sptk2 logo
SPTK Home Page
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
sptk::CLayoutManager Class Reference

Layout Manager. More...

#include <CLayoutManager.h>

Inheritance diagram for sptk::CLayoutManager:
sptk::CLayoutClient sptk::CGroup sptk::CScroll sptk::CWindow sptk::CTabs sptk::CToolBar sptk::CTreeItem sptk::CTreeControl sptk::CDialog sptk::CPopupWindow sptk::CDialogTabs sptk::CAskDialog sptk::CFileDialog sptk::CSpellChecker sptk::CDBDropDownList sptk::CPopupCalendar sptk::CInputDialog sptk::CMessageDialog sptk::CDirOpenDialog sptk::CFileOpenDialog sptk::CFileSaveDialog sptk::CEditorSpellChecker

Public Member Functions

 CLayoutManager (Fl_Group *group, int layoutSize, CLayoutAlign ca)
 
 ~CLayoutManager () override=default
 
virtual void clear ()
 Removes all the children. More...
 
int layoutSpacing () const
 
void layoutSpacing (int ls)
 
void layoutGrowMode (CLayoutGrowMode gm=CLayoutGrowMode::LGM_AUTO_GROW)
 
CLayoutGrowMode layoutGrowMode () const
 
void relayout ()
 
void frame (CFrame *frame, bool drawBackground=true)
 Defines frame. More...
 
const CFrameframe () const
 Returnes the current frame.
 
uint32_t frameWidth () const
 Returns frame width.
 
virtual void loadLayout (const xdoc::SNode &node, CLayoutXMLmode xmlMode)
 Loads group controls data from XML node. More...
 
virtual void saveLayout (const xdoc::SNode &node, CLayoutXMLmode xmlMode) const
 Saves group controls data into XML node. More...
 
void nameIndex (CWidgetNamesMap &index, bool recursive, bool clean=true) const
 Builds an index of internal widget names. More...
 
bool noXml () const
 Returns flag of blocking XML processing. More...
 
void noXml (bool noXml)
 Sets flag of blocking XML processing. More...
 
- Public Member Functions inherited from sptk::CLayoutClient
 CLayoutClient (Fl_Widget *widget, int layoutSize, CLayoutAlign ca)
 
virtual ~CLayoutClient ()
 
CLayoutAlign layoutAlign () const
 
void layoutAlign (CLayoutAlign al)
 
int layoutSize () const
 
void layoutSize (int ls)
 
virtual void label (const String &l)
 
virtual const Stringlabel () const
 
void name (const char *aname)
 
void name (const String &aname)
 
const Stringname () const
 
virtual bool preferredSize (int &w, int &h)
 
virtual bool computeSize (int &w, int &h)
 
virtual String className () const
 
Fl_Widget * widget () const
 
virtual void load (const xdoc::SNode &node, CLayoutXMLmode xmlMode)
 
virtual void load (const std::shared_ptr< xdoc::Node > &node)
 
virtual void save (const std::shared_ptr< xdoc::Node > &node, CLayoutXMLmode xmlMode) const
 

Static Public Member Functions

static void registerControl (std::string typeName, createControlCallback creator) noexcept
 Register control type for loading layouts. More...
 
static const std::map< std::string, Fl_Boxtype > & boxTypeNames ()
 Returns a read-only map of box type names and corresponding constants.
 

Protected Member Functions

bool autoLayout (int x, int y, int &w, int &h, bool resizeWidgets) const
 
virtual void paintBackground ()
 
- Protected Member Functions inherited from sptk::CLayoutClient
int lastPreferredH () const
 
int lastPreferredW () const
 
void lastPreferredH (int height)
 
void lastPreferredW (int width)
 

Protected Attributes

int m_layoutSpacing
 
CLayoutGrowMode m_layoutGrowMode
 
Fl_Group * m_group
 
CFramem_frame
 
bool m_frameDrawBackground
 
bool m_noXml
 
- Protected Attributes inherited from sptk::CLayoutClient
Fl_Widget * m_widget
 
String m_name
 
String m_label
 
CLayoutAlign m_layoutAlign
 

Static Protected Attributes

static std::map< std::string, Fl_Boxtype > m_boxTypeNames
 
static createControlCallbackMap controlCreator
 

Friends

class CLayoutManagerInitializer
 

Detailed Description

Layout Manager.

Maintains the position and size of the CLayoutClient-derived objects in the attached group. It uses the CLayoutClient::layoutAlign() property of such objects and the output of CLayoutClient::preferredSize() to determine the widget's size and position.

See also
CLayoutClient

Constructor & Destructor Documentation

◆ CLayoutManager()

sptk::CLayoutManager::CLayoutManager ( Fl_Group *  group,
int  layoutSize,
CLayoutAlign  ca 
)

Constructor

Parameters
groupFl_Group*, a group widget to manage (CGroup, CScroll, or CWindow)
layoutSizeint, the size of the widget in layout. See m_layoutSize for more information.
caCLayoutAlign, widget align in layout

◆ ~CLayoutManager()

sptk::CLayoutManager::~CLayoutManager ( )
overridedefault

Destructor

Member Function Documentation

◆ autoLayout()

bool sptk::CLayoutManager::autoLayout ( int  x,
int  y,
int &  w,
int &  h,
bool  resizeWidgets 
) const
protected

