xref: /haiku/headers/private/interface/ViewPrivate.h (revision 1acbe440b8dd798953bec31d18ee589aa3f71b73)
1 /*
2  * Copyright 2003-2006, Haiku.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Adrian Oanca <adioanca@cotty.iren.ro>
7  *		Axel Dörfler, axeld@pinc-software.de
8  */
9 #ifndef VIEW_PRIVATE_H
10 #define VIEW_PRIVATE_H
11 
12 
13 #include <PortLink.h>
14 
15 #include <Font.h>
16 #include <InterfaceDefs.h>
17 #include <Point.h>
18 #include <Rect.h>
19 #include <Region.h>
20 
21 const static uint32 kDeleteReplicant = 'JAHA';
22 
23 enum {
24 	B_VIEW_FONT_BIT				= 0x00000001,
25 	B_VIEW_HIGH_COLOR_BIT		= 0x00000002,
26 	B_VIEW_DRAWING_MODE_BIT		= 0x00000004,
27 	B_VIEW_CLIP_REGION_BIT		= 0x00000008,
28 	B_VIEW_LINE_MODES_BIT		= 0x00000010,
29 	B_VIEW_BLENDING_BIT			= 0x00000020,
30 	B_VIEW_SCALE_BIT			= 0x00000040,
31 	B_VIEW_FONT_ALIASING_BIT	= 0x00000080,
32 	B_VIEW_FRAME_BIT			= 0x00000100,
33 	B_VIEW_ORIGIN_BIT			= 0x00000200,
34 	B_VIEW_PEN_SIZE_BIT			= 0x00000400,
35 	B_VIEW_PEN_LOCATION_BIT		= 0x00000800,
36 	B_VIEW_LOW_COLOR_BIT		= 0x00008000,
37 	B_VIEW_VIEW_COLOR_BIT		= 0x00010000,
38 	B_VIEW_PATTERN_BIT			= 0x00020000,
39 
40 	B_VIEW_ALL_BITS				= 0x0003ffff,
41 
42 	// these used for archiving only
43 	B_VIEW_RESIZE_BIT			= 0x00001000,
44 	B_VIEW_FLAGS_BIT			= 0x00002000,
45 	B_VIEW_EVENT_MASK_BIT		= 0x00004000
46 };
47 
48 
49 namespace BPrivate {
50 
51 class ViewState {
52 	public:
53 		ViewState();
54 
55 		inline bool IsValid(uint32 bit) const;
56 		inline bool IsAllValid() const;
57 
58 		void UpdateServerFontState(BPrivate::PortLink &link);
59 		void UpdateServerState(BPrivate::PortLink &link);
60 
61 		void UpdateFrom(BPrivate::PortLink &link);
62 
63 	public:
64 		BPoint				pen_location;
65 		float				pen_size;
66 
67 		rgb_color			high_color;
68 		rgb_color			low_color;
69 
70 		// This one is not affected by pop state/push state
71 		rgb_color			view_color;
72 
73 		::pattern			pattern;
74 
75 		::drawing_mode		drawing_mode;
76 		BRegion				clipping_region;
77 		bool				clipping_region_used;
78 		BPoint				origin;
79 
80 		// line modes
81 		join_mode			line_join;
82 		cap_mode			line_cap;
83 		float				miter_limit;
84 
85 		// alpha blending
86 		source_alpha		alpha_source_mode;
87 		alpha_function		alpha_function_mode;
88 
89 		float				scale;
90 
91 		// fonts
92 		BFont				font;
93 		uint16				font_flags;
94 		bool				font_aliasing;
95 			// font aliasing. Used for printing only!
96 
97 		// flags used for synchronization with app_server
98 		uint32				valid_flags;
99 		// flags used for archiving
100 		uint32				archiving_flags;
101 };
102 
103 inline bool
104 ViewState::IsValid(uint32 bit) const
105 {
106 	return valid_flags & bit;
107 }
108 
109 inline bool
110 ViewState::IsAllValid() const
111 {
112 	return (valid_flags & B_VIEW_ALL_BITS & ~B_VIEW_CLIP_REGION_BIT)
113 		== (B_VIEW_ALL_BITS & ~B_VIEW_CLIP_REGION_BIT);
114 }
115 
116 }	// namespace BPrivate
117 
118 struct _array_hdr_{
119 	float			startX;
120 	float			startY;
121 	float			endX;
122 	float			endY;
123 	rgb_color		color;
124 };
125 
126 struct _array_data_{
127 		// the max number of points in the array
128 	uint32			maxCount;
129 		// the current number of points in the array
130 	uint32			count;
131 		// the array of points
132 	_array_hdr_*	array;
133 };
134 
135 #endif	/* VIEW_PRIVATE_H */
136