Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
BAbstractLayout Class Reference

BLayout subclass providing convenience methods for derived implementations. More...

Inherits BLayout.

Inherited by BCardLayout, and BTwoDimensionalLayout.

Public Member Functions

virtual BAlignment Alignment ()
 
virtual status_t Archive (BMessage *into, bool deep=true) const
 Archives this layout into archive. If deep is true, also archives the items in this layout, calling ItemArchived() for each one.
 
virtual BRect Frame ()
 Return the bounding frame of this item.
 
virtual bool IsVisible ()
 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 BSize MaxSize ()
 
virtual BSize MinSize ()
 
virtual status_t Perform (perform_code d, void *arg)
 Perform some action (Internal method defined for binary compatibility purposes).
 
virtual BSize PreferredSize ()
 
virtual void SetExplicitAlignment (BAlignment alignment)
 Set this item's explicit alignment, to be used in Alignment().
 
virtual void SetExplicitMaxSize (BSize size)
 Set this item's explicit max size, to be used in MaxSize().
 
virtual void SetExplicitMinSize (BSize size)
 Set this item's explicit min size, to be used in MinSize().
 
virtual void SetExplicitPreferredSize (BSize size)
 Set this item's explicit preferred size, to be used in PreferredSize().
 
virtual void SetFrame (BRect frame)
 Set the bounding frame of this item.
 
virtual void SetVisible (bool visible)
 Set the local visibility of this item.
 
Constructors
 BAbstractLayout ()
 Construct a BAbstractLayout.
 
 BAbstractLayout (BMessage *from)
 Archive constructor.
 
Hook Methods
virtual BSize BaseMinSize ()
 Method to be implemented in derived classes return the minimum size constraint for this BAbstractLayout.
 
virtual BSize BaseMaxSize ()
 Method to be implemented in derived classes return the maximum size constraint for this BAbstractLayout.
 
virtual BSize BasePreferredSize ()
 Method to be implemented in derived classes return the preferred size constraint for this BAbstractLayout.
 
virtual BAlignment BaseAlignment ()
 Method to be implemented in derived classes return the preferred alignment for this BAbstractLayout.
 
- Public Member Functions inherited from BLayout
 BLayout ()
 Default constructor.
 
 BLayout (BMessage *archive)
 Archive constructor.
 
virtual ~BLayout ()
 Destructor, deletes all BLayoutItem's that this layout manages, and detaches from this BLayout's owner view if there is one.
 
virtual status_t Perform (perform_code d, void *arg)
 Perform some action (Internal method defined for binary compatibility purposes).
 
BViewOwner () const
 Returns the Owner of this layout, i.e. the view this layout manages.
 
BViewTargetView () const
 Returns the target view of this layout.
 
virtual BViewView ()
 Returns the same BView* as BLayout::Owner(), this method is inherited from BLayoutItem.
 
virtual BLayoutItemAddView (BView *child)
 Creates a BLayoutItem to represent a BView, and adds that item to this layout.
 
virtual BLayoutItemAddView (int32 index, BView *child)
 Creates a BLayoutItem to represent child, and adds that item at index to this layout. child is added to this BLayout's target view.
 
virtual bool AddItem (BLayoutItem *item)
 Adds a BLayoutItem to this layout, and adds the BView it represents to this BLayout's target view.
 
virtual bool AddItem (int32 index, BLayoutItem *item)
 Adds item to this layout, and adds the BView item represents to this BLayout's target view.
 
virtual bool RemoveView (BView *child)
 Removes and deletes all BLayoutItem representing a BView from this layout.
 
virtual bool RemoveItem (BLayoutItem *item)
 Removes a BLayoutItem from this layout, and also removes the view it represents from this BLayout's target view.
 
virtual BLayoutItemRemoveItem (int32 index)
 Remove the BLayoutItem at index.
 
BLayoutItemItemAt (int32 index) const
 Get the BLayoutItem at index. Returns NULL if index is out of bounds.
 
int32 CountItems () const
 Get the number of BLayoutItem s in this layout.
 
int32 IndexOfItem (const BLayoutItem *item) const
 Get the index of a BLayoutItem in this layout.
 
int32 IndexOfView (BView *child) const
 Get the index of child in this layout.
 
virtual void Relayout (bool immediate=false)
 Request this BLayout to reposition and resize its items as required.
 
void LayoutItems (bool force=false)
 If there is no layout currently ongoing, and force is false, creates a new BLayoutContext and calls the DoLayout() method of this BLayout and any BLayout's nested in this BLayout.
 
BLayoutContext * LayoutContext () const
 Returns the BLayoutContext this BLayout is currently operating in, or NULL.
 
