]> git.tdb.fi Git - libs/gltk.git/blob - source/dropdown.h
Strip copyright messages and id tags from individual files
[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 render_special(const Part &) const;
49
50 public:
51         virtual void button_press(int, int, unsigned);
52 private:
53         virtual void on_geometry_change();
54         virtual void on_style_change();
55
56         void list_autosize_changed();
57         void resize_list();
58         void list_item_selected(unsigned, const std::string &);
59 };
60
61 } // namespace GLtk
62 } // namespace Msp
63
64 #endif