xref: /haiku/headers/os/interface/View.h (revision a4ef4a49150f118d47324242917a596a3f8f8bd5)
1 /*
2  * Copyright 2001-2006, Haiku.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Erik Jaesler (erik@cgsoftware.com)
7  */
8 #ifndef	_VIEW_H
9 #define	_VIEW_H
10 
11 
12 #include <Alignment.h>
13 #include <BeBuild.h>
14 #include <Font.h>
15 #include <Handler.h>
16 #include <InterfaceDefs.h>
17 #include <Rect.h>
18 #include <Size.h>
19 #include <Gradient.h>
20 
21 
22 // mouse button
23 enum {
24 	B_PRIMARY_MOUSE_BUTTON		= 0x01,
25 	B_SECONDARY_MOUSE_BUTTON	= 0x02,
26 	B_TERTIARY_MOUSE_BUTTON		= 0x04
27 };
28 
29 // mouse transit
30 enum {
31 	B_ENTERED_VIEW = 0,
32 	B_INSIDE_VIEW,
33 	B_EXITED_VIEW,
34 	B_OUTSIDE_VIEW
35 };
36 
37 // event mask
38 enum {
39 	B_POINTER_EVENTS			= 0x00000001,
40 	B_KEYBOARD_EVENTS			= 0x00000002
41 };
42 
43 // event mask options
44 enum {
45 	B_LOCK_WINDOW_FOCUS			= 0x00000001,
46 	B_SUSPEND_VIEW_FOCUS		= 0x00000002,
47 	B_NO_POINTER_HISTORY		= 0x00000004,
48 	// new in Haiku (unless this flag is
49 	// specified, both BWindow and BView::GetMouse()
50 	// will filter out older mouse moved messages)
51 	B_FULL_POINTER_HISTORY		= 0x00000008
52 };
53 
54 enum {
55 	B_TRACK_WHOLE_RECT,
56 	B_TRACK_RECT_CORNER
57 };
58 
59 // bitmap drawing options
60 enum {
61 	B_FILTER_BITMAP_BILINEAR	= 0x00000001,
62 		// TODO: Make this simply "SMOOTH_SCALE" and use
63 		// better quality methods the faster the computer?
64 };
65 
66 // set font mask
67 enum {
68 	B_FONT_FAMILY_AND_STYLE		= 0x00000001,
69 	B_FONT_SIZE					= 0x00000002,
70 	B_FONT_SHEAR				= 0x00000004,
71 	B_FONT_ROTATION				= 0x00000008,
72 	B_FONT_SPACING     			= 0x00000010,
73 	B_FONT_ENCODING				= 0x00000020,
74 	B_FONT_FACE					= 0x00000040,
75 	B_FONT_FLAGS				= 0x00000080,
76 	B_FONT_FALSE_BOLD_WIDTH		= 0x00000100,
77 	B_FONT_ALL					= 0x000001FF
78 };
79 
80 // view flags
81 const uint32 B_FULL_UPDATE_ON_RESIZE 	= 0x80000000UL;	/* 31 */
82 const uint32 _B_RESERVED1_ 				= 0x40000000UL;	/* 30 */
83 const uint32 B_WILL_DRAW 				= 0x20000000UL;	/* 29 */
84 const uint32 B_PULSE_NEEDED 			= 0x10000000UL;	/* 28 */
85 const uint32 B_NAVIGABLE_JUMP 			= 0x08000000UL;	/* 27 */
86 const uint32 B_FRAME_EVENTS				= 0x04000000UL;	/* 26 */
87 const uint32 B_NAVIGABLE 				= 0x02000000UL;	/* 25 */
88 const uint32 B_SUBPIXEL_PRECISE 		= 0x01000000UL;	/* 24 */
89 const uint32 B_DRAW_ON_CHILDREN 		= 0x00800000UL;	/* 23 */
90 const uint32 B_INPUT_METHOD_AWARE 		= 0x00400000UL;	/* 23 */
91 const uint32 _B_RESERVED7_ 				= 0x00200000UL;	/* 22 */
92 const uint32 B_SUPPORTS_LAYOUT			= 0x00100000UL;	/* 21 */
93 const uint32 B_INVALIDATE_AFTER_LAYOUT	= 0x00080000UL;	/* 20 */
94 
95 #define _RESIZE_MASK_ (0xffff)
96 
97 const uint32 _VIEW_TOP_ 	= 1UL;
98 const uint32 _VIEW_LEFT_ 	= 2UL;
99 const uint32 _VIEW_BOTTOM_ 	= 3UL;
100 const uint32 _VIEW_RIGHT_ 	= 4UL;
101 const uint32 _VIEW_CENTER_ 	= 5UL;
102 
103 inline uint32 _rule_(uint32 r1, uint32 r2, uint32 r3, uint32 r4)
104 	{ return ((r1 << 12) | (r2 << 8) | (r3 << 4) | r4); }
105 
106 #define B_FOLLOW_NONE 0
107 #define B_FOLLOW_ALL_SIDES	_rule_(_VIEW_TOP_, _VIEW_LEFT_, _VIEW_BOTTOM_, _VIEW_RIGHT_)
108 #define B_FOLLOW_ALL  		B_FOLLOW_ALL_SIDES
109 
110 #define B_FOLLOW_LEFT		_rule_(0, _VIEW_LEFT_, 0, _VIEW_LEFT_)
111 #define B_FOLLOW_RIGHT		_rule_(0, _VIEW_RIGHT_, 0, _VIEW_RIGHT_)
112 #define B_FOLLOW_LEFT_RIGHT	_rule_(0, _VIEW_LEFT_, 0, _VIEW_RIGHT_)
113 #define B_FOLLOW_H_CENTER	_rule_(0, _VIEW_CENTER_, 0, _VIEW_CENTER_)
114 
115 #define B_FOLLOW_TOP		_rule_(_VIEW_TOP_, 0, _VIEW_TOP_, 0)
116 #define B_FOLLOW_BOTTOM		_rule_(_VIEW_BOTTOM_, 0, _VIEW_BOTTOM_, 0)
117 #define B_FOLLOW_TOP_BOTTOM	_rule_(_VIEW_TOP_, 0, _VIEW_BOTTOM_, 0)
118 #define B_FOLLOW_V_CENTER	_rule_(_VIEW_CENTER_, 0, _VIEW_CENTER_, 0)
119 
120 class BBitmap;
121 class BCursor;
122 class BLayout;
123 class BLayoutContext;
124 class BLayoutItem;
125 class BMessage;
126 class BPicture;
127 class BPolygon;
128 class BRegion;
129 class BScrollBar;
130 class BScrollView;
131 class BShape;
132 class BShelf;
133 class BString;
134 class BWindow;
135 struct _array_data_;
136 struct _array_hdr_;
137 struct overlay_restrictions;
138 
139 namespace BPrivate {
140 	class ViewState;
141 };
142 
143 
144 class BView : public BHandler {
145 public:
146 							BView(const char* name, uint32 flags,
147 								BLayout* layout = NULL);
148 							BView(BRect frame, const char* name,
149 								uint32 resizeMask, uint32 flags);
150 	virtual					~BView();
151 
152 							BView(BMessage* data);
153 	static	BArchivable*	Instantiate(BMessage* data);
154 	virtual	status_t		Archive(BMessage* data, bool deep = true) const;
155 
156 	virtual	void			AttachedToWindow();
157 	virtual	void			AllAttached();
158 	virtual	void			DetachedFromWindow();
159 	virtual	void			AllDetached();
160 
161 	virtual	void			MessageReceived(BMessage* msg);
162 
163 			void			AddChild(BView* child, BView* before = NULL);
164 			bool			AddChild(BLayoutItem* child);
165 			bool			RemoveChild(BView* child);
166 			int32			CountChildren() const;
167 			BView*			ChildAt(int32 index) const;
168 			BView*			NextSibling() const;
169 			BView*			PreviousSibling() const;
170 			bool			RemoveSelf();
171 
172 			BWindow*		Window() const;
173 
174 	virtual	void			Draw(BRect updateRect);
175 	virtual	void			MouseDown(BPoint where);
176 	virtual	void			MouseUp(BPoint where);
177 	virtual	void			MouseMoved(BPoint where, uint32 code,
178 								const BMessage* dragMessage);
179 	virtual	void			WindowActivated(bool state);
180 	virtual	void			KeyDown(const char* bytes, int32 numBytes);
181 	virtual	void			KeyUp(const char* bytes, int32 numBytes);
182 	virtual	void			Pulse();
183 	virtual	void			FrameMoved(BPoint newPosition);
184 	virtual	void			FrameResized(float newWidth, float newHeight);
185 
186 	virtual	void			TargetedByScrollView(BScrollView* scrollView);
187 			void			BeginRectTracking(BRect startRect,
188 								uint32 style = B_TRACK_WHOLE_RECT);
189 			void			EndRectTracking();
190 
191 			void			GetMouse(BPoint* location, uint32* buttons,
192 								bool checkMessageQueue = true);
193 
194 			void			DragMessage(BMessage* message, BRect dragRect,
195 								BHandler* replyTo = NULL);
196 			void			DragMessage(BMessage* message, BBitmap* bitmap,
197 								BPoint offset, BHandler* replyTo = NULL);
198 			void			DragMessage(BMessage* message, BBitmap* bitmap,
199 								drawing_mode dragMode, BPoint offset,
200 								BHandler* replyTo = NULL);
201 
202 			BView*			FindView(const char* name) const;
203 			BView*			Parent() const;
204 			BRect			Bounds() const;
205 			BRect			Frame() const;
206 			void			ConvertToScreen(BPoint* pt) const;
207 			BPoint			ConvertToScreen(BPoint pt) const;
208 			void			ConvertFromScreen(BPoint* pt) const;
209 			BPoint			ConvertFromScreen(BPoint pt) const;
210 			void			ConvertToScreen(BRect* r) const;
211 			BRect			ConvertToScreen(BRect r) const;
212 			void			ConvertFromScreen(BRect* r) const;
213 			BRect			ConvertFromScreen(BRect r) const;
214 			void			ConvertToParent(BPoint* pt) const;
215 			BPoint			ConvertToParent(BPoint pt) const;
216 			void			ConvertFromParent(BPoint* pt) const;
217 			BPoint			ConvertFromParent(BPoint pt) const;
218 			void			ConvertToParent(BRect* r) const;
219 			BRect			ConvertToParent(BRect r) const;
220 			void			ConvertFromParent(BRect* r) const;
221 			BRect			ConvertFromParent(BRect r) const;
222 			BPoint			LeftTop() const;
223 
224 			void			GetClippingRegion(BRegion* region) const;
225 	virtual	void			ConstrainClippingRegion(BRegion* region);
226 			void			ClipToPicture(BPicture* picture,
227 								BPoint where = B_ORIGIN, bool sync = true);
228 			void			ClipToInversePicture(BPicture* picture,
229 								BPoint where = B_ORIGIN, bool sync = true);
230 
231 	virtual	void			SetDrawingMode(drawing_mode mode);
232 			drawing_mode 	DrawingMode() const;
233 
234 			void			SetBlendingMode(source_alpha srcAlpha,
235 								alpha_function alphaFunc);
236 			void	 		GetBlendingMode(source_alpha* srcAlpha,
237 								alpha_function* alphaFunc) const;
238 
239 	virtual	void			SetPenSize(float size);
240 			float			PenSize() const;
241 
242 			void			SetViewCursor(const BCursor* cursor,
243 								bool sync = true);
244 
245 	virtual	void			SetViewColor(rgb_color c);
246 			void			SetViewColor(uchar r, uchar g, uchar b,
247 								uchar a = 255);
248 			rgb_color		ViewColor() const;
249 
250 			void			SetViewBitmap(const BBitmap* bitmap,
251 								BRect srcRect, BRect dstRect,
252 								uint32 followFlags
253 									= B_FOLLOW_TOP | B_FOLLOW_LEFT,
254 								uint32 options = B_TILE_BITMAP);
255 			void			SetViewBitmap(const BBitmap* bitmap,
256 								uint32 followFlags
257 									= B_FOLLOW_TOP | B_FOLLOW_LEFT,
258 								uint32 options = B_TILE_BITMAP);
259 			void			ClearViewBitmap();
260 
261 			status_t		SetViewOverlay(const BBitmap* overlay,
262 								BRect srcRect, BRect dstRect,
263 								rgb_color* colorKey,
264 								uint32 followFlags
265 									= B_FOLLOW_TOP | B_FOLLOW_LEFT,
266 								uint32 options = 0);
267 			status_t		SetViewOverlay(const BBitmap* overlay,
268 								rgb_color* colorKey,
269 								uint32 followFlags
270 									= B_FOLLOW_TOP | B_FOLLOW_LEFT,
271 								uint32 options = 0);
272 			void			ClearViewOverlay();
273 
274 	virtual	void			SetHighColor(rgb_color a_color);
275 			void			SetHighColor(uchar r, uchar g, uchar b,
276 								uchar a = 255);
277 			rgb_color		HighColor() const;
278 
279 	virtual	void			SetLowColor(rgb_color a_color);
280 			void			SetLowColor(uchar r, uchar g, uchar b,
281 								uchar a = 255);
282 			rgb_color		LowColor() const;
283 
284 			void			SetLineMode(cap_mode lineCap, join_mode lineJoin,
285 								float miterLimit = B_DEFAULT_MITER_LIMIT);
286 			join_mode		LineJoinMode() const;
287 			cap_mode		LineCapMode() const;
288 			float			LineMiterLimit() const;
289 
290 			void			SetOrigin(BPoint pt);
291 			void			SetOrigin(float x, float y);
292 			BPoint			Origin() const;
293 
294 			void			PushState();
295 			void			PopState();
296 
297 			void			MovePenTo(BPoint pt);
298 			void			MovePenTo(float x, float y);
299 			void			MovePenBy(float x, float y);
300 			BPoint			PenLocation() const;
301 			void			StrokeLine(BPoint toPt, pattern p = B_SOLID_HIGH);
302 			void			StrokeLine(BPoint a, BPoint b,
303 								pattern p = B_SOLID_HIGH);
304 			void			BeginLineArray(int32 count);
305 			void			AddLine(BPoint a, BPoint b, rgb_color color);
306 			void			EndLineArray();
307 
308 			void			StrokePolygon(const BPolygon* polygon,
309 								bool closed = true, pattern p = B_SOLID_HIGH);
310 			void			StrokePolygon(const BPoint* ptArray, int32 numPts,
311 								bool closed = true, pattern p = B_SOLID_HIGH);
312 			void			StrokePolygon(const BPoint* ptArray, int32 numPts,
313 								BRect bounds, bool closed = true,
314 								pattern p = B_SOLID_HIGH);
315 			void			FillPolygon(const BPolygon* polygon,
316 								pattern p = B_SOLID_HIGH);
317 			void			FillPolygon(const BPoint* ptArray, int32 numPts,
318 								pattern p = B_SOLID_HIGH);
319 			void			FillPolygon(const BPoint* ptArray, int32 numPts,
320 								BRect bounds, pattern p = B_SOLID_HIGH);
321 			void			FillPolygon(const BPolygon* polygon,
322 								const BGradient& gradient);
323 			void			FillPolygon(const BPoint* ptArray, int32 numPts,
324 								const BGradient& gradient);
325 			void			FillPolygon(const BPoint* ptArray, int32 numPts,
326 								BRect bounds, const BGradient& gradient);
327 
328 			void			StrokeTriangle(BPoint pt1, BPoint pt2, BPoint pt3,
329 								BRect bounds, pattern p = B_SOLID_HIGH);
330 			void			StrokeTriangle(BPoint pt1, BPoint pt2, BPoint pt3,
331 								pattern p = B_SOLID_HIGH);
332 			void			FillTriangle(BPoint pt1, BPoint pt2, BPoint pt3,
333 								pattern p = B_SOLID_HIGH);
334 			void			FillTriangle(BPoint pt1, BPoint pt2, BPoint pt3,
335 								BRect bounds, pattern p = B_SOLID_HIGH);
336 			void			FillTriangle(BPoint pt1, BPoint pt2, BPoint pt3,
337 								const BGradient& gradient);
338 			void			FillTriangle(BPoint pt1, BPoint pt2, BPoint pt3,
339 								BRect bounds, const BGradient& gradient);
340 
341 			void			StrokeRect(BRect r, pattern p = B_SOLID_HIGH);
342 			void			FillRect(BRect r, pattern p = B_SOLID_HIGH);
343 			void			FillRect(BRect r, const BGradient& gradient);
344 			void			FillRegion(BRegion* region,
345 								pattern p = B_SOLID_HIGH);
346 			void			FillRegion(BRegion* region,
347 							   const BGradient& gradient);
348 			void			InvertRect(BRect r);
349 
350 			void			StrokeRoundRect(BRect r, float xRadius,
351 								float yRadius, pattern p = B_SOLID_HIGH);
352 			void			FillRoundRect(BRect r, float xRadius, float yRadius,
353 								pattern p = B_SOLID_HIGH);
354 			void			FillRoundRect(BRect r, float xRadius, float yRadius,
355 								const BGradient& gradient);
356 
357 			void			StrokeEllipse(BPoint center, float xRadius,
358 								float yRadius, pattern p = B_SOLID_HIGH);
359 			void			StrokeEllipse(BRect r, pattern p = B_SOLID_HIGH);
360 			void			FillEllipse(BPoint center, float xRadius,
361 								float yRadius, pattern p = B_SOLID_HIGH);
362 			void			FillEllipse(BRect r, pattern p = B_SOLID_HIGH);
363 			void			FillEllipse(BPoint center, float xRadius,
364 								float yRadius, const BGradient& gradient);
365 			void			FillEllipse(BRect r, const BGradient& gradient);
366 
367 			void			StrokeArc(BPoint center, float xRadius,
368 								float yRadius, float startAngle, float arcAngle,
369 								pattern p = B_SOLID_HIGH);
370 			void			StrokeArc(BRect r, float startAngle,
371 								float arcAngle, pattern p = B_SOLID_HIGH);
372 			void			FillArc(BPoint center, float xRadius, float yRadius,
373 								float startAngle, float arcAngle,
374 								pattern p = B_SOLID_HIGH);
375 			void			FillArc(BRect r, float startAngle, float arcAngle,
376 								pattern p = B_SOLID_HIGH);
377 			void			FillArc(BPoint center, float xRadius, float yRadius,
378 								float startAngle, float arcAngle,
379 								const BGradient& gradient);
380 			void			FillArc(BRect r, float startAngle, float arcAngle,
381 								const BGradient& gradient);
382 
383 			void			StrokeBezier(BPoint* controlPoints,
384 								pattern p = B_SOLID_HIGH);
385 			void			FillBezier(BPoint* controlPoints,
386 								pattern p = B_SOLID_HIGH);
387 			void			FillBezier(BPoint* controlPoints,
388 							   const BGradient& gradient);
389 
390 			void			StrokeShape(BShape* shape,
391 								pattern p = B_SOLID_HIGH);
392 			void			FillShape(BShape* shape, pattern p = B_SOLID_HIGH);
393 			void			FillShape(BShape* shape, const BGradient& gradient);
394 
395 			void			CopyBits(BRect src, BRect dst);
396 
397 			void			DrawBitmapAsync(const BBitmap* aBitmap,
398 								BRect bitmapRect, BRect viewRect,
399 								uint32 options);
400 			void			DrawBitmapAsync(const BBitmap* aBitmap,
401 								BRect bitmapRect, BRect viewRect);
402 			void			DrawBitmapAsync(const BBitmap* aBitmap,
403 								BRect viewRect);
404 			void			DrawBitmapAsync(const BBitmap* aBitmap,
405 								BPoint where);
406 			void			DrawBitmapAsync(const BBitmap* aBitmap);
407 
408 			void			DrawBitmap(const BBitmap* aBitmap,
409 								BRect bitmapRect, BRect viewRect,
410 								uint32 options);
411 			void			DrawBitmap(const BBitmap* aBitmap,
412 								BRect bitmapRect, BRect viewRect);
413 			void			DrawBitmap(const BBitmap* aBitmap,
414 								BRect viewRect);
415 			void			DrawBitmap(const BBitmap* aBitmap,
416 								BPoint where);
417 			void			DrawBitmap(const BBitmap* aBitmap);
418 
419 			void			DrawChar(char aChar);
420 			void			DrawChar(char aChar, BPoint location);
421 			void			DrawString(const char* aString,
422 								escapement_delta* delta = NULL);
423 			void			DrawString(const char* aString, BPoint location,
424 								escapement_delta* delta = NULL);
425 			void			DrawString(const char* aString, int32 length,
426 								escapement_delta* delta = NULL);
427 			void			DrawString(const char* aString, int32 length,
428 								BPoint location, escapement_delta* delta = 0L);
429 
430 	virtual void            SetFont(const BFont* font,
431 								uint32 mask = B_FONT_ALL);
432 
433 			void            GetFont(BFont* font) const;
434 			void			TruncateString(BString* in_out, uint32 mode,
435 								float width) const;
436 			float			StringWidth(const char* string) const;
437 			float			StringWidth(const char* string, int32 length) const;
438 			void			GetStringWidths(char* stringArray[],
439 								int32 lengthArray[], int32 numStrings,
440 								float widthArray[]) const;
441 			void			SetFontSize(float size);
442 			void			ForceFontAliasing(bool enable);
443 			void			GetFontHeight(font_height* height) const;
444 
445 			void			Invalidate(BRect invalRect);
446 			void			Invalidate(const BRegion* invalRegion);
447 			void			Invalidate();
448 
449 			void			SetDiskMode(char* filename, long offset);
450 
451 			void			BeginPicture(BPicture* a_picture);
452 			void			AppendToPicture(BPicture* a_picture);
453 			BPicture*		EndPicture();
454 
455 			void			DrawPicture(const BPicture* a_picture);
456 			void			DrawPicture(const BPicture* a_picture,
457 								BPoint where);
458 			void			DrawPicture(const char* filename, long offset,
459 								BPoint where);
460 			void			DrawPictureAsync(const BPicture* a_picture);
461 			void			DrawPictureAsync(const BPicture* a_picture,
462 								BPoint where);
463 			void			DrawPictureAsync(const char* filename, long offset,
464 								BPoint where);
465 
466 			status_t		SetEventMask(uint32 mask, uint32 options = 0);
467 			uint32			EventMask();
468 			status_t		SetMouseEventMask(uint32 mask, uint32 options = 0);
469 
470 	virtual	void			SetFlags(uint32 flags);
471 			uint32			Flags() const;
472 	virtual	void			SetResizingMode(uint32 mode);
473 			uint32			ResizingMode() const;
474 			void			MoveBy(float dh, float dv);
475 			void			MoveTo(BPoint where);
476 			void			MoveTo(float x, float y);
477 			void			ResizeBy(float dh, float dv);
478 			void			ResizeTo(float width, float height);
479 			void			ResizeTo(BSize size);
480 			void			ScrollBy(float dh, float dv);
481 			void			ScrollTo(float x, float y);
482 	virtual	void			ScrollTo(BPoint where);
483 	virtual	void			MakeFocus(bool focusState = true);
484 			bool			IsFocus() const;
485 
486 	virtual	void			Show();
487 	virtual	void			Hide();
488 			bool			IsHidden() const;
489 			bool			IsHidden(const BView* looking_from) const;
490 
491 			void			Flush() const;
492 			void			Sync() const;
493 
494 	virtual	void			GetPreferredSize(float* width, float* height);
495 	virtual	void			ResizeToPreferred();
496 
497 			BScrollBar*		ScrollBar(orientation posture) const;
498 
499 	virtual BHandler*		ResolveSpecifier(BMessage* msg, int32 index,
500 								BMessage* specifier, int32 form,
501 								const char* property);
502 	virtual status_t		GetSupportedSuites(BMessage* data);
503 
504 			bool			IsPrinting() const;
505 			void			SetScale(float scale) const;
506 			float			Scale() const;
507 								// new for Haiku
508 
509 	virtual status_t		Perform(perform_code code, void* data);
510 
511 	virtual	void			DrawAfterChildren(BRect r);
512 
513 
514 			// layout related
515 
516 	virtual	BSize			MinSize();
517 	virtual	BSize			MaxSize();
518 	virtual	BSize			PreferredSize();
519 	virtual	BAlignment		LayoutAlignment();
520 
521 			void			SetExplicitMinSize(BSize size);
522 			void			SetExplicitMaxSize(BSize size);
523 			void			SetExplicitPreferredSize(BSize size);
524 			void			SetExplicitAlignment(BAlignment alignment);
525 
526 			BSize			ExplicitMinSize() const;
527 			BSize			ExplicitMaxSize() const;
528 			BSize			ExplicitPreferredSize() const;
529 			BAlignment		ExplicitAlignment() const;
530 
531 	virtual	bool			HasHeightForWidth();
532 	virtual	void			GetHeightForWidth(float width, float* min,
533 								float* max, float* preferred);
534 
535 	virtual	void			SetLayout(BLayout* layout);
536 			BLayout*		GetLayout() const;
537 
538 	virtual	void			InvalidateLayout(bool descendants = false);
539 			void			EnableLayoutInvalidation();
540 			void			DisableLayoutInvalidation();
541 			bool			IsLayoutValid() const;
542 
543 			BLayoutContext*	LayoutContext() const;
544 
545 			void			Layout(bool force);
546 			void			Relayout();
547 
548 protected:
549 	virtual	void			DoLayout();
550 
551 private:
552 			void			_Layout(bool force, BLayoutContext* context);
553 
554 private:
555 	struct LayoutData;
556 
557 	friend class BBitmap;
558 	friend class BLayout;
559 	friend class BPrintJob;
560 	friend class BScrollBar;
561 	friend class BShelf;
562 	friend class BTabView;
563 	friend class BWindow;
564 
565 	virtual	void			_ReservedView11();
566 	virtual	void			_ReservedView12();
567 	virtual	void			_ReservedView13();
568 	virtual	void			_ReservedView14();
569 	virtual	void			_ReservedView15();
570 	virtual	void			_ReservedView16();
571 
572 							BView(const BView&);
573 			BView&			operator=(const BView&);
574 
575 			void			_InitData(BRect frame, const char* name,
576 								uint32 resizeMask, uint32 flags);
577 			status_t		_SetViewBitmap(const BBitmap* bitmap,
578 								BRect srcRect, BRect dstRect,
579 								uint32 followFlags, uint32 options);
580 			void			_ClipToPicture(BPicture* picture, BPoint where,
581 								bool invert, bool sync);
582 
583 			bool			_CheckOwnerLockAndSwitchCurrent() const;
584 			bool			_CheckOwnerLock() const;
585 			void			_CheckLockAndSwitchCurrent() const;
586 			void			_CheckLock() const;
587 			void			_SwitchServerCurrentView() const;
588 
589 			void			_SetOwner(BWindow* newOwner);
590 			void			_RemoveCommArray();
591 
592 			BShelf*			_Shelf() const;
593 			void			_SetShelf(BShelf* shelf);
594 
595 			void			_MoveTo(int32 x, int32 y);
596 			void			_ResizeBy(int32 deltaWidth, int32 deltaHeight);
597 			void			_ParentResizedBy(int32 deltaWidth,
598 								int32 deltaHeight);
599 
600 			void			_ConvertToScreen(BPoint* pt, bool checkLock) const;
601 			void			_ConvertFromScreen(BPoint* pt,
602 								bool checkLock) const;
603 
604 			void			_ConvertToParent(BPoint* pt, bool checkLock) const;
605 			void			_ConvertFromParent(BPoint* pt,
606 								bool checkLock) const;
607 
608 
609 			void			_Activate(bool state);
610 			void			_Attach();
611 			void			_Detach();
612 			void			_Draw(BRect screenUpdateRect);
613 			void			_DrawAfterChildren(BRect screenUpdateRect);
614 			void			_Pulse();
615 
616 			void			_UpdateStateForRemove();
617 			void			_UpdatePattern(::pattern pattern);
618 
619 			void			_FlushIfNotInTransaction();
620 
621 			bool			_CreateSelf();
622 			bool			_AddChildToList(BView* child, BView* before = NULL);
623 			bool			_RemoveChildFromList(BView* child);
624 
625 			bool			_AddChild(BView *child, BView *before);
626 			bool			_RemoveSelf();
627 
628 			// Debugging methods
629 			void 			_PrintToStream();
630 			void			_PrintTree();
631 
632 			int32			server_token;
633 			uint32			fFlags;
634 			BPoint			fParentOffset;
635 			BWindow*		fOwner;
636 			BView*			fParent;
637 			BView*			fNextSibling;
638 			BView*			fPreviousSibling;
639 			BView*			fFirstChild;
640 
641 			int16 			fShowLevel;
642 			bool			fTopLevelView;
643 			bool			fNoISInteraction;
644 			BPicture*		fCurrentPicture;
645 			_array_data_*	fCommArray;
646 
647 			BScrollBar*		fVerScroller;
648 			BScrollBar*		fHorScroller;
649 			bool			fIsPrinting;
650 			bool			fAttached;
651 			bool			_unused_bool1;
652 			bool			_unused_bool2;
653 			BPrivate::ViewState*	fState;
654 			BRect			fBounds;
655 			BShelf*			fShelf;
656 			uint32			fEventMask;
657 			uint32			fEventOptions;
658 			uint32			fMouseEventOptions;
659 
660 			LayoutData*		fLayoutData;
661 
662 			uint32			_reserved[7];
663 };
664 
665 
666 // inline definitions ----------------------------------------------------------
667 
668 inline void
669 BView::ScrollTo(float x, float y)
670 {
671 	ScrollTo(BPoint(x, y));
672 }
673 
674 inline void
675 BView::SetViewColor(uchar r, uchar g, uchar b, uchar a)
676 {
677 	rgb_color color;
678 	color.red = r;
679 	color.green = g;
680 	color.blue = b;
681 	color.alpha = a;
682 	SetViewColor(color);
683 }
684 
685 inline void
686 BView::SetHighColor(uchar r, uchar g, uchar b, uchar a)
687 {
688 	rgb_color color;
689 	color.red = r;
690 	color.green = g;
691 	color.blue = b;
692 	color.alpha = a;
693 	SetHighColor(color);
694 }
695 
696 inline void
697 BView::SetLowColor(uchar r, uchar g, uchar b, uchar a)
698 {
699 	rgb_color color;
700 	color.red = r;
701 	color.green = g;
702 	color.blue = b;
703 	color.alpha = a;
704 	SetLowColor(color);
705 }
706 
707 #endif	// _VIEW_H
708