xref: /haiku/headers/private/interface/ViewPrivate.h (revision 778611c7e6a61b8ba072212756ce53eda826360a)
1 /*
2  * Copyright 2003-2008, 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 <Font.h>
14 #include <InterfaceDefs.h>
15 #include <Point.h>
16 #include <Rect.h>
17 #include <Region.h>
18 #include <ServerProtocolStructs.h>
19 #include <View.h>
20 
21 const static uint32 kDeleteReplicant = 'JAHA';
22 
23 const static uint32 kWorkspacesViewFlag = 0x40000000UL;
24 	// was/is _B_RESERVED1_ in View.h
25 
26 enum {
27 	B_VIEW_FONT_BIT				= 0x00000001,
28 	B_VIEW_HIGH_COLOR_BIT		= 0x00000002,
29 	B_VIEW_DRAWING_MODE_BIT		= 0x00000004,
30 	B_VIEW_CLIP_REGION_BIT		= 0x00000008,
31 	B_VIEW_LINE_MODES_BIT		= 0x00000010,
32 	B_VIEW_BLENDING_BIT			= 0x00000020,
33 	B_VIEW_SCALE_BIT			= 0x00000040,
34 	B_VIEW_FONT_ALIASING_BIT	= 0x00000080,
35 	B_VIEW_FRAME_BIT			= 0x00000100,
36 	B_VIEW_ORIGIN_BIT			= 0x00000200,
37 	B_VIEW_PEN_SIZE_BIT			= 0x00000400,
38 	B_VIEW_PEN_LOCATION_BIT		= 0x00000800,
39 	B_VIEW_LOW_COLOR_BIT		= 0x00008000,
40 	B_VIEW_VIEW_COLOR_BIT		= 0x00010000,
41 	B_VIEW_PATTERN_BIT			= 0x00020000,
42 	B_VIEW_TRANSFORM_BIT		= 0x00040000,
43 	B_VIEW_FILL_RULE_BIT		= 0x00080000,
44 
45 	B_VIEW_ALL_BITS				= 0x000fffff,
46 
47 	// these used for archiving only
48 	B_VIEW_RESIZE_BIT			= 0x00001000,
49 	B_VIEW_FLAGS_BIT			= 0x00002000,
50 	B_VIEW_EVENT_MASK_BIT		= 0x00004000
51 };
52 
53 
54 class BView::Private {
55 public:
56 	Private(BView* view)
57 		:
58 		fView(view)
59 	{
60 	}
61 
62 	int16 ShowLevel()
63 	{
64 		return fView->fShowLevel;
65 	}
66 
67 	// defined in View.cpp
68 	bool	WillLayout();
69 	bool	MinMaxValid();
70 
71 	BLayoutItem* LayoutItemAt(int32 index);
72 	int32	CountLayoutItems();
73 	void	RegisterLayoutItem(BLayoutItem* item);
74 	void	DeregisterLayoutItem(BLayoutItem* item);
75 
76 	bool RemoveSelf()
77 	{
78 		return fView->_RemoveSelf();
79 	}
80 
81 	BView* fView;
82 };
83 
84 
85 namespace BPrivate {
86 
87 class PortLink;
88 
89 class ViewState {
90 	public:
91 		ViewState();
92 
93 		inline bool IsValid(uint32 bit) const;
94 		inline bool IsAllValid() const;
95 
96 		void UpdateServerFontState(BPrivate::PortLink &link);
97 		void UpdateServerState(BPrivate::PortLink &link);
98 
99 		void UpdateFrom(BPrivate::PortLink &link);
100 
101 	public:
102 		BPoint				pen_location;
103 		float				pen_size;
104 
105 		rgb_color			high_color;
106 		rgb_color			low_color;
107 
108 		// This one is not affected by pop state/push state
109 		rgb_color			view_color;
110 
111 		::pattern			pattern;
112 
113 		::drawing_mode		drawing_mode;
114 		BRegion				clipping_region;
115 		bool				clipping_region_used;
116 
117 		// transformation
118 		BPoint				origin;
119 		float				scale;
120 		BAffineTransform	transform;
121 
122 		// line modes
123 		join_mode			line_join;
124 		cap_mode			line_cap;
125 		float				miter_limit;
126 
127 		// fill rule
128 		int32				fill_rule;
129 
130 		// alpha blending
131 		source_alpha		alpha_source_mode;
132 		alpha_function		alpha_function_mode;
133 
134 		// fonts
135 		BFont				font;
136 		uint16				font_flags;
137 		bool				font_aliasing;
138 			// font aliasing. Used for printing only!
139 
140 		// flags used for synchronization with app_server
141 		uint32				valid_flags;
142 		// flags used for archiving
143 		uint32				archiving_flags;
144 
145 		// maintain our own rect as seen from the app while printing
146 		BRect				print_rect;
147 };
148 
149 inline bool
150 ViewState::IsValid(uint32 bit) const
151 {
152 	return valid_flags & bit;
153 }
154 
155 inline bool
156 ViewState::IsAllValid() const
157 {
158 	return (valid_flags & B_VIEW_ALL_BITS & ~B_VIEW_CLIP_REGION_BIT)
159 		== (B_VIEW_ALL_BITS & ~B_VIEW_CLIP_REGION_BIT);
160 }
161 
162 }	// namespace BPrivate
163 
164 struct _array_data_{
165 		// the max number of points in the array
166 	uint32				maxCount;
167 		// the current number of points in the array
168 	uint32				count;
169 		// the array of points
170 	ViewLineArrayInfo*	array;
171 };
172 
173 #endif	/* VIEW_PRIVATE_H */
174