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