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