1f17cfabcSAxel Dörfler /* 2*7f9368caSlooncraz * Copyright 2005-2015 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*7f9368caSlooncraz uint32 resizingMode = B_FOLLOW_LEFT_TOP, 16f17cfabcSAxel Dörfler uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS 17f17cfabcSAxel Dörfler | B_NAVIGABLE_JUMP, 1852a38012Sejakowatz border_style border = B_FANCY_BORDER); 19caf8aba2SIngo Weinhold BBox(const char* name, 20caf8aba2SIngo Weinhold uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS 21caf8aba2SIngo Weinhold | B_NAVIGABLE_JUMP, 22caf8aba2SIngo Weinhold border_style border = B_FANCY_BORDER, 23caf8aba2SIngo Weinhold BView* child = NULL); 24caf8aba2SIngo Weinhold BBox(border_style border, BView* child); 2552a38012Sejakowatz virtual ~BBox(); 2652a38012Sejakowatz 2752a38012Sejakowatz /* Archiving */ 2852a38012Sejakowatz BBox(BMessage* archive); 2952a38012Sejakowatz static BArchivable* Instantiate(BMessage* archive); 3052a38012Sejakowatz virtual status_t Archive(BMessage* archive, bool deep = true) const; 3152a38012Sejakowatz 3252a38012Sejakowatz virtual void SetBorder(border_style border); 3352a38012Sejakowatz border_style Border() const; 3452a38012Sejakowatz 35ef4aa90fSAxel Dörfler float TopBorderOffset(); 36ef4aa90fSAxel Dörfler BRect InnerFrame(); 37ef4aa90fSAxel Dörfler 3852a38012Sejakowatz void SetLabel(const char* string); 3952a38012Sejakowatz status_t SetLabel(BView* viewLabel); 4052a38012Sejakowatz 4152a38012Sejakowatz const char* Label() const; 4252a38012Sejakowatz BView* LabelView() const; 4352a38012Sejakowatz 4452a38012Sejakowatz virtual void Draw(BRect updateRect); 4552a38012Sejakowatz virtual void AttachedToWindow(); 4652a38012Sejakowatz virtual void DetachedFromWindow(); 4752a38012Sejakowatz virtual void AllAttached(); 4852a38012Sejakowatz virtual void AllDetached(); 4952a38012Sejakowatz virtual void FrameResized(float width, float height); 5052a38012Sejakowatz virtual void MessageReceived(BMessage* message); 5152a38012Sejakowatz virtual void MouseDown(BPoint point); 5252a38012Sejakowatz virtual void MouseUp(BPoint point); 5352a38012Sejakowatz virtual void WindowActivated(bool active); 5452a38012Sejakowatz virtual void MouseMoved(BPoint point, uint32 transit, 55f17cfabcSAxel Dörfler const BMessage* dragMessage); 5652a38012Sejakowatz virtual void FrameMoved(BPoint newLocation); 5752a38012Sejakowatz 5852a38012Sejakowatz virtual BHandler* ResolveSpecifier(BMessage* message, 59f17cfabcSAxel Dörfler int32 index, BMessage* specifier, 60f17cfabcSAxel Dörfler int32 what, const char* property); 6152a38012Sejakowatz 6252a38012Sejakowatz virtual void ResizeToPreferred(); 63f17cfabcSAxel Dörfler virtual void GetPreferredSize(float* _width, float* _height); 6452a38012Sejakowatz virtual void MakeFocus(bool focused = true); 6552a38012Sejakowatz virtual status_t GetSupportedSuites(BMessage* message); 6652a38012Sejakowatz 6752a38012Sejakowatz virtual status_t Perform(perform_code d, void* arg); 6852a38012Sejakowatz 69caf8aba2SIngo Weinhold virtual BSize MinSize(); 70caf8aba2SIngo Weinhold virtual BSize MaxSize(); 71caf8aba2SIngo Weinhold virtual BSize PreferredSize(); 72d3765546SRene Gollent virtual BAlignment LayoutAlignment(); 73caf8aba2SIngo Weinhold 74eee4243dSAlex Wilson protected: 75eee4243dSAlex Wilson virtual void LayoutInvalidated(bool descendants = false); 76caf8aba2SIngo Weinhold virtual void DoLayout(); 77caf8aba2SIngo Weinhold 7852a38012Sejakowatz private: 79caf8aba2SIngo Weinhold struct LayoutData; 80caf8aba2SIngo Weinhold 8152a38012Sejakowatz virtual void _ReservedBox1(); 8252a38012Sejakowatz virtual void _ReservedBox2(); 8352a38012Sejakowatz 8452a38012Sejakowatz BBox &operator=(const BBox &); 8552a38012Sejakowatz 86f17cfabcSAxel Dörfler void _InitObject(BMessage* data = NULL); 87f17cfabcSAxel Dörfler void _DrawPlain(BRect labelBox); 88f17cfabcSAxel Dörfler void _DrawFancy(BRect labelBox); 89f17cfabcSAxel Dörfler void _ClearLabel(); 9052a38012Sejakowatz 91caf8aba2SIngo Weinhold BView* _Child() const; 92caf8aba2SIngo Weinhold void _ValidateLayoutData(); 93caf8aba2SIngo Weinhold 9452a38012Sejakowatz char* fLabel; 9552a38012Sejakowatz BRect fBounds; 9652a38012Sejakowatz border_style fStyle; 9752a38012Sejakowatz BView* fLabelView; 98caf8aba2SIngo Weinhold LayoutData* fLayoutData; 9952a38012Sejakowatz }; 10052a38012Sejakowatz 10152a38012Sejakowatz #endif // _BOX_H 102