bool AncestorsVisible () const
 Get the visibility of the ancestors of this layout.
 
BRect LayoutArea ()
 Returns the on-screen area this layout has received to lay out its items in.
 
virtual void InvalidateLayout (bool children=false)
 Invalidate this layout and any cached data this layout has relating to positioning and sizing of its items.
 
void RequireLayout ()
 Flag this layout as stale, i.e. any cached data may still be valid, but the items need to be repositioned or resized.
 
bool IsValid ()
 Returns whether this layout has been invalidated (via BLayout::InvalidateLayout()) and has not yet been validated (by doing a layout, or by its ResetLayoutInvalidation() method.
 
void EnableLayoutInvalidation ()
 Re-enable layout invalidation after a call to DisableLayoutInvalidation().
 
void DisableLayoutInvalidation ()
 Disable layout invalidation notifications, i.e. calls to this object's InvalidateLayout() method.
 
- 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.
 
BLayoutLayout () 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 BViewView ()
 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.
 
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 *archive) const
 Method relating to the use of BArchiver.
 
virtual status_t AllUnarchived (const BMessage *from)
 Unarchives the BLayoutItem's for this layout, calling ItemUnarchived() for each one.
 
virtual void AncestorVisibilityChanged (bool shown)
 Hook method inherited from BLayoutItem, classes derived from BLayout must include the BLayout version of this method in their implementation.
 
virtual void AttachedToLayout ()
 Hook method inherited from BLayoutItem, classes derived from BLayout must include the BLayout version of this method in their implementation.
 
virtual void DetachedFromLayout (BLayout *layout)
 Hook method inherited from BLayoutItem, classes derived from BLayout must include the BLayout version of this method in their implementation.
 
virtual bool ItemAdded (BLayoutItem *item, int32 atIndex)
 Hook method called when item is added to this layout.
 
virtual status_t ItemArchived (BMessage *into, BLayoutItem *item, int32 index) const
 Hook for derived classes to add data specific to item to the into BMessage. item resides at index.
 
virtual void ItemRemoved (BLayoutItem *item, int32 fromIndex)
 Hook method called when item is removed from this layout.
 
virtual status_t ItemUnarchived (const BMessage *from, BLayoutItem *item, int32 index)
 Hook for derived classes to retrieve data specific to item from the from BMessage. item resides at index.
 
virtual void LayoutInvalidated (bool children)
 
virtual void OwnerChanged (BView *was)
 Hook method called when this layout is attached to a BView.
 
- Protected Member Functions inherited from BLayout
virtual status_t AllArchived (BMessage *archive) const
 Method relating to the use of BArchiver.
 
virtual void DoLayout ()=0
 Implemented by derived classes to position and resize the items in this layout.
 
void VisibilityChanged (bool show)
 Method to be called by derived classes in their SetVisible() implementation. Calls AncestorVisibilityChanged() on the items in this BLayout.
 
void ResetLayoutInvalidation ()
 Reset layout invalidation, causing InvalidateLayout calls to proceed again. This method should be called once any cached data has been validated, or updated to valid values.
 
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

Additional Inherited Members

- Static Public Member Functions inherited from BArchivable
static BArchivableInstantiate (BMessage *archive)
 Static member to restore objects from messages.
 

Detailed Description

BLayout subclass providing convenience methods for derived implementations.

Since
Haiku R1

This class is designed to reduce the amount of boilerplate code required to write a BLayout subclass. In most cases, you classes should derive from BAbstractLayout rather than BLayout.

When a BAbstractLayout is attached to a BView, many of the methods provided by the BAbstractLayout class are forwarded to the BAbstractLayout's owner BView. When a BAbstractLayout is viewless, these methods are handled locally.

Warning
This class is not yet finalized, if you use it in your software assume that it will break some time in the future.

Constructor & Destructor Documentation

◆ BAbstractLayout() [1/2]

BAbstractLayout::BAbstractLayout ( )

Construct a BAbstractLayout.

Since
Haiku R1

◆ BAbstractLayout() [2/2]

BAbstractLayout::BAbstractLayout ( BMessage from)

Archive constructor.

Since
Haiku R1

Member Function Documentation

◆ Alignment()

BAlignment BAbstractLayout::Alignment ( )
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.

Since
Haiku R1

The return value for this method is composed (using BLayoutUtils::ComposeAlignment()) from the values returned by BaseAlignment() and ExplicitAlignment()

Since
Haiku R1

Implements BLayoutItem.

◆ AllArchived()

virtual status_t BAbstractLayout::AllArchived ( BMessage into) const
protectedvirtual

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.

