summaryrefslogtreecommitdiff
path: root/plugingui/listboxbasic.h
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2015-10-03 14:34:20 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2015-10-03 14:34:20 +0200
commit21bb5bd2bd4243dc83a08d6e0329b5de2f96b1fe (patch)
treebeef1c65f08a9677611b20fbb86deff5f1820bd9 /plugingui/listboxbasic.h
parent3be8598f672eb5b8e48373ed4ee59feff543ada2 (diff)
Refactor ComboBox and ListBox(Thin and Basic).
Diffstat (limited to 'plugingui/listboxbasic.h')
-rw-r--r--plugingui/listboxbasic.h84
1 files changed, 36 insertions, 48 deletions
diff --git a/plugingui/listboxbasic.h b/plugingui/listboxbasic.h
index deb4a67..ef6aceb 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,58 @@
#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();
+ class Item {
+ public:
+ std::string name;
+ std::string value;
+ };
- bool isFocusable() { return true; }
+ ListBoxBasic(Widget *parent);
+ ~ListBoxBasic();
- void addItem(std::string name, std::string value);
- void addItems(std::vector<Item> &items);
+ void addItem(std::string name, std::string value);
+ void addItems(std::vector<Item> &items);
- void clear();
- bool selectItem(int index);
- std::string selectedName();
- std::string selectedValue();
+ void clear();
+ bool selectItem(int index);
+ std::string selectedName();
+ std::string selectedValue();
- void clearSelectedValue();
+ void clearSelectedValue();
- void registerSelectHandler(void (*handler)(void *), void *ptr);
- void registerClickHandler(void (*handler)(void *), void *ptr);
- void registerValueChangeHandler(void (*handler)(void *), void *ptr);
+ // From Widget:
+ bool isFocusable() override { return true; }
+ virtual void repaintEvent(RepaintEvent *e) override;
+ virtual void buttonEvent(ButtonEvent *e) override;
+ virtual void scrollEvent(ScrollEvent *e) override;
+ virtual void keyEvent(KeyEvent *e) override;
+ virtual void resize(int w, int h) override;
- 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;
-
- Image bg_img;
-
- void setSelection(int index);
+ ScrollBar scroll;
- std::vector<Item> items;
+ Image bg_img;
- int selected;
- int marked;
- GUI::Font font;
- int padding;
- int btn_size;
+ void setSelection(int index);
- void (*sel_handler)(void *);
- void *sel_ptr;
-
- 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::