]> git.tdb.fi Git - libs/gltk.git/blob - source/dropdown.h
7a0f04d3f1feb2afed2a5a313bd3c149b1ed4d06
[libs/gltk.git] / source / dropdown.h
1 #ifndef MSP_GLTK_DROPDOWN_H_
2 #define MSP_GLTK_DROPDOWN_H_
3
4 #include <sigc++/signal.h>
5 #include "list.h"
6 #include "widget.h"
7
8 namespace Msp {
9 namespace GLtk {
10
11 class List;
12
13 class Dropdown: virtual public Widget, private Container
14 {
15 public:
16         class Loader: public DataFile::DerivedObjectLoader<Dropdown, Widget::Loader>
17         {
18         public:
19                 Loader(Dropdown &);
20         private:
21                 void item(const std::string &);
22         };
23
24         sigc::signal<void, unsigned> signal_item_selected;
25
26 private:
27         List list;
28         bool dropped;
29
30 public:
31         Dropdown();
32         Dropdown(ListData &);
33 private:
34         void init();
35
36 public:
37         virtual const char *get_class() const { return "dropdown"; }
38
39         virtual void autosize();
40
41         void set_data(ListData &d) { list.set_data(d); }
42         ListData &get_data() { return list.get_data(); }
43         const ListData &get_data() const { return list.get_data(); }
44
45         void set_selected_index(int i) { list.set_selected_index(i); }
46         int get_selected_index() const { return list.get_selected_index(); }
47
48 private:
49         virtual void rebuild_special(const Part &, CachedPart &);
50         virtual void render_special(const Part &, GL::Renderer &) const;
51
52 public:
53         virtual void button_press(int, int, unsigned);
54 private:
55         virtual void on_geometry_change();
56         virtual void on_style_change();
57
58         void list_autosize_changed();
59         void resize_list();
60         void list_item_selected(unsigned);
61 };
62
63 } // namespace GLtk
64 } // namespace Msp
65
66 #endif