Abstract class representing things that are positionable and resizable by objects of the BLayout class. More...
Inherits BArchivable.
Inherited by BAbstractLayoutItem, BLayout, and BSpaceLayoutItem.
Public Member Functions | |
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. | |
Reporting Size and Alignment Constraints to a BLayout | |
virtual BSize | MinSize ()=0 |
Returns the minimum desirable size for this item. | |
virtual BSize | MaxSize ()=0 |
Returns the maximum desirable size for this item. | |
virtual BSize | PreferredSize ()=0 |
Returns the preferred size for this item. | |
virtual BAlignment | Alignment ()=0 |
Returns the requested alignment for this item. | |
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. | |
Overriding Size and Alignment Constraints | |
Although the explicit constraints placed on an item are not enforced by the BLayoutItem class, all Haiku BLayoutItem subclasses will use the BLayoutUtils::ComposeSize() or BLayoutUtils::ComposeAlignment() functions in when reporting these constraints. It is recommended that all subclasses do this as well, the BAbstractLayoutItem class provides any easy way to include this behaviour in your class.
| |
virtual void | SetExplicitMinSize (BSize size)=0 |
Set this item's explicit min size, to be used in MinSize(). | |
virtual void | SetExplicitMaxSize (BSize size)=0 |
Set this item's explicit max size, to be used in MaxSize(). | |
virtual void | SetExplicitPreferredSize (BSize size)=0 |
Set this item's explicit preferred size, to be used in PreferredSize(). | |
void | SetExplicitSize (BSize size) |
Set the explicity size to size. | |
virtual void | SetExplicitAlignment (BAlignment alignment)=0 |
Set this item's explicit alignment, to be used in Alignment(). | |
Getting/Setting the Visibility of a BLayoutItem | |
These methods take into account only the local visibility of this item, not the visibility of its ancestors. | |
virtual bool | IsVisible ()=0 |
Return the current local visibility of this item. If an item is not visible, it will not be given space by the BLayout it resides in. | |
virtual void | SetVisible (bool visible)=0 |
Set the local visibility of this item. | |
Getting/Setting Current On-Screen Positioning of a BLayoutItem | |
virtual BRect | Frame ()=0 |
Return the bounding frame of this item. | |
virtual void | SetFrame (BRect frame)=0 |
Set the bounding frame of this item. | |
void | AlignInFrame (BRect frame) |
Position this BLayoutItem within frame, given the value returned by Alignment(), and the size constraints for this item. | |
Layout Events and Requests | |
These methods represent events or requests originating from a BLayout. In some implementations they may be handled directly by this BLayoutItem, but many implementations will forward these events to another object. | |
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. | |
Utility Methods for BLayout Subclasses | |
Utility methods for the BLayout class to attach and retrieve arbitrary data for a BLayoutItem. | |
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). | |
Protected Member Functions | |
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 . | |
Hook methods | |
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. | |
Additional Inherited Members | |
Static Public Member Functions inherited from BArchivable | |
static BArchivable * | Instantiate (BMessage *archive) |
Static member to restore objects from messages. | |
Abstract class representing things that are positionable and resizable by objects of the BLayout class.
The BLayoutItem class provides an interface that is meant to be used almost exclusively by objects of the BLayout class. Despite this, there are some methods that are provided for other users of the class.
BLayoutItem::BLayoutItem | ( | BMessage * | archive | ) |
void BLayoutItem::AlignInFrame | ( | BRect | frame | ) |
Position this BLayoutItem within frame, given the value returned by Alignment(), and the size constraints for this item.
|
pure 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.
Implemented in BAbstractLayout, and BSpaceLayoutItem.
Method relating to the use of BArchiver
.
This hook function is called once the first BArchiver that was created in an archiving session is either destroyed, or has its Finish() method called. Implementations of this method can be used, in conjunction with BArchiver::IsArchived(), to reference objects in your archive that you do not own, depending on whether or not those objects were archived by their owners. Implementations of this method should call the implementation of their parent class, the same as for the Archive() method.
Reimplemented from BArchivable.
Reimplemented in BAbstractLayout, BCardLayout, BLayout, BGridLayout, BGroupLayout, and BTwoDimensionalLayout.
Method relating to the use of BUnarchiver
.
This hook function is called triggered in the BUnarchiver::Finish() method. In this method, you can rebuild references to objects that may be direct children of your object, or may be children of other objects. Implementations of this method should call the implementation of their parent class, the same as for the Archive() method.
Reimplemented from BArchivable.
Reimplemented in BAbstractLayout, BCardLayout, BGridLayout, BGroupLayout, BLayout, and BTwoDimensionalLayout.
|
protectedvirtual |
Hook called when this BLayoutItem's ancestors change visibility, effectively hiding or showing this item.
Implementations of this method should alter the onscreen visibility of this item. I.E. if shown is false
, nothing should be drawn to represent this item.
shown | true to show, false to hide. |
Reimplemented in BAbstractLayout, and BLayout.
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 BArchivable.
Reimplemented in BAbstractLayout, BCardLayout, BGridLayout, BGroupLayout, BLayout, BSpaceLayoutItem, and BTwoDimensionalLayout.
|
protectedvirtual |
Hook called when this object is attached to a BLayout (via BLayout::AddItem())
Reimplemented in BAbstractLayout, and BLayout.
|
protectedvirtual |
Hook called when this object is attached to a BLayout (via BLayout::RemoveItem())
this
to BLayout, doing so will cause undefined behaviour (probably a crash).layout | The BLayout you were previously attached to. |
Reimplemented in BAbstractLayout, and BLayout.
|
pure 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.
Implemented in BAbstractLayout, and BSpaceLayoutItem.
|
virtual |
Get this BLayoutItem's height constraints for a given width.
If a BLayoutItem does not have height for width constraints (HasHeightForWidth() returns false
) it does not need to implement this method.
NULL
before dereferencing them.Reimplemented in BCardLayout, and BTwoDimensionalLayout.
|
virtual |
Returns whether or not this BLayoutItem's height constraints are dependent on its width.
false
.Reimplemented in BCardLayout, and BTwoDimensionalLayout.
|
virtual |
Invalidate the layout of this item, or the object it represents.
Although this method is virtual, you should not override it in your classes, override LayoutInvalidated() instead. This method will take care of calling the InvalidateLayout() methods of affected views/layouts/items. However, if there is an object that is somehow connected to this one by means other than the standard mechanisms provided by the Haiku API, you should use the LayoutInvalidated() hook to do this.
children | Whether or not to invalidate children of this object. |
Reimplemented in BLayout.
|
pure virtual |
Return the current local visibility of this item. If an item is not visible, it will not be given space by the BLayout it resides in.
A simple implementation would return the last thing passed to SetVisible(). A more complex implementation may deal with a BView that could be hidden in any number of ways.
Implemented in BAbstractLayout, and BSpaceLayoutItem.
BLayout * BLayoutItem::Layout | ( | ) | const |
Returns the BLayout this BLayoutItem resides in.
void * BLayoutItem::LayoutData | ( | ) | const |
Retrieve arbitrary data attached to this BLayoutItem.
|
protectedvirtual |
Hook called from InvalidateLayout().
Override this method to clean out an cached layout info. It is good practice to recreate such info only on demand, eg when MinSize() or friends are called.
If children is true
, then you should invalidate any information on child objects as well, and propagate the invalidation to them.
Reimplemented in BAbstractLayout, BLayout, BCardLayout, and BTwoDimensionalLayout.
|
pure virtual |
Returns the maximum desirable size for this item.
Implemented in BAbstractLayout, and BSpaceLayoutItem.
|
pure virtual |
Returns the minimum desirable size for this item.
Implemented in BAbstractLayout, and BSpaceLayoutItem.
|
virtual |
Perform some action (Internal method defined for binary compatibility purposes).
Reimplemented from BArchivable.
Reimplemented in BAbstractLayout, BCardLayout, BGridLayout, BGroupLayout, BLayout, and BTwoDimensionalLayout.
|
pure virtual |
Returns the preferred size for this item.
Implemented in BAbstractLayout, and BSpaceLayoutItem.
|
virtual |
Relayout any children or onscreen data this item contains. Often this request is forwarded to another object.
The default implementation of this method will likely be sufficient in most cases. Assuming this->View()
doesn't return NULL
, the default implementation calls Relayout() or Layout() on the value returned by View().
Reimplemented in BLayout.
bool BLayoutItem::RemoveSelf | ( | ) |
Remove this layout item from the BLayout it is a part of.
This method works analoguous to BView::RemoveSelf(), that is it removes itself from the parent layout and returns whether or not this was succesful.
true
if the item was removed from the layout, or false
if item was not part of a layout, or removal was succesful.
|
pure virtual |
Set this item's explicit alignment, to be used in Alignment().
Implemented in BAbstractLayout, and BSpaceLayoutItem.
Referenced by BLayoutBuilder::Grid< ParentBuilder >::AddMenuField(), and BLayoutBuilder::Grid< ParentBuilder >::AddTextControl().
|
pure virtual |
Set this item's explicit max size, to be used in MaxSize().
Implemented in BAbstractLayout, and BSpaceLayoutItem.
|
pure 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.
Implemented in BAbstractLayout, and BSpaceLayoutItem.
|
pure virtual |
Set this item's explicit preferred size, to be used in PreferredSize().
Implemented in BAbstractLayout, and BSpaceLayoutItem.
void BLayoutItem::SetExplicitSize | ( | BSize | size | ) |
Set the explicity size to size.
This method is a convenience method that sets the minimum size, maximum size and preferred size to size, as to force this layout item to have a specific size.
size | The specific (non-zero) size for this layout item. |
|
pure 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.
Implemented in BAbstractLayout, BSpaceLayoutItem, and BTwoDimensionalLayout.
void BLayoutItem::SetLayoutData | ( | void * | data | ) |
Attach arbitrary data to this BLayoutItem.
|
pure virtual |
Set the local visibility of this item.
Implemented in BAbstractLayout, and BSpaceLayoutItem.