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