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