diff options
Diffstat (limited to 'plugingui/listboxbasic.h')
-rw-r--r-- | plugingui/listboxbasic.h | 86 |
1 files changed, 39 insertions, 47 deletions
diff --git a/plugingui/listboxbasic.h b/plugingui/listboxbasic.h index deb4a67..3a190da 100644 --- a/plugingui/listboxbasic.h +++ b/plugingui/listboxbasic.h @@ -24,8 +24,7 @@ * along with DrumGizmo; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#ifndef __DRUMGIZMO_LISTBOXBASIC_H__ -#define __DRUMGIZMO_LISTBOXBASIC_H__ +#pragma once #include <string.h> #include <vector> @@ -33,69 +32,62 @@ #include "widget.h" #include "font.h" #include "painter.h" - #include "scrollbar.h" +#include "notifier.h" namespace GUI { class ListBoxBasic : public Widget { public: - class Item { - public: - std::string name; - std::string value; - }; - - ListBoxBasic(Widget *parent); - ~ListBoxBasic(); - - bool isFocusable() { return true; } + class Item { + public: + std::string name; + std::string value; + }; - void addItem(std::string name, std::string value); - void addItems(std::vector<Item> &items); + ListBoxBasic(Widget *parent); + ~ListBoxBasic(); - void clear(); - bool selectItem(int index); - std::string selectedName(); - std::string selectedValue(); + void addItem(const std::string& name, const std::string& value); + void addItems(const std::vector<Item>& items); - void clearSelectedValue(); + void clear(); + bool selectItem(int index); + std::string selectedName(); + std::string selectedValue(); - void registerSelectHandler(void (*handler)(void *), void *ptr); - void registerClickHandler(void (*handler)(void *), void *ptr); - void registerValueChangeHandler(void (*handler)(void *), void *ptr); + void clearSelectedValue(); - virtual void repaintEvent(RepaintEvent *e); - virtual void buttonEvent(ButtonEvent *e); - virtual void scrollEvent(ScrollEvent *e); - virtual void keyEvent(KeyEvent *e); - virtual void resize(int w, int h); + Notifier<> selectionNotifier; + Notifier<> clickNotifier; + Notifier<> valueChangedNotifier; -private: - ScrollBar scroll; + // From Widget: + virtual void resize(int w, int h) override; - Image bg_img; +protected: + void onScrollBarValueChange(int value); - void setSelection(int index); + // From Widget: + bool isFocusable() override { return true; } + virtual void repaintEvent(RepaintEvent* repaintEvent) override; + virtual void buttonEvent(ButtonEvent* buttonEvent) override; + virtual void keyEvent(KeyEvent* keyEvent) override; + virtual void scrollEvent(ScrollEvent* scrollEvent) override; - std::vector<Item> items; + ScrollBar scroll; - int selected; - int marked; - GUI::Font font; - int padding; - int btn_size; + Image bg_img; - void (*sel_handler)(void *); - void *sel_ptr; + void setSelection(int index); - void (*clk_handler)(void *); - void *clk_ptr; - - void (*valch_handler)(void *); - void *valch_ptr; -}; + std::vector<Item> items; + int selected; + int marked; + Font font; + int padding; + int btn_size; }; -#endif/*__DRUMGIZMO_LISTBOXBASIC_H__*/ +} // GUI:: |