]> git.tdb.fi Git - libs/gltk.git/blob - source/entry.h
Strip copyright messages and id tags from individual files
[libs/gltk.git] / source / entry.h
1 #ifndef MSP_GLTK_ENTRY_H_
2 #define MSP_GLTK_ENTRY_H_
3
4 #include "container.h"
5 #include "text.h"
6 #include "widget.h"
7
8 namespace Msp {
9 namespace GLtk {
10
11 class VSlider;
12
13 /**
14 Text entry field.
15
16 Special parts:
17
18   text    The current text of the widget.  Graphics are ignored.
19   cursor  Indicates the current input position.  Fill_x is ignored.
20   slider  A vertical slider for multiline entries.
21 */
22 class Entry: virtual public Widget, private Container
23 {
24 public:
25         class Loader: public Widget::Loader
26         {
27         public:
28                 Loader(Entry &);
29         };
30
31         sigc::signal<void> signal_enter;
32
33 private:
34         Text text;
35         bool multiline;
36         unsigned edit_pos;
37         unsigned first_row;
38         unsigned visible_rows;
39         const Part *text_part;
40         VSlider *slider;
41
42 public:
43         Entry(const std::string & = std::string());
44
45         virtual const char *get_class() const { return "entry"; }
46
47         virtual void autosize();
48
49         void set_text(const std::string &);
50         const std::string &get_text() const { return text.get(); }
51         void set_multiline(bool);
52         bool is_multiline() const { return multiline; }
53
54 private:
55         virtual void render_special(const Part &) const;
56
57 public:
58         virtual void key_press(unsigned, unsigned, wchar_t);
59 private:
60         virtual void on_geometry_change();
61         virtual void on_style_change();
62
63         void reposition_slider();
64         void check_view_range();
65         void slider_value_changed(double);
66 };
67
68 } // namespace GLtk
69 } // namespace Msp
70
71 #endif
72