Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
BCardLayout Class Reference

The BCardLayout class is a simple BLayout subclass that arranges the items as a stack of cards with only one card being on top and visible to the user. More...

Inherits BAbstractLayout.

Public Member Functions

 BCardLayout ()
 Create a new card layout. More...
 
 BCardLayout (BMessage *from)
 Constructs a BCardLayout from an archive message. More...
 
virtual ~BCardLayout ()
 Destructor. More...
 
virtual status_t Archive (BMessage *into, bool deep=true) const
 Archive this layout into a BMessage. More...
 
virtual BAlignment BaseAlignment ()
 Overridden hook method from BAbstractLayout. More...
 
virtual BSize BaseMaxSize ()
 Overridden hook method from BAbstractLayout. More...
 
virtual BSize BaseMinSize ()
 Overridden hook method from BAbstractLayout. More...
 
virtual BSize BasePreferredSize ()
 Overridden hook method from BAbstractLayout. More...
 
virtual void GetHeightForWidth (float width, float *min, float *max, float *preferred)
 Overridden hook method from BAbstractLayout. More...
 
virtual bool HasHeightForWidth ()
 Overridden hook method from BAbstractLayout. More...
 
virtual status_t Perform (perform_code d, void *arg)
 Overridden hook method from BAbstractLayout. More...
 
void SetVisibleItem (BLayoutItem *item)
 Set the current visible item to item. More...
 
void SetVisibleItem (int32 index)
 Set the current visible item to the item at index. More...
 
int32 VisibleIndex () const
 Get the index of the currently visible item. More...
 
BLayoutItemVisibleItem () const
 Get a pointer to the currently visible item. More...
 
- Public Member Functions inherited from BAbstractLayout
virtual BAlignment Alignment ()
 Returns the requested alignment for this item. More...
 
virtual BRect Frame ()
 Return the bounding frame of this item. More...
 
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. More...
 
virtual BSize MaxSize ()
 Returns the maximum desirable size for this item. More...
 
virtual BSize MinSize ()
 Returns the minimum desirable size for this item. More...
 
virtual BSize PreferredSize ()
 Returns the preferred size for this item. More...
 
virtual void SetExplicitAlignment (BAlignment alignment)
 Set this item's explicit alignment, to be used in Alignment(). More...
 
virtual void SetExplicitMaxSize (BSize size)
 Set this item's explicit max size, to be used in MaxSize(). More...
 
virtual void SetExplicitMinSize (BSize size)
 Set this item's explicit min size, to be used in MinSize(). More...
 
virtual void SetExplicitPreferredSize (BSize size)
 Set this item's explicit preferred size, to be used in PreferredSize(). More...
 
virtual void SetFrame (BRect frame)
 Set the bounding frame of this item. More...
 
virtual void SetVisible (bool visible)
 Set the local visibility of this item. More...
 
 BAbstractLayout ()
 Construct a BAbstractLayout. More...
 
 BAbstractLayout (BMessage *from)
 Archive constructor. More...
 
- Public Member Functions inherited from BLayout
 BLayout ()
 Default constructor. More...
 
 BLayout (BMessage *archive)
 Archive constructor. More...
 
virtual ~BLayout ()
 Destructor, deletes all BLayoutItem's that this layout manages, and detaches from this BLayout's owner view if there is one. More...
 
BViewOwner () const
 Returns the Owner of this layout, i.e. the view this layout manages. More...
 
BViewTargetView () const
 Returns the target view of this layout. More...
 
virtual BViewView ()
 Returns the same BView* as BLayout::Owner(), this method is inherited from BLayoutItem. More...
 
virtual BLayoutItemAddView (BView *child)
 Creates a BLayoutItem to represent a BView, and adds that item to this layout. More...
 
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. More...
 
virtual bool AddItem (BLayoutItem *item)
 Adds a BLayoutItem to this layout, and adds the BView it represents to this BLayout's target view. More...
 
virtual bool AddItem (int32 index, BLayoutItem *item)
 Adds item to this layout, and adds the BView item represents to this BLayout's target view. More...
 
virtual bool RemoveView (BView *child)
 Removes and deletes all BLayoutItem representing a BView from this layout. More...
 
virtual bool RemoveItem (BLayoutItem *item)
 Removes a BLayoutItem from this layout, and also removes the view it represents from this BLayout's target view. More...
 
virtual BLayoutItemRemoveItem (int32 index)
 Remove the BLayoutItem at index. More...
 
BLayoutItemItemAt (int32 index) const
 Get the BLayoutItem at index. Returns NULL if index is out of bounds. More...
 
int32 CountItems () const
 Get the number of BLayoutItem s in this layout. More...
 
int32 IndexOfItem (const BLayoutItem *item) const
 Get the index of a BLayoutItem in this layout. More...
 
int32 IndexOfView (BView *child) const
 Get the index of child in this layout. More...
 
virtual void Relayout (bool immediate=false)
 Request this BLayout to reposition and resize its items as required. More...
 
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. More...
 
