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

Tree widget item. More...

#include <CTreeControl.h>

Inheritance diagram for sptk::CTreeItem:
sptk::CGroup sptk::CLayoutManager sptk::CLayoutClient

Public Member Functions

 CTreeItem (const char *label, const Fl_Image *openedImage=nullptr, const Fl_Image *closedImage=nullptr, void *data=nullptr)
 
CTreeItemaddItem (const char *label, const Fl_Image *openedImage=nullptr, const Fl_Image *closedImage=nullptr, void *data=nullptr)
 
CTreeItemaddPath (const std::vector< String > &path, const Fl_Image *openedImage, const Fl_Image *closedImage, const Fl_Image *itemImage=0L, void *data=0L)
 
CTreeItemaddPath (const std::vector< String > &path, const Fl_Image *itemImage=0L, void *data=0L)
 
CLayoutClientbody ()
 The widget that represents the item without children.
 
void label (const String &lbl) override
 Sets the item's caption. More...
 
const Stringlabel () const override
 Returns the item's caption. More...
 
void clear () override
 Removes all the child items of the item. More...
 
CTreeItemfindItem (const char *label) const
 Finds an item among the child items. More...
 
CTreeItemfindData (const void *data) const
 Finds an item by the item user data in the whole tree. More...
 
void removeItem (CTreeItem *item)
 Removes an item from the child items. More...
 
CTreeItemparentItem () const
 Returns the parent item. More...
 
CTreeControltree () const
 Returns the tree control this item belongs to.
 
void moveItem (CTreeItem *item, CTreeItem *beforeItem=nullptr)
 Moves the immediate child before another immediate child. More...
 
void moveItem (CTreeItem *item, int direction)
 Moves the immediate child up or down in the list of items. More...
 
void visibleChildren (bool vc)
 Shows or hides all the child items. Changes the item state accordingly. More...
 
void open ()
 Shows all the child items. Changes the item state accordingly.
 
void close ()
 Hides all the child items. Changes the item state accordingly.
 
bool opened () const
 Reports the item state - opened or closed.
 
uint32_t indent () const
 Reports the item indent from the left.
 
void setImage (const Fl_Image *openedImage, const Fl_Image *closedImage=nullptr)
 Sets image(s) for the item. More...
 
int handle (int event) override
 The event handle function. Internal. See Fl_Widget for details. More...
 
void draw () override
 The draw function. Internal. See Fl_Widget for details.
 
bool preferredSize (int &w, int &h) override
 Computes the preferred size of the item based on the font of the parent widget, the image size, and the text (label) of the item. More...
 
void resize (int xx, int yy, int ww, int hh) override
 Resizes item and sub items.
 
virtual void select (bool flag)
 Selects or unselects item. More...
 
bool selected () const
 Returns selection state of the item.
 
bool selectNext ()
 Selects the next item in the tree.
 
bool selectPrior ()
 Selects the prior item in the tree.
 
CTreeItemfindFirst () const
 Selects the first visible item in the child tree.
 
CTreeItemfindLast (bool recursive) const
 Selects the last visible item in the child tree. More...
 
CTreeItemfindNext (bool recursive) const
 Selects the next visible item in the child tree. More...
 
CTreeItemfindPrior (bool recursive) const
 Selects the prior visible item in the child tree. More...
 
String className () const override
 Returns widget class name (internal SPTK RTTI). More...
 
- Public Member Functions inherited from sptk::CGroup
bool drawClipped () const
 
void drawClipped (bool drawClipped)
 
 CGroup (const char *label=nullptr, int layoutSize=10, CLayoutAlign layoutAlign=CLayoutAlign::TOP)
 
void draw () override
 
void resize (int x, int y, int w, int h) override
 
bool preferredSize (int &w, int &h) override
 
void clear () override
 Removes all the widgets inside the group. More...
 
const Stringlabel () const override
 Returns the current label. More...
 
String className () const override
 Returns widget class name (internal SPTK RTTI). More...
 
virtual void label (const String &l)
 
virtual const Stringlabel () const
 
