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