Public Member Functions | List of all members
LayoutManager Class Referenceabstract

The LayoutManager class is the base class of the layout managers. More...

#include <LayoutManager.h>

Inheritance diagram for LayoutManager:
LayoutItem RefCounted< IRefCounted > IRefCounted DockLayout FlowLayout GridLayout SplitterLayout StackLayout HSplitterLayout VSplitterLayout HStackLayout VStackLayout

Public Member Functions

virtual void AddItem (LayoutItem *item)=0
 Adds a LayoutItem to this Layout Manager. More...
 
virtual LayoutItemItemAt (int index) const =0
 Retrieves the item at index in the layout and returns the item. More...
 
virtual LayoutItemTakeAt (int index)=0
 Removes the item at index from the layout, and returns the item. More...
 
virtual size_t Count () const =0
 Returns the number of items in this layout. More...
 
virtual void Invalidate ()
 Resets the layout's rectangle then calls Update() More...
 
virtual void SetDirty ()
 Resets the layout's rectangle. More...
 
virtual int GetSpacing () const
 Gets the spacing between items in the layout. More...
 
virtual void SetSpacing (int spacing)
 Sets the spacing between items in the layout. More...
 
virtual int IndexOf (LayoutControl *ctl) const
 Searches for the control in this layout (not including child layouts). More...
 
virtual int IndexOf (LayoutItem *item) const
 Searches for the LayoutItem in this layout (not including child layouts). More...
 
void WindowSizeDoLayout (const BSize &size)
 Notifies this LayoutManager that the Window size has changed and all child items should be laid out accordingly. More...
 
void VisibleDoLayout ()
 Notifies this LayoutManager that the layout has changed visibility and all child items should be laid out accordingly. More...
 
void ItemSizeDoLayout ()
 Notifies this LayoutManager that a child has changed size and all child items should be laid out accordingly. More...
 
LayoutManagerGetMainLayout ()
 Retrieves the main LayoutManager associated with this Layout Manager. More...
 
LayoutManagerGetSharedSizeGroupBoundary ()
 Retrieves the next Shared Size Group Boundary associated with this Layout Manager. More...
 
LayoutManagerGetParentLayout () const
 Retrieves the parent LayoutManager associated with this Layout Manager. More...
 
void SetParentLayout (LayoutManager *)
 Sets the parent LayoutManager for this Layout Manager. More...
 
LayoutControlGetParentControl () const
 Retrieves the parent LayoutControl associated with this Layout Manager. More...
 
void SetParentControl (LayoutControl *)
 Sets the parent LayoutControl for this Layout Manager. More...
 
int GetMargin () const
 Retrieves the margin for the LayoutManager, but only if all 4 margins are the same. Otherwise, -1 is returned. More...
 
void SetMargin (int margin)
 Sets the 4 margins for the LayoutManager to the same value. More...
 
void SetLayoutMargins (int left, int top, int right, int bottom)
 Sets the 4 margins for the LayoutManager. More...
 
void SetLayoutMargins (const Margins &margins)
 Sets the margins for the LayoutManager. More...
 
void GetLayoutMargins (int *left, int *top, int *right, int *bottom) const
 Gets the 4 margins for the LayoutManager. More...
 
Margins GetLayoutMargins () const
 Gets the 4 margins for the LayoutManager. More...
 
BRect GetContentsRect () const
 Gets the bounding rectangle for the contents in the LayoutManager. More...
 
bool SetAlignment (LayoutControl *ctl, LayoutAlignment alignment)
 Sets the alignment for a child control. More...
 
bool SetAlignment (LayoutManager *layout, LayoutAlignment alignment)
 Sets the alignment for a child layout. More...
 
bool Activate ()
 Invalidates the layout item then updates it. More...
 
void Update ()
 Invalidates the layout item without updating it. More...
 
void RemoveControl (LayoutControl *ctl)
 Removes a child control. More...
 
void RemoveItem (LayoutItem *item)
 Removes a child item. More...
 
int GetTotalHeightForWidth (int width) const
 Retrieves the required height for a given width. More...
 
BSize GetTotalMinimumSize () const
 Retrieves the total minimum size for the layout. More...
 
BSize GetTotalMaximumSize () const
 Retrieves the total maximum size for the layout. More...
 
BSize GetTotalDesiredSize () const
 Retrieves the total desired size for the layout. More...
 
