1 /* 2 * Copyright 2005-2006, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _BOX_H 6 #define _BOX_H 7 8 9 #include <View.h> 10 11 12 class BBox : public BView { 13 public: 14 BBox(BRect frame, const char *name = NULL, 15 uint32 resizingMode = B_FOLLOW_LEFT 16 | B_FOLLOW_TOP, 17 uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS 18 | B_NAVIGABLE_JUMP, 19 border_style border = B_FANCY_BORDER); 20 BBox(const char* name, 21 uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS 22 | B_NAVIGABLE_JUMP, 23 border_style border = B_FANCY_BORDER, 24 BView* child = NULL); 25 BBox(border_style border, BView* child); 26 virtual ~BBox(); 27 28 /* Archiving */ 29 BBox(BMessage* archive); 30 static BArchivable* Instantiate(BMessage* archive); 31 virtual status_t Archive(BMessage* archive, bool deep = true) const; 32 33 virtual void SetBorder(border_style border); 34 border_style Border() const; 35 36 float TopBorderOffset(); 37 BRect InnerFrame(); 38 39 void SetLabel(const char* string); 40 status_t SetLabel(BView* viewLabel); 41 42 const char* Label() const; 43 BView* LabelView() const; 44 45 virtual void Draw(BRect updateRect); 46 virtual void AttachedToWindow(); 47 virtual void DetachedFromWindow(); 48 virtual void AllAttached(); 49 virtual void AllDetached(); 50 virtual void FrameResized(float width, float height); 51 virtual void MessageReceived(BMessage* message); 52 virtual void MouseDown(BPoint point); 53 virtual void MouseUp(BPoint point); 54 virtual void WindowActivated(bool active); 55 virtual void MouseMoved(BPoint point, uint32 transit, 56 const BMessage* dragMessage); 57 virtual void FrameMoved(BPoint newLocation); 58 59 virtual BHandler* ResolveSpecifier(BMessage* message, 60 int32 index, BMessage* specifier, 61 int32 what, const char* property); 62 63 virtual void ResizeToPreferred(); 64 virtual void GetPreferredSize(float* _width, float* _height); 65 virtual void MakeFocus(bool focused = true); 66 virtual status_t GetSupportedSuites(BMessage* message); 67 68 virtual status_t Perform(perform_code d, void* arg); 69 70 virtual BSize MinSize(); 71 virtual BSize MaxSize(); 72 virtual BSize PreferredSize(); 73 74 protected: 75 virtual void LayoutInvalidated(bool descendants = false); 76 virtual void DoLayout(); 77 78 private: 79 struct LayoutData; 80 81 virtual void _ReservedBox1(); 82 virtual void _ReservedBox2(); 83 84 BBox &operator=(const BBox &); 85 86 void _InitObject(BMessage* data = NULL); 87 void _DrawPlain(BRect labelBox); 88 void _DrawFancy(BRect labelBox); 89 void _ClearLabel(); 90 91 BView* _Child() const; 92 void _ValidateLayoutData(); 93 94 char* fLabel; 95 BRect fBounds; 96 border_style fStyle; 97 BView* fLabelView; 98 LayoutData* fLayoutData; 99 }; 100 101 #endif // _BOX_H 102