An empty layout item that expands into empty space based on its size configuration. More...
Inherits BLayoutItem.
Public Member Functions | |
BSpaceLayoutItem (BMessage *archive) | |
Constructs a BSpaceLayoutItem from an archive message. | |
BSpaceLayoutItem (BSize minSize, BSize maxSize, BSize preferredSize, BAlignment alignment) | |
Create a space layout item with specific properties. | |
virtual | ~BSpaceLayoutItem () |
Destructor. | |
virtual BAlignment | Alignment () |
virtual status_t | Archive (BMessage *into, bool deep=true) const |
Archive the object into a BMessage. | |
virtual BRect | Frame () |
virtual bool | IsVisible () |
Return the current local visibility of this item. | |
virtual BSize | MaxSize () |
virtual BSize | MinSize () |
virtual BSize | PreferredSize () |
virtual void | SetExplicitAlignment (BAlignment alignment) |
virtual void | SetExplicitMaxSize (BSize size) |
virtual void | SetExplicitMinSize (BSize size) |
virtual void | SetExplicitPreferredSize (BSize size) |
virtual void | SetFrame (BRect frame) |
virtual void | SetVisible (bool visible) |
Set the visibility of this space layout item. | |
Public Member Functions inherited from BLayoutItem | |
BLayoutItem (BMessage *from) | |
Archive constructor. | |
virtual status_t | Archive (BMessage *into, bool deep=true) const |
Archive the object into a BMessage. | |
BLayout * | Layout () const |
Returns the BLayout this BLayoutItem resides in. | |
virtual status_t | Perform (perform_code d, void *arg) |
Perform some action (Internal method defined for binary compatibility purposes). | |
bool | RemoveSelf () |
Remove this layout item from the BLayout it is a part of. | |
virtual BView * | View () |
Return the BView this item is representing, or NULL if it does not represent any view. | |
virtual bool | HasHeightForWidth () |
Returns whether or not this BLayoutItem's height constraints are dependent on its width. | |
virtual void | GetHeightForWidth (float width, float *min, float *max, float *preferred) |
Get this BLayoutItem's height constraints for a given width. | |
void | SetExplicitSize (BSize size) |
Set the explicity size to size. | |
void | AlignInFrame (BRect frame) |
Position this BLayoutItem within frame, given the value returned by Alignment(), and the size constraints for this item. | |
virtual void | InvalidateLayout (bool children=false) |
Invalidate the layout of this item, or the object it represents. | |
virtual void | Relayout (bool immediate=false) |
Relayout any children or onscreen data this item contains. Often this request is forwarded to another object. | |
void * | LayoutData () const |
Retrieve arbitrary data attached to this BLayoutItem. | |
void | SetLayoutData (void *data) |
Attach arbitrary data to this BLayoutItem. | |
Public Member Functions inherited from BArchivable | |
BArchivable () | |
Constructor. Does nothing. | |
BArchivable (BMessage *from) | |
Constructor. Does important behind-the-scenes work in the unarchiving process. | |
virtual | ~BArchivable () |
Destructor. Does nothing. | |
virtual status_t | AllArchived (BMessage *archive) const |
Method relating to the use of BArchiver . | |
virtual status_t | AllUnarchived (const BMessage *archive) |
Method relating to the use of BUnarchiver . | |
virtual status_t | Archive (BMessage *into, bool deep=true) const |
Archive the object into a BMessage. | |
virtual status_t | Perform (perform_code d, void *arg) |
Perform some action (Internal method defined for binary compatibility purposes). | |
Static Public Member Functions | |
static BSpaceLayoutItem * | CreateGlue () |
Create a layout item that acts like glue. | |
static BSpaceLayoutItem * | CreateHorizontalStrut (float width) |
Create a layout item that horizontally expands to a maximum width. | |
static BSpaceLayoutItem * | CreateVerticalStrut (float height) |
Create a layout item that vertically expands to a maximum height. | |
static BArchivable * | Instantiate (BMessage *from) |
Instantiate the item from the message from. | |
Static Public Member Functions inherited from BArchivable | |
static BArchivable * | Instantiate (BMessage *archive) |
Static member to restore objects from messages. | |
Additional Inherited Members | |
Protected Member Functions inherited from BLayoutItem | |
virtual status_t | AllArchived (BMessage *into) const |
Method relating to the use of BArchiver . | |
virtual status_t | AllUnarchived (const BMessage *from) |
Method relating to the use of BUnarchiver . | |
virtual void | LayoutInvalidated (bool children) |
Hook called from InvalidateLayout(). | |
virtual void | AttachedToLayout () |
Hook called when this object is attached to a BLayout (via BLayout::AddItem()) | |
virtual void | DetachedFromLayout (BLayout *layout) |
Hook called when this object is attached to a BLayout (via BLayout::RemoveItem()) | |
virtual void | AncestorVisibilityChanged (bool shown) |
Hook called when this BLayoutItem's ancestors change visibility, effectively hiding or showing this item. | |
An empty layout item that expands into empty space based on its size configuration.
This class is a specialized layout item, that is used to distribute space within one of the layouts. The layout item can be manually configured, but there are also two default varieties.
The first variety is the glue variety. Glue is an element that expands to the maximum space that is available. Let's say, you have a horizontal BGroupLayout. You want a button on the left, and a button on the right, with empty space in the middle. The middle element can be a glue element. The glue will push the right button all the way to the end of the available space. If the host view gets larger, the glue will expand. You can use the static method BSpaceLayoutItem::CreateGlue() to easily create a glue element.
Another variety is the strut. A is a layout item with no minimum size, and a maximum size. This means that the item might be smaller than the maximum size, but it will never be larger than the maximum size. You can use the static methods BSpaceLayoutItem::CreateVerticalStrut() and BSpaceLayoutItem::CreateHorizontalStrut() to create a strut item.
The default constructor allows you to create a layout item with custom minimum sizes, maximum sizes, preferred sizes and alignments.
BSpaceLayoutItem::BSpaceLayoutItem | ( | BSize | minSize, |
BSize | maxSize, | ||
BSize | preferredSize, | ||
BAlignment | alignment | ||
) |
Create a space layout item with specific properties.
See the CreateGlue(), CreateVerticalStrut() and CreateHorizontalStruct static methods to create common space items.
minSize | The minimum size for this item. |
maxSize | The maximum size for this item. |
preferredSize | The preferred size for this item. |
alignment | The alignment of this item. |
BSpaceLayoutItem::BSpaceLayoutItem | ( | BMessage * | archive | ) |
Constructs a BSpaceLayoutItem from an archive message.
This method is usually not called directly, if you want to build a space layout item from an archived message you should call Instantiate() instead because it can handle errors properly.
archive | The BMessage that contains the space layout item. |
|
virtual |
Destructor.
|
virtual |
Returns the requested alignment for this item.
The value returned from this method is used in BLayoutItem::AlignInFrame(), which BLayouts use to position and resize items. In a vertical BGroupLayout, for example, although each item recieves the same horizontal area, each item can use that area differently, aligning to the left, right or center for example.
Implements BLayoutItem.
Archive the object into a BMessage.
You should call this method from your derived implementation as it adds the data needed to instantiate your object to the message.
into | The message you store your object in. |
deep | If true , all children of this object should be archived as well. |
B_OK | The archive operation was successful. |
B_BAD_VALUE | NULL archive message. |
B_ERROR | The archive operation failed. |
Reimplemented from BLayoutItem.
|
static |
Create a layout item that acts like glue.
This type of space layout item has no minimum size, and expands to the maximum available space in all directions.
Referenced by BLayoutBuilder::Group< ParentBuilder >::AddGlue(), and BLayoutBuilder::Grid< ParentBuilder >::AddGlue().
|
static |
Create a layout item that horizontally expands to a maximum width.
The item has no minimum size, meaning that if the total available width is smaller than the maximum width, the strut will use the available space.
width | The maximum width. |
Referenced by BLayoutBuilder::Group< ParentBuilder >::AddStrut().
|
static |
Create a layout item that vertically expands to a maximum height.
The item has no minimum size, meaning that if the total available height is smaller than the maximum width, the strut will use the available space.
height | The maximum height. |
Referenced by BLayoutBuilder::Group< ParentBuilder >::AddStrut().
|
virtual |
Return the bounding frame of this item.
The returned BRect is in the coordinate system of the target view of the BLayout this item belongs to.
Implements BLayoutItem.
|
static |
Instantiate the item from the message from.
|
virtual |
Return the current local visibility of this item.
The visibility is set explicitly through SetVisible(). By default, the layout item is visible.
Implements BLayoutItem.
|
virtual |
|
virtual |
|
virtual |
|
virtual |
Set this item's explicit alignment, to be used in Alignment().
Implements BLayoutItem.
|
virtual |
|
virtual |
Set this item's explicit min size, to be used in MinSize().
This forces the minimal size for the item and overrides any constraints that would normally be used to compute it. Most importantly, the minimal size of children is ignored, so setting this can lead to the children not fitting the view.
Implements BLayoutItem.
|
virtual |
Set this item's explicit preferred size, to be used in PreferredSize().
Implements BLayoutItem.
|
virtual |
Set the bounding frame of this item.
frame is in the coordinate system of the target view of the BLayout that this item belongs to.
Implements BLayoutItem.
|
virtual |
Set the visibility of this space layout item.
visible | The desired visibility of the layout item. |
Implements BLayoutItem.