]> git.tdb.fi Git - libs/gltk.git/blob - source/dropdown.h
Implement autosize() method for most widgets
[libs/gltk.git] / source / dropdown.h
1 /* $Id$
2
3 This file is part of libmspgltk
4 Copyright © 2007-2011  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         sigc::signal<void, int, const std::string &> signal_item_selected;
32
33 private:
34         List list;
35         bool dropped;
36
37 public:
38         Dropdown();
39
40         virtual const char *get_class() const { return "dropdown"; }
41
42         virtual void autosize();
43
44         void append(const std::string &);
45         void insert(unsigned, const std::string &);
46         void remove(unsigned);
47         void clear();
48         unsigned get_n_items() const;
49
50         void set_selected_index(int);
51         const std::string &get_selected() const;
52         int get_selected_index() const;
53
54 private:
55         virtual void render_special(const Part &) const;
56
57 public:
58         virtual void button_press(int, int, unsigned);
59 private:
60         virtual void on_geometry_change();
61         virtual void on_style_change();
62
63         void resize_list();
64         void list_item_selected(unsigned, const std::string &);
65 };
66
67 } // namespace GLtk
68 } // namespace Msp
69
70 #endif