Warning
To guarantee that your AllArchived() method will be called during archival, you must create a BArchiver object in your Archive() implementation.
You should archive any objects you own in your Archive() method implementation, and NOT your AllArchived() method.
See also
BArchiver BArchiver::Finish()
Since
Haiku R1

Reimplemented from BLayout.

Reimplemented in BCardLayout, BGridLayout, BGroupLayout, and BTwoDimensionalLayout.

◆ AllUnarchived()

virtual status_t BAbstractLayout::AllUnarchived ( const BMessage from)
protectedvirtual

Unarchives the BLayoutItem's for this layout, calling ItemUnarchived() for each one.

Since
Haiku R1

Reimplemented from BLayout.

Reimplemented in BCardLayout, BGridLayout, BGroupLayout, and BTwoDimensionalLayout.

◆ AncestorVisibilityChanged()

virtual void BAbstractLayout::AncestorVisibilityChanged ( bool  shown)
protectedvirtual

Hook method inherited from BLayoutItem, classes derived from BLayout must include the BLayout version of this method in their implementation.

Since
Haiku R1

Reimplemented from BLayout.

◆ Archive()

virtual status_t BAbstractLayout::Archive ( BMessage archive,
bool  deep = true 
) const
virtual

Archives this layout into archive. If deep is true, also archives the items in this layout, calling ItemArchived() for each one.

Since
Haiku R1

Reimplemented from BLayout.

Reimplemented in BCardLayout, BGridLayout, BGroupLayout, and BTwoDimensionalLayout.

◆ AttachedToLayout()

virtual void BAbstractLayout::AttachedToLayout ( )
protectedvirtual

Hook method inherited from BLayoutItem, classes derived from BLayout must include the BLayout version of this method in their implementation.

Since
Haiku R1

Reimplemented from BLayout.

◆ BaseMaxSize()

BSize BAbstractLayout::BaseMaxSize ( )
virtual

Method to be implemented in derived classes return the maximum size constraint for this BAbstractLayout.

Since
Haiku R1

Reimplemented in BCardLayout, and BTwoDimensionalLayout.

◆ BaseMinSize()

BSize BAbstractLayout::BaseMinSize ( )
virtual

Method to be implemented in derived classes return the minimum size constraint for this BAbstractLayout.

Since
Haiku R1

Reimplemented in BCardLayout, and BTwoDimensionalLayout.

◆ BasePreferredSize()

BSize BAbstractLayout::BasePreferredSize ( )
virtual

Method to be implemented in derived classes return the preferred size constraint for this BAbstractLayout.

Since
Haiku R1

Reimplemented in BCardLayout, and BTwoDimensionalLayout.

◆ DetachedFromLayout()

virtual void BAbstractLayout::DetachedFromLayout ( BLayout layout)
protectedvirtual

Hook method inherited from BLayoutItem, classes derived from BLayout must include the BLayout version of this method in their implementation.

Parameters
layoutThe BLayout that this BLayout was detached from.
Since
Haiku R1

Reimplemented from BLayout.

◆ Frame()

virtual BRect BAbstractLayout::Frame ( )
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.

Since
Haiku R1

Implements BLayoutItem.

◆ IsVisible()

virtual bool BAbstractLayout::IsVisible ( )
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.

Since
Haiku R1

Implements BLayoutItem.

◆ ItemAdded()

virtual bool BAbstractLayout::ItemAdded ( BLayoutItem item,
int32  atIndex 
)
protectedvirtual

Hook method called when item is added to this layout.

Parameters
itemThe BLayoutItem that is being added.
atIndexThe index of the BLayoutItem.
Returns
true on succcess, false if item will not be added.
Note
This is a good time to allocate data for a BLayoutItem and attach it to item via BLayoutItem::SetLayoutData().
Since
Haiku R1

Reimplemented from BLayout.

Reimplemented in BCardLayout, BGridLayout, and BGroupLayout.

◆ ItemArchived()

virtual status_t BAbstractLayout::ItemArchived ( BMessage into,
BLayoutItem item,
int32  index 
) const
protectedvirtual

Hook for derived classes to add data specific to item to the into BMessage. item resides at index.

Note
The same archive is passed to BLayout::ItemArchived() for all items, so any data added for each item will be stored in an array.
Since
Haiku R1

Reimplemented from BLayout.

Reimplemented in BCardLayout, BGridLayout, BGroupLayout, and BTwoDimensionalLayout.

◆ ItemRemoved()

virtual void BAbstractLayout::ItemRemoved ( BLayoutItem item,
int32  fromIndex 
)
protectedvirtual

