xref: /haiku/headers/os/interface/View.h (revision 52c4471a3024d2eb81fe88e2c3982b9f8daa5e56)
1 /*
2  * Copyright 2001-2020 Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef	_VIEW_H
6 #define	_VIEW_H
7 
8 
9 #include <AffineTransform.h>
10 #include <Alignment.h>
11 #include <Font.h>
12 #include <Handler.h>
13 #include <InterfaceDefs.h>
14 #include <Rect.h>
15 #include <Gradient.h>
16 
17 
18 // mouse button
19 #define B_MOUSE_BUTTON(n) (1 << ((n) - 1))
20 
21 // Legacy BeOS R5 mouse button definitions
22 enum {
23 	B_PRIMARY_MOUSE_BUTTON				= B_MOUSE_BUTTON(1),
24 	B_SECONDARY_MOUSE_BUTTON			= B_MOUSE_BUTTON(2),
25 	B_TERTIARY_MOUSE_BUTTON				= B_MOUSE_BUTTON(3)
26 };
27 
28 // mouse transit
29 enum {
30 	B_ENTERED_VIEW						= 0,
31 	B_INSIDE_VIEW,
32 	B_EXITED_VIEW,
33 	B_OUTSIDE_VIEW
34 };
35 
36 // event mask
37 enum {
38 	B_POINTER_EVENTS					= 0x00000001,
39 	B_KEYBOARD_EVENTS					= 0x00000002
40 };
41 
42 // event mask options
43 enum {
44 	B_LOCK_WINDOW_FOCUS					= 0x00000001,
45 	B_SUSPEND_VIEW_FOCUS				= 0x00000002,
46 	B_NO_POINTER_HISTORY				= 0x00000004,
47 		// NOTE: This is the default behavior in Haiku, unlike in BeOS
48 	B_FULL_POINTER_HISTORY				= 0x00000008
49 		// NOTE: New in Haiku (unless this flag is
50 		// specified, both BWindow and BView::GetMouse()
51 		// will filter out older mouse moved messages)
52 };
53 
54 enum {
55 	B_TRACK_WHOLE_RECT,
56 	B_TRACK_RECT_CORNER
57 };
58 
59 // set font mask
60 enum {
61 	B_FONT_FAMILY_AND_STYLE				= 0x00000001,
62 	B_FONT_SIZE							= 0x00000002,
63 	B_FONT_SHEAR						= 0x00000004,
64 	B_FONT_ROTATION						= 0x00000008,
65 	B_FONT_SPACING						= 0x00000010,
66 	B_FONT_ENCODING						= 0x00000020,
67 	B_FONT_FACE							= 0x00000040,
68 	B_FONT_FLAGS						= 0x00000080,
69 	B_FONT_FALSE_BOLD_WIDTH				= 0x00000100,
70 	B_FONT_ALL							= 0x000001FF
71 };
72 
73 typedef enum {
74 	B_CURRENT_STATE_COORDINATES,
75 	B_PREVIOUS_STATE_COORDINATES,
76 	B_VIEW_COORDINATES,
77 	B_PARENT_VIEW_DRAW_COORDINATES,
78 	B_PARENT_VIEW_COORDINATES,
79 	B_WINDOW_COORDINATES,
80 	B_SCREEN_COORDINATES
81 } coordinate_space;
82 
83 // view flags
84 const uint32 B_FULL_UPDATE_ON_RESIZE	= 0x80000000UL;	/* 31 */
85 const uint32 _B_RESERVED1_				= 0x40000000UL;	/* 30 */
86 const uint32 B_WILL_DRAW				= 0x20000000UL;	/* 29 */
87 const uint32 B_PULSE_NEEDED				= 0x10000000UL;	/* 28 */
88 const uint32 B_NAVIGABLE_JUMP			= 0x08000000UL;	/* 27 */
89 const uint32 B_FRAME_EVENTS				= 0x04000000UL;	/* 26 */
90 const uint32 B_NAVIGABLE				= 0x02000000UL;	/* 25 */
91 const uint32 B_SUBPIXEL_PRECISE			= 0x01000000UL;	/* 24 */
92 const uint32 B_DRAW_ON_CHILDREN			= 0x00800000UL;	/* 23 */
93 const uint32 B_INPUT_METHOD_AWARE		= 0x00400000UL;	/* 22 */
94 const uint32 B_SCROLL_VIEW_AWARE		= 0x00200000UL;	/* 21 */
95 const uint32 B_SUPPORTS_LAYOUT			= 0x00100000UL;	/* 20 */
96 const uint32 B_INVALIDATE_AFTER_LAYOUT	= 0x00080000UL;	/* 19 */
97 const uint32 B_TRANSPARENT_BACKGROUND	= 0x00040000UL;	/* 18 */
98 
99 #define _RESIZE_MASK_ (0xffff)
100 
101 const uint32 _VIEW_TOP_					= 1UL;
102 const uint32 _VIEW_LEFT_				= 2UL;
103 const uint32 _VIEW_BOTTOM_				= 3UL;
104 const uint32 _VIEW_RIGHT_				= 4UL;
105 const uint32 _VIEW_CENTER_				= 5UL;
106 
107 inline uint32 _rule_(uint32 r1, uint32 r2, uint32 r3, uint32 r4)
108 	{ return ((r1 << 12) | (r2 << 8) | (r3 << 4) | r4); }
109 
110 #define B_FOLLOW_NONE 0
111 #define B_FOLLOW_ALL_SIDES	_rule_(_VIEW_TOP_, _VIEW_LEFT_, _VIEW_BOTTOM_, \
112 								_VIEW_RIGHT_)
113 #define B_FOLLOW_ALL		B_FOLLOW_ALL_SIDES
114 
115 #define B_FOLLOW_LEFT		_rule_(0, _VIEW_LEFT_, 0, _VIEW_LEFT_)
116 #define B_FOLLOW_RIGHT		_rule_(0, _VIEW_RIGHT_, 0, _VIEW_RIGHT_)
117 #define B_FOLLOW_LEFT_RIGHT	_rule_(0, _VIEW_LEFT_, 0, _VIEW_RIGHT_)
118 #define B_FOLLOW_H_CENTER	_rule_(0, _VIEW_CENTER_, 0, _VIEW_CENTER_)
119 
120 #define B_FOLLOW_TOP		_rule_(_VIEW_TOP_, 0, _VIEW_TOP_, 0)
121 #define B_FOLLOW_BOTTOM		_rule_(_VIEW_BOTTOM_, 0, _VIEW_BOTTOM_, 0)
122 #define B_FOLLOW_TOP_BOTTOM	_rule_(_VIEW_TOP_, 0, _VIEW_BOTTOM_, 0)
123 #define B_FOLLOW_V_CENTER	_rule_(_VIEW_CENTER_, 0, _VIEW_CENTER_, 0)
124 
125 #define B_FOLLOW_LEFT_TOP	B_FOLLOW_TOP | B_FOLLOW_LEFT
126 
127 class BBitmap;
128 class BCursor;
129 class BLayout;
130 class BLayoutContext;
131 class BLayoutItem;
132 class BMessage;
133 class BPicture;
134 class BPolygon;
135 class BRegion;
136 class BScrollBar;
137 class BScrollView;
138 class BShape;
139 class BShelf;
140 class BString;
141 class BToolTip;
142 class BWindow;
143 struct _array_data_;
144 struct _array_hdr_;
145 struct overlay_restrictions;
146 
147 namespace BPrivate {
148 	class ViewState;
149 };
150 
151 
152 class BView : public BHandler {
153 public:
154 								BView(const char* name, uint32 flags,
155 									BLayout* layout = NULL);
156 								BView(BRect frame, const char* name,
157 									uint32 resizingMode, uint32 flags);
158 	virtual						~BView();
159 
160 								BView(BMessage* archive);
161 	static	BArchivable*		Instantiate(BMessage* archive);
162 	virtual	status_t			Archive(BMessage* archive,
163 									bool deep = true) const;
164 	virtual	status_t			AllUnarchived(const BMessage* archive);
165 	virtual status_t			AllArchived(BMessage* archive) const;
166 
167 	virtual	void				AttachedToWindow();
168 	virtual	void				AllAttached();
169 	virtual	void				DetachedFromWindow();
170 	virtual	void				AllDetached();
171 
172 	virtual	void				MessageReceived(BMessage* message);
173 
174 			void				AddChild(BView* child, BView* before = NULL);
175 			bool				AddChild(BLayoutItem* child);
176 			bool				RemoveChild(BView* child);
177 			int32				CountChildren() const;
178 			BView*				ChildAt(int32 index) const;
179 			BView*				NextSibling() const;
180 			BView*				PreviousSibling() const;
181 			bool				RemoveSelf();
182 
183 			BWindow*			Window() const;
184 
185 	virtual	void				Draw(BRect updateRect);
186 	virtual	void				MouseDown(BPoint where);
187 	virtual	void				MouseUp(BPoint where);
188 	virtual	void				MouseMoved(BPoint where, uint32 code,
189 									const BMessage* dragMessage);
190 	virtual	void				WindowActivated(bool active);
191 	virtual	void				KeyDown(const char* bytes, int32 numBytes);
192 	virtual	void				KeyUp(const char* bytes, int32 numBytes);
193 	virtual	void				Pulse();
194 	virtual	void				FrameMoved(BPoint newPosition);
195 	virtual	void				FrameResized(float newWidth, float newHeight);
196 
197 	virtual	void				TargetedByScrollView(BScrollView* scrollView);
198 			void				BeginRectTracking(BRect startRect,
199 									uint32 style = B_TRACK_WHOLE_RECT);
200 			void				EndRectTracking();
201 
202 			void				GetMouse(BPoint* location, uint32* buttons,
203 									bool checkMessageQueue = true);
204 
205 			void				DragMessage(BMessage* message, BRect dragRect,
206 									BHandler* replyTo = NULL);
207 			void				DragMessage(BMessage* message, BBitmap* bitmap,
208 									BPoint offset, BHandler* replyTo = NULL);
209 			void				DragMessage(BMessage* message, BBitmap* bitmap,
210 									drawing_mode dragMode, BPoint offset,
211 									BHandler* replyTo = NULL);
212 
213 			BView*				FindView(const char* name) const;
214 			BView*				Parent() const;
215 			BRect				Bounds() const;
216 			BRect				Frame() const;
217 			void				ConvertToScreen(BPoint* point) const;
218 			BPoint				ConvertToScreen(BPoint point) const;
219 			void				ConvertFromScreen(BPoint* point) const;
220 			BPoint				ConvertFromScreen(BPoint point) const;
221 			void				ConvertToScreen(BRect* rect) const;
222 			BRect				ConvertToScreen(BRect rect) const;
223 			void				ConvertFromScreen(BRect* rect) const;
224 			BRect				ConvertFromScreen(BRect rect) const;
225 			void				ConvertToParent(BPoint* point) const;
226 			BPoint				ConvertToParent(BPoint point) const;
227 			void				ConvertFromParent(BPoint* point) const;
228 			BPoint				ConvertFromParent(BPoint point) const;
229 			void				ConvertToParent(BRect* rect) const;
230 			BRect				ConvertToParent(BRect rect) const;
231 			void				ConvertFromParent(BRect* rect) const;
232 			BRect				ConvertFromParent(BRect rect) const;
233 			BPoint				LeftTop() const;
234 
235 			void				GetClippingRegion(BRegion* region) const;
236 	virtual	void				ConstrainClippingRegion(BRegion* region);
237 			void				ClipToPicture(BPicture* picture,
238 									BPoint where = B_ORIGIN, bool sync = true);
239 			void				ClipToInversePicture(BPicture* picture,
240 									BPoint where = B_ORIGIN, bool sync = true);
241 
242 			void				ClipToRect(BRect rect);
243 			void				ClipToInverseRect(BRect rect);
244 			void				ClipToShape(BShape* shape);
245 			void				ClipToInverseShape(BShape* shape);
246 
247 	virtual	void				SetDrawingMode(drawing_mode mode);
248 			drawing_mode		DrawingMode() const;
249 
250 			void				SetBlendingMode(source_alpha srcAlpha,
251 									alpha_function alphaFunc);
252 			void				GetBlendingMode(source_alpha* srcAlpha,
253 									alpha_function* alphaFunc) const;
254 
255 	virtual	void				SetPenSize(float size);
256 			float				PenSize() const;
257 
258 			void				SetViewCursor(const BCursor* cursor,
259 									bool sync = true);
260 
261 			bool				HasDefaultColors() const;
262 			bool				HasSystemColors() const;
263 			void				AdoptParentColors();
264 			void				AdoptSystemColors();
265 			void				AdoptViewColors(BView* view);
266 
267 	virtual	void				SetViewColor(rgb_color color);
268 			void				SetViewColor(uchar red, uchar green, uchar blue,
269 									uchar alpha = 255);
270 			rgb_color			ViewColor() const;
271 
272 			void				SetViewUIColor(color_which which,
273 									float tint = B_NO_TINT);
274 			color_which			ViewUIColor(float* tint = NULL) const;
275 
276 			void				SetViewBitmap(const BBitmap* bitmap,
277 									BRect srcRect, BRect dstRect,
278 									uint32 followFlags = B_FOLLOW_LEFT_TOP,
279 									uint32 options = B_TILE_BITMAP);
280 			void				SetViewBitmap(const BBitmap* bitmap,
281 									uint32 followFlags = B_FOLLOW_LEFT_TOP,
282 									uint32 options = B_TILE_BITMAP);
283 			void				ClearViewBitmap();
284 
285 			status_t			SetViewOverlay(const BBitmap* overlay,
286 									BRect srcRect, BRect dstRect,
287 									rgb_color* colorKey,
288 									uint32 followFlags = B_FOLLOW_LEFT_TOP,
289 									uint32 options = 0);
290 			status_t			SetViewOverlay(const BBitmap* overlay,
291 									rgb_color* colorKey,
292 									uint32 followFlags = B_FOLLOW_LEFT_TOP,
293 									uint32 options = 0);
294 			void				ClearViewOverlay();
295 
296 	virtual	void				SetHighColor(rgb_color color);
297 			void				SetHighColor(uchar red, uchar green, uchar blue,
298 									uchar alpha = 255);
299 			rgb_color			HighColor() const;
300 
301 			void				SetHighUIColor(color_which which,
302 									float tint = B_NO_TINT);
303 			color_which			HighUIColor(float* tint = NULL) const;
304 
305 	virtual	void				SetLowColor(rgb_color color);
306 			void				SetLowColor(uchar red, uchar green, uchar blue,
307 									uchar alpha = 255);
308 			rgb_color			LowColor() const;
309 
310 			void				SetLowUIColor(color_which which,
311 									float tint = B_NO_TINT);
312 			color_which			LowUIColor(float* tint = NULL) const;
313 
314 			void				SetLineMode(cap_mode lineCap,
315 									join_mode lineJoin,
316 									float miterLimit = B_DEFAULT_MITER_LIMIT);
317 			join_mode			LineJoinMode() const;
318 			cap_mode			LineCapMode() const;
319 			float				LineMiterLimit() const;
320 
321 			void				SetFillRule(int32 rule);
322 			int32				FillRule() const;
323 
324 			void				SetOrigin(BPoint where);
325 			void				SetOrigin(float x, float y);
326 			BPoint				Origin() const;
327 
328 								// Works in addition to Origin and Scale.
329 								// May be used in parallel or as a much
330 								// more powerful alternative.
331 			void				SetTransform(BAffineTransform transform);
332 			BAffineTransform	Transform() const;
333 			void				TranslateBy(double x, double y);
334 			void				ScaleBy(double x, double y);
335 			void				RotateBy(double angleRadians);
336 
337 			BAffineTransform	TransformTo(coordinate_space basis) const;
338 
339 			void				PushState();
340 			void				PopState();
341 
342 			void				MovePenTo(BPoint pt);
343 			void				MovePenTo(float x, float y);
344 			void				MovePenBy(float x, float y);
345 			BPoint				PenLocation() const;
346 			void				StrokeLine(BPoint toPoint,
347 									::pattern pattern = B_SOLID_HIGH);
348 			void				StrokeLine(BPoint start, BPoint end,
349 									::pattern pattern = B_SOLID_HIGH);
350 			void				BeginLineArray(int32 count);
351 			void				AddLine(BPoint start, BPoint end,
352 									rgb_color color);
353 			void				EndLineArray();
354 
355 			void				StrokePolygon(const BPolygon* polygon,
356 									bool closed = true,
357 									::pattern pattern = B_SOLID_HIGH);
358 			void				StrokePolygon(const BPoint* pointArray,
359 									int32 numPoints, bool closed = true,
360 									::pattern pattern = B_SOLID_HIGH);
361 			void				StrokePolygon(const BPoint* pointArray,
362 									int32 numPoints, BRect bounds,
363 									bool closed = true,
364 									::pattern pattern = B_SOLID_HIGH);
365 			void				FillPolygon(const BPolygon* polygon,
366 									::pattern pattern = B_SOLID_HIGH);
367 			void				FillPolygon(const BPoint* pointArray,
368 									int32 numPoints,
369 									::pattern pattern = B_SOLID_HIGH);
370 			void				FillPolygon(const BPoint* pointArray,
371 									int32 numPoints, BRect bounds,
372 									::pattern pattern = B_SOLID_HIGH);
373 			void				FillPolygon(const BPolygon* polygon,
374 									const BGradient& gradient);
375 			void				FillPolygon(const BPoint* pointArray,
376 									int32 numPoints, const BGradient& gradient);
377 			void				FillPolygon(const BPoint* pointArray,
378 									int32 numPoints, BRect bounds,
379 									const BGradient& gradient);
380 
381 			void				StrokeTriangle(BPoint point1, BPoint point2,
382 									BPoint point3, BRect bounds,
383 									::pattern pattern = B_SOLID_HIGH);
384 			void				StrokeTriangle(BPoint point1, BPoint point2,
385 									BPoint point3,
386 									::pattern pattern = B_SOLID_HIGH);
387 			void				FillTriangle(BPoint point1, BPoint point2,
388 									BPoint point3,
389 									::pattern pattern = B_SOLID_HIGH);
390 			void				FillTriangle(BPoint point1, BPoint point2,
391 									BPoint point3, BRect bounds,
392 									::pattern pattern = B_SOLID_HIGH);
393 			void				FillTriangle(BPoint point1, BPoint point2,
394 									BPoint point3, const BGradient& gradient);
395 			void				FillTriangle(BPoint point1, BPoint point2,
396 									BPoint point3, BRect bounds,
397 									const BGradient& gradient);
398 
399 			void				StrokeRect(BRect rect,
400 									::pattern pattern = B_SOLID_HIGH);
401 			void				FillRect(BRect rect,
402 									::pattern pattern = B_SOLID_HIGH);
403 			void				FillRect(BRect rect, const BGradient& gradient);
404 			void				FillRegion(BRegion* rectegion,
405 									::pattern pattern = B_SOLID_HIGH);
406 			void				FillRegion(BRegion* rectegion,
407 									const BGradient& gradient);
408 			void				InvertRect(BRect rect);
409 
410 			void				StrokeRoundRect(BRect rect, float xRadius,
411 									float yRadius,
412 									::pattern pattern = B_SOLID_HIGH);
413 			void				FillRoundRect(BRect rect, float xRadius,
414 									float yRadius,
415 									::pattern pattern = B_SOLID_HIGH);
416 			void				FillRoundRect(BRect rect, float xRadius,
417 									float yRadius, const BGradient& gradient);
418 
419 			void				StrokeEllipse(BPoint center, float xRadius,
420 									float yRadius,
421 									::pattern pattern = B_SOLID_HIGH);
422 			void				StrokeEllipse(BRect rect,
423 									::pattern pattern = B_SOLID_HIGH);
424 			void				FillEllipse(BPoint center, float xRadius,
425 									float yRadius,
426 									::pattern pattern = B_SOLID_HIGH);
427 			void				FillEllipse(BRect rect,
428 									::pattern pattern = B_SOLID_HIGH);
429 			void				FillEllipse(BPoint center, float xRadius,
430 									float yRadius, const BGradient& gradient);
431 			void				FillEllipse(BRect rect,
432 									const BGradient& gradient);
433 
434 			void				StrokeArc(BPoint center, float xRadius,
435 									float yRadius, float startAngle,
436 									float arcAngle,
437 									::pattern pattern = B_SOLID_HIGH);
438 			void				StrokeArc(BRect rect, float startAngle,
439 									float arcAngle,
440 									::pattern pattern = B_SOLID_HIGH);
441 			void				FillArc(BPoint center, float xRadius,
442 									float yRadius, float startAngle,
443 									float arcAngle,
444 									::pattern pattern = B_SOLID_HIGH);
445 			void				FillArc(BRect rect, float startAngle,
446 									float arcAngle,
447 									::pattern pattern = B_SOLID_HIGH);
448 			void				FillArc(BPoint center, float xRadius,
449 									float yRadius, float startAngle,
450 									float arcAngle, const BGradient& gradient);
451 			void				FillArc(BRect rect, float startAngle,
452 									float arcAngle, const BGradient& gradient);
453 
454 			void				StrokeBezier(BPoint* controlPoints,
455 									::pattern pattern = B_SOLID_HIGH);
456 			void				FillBezier(BPoint* controlPoints,
457 									::pattern pattern = B_SOLID_HIGH);
458 			void				FillBezier(BPoint* controlPoints,
459 									const BGradient& gradient);
460 
461 			void				StrokeShape(BShape* shape,
462 									::pattern pattern = B_SOLID_HIGH);
463 			void				FillShape(BShape* shape,
464 									::pattern pattern = B_SOLID_HIGH);
465 			void				FillShape(BShape* shape,
466 									const BGradient& gradient);
467 
468 			void				CopyBits(BRect src, BRect dst);
469 
470 			void				DrawBitmapAsync(const BBitmap* aBitmap,
471 									BRect bitmapRect, BRect viewRect,
472 									uint32 options);
473 			void				DrawBitmapAsync(const BBitmap* aBitmap,
474 									BRect bitmapRect, BRect viewRect);
475 			void				DrawBitmapAsync(const BBitmap* aBitmap,
476 									BRect viewRect);
477 			void				DrawBitmapAsync(const BBitmap* aBitmap,
478 									BPoint where);
479 			void				DrawBitmapAsync(const BBitmap* aBitmap);
480 
481 			void				DrawBitmap(const BBitmap* aBitmap,
482 									BRect bitmapRect, BRect viewRect,
483 									uint32 options);
484 			void				DrawBitmap(const BBitmap* aBitmap,
485 									BRect bitmapRect, BRect viewRect);
486 			void				DrawBitmap(const BBitmap* aBitmap,
487 									BRect viewRect);
488 			void				DrawBitmap(const BBitmap* aBitmap,
489 									BPoint where);
490 			void				DrawBitmap(const BBitmap* aBitmap);
491 
492 			void				DrawTiledBitmapAsync(const BBitmap* aBitmap,
493 									BRect viewRect, BPoint phase = B_ORIGIN);
494 
495 			void				DrawTiledBitmap(const BBitmap* aBitmap,
496 									BRect viewRect, BPoint phase = B_ORIGIN);
497 
498 			void				DrawChar(char aChar);
499 			void				DrawChar(char aChar, BPoint location);
500 			void				DrawString(const char* string,
501 									escapement_delta* delta = NULL);
502 			void				DrawString(const char* string,
503 									BPoint location,
504 									escapement_delta* delta = NULL);
505 			void				DrawString(const char* string, int32 length,
506 									escapement_delta* delta = NULL);
507 			void				DrawString(const char* string, int32 length,
508 									BPoint location,
509 									escapement_delta* delta = 0L);
510 			void				DrawString(const char* string,
511 									const BPoint* locations,
512 									int32 locationCount);
513 			void				DrawString(const char* string, int32 length,
514 									const BPoint* locations,
515 									int32 locationCount);
516 
517 	virtual	void				SetFont(const BFont* font,
518 									uint32 mask = B_FONT_ALL);
519 
520 			void				GetFont(BFont* font) const;
521 			void				TruncateString(BString* in_out, uint32 mode,
522 									float width) const;
523 			float				StringWidth(const char* string) const;
524 			float				StringWidth(const char* string,
525 									int32 length) const;
526 			void				GetStringWidths(char* stringArray[],
527 									int32 lengthArray[], int32 numStrings,
528 									float widthArray[]) const;
529 			void				SetFontSize(float size);
530 			void				ForceFontAliasing(bool enable);
531 			void				GetFontHeight(font_height* height) const;
532 
533 			void				Invalidate(BRect invalRect);
534 			void				Invalidate(const BRegion* invalRegion);
535 			void				Invalidate();
536 			void				DelayedInvalidate(bigtime_t delay);
537 			void				DelayedInvalidate(bigtime_t delay,
538 									BRect invalRect);
539 
540 			void				SetDiskMode(char* filename, long offset);
541 
542 			void				BeginPicture(BPicture* a_picture);
543 			void				AppendToPicture(BPicture* a_picture);
544 			BPicture*			EndPicture();
545 
546 			void				DrawPicture(const BPicture* a_picture);
547 			void				DrawPicture(const BPicture* a_picture,
548 									BPoint where);
549 			void				DrawPicture(const char* filename, long offset,
550 									BPoint where);
551 			void				DrawPictureAsync(const BPicture* a_picture);
552 			void				DrawPictureAsync(const BPicture* a_picture,
553 									BPoint where);
554 			void				DrawPictureAsync(const char* filename,
555 									long offset, BPoint where);
556 
557 			void				BeginLayer(uint8 opacity);
558 			void				EndLayer();
559 
560 			status_t			SetEventMask(uint32 mask, uint32 options = 0);
561 			uint32				EventMask();
562 			status_t			SetMouseEventMask(uint32 mask,
563 									uint32 options = 0);
564 
565 	virtual	void				SetFlags(uint32 flags);
566 			uint32				Flags() const;
567 	virtual	void				SetResizingMode(uint32 mode);
568 			uint32				ResizingMode() const;
569 			void				MoveBy(float dh, float dv);
570 			void				MoveTo(BPoint where);
571 			void				MoveTo(float x, float y);
572 			void				ResizeBy(float dh, float dv);
573 			void				ResizeTo(float width, float height);
574 			void				ResizeTo(BSize size);
575 			void				ScrollBy(float dh, float dv);
576 			void				ScrollTo(float x, float y);
577 	virtual	void				ScrollTo(BPoint where);
578 	virtual	void				MakeFocus(bool focus = true);
579 			bool				IsFocus() const;
580 
581 	virtual	void				Show();
582 	virtual	void				Hide();
583 			bool				IsHidden() const;
584 			bool				IsHidden(const BView* looking_from) const;
585 
586 			void				Flush() const;
587 			void				Sync() const;
588 
589 	virtual	void				GetPreferredSize(float* _width, float* _height);
590 	virtual	void				ResizeToPreferred();
591 
592 			BScrollBar*			ScrollBar(orientation direction) const;
593 
594 	virtual	BHandler*			ResolveSpecifier(BMessage* message, int32 index,
595 									BMessage* specifier, int32 form,
596 									const char* property);
597 	virtual	status_t			GetSupportedSuites(BMessage* data);
598 
599 			bool				IsPrinting() const;
600 			void				SetScale(float scale) const;
601 			float				Scale() const;
602 									// new for Haiku
603 
604 	virtual	status_t			Perform(perform_code code, void* data);
605 
606 	virtual	void				DrawAfterChildren(BRect updateRect);
607 
608 	// layout related
609 
610 	virtual	BSize				MinSize();
611 	virtual	BSize				MaxSize();
612 	virtual	BSize				PreferredSize();
613 	virtual	BAlignment			LayoutAlignment();
614 
615 			void				SetExplicitMinSize(BSize size);
616 			void				SetExplicitMaxSize(BSize size);
617 			void				SetExplicitPreferredSize(BSize size);
618 			void				SetExplicitSize(BSize size);
619 			void				SetExplicitAlignment(BAlignment alignment);
620 
621 			BSize				ExplicitMinSize() const;
622 			BSize				ExplicitMaxSize() const;
623 			BSize				ExplicitPreferredSize() const;
624 			BAlignment			ExplicitAlignment() const;
625 
626 	virtual	bool				HasHeightForWidth();
627 	virtual	void				GetHeightForWidth(float width, float* min,
628 									float* max, float* preferred);
629 
630 			void				InvalidateLayout(bool descendants = false);
631 	virtual	void				SetLayout(BLayout* layout);
632 			BLayout*			GetLayout() const;
633 
634 			void				EnableLayoutInvalidation();
635 			void				DisableLayoutInvalidation();
636 			bool				IsLayoutInvalidationDisabled();
637 			bool				IsLayoutValid() const;
638 			void				ResetLayoutInvalidation();
639 
640 			BLayoutContext*		LayoutContext() const;
641 
642 			void				Layout(bool force);
643 			void				Relayout();
644 
645 	class Private;
646 
647 protected:
648 	virtual	void				LayoutInvalidated(bool descendants = false);
649 	virtual	void				DoLayout();
650 
651 public:
652 	// tool tip support
653 
654 			void				SetToolTip(const char* text);
655 			void				SetToolTip(BToolTip* tip);
656 			BToolTip*			ToolTip() const;
657 
658 			void				ShowToolTip(BToolTip* tip = NULL);
659 			void				HideToolTip();
660 
661 protected:
662 	virtual	bool				GetToolTipAt(BPoint point, BToolTip** _tip);
663 
664 	virtual	void				LayoutChanged();
665 
666 			status_t			ScrollWithMouseWheelDelta(BScrollBar*, float);
667 
668 private:
669 			void				_Layout(bool force, BLayoutContext* context);
670 			void				_LayoutLeft(BLayout* deleted);
671 			void				_InvalidateParentLayout();
672 
673 private:
674 	// FBC padding and forbidden methods
675 	virtual	void				_ReservedView13();
676 	virtual	void				_ReservedView14();
677 	virtual	void				_ReservedView15();
678 	virtual	void				_ReservedView16();
679 
680 								BView(const BView&);
681 			BView&				operator=(const BView&);
682 
683 private:
684 	struct LayoutData;
685 
686 	friend class Private;
687 	friend class BBitmap;
688 	friend class BLayout;
689 	friend class BPrintJob;
690 	friend class BScrollBar;
691 	friend class BShelf;
692 	friend class BTabView;
693 	friend class BWindow;
694 
695 			void				_InitData(BRect frame, const char* name,
696 									uint32 resizingMode, uint32 flags);
697 			status_t			_SetViewBitmap(const BBitmap* bitmap,
698 									BRect srcRect, BRect dstRect,
699 									uint32 followFlags, uint32 options);
700 			void				_ClipToPicture(BPicture* picture, BPoint where,
701 									bool invert, bool sync);
702 
703 			void				_ClipToRect(BRect rect, bool inverse);
704 			void				_ClipToShape(BShape* shape, bool inverse);
705 
706 			bool				_CheckOwnerLockAndSwitchCurrent() const;
707 			bool				_CheckOwnerLock() const;
708 			void				_CheckLockAndSwitchCurrent() const;
709 			void				_CheckLock() const;
710 			void				_SwitchServerCurrentView() const;
711 
712 			void				_SetOwner(BWindow* newOwner);
713 			void				_RemoveCommArray();
714 
715 			BShelf*				_Shelf() const;
716 			void				_SetShelf(BShelf* shelf);
717 
718 			void				_MoveTo(int32 x, int32 y);
719 			void				_ResizeBy(int32 deltaWidth, int32 deltaHeight);
720 			void				_ParentResizedBy(int32 deltaWidth,
721 									int32 deltaHeight);
722 
723 			void				_ConvertToScreen(BPoint* pt,
724 									bool checkLock) const;
725 			void				_ConvertFromScreen(BPoint* pt,
726 									bool checkLock) const;
727 
728 			void				_ConvertToParent(BPoint* pt,
729 									bool checkLock) const;
730 			void				_ConvertFromParent(BPoint* pt,
731 									bool checkLock) const;
732 
733 			void				_Activate(bool state);
734 			void				_Attach();
735 			void				_ColorsUpdated(BMessage* message);
736 			void				_Detach();
737 			void				_Draw(BRect screenUpdateRect);
738 			void				_DrawAfterChildren(BRect screenUpdateRect);
739 			void				_FontsUpdated(BMessage*);
740 			void				_Pulse();
741 
742 			void				_UpdateStateForRemove();
743 			void				_UpdatePattern(::pattern pattern);
744 
745 			void				_FlushIfNotInTransaction();
746 
747 			bool				_CreateSelf();
748 			bool				_AddChildToList(BView* child,
749 									BView* before = NULL);
750 			bool				_RemoveChildFromList(BView* child);
751 
752 			bool				_AddChild(BView *child, BView *before);
753 			bool				_RemoveSelf();
754 			void				_RemoveLayoutItemsFromLayout(bool deleteItems);
755 
756 	// Debugging methods
757 			void				_PrintToStream();
758 			void				_PrintTree();
759 
760 			int32				_unused_int1;
761 
762 			uint32				fFlags;
763 			BPoint				fParentOffset;
764 			BWindow*			fOwner;
765 			BView*				fParent;
766 			BView*				fNextSibling;
767 			BView*				fPreviousSibling;
768 			BView*				fFirstChild;
769 
770 			int16				fShowLevel;
771 			bool				fTopLevelView;
772 			bool				fNoISInteraction;
773 			BPicture*			fCurrentPicture;
774 			_array_data_*		fCommArray;
775 
776 			BScrollBar*			fVerScroller;
777 			BScrollBar*			fHorScroller;
778 			bool				fIsPrinting;
779 			bool				fAttached;
780 			bool				_unused_bool1;
781 			bool				_unused_bool2;
782 			::BPrivate::ViewState* fState;
783 			BRect				fBounds;
784 			BShelf*				fShelf;
785 			uint32				fEventMask;
786 			uint32				fEventOptions;
787 			uint32				fMouseEventOptions;
788 
789 			LayoutData*			fLayoutData;
790 			BToolTip*			fToolTip;
791 
792 			uint32				_reserved[6];
793 };
794 
795 
796 // #pragma mark - inline definitions
797 
798 
799 inline void
800 BView::ScrollTo(float x, float y)
801 {
802 	ScrollTo(BPoint(x, y));
803 }
804 
805 
806 inline void
807 BView::SetViewColor(uchar red, uchar green, uchar blue, uchar alpha)
808 {
809 	rgb_color color;
810 	color.red = red;
811 	color.green = green;
812 	color.blue = blue;
813 	color.alpha = alpha;
814 	SetViewColor(color);
815 }
816 
817 
818 inline void
819 BView::SetHighColor(uchar red, uchar green, uchar blue, uchar alpha)
820 {
821 	rgb_color color;
822 	color.red = red;
823 	color.green = green;
824 	color.blue = blue;
825 	color.alpha = alpha;
826 	SetHighColor(color);
827 }
828 
829 
830 inline void
831 BView::SetLowColor(uchar red, uchar green, uchar blue, uchar alpha)
832 {
833 	rgb_color color;
834 	color.red = red;
835 	color.green = green;
836 	color.blue = blue;
837 	color.alpha = alpha;
838 	SetLowColor(color);
839 }
840 
841 
842 #endif // _VIEW_H
843