MySQL Workbench  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
textbox.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; version 2 of the
7  * License.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17  * 02110-1301 USA
18  */
19 #ifndef _MFORMS_TEXTBOX_H_
20 #define _MFORMS_TEXTBOX_H_
21 
22 #include <mforms/view.h>
23 #include <mforms/utilities.h>
24 
25 namespace mforms {
26  enum ScrollBars {
28  HorizontalScrollBar = (1 << 0),
29  VerticalScrollBar = (1 << 1),
31  SmallScrollBars = (1 << 2)
32  };
33 
37  enum KeyCode {
48  };
49 
50  class TextBox;
51 
52 #ifndef DOXYGEN_SHOULD_SKIP_THIS
53 #ifndef SWIG
54  struct TextBoxImplPtrs
55  {
56  bool (*create)(TextBox *self, ScrollBars scroll_bars);
57  void (*set_bordered)(TextBox *self, bool flag);
58  void (*set_read_only)(TextBox *self, bool flag);
59  void (*set_text)(TextBox *self, const std::string &text);
60  std::string (*get_text)(TextBox *self);
61  void (*append_text)(TextBox *self, const std::string &text, bool scroll_to_end);
62 // void (*append_text_with_attributes)(TextBox *self, const std::string &text, const TextAttributes &attr, bool scroll_to_end);
63  void (*set_padding)(TextBox *self, int pad); // TODO: not supported on Windows, should be removed.
64  void (*set_monospaced)(TextBox *self, bool flag);
65  void (*get_selected_range)(TextBox *self, int &start, int &end);
66  void (*clear)(TextBox *self);
67  };
68 #endif
69 #endif
70 
72  class MFORMS_EXPORT TextBox : public View
73  {
74 #ifdef SWIG
75 // workaround for problem with unicode strings and default args in swig
76 %rename(append_text_and_scroll) append_text(const std::string &text, bool scroll_to_end);
77 %rename(append_text) append_text(const std::string &text);
78 
79 %rename(append_text_with_encoding_and_scroll) append_text_with_encoding(const std::string &text, const std::string &encoding, bool scroll_to_end);
80 %rename(append_text_with_encoding) append_text_with_encoding(const std::string &text, const std::string &encoding);
81 #endif
82  public:
83  TextBox(ScrollBars scroll_bars);
84 
86  void set_bordered(bool flag);
88  void set_monospaced(bool flag);
89 
91  void set_read_only(bool flag);
93  void set_value(const std::string &text);
95  virtual std::string get_string_value();
96 
98  void get_selected_range(int &start, int &end);
99 
103  void append_text(const std::string &text, bool scroll_to_end= false);
104 
108  void append_text_with_encoding(const std::string &text, const std::string &encoding, bool scroll_to_end= false);
109 
111  void set_padding(int pad);
112 
114  void clear();
115 
116 #ifndef SWIG
117 
118  boost::signals2::signal<void ()>* signal_changed() { return &_signal_changed; };
119 
124  boost::signals2::signal<bool (KeyCode, ModifierKey, const std::string&)>* key_event_signal() { return &_key_event_signal; };
125 #ifndef DOXYGEN_SHOULD_SKIP_THIS
126  public:
127  void callback();
128  bool key_event(KeyCode code, ModifierKey modifiers, const std::string& text);
129 #endif
130 #endif
131  protected:
132  TextBoxImplPtrs *_textbox_impl;
133  bool _updating;
134 
135  boost::signals2::signal<void ()> _signal_changed;
136  boost::signals2::signal<bool (KeyCode, ModifierKey, const std::string&)> _key_event_signal;
137  };
138 };
139 
140 #endif
Show only the vertical scroll bar.
Definition: textbox.h:29
boost::signals2::signal< bool(KeyCode, ModifierKey, const std::string &)> * key_event_signal()
Signal emitted when a key was pressed.
Definition: textbox.h:124
KeyCode
Code which abstracts special keys for each platform, to be used in the key event. ...
Definition: textbox.h:37
boost::signals2::signal< void()> * signal_changed()
Signal emitted when control's text changes (e.g.
Definition: textbox.h:118
boost::signals2::signal< void()> _signal_changed
Definition: textbox.h:135
Don't show any scroll bar.
Definition: textbox.h:27
boost::signals2::signal< bool(KeyCode, ModifierKey, const std::string &)> _key_event_signal
Definition: textbox.h:136
No special char. The key event has the entered character(s) in the text field.
Definition: textbox.h:39
Any other key, not yet mapped.
Definition: textbox.h:47
#define MFORMS_EXPORT
Definition: base.h:33
ModifierKey
Flags which describe which modifier key was pressed during a event.
Definition: utilities.h:61
The numpad key.
Definition: textbox.h:41
A combination of Shift/Control/Command/Alt only, without another key.
Definition: textbox.h:40
The main keyboard key.
Definition: textbox.h:42
A smaller version of the scrollbars.
Definition: textbox.h:31
Show only the horizontal scroll bar.
Definition: textbox.h:28
bool _updating
Definition: textbox.h:133
Multiline text editing control.
Definition: textbox.h:72
Show both scroll bars.
Definition: textbox.h:30
ScrollBars
Definition: textbox.h:26
MySQL Workbench 6.1 documentation