Hook method called when item is removed from this layout.

Parameters
itemThe BLayoutItem being removed.
fromIndexThe index where item used to reside.

When this hook is called, item is not yet completely removed. It can no longer be accessed with LayoutItemAt(), nor does it contribute to the value of CountItems(), but the item has not yet had its ItemDetached() hook called.

Note
This is a good time to delete the data you've attached to item via BLayoutItem::SetLayoutData().
Since
Haiku R1

Reimplemented from BLayout.

Reimplemented in BCardLayout, BGridLayout, and BGroupLayout.

◆ ItemUnarchived()

virtual status_t BAbstractLayout::ItemUnarchived ( const BMessage from,
BLayoutItem item,
int32  index 
)
protectedvirtual

Hook for derived classes to retrieve data specific to item from the from BMessage. item resides at index.

Note
The same archive is passed to BLayout::ItemArchived() for all items, so any data added for each item will be stored in an array. You should pass index to the BMessage methods you will be using in this method.
Since
Haiku R1

Reimplemented from BLayout.

Reimplemented in BCardLayout, BGridLayout, BGroupLayout, and BTwoDimensionalLayout.

◆ LayoutInvalidated()

virtual void BAbstractLayout::LayoutInvalidated ( bool  children)
protectedvirtual

Hook method called when this layout becomes invalid. This is a good place to clear any caches your object might hold.

Parameters
childrenWhether or not child layouts have also been invalidated.
Since
Haiku R1

Reimplemented from BLayout.

Reimplemented in BCardLayout, and BTwoDimensionalLayout.

◆ MaxSize()

BSize BAbstractLayout::MaxSize ( )
virtual

Returns the maximum desirable size for this item.

Since
Haiku R1

The return value for this method is composed (using BLayoutUtils::ComposeSize()) from the values returned by BaseMaxSize() and ExplicitMaxSize().

Since
Haiku R1

Implements BLayoutItem.

◆ MinSize()

BSize BAbstractLayout::MinSize ( )
virtual

Returns the minimum desirable size for this item.

Since
Haiku R1
Haiku R1

The return value for this method is composed (using BLayoutUtils::ComposeSize()) from the values returned by BaseMinSize() and ExplicitMinSize().

Implements BLayoutItem.

◆ OwnerChanged()

virtual void BAbstractLayout::OwnerChanged ( BView was)
protectedvirtual

Hook method called when this layout is attached to a BView.

Parameters
wasThe previous owner of this BLayout, for new BLayout s, this will be NULL.
Since
Haiku R1

Reimplemented from BLayout.

◆ Perform()

virtual status_t BAbstractLayout::Perform ( perform_code  d,
void *  arg 
)
virtual

Perform some action (Internal method defined for binary compatibility purposes).

Reimplemented from BLayout.

Reimplemented in BCardLayout, BGridLayout, BGroupLayout, and BTwoDimensionalLayout.

◆ PreferredSize()

BSize BAbstractLayout::PreferredSize ( )
virtual

Returns the preferred size for this item.

Since
Haiku R1

The return value for this method is composed (using BLayoutUtils::ComposeSize()) from the values returned by BasePreferredSize() and ExplicitPreferredSize().

Since
Haiku R1

Implements BLayoutItem.

◆ SetExplicitAlignment()

virtual void BAbstractLayout::SetExplicitAlignment ( BAlignment  alignment)
virtual

Set this item's explicit alignment, to be used in Alignment().

Since
Haiku R1

Implements BLayoutItem.

◆ SetExplicitMaxSize()

virtual void BAbstractLayout::SetExplicitMaxSize ( BSize  size)
virtual

Set this item's explicit max size, to be used in MaxSize().

Since
Haiku R1

Implements BLayoutItem.

◆ SetExplicitMinSize()

virtual void BAbstractLayout::SetExplicitMinSize ( BSize  size)
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.

Since
Haiku R1

Implements BLayoutItem.

◆ SetExplicitPreferredSize()

virtual void BAbstractLayout::SetExplicitPreferredSize ( BSize  size)
virtual

Set this item's explicit preferred size, to be used in PreferredSize().

Since
Haiku R1

Implements BLayoutItem.

◆ SetFrame()

virtual void BAbstractLayout::SetFrame ( BRect  frame)
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.

Since
Haiku R1

Implements BLayoutItem.

Reimplemented in BTwoDimensionalLayout.

◆ SetVisible()

virtual void BAbstractLayout::SetVisible ( bool  visible)
virtual

Set the local visibility of this item.

Since
Haiku R1

Implements BLayoutItem.