- 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 const Fl_Image * getTreeOpened ()
 
static void setTreeOpened (const Fl_Image *image)
 
static const Fl_Image * getTreeClosed ()
 
static void setTreeClosed (const Fl_Image *image)
 
static const Fl_Image * getFolderOpened ()
 
static void setFolderOpened (const Fl_Image *image)
 
static const Fl_Image * getFolderClosed ()
 
static void setFolderClosed (const Fl_Image *image)
 
static const Fl_Image * getDocument ()
 
static void setDocument (const Fl_Image *image)
 
- Static Public Member Functions inherited from sptk::CGroup
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.
 

Protected Member Functions

CTreeItemaddPathOffset (const std::vector< String > &pathFolders, uint32_t offset, const Fl_Image *openedImage, const Fl_Image *closedImage, const Fl_Image *itemImage=0L, void *data=0L)
 
- Protected Member Functions inherited from sptk::CGroup
void ctor_init (const char *label)
 
- 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)
 

Static Protected Attributes

static const Fl_Image * treeOpened
 
static const Fl_Image * treeClosed
 
static const Fl_Image * folderOpened
 
static const Fl_Image * folderClosed
 
static const Fl_Image * document
 
- Static Protected Attributes inherited from sptk::CLayoutManager
static std::map< std::string, Fl_Boxtype > m_boxTypeNames
 
static createControlCallbackMap controlCreator
 

Additional Inherited Members

- 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
 

Detailed Description

Tree widget item.

A group widget with the extra information about item pixmaps and current state.

Constructor & Destructor Documentation

◆ CTreeItem()

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

Constructor. 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

Member Function Documentation

◆ addItem()

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

Adds a child item to the 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

Referenced by sptk::CTreeView::addItem().

◆ addPath() [1/2]

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

Adds a child item to the item using the path. The required path items are created automatically. The default images are used for the folders in the path.

Parameters
pathThe path to the new child item relatively to the 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::CTreeItem::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 item using the path. The required path items are created automatically.

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

Referenced by sptk::CTreeView::addPath().

◆ addPathOffset()

CTreeItem * sptk::CTreeItem::addPathOffset ( const std::vector< String > &  pathFolders,
uint32_t  offset,
const Fl_Image *  openedImage,
const Fl_Image *  closedImage,
const Fl_Image *  itemImage = 0L,
void *  data = 0L 
)
protected

Adds a child item to the item using the path. The required path items are created automatically. This method is used internally only.

Parameters
pathFoldersThe path to the new child item relatively to the item
offsetThe offset in pathFolders where the path starts
openedImageThe image for the opened folder
closedImageThe image for the closed folder
itemImageThe image for the child item
dataThe user data or ID attached to the item
Returns
the new child item

◆ className()

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

Returns widget class name (internal SPTK RTTI).

Reimplemented from sptk::CGroup.

◆ clear()

void sptk::CTreeItem::clear ( )
overridevirtual

Removes all the child items of the item.

Reimplemented from sptk::CGroup.

Referenced by sptk::CTreeControl::clear().

◆ findData()

CTreeItem * sptk::CTreeItem::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::CTreeItem::findItem ( const char *  label) const

Finds an item among the child items.

Returns
the child item (if found) or NULL

◆ findLast()

CTreeItem * sptk::CTreeItem::findLast ( bool  recursive) const

Selects the last visible item in the child tree.

Parameters
recursiveShould we search the child items

◆ findNext()

CTreeItem * sptk::CTreeItem::findNext ( bool  recursive) const

Selects the next visible item in the child tree.

Parameters
recursiveShould we search the child items

◆ findPrior()

CTreeItem * sptk::CTreeItem::findPrior ( bool  recursive) const

Selects the prior visible item in the child tree.

Parameters
recursiveShould we search the child items

◆ getDocument()

static const Fl_Image * sptk::CTreeItem::getDocument ( )
static

Default image of the document

◆ getFolderClosed()

static const Fl_Image * sptk::CTreeItem::getFolderClosed ( )
static

Default image of the closed floder

◆ getFolderOpened()

