xref: /haiku/headers/private/interface/ViewPrivate.h (revision 675ffabd70492a962f8c0288a32208c22ce5de18)
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 	BView* fView;
70 };
71 
72 
73 namespace BPrivate {
74 
75 class PortLink;
76 
77 class ViewState {
78 	public:
79 		ViewState();
80 
81 		inline bool IsValid(uint32 bit) const;
82 		inline bool IsAllValid() const;
83 
84 		void UpdateServerFontState(BPrivate::PortLink &link);
85 		void UpdateServerState(BPrivate::PortLink &link);
86 
87 		void UpdateFrom(BPrivate::PortLink &link);
88 
89 	public:
90 		BPoint				pen_location;
91 		float				pen_size;
92 
93 		rgb_color			high_color;
94 		rgb_color			low_color;
95 
96 		// This one is not affected by pop state/push state
97 		rgb_color			view_color;
98 
99 		::pattern			pattern;
100 
101 		::drawing_mode		drawing_mode;
102 		BRegion				clipping_region;
103 		bool				clipping_region_used;
104 		BPoint				origin;
105 
106 		// line modes
107 		join_mode			line_join;
108 		cap_mode			line_cap;
109 		float				miter_limit;
110 
111 		// alpha blending
112 		source_alpha		alpha_source_mode;
113 		alpha_function		alpha_function_mode;
114 
115 		float				scale;
116 
117 		// fonts
118 		BFont				font;
119 		uint16				font_flags;
120 		bool				font_aliasing;
121 			// font aliasing. Used for printing only!
122 
123 		// flags used for synchronization with app_server
124 		uint32				valid_flags;
125 		// flags used for archiving
126 		uint32				archiving_flags;
127 
128 		// maintain our own rect as seen from the app while printing
129 		BRect				print_rect;
130 };
131 
132 inline bool
133 ViewState::IsValid(uint32 bit) const
134 {
135 	return valid_flags & bit;
136 }
137 
138 inline bool
139 ViewState::IsAllValid() const
140 {
141 	return (valid_flags & B_VIEW_ALL_BITS & ~B_VIEW_CLIP_REGION_BIT)
142 		== (B_VIEW_ALL_BITS & ~B_VIEW_CLIP_REGION_BIT);
143 }
144 
145 }	// namespace BPrivate
146 
147 struct _array_data_{
148 		// the max number of points in the array
149 	uint32				maxCount;
150 		// the current number of points in the array
151 	uint32				count;
152 		// the array of points
153 	ViewLineArrayInfo*	array;
154 };
155 
156 #endif	/* VIEW_PRIVATE_H */
157