* Added layout-friendly constructors and implemented Min/Max/PreferredSize(),
and DoLayout(). When the B_SUPPORTS_LAYOUT view flag is set (as is by default when using one of the new constructors) the BBox completely manages one true child (the first child that is not the label view). * Centralized the layout related computation in new method _ValidateLayoutData(). The computed infos are cached in a new private LayoutData structure. * GetPreferredSize() was broken in several respects. It does now return the same result as PreferredSize(). If B_SUPPORTS_LAYOUT is not set, these are the sums of the insets induces by the frame and the label. I.e. those values can for instance be added to the child's preferred size to compute the preferred size of the compound. Not sure, if the Haiku-only TopBorderOffset() and InnerFrame() functions still make sense. With layout management they're actually superfluous. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21356 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -12,10 +12,17 @@
|
||||
class BBox : public BView {
|
||||
public:
|
||||
BBox(BRect frame, const char *name = NULL,
|
||||
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
uint32 resizingMode = B_FOLLOW_LEFT
|
||||
| B_FOLLOW_TOP,
|
||||
uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS
|
||||
| B_NAVIGABLE_JUMP,
|
||||
border_style border = B_FANCY_BORDER);
|
||||
BBox(const char* name,
|
||||
uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS
|
||||
| B_NAVIGABLE_JUMP,
|
||||
border_style border = B_FANCY_BORDER,
|
||||
BView* child = NULL);
|
||||
BBox(border_style border, BView* child);
|
||||
virtual ~BBox();
|
||||
|
||||
/* Archiving */
|
||||
@@ -60,7 +67,16 @@ class BBox : public BView {
|
||||
|
||||
virtual status_t Perform(perform_code d, void* arg);
|
||||
|
||||
virtual BSize MinSize();
|
||||
virtual BSize MaxSize();
|
||||
virtual BSize PreferredSize();
|
||||
|
||||
virtual void InvalidateLayout(bool descendants = false);
|
||||
virtual void DoLayout();
|
||||
|
||||
private:
|
||||
struct LayoutData;
|
||||
|
||||
virtual void _ReservedBox1();
|
||||
virtual void _ReservedBox2();
|
||||
|
||||
@@ -71,11 +87,14 @@ class BBox : public BView {
|
||||
void _DrawFancy(BRect labelBox);
|
||||
void _ClearLabel();
|
||||
|
||||
BView* _Child() const;
|
||||
void _ValidateLayoutData();
|
||||
|
||||
char* fLabel;
|
||||
BRect fBounds;
|
||||
border_style fStyle;
|
||||
BView* fLabelView;
|
||||
BRect* fLabelBox;
|
||||
LayoutData* fLayoutData;
|
||||
};
|
||||
|
||||
#endif // _BOX_H
|
||||
|
||||
Reference in New Issue
Block a user