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 float ItemHeightAuto; // All items have individual height returned by getRequiredSize() 
    static const float ItemHeightText; // All items have same height equal to line height of text "Wy" 

    enum class State // Possible states 
    {
        Normal,
        Hovered,
        Focused,
        FocusedHovered,
        Disabled
    };

    enum class FolderState // Folder states 
    {
        Normal,
        Hovered
    };

    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 current state 
    // Return layout properties 
    RectF getBorderWidth() const;
    RectF getBorderRadius() const;
    RectF getPadding() const;
    BorderColor 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 FolderState state) const;
    RectF getFolderBorderRadius(const FolderState state) const;
    BorderColor getFolderBorderColor(const FolderState state) const;
    Color getFolderBackgroundColor(const FolderState state) const;
    Gradient *getFolderBackgroundGradient(const FolderState state);
    PointF getFolderSignSize(const FolderState state) const;
    Color getFolderSignColor(const FolderState 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 
    ScrollVisibility getHScrollVisibility() const;
    ScrollVisibility 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 BorderColor &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 FolderState state, const RectF &value);
    bool setFolderBorderRadius(const FolderState state, const RectF &value);
    bool setFolderBorderColor(const FolderState state, const BorderColor &value);
    bool setFolderBackgroundColor(const FolderState state, const Color &value);
    bool setFolderSignSize(const FolderState state, const PointF &value);
    bool setFolderSignColor(const FolderState 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 ScrollVisibility value);
    bool setVScrollVisibility(const ScrollVisibility value);
    bool setScrollInterval(const float value);
    bool setScrollDelta(const float value);
    bool setFolded(IListItem *item, const bool value); // Fold/unfold item 
    bool setBorderColor(const BorderColor &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