1f17cfabcSAxel Dörfler /* 2ef4aa90fSAxel Dörfler * Copyright 2005-2006, Haiku, Inc. All Rights Reserved. 3f17cfabcSAxel Dörfler * Distributed under the terms of the MIT License. 4f17cfabcSAxel Dörfler */ 552a38012Sejakowatz #ifndef _BOX_H 652a38012Sejakowatz #define _BOX_H 752a38012Sejakowatz 852a38012Sejakowatz 952a38012Sejakowatz #include <View.h> 1052a38012Sejakowatz 1152a38012Sejakowatz 1252a38012Sejakowatz class BBox : public BView { 1352a38012Sejakowatz public: 14f17cfabcSAxel Dörfler BBox(BRect frame, const char *name = NULL, 15*caf8aba2SIngo Weinhold uint32 resizingMode = B_FOLLOW_LEFT 16*caf8aba2SIngo Weinhold | B_FOLLOW_TOP, 17f17cfabcSAxel Dörfler uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS 18f17cfabcSAxel Dörfler | B_NAVIGABLE_JUMP, 1952a38012Sejakowatz border_style border = B_FANCY_BORDER); 20*caf8aba2SIngo Weinhold BBox(const char* name, 21*caf8aba2SIngo Weinhold uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS 22*caf8aba2SIngo Weinhold | B_NAVIGABLE_JUMP, 23*caf8aba2SIngo Weinhold border_style border = B_FANCY_BORDER, 24*caf8aba2SIngo Weinhold BView* child = NULL); 25*caf8aba2SIngo Weinhold BBox(border_style border, BView* child); 2652a38012Sejakowatz virtual ~BBox(); 2752a38012Sejakowatz 2852a38012Sejakowatz /* Archiving */ 2952a38012Sejakowatz BBox(BMessage* archive); 3052a38012Sejakowatz static BArchivable* Instantiate(BMessage* archive); 3152a38012Sejakowatz virtual status_t Archive(BMessage* archive, bool deep = true) const; 3252a38012Sejakowatz 3352a38012Sejakowatz virtual void SetBorder(border_style border); 3452a38012Sejakowatz border_style Border() const; 3552a38012Sejakowatz 36ef4aa90fSAxel Dörfler float TopBorderOffset(); 37ef4aa90fSAxel Dörfler BRect InnerFrame(); 38ef4aa90fSAxel Dörfler 3952a38012Sejakowatz void SetLabel(const char* string); 4052a38012Sejakowatz status_t SetLabel(BView* viewLabel); 4152a38012Sejakowatz 4252a38012Sejakowatz const char* Label() const; 4352a38012Sejakowatz BView* LabelView() const; 4452a38012Sejakowatz 4552a38012Sejakowatz virtual void Draw(BRect updateRect); 4652a38012Sejakowatz virtual void AttachedToWindow(); 4752a38012Sejakowatz virtual void DetachedFromWindow(); 4852a38012Sejakowatz virtual void AllAttached(); 4952a38012Sejakowatz virtual void AllDetached(); 5052a38012Sejakowatz virtual void FrameResized(float width, float height); 5152a38012Sejakowatz virtual void MessageReceived(BMessage* message); 5252a38012Sejakowatz virtual void MouseDown(BPoint point); 5352a38012Sejakowatz virtual void MouseUp(BPoint point); 5452a38012Sejakowatz virtual void WindowActivated(bool active); 5552a38012Sejakowatz virtual void MouseMoved(BPoint point, uint32 transit, 56f17cfabcSAxel Dörfler const BMessage* dragMessage); 5752a38012Sejakowatz virtual void FrameMoved(BPoint newLocation); 5852a38012Sejakowatz 5952a38012Sejakowatz virtual BHandler* ResolveSpecifier(BMessage* message, 60f17cfabcSAxel Dörfler int32 index, BMessage* specifier, 61f17cfabcSAxel Dörfler int32 what, const char* property); 6252a38012Sejakowatz 6352a38012Sejakowatz virtual void ResizeToPreferred(); 64f17cfabcSAxel Dörfler virtual void GetPreferredSize(float* _width, float* _height); 6552a38012Sejakowatz virtual void MakeFocus(bool focused = true); 6652a38012Sejakowatz virtual status_t GetSupportedSuites(BMessage* message); 6752a38012Sejakowatz 6852a38012Sejakowatz virtual status_t Perform(perform_code d, void* arg); 6952a38012Sejakowatz 70*caf8aba2SIngo Weinhold virtual BSize MinSize(); 71*caf8aba2SIngo Weinhold virtual BSize MaxSize(); 72*caf8aba2SIngo Weinhold virtual BSize PreferredSize(); 73*caf8aba2SIngo Weinhold 74*caf8aba2SIngo Weinhold virtual void InvalidateLayout(bool descendants = false); 75*caf8aba2SIngo Weinhold virtual void DoLayout(); 76*caf8aba2SIngo Weinhold 7752a38012Sejakowatz private: 78*caf8aba2SIngo Weinhold struct LayoutData; 79*caf8aba2SIngo Weinhold 8052a38012Sejakowatz virtual void _ReservedBox1(); 8152a38012Sejakowatz virtual void _ReservedBox2(); 8252a38012Sejakowatz 8352a38012Sejakowatz BBox &operator=(const BBox &); 8452a38012Sejakowatz 85f17cfabcSAxel Dörfler void _InitObject(BMessage* data = NULL); 86f17cfabcSAxel Dörfler void _DrawPlain(BRect labelBox); 87f17cfabcSAxel Dörfler void _DrawFancy(BRect labelBox); 88f17cfabcSAxel Dörfler void _ClearLabel(); 8952a38012Sejakowatz 90*caf8aba2SIngo Weinhold BView* _Child() const; 91*caf8aba2SIngo Weinhold void _ValidateLayoutData(); 92*caf8aba2SIngo Weinhold 9352a38012Sejakowatz char* fLabel; 9452a38012Sejakowatz BRect fBounds; 9552a38012Sejakowatz border_style fStyle; 9652a38012Sejakowatz BView* fLabelView; 97*caf8aba2SIngo Weinhold LayoutData* fLayoutData; 9852a38012Sejakowatz }; 9952a38012Sejakowatz 10052a38012Sejakowatz #endif // _BOX_H 101