ClanLib  2.3.7
lineedit.h
Go to the documentation of this file.
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2011 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Magnus Norddahl
27 ** Harry Storbacka
28 */
29 
32 
33 #pragma once
34 
35 #include "../api_gui.h"
36 #include "../gui_component.h"
37 #include "../../Display/Window/input_event.h"
38 #include "../../Core/Signals/callback_v0.h"
39 #include "../../Core/Signals/callback_v1.h"
40 #include "../../Core/Signals/callback_1.h"
41 
42 class CL_LineEdit_Impl;
43 
48 {
51 
52 public:
53 
58 
59  virtual ~CL_LineEdit();
60 
64 
65 public:
66  enum Alignment
67  {
70  align_right
71  };
72 
74 
78  static CL_LineEdit *get_named_item(CL_GUIComponent *reference_component, const CL_StringRef &id);
79 
83  Alignment get_alignment() const;
84 
88  bool is_read_only() const;
89 
93  bool is_lowercase() const;
94 
98  bool is_uppercase() const;
99 
103  bool is_password_mode() const;
104 
108  int get_max_length() const;
109 
113  CL_StringRef get_text() const;
114 
116  int get_text_int() const;
117 
119  float get_text_float() const;
120 
124  CL_String get_selection() const;
125 
129  int get_selection_start() const;
130 
134  int get_selection_length() const;
135 
139  int get_cursor_pos() const;
140 
144  virtual CL_Size get_preferred_size() const;
145 
147  CL_Size get_text_size();
148 
154  CL_Size get_text_size(const CL_String &str);
155 
159 
160 public:
161  void set_select_all_on_focus_gain(bool enable);
162 
164  void select_all();
165 
169  void set_alignment(Alignment alignment);
170 
174  void set_read_only(bool enable = true);
175 
179  void set_lowercase(bool enable = true);
180 
184  void set_uppercase(bool enable = true);
185 
189  void set_password_mode(bool enable = true);
190 
195  void set_numeric_mode(bool enable = true, bool decimals = false);
196 
200  void set_max_length(int length);
201 
205  void set_text(const CL_StringRef &text);
206 
210  void set_text(int number);
211 
216  void set_text(float number, int num_decimal_places = 6);
217 
222  void set_selection(int pos, int length);
223 
225  void clear_selection();
226 
230  void set_cursor_pos(int pos);
231 
233  void delete_selected_text();
234 
236  void resize_to_fit(int max_width);
237 
239  void set_input_mask(const CL_StringRef &mask);
240 
244  void set_decimal_character(const CL_StringRef &decimal_char);
245 
247  void set_cursor_drawing_enabled(bool enable);
248 
252 
253 public:
254  CL_Callback_v1<CL_InputEvent &> &func_before_edit_changed();
255 
256  CL_Callback_v1<CL_InputEvent &> &func_after_edit_changed();
257 
261  CL_Callback_v0 &func_selection_changed();
262 
265 
268 
272  CL_Callback_v0 &func_enter_pressed();
273 
277 
278 private:
279  CL_SharedPtr<CL_LineEdit_Impl> impl;
281 };
282