1/*
2 * Copyright 2001-2012, 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
18enum {
19	B_PRIMARY_MOUSE_BUTTON				= 0x01,
20	B_SECONDARY_MOUSE_BUTTON			= 0x02,
21	B_TERTIARY_MOUSE_BUTTON				= 0x04
22};
23
24// mouse transit
25enum {
26	B_ENTERED_VIEW						= 0,
27	B_INSIDE_VIEW,
28	B_EXITED_VIEW,
29	B_OUTSIDE_VIEW
30};
31
32// event mask
33enum {
34	B_POINTER_EVENTS					= 0x00000001,
35	B_KEYBOARD_EVENTS					= 0x00000002
36};
37
38// event mask options
39enum {
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
49enum {
50	B_TRACK_WHOLE_RECT,
51	B_TRACK_RECT_CORNER
52};
53
54// set font mask
55enum {
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
69const uint32 B_FULL_UPDATE_ON_RESIZE 	= 0x80000000UL;	/* 31 */
70const uint32 _B_RESERVED1_ 				= 0x40000000UL;	/* 30 */
71const uint32 B_WILL_DRAW 				= 0x20000000UL;	/* 29 */
72const uint32 B_PULSE_NEEDED 			= 0x10000000UL;	/* 28 */
73const uint32 B_NAVIGABLE_JUMP 			= 0x08000000UL;	/* 27 */
74const uint32 B_FRAME_EVENTS				= 0x04000000UL;	/* 26 */
75const uint32 B_NAVIGABLE 				= 0x02000000UL;	/* 25 */
76const uint32 B_SUBPIXEL_PRECISE 		= 0x01000000UL;	/* 24 */
77const uint32 B_DRAW_ON_CHILDREN 		= 0x00800000UL;	/* 23 */
78const uint32 B_INPUT_METHOD_AWARE 		= 0x00400000UL;	/* 23 */
79const uint32 _B_RESERVED7_ 				= 0x00200000UL;	/* 22 */
80const uint32 B_SUPPORTS_LAYOUT			= 0x00100000UL;	/* 21 */
81const uint32 B_INVALIDATE_AFTER_LAYOUT	= 0x00080000UL;	/* 20 */
82
83#define _RESIZE_MASK_ (0xffff)
84
85const uint32 _VIEW_TOP_				 	= 1UL;
86const uint32 _VIEW_LEFT_ 				= 2UL;
87const uint32 _VIEW_BOTTOM_			 	= 3UL;
88const uint32 _VIEW_RIGHT_ 				= 4UL;
89const uint32 _VIEW_CENTER_ 				= 5UL;
90
91inline 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
109class BBitmap;
110class BCursor;
111class BLayout;
112class BLayoutContext;
113class BLayoutItem;
114class BMessage;
115class BPicture;
116class BPolygon;
117class BRegion;
118class BScrollBar;
119class BScrollView;
120class BShape;
121class BShelf;
122class BString;
123class BToolTip;
124class BWindow;
125struct _array_data_;
126struct _array_hdr_;
127struct overlay_restrictions;
128
129namespace BPrivate {
130	class ViewState;
131};
132
133
134class BView : public BHandler {
135public:
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				SetExplicitSize(BSize size);
541			void				SetExplicitAlignment(BAlignment alignment);
542
543			BSize				ExplicitMinSize() const;
544			BSize				ExplicitMaxSize() const;
545			BSize				ExplicitPreferredSize() const;
546			BAlignment			ExplicitAlignment() const;
547
548	virtual	bool				HasHeightForWidth();
549	virtual	void				GetHeightForWidth(float width, float* min,
550									float* max, float* preferred);
551
552			void				InvalidateLayout(bool descendants = false);
553	virtual	void				SetLayout(BLayout* layout);
554			BLayout*			GetLayout() const;
555
556			void				EnableLayoutInvalidation();
557			void				DisableLayoutInvalidation();
558			bool				IsLayoutInvalidationDisabled();
559			bool				IsLayoutValid() const;
560			void				ResetLayoutInvalidation();
561
562			BLayoutContext*		LayoutContext() const;
563
564			void				Layout(bool force);
565			void				Relayout();
566
567	class Private;
568
569protected:
570	virtual	void				LayoutInvalidated(bool descendants = false);
571	virtual	void				DoLayout();
572
573public:
574	// tool tip support
575
576			void				SetToolTip(const char* text);
577			void				SetToolTip(BToolTip* tip);
578			BToolTip*			ToolTip() const;
579
580			void				ShowToolTip(BToolTip* tip = NULL);
581			void				HideToolTip();
582
583protected:
584	virtual bool				GetToolTipAt(BPoint point, BToolTip** _tip);
585
586	virtual	void				LayoutChanged();
587
588			void				ScrollWithMouseWheelDelta(BScrollBar*, float);
589
590private:
591			void				_Layout(bool force, BLayoutContext* context);
592			void				_LayoutLeft(BLayout* deleted);
593			void				_InvalidateParentLayout();
594
595private:
596	// FBC padding and forbidden methods
597	virtual	void				_ReservedView13();
598	virtual	void				_ReservedView14();
599	virtual	void				_ReservedView15();
600	virtual	void				_ReservedView16();
601
602								BView(const BView&);
603			BView&				operator=(const BView&);
604
605private:
606	struct LayoutData;
607
608	friend class Private;
609	friend class BBitmap;
610	friend class BLayout;
611	friend class BPrintJob;
612	friend class BScrollBar;
613	friend class BShelf;
614	friend class BTabView;
615	friend class BWindow;
616
617			void				_InitData(BRect frame, const char* name,
618									uint32 resizeMask, uint32 flags);
619			status_t			_SetViewBitmap(const BBitmap* bitmap,
620									BRect srcRect, BRect dstRect,
621									uint32 followFlags, uint32 options);
622			void				_ClipToPicture(BPicture* picture, BPoint where,
623									bool invert, bool sync);
624
625			bool				_CheckOwnerLockAndSwitchCurrent() const;
626			bool				_CheckOwnerLock() const;
627			void				_CheckLockAndSwitchCurrent() const;
628			void				_CheckLock() const;
629			void				_SwitchServerCurrentView() const;
630
631			void				_SetOwner(BWindow* newOwner);
632			void				_RemoveCommArray();
633
634			BShelf*				_Shelf() const;
635			void				_SetShelf(BShelf* shelf);
636
637			void				_MoveTo(int32 x, int32 y);
638			void				_ResizeBy(int32 deltaWidth, int32 deltaHeight);
639			void				_ParentResizedBy(int32 deltaWidth,
640									int32 deltaHeight);
641
642			void				_ConvertToScreen(BPoint* pt,
643									bool checkLock) const;
644			void				_ConvertFromScreen(BPoint* pt,
645									bool checkLock) const;
646
647			void				_ConvertToParent(BPoint* pt,
648									bool checkLock) const;
649			void				_ConvertFromParent(BPoint* pt,
650									bool checkLock) const;
651
652			void				_Activate(bool state);
653			void				_Attach();
654			void				_Detach();
655			void				_Draw(BRect screenUpdateRect);
656			void				_DrawAfterChildren(BRect screenUpdateRect);
657			void				_Pulse();
658
659			void				_UpdateStateForRemove();
660			void				_UpdatePattern(::pattern pattern);
661
662			void				_FlushIfNotInTransaction();
663
664			bool				_CreateSelf();
665			bool				_AddChildToList(BView* child,
666									BView* before = NULL);
667			bool				_RemoveChildFromList(BView* child);
668
669			bool				_AddChild(BView *child, BView *before);
670			bool				_RemoveSelf();
671
672	// Debugging methods
673			void 				_PrintToStream();
674			void				_PrintTree();
675
676			int32				_unused_int1;
677
678			uint32				fFlags;
679			BPoint				fParentOffset;
680			BWindow*			fOwner;
681			BView*				fParent;
682			BView*				fNextSibling;
683			BView*				fPreviousSibling;
684			BView*				fFirstChild;
685
686			int16 				fShowLevel;
687			bool				fTopLevelView;
688			bool				fNoISInteraction;
689			BPicture*			fCurrentPicture;
690			_array_data_*		fCommArray;
691
692			BScrollBar*			fVerScroller;
693			BScrollBar*			fHorScroller;
694			bool				fIsPrinting;
695			bool				fAttached;
696			bool				_unused_bool1;
697			bool				_unused_bool2;
698			BPrivate::ViewState* fState;
699			BRect				fBounds;
700			BShelf*				fShelf;
701			uint32				fEventMask;
702			uint32				fEventOptions;
703			uint32				fMouseEventOptions;
704
705			LayoutData*			fLayoutData;
706			BToolTip*			fToolTip;
707
708			uint32				_reserved[6];
709};
710
711
712// #pragma mark - inline definitions
713
714
715inline void
716BView::ScrollTo(float x, float y)
717{
718	ScrollTo(BPoint(x, y));
719}
720
721
722inline void
723BView::SetViewColor(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	SetViewColor(color);
731}
732
733
734inline void
735BView::SetHighColor(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	SetHighColor(color);
743}
744
745
746inline void
747BView::SetLowColor(uchar r, uchar g, uchar b, uchar a)
748{
749	rgb_color color;
750	color.red = r;
751	color.green = g;
752	color.blue = b;
753	color.alpha = a;
754	SetLowColor(color);
755}
756
757
758#endif // _VIEW_H
759