xref: /haiku/headers/private/interface/ViewPrivate.h (revision f2b4344867e97c3f4e742a1b4a15e6879644601a)
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 
43 	B_VIEW_ALL_BITS				= 0x0003ffff,
44 
45 	// these used for archiving only
46 	B_VIEW_RESIZE_BIT			= 0x00001000,
47 	B_VIEW_FLAGS_BIT			= 0x00002000,
48 	B_VIEW_EVENT_MASK_BIT		= 0x00004000
49 };
50 
51 
52 class BView::Private {
53 public:
54 	Private(BView* view)
55 		:
56 		fView(view)
57 	{
58 	}
59 
60 	int16 ShowLevel()
61 	{
62 		return fView->fShowLevel;
63 	}
64 
65 	// defined in View.cpp
66 	bool	WillLayout();
67 	bool	MinMaxValid();
68 
69 	BLayoutItem* LayoutItemAt(int32 index);
70 	int32	CountLayoutItems();
71 	void	RegisterLayoutItem(BLayoutItem* item);
72 	void	DeregisterLayoutItem(BLayoutItem* item);
73 
74 	bool RemoveSelf()
75 	{
76 		return fView->_RemoveSelf();
77 	}
78 
79 	BView* fView;
80 };
81 
82 
83 namespace BPrivate {
84 
85 class PortLink;
86 
87 class ViewState {
88 	public:
89 		ViewState();
90 
91 		inline bool IsValid(uint32 bit) const;
92 		inline bool IsAllValid() const;
93 
94 		void UpdateServerFontState(BPrivate::PortLink &link);
95 		void UpdateServerState(BPrivate::PortLink &link);
96 
97 		void UpdateFrom(BPrivate::PortLink &link);
98 
99 	public:
100 		BPoint				pen_location;
101 		float				pen_size;
102 
103 		rgb_color			high_color;
104 		rgb_color			low_color;
105 
106 		// This one is not affected by pop state/push state
107 		rgb_color			view_color;
108 
109 		::pattern			pattern;
110 
111 		::drawing_mode		drawing_mode;
112 		BRegion				clipping_region;
113 		bool				clipping_region_used;
114 		BPoint				origin;
115 
116 		// line modes
117 		join_mode			line_join;
118 		cap_mode			line_cap;
119 		float				miter_limit;
120 
121 		// alpha blending
122 		source_alpha		alpha_source_mode;
123 		alpha_function		alpha_function_mode;
124 
125 		float				scale;
126 
127 		// fonts
128 		BFont				font;
129 		uint16				font_flags;
130 		bool				font_aliasing;
131 			// font aliasing. Used for printing only!
132 
133 		// flags used for synchronization with app_server
134 		uint32				valid_flags;
135 		// flags used for archiving
136 		uint32				archiving_flags;
137 
138 		// maintain our own rect as seen from the app while printing
139 		BRect				print_rect;
140 };
141 
142 inline bool
143 ViewState::IsValid(uint32 bit) const
144 {
145 	return valid_flags & bit;
146 }
147 
148 inline bool
149 ViewState::IsAllValid() const
150 {
151 	return (valid_flags & B_VIEW_ALL_BITS & ~B_VIEW_CLIP_REGION_BIT)
152 		== (B_VIEW_ALL_BITS & ~B_VIEW_CLIP_REGION_BIT);
153 }
154 
155 }	// namespace BPrivate
156 
157 struct _array_data_{
158 		// the max number of points in the array
159 	uint32				maxCount;
160 		// the current number of points in the array
161 	uint32				count;
162 		// the array of points
163 	ViewLineArrayInfo*	array;
164 };
165 
166 #endif	/* VIEW_PRIVATE_H */
167