BLayoutContext * LayoutContext () const
 Returns the BLayoutContext this BLayout is currently operating in, or NULL. More...
 
bool AncestorsVisible () const
 Get the visibility of the ancestors of this layout. More...
 
BRect LayoutArea ()
 Returns the on-screen area this layout has received to lay out its items in. More...
 
virtual void InvalidateLayout (bool children=false)
 Invalidate this layout and any cached data this layout has relating to positioning and sizing of its items. More...
 
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. More...
 
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. More...
 
void EnableLayoutInvalidation ()
 Re-enable layout invalidation after a call to DisableLayoutInvalidation(). More...
 
void DisableLayoutInvalidation ()
 Disable layout invalidation notifications, i.e. calls to this object's InvalidateLayout() method. More...
 
- Public Member Functions inherited from BLayoutItem
 BLayoutItem (BMessage *from)
 Archive constructor. More...
 
BLayoutLayout () const
 Returns the BLayout this BLayoutItem resides in. More...
 
bool RemoveSelf ()
 Remove this layout item from the BLayout it is a part of. More...
 
void SetExplicitSize (BSize size)
 Set the explicity size to size. More...
 
void AlignInFrame (BRect frame)
 Position this BLayoutItem within frame, given the value returned by Alignment(), and the size constraints for this item. More...
 
void * LayoutData () const
 Retrieve arbitrary data attached to this BLayoutItem. More...
 
void SetLayoutData (void *data)
 Attach arbitrary data to this BLayoutItem. More...
 
- Public Member Functions inherited from BArchivable
 BArchivable ()
 Constructor. Does nothing. More...
 
 BArchivable (BMessage *from)
 Constructor. Does important behind-the-scenes work in the unarchiving process. More...
 
virtual ~BArchivable ()
 Destructor. Does nothing. More...
 

Static Public Member Functions

static BArchivableInstantiate (BMessage *from)
 Instantiate a BCardLayout object from message from. More...
 
- Static Public Member Functions inherited from BArchivable
static BArchivableInstantiate (BMessage *archive)
 Static member to restore objects from messages. More...
 

Protected Member Functions

virtual status_t AllArchived (BMessage *archive) const
 Hook method overridden from BArchivable. More...
 
virtual status_t AllUnarchived (const BMessage *from)
 Hook method overridden from BArchivable. More...
 
virtual void DoLayout ()
 Hook method overridden from BAbstractLayout. More...
 
virtual bool ItemAdded (BLayoutItem *item, int32 atIndex)
 Hook method overridden from BAbstractLayout. More...
 
virtual status_t ItemArchived (BMessage *into, BLayoutItem *item, int32 index) const
 Hook method overridden from BArchivable. More...
 
virtual void ItemRemoved (BLayoutItem *item, int32 fromIndex)
 Hook method overridden from BAbstractLayout. More...
 
virtual status_t ItemUnarchived (const BMessage *from, BLayoutItem *item, int32 index)
 Hook method overridden from BArchivable. More...
 
virtual void LayoutInvalidated (bool children=false)
 Hook method overridden from BAbstractLayout. More...
 
- Protected Member Functions inherited from BAbstractLayout
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. More...
 
virtual void AttachedToLayout ()
 Hook method inherited from BLayoutItem, classes derived from BLayout must include the BLayout version of this method in their implementation. More...
 
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. More...
 
virtual void OwnerChanged (BView *was)
 Hook method called when this layout is attached to a BView. More...
 
- Protected Member Functions inherited from BLayout
void VisibilityChanged (bool show)
 Method to be called by derived classes in their SetVisible() implementation. Calls AncestorVisibilityChanged() on the items in this BLayout. More...
 
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. More...
 
Hook methods

Detailed Description

The BCardLayout class is a simple BLayout subclass that arranges the items as a stack of cards with only one card being on top and visible to the user.

Once you have set up the items in the container, you can select which one is visible using the SetVisibleItem() methods on this class. When there is no item on top, the system's default grey background is shown.

This view is useful when you have a number of pre-loaded UI elements, and you want to be able to swap between them quickly, while retaining the underlying state. The container itself will retain a fixed size, so from a visual perspective, it is imperative that the items in the stack have comparable dimensions.

An example usage is for a configuration wizard, where the user will need to complete a number of steps to perform an action. Because you want to the user to experience all these steps as a smooth flow within one window, you can set up the individual pages as views, and add these as cards to the card layout. Then you tie the Next and Previous buttons to switch between the visible cards using the BCardLayout::SetVisible() methods.

Since
Haiku R1

Constructor & Destructor Documentation

◆ BCardLayout() [1/2]

BCardLayout::BCardLayout ( )

Create a new card layout.

Since
Haiku R1

◆ BCardLayout() [2/2]

BCardLayout::BCardLayout ( BMessage from)

Constructs a BCardLayout from an archive message.

This method is usually not called directly, if you want to build a card layout from an archived message you should call Instantiate() instead because it can handle errors properly.

