textedit.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2011 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib may link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 **    Harry Storbacka
00028 */
00029 
00032 
00033 #pragma once
00034 
00035 #include "../api_gui.h"
00036 #include "../gui_component.h"
00037 
00038 class CL_TextEdit_Impl;
00039 
00043 class CL_API_GUI CL_TextEdit : public CL_GUIComponent
00044 {
00047 
00048 public:
00052         CL_TextEdit(CL_GUIComponent *parent);
00053 
00054         virtual ~CL_TextEdit();
00055 
00059 
00060 public:
00061         using CL_GUIComponent::get_named_item;
00062 
00066         static CL_TextEdit *get_named_item(CL_GUIComponent *reference_component, const CL_StringRef &id);
00067 
00071         bool is_read_only() const;
00072 
00076         bool is_lowercase() const;
00077 
00081         bool is_uppercase() const;
00082 
00086         int get_max_length() const;
00087 
00091         CL_String get_text() const;
00092 
00096         int get_line_count() const;
00097 
00101         CL_String get_line_text(int line) const;
00102 
00106         CL_String get_selection() const;
00107 
00111         int get_selection_start() const;
00112 
00116         int get_selection_length() const;
00117 
00121         int get_cursor_pos() const;
00122 
00126         int get_cursor_line_number() const;
00127 
00131         virtual CL_Size get_preferred_size() const;
00132 
00134         int get_total_height();
00135 
00139 
00140 public:
00141         void set_select_all_on_focus_gain(bool enable);
00142 
00144         void select_all();
00145 
00149         void set_read_only(bool enable = true);
00150 
00154         void set_lowercase(bool enable = true);
00155 
00159         void set_uppercase(bool enable = true);
00160 
00164         void set_max_length(int length);
00165 
00169         void set_text(const CL_StringRef &text);
00170 
00174         void add_text(const CL_StringRef &text);
00175 
00180         void set_selection(int pos, int length);
00181 
00183         void clear_selection();
00184 
00188         void set_cursor_pos(int pos);
00189 
00191         void delete_selected_text();
00192 
00194         void set_input_mask(const CL_StringRef &mask);
00195 
00197         void set_cursor_drawing_enabled(bool enable);
00198 
00202 
00203 public:
00204         CL_Callback_v1<CL_InputEvent &> &func_before_edit_changed();
00205 
00206         CL_Callback_v1<CL_InputEvent &> &func_after_edit_changed();
00207 
00211         CL_Callback_v0 &func_selection_changed();
00212 
00214         CL_Callback_v0 &func_focus_gained();
00215 
00217         CL_Callback_v0 &func_focus_lost();
00218 
00222         CL_Callback_v0 &func_enter_pressed();
00223 
00227 
00228 private:
00229         CL_SharedPtr<CL_TextEdit_Impl> impl;
00231 };
00232