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

Tree widget. More...

#include <CTreeControl.h>

Inheritance diagram for sptk::CTreeControl:
sptk::CScroll sptk::CLayoutManager sptk::CLayoutClient

Public Member Functions

 CTreeControl (const char *label, int layoutSize=50, CLayoutAlign align=CLayoutAlign::TOP)
 The constructor. More...
 
CTreeItemaddItem (const char *label, const Fl_Image *openedImage=nullptr, const Fl_Image *closedImage=nullptr, void *data=nullptr)
 Adds a child item to the root item. If the closedImage parameter is omitted the openedImage is used instead. More...
 
CTreeItemaddPath (const std::vector< String > &path, const Fl_Image *openedImage, const Fl_Image *closedImage, const Fl_Image *itemImage=0L, void *data=0L)
 Adds a child item to the root item using the path. More...
 
CTreeItemaddPath (const std::vector< String > &path, const Fl_Image *itemImage=0L, void *data=0L)
 
CTreeItemfindItem (const char *item) const
 Finds an item by the item label in the whole tree. More...
 
CTreeItemfindData (const void *data) const
 Finds an item by the item user data in the whole tree. More...
 
void clear () override
 Removes all the items in the tree. More...
 
void removeItem (CTreeItem *item)
 Removes all the item and underlying structure from the tree. More...
 
CTreeItemroot () const
 Reports the root item.
 
CTreeItemselected () const
 Reports the currently selected item.
 
void selectOnly (CTreeItem *item, bool giveFocus=false)
 Selects only one item. More...
 
void makeVisible (CTreeItem *item)
 Makes the item visible if it's outside the visible area. More...
 
int handle (int event) override
 Special handle() function. More...
 
void itemCreator (CTreeItemCreator ic)
 The tree item creator creates a tree item' body,. More...
 
void load (const xdoc::SNode &node, CLayoutXMLmode xmlMode) override
 Loads group controls data from XML node. More...
 
void save (const xdoc::SNode &node, CLayoutXMLmode xmlMode) const override
 Saves group controls data into XML node. More...
 
String className () const override
 Returns widget class name (internal SPTK RTTI). More...
 
- Public Member Functions inherited from sptk::CScroll
 CScroll (const char *label=0, int layoutSize=10, CLayoutAlign layoutAlign=CLayoutAlign::TOP)
 Constructor in SPTK style. More...
 
void resize (int x, int y, int w, int h) override
 Resizes the group and inside widgets. More...
 
void draw () override
 Custom draw() method.
 
bool preferredSize (int &w, int &h) override
 Computes the optimal group size. More...
 
void clear () override
 Removes all the child widgets. More...
 
virtual void position (int X, int Y)
 Sets the position of the scrolled area.
 
int xposition () const
 Returns the x-position of the scrolled area.
 
int yposition () const
 Returns the y-position of the scrolled area.
 
int handle (int) override
 Custom handle method.
 
String className () const override
 Returns widget class name (internal SPTK RTTI). More...
 
- Public Member Functions inherited from sptk::CLayoutManager
 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 moveItem (CTreeItem *item, CTreeItem *beforeItem=nullptr)
 Moves the item in the tree. More...
 
- Static Public Member Functions inherited from sptk::CScroll
static CLayoutClientcreator (const xdoc::SNode &node)
 Creates a widget based on the XML node information. More...
 
- Static Public Member Functions inherited from sptk::CLayoutManager
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.
 

Static Protected Member Functions

static CLayoutClientdefaultItemCreator (CTreeItem *item)
 The default tree item creator. More...
 

Friends

class CTreeItem
 

Additional Inherited Members

- Public Attributes inherited from sptk::CScroll
CScrollBar scrollbar
 
CScrollBar hscrollbar
 
- Protected Member Functions inherited from sptk::CLayoutManager
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 inherited from sptk::CLayoutManager
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 inherited from sptk::CLayoutManager
static std::map< std::string, Fl_Boxtype > m_boxTypeNames
 
static createControlCallbackMap controlCreator
 

Detailed Description

Tree widget.

Designed to be used inside CTreeView widget, but also can be used by itself. It's missing for data connection support of CTreeView, though.

Constructor & Destructor Documentation

◆ CTreeControl()

sptk::CTreeControl::CTreeControl ( const char *  label,
int  layoutSize = 50,
CLayoutAlign  align = CLayoutAlign::TOP 
)

The constructor.

