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