Public Member Functions | Static Public Member Functions | List of all members
SplitterLayout Class Reference

A SplitterLayout lets the user control the size of child controls or layouts by dragging the boundary between the children. More...

#include <SplitterLayout.h>

Inheritance diagram for SplitterLayout:
LayoutManager LayoutItem RefCounted< IRefCounted > IRefCounted HSplitterLayout VSplitterLayout

Public Member Functions

void AddControl (LayoutControl *ctl, int stretch=0)
 Adds a control to the layout. More...
 
void InsertControl (int index, LayoutControl *ctl, int stretch=0)
 Inserts a control at position index in the splitter's list of items. More...
 
void AddLayout (LayoutManager *layout, int stretch=0)
 Adds a child layout to this layout. More...
 
void InsertLayout (int index, LayoutManager *layout, int stretch=0)
 Inserts a child layout at position index in the splitter's list of items. More...
 
void AssignHandle (SplitterHandle *handle, LayoutItem *item)
 Assigns a SplitterHandle to a given child LayoutItem. More...
 
LayoutOrientation GetOrientation () const
 Gets the layout orientation for this SplitterLayout. More...
 
void SetOrientation (LayoutOrientation) const
 Sets the layout orientation for this SplitterLayout. More...
 
void Refresh ()
 Refreshes the items in the layout. More...
 
virtual BSize GetDesiredSize () const override
 Returns the desired size for this layout. More...
 
virtual BSize GetMinimumSize () const override
 Returns the minimum size for this layout. More...
 
virtual BSize GetMaximumSize () const override
 Returns the maximum size for this layout. More...
 
virtual BSize GetMinimumDesiredSize () const
 Returns the minimum desired size for this layout. More...
 
int GetStretchFactor (int index) const
 Retrieves the stretch factor for the item at a given index. More...
 
bool SetStretchFactor (int index, int stretch)
 Sets the stretch factor for the item at a given index. More...
 
bool SetStretchFactor (LayoutControl *ctl, int stretch)
 Sets the stretch factor for a given control. More...
 
bool SetStretchFactor (LayoutItem *item, int stretch)
 Sets the stretch factor for a given item. More...
 
virtual int IndexOf (LayoutControl *ctl) const override
 Searches for the control in this layout (not including child layouts). More...
 
virtual int IndexOf (LayoutItem *item) const override
 Searches for the LayoutItem in this layout (not including child layouts). More...
 
virtual LayoutItemItemAt (int index) const override
 Retrieves the item at index in the layout and returns the item. More...
 
virtual LayoutItemTakeAt (int index) override
 Removes the item at index from the layout, and returns the item. More...
 
virtual size_t Count () const override
 Returns the number of items in this layout. More...
 
virtual void SetGeometry (const BRect &rect) override
 Sets the geometry for this layout item to the given rectangle. More...
 
virtual void Invalidate () override
 Resets the layout's rectangle then calls Update() More...
 
virtual void SetDirty () override
 Resets the layout's rectangle. More...
 
- Public Member Functions inherited from LayoutManager
virtual void AddItem (LayoutItem *item)=0
 Adds a LayoutItem to this Layout Manager. 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...
 
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 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 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
 

Static Public Member Functions

static SplitterLayoutCreate (LayoutOrientation=LO_Horizontal, LayoutControl *parent=0)
 Creates a SplitterLayout Layout Manager. More...
 

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

A SplitterLayout lets the user control the size of child controls or layouts by dragging the boundary between the children.

The boundary between children is a handle that is used to resize the controls. This handle is called a SplitterHandle or Sash. Any number of controls may be controlled by a single SplitterLayout. The typical use of a SplitterLayout is to create several controls and add them using AddControl() or AddLayout().

If a control or layout is already inside a SplitterLayout when InsertControl(), Addcontrol(), InsertLayout() or AddLayout() is called, it will move to the new position. This can be used to reorder controls in the SplitterLayout later. You can use IndexOf(), Count() and GetItemAtIndex() to get access to the children inside the SplitterLayout.

A default SplitterLayout lays out its children horizontally (side by side); you can use SetOrientation(LO_Vertical) to lay its children out vertically. Or you can use the HSplitterLayout or VSplitterLayout subclasses.

By default, all controls can be as large or as small as the user wishes, between the GetMinimumDesiredSize() (or GetMinimumSize()) and GetMaximumSize() of the children.

