CCustomListBox


Implements list box with supporting of any type items. Use a base class when developing a listbox-like controls.

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

class CCustomListBox :public CControlItemList
{
public:
    enum STATE // Possible states 
    {
        stNormal,
        stHovered,
        stFocused,
        stFocusedHovered,
        stDisabled
    };

    using FCompare = bool(*)(IListItem *a, IListItem *b); // Items comparing(for sorting) function prototype 
protected:
    void SortItems() override;
    virtual FCompare getCompareItems(); // Return items comparison function. Null by default 
    virtual int Search(const String &search); // Return index of first item started by "search" substring. Default -1. Search should be done with applying translation to item captions(not to "search") if translateable items(like color names) are used. Also dont forget to convert to lower case("search" is already converted) 
public:
    void(*OnActivate)(IControl *sender, const int index); // Event called when item has been activated(index is -1 if there is no new active item) 
    void(*OnSelect)(IControl *sender, IListItem *item); // Event called when item has been selected 
    void(*OnDeselect)(IControl *sender, IListItem *item); // Event called when item has been deselected 

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

    bool InsertItem(IListItem *item, const int before) override;
    bool DeleteItem(const int index) override;
    bool DeleteItem(IListItem *item) override;
    bool DeleteItems() override;

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

    bool setDPI(const Point &value) override;

    IListItemOwner *QueryListItemOwner() override;

    CCustomListBox(const String &class_name, const bool accept_form, const bool accept_control, const bool tab_stop);
    ~CCustomListBox() override;

    STATE getState(); // Return current state 
    bool isSortable() const; // Return whether items should be sorted 
    int getActiveIndex(); // Return active item index 
    float getSearchResetInterval() const; // Return search by typing reset interval(in seconds) 
    int getColumns() const; // Return column count 
    bool isMultiselect() const; // Whether multiple item could be selected at the same time 
    float getScrollInterval() const; // Scroll interval(in seconds) 
    // Return layout properties 
    RectF getBorderWidth() const;
    RectF getBorderRadius() const;
    RectF getPadding() const;
    SCROLL_VISIBILITY getHorizontalScrollBar() const;
    SCROLL_VISIBILITY getVerticalScrollBar() const;
    Color getShadowColor(const STATE state) const;
    PointF getShadowShift(const STATE state) const;
    int getShadowRadius(const STATE state) const;
    RectC getBorderColor(const STATE state) const;
    Color getLeftBorderColor(const STATE state) const;
    Color getTopBorderColor(const STATE state) const;
    Color getRightBorderColor(const STATE state) const;
    Color getBottomBorderColor(const STATE state) const;
    Color getBackgroundColor(const STATE state) const;
    Gradient *getBackgroundGradient(const STATE state);
    Color getCornerColor(const STATE state) const;

    bool setHScroll(IBuiltInScroll *value); // Assign new horizontal scroll 
    bool setVScroll(IBuiltInScroll *value); // Assign new vertical scroll 
    bool setSortable(const bool value); // Set whether items should be sorted 
    bool setActiveIndex(const int value); // Set active item 
    bool setSearchResetInterval(const float value); // Set search reset interval(in seconds) 
    bool setColumns(const int value); // Set column count 
    bool setMultiselect(const bool value); // Set whether several items could be selected at the same time 
    bool setScrollInterval(const float value); // Set scroll interval(in seconds) 
    // Set layout properties 
    bool setBorderWidth(const RectF &value);
    bool setBorderRadius(const RectF &value);
    bool setPadding(const RectF &value);
    bool setHorizontalScrollBar(const SCROLL_VISIBILITY value);
    bool setVerticalScrollBar(const SCROLL_VISIBILITY 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 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 setCornerColor(const STATE state, const Color &value);

    void LockUpdate(); // Lock update and repaint 
    void UnlockUpdate(); // Unlock update and repaint 
};
Namespace: nitisa::standard
Include: Standard/Controls/ListBox/CustomListBox.h