Tree widget item. More...
#include <CTreeControl.h>
Public Member Functions | |
CTreeItem (const char *label, const Fl_Image *openedImage=nullptr, const Fl_Image *closedImage=nullptr, void *data=nullptr) | |
CTreeItem * | addItem (const char *label, const Fl_Image *openedImage=nullptr, const Fl_Image *closedImage=nullptr, void *data=nullptr) |
CTreeItem * | addPath (const std::vector< String > &path, const Fl_Image *openedImage, const Fl_Image *closedImage, const Fl_Image *itemImage=0L, void *data=0L) |
CTreeItem * | addPath (const std::vector< String > &path, const Fl_Image *itemImage=0L, void *data=0L) |
CLayoutClient * | body () |
The widget that represents the item without children. | |
void | label (const String &lbl) override |
Sets the item's caption. More... | |
const String & | label () const override |
Returns the item's caption. More... | |
void | clear () override |
Removes all the child items of the item. More... | |
CTreeItem * | findItem (const char *label) const |
Finds an item among the child items. More... | |
CTreeItem * | findData (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... | |
CTreeItem * | parentItem () const |
Returns the parent item. More... | |
CTreeControl * | tree () 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. | |
CTreeItem * | findFirst () const |
Selects the first visible item in the child tree. | |
CTreeItem * | findLast (bool recursive) const |
Selects the last visible item in the child tree. More... | |
CTreeItem * | findNext (bool recursive) const |
Selects the next visible item in the child tree. More... | |
CTreeItem * | findPrior (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 String & | label () 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 String & | label () 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 CFrame * | frame () 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 String & | label () const |
void | name (const char *aname) |
void | name (const String &aname) |
const String & | name () 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 CLayoutClient * | creator (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 | |
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 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 |
CFrame * | m_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 |
Tree widget item.
A group widget with the extra information about item pixmaps and current state.
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.
label | The item label |
openedImage | The image for the opened state |
closedImage | The image for the closed state |
data | The user data or ID attached to the item |
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.
label | The item label |
openedImage | The image for the opened state |
closedImage | The image for the closed state |
data | The user data or ID attached to the item |
Referenced by sptk::CTreeView::addItem().
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.
path | The path to the new child item relatively to the item |
itemImage | The image for the child item |
data | The user data or ID attached to the item |
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.
path | The path to the new child item relatively to the item |
openedImage | The image for the opened folder |
closedImage | The image for the closed folder |
itemImage | The image for the child item |
data | The user data or ID attached to the item |
Referenced by sptk::CTreeView::addPath().
|
protected |
Adds a child item to the item using the path. The required path items are created automatically. This method is used internally only.
pathFolders | The path to the new child item relatively to the item |
offset | The offset in pathFolders where the path starts |
openedImage | The image for the opened folder |
closedImage | The image for the closed folder |
itemImage | The image for the child item |
data | The user data or ID attached to the item |
|
inlineoverridevirtual |
Returns widget class name (internal SPTK RTTI).
Reimplemented from sptk::CGroup.
|
overridevirtual |
Removes all the child items of the item.
Reimplemented from sptk::CGroup.
Referenced by sptk::CTreeControl::clear().
CTreeItem * sptk::CTreeItem::findData | ( | const void * | data | ) | const |
Finds an item by the item user data in the whole tree.
data | User data to find |
CTreeItem * sptk::CTreeItem::findItem | ( | const char * | label | ) | const |
Finds an item among the child items.
CTreeItem * sptk::CTreeItem::findLast | ( | bool | recursive | ) | const |
Selects the last visible item in the child tree.
recursive | Should we search the child items |
CTreeItem * sptk::CTreeItem::findNext | ( | bool | recursive | ) | const |
Selects the next visible item in the child tree.
recursive | Should we search the child items |
CTreeItem * sptk::CTreeItem::findPrior | ( | bool | recursive | ) | const |
Selects the prior visible item in the child tree.
recursive | Should we search the child items |
|
static |
Default image of the document
|
static |
Default image of the closed floder
|
static |
Default image of the opened floder
|
static |
Default image of the closed tree
|
static |
Default image of the opened tree
|
override |
The event handle function. Internal. See Fl_Widget for details.
event | Event type. |
|
inlineoverridevirtual |
Returns the item's caption.
Reimplemented from sptk::CGroup.
|
overridevirtual |
Moves the immediate child before another immediate child.
If beforeItem is 0L then moves to the end of the children
item | The item to move |
beforeItem | The item to insert before |
void sptk::CTreeItem::moveItem | ( | CTreeItem * | item, |
int | direction | ||
) |
Moves the immediate child up or down in the list of items.
item | The item to move |
direction | The direction to move. -1 to move up, 1 to move down |
CTreeItem * sptk::CTreeItem::parentItem | ( | ) | const |
Returns the parent item.
|
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.
w | Input/output desirable widget width |
h | Iinput/output desirable widget heigth |
Reimplemented from sptk::CGroup.
void sptk::CTreeItem::removeItem | ( | CTreeItem * | item | ) |
Removes an item from the child items.
Only the intermediate children are considered
item | Item to remove |
|
virtual |
Selects or unselects item.
flag | True is item shoud be selected |
|
static |
Default image of the document
|
static |
Default image of the closed floder
|
static |
Default image of the opened floder
|
inline |
Sets image(s) for the item.
openedImage | The image for the opened state |
closedImage | The image for the closed state |
|
static |
Default image of the closed tree
|
static |
Default image of the opened tree
void sptk::CTreeItem::visibleChildren | ( | bool | vc | ) |
Shows or hides all the child items. Changes the item state accordingly.
vc | bool, show(true) or hide(false) children |
|
staticprotected |
Default image of the document
|
staticprotected |
Default image of the closed floder
|
staticprotected |
Default image of the opened floder
|
staticprotected |
Default image of the closed tree
|
staticprotected |
Default image of the opened tree