Parameters
labelWidget's label
layoutSizeSize of widget in layout. See CLayoutClient for details
alignWidget align in the layout

Member Function Documentation

◆ addItem()

CTreeItem * sptk::CTreeControl::addItem ( const char *  label,
const Fl_Image *  openedImage = nullptr,
const Fl_Image *  closedImage = nullptr,
void *  data = nullptr 
)

Adds a child item to the root item. If the closedImage parameter is omitted the openedImage is used instead.

Parameters
labelThe item label
openedImageThe image for the opened state
closedImageThe image for the closed state
dataThe user data or ID attached to the item
Returns
the new child item

◆ addPath() [1/2]

CTreeItem * sptk::CTreeControl::addPath ( const std::vector< String > &  path,
const Fl_Image *  itemImage = 0L,
void *  data = 0L 
)

Adds a child item to the root item using the path. The required path items are created automatically. Path elements are separated with '/'. The default images are used for the folders in the path.

Parameters
pathThe path to the new child item
itemImageThe image for the child item
dataThe user data or ID attached to the item
Returns
the new child item

◆ addPath() [2/2]

CTreeItem * sptk::CTreeControl::addPath ( const std::vector< String > &  path,
const Fl_Image *  openedImage,
const Fl_Image *  closedImage,
const Fl_Image *  itemImage = 0L,
void *  data = 0L 
)

Adds a child item to the root item using the path.

The required path items are created automatically. Path elements are separated with '/'. The default images are used for the folders in the path.

Parameters
pathThe path to the new child item
openedImageThe image for the folders in opened state
closedImageThe image for the folders in closed state
itemImageThe image for the child item
dataThe user data or ID attached to the item
Returns
the new child item

◆ className()

String sptk::CTreeControl::className ( ) const
inlineoverridevirtual

Returns widget class name (internal SPTK RTTI).

Reimplemented from sptk::CScroll.

◆ clear()

void sptk::CTreeControl::clear ( )
inlineoverridevirtual

Removes all the items in the tree.

Reimplemented from sptk::CScroll.

References sptk::CTreeItem::clear().

◆ defaultItemCreator()

static CLayoutClient * sptk::CTreeControl::defaultItemCreator ( CTreeItem item)
staticprotected

The default tree item creator.

Creates a tree item' body as CBox,

See also
CTreeItemCreator

◆ findData()

CTreeItem * sptk::CTreeControl::findData ( const void *  data) const

Finds an item by the item user data in the whole tree.

Parameters
dataUser data to find
Returns
the child item (if found) or NULL

◆ findItem()

CTreeItem * sptk::CTreeControl::findItem ( const char *  item) const

Finds an item by the item label in the whole tree.

Parameters
itemItem label to find
Returns
the child item (if found) or NULL

◆ handle()

int sptk::CTreeControl::handle ( int  event)
override

Special handle() function.

Parameters
eventAn FLTK event
Returns
true, if event was processed

◆ itemCreator()

void sptk::CTreeControl::itemCreator ( CTreeItemCreator  ic)
inline

The tree item creator creates a tree item' body,.

See also
CTreeItemCreator

◆ load()

void sptk::CTreeControl::load ( const xdoc::SNode &  node,
CLayoutXMLmode  xmlMode 
)
overridevirtual

Loads group controls data from XML node.

Parameters
nodeNode to load data from
autoCreateIgnored

Reimplemented from sptk::CLayoutClient.

◆ makeVisible()

void sptk::CTreeControl::makeVisible ( CTreeItem item)

Makes the item visible if it's outside the visible area.

Parameters
itemItem to make visible

◆ moveItem()

static void sptk::CTreeControl::moveItem ( CTreeItem item,
CTreeItem beforeItem = nullptr 
)
static

Moves the item in the tree.

Parameters
itemItem to insert
beforeItemItem before the insert point. If 0L - it's moved to the very last position in parent item list of items.

◆ removeItem()

void sptk::CTreeControl::removeItem ( CTreeItem item)

Removes all the item and underlying structure from the tree.

Parameters
itemItem to remove

◆ save()

void sptk::CTreeControl::save ( const xdoc::SNode &  node,
CLayoutXMLmode  xmlMode 
) const
override

Saves group controls data into XML node.

Parameters
nodeNode to save data into

◆ selectOnly()

void sptk::CTreeControl::selectOnly ( CTreeItem item,
bool  giveFocus = false 
)

Selects only one item.

Parameters
itemItem to select
giveFocusShould the item be focused?

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

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