void SetEnabled (bool)
 Sets whether the layout is enabled. More...
 
bool IsEnabled () const
 Determines whether the layout is enabled. More...
 
void SetTopLevel (bool)
 Sets whether the layout is top-level. More...
 
bool IsTopLevel () const
 Determines whether the layout is top-level. More...
 
void SetSharedSizeGroupBoundary (bool)
 Sets whether the layout is a Shared Group Boundary. More...
 
bool IsSharedSizeGroupBoundary () const
 Determines whether the layout is a Shared Group Boundary. More...
 
virtual bool IsEmpty () const override
 Returns whether the layout item is empty. More...
 
virtual bool IsVisible () const override
 Returns whether the layout item is visible. More...
 
virtual BSize GetMinimumSize () const override
 Returns the minimum size for this layout item. More...
 
virtual BSize GetMaximumSize () const override
 Retrieves the maximum size for this layout item. More...
 
virtual void SetGeometry (const BRect &rect) override
 Sets the geometry for this layout item to the given rectangle. More...
 
virtual BRect GetGeometry () const override
 Retrieves the geometry for this layout item. More...
 
virtual LayoutManagerGetLayout () override
 If the concrete item is a LayoutManager, it can be retrieved using GetLayout(). More...
 
virtual LayoutOrientations GetExpandingOrientations () const override
 Returns whether this layout item can make use of more space than GetDesiredSize(). More...
 
- Public Member Functions inherited from LayoutItem
virtual BSize GetDesiredSize () const =0
 Returns the desired size for this layout item. More...
 
virtual BSize GetSize () const
 Returns the geometry's size for this layout item. More...
 
virtual bool HasHeightForWidth () const
 Returns whether this layout's preferred height depends on its width. More...
 
virtual int GetHeightForWidth (int width) const
 Returns the preferred height for this layout item, given the width. More...
 
virtual int GetMinimumHeightForWidth (int width) const
 Returns the minimum height for this layout item, given the width. More...
 
virtual LayoutControlGetControl ()
 If the concrete item is a LayoutControl, it can be retrieved using GetControl(). More...
 
LayoutAlignment GetAlignment () const
 Returns the alignment within the layout for this layout item. More...
 
void SetAlignment (LayoutAlignment alignment)
 Sets the alignment within the layout for this layout item. More...
 
- Public Member Functions inherited from RefCounted< IRefCounted >
void * operator new (size_t size)
 
void operator delete (void *rawMemory, size_t size)
 
UInt32 AddRef () const
 
UInt32 Release () const
 
 RefCounted ()
 
 RefCounted (RefCounted const &rhs)
 
RefCountedoperator= (RefCounted const &rhs)
 
UInt32 GetRefCount () const
 

Additional Inherited Members

- Protected Member Functions inherited from RefCounted< IRefCounted >
virtual ~RefCounted ()
 
- Protected Member Functions inherited from IRefCounted
virtual ~IRefCounted ()
 
void * operator new (size_t size)
 
void operator delete (void *rawMemory, size_t size)
 

Detailed Description

The LayoutManager class is the base class of the layout managers.

This is an abstract base class inherited by the concrete classes DockLayout, FlowLayout, GridLayout, SplitterLayout and StackLayout.

For users of LayoutManager subclasses there is seldom any need to use the basic functions provided by LayoutManager, such as SetSizeConstraint().

To make your own layout manager, implement the functions AddItem(), GetDesiredSize(), SetGeometry(), ItemAt() and TakeAt(). You should also implement GetMinimumSize() to ensure your layout isn't resized to zero size if there is too little space. To support children whose heights depend on their widths, implement HasHeightForWidth() and GetHeightForWidth().

Geometry management stops when the layout manager is deleted.

Member Function Documentation

bool Activate ( )

Invalidates the layout item then updates it.

virtual void AddItem ( LayoutItem item)
pure virtual

Adds a LayoutItem to this Layout Manager.

Parameters
[in]itemThe layout item to add to the layout.
Remarks
Must be implemented in subclasses to add an item. How it is added is specific to each subclass.

This function is not usually called in application code. To add a control to a layout, use the AddControl() function; to add a child layout, use the AddLayout() function provided by the relevant LayoutManager subclass.

Note: The ownership of the item is transferred to the layout, and it's the layout's responsibility to delete it.

virtual size_t Count ( ) const
pure virtual

Returns the number of items in this layout.

