]> git.tdb.fi Git - libs/gltk.git/blob - source/dropdown.h
Cache widget parts in meshes
[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 Widget::Loader
17         {
18         public:
19                 Loader(Dropdown &);
20         private:
21                 void item(const std::string &);
22         };
23
24         sigc::signal<void, int, const std::string &> signal_item_selected;
25
26 private:
27         List list;
28         bool dropped;
29
30 public:
31         Dropdown();
32
33         virtual const char *get_class() const { return "dropdown"; }
34
35         virtual void autosize();
36
37         void append(const std::string &);
38         void insert(unsigned, const std::string &);
39         void remove(unsigned);
40         void clear();
41         unsigned get_n_items() const;
42
43         void set_selected_index(int);
44         const std::string &get_selected() const;
45         int get_selected_index() const;
46
47 private:
48         virtual void rebuild_special(const Part &, CachedPart &);
49         virtual void render_special(const Part &) const;
50
51 public:
52         virtual void button_press(int, int, unsigned);
53 private:
54         virtual void on_geometry_change();
55         virtual void on_style_change();
56
57         void list_autosize_changed();
58         void resize_list();
59         void list_item_selected(unsigned, const std::string &);
60 };
61
62 } // namespace GLtk
63 } // namespace Msp
64
65 #endif