CCustomTreeView



Implements tree view with supporting of any type items. Use a base class when developing a treeview-like controls.

You can find more information in comments below. Overrided methods can be found in corresponding base classes and interfaces.

class CCustomTreeView :public virtual IComponentItemTree, public CControl
{
public:
    static const int ItemHeightAuto; // All items have individual height returned by getRequiredSize() 
    static const int ItemHeightText; // All items have same height equal to line height of text "Wy" 

    enum STATE // Possible states 
    {
        stNormal,
        stHovered,
        stFocused,
        stFocusedHovered,
        stDisabled
    };

    enum FOLDER_STATE // Folder states 
    {
        fsNormal,
        fsHovered
    };

    using FItemCallback = void(*)(void *param, IListItem *item); // Function prototype called when enumeration items 
public:
    void(*OnSelectItem)(IControl *sender, IListItem *item); // Event called when item has been selected 
    void(*OnDeselectItem)(IControl *sender, IListItem *item); // Event called when item has been unselected 
    void(*OnMovingSelection)(IControl *sender, IListItem *dest); // Event called when moving selected items by move drag and drop 
    void(*OnMoveSelection)(IControl *sender, IListItem *dest); // Event called when drop appears in moving items. Dest can be empy if mouse button released out of any item 
    void(*OnActivateItem)(IControl *sender, IListItem *item); // Event called when item has been activated 
    void(*OnDeactivateItem)(IControl *sender, IListItem *item); // Event called when item has been deactivated 

    // IControl methods 
    void Refresh(const bool refresh_children) override;

    IListItem *getRootItem() override;

    RectF getClientRect() override;
    RectF getRenderRect() override;

    bool setDPI(const Point &value) override;

    IListItemOwner *QueryListItemOwner() override;

    CCustomTreeView(const String &class_name);
    ~CCustomTreeView() override;

    IListItem *getActiveItem(); // Return activate item 
    STATE getState(); // Return curren state 
    // Return layout properties
    RectF getBorderWidth() const;
    RectF getBorderRadius() const;
    RectF getPadding() const;
    RectC getBorderColor(const STATE state) const;
    Color getBackgroundColor(const STATE state) const;
    Gradient *getBackgroundGradient(const STATE state);
    Color getShadowColor(const STATE state) const;
    PointF getShadowShift(const STATE state) const;
    int getShadowRadius(const STATE state) const;
    Color getCornerColor(const STATE state) const;
    float getItemHeight() const;
    PointF getFolderSize() const;
    Color getFolderLinesColor() const;
    RectF getFolderBorderWidth(const FOLDER_STATE state) const;
    RectF getFolderBorderRadius(const FOLDER_STATE state) const;
    RectC getFolderBorderColor(const FOLDER_STATE state) const;
    Color getFolderBackgroundColor(const FOLDER_STATE state) const;
    Gradient *getFolderBackgroundGradient(const FOLDER_STATE state);
    PointF getFolderSignSize(const FOLDER_STATE state) const;
    Color getFolderSignColor(const FOLDER_STATE state) const;
    bool isMultiselect() const; // Whether multiple items can be selected at the same time 
    bool isMovable() const; // Whether selection could be moved by drag and drop 
    SCROLL_VISIBILITY getHScrollVisibility() const;
    SCROLL_VISIBILITY getVScrollVisibility() const;
    float getScrollInterval() const;
    float getScrollDelta() const;
    bool isFolded(IListItem *item); // Whether specified item is folded(subitems are hidden) 

    // Set layout properties 
    bool setBorderWidth(const RectF &value);
    bool setBorderRadius(const RectF &value);
    bool setPadding(const RectF &value);
    bool setBorderColor(const STATE state, const RectC &value);
    bool setLeftBorderColor(const STATE state, const Color &value);
    bool setTopBorderColor(const STATE state, const Color &value);
    bool setRightBorderColor(const STATE state, const Color &value);
    bool setBottomBorderColor(const STATE state, const Color &value);
    bool setBackgroundColor(const STATE state, const Color &value);
    bool setShadowColor(const STATE state, const Color &value);
    bool setShadowShift(const STATE state, const PointF &value);
    bool setShadowRadius(const STATE state, const int value);
    bool setCornerColor(const STATE state, const Color &value);
    bool setItemHeight(const float value);
    bool setFolderSize(const PointF &value);
    bool setFolderLinesColor(const Color &value);
    bool setFolderBorderWidth(const FOLDER_STATE state, const RectF &value);
    bool setFolderBorderRadius(const FOLDER_STATE state, const RectF &value);
    bool setFolderBorderColor(const FOLDER_STATE state, const RectC &value);
    bool setFolderBackgroundColor(const FOLDER_STATE state, const Color &value);
    bool setFolderSignSize(const FOLDER_STATE state, const PointF &value);
    bool setFolderSignColor(const FOLDER_STATE state, const Color &value);
    bool setMultiselect(const bool value); // Set whether multiple items could be selected at the same time 
    bool setMovable(const bool value); // Set whether moving of selected items by drag and drop is allowed 
    bool setHScrollVisibility(const SCROLL_VISIBILITY value);
    bool setVScrollVisibility(const SCROLL_VISIBILITY value);
    bool setScrollInterval(const float value);
    bool setScrollDelta(const float value);
    bool setFolded(IListItem *item, const bool value); // Fold/unfold item 
    bool setBorderColor(const RectC &value);
    bool setLeftBorderColor(const Color &value);
    bool setTopBorderColor(const Color &value);
    bool setRightBorderColor(const Color &value);
    bool setBottomBorderColor(const Color &value);
    bool setBackgroundColor(const Color &value);
    bool setShadowColor(const Color &value);
    bool setShadowShift(const PointF &value);
    bool setShadowRadius(const int value);
    bool setCornerColor(const Color &value);

    void LockUpdate(); // Lock update and repaint 
    void UnlockUpdate(); // Unlock update and repaint 
    void EnumSelectedItems(void *param, FItemCallback callback); // Enumerate selected items 
    bool ScrollToActiveItem(); // Scroll to active item 
    bool FoldAll(); // Fold all 
    bool UnfoldAll(); // Unfold all 
    bool Fold(IListItem *item); // Fold item 
    bool Unfold(IListItem *item); // Unfold item 
};
Namespace: nitisa::standard
Include: Standard/Controls/TreeView/CustomTreeView.h