Remarks
Must be implemented in subclasses to return the number of items in the layout.

Implemented in GridLayout, StackLayout, SplitterLayout, FlowLayout, and DockLayout.

BRect GetContentsRect ( ) const

Gets the bounding rectangle for the contents in the LayoutManager.

virtual LayoutOrientations GetExpandingOrientations ( ) const
overridevirtual

Returns whether this layout item can make use of more space than GetDesiredSize().

A value of LO_Vertical or LO_Horizontal means that it wants to grow in only one dimension, whereas LO_Vertical | LO_Horizontal means that it wants to grow in both dimensions.

Implements LayoutItem.

Reimplemented in GridLayout, StackLayout, FlowLayout, and DockLayout.

virtual BRect GetGeometry ( ) const
overridevirtual

Retrieves the geometry for this layout item.

Implements LayoutItem.

virtual LayoutManager* GetLayout ( )
overridevirtual

If the concrete item is a LayoutManager, it can be retrieved using GetLayout().

Reimplemented from LayoutItem.

void GetLayoutMargins ( int *  left,
int *  top,
int *  right,
int *  bottom 
) const

Gets the 4 margins for the LayoutManager.

Each of the arguments may be NULL.

Parameters
[in]leftReceives the left margin if not NULL
[in]topReceives the top margin if not NULL
[in]rightReceives the right margin if not NULL
[in]bottomReceives the bottom margin if not NULL
Margins GetLayoutMargins ( ) const

Gets the 4 margins for the LayoutManager.

Returns
The margins for the LayoutManager
LayoutManager* GetMainLayout ( )

Retrieves the main LayoutManager associated with this Layout Manager.

This searches backwards recursively searching for the main layout.

int GetMargin ( ) const

Retrieves the margin for the LayoutManager, but only if all 4 margins are the same. Otherwise, -1 is returned.

virtual BSize GetMaximumSize ( ) const
overridevirtual

Retrieves the maximum size for this layout item.

Implements LayoutItem.

Reimplemented in GridLayout, StackLayout, and SplitterLayout.

virtual BSize GetMinimumSize ( ) const
overridevirtual

Returns the minimum size for this layout item.

Implements LayoutItem.

Reimplemented in GridLayout, StackLayout, SplitterLayout, FlowLayout, and DockLayout.

LayoutControl* GetParentControl ( ) const

Retrieves the parent LayoutControl associated with this Layout Manager.

LayoutManager* GetParentLayout ( ) const

Retrieves the parent LayoutManager associated with this Layout Manager.

LayoutManager* GetSharedSizeGroupBoundary ( )

Retrieves the next Shared Size Group Boundary associated with this Layout Manager.

This searches backwards recursively searching for the next Shared Size Group Boundary.

virtual int GetSpacing ( ) const
virtual

Gets the spacing between items in the layout.

Reimplemented in StackLayout, and GridLayout.

BSize GetTotalDesiredSize ( ) const

Retrieves the total desired size for the layout.

int GetTotalHeightForWidth ( int  width) const

Retrieves the required height for a given width.

Parameters
[in]widthThe width for which to determine the required height
BSize GetTotalMaximumSize ( ) const

Retrieves the total maximum size for the layout.

BSize GetTotalMinimumSize ( ) const

Retrieves the total minimum size for the layout.

virtual int IndexOf ( LayoutControl ctl) const
virtual

Searches for the control in this layout (not including child layouts).

Parameters
[in]ctlThe control in the layout.
Returns
The index of the control, or - 1 if it is not found.
Remarks
The default implementation iterates over all items using ItemAt ().

Reimplemented in SplitterLayout.

virtual int IndexOf ( LayoutItem item) const
virtual

Searches for the LayoutItem in this layout (not including child layouts).

Parameters
[in]itemThe item in the layout.
Returns
The index of the LayoutItem, or - 1 if it is not found.
Remarks
The default implementation iterates over all items using ItemAt ().

Reimplemented in SplitterLayout.

virtual void Invalidate ( )
virtual

Resets the layout's rectangle then calls Update()

Reimplemented from LayoutItem.

Reimplemented in GridLayout, StackLayout, and SplitterLayout.

virtual bool IsEmpty ( ) const
overridevirtual

Returns whether the layout item is empty.

Implements LayoutItem.

bool IsEnabled ( ) const

Determines whether the layout is enabled.

