summaryrefslogtreecommitdiff
path: root/plugingui/listboxthin.cc
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/listboxthin.cc
parent3be8598f672eb5b8e48373ed4ee59feff543ada2 (diff)
Refactor ComboBox and ListBox(Thin and Basic).
Diffstat (limited to 'plugingui/listboxthin.cc')
-rw-r--r--plugingui/listboxthin.cc112
1 files changed, 57 insertions, 55 deletions
diff --git a/plugingui/listboxthin.cc b/plugingui/listboxthin.cc
index 3f0fbc6..18cfc76 100644
--- a/plugingui/listboxthin.cc
+++ b/plugingui/listboxthin.cc
@@ -29,90 +29,92 @@
#include "painter.h"
#include "font.h"
-#include <stdio.h>
-
-GUI::ListBoxThin::ListBoxThin(GUI::Widget *parent)
- : GUI::Widget(parent)
+namespace GUI {
+
+ListBoxThin::ListBoxThin(Widget *parent)
+ : Widget(parent)
+ , selectionNotifier(basic.selectionNotifier)
+ , clickNotifier(basic.clickNotifier)
+ , valueChangedNotifier(basic.valueChangedNotifier)
+ , basic(this)
{
- box.topLeft = new Image(":thinlistbox_tl.png");
- box.top = new Image(":thinlistbox_t.png");
- box.topRight = new Image(":thinlistbox_tr.png");
- box.left = new Image(":thinlistbox_l.png");
- box.right = new Image(":thinlistbox_r.png");
- box.bottomLeft = new Image(":thinlistbox_bl.png");
- box.bottom = new Image(":thinlistbox_b.png");
- box.bottomRight = new Image(":thinlistbox_br.png");
- box.center = new Image(":thinlistbox_c.png");
-
- basic = new GUI::ListBoxBasic(this);
- basic->move(box.left->width(), box.top->height());
+ box.topLeft = new Image(":thinlistbox_tl.png");
+ box.top = new Image(":thinlistbox_t.png");
+ box.topRight = new Image(":thinlistbox_tr.png");
+ box.left = new Image(":thinlistbox_l.png");
+ box.right = new Image(":thinlistbox_r.png");
+ box.bottomLeft = new Image(":thinlistbox_bl.png");
+ box.bottom = new Image(":thinlistbox_b.png");
+ box.bottomRight = new Image(":thinlistbox_br.png");
+ box.center = new Image(":thinlistbox_c.png");
+
+ basic.move(box.left->width(), box.top->height());
}
-GUI::ListBoxThin::~ListBoxThin()
+ListBoxThin::~ListBoxThin()
{
+ delete box.topLeft;
+ delete box.top;
+ delete box.topRight;
+ delete box.left;
+ delete box.right;
+ delete box.bottomLeft;
+ delete box.bottom;
+ delete box.bottomRight;
+ delete box.center;
}
-void GUI::ListBoxThin::addItem(std::string name, std::string value)
+void ListBoxThin::addItem(std::string name, std::string value)
{
- basic->addItem(name, value);
+ basic.addItem(name, value);
}
-void GUI::ListBoxThin::addItems(std::vector<ListBoxBasic::Item> &items)
+void ListBoxThin::addItems(std::vector<ListBoxBasic::Item> &items)
{
- basic->addItems(items);
+ basic.addItems(items);
}
-void GUI::ListBoxThin::clear()
+void ListBoxThin::clear()
{
- basic->clear();
+ basic.clear();
}
-bool GUI::ListBoxThin::selectItem(int index)
+bool ListBoxThin::selectItem(int index)
{
- return basic->selectItem(index);
+ return basic.selectItem(index);
}
-std::string GUI::ListBoxThin::selectedName()
+std::string ListBoxThin::selectedName()
{
- return basic->selectedName();
+ return basic.selectedName();
}
-std::string GUI::ListBoxThin::selectedValue()
+std::string ListBoxThin::selectedValue()
{
- return basic->selectedValue();
+ return basic.selectedValue();
}
-void GUI::ListBoxThin::registerClickHandler(void (*handler)(void *), void *ptr)
+void ListBoxThin::repaintEvent(RepaintEvent *e)
{
- basic->registerClickHandler(handler, ptr);
-}
+ Painter p(this);
-void GUI::ListBoxThin::registerSelectHandler(void (*handler)(void *), void *ptr)
-{
- basic->registerSelectHandler(handler, ptr);
-}
+ p.clear();
-void GUI::ListBoxThin::registerValueChangeHandler(void (*handler)(void *),
- void *ptr)
-{
- basic->registerValueChangeHandler(handler, ptr);
-}
+ int w = width();
+ int h = height();
+ if(w == 0 || h == 0)
+ {
+ return;
+ }
-void GUI::ListBoxThin::repaintEvent(GUI::RepaintEvent *e)
-{
- GUI::Painter p(this);
-
- p.clear();
-
- int w = width();
- int h = height();
- if(w == 0 || h == 0) return;
- p.drawBox(0, 0, &box, w, h);
+ p.drawBox(0, 0, &box, w, h);
}
-void GUI::ListBoxThin::resize(int width, int height)
+void ListBoxThin::resize(int width, int height)
{
- GUI::Widget::resize(width, height);
- basic->resize(width - (box.left->width() + box.right->width()),
- height - (box.top->height() + box.bottom->height()));
+ Widget::resize(width, height);
+ basic.resize(width - (box.left->width() + box.right->width()),
+ height - (box.top->height() + box.bottom->height()));
}
+
+} // GUI::