ViewPrivate.h revision b617d006
1/*
2 * Copyright 2003-2015, 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
22const static uint32 kDeleteReplicant = 'JAHA';
23
24const static uint32 kWorkspacesViewFlag = 0x40000000UL;
25	// was/is _B_RESERVED1_ in View.h
26
27enum {
28	B_VIEW_FONT_BIT				= 0x00000001,
29	B_VIEW_HIGH_COLOR_BIT		= 0x00000002,
30	B_VIEW_DRAWING_MODE_BIT		= 0x00000004,
31	B_VIEW_CLIP_REGION_BIT		= 0x00000008,
32	B_VIEW_LINE_MODES_BIT		= 0x00000010,
33	B_VIEW_BLENDING_BIT			= 0x00000020,
34	B_VIEW_SCALE_BIT			= 0x00000040,
35	B_VIEW_FONT_ALIASING_BIT	= 0x00000080,
36	B_VIEW_FRAME_BIT			= 0x00000100,
37	B_VIEW_ORIGIN_BIT			= 0x00000200,
38	B_VIEW_PEN_SIZE_BIT			= 0x00000400,
39	B_VIEW_PEN_LOCATION_BIT		= 0x00000800,
40	B_VIEW_LOW_COLOR_BIT		= 0x00008000,
41	B_VIEW_VIEW_COLOR_BIT		= 0x00010000,
42	B_VIEW_PATTERN_BIT			= 0x00020000,
43	B_VIEW_TRANSFORM_BIT		= 0x00040000,
44	B_VIEW_FILL_RULE_BIT		= 0x00080000,
45
46	B_VIEW_ALL_BITS				= 0x000fffff,
47
48	// these used for archiving only
49	B_VIEW_RESIZE_BIT			= 0x00001000,
50	B_VIEW_FLAGS_BIT			= 0x00002000,
51	B_VIEW_EVENT_MASK_BIT		= 0x00004000
52};
53
54
55class BView::Private {
56public:
57								Private(BView* view)
58									:
59									fView(view)
60								{
61								}
62
63			int16				ShowLevel()
64									{ return fView->fShowLevel; }
65
66			// defined in View.cpp
67			bool				WillLayout();
68			bool				MinMaxValid();
69
70			BLayoutItem*		LayoutItemAt(int32 index);
71			int32				CountLayoutItems();
72			void				RegisterLayoutItem(BLayoutItem* item);
73			void				DeregisterLayoutItem(BLayoutItem* item);
74
75			bool				RemoveSelf()
76									{ return fView->_RemoveSelf(); }
77
78private:
79			BView* fView;
80};
81
82
83namespace BPrivate {
84
85
86class PortLink;
87
88
89class 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
150inline bool
151ViewState::IsValid(uint32 bit) const
152{
153	return valid_flags & bit;
154}
155
156
157inline bool
158ViewState::IsAllValid() const
159{
160	return (valid_flags & B_VIEW_ALL_BITS & ~B_VIEW_CLIP_REGION_BIT)
161		== (B_VIEW_ALL_BITS & ~B_VIEW_CLIP_REGION_BIT);
162}
163
164
165}	// namespace BPrivate
166
167
168struct _array_data_{
169		// the max number of points in the array
170	uint32				maxCount;
171		// the current number of points in the array
172	uint32				count;
173		// the array of points
174	ViewLineArrayInfo*	array;
175};
176
177
178#endif	/* VIEW_PRIVATE_H */
179