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