Does the auto layout computations and optional actual widget resizing

Parameters
xint, the layout x position, input
yint, the layout y position, input
wint&, the layout width, input/output
hint&, the layout height, input/output
resizeWidgetsbool, resize widgets if true, or just compute the layout size
Returns
true if the size is stable (doesn't depend on input sizes w,h)

◆ clear()

virtual void sptk::CLayoutManager::clear ( )
virtual

Removes all the children.

Reimplemented in sptk::CGroup, sptk::CScroll, sptk::CTreeItem, sptk::CTreeControl, and sptk::CWindow.

◆ frame()

void sptk::CLayoutManager::frame ( CFrame frame,
bool  drawBackground = true 
)
inline

Defines frame.

Parameters
frameCFrame *, frame to use
drawBackgroundbool, if true then background is paint

◆ layoutGrowMode() [1/2]

CLayoutGrowMode sptk::CLayoutManager::layoutGrowMode ( ) const
inline

Returns current layout grow mode

See also
CLayoutGrowMode

◆ layoutGrowMode() [2/2]

void sptk::CLayoutManager::layoutGrowMode ( CLayoutGrowMode  gm = CLayoutGrowMode::LGM_AUTO_GROW)
inline

Defines layout grow mode

Parameters
gmCLayoutGrowMode, new layout grow mode
See also
CLayoutGrowMode

◆ layoutSpacing() [1/2]

int sptk::CLayoutManager::layoutSpacing ( ) const
inline

Returns current layout spacing between widgets

◆ layoutSpacing() [2/2]

void sptk::CLayoutManager::layoutSpacing ( int  ls)
inline

Defines layout spacing between widgets

Parameters
lsint, new layout spacing

◆ loadLayout()

virtual void sptk::CLayoutManager::loadLayout ( const xdoc::SNode &  node,
CLayoutXMLmode  xmlMode 
)
virtual

Loads group controls data from XML node.

Parameters
nodeconst xml::Node*, node to load data from
xmlModeCLayoutXMLmode, the mode defining how the layout and/or data should be loaded

◆ nameIndex()

void sptk::CLayoutManager::nameIndex ( CWidgetNamesMap index,
bool  recursive,
bool  clean = true 
) const

Builds an index of internal widget names.

The index is filled in with pairs of widget name - widget. Only CLayoutClient-derived widgets with names are included.

Parameters
indexCWidgetNamesMap&, the index to fill in
recursivebool, if true also processes the children
cleanbool, if true, the list is cleaned prior to fill

◆ noXml() [1/2]

bool sptk::CLayoutManager::noXml ( ) const
inline

Returns flag of blocking XML processing.

If this flag is set then no XML is loaded or saved

◆ noXml() [2/2]

void sptk::CLayoutManager::noXml ( bool  noXml)
inline

Sets flag of blocking XML processing.

If this flag is set then no XML is loaded or saved. This flag may be used, for instance, if you want to exclude some control (widget) from being stored in XML.

Parameters
noXmlbool, if true - no XML is red or written

◆ paintBackground()

virtual void sptk::CLayoutManager::paintBackground ( )
protectedvirtual

Paints background in tiles mode

◆ registerControl()

static void sptk::CLayoutManager::registerControl ( std::string  typeName,
createControlCallback  creator 
)
staticnoexcept

Register control type for loading layouts.

The control name can be anything as far as in can be used as XML tag name. The creator callback creates a control (widget) using the XML information passed to the callback by the layout manager.

Parameters
typeNamestd::string, the type of the (control) widget
creatorcreateControlCallback, a callback that creates the required widget

◆ relayout()

void sptk::CLayoutManager::relayout ( )

Relayouts the attached group. It may be necessary if the inside widgets have changed content or shown/hidden.

◆ saveLayout()

virtual void sptk::CLayoutManager::saveLayout ( const xdoc::SNode &  node,
CLayoutXMLmode  xmlMode 
) const
virtual

Saves group controls data into XML node.

Parameters
nodeconst xml::Node*, node to save data into
xmlModeCLayoutXMLmode, the mode defining how the layout and/or data should be stored

Member Data Documentation

◆ controlCreator

createControlCallbackMap sptk::CLayoutManager::controlCreator
staticprotected

A map of control types and callbacks that create them

◆ m_boxTypeNames

std::map<std::string, Fl_Boxtype> sptk::CLayoutManager::m_boxTypeNames
staticprotected

A map of box type names and corresponding constants

◆ m_frame

CFrame* sptk::CLayoutManager::m_frame
protected

The group frame, including optional background image

◆ m_frameDrawBackground

bool sptk::CLayoutManager::m_frameDrawBackground
protected

Should we draw background

◆ m_group

Fl_Group* sptk::CLayoutManager::m_group
protected

Attached group to manage

◆ m_layoutGrowMode

CLayoutGrowMode sptk::CLayoutManager::m_layoutGrowMode
protected

Layout grow mode,

See also
CLayoutGrowMode

◆ m_layoutSpacing

int sptk::CLayoutManager::m_layoutSpacing
protected

An extra space between widgets

◆ m_noXml

bool sptk::CLayoutManager::m_noXml
protected

If true - do not read or write any XML


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

Fri Oct 14 2022 09:58:37: SPTK 5.4.1