xref: /haiku/headers/os/interface/View.h (revision f2b4344867e97c3f4e742a1b4a15e6879644601a)
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 	virtual	status_t			AllUnarchived(const BMessage* archive);
147 	virtual status_t			AllArchived(BMessage* archive) const;
148 
149 	virtual	void				AttachedToWindow();
150 	virtual	void				AllAttached();
151 	virtual	void				DetachedFromWindow();
152 	virtual	void				AllDetached();
153 
154 	virtual	void				MessageReceived(BMessage* message);
155 
156 			void				AddChild(BView* child, BView* before = NULL);
157 			bool				AddChild(BLayoutItem* child);
158 			bool				RemoveChild(BView* child);
159 			int32				CountChildren() const;
160 			BView*				ChildAt(int32 index) const;
161 			BView*				NextSibling() const;
162 			BView*				PreviousSibling() const;
163 			bool				RemoveSelf();
164 
165 			BWindow*			Window() const;
166 
167 	virtual	void				Draw(BRect updateRect);
168 	virtual	void				MouseDown(BPoint where);
169 	virtual	void				MouseUp(BPoint where);
170 	virtual	void				MouseMoved(BPoint where, uint32 code,
171 									const BMessage* dragMessage);
172 	virtual	void				WindowActivated(bool state);
173 	virtual	void				KeyDown(const char* bytes, int32 numBytes);
174 	virtual	void				KeyUp(const char* bytes, int32 numBytes);
175 	virtual	void				Pulse();
176 	virtual	void				FrameMoved(BPoint newPosition);
177 	virtual	void				FrameResized(float newWidth, float newHeight);
178 
179 	virtual	void				TargetedByScrollView(BScrollView* scrollView);
180 			void				BeginRectTracking(BRect startRect,
181 									uint32 style = B_TRACK_WHOLE_RECT);
182 			void				EndRectTracking();
183 
184 			void				GetMouse(BPoint* location, uint32* buttons,
185 									bool checkMessageQueue = true);
186 
187 			void				DragMessage(BMessage* message, BRect dragRect,
188 									BHandler* replyTo = NULL);
189 			void				DragMessage(BMessage* message, BBitmap* bitmap,
190 									BPoint offset, BHandler* replyTo = NULL);
191 			void				DragMessage(BMessage* message, BBitmap* bitmap,
192 									drawing_mode dragMode, BPoint offset,
193 									BHandler* replyTo = NULL);
194 
195 			BView*				FindView(const char* name) const;
196 			BView*				Parent() const;
197 			BRect				Bounds() const;
198 			BRect				Frame() const;
199 			void				ConvertToScreen(BPoint* pt) const;
200 			BPoint				ConvertToScreen(BPoint pt) const;
201 			void				ConvertFromScreen(BPoint* pt) const;
202 			BPoint				ConvertFromScreen(BPoint pt) const;
203 			void				ConvertToScreen(BRect* r) const;
204 			BRect				ConvertToScreen(BRect r) const;
205 			void				ConvertFromScreen(BRect* r) const;
206 			BRect				ConvertFromScreen(BRect r) const;
207 			void				ConvertToParent(BPoint* pt) const;
208 			BPoint				ConvertToParent(BPoint pt) const;
209 			void				ConvertFromParent(BPoint* pt) const;
210 			BPoint				ConvertFromParent(BPoint pt) const;
211 			void				ConvertToParent(BRect* r) const;
212 			BRect				ConvertToParent(BRect r) const;
213 			void				ConvertFromParent(BRect* r) const;
214 			BRect				ConvertFromParent(BRect r) const;
215 			BPoint				LeftTop() const;
216 
217 			void				GetClippingRegion(BRegion* region) const;
218 	virtual	void				ConstrainClippingRegion(BRegion* region);
219 			void				ClipToPicture(BPicture* picture,
220 									BPoint where = B_ORIGIN, bool sync = true);
221 			void				ClipToInversePicture(BPicture* picture,
222 									BPoint where = B_ORIGIN, bool sync = true);
223 
224 	virtual	void				SetDrawingMode(drawing_mode mode);
225 			drawing_mode 		DrawingMode() const;
226 
227 			void				SetBlendingMode(source_alpha srcAlpha,
228 									alpha_function alphaFunc);
229 			void	 			GetBlendingMode(source_alpha* srcAlpha,
230 									alpha_function* alphaFunc) const;
231 
232 	virtual	void				SetPenSize(float size);
233 			float				PenSize() const;
234 
235 			void				SetViewCursor(const BCursor* cursor,
236 									bool sync = true);
237 
238 	virtual	void				SetViewColor(rgb_color c);
239 			void				SetViewColor(uchar r, uchar g, uchar b,
240 									uchar a = 255);
241 			rgb_color			ViewColor() const;
242 
243 			void				SetViewBitmap(const BBitmap* bitmap,
244 									BRect srcRect, BRect dstRect,
245 									uint32 followFlags
246 										= B_FOLLOW_TOP | B_FOLLOW_LEFT,
247 									uint32 options = B_TILE_BITMAP);
248 			void				SetViewBitmap(const BBitmap* bitmap,
249 									uint32 followFlags
250 										= B_FOLLOW_TOP | B_FOLLOW_LEFT,
251 									uint32 options = B_TILE_BITMAP);
252 			void				ClearViewBitmap();
253 
254 			status_t			SetViewOverlay(const BBitmap* overlay,
255 									BRect srcRect, BRect dstRect,
256 									rgb_color* colorKey,
257 									uint32 followFlags
258 										= B_FOLLOW_TOP | B_FOLLOW_LEFT,
259 									uint32 options = 0);
260 			status_t			SetViewOverlay(const BBitmap* overlay,
261 									rgb_color* colorKey,
262 									uint32 followFlags
263 										= B_FOLLOW_TOP | B_FOLLOW_LEFT,
264 									uint32 options = 0);
265 			void				ClearViewOverlay();
266 
267 	virtual	void				SetHighColor(rgb_color a_color);
268 			void				SetHighColor(uchar r, uchar g, uchar b,
269 									uchar a = 255);
270 			rgb_color			HighColor() const;
271 
272 	virtual	void				SetLowColor(rgb_color a_color);
273 			void				SetLowColor(uchar r, uchar g, uchar b,
274 									uchar a = 255);
275 			rgb_color			LowColor() const;
276 
277 			void				SetLineMode(cap_mode lineCap,
278 									join_mode lineJoin,
279 									float miterLimit = B_DEFAULT_MITER_LIMIT);
280 			join_mode			LineJoinMode() const;
281 			cap_mode			LineCapMode() const;
282 			float				LineMiterLimit() const;
283 
284 			void				SetOrigin(BPoint pt);
285 			void				SetOrigin(float x, float y);
286 			BPoint				Origin() const;
287 
288 			void				PushState();
289 			void				PopState();
290 
291 			void				MovePenTo(BPoint pt);
292 			void				MovePenTo(float x, float y);
293 			void				MovePenBy(float x, float y);
294 			BPoint				PenLocation() const;
295 			void				StrokeLine(BPoint toPt,
296 									pattern p = B_SOLID_HIGH);
297 			void				StrokeLine(BPoint a, BPoint b,
298 									pattern p = B_SOLID_HIGH);
299 			void				BeginLineArray(int32 count);
300 			void				AddLine(BPoint a, BPoint b, rgb_color color);
301 			void				EndLineArray();
302 
303 			void				StrokePolygon(const BPolygon* polygon,
304 									bool closed = true,
305 									pattern p = B_SOLID_HIGH);
306 			void				StrokePolygon(const BPoint* ptArray,
307 									int32 numPts, bool closed = true,
308 									pattern p = B_SOLID_HIGH);
309 			void				StrokePolygon(const BPoint* ptArray,
310 									int32 numPts, BRect bounds,
311 									bool closed = true,
312 									pattern p = B_SOLID_HIGH);
313 			void				FillPolygon(const BPolygon* polygon,
314 									pattern p = B_SOLID_HIGH);
315 			void				FillPolygon(const BPoint* ptArray,
316 									int32 numPts, pattern p = B_SOLID_HIGH);
317 			void				FillPolygon(const BPoint* ptArray,
318 									int32 numPts, BRect bounds,
319 									pattern p = B_SOLID_HIGH);
320 			void				FillPolygon(const BPolygon* polygon,
321 									const BGradient& gradient);
322 			void				FillPolygon(const BPoint* ptArray,
323 									int32 numPts, const BGradient& gradient);
324 			void				FillPolygon(const BPoint* ptArray,
325 									int32 numPts, BRect bounds,
326 									const BGradient& gradient);
327 
328 			void				StrokeTriangle(BPoint pt1, BPoint pt2,
329 									BPoint pt3, BRect bounds,
330 									pattern p = B_SOLID_HIGH);
331 			void				StrokeTriangle(BPoint pt1, BPoint pt2,
332 									BPoint pt3, pattern p = B_SOLID_HIGH);
333 			void				FillTriangle(BPoint pt1, BPoint pt2,
334 									BPoint pt3, pattern p = B_SOLID_HIGH);
335 			void				FillTriangle(BPoint pt1, BPoint pt2,
336 									BPoint pt3, BRect bounds,
337 									pattern p = B_SOLID_HIGH);
338 			void				FillTriangle(BPoint pt1, BPoint pt2,
339 									BPoint pt3, const BGradient& gradient);
340 			void				FillTriangle(BPoint pt1, BPoint pt2,
341 									BPoint pt3, BRect bounds,
342 									const BGradient& gradient);
343 
344 			void				StrokeRect(BRect r, pattern p = B_SOLID_HIGH);
345 			void				FillRect(BRect r, pattern p = B_SOLID_HIGH);
346 			void				FillRect(BRect r, const BGradient& gradient);
347 			void				FillRegion(BRegion* region,
348 									pattern p = B_SOLID_HIGH);
349 			void				FillRegion(BRegion* region,
350 								   const BGradient& gradient);
351 			void				InvertRect(BRect r);
352 
353 			void				StrokeRoundRect(BRect r, float xRadius,
354 									float yRadius, pattern p = B_SOLID_HIGH);
355 			void				FillRoundRect(BRect r, float xRadius,
356 									float yRadius, pattern p = B_SOLID_HIGH);
357 			void				FillRoundRect(BRect r, float xRadius,
358 									float yRadius, const BGradient& gradient);
359 
360 			void				StrokeEllipse(BPoint center, float xRadius,
361 									float yRadius, pattern p = B_SOLID_HIGH);
362 			void				StrokeEllipse(BRect r,
363 									pattern p = B_SOLID_HIGH);
364 			void				FillEllipse(BPoint center, float xRadius,
365 									float yRadius, pattern p = B_SOLID_HIGH);
366 			void				FillEllipse(BRect r, pattern p = B_SOLID_HIGH);
367 			void				FillEllipse(BPoint center, float xRadius,
368 									float yRadius, const BGradient& gradient);
369 			void				FillEllipse(BRect r,
370 									const BGradient& gradient);
371 
372 			void				StrokeArc(BPoint center, float xRadius,
373 									float yRadius, float startAngle,
374 									float arcAngle, pattern p = B_SOLID_HIGH);
375 			void				StrokeArc(BRect r, float startAngle,
376 									float arcAngle, pattern p = B_SOLID_HIGH);
377 			void				FillArc(BPoint center, float xRadius,
378 									float yRadius, float startAngle,
379 									float arcAngle, pattern p = B_SOLID_HIGH);
380 			void				FillArc(BRect r, float startAngle,
381 									float arcAngle, pattern p = B_SOLID_HIGH);
382 			void				FillArc(BPoint center, float xRadius,
383 									float yRadius, float startAngle,
384 									float arcAngle, const BGradient& gradient);
385 			void				FillArc(BRect r, float startAngle,
386 									float arcAngle, const BGradient& gradient);
387 
388 			void				StrokeBezier(BPoint* controlPoints,
389 									pattern p = B_SOLID_HIGH);
390 			void				FillBezier(BPoint* controlPoints,
391 									pattern p = B_SOLID_HIGH);
392 			void				FillBezier(BPoint* controlPoints,
393 								   const BGradient& gradient);
394 
395 			void				StrokeShape(BShape* shape,
396 									pattern p = B_SOLID_HIGH);
397 			void				FillShape(BShape* shape,
398 									pattern p = B_SOLID_HIGH);
399 			void				FillShape(BShape* shape,
400 									const BGradient& gradient);
401 
402 			void				CopyBits(BRect src, BRect dst);
403 
404 			void				DrawBitmapAsync(const BBitmap* aBitmap,
405 									BRect bitmapRect, BRect viewRect,
406 									uint32 options);
407 			void				DrawBitmapAsync(const BBitmap* aBitmap,
408 									BRect bitmapRect, BRect viewRect);
409 			void				DrawBitmapAsync(const BBitmap* aBitmap,
410 									BRect viewRect);
411 			void				DrawBitmapAsync(const BBitmap* aBitmap,
412 									BPoint where);
413 			void				DrawBitmapAsync(const BBitmap* aBitmap);
414 
415 			void				DrawBitmap(const BBitmap* aBitmap,
416 									BRect bitmapRect, BRect viewRect,
417 									uint32 options);
418 			void				DrawBitmap(const BBitmap* aBitmap,
419 									BRect bitmapRect, BRect viewRect);
420 			void				DrawBitmap(const BBitmap* aBitmap,
421 									BRect viewRect);
422 			void				DrawBitmap(const BBitmap* aBitmap,
423 									BPoint where);
424 			void				DrawBitmap(const BBitmap* aBitmap);
425 
426 			void				DrawChar(char aChar);
427 			void				DrawChar(char aChar, BPoint location);
428 			void				DrawString(const char* string,
429 									escapement_delta* delta = NULL);
430 			void				DrawString(const char* string,
431 									BPoint location,
432 									escapement_delta* delta = NULL);
433 			void				DrawString(const char* string, int32 length,
434 									escapement_delta* delta = NULL);
435 			void				DrawString(const char* string, int32 length,
436 									BPoint location,
437 									escapement_delta* delta = 0L);
438 			void				DrawString(const char* string,
439 									const BPoint* locations,
440 									int32 locationCount);
441 			void				DrawString(const char* string, int32 length,
442 									const BPoint* locations,
443 									int32 locationCount);
444 
445 	virtual void            	SetFont(const BFont* font,
446 									uint32 mask = B_FONT_ALL);
447 
448 			void            	GetFont(BFont* font) const;
449 			void				TruncateString(BString* in_out, uint32 mode,
450 									float width) const;
451 			float				StringWidth(const char* string) const;
452 			float				StringWidth(const char* string,
453 									int32 length) const;
454 			void				GetStringWidths(char* stringArray[],
455 									int32 lengthArray[], int32 numStrings,
456 									float widthArray[]) const;
457 			void				SetFontSize(float size);
458 			void				ForceFontAliasing(bool enable);
459 			void				GetFontHeight(font_height* height) const;
460 
461 			void				Invalidate(BRect invalRect);
462 			void				Invalidate(const BRegion* invalRegion);
463 			void				Invalidate();
464 
465 			void				SetDiskMode(char* filename, long offset);
466 
467 			void				BeginPicture(BPicture* a_picture);
468 			void				AppendToPicture(BPicture* a_picture);
469 			BPicture*			EndPicture();
470 
471 			void				DrawPicture(const BPicture* a_picture);
472 			void				DrawPicture(const BPicture* a_picture,
473 									BPoint where);
474 			void				DrawPicture(const char* filename, long offset,
475 									BPoint where);
476 			void				DrawPictureAsync(const BPicture* a_picture);
477 			void				DrawPictureAsync(const BPicture* a_picture,
478 									BPoint where);
479 			void				DrawPictureAsync(const char* filename,
480 									long offset, BPoint where);
481 
482 			status_t			SetEventMask(uint32 mask, uint32 options = 0);
483 			uint32				EventMask();
484 			status_t			SetMouseEventMask(uint32 mask,
485 									uint32 options = 0);
486 
487 	virtual	void				SetFlags(uint32 flags);
488 			uint32				Flags() const;
489 	virtual	void				SetResizingMode(uint32 mode);
490 			uint32				ResizingMode() const;
491 			void				MoveBy(float dh, float dv);
492 			void				MoveTo(BPoint where);
493 			void				MoveTo(float x, float y);
494 			void				ResizeBy(float dh, float dv);
495 			void				ResizeTo(float width, float height);
496 			void				ResizeTo(BSize size);
497 			void				ScrollBy(float dh, float dv);
498 			void				ScrollTo(float x, float y);
499 	virtual	void				ScrollTo(BPoint where);
500 	virtual	void				MakeFocus(bool focusState = true);
501 			bool				IsFocus() const;
502 
503 	virtual	void				Show();
504 	virtual	void				Hide();
505 			bool				IsHidden() const;
506 			bool				IsHidden(const BView* looking_from) const;
507 
508 			void				Flush() const;
509 			void				Sync() const;
510 
511 	virtual	void				GetPreferredSize(float* width, float* height);
512 	virtual	void				ResizeToPreferred();
513 
514 			BScrollBar*			ScrollBar(orientation posture) const;
515 
516 	virtual BHandler*			ResolveSpecifier(BMessage* msg, int32 index,
517 									BMessage* specifier, int32 form,
518 									const char* property);
519 	virtual status_t			GetSupportedSuites(BMessage* data);
520 
521 			bool				IsPrinting() const;
522 			void				SetScale(float scale) const;
523 			float				Scale() const;
524 									// new for Haiku
525 
526 	virtual status_t			Perform(perform_code code, void* data);
527 
528 	virtual	void				DrawAfterChildren(BRect r);
529 
530 	// layout related
531 
532 	virtual	BSize				MinSize();
533 	virtual	BSize				MaxSize();
534 	virtual	BSize				PreferredSize();
535 	virtual	BAlignment			LayoutAlignment();
536 
537 			void				SetExplicitMinSize(BSize size);
538 			void				SetExplicitMaxSize(BSize size);
539 			void				SetExplicitPreferredSize(BSize size);
540 			void				SetExplicitAlignment(BAlignment alignment);
541 
542 			BSize				ExplicitMinSize() const;
543 			BSize				ExplicitMaxSize() const;
544 			BSize				ExplicitPreferredSize() const;
545 			BAlignment			ExplicitAlignment() const;
546 
547 	virtual	bool				HasHeightForWidth();
548 	virtual	void				GetHeightForWidth(float width, float* min,
549 									float* max, float* preferred);
550 
551 			void				InvalidateLayout(bool descendants = false);
552 	virtual	void				SetLayout(BLayout* layout);
553 			BLayout*			GetLayout() const;
554 
555 			void				EnableLayoutInvalidation();
556 			void				DisableLayoutInvalidation();
557 			bool				IsLayoutValid() const;
558 			void				ResetLayoutInvalidation();
559 
560 			BLayoutContext*		LayoutContext() const;
561 
562 			void				Layout(bool force);
563 			void				Relayout();
564 
565 	class Private;
566 
567 protected:
568 	virtual	void				LayoutInvalidated(bool descendants = false);
569 	virtual	void				DoLayout();
570 
571 public:
572 	// tool tip support
573 
574 			void				SetToolTip(const char* text);
575 			void				SetToolTip(BToolTip* tip);
576 			BToolTip*			ToolTip() const;
577 
578 			void				ShowToolTip(BToolTip* tip = NULL);
579 			void				HideToolTip();
580 
581 protected:
582 	virtual bool				GetToolTipAt(BPoint point, BToolTip** _tip);
583 
584 	virtual	void				LayoutChanged();
585 
586 private:
587 			void				_Layout(bool force, BLayoutContext* context);
588 			void				_LayoutLeft(BLayout* deleted);
589 			void				_InvalidateParentLayout();
590 
591 private:
592 	// FBC padding and forbidden methods
593 	virtual	void				_ReservedView13();
594 	virtual	void				_ReservedView14();
595 	virtual	void				_ReservedView15();
596 	virtual	void				_ReservedView16();
597 
598 								BView(const BView&);
599 			BView&				operator=(const BView&);
600 
601 private:
602 	struct LayoutData;
603 
604 	friend class Private;
605 	friend class BBitmap;
606 	friend class BLayout;
607 	friend class BPrintJob;
608 	friend class BScrollBar;
609 	friend class BShelf;
610 	friend class BTabView;
611 	friend class BWindow;
612 
613 			void				_InitData(BRect frame, const char* name,
614 									uint32 resizeMask, uint32 flags);
615 			status_t			_SetViewBitmap(const BBitmap* bitmap,
616 									BRect srcRect, BRect dstRect,
617 									uint32 followFlags, uint32 options);
618 			void				_ClipToPicture(BPicture* picture, BPoint where,
619 									bool invert, bool sync);
620 
621 			bool				_CheckOwnerLockAndSwitchCurrent() const;
622 			bool				_CheckOwnerLock() const;
623 			void				_CheckLockAndSwitchCurrent() const;
624 			void				_CheckLock() const;
625 			void				_SwitchServerCurrentView() const;
626 
627 			void				_SetOwner(BWindow* newOwner);
628 			void				_RemoveCommArray();
629 
630 			BShelf*				_Shelf() const;
631 			void				_SetShelf(BShelf* shelf);
632 
633 			void				_MoveTo(int32 x, int32 y);
634 			void				_ResizeBy(int32 deltaWidth, int32 deltaHeight);
635 			void				_ParentResizedBy(int32 deltaWidth,
636 									int32 deltaHeight);
637 
638 			void				_ConvertToScreen(BPoint* pt,
639 									bool checkLock) const;
640 			void				_ConvertFromScreen(BPoint* pt,
641 									bool checkLock) const;
642 
643 			void				_ConvertToParent(BPoint* pt,
644 									bool checkLock) const;
645 			void				_ConvertFromParent(BPoint* pt,
646 									bool checkLock) const;
647 
648 			void				_Activate(bool state);
649 			void				_Attach();
650 			void				_Detach();
651 			void				_Draw(BRect screenUpdateRect);
652 			void				_DrawAfterChildren(BRect screenUpdateRect);
653 			void				_Pulse();
654 
655 			void				_UpdateStateForRemove();
656 			void				_UpdatePattern(::pattern pattern);
657 
658 			void				_FlushIfNotInTransaction();
659 
660 			bool				_CreateSelf();
661 			bool				_AddChildToList(BView* child,
662 									BView* before = NULL);
663 			bool				_RemoveChildFromList(BView* child);
664 
665 			bool				_AddChild(BView *child, BView *before);
666 			bool				_RemoveSelf();
667 
668 	// Debugging methods
669 			void 				_PrintToStream();
670 			void				_PrintTree();
671 
672 			int32				_unused_int1;
673 
674 			uint32				fFlags;
675 			BPoint				fParentOffset;
676 			BWindow*			fOwner;
677 			BView*				fParent;
678 			BView*				fNextSibling;
679 			BView*				fPreviousSibling;
680 			BView*				fFirstChild;
681 
682 			int16 				fShowLevel;
683 			bool				fTopLevelView;
684 			bool				fNoISInteraction;
685 			BPicture*			fCurrentPicture;
686 			_array_data_*		fCommArray;
687 
688 			BScrollBar*			fVerScroller;
689 			BScrollBar*			fHorScroller;
690 			bool				fIsPrinting;
691 			bool				fAttached;
692 			bool				_unused_bool1;
693 			bool				_unused_bool2;
694 			BPrivate::ViewState* fState;
695 			BRect				fBounds;
696 			BShelf*				fShelf;
697 			uint32				fEventMask;
698 			uint32				fEventOptions;
699 			uint32				fMouseEventOptions;
700 
701 			LayoutData*			fLayoutData;
702 			BToolTip*			fToolTip;
703 			BToolTip*			fVisibleToolTip;
704 
705 			uint32				_reserved[5];
706 };
707 
708 
709 // #pragma mark - inline definitions
710 
711 
712 inline void
713 BView::ScrollTo(float x, float y)
714 {
715 	ScrollTo(BPoint(x, y));
716 }
717 
718 
719 inline void
720 BView::SetViewColor(uchar r, uchar g, uchar b, uchar a)
721 {
722 	rgb_color color;
723 	color.red = r;
724 	color.green = g;
725 	color.blue = b;
726 	color.alpha = a;
727 	SetViewColor(color);
728 }
729 
730 
731 inline void
732 BView::SetHighColor(uchar r, uchar g, uchar b, uchar a)
733 {
734 	rgb_color color;
735 	color.red = r;
736 	color.green = g;
737 	color.blue = b;
738 	color.alpha = a;
739 	SetHighColor(color);
740 }
741 
742 
743 inline void
744 BView::SetLowColor(uchar r, uchar g, uchar b, uchar a)
745 {
746 	rgb_color color;
747 	color.red = r;
748 	color.green = g;
749 	color.blue = b;
750 	color.alpha = a;
751 	SetLowColor(color);
752 }
753 
754 #endif // _VIEW_H
755