]> git.tdb.fi Git - libs/gltk.git/blob - source/entry.h
Add a VSlider to multiline Entries
[libs/gltk.git] / source / entry.h
1 /* $Id$
2
3 This file is part of libmspgltk
4 Copyright © 2007-2010  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 private:
39         Text text;
40         bool multiline;
41         unsigned edit_pos;
42         unsigned first_row;
43         unsigned visible_rows;
44         const Part *text_part;
45         VSlider *slider;
46
47 public:
48         sigc::signal<void> signal_enter;
49
50         Entry(const Resources &, const std::string & =std::string());
51
52         void set_text(const std::string &);
53         const std::string &get_text() const { return text.get(); }
54         void set_multiline(bool);
55         bool is_multiline() const { return multiline; }
56
57         virtual void key_press(unsigned, unsigned, wchar_t);
58 private:
59         virtual const char *get_class() const { return "entry"; }
60         virtual void render_special(const Part &) const;
61
62         virtual void on_geometry_change();
63         virtual void on_style_change();
64         void reposition_slider();
65         void slider_value_changed(double);
66         void check_view_range();
67 };
68
69 } // namespace GLtk
70 } // namespace Msp
71
72 #endif
73