]> git.tdb.fi Git - libs/gltk.git/blob - source/dropdown.h
Render text in Dropdown directly from the List
[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         bool dropped;
33         bool list_active;
34
35 public:
36         sigc::signal<void, int, const std::string &> signal_item_selected;
37
38         Dropdown(const Resources &);
39         ~Dropdown();
40
41         void append(const std::string &);
42         void insert(unsigned, const std::string &);
43         void remove(unsigned);
44         void clear();
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         virtual void button_release(int, int, unsigned);
52         virtual void pointer_motion(int, int);
53
54 private:
55         virtual const char *get_class() const { return "dropdown"; }
56         virtual void render_special(const Part &) const;
57
58         virtual void on_geometry_change();
59
60         void list_item_selected(unsigned, const std::string &);
61 };
62
63 } // namespace GLtk
64 } // namespace Msp
65
66 #endif