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