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