Parameters
fromThe BMessage that contains the card layout.
Since
Haiku R1

◆ ~BCardLayout()

BCardLayout::~BCardLayout ( )
virtual

Destructor.

Since
Haiku R1

Member Function Documentation

◆ AllArchived()

status_t BCardLayout::AllArchived ( BMessage archive) const
protectedvirtual

Hook method overridden from BArchivable.

Since
Haiku R1

Reimplemented from BAbstractLayout.

◆ AllUnarchived()

status_t BCardLayout::AllUnarchived ( const BMessage from)
protectedvirtual

Hook method overridden from BArchivable.

Since
Haiku R1

Reimplemented from BAbstractLayout.

◆ Archive()

status_t BCardLayout::Archive ( BMessage into,
bool  deep = true 
) const
virtual

Archive this layout into a BMessage.

Parameters
intoThe message to which to archive into.
deepWhen true, the children of this layout will also be added.
Since
Haiku R1

Reimplemented from BAbstractLayout.

◆ BaseAlignment()

BAlignment BCardLayout::BaseAlignment ( )
virtual

Overridden hook method from BAbstractLayout.

Since
Haiku R1

Reimplemented from BAbstractLayout.

◆ BaseMaxSize()

BSize BCardLayout::BaseMaxSize ( )
virtual

Overridden hook method from BAbstractLayout.

Since
Haiku R1

Reimplemented from BAbstractLayout.

◆ BaseMinSize()

BSize BCardLayout::BaseMinSize ( )
virtual

Overridden hook method from BAbstractLayout.

Since
Haiku R1

Reimplemented from BAbstractLayout.

◆ BasePreferredSize()

BSize BCardLayout::BasePreferredSize ( )
virtual

Overridden hook method from BAbstractLayout.

Since
Haiku R1

Reimplemented from BAbstractLayout.

◆ DoLayout()

void BCardLayout::DoLayout ( )
protectedvirtual

Hook method overridden from BAbstractLayout.

Since
Haiku R1

Implements BLayout.

◆ GetHeightForWidth()

void BCardLayout::GetHeightForWidth ( float  width,
float *  min,
float *  max,
float *  preferred 
)
virtual

Overridden hook method from BAbstractLayout.

Since
Haiku R1

Reimplemented from BLayoutItem.

◆ HasHeightForWidth()

bool BCardLayout::HasHeightForWidth ( )
virtual

Overridden hook method from BAbstractLayout.

Since
Haiku R1

Reimplemented from BLayoutItem.

◆ Instantiate()

static BArchivable * BCardLayout::Instantiate ( BMessage from)
static

Instantiate a BCardLayout object from message from.

Since
Haiku R1

◆ ItemAdded()

bool BCardLayout::ItemAdded ( BLayoutItem item,
int32  atIndex 
)
protectedvirtual

Hook method overridden from BAbstractLayout.

Since
Haiku R1

Reimplemented from BAbstractLayout.

◆ ItemArchived()

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

Hook method overridden from BArchivable.

Since
Haiku R1

Reimplemented from BAbstractLayout.

◆ ItemRemoved()

void BCardLayout::ItemRemoved ( BLayoutItem item,
int32  fromIndex 
)
protectedvirtual

Hook method overridden from BAbstractLayout.

Since
Haiku R1

Reimplemented from BAbstractLayout.

◆ ItemUnarchived()

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

Hook method overridden from BArchivable.

Since
Haiku R1

Reimplemented from BAbstractLayout.

◆ LayoutInvalidated()

void BCardLayout::LayoutInvalidated ( bool  children = false)
protectedvirtual

Hook method overridden from BAbstractLayout.

Since
Haiku R1

Reimplemented from BAbstractLayout.

◆ Perform()

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

Overridden hook method from BAbstractLayout.

Since
Haiku R1

Reimplemented from BAbstractLayout.

◆ SetVisibleItem() [1/2]

void BCardLayout::SetVisibleItem ( BLayoutItem item)

Set the current visible item to item.

Parameters
itemA pointer to an item that is already added to this layout. When a reference to an item not on the stack, or NULL is passed, then no item will be displayed and the view will reset to the default grey background.
Since
Haiku R1

◆ SetVisibleItem() [2/2]

void BCardLayout::SetVisibleItem ( int32  index)

Set the current visible item to the item at index.

Parameters
indexThis is a zero-based index for the item you want to display. If the item does not exist (it is lower than 0 or it is higher than the number of items), no item will be displayed and the view will reset to the default grey background.
Since
Haiku R1

◆ VisibleIndex()

int32 BCardLayout::VisibleIndex ( ) const

Get the index of the currently visible item.

Returns
Returns the zero-based index, or -1 if there is no item visible.
Since
Haiku R1

◆ VisibleItem()

BLayoutItem * BCardLayout::VisibleItem ( ) const

Get a pointer to the currently visible item.

Returns
This method returns a pointer to the currently visible layout item, or NULL if there is no card visible.
Since
Haiku R1