haiku/headers/os/interface/Box.h
Ingo Weinhold caf8aba2c9 * 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
2007-06-08 23:40:16 +00:00

101 lines
2.7 KiB
C++

/*
* Copyright 2005-2006, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _BOX_H
#define _BOX_H
#include <View.h>
class BBox : public BView {
public:
BBox(BRect frame, const char *name = NULL,
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 */
BBox(BMessage* archive);
static BArchivable* Instantiate(BMessage* archive);
virtual status_t Archive(BMessage* archive, bool deep = true) const;
virtual void SetBorder(border_style border);
border_style Border() const;
float TopBorderOffset();
BRect InnerFrame();
void SetLabel(const char* string);
status_t SetLabel(BView* viewLabel);
const char* Label() const;
BView* LabelView() const;
virtual void Draw(BRect updateRect);
virtual void AttachedToWindow();
virtual void DetachedFromWindow();
virtual void AllAttached();
virtual void AllDetached();
virtual void FrameResized(float width, float height);
virtual void MessageReceived(BMessage* message);
virtual void MouseDown(BPoint point);
virtual void MouseUp(BPoint point);
virtual void WindowActivated(bool active);
virtual void MouseMoved(BPoint point, uint32 transit,
const BMessage* dragMessage);
virtual void FrameMoved(BPoint newLocation);
virtual BHandler* ResolveSpecifier(BMessage* message,
int32 index, BMessage* specifier,
int32 what, const char* property);
virtual void ResizeToPreferred();
virtual void GetPreferredSize(float* _width, float* _height);
virtual void MakeFocus(bool focused = true);
virtual status_t GetSupportedSuites(BMessage* message);
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();
BBox &operator=(const BBox &);
void _InitObject(BMessage* data = NULL);
void _DrawPlain(BRect labelBox);
void _DrawFancy(BRect labelBox);
void _ClearLabel();
BView* _Child() const;
void _ValidateLayoutData();
char* fLabel;
BRect fBounds;
border_style fStyle;
BView* fLabelView;
LayoutData* fLayoutData;
};
#endif // _BOX_H