bool IsSharedSizeGroupBoundary ( ) const

Determines whether the layout is a Shared Group Boundary.

bool IsTopLevel ( ) const

Determines whether the layout is top-level.

virtual bool IsVisible ( ) const
overridevirtual

Returns whether the layout item is visible.

Implements LayoutItem.

virtual LayoutItem* ItemAt ( int  index) const
pure virtual

Retrieves the item at index in the layout and returns the item.

If there is no such item, the function returns NULL.

Parameters
[in]indexThe index of the item to retrieve. Items are numbered consecutively from 0.
Remarks
ItemAt must be implemented in subclasses to return the layout item at index. If there is no such item, the function must return 0. Items are numbered consecutively from 0. If an item is deleted, other items will be renumbered. This function can be used to iterate over a layout.

Implemented in GridLayout, StackLayout, SplitterLayout, FlowLayout, and DockLayout.

void ItemSizeDoLayout ( )

Notifies this LayoutManager that a child has changed size and all child items should be laid out accordingly.

void RemoveControl ( LayoutControl ctl)

Removes a child control.

Parameters
[in]ctlThe child control
void RemoveItem ( LayoutItem item)

Removes a child item.

Parameters
[in]itemThe child item
bool SetAlignment ( LayoutControl ctl,
LayoutAlignment  alignment 
)

Sets the alignment for a child control.

Parameters
[in]ctlThe child control
[in]alignmentThe new LayoutAlignment value
bool SetAlignment ( LayoutManager layout,
LayoutAlignment  alignment 
)

Sets the alignment for a child layout.

Parameters
[in]layoutThe child layout
[in]alignmentThe new LayoutAlignment value
virtual void SetDirty ( )
virtual

Resets the layout's rectangle.

Reimplemented from LayoutItem.

Reimplemented in GridLayout, StackLayout, and SplitterLayout.

void SetEnabled ( bool  )

Sets whether the layout is enabled.

virtual void SetGeometry ( const BRect rect)
overridevirtual

Sets the geometry for this layout item to the given rectangle.

Parameters
[in]rectThe rectangle of the new geometry for the layout item.

Implements LayoutItem.

Reimplemented in GridLayout, StackLayout, SplitterLayout, FlowLayout, and DockLayout.

void SetLayoutMargins ( int  left,
int  top,
int  right,
int  bottom 
)

Sets the 4 margins for the LayoutManager.

Parameters
[in]leftThe left margin
[in]topThe top margin
[in]rightThe right margin
[in]bottomThe bottom margin
void SetLayoutMargins ( const Margins margins)

Sets the margins for the LayoutManager.

Parameters
[in]marginsThe new margins
void SetMargin ( int  margin)

Sets the 4 margins for the LayoutManager to the same value.

Parameters
[in]marginThe value used for the 4 margins.
void SetParentControl ( LayoutControl )

Sets the parent LayoutControl for this Layout Manager.

void SetParentLayout ( LayoutManager )

Sets the parent LayoutManager for this Layout Manager.

void SetSharedSizeGroupBoundary ( bool  )

Sets whether the layout is a Shared Group Boundary.

virtual void SetSpacing ( int  spacing)
virtual

Sets the spacing between items in the layout.

Parameters
[in]spacingThe amount of space between items in the layout.

Reimplemented in StackLayout, and GridLayout.

void SetTopLevel ( bool  )

Sets whether the layout is top-level.

virtual LayoutItem* TakeAt ( int  index)
pure virtual

Removes the item at index from the layout, and returns the item.

If there is no such item, the function does nothing and returns NULL.

Parameters
[in]indexThe index of the item to remove. Items are numbered consecutively from 0.
Remarks
Must be implemented in subclasses to remove the layout item at index from the layout, and return the item. If there is no such item, the function must do nothing and return 0. Items are numbered consecutively from 0. If an item is removed, other items will be renumbered.

Implemented in GridLayout, StackLayout, SplitterLayout, FlowLayout, and DockLayout.

void Update ( )

Invalidates the layout item without updating it.

void VisibleDoLayout ( )

Notifies this LayoutManager that the layout has changed visibility and all child items should be laid out accordingly.

void WindowSizeDoLayout ( const BSize size)

Notifies this LayoutManager that the Window size has changed and all child items should be laid out accordingly.

Parameters
[in]sizeThe new size of the window.

The documentation for this class was generated from the following file:

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.