29#include <FL/Fl_Pixmap.H>
30#include <FL/Fl_Widget.H>
31#include <sptk5/gui/CGroup.h>
32#include <sptk5/gui/CLayoutClient.h>
33#include <sptk5/gui/CScroll.h>
80 bool m_selected {
false};
85 Fl_Color m_itemColor[2] {};
95 const Fl_Image* m_openedImage {
nullptr};
100 const Fl_Image* m_closedImage {
nullptr};
105 bool m_opened {
false};
124 const Fl_Image* closedImage,
const Fl_Image* itemImage = 0L,
void* data = 0L);
158 CTreeItem(
const char* label,
const Fl_Image* openedImage =
nullptr,
const Fl_Image* closedImage =
nullptr,
159 void* data =
nullptr);
168 CTreeItem*
addItem(
const char* label,
const Fl_Image* openedImage =
nullptr,
const Fl_Image* closedImage =
nullptr,
169 void* data =
nullptr);
179 CTreeItem*
addPath(
const std::vector<String>& path,
const Fl_Image* openedImage,
const Fl_Image* closedImage,
180 const Fl_Image* itemImage = 0L,
void* data = 0L);
189 CTreeItem*
addPath(
const std::vector<String>& path,
const Fl_Image* itemImage = 0L,
void* data = 0L);
210 return m_body->label();
280 visibleChildren(
true);
288 visibleChildren(
false);
312 void setImage(
const Fl_Image* openedImage,
const Fl_Image* closedImage =
nullptr)
314 m_openedImage = openedImage;
315 m_closedImage = closedImage;
341 void resize(
int xx,
int yy,
int ww,
int hh)
override;
511 CTreeItem*
addItem(
const char* label,
const Fl_Image* openedImage =
nullptr,
const Fl_Image* closedImage =
nullptr,
512 void* data =
nullptr);
526 CTreeItem*
addPath(
const std::vector<String>& path,
const Fl_Image* openedImage,
const Fl_Image* closedImage,
527 const Fl_Image* itemImage = 0L,
void* data = 0L);
536 CTreeItem*
addPath(
const std::vector<String>& path,
const Fl_Image* itemImage = 0L,
void* data = 0L);
557 m_selectedItems.clear();
587 if (m_selectedItems.empty())
592 return m_selectedItems[0];
SPTK group widget.
Definition: CGroup.h:50
Definition: CLayoutClient.h:82
Tree widget.
Definition: CTreeControl.h:463
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 i...
CTreeItem * findItem(const char *item) const
Finds an item by the item label in the whole tree.
void load(const xdoc::SNode &node, CLayoutXMLmode xmlMode) override
Loads group controls data from XML node.
CTreeControl(const char *label, int layoutSize=50, CLayoutAlign align=CLayoutAlign::TOP)
The constructor.
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.
CTreeItem * root() const
Reports the root item.
Definition: CTreeControl.h:577
void clear() override
Removes all the items in the tree.
Definition: CTreeControl.h:555
void removeItem(CTreeItem *item)
Removes all the item and underlying structure from the tree.
int handle(int event) override
Special handle() function.
CTreeItem * findData(const void *data) const
Finds an item by the item user data in the whole tree.
void save(const xdoc::SNode &node, CLayoutXMLmode xmlMode) const override
Saves group controls data into XML node.
void selectOnly(CTreeItem *item, bool giveFocus=false)
Selects only one item.
void itemCreator(CTreeItemCreator ic)
The tree item creator creates a tree item' body,.
Definition: CTreeControl.h:618
CTreeItem * selected() const
Reports the currently selected item.
Definition: CTreeControl.h:585
static void moveItem(CTreeItem *item, CTreeItem *beforeItem=nullptr)
Moves the item in the tree.
void makeVisible(CTreeItem *item)
Makes the item visible if it's outside the visible area.
String className() const override
Returns widget class name (internal SPTK RTTI).
Definition: CTreeControl.h:641
CTreeItem * addPath(const std::vector< String > &path, const Fl_Image *itemImage=0L, void *data=0L)
static CLayoutClient * defaultItemCreator(CTreeItem *item)
The default tree item creator.
Tree widget item.
Definition: CTreeControl.h:66
void open()
Shows all the child items. Changes the item state accordingly.
Definition: CTreeControl.h:278
bool selected() const
Returns selection state of the item.
Definition: CTreeControl.h:352
static const Fl_Image * getTreeClosed()
void draw() override
The draw function. Internal. See Fl_Widget for details.
void label(const String &lbl) override
Sets the item's caption.
void close()
Hides all the child items. Changes the item state accordingly.
Definition: CTreeControl.h:286
virtual void select(bool flag)
Selects or unselects item.
const String & label() const override
Returns the item's caption.
Definition: CTreeControl.h:208
CTreeItem * findItem(const char *label) const
Finds an item among the child items.
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)
static const Fl_Image * treeClosed
Definition: CTreeControl.h:134
static const Fl_Image * folderOpened
Definition: CTreeControl.h:139
static void setDocument(const Fl_Image *image)
void moveItem(CTreeItem *item, CTreeItem *beforeItem=nullptr)
Moves the immediate child before another immediate child.
static const Fl_Image * document
Definition: CTreeControl.h:149
static const Fl_Image * getFolderClosed()
void setImage(const Fl_Image *openedImage, const Fl_Image *closedImage=nullptr)
Sets image(s) for the item.
Definition: CTreeControl.h:312
CLayoutClient * body()
The widget that represents the item without children.
Definition: CTreeControl.h:194
String className() const override
Returns widget class name (internal SPTK RTTI).
Definition: CTreeControl.h:393
CTreeItem * findFirst() const
Selects the first visible item in the child tree.
CTreeItem * addItem(const char *label, const Fl_Image *openedImage=nullptr, const Fl_Image *closedImage=nullptr, void *data=nullptr)
void removeItem(CTreeItem *item)
Removes an item from the child items.
CTreeItem * findData(const void *data) const
Finds an item by the item user data in the whole tree.
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,...
static const Fl_Image * getFolderOpened()
void moveItem(CTreeItem *item, int direction)
Moves the immediate child up or down in the list of items.
static const Fl_Image * treeOpened
Definition: CTreeControl.h:129
static const Fl_Image * getDocument()
CTreeItem * parentItem() const
Returns the parent item.
int handle(int event) override
The event handle function. Internal. See Fl_Widget for details.
CTreeItem * findPrior(bool recursive) const
Selects the prior visible item in the child tree.
void clear() override
Removes all the child items of the item.
CTreeItem * addPath(const std::vector< String > &path, const Fl_Image *itemImage=0L, void *data=0L)
void resize(int xx, int yy, int ww, int hh) override
Resizes item and sub items.
CTreeControl * tree() const
Returns the tree control this item belongs to.
Definition: CTreeControl.h:248
void visibleChildren(bool vc)
Shows or hides all the child items. Changes the item state accordingly.
CTreeItem * findNext(bool recursive) const
Selects the next visible item in the child tree.
bool selectNext()
Selects the next item in the tree.
static void setFolderClosed(const Fl_Image *image)
static const Fl_Image * folderClosed
Definition: CTreeControl.h:144
static void setFolderOpened(const Fl_Image *image)
CTreeItem * findLast(bool recursive) const
Selects the last visible item in the child tree.
bool opened() const
Reports the item state - opened or closed.
Definition: CTreeControl.h:294
static void setTreeClosed(const Fl_Image *image)
bool selectPrior()
Selects the prior item in the tree.
uint32_t indent() const
Reports the item indent from the left.
Definition: CTreeControl.h:302
CTreeItem * addPath(const std::vector< String > &path, const Fl_Image *openedImage, const Fl_Image *closedImage, const Fl_Image *itemImage=0L, void *data=0L)
static const Fl_Image * getTreeOpened()
static void setTreeOpened(const Fl_Image *image)
CTreeItem(const char *label, const Fl_Image *openedImage=nullptr, const Fl_Image *closedImage=nullptr, void *data=nullptr)
std::vector< CTreeItem * > CTreeItemVector
Vector of CTreeItem pointers.
Definition: CTreeControl.h:452
CLayoutAlign
Definition: CLayoutClient.h:44
CLayoutXMLmode
Definition: CLayoutClient.h:57
CLayoutClient *(*)(CTreeItem *item) CTreeItemCreator
A callback that allows to create a widget of required type and use it as an item body.
Definition: CTreeControl.h:56