SavvyUI C++ UI Library
Loading...
Searching...
No Matches
ListBox.h
Go to the documentation of this file.
1#pragma once
2
3#include "Component.h"
4
6{
7public:
8 wstring _text;
9 COLORREF _color;
11};
12
20class ListBox : public Component
21{
22 std::vector<ListBoxItem> _selections;
23
24 long _maxVisibleRows;
25 __int64 _firstVisibleRow;
26 __int64 _lastVisibleRow;
27 __int64 _currentRow;
28
29 BOOL _isColorList;
30
31protected:
32
42 BOOL getCreateWindowOptions(wstring& title, UINT& widownStyles, wstring& wndClassName, BOOL& isCustomWndProc);
43
48
49public:
50
55
59 virtual ~ListBox();
60
62
63 void clear();
64
71 void addItem(const wstring& text, COLORREF color = Theme::BackgroundColor);
72
78 void setSelectedItem(const wstring& text);
79
85 wstring getSelectedItem();
86
87public: // Overridables
88
89 void onPaint(Graphics* g) override;
90 void onWindowResized() override;
91
92 void onArrowUp(BOOL shiftPressed, BOOL ctrlPressed) override;
93 void onArrowDown(BOOL shiftPressed, BOOL ctrlPressed) override;
94 void onPageUp(BOOL shiftPressed, BOOL ctrlPressed) override;
95 void onPageDown(BOOL shiftPressed, BOOL ctrlPressed) override;
96 void onKeyHome(BOOL shiftPressed, BOOL ctrlPressed) override;
97 void onKeyEnd(BOOL shiftPressed, BOOL ctrlPressed) override;
98
99 void onMousePressed(WinHandle hWnd, int x, int y, int clickCount, BOOL shiftPressed, BOOL ctrlPressed) override;
100 BOOL onMouseWheel(WinHandle hWnd, int x, int y, int delta) override;
101
102 void onFocusGained() override;;
103 void onFocusLost() override;;
104
105 BOOL getScrollingInfo(__int64& scrollMin, __int64& scrollMax, __int64& pageSize) override;
106 void setScrollbarTopOffset(__int64 firstVisibleRow) override;
107
108public:
109
112};
HWND WinHandle
Definition Common.h:16
Definition Common.h:20
Component()
Constructs a new Component instance.
Definition Graphics.h:161
void addItem(const wstring &text, COLORREF color=Theme::BackgroundColor)
Adds to the list of selectable options.
void onKeyHome(BOOL shiftPressed, BOOL ctrlPressed) override
void onFocusGained() override
Called when the component gains keyboard focus.
virtual ~ListBox()
Destructor.
ListBox()
Constructs an empty ListBox component.
void onPageDown(BOOL shiftPressed, BOOL ctrlPressed) override
void onFocusLost() override
Called when the component loses keyboard focus.
void windowCreated()
Called once the native window has been created.
void onMousePressed(WinHandle hWnd, int x, int y, int clickCount, BOOL shiftPressed, BOOL ctrlPressed) override
Called when the mouse is pressed within the component.
void clear()
void onArrowDown(BOOL shiftPressed, BOOL ctrlPressed) override
void onArrowUp(BOOL shiftPressed, BOOL ctrlPressed) override
void setScrollbarTopOffset(__int64 firstVisibleRow) override
Sets the scrollbar's top offset.
BOOL onMouseWheel(WinHandle hWnd, int x, int y, int delta) override
Called when the mouse wheel is used over the component.
void onPageUp(BOOL shiftPressed, BOOL ctrlPressed) override
void setSelectedItem(const wstring &text)
Sets the currently selected item by text.
void setColorsListType()
wstring getSelectedItem()
Retrieves the currently selected item text.
void onPaint(Graphics *g) override
Called to paint the component's client area.
void onKeyEnd(BOOL shiftPressed, BOOL ctrlPressed) override
void addItemDoubleClickedListener(RowDoubleClickListener *l)
BOOL getScrollingInfo(__int64 &scrollMin, __int64 &scrollMax, __int64 &pageSize) override
Provides scrolling information if supported.
BOOL getCreateWindowOptions(wstring &title, UINT &widownStyles, wstring &wndClassName, BOOL &isCustomWndProc)
Provides native window creation options for the ListBox control.
void addSelectionChangedListener(SelectionChangeListener *l)
void onWindowResized() override
Called when the component's window is resized.
Definition ListBox.h:6
wstring _text
Definition ListBox.h:8
COLORREF _color
Definition ListBox.h:9
Bounds _rect
Definition ListBox.h:10
Definition EventListeners.h:60
Definition EventListeners.h:31
static COLORREF BackgroundColor
Definition Theme.h:103