]> git.tdb.fi Git - libs/gltk.git/blob - source/dropdown.h
Add Container class
[libs/gltk.git] / source / dropdown.h
1 /* $Id$
2
3 This file is part of libmspgltk
4 Copyright © 2007-2009  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GLTK_DROPDOWN_H_
9 #define MSP_GLTK_DROPDOWN_H_
10
11 #include <sigc++/signal.h>
12 #include "list.h"
13 #include "widget.h"
14
15 namespace Msp {
16 namespace GLtk {
17
18 class List;
19
20 class Dropdown: virtual public Widget, private Container
21 {
22 public:
23         class Loader: public Widget::Loader
24         {
25         public:
26                 Loader(Dropdown &);
27         private:
28                 void item(const std::string &);
29         };
30
31 private:
32         List list;
33         bool dropped;
34
35 public:
36         sigc::signal<void, int, const std::string &> signal_item_selected;
37
38         Dropdown(const Resources &);
39
40         void append(const std::string &);
41         void insert(unsigned, const std::string &);
42         void remove(unsigned);
43         void clear();
44         unsigned get_n_items() const;
45
46         void set_selected_index(int);
47         const std::string &get_selected() const;
48         int get_selected_index() const;
49
50         virtual void button_press(int, int, unsigned);
51
52 private:
53         virtual const char *get_class() const { return "dropdown"; }
54         virtual void render_special(const Part &) const;
55
56         virtual void on_geometry_change();
57         void resize_list();
58
59         void list_item_selected(unsigned, const std::string &);
60 };
61
62 } // namespace GLtk
63 } // namespace Msp
64
65 #endif