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