static const Fl_Image * sptk::CTreeItem::getFolderOpened ( )
static

Default image of the opened floder

◆ getTreeClosed()

static const Fl_Image * sptk::CTreeItem::getTreeClosed ( )
static

Default image of the closed tree

◆ getTreeOpened()

static const Fl_Image * sptk::CTreeItem::getTreeOpened ( )
static

Default image of the opened tree

◆ handle()

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

The event handle function. Internal. See Fl_Widget for details.

Parameters
eventEvent type.
Returns
true if event was processed.

◆ label() [1/2]

const String & sptk::CTreeItem::label ( ) const
inlineoverridevirtual

Returns the item's caption.

Reimplemented from sptk::CGroup.

◆ label() [2/2]

void sptk::CTreeItem::label ( const String lbl)
overridevirtual

Sets the item's caption.

Parameters
lblThe new item caption

Reimplemented from sptk::CLayoutClient.

◆ moveItem() [1/2]

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

Moves the immediate child before another immediate child.

If beforeItem is 0L then moves to the end of the children

Parameters
itemThe item to move
beforeItemThe item to insert before

◆ moveItem() [2/2]

void sptk::CTreeItem::moveItem ( CTreeItem item,
int  direction 
)

Moves the immediate child up or down in the list of items.

Parameters
itemThe item to move
directionThe direction to move. -1 to move up, 1 to move down

◆ parentItem()

CTreeItem * sptk::CTreeItem::parentItem ( ) const

Returns the parent item.

Returns
the parent item or NULL (for the root item)

◆ preferredSize()

bool sptk::CTreeItem::preferredSize ( int &  w,
int &  h 
)
overridevirtual

Computes the preferred size of the item based on the font of the parent widget, the image size, and the text (label) of the item.

Parameters
wInput/output desirable widget width
hIinput/output desirable widget heigth
Returns
true if the size is stable (doesn't depend on input sizes)

Reimplemented from sptk::CGroup.

◆ removeItem()

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

Removes an item from the child items.

Only the intermediate children are considered

Parameters
itemItem to remove

◆ select()

virtual void sptk::CTreeItem::select ( bool  flag)
virtual

Selects or unselects item.

Parameters
flagTrue is item shoud be selected

◆ setDocument()

static void sptk::CTreeItem::setDocument ( const Fl_Image *  image)
static

Default image of the document

◆ setFolderClosed()

static void sptk::CTreeItem::setFolderClosed ( const Fl_Image *  image)
static

Default image of the closed floder

◆ setFolderOpened()

static void sptk::CTreeItem::setFolderOpened ( const Fl_Image *  image)
static

Default image of the opened floder

◆ setImage()

void sptk::CTreeItem::setImage ( const Fl_Image *  openedImage,
const Fl_Image *  closedImage = nullptr 
)
inline

Sets image(s) for the item.

Parameters
openedImageThe image for the opened state
closedImageThe image for the closed state

◆ setTreeClosed()

static void sptk::CTreeItem::setTreeClosed ( const Fl_Image *  image)
static

Default image of the closed tree

◆ setTreeOpened()

static void sptk::CTreeItem::setTreeOpened ( const Fl_Image *  image)
static

Default image of the opened tree

◆ visibleChildren()

void sptk::CTreeItem::visibleChildren ( bool  vc)

Shows or hides all the child items. Changes the item state accordingly.

Parameters
vcbool, show(true) or hide(false) children

Member Data Documentation

◆ document

const Fl_Image* sptk::CTreeItem::document
staticprotected

Default image of the document

◆ folderClosed

const Fl_Image* sptk::CTreeItem::folderClosed
staticprotected

Default image of the closed floder

◆ folderOpened

const Fl_Image* sptk::CTreeItem::folderOpened
staticprotected

Default image of the opened floder

◆ treeClosed

const Fl_Image* sptk::CTreeItem::treeClosed
staticprotected

Default image of the closed tree

◆ treeOpened

const Fl_Image* sptk::CTreeItem::treeOpened
staticprotected

Default image of the opened tree


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

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