]> git.tdb.fi Git - libs/gltk.git/blob - source/dropdown.h
ecba9753cb5cace6957f74fa52162887703e202e
[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 "list.h"
13 #include "widget.h"
14
15 namespace Msp {
16 namespace GLtk {
17
18 class List;
19
20 class Dropdown: public Widget
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         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         unsigned get_n_items() const;
47
48         void set_selected_index(int);
49         const std::string &get_selected() const;
50         int get_selected_index() const;
51
52         virtual void button_press(int, int, unsigned);
53         virtual void button_release(int, int, unsigned);
54         virtual void pointer_motion(int, int);
55
56 private:
57         virtual const char *get_class() const { return "dropdown"; }
58         virtual void render_special(const Part &) const;
59
60         virtual void on_geometry_change();
61         void resize_list();
62
63         void list_item_selected(unsigned, const std::string &);
64 };
65
66 } // namespace GLtk
67 } // namespace Msp
68
69 #endif