ClanLib  2.3.7
textedit.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 
38 class CL_TextEdit_Impl;
39 
44 {
47 
48 public:
53 
54  virtual ~CL_TextEdit();
55 
59 
60 public:
62 
66  static CL_TextEdit *get_named_item(CL_GUIComponent *reference_component, const CL_StringRef &id);
67 
71  bool is_read_only() const;
72 
76  bool is_lowercase() const;
77 
81  bool is_uppercase() const;
82 
86  int get_max_length() const;
87 
91  CL_String get_text() const;
92 
96  int get_line_count() const;
97 
101  CL_String get_line_text(int line) const;
102 
106  CL_String get_selection() const;
107 
111  int get_selection_start() const;
112 
116  int get_selection_length() const;
117 
121  int get_cursor_pos() const;
122 
126  int get_cursor_line_number() const;
127 
131  virtual CL_Size get_preferred_size() const;
132 
134  int get_total_height();
135 
139 
140 public:
141  void set_select_all_on_focus_gain(bool enable);
142 
144  void select_all();
145 
149  void set_read_only(bool enable = true);
150 
154  void set_lowercase(bool enable = true);
155 
159  void set_uppercase(bool enable = true);
160 
164  void set_max_length(int length);
165 
169  void set_text(const CL_StringRef &text);
170 
174  void add_text(const CL_StringRef &text);
175 
180  void set_selection(int pos, int length);
181 
183  void clear_selection();
184 
188  void set_cursor_pos(int pos);
189 
191  void delete_selected_text();
192 
194  void set_input_mask(const CL_StringRef &mask);
195 
197  void set_cursor_drawing_enabled(bool enable);
198 
202 
203 public:
204  CL_Callback_v1<CL_InputEvent &> &func_before_edit_changed();
205 
206  CL_Callback_v1<CL_InputEvent &> &func_after_edit_changed();
207 
211  CL_Callback_v0 &func_selection_changed();
212 
215 
218 
222  CL_Callback_v0 &func_enter_pressed();
223 
227 
228 private:
229  CL_SharedPtr<CL_TextEdit_Impl> impl;
231 };
232