SplitterLayout resizes its children dynamically by default. If you would rather have SplitterLayout resize the children only at the end of a resize operation, call SetOpaqueResize(false).

The initial distribution of size between the children is determined by multiplying the initial size with the stretch factor. You can also use SetSizes() to set the sizes of all the controls. The function GetSizes() returns the sizes set by the user.

When you Hide() a child, its space will be distributed among the other children. It will be reinstated when you Show() it again.

Member Function Documentation

void AddControl ( LayoutControl ctl,
int  stretch = 0 
)

Adds a control to the layout.

Parameters
[in]ctlThe LayoutControl being added to the layout.
[in]stretchThe stretch factor to use for the control being added.
void AddLayout ( LayoutManager layout,
int  stretch = 0 
)

Adds a child layout to this layout.

Parameters
[in]layoutThe LayoutManager being added to the layout.
[in]stretchThe stretch factor to use for the layout being added.
void AssignHandle ( SplitterHandle handle,
LayoutItem item 
)

Assigns a SplitterHandle to a given child LayoutItem.

Parameters
[in]handleThe SplitterHandle to associate with a given LayoutItem
[in]itemThe LayoutItem being assigned the SplitterHandle
virtual size_t Count ( ) const
overridevirtual

Returns the number of items in this layout.

Implements LayoutManager.

static SplitterLayout* Create ( LayoutOrientation  = LO_Horizontal,
LayoutControl parent = 0 
)
static

Creates a SplitterLayout Layout Manager.

Parameters
[in]parentThe parent LayoutControl
Returns
A pointer to the new SplitterLayout object.
virtual BSize GetDesiredSize ( ) const
overridevirtual

Returns the desired size for this layout.

Implements LayoutItem.

virtual BSize GetMaximumSize ( ) const
overridevirtual

Returns the maximum size for this layout.

Reimplemented from LayoutManager.

virtual BSize GetMinimumDesiredSize ( ) const
virtual

Returns the minimum desired size for this layout.

virtual BSize GetMinimumSize ( ) const
overridevirtual

Returns the minimum size for this layout.

Reimplemented from LayoutManager.

LayoutOrientation GetOrientation ( ) const

Gets the layout orientation for this SplitterLayout.

int GetStretchFactor ( int  index) const

Retrieves the stretch factor for the item at a given index.

virtual int IndexOf ( LayoutControl ctl) const
overridevirtual

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.

Reimplemented from LayoutManager.

virtual int IndexOf ( LayoutItem item) const
overridevirtual

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.

Reimplemented from LayoutManager.

void InsertControl ( int  index,
LayoutControl ctl,
int  stretch = 0 
)

Inserts a control at position index in the splitter's list of items.

If ctl is already in the splitter, it will be moved to the new position.

Parameters
[in]indexposition index in the splitter's list of items
[in]ctlThe LayoutControl being added to the layout
[in]stretchThe stretch factor to use for the control being added
void InsertLayout ( int  index,
LayoutManager layout,
int  stretch = 0 
)

Inserts a child layout at position index in the splitter's list of items.

If ctl is already in the splitter, it will be moved to the new position.

Parameters
[in]indexposition index in the splitter's list of items
[in]layoutThe LayoutManager being added to the layout.
[in]stretchThe stretch factor to use for the layout being added
virtual void Invalidate ( )
overridevirtual

Resets the layout's rectangle then calls Update()

Reimplemented from LayoutManager.

virtual LayoutItem* ItemAt ( int  index) const
overridevirtual

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.

Implements LayoutManager.

void Refresh ( )

Refreshes the items in the layout.

virtual void SetDirty ( )
overridevirtual

Resets the layout's rectangle.

Reimplemented from LayoutManager.

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.

Reimplemented from LayoutManager.

void SetOrientation ( LayoutOrientation  ) const

Sets the layout orientation for this SplitterLayout.

bool SetStretchFactor ( int  index,
int  stretch 
)

Sets the stretch factor for the item at a given index.

bool SetStretchFactor ( LayoutControl ctl,
int  stretch 
)

Sets the stretch factor for a given control.

bool SetStretchFactor ( LayoutItem item,
int  stretch 
)

Sets the stretch factor for a given item.

virtual LayoutItem* TakeAt ( int  index)
overridevirtual

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.

Implements LayoutManager.


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

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