Tree widget. More...
#include <CTreeControl.h>
Public Member Functions | |
CTreeControl (const char *label, int layoutSize=50, CLayoutAlign align=CLayoutAlign::TOP) | |
The constructor. More... | |
CTreeItem * | 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. More... | |
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 root item using the path. More... | |
CTreeItem * | addPath (const std::vector< String > &path, const Fl_Image *itemImage=0L, void *data=0L) |
CTreeItem * | findItem (const char *item) const |
Finds an item by the item label in the whole tree. More... | |
CTreeItem * | findData (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... | |
CTreeItem * | root () const |
Reports the root item. | |
CTreeItem * | selected () 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 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 void | moveItem (CTreeItem *item, CTreeItem *beforeItem=nullptr) |
Moves the item in the tree. More... | |
Static Public Member Functions inherited from sptk::CScroll | |
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. | |
Static Protected Member Functions | |
static CLayoutClient * | defaultItemCreator (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 |
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 |
Static Protected Attributes inherited from sptk::CLayoutManager | |
static std::map< std::string, Fl_Boxtype > | m_boxTypeNames |
static createControlCallbackMap | controlCreator |
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.
sptk::CTreeControl::CTreeControl | ( | const char * | label, |
int | layoutSize = 50 , |
||
CLayoutAlign | align = CLayoutAlign::TOP |
||
) |
The constructor.
label | Widget's label |
layoutSize | Size of widget in layout. See CLayoutClient for details |
align | Widget align in the layout |
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.
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::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.
path | The path to the new child item |
itemImage | The image for the child item |
data | The user data or ID attached to the item |
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.
path | The path to the new child item |
openedImage | The image for the folders in opened state |
closedImage | The image for the folders in closed state |
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::CScroll.
|
inlineoverridevirtual |
Removes all the items in the tree.
Reimplemented from sptk::CScroll.
References sptk::CTreeItem::clear().
|
staticprotected |
CTreeItem * sptk::CTreeControl::findData | ( | const void * | data | ) | const |
Finds an item by the item user data in the whole tree.
data | User data to find |
CTreeItem * sptk::CTreeControl::findItem | ( | const char * | item | ) | const |
Finds an item by the item label in the whole tree.
item | Item label to find |
|
override |
|
inline |
The tree item creator creates a tree item' body,.
|
overridevirtual |
Loads group controls data from XML node.
node | Node to load data from |
autoCreate | Ignored |
Reimplemented from sptk::CLayoutClient.
void sptk::CTreeControl::makeVisible | ( | CTreeItem * | item | ) |
Makes the item visible if it's outside the visible area.
item | Item to make visible |
|
static |
Moves the item in the tree.
item | Item to insert |
beforeItem | Item before the insert point. If 0L - it's moved to the very last position in parent item list of items. |
void sptk::CTreeControl::removeItem | ( | CTreeItem * | item | ) |
Removes all the item and underlying structure from the tree.
item | Item to remove |
|
override |
Saves group controls data into XML node.
node | Node to save data into |
void sptk::CTreeControl::selectOnly | ( | CTreeItem * | item, |
bool | giveFocus = false |
||
) |
Selects only one item.
item | Item to select |
giveFocus | Should the item be focused? |