]> git.tdb.fi Git - libs/gltk.git/blob - source/dropdown.h
c9291f91e8d8c39929d0eca0b3bb829ca8e449a2
[libs/gltk.git] / source / dropdown.h
1 /* $Id$
2
3 This file is part of libmspgltk
4 Copyright © 2007  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 "widget.h"
13
14 namespace Msp {
15 namespace GLtk {
16
17 class List;
18
19 class Dropdown: public Widget
20 {
21 public:
22         class Loader: public Widget::Loader
23         {
24         public:
25                 Loader(Dropdown &);
26         private:
27                 void item(const std::string &);
28         };
29
30 private:
31         List *list;
32         std::string text;
33         bool dropped;
34         bool list_active;
35
36 public:
37         sigc::signal<void, int, const std::string &> signal_item_selected;
38
39         Dropdown(const Resources &);
40         ~Dropdown();
41
42         void append(const std::string &);
43         void insert(unsigned, const std::string &);
44         void remove(unsigned);
45         void clear();
46
47         void set_selected_index(int);
48         const std::string &get_selected() const;
49         int get_selected_index() const;
50
51         virtual void button_press(int, int, unsigned);
52         virtual void button_release(int, int, unsigned);
53         virtual void pointer_motion(int, int);
54
55 private:
56         virtual const char *get_class() const { return "dropdown"; }
57         virtual void render_special(const Part &) const;
58
59         virtual void on_geometry_change();
60
61         void list_item_selected(unsigned, const std::string &);
62 };
63
64 } // namespace GLtk
65 } // namespace Msp
66
67 #endif