00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "precomp.h"
00010 #include "API/GUI/inputbox.h"
00011 #include "API/GUI/component_options.h"
00012 #include "API/GUI/stylemanager.h"
00013 #include "inputbox_generic.h"
00014
00016
00017
00018 CL_InputBox::CL_InputBox(
00019 const CL_ComponentOptions &options,
00020 CL_Component *parent,
00021 CL_StyleManager *style)
00022 :
00023 CL_Component(options, parent, style),
00024 impl(NULL)
00025 {
00026 impl = new CL_InputBox_Generic(this, options, get_style_manager());
00027 get_style_manager()->connect_styles("inputbox", options, this);
00028 }
00029
00030 CL_InputBox::CL_InputBox(
00031 const CL_Rect &pos,
00032 const std::string &text,
00033 CL_Component *parent,
00034 CL_StyleManager *style)
00035 :
00036 CL_Component(
00037 CL_InputBox_Generic::create_options(pos, text, false, false, 0),
00038 parent,
00039 style),
00040 impl(NULL)
00041 {
00042 CL_ComponentOptions options = CL_InputBox_Generic::create_options(pos, text, false, false, 0);
00043 impl = new CL_InputBox_Generic(this, options, get_style_manager());
00044 get_style_manager()->connect_styles("inputbox", options, this);
00045 }
00046
00047 CL_InputBox::~CL_InputBox()
00048 {
00049 delete impl;
00050 }
00051
00053
00054
00055 int CL_InputBox::get_length() const
00056 {
00057 return impl->text.size();
00058 }
00059
00060 const std::string &CL_InputBox::get_text() const
00061 {
00062 return impl->text;
00063 }
00064
00065 const std::string &CL_InputBox::get_marked_text() const
00066 {
00067 return impl->get_marked_text();
00068 }
00069
00070 bool CL_InputBox::has_marked_text() const
00071 {
00072 return (get_selection_length() > 0);
00073 }
00074
00075 int CL_InputBox::get_selection_start() const
00076 {
00077 return impl->get_selection_start();
00078 }
00079
00080 int CL_InputBox::get_selection_length() const
00081 {
00082 return impl->get_selection_length();
00083 }
00084
00085 int CL_InputBox::get_max_length() const
00086 {
00087 return impl->max_length;
00088 }
00089
00090 bool CL_InputBox::in_password_mode() const
00091 {
00092 return impl->password_mode;
00093 }
00094
00095 bool CL_InputBox::is_read_only() const
00096 {
00097 return impl->read_only;
00098 }
00099
00100 int CL_InputBox::get_cursor_position() const
00101 {
00102 return impl->cursor_position;
00103 }
00104
00105 bool CL_InputBox::is_edited() const
00106 {
00107 return impl->edited;
00108 }
00109
00111
00112
00113 void CL_InputBox::set_text(const std::string &text)
00114 {
00115 impl->set_text(text);
00116 }
00117
00118 void CL_InputBox::set_max_length(int length)
00119 {
00120 impl->set_max_length(length);
00121 }
00122
00123 void CL_InputBox::set_password_mode(bool enable)
00124 {
00125 impl->password_mode = enable;
00126 }
00127
00128 void CL_InputBox::set_read_only(bool enable)
00129 {
00130 impl->read_only = enable;
00131 }
00132
00133 void CL_InputBox::select_all()
00134 {
00135 impl->select_all();
00136 }
00137
00138 void CL_InputBox::deselect()
00139 {
00140 impl->deselect();
00141 }
00142
00143 void CL_InputBox::set_selection(int start, int length)
00144 {
00145 impl->set_selection(start, length);
00146 }
00147
00148 void CL_InputBox::set_cursor_position(int pos)
00149 {
00150 impl->set_cursor_position(pos);
00151 }
00152
00153 void CL_InputBox::clear()
00154 {
00155 impl->set_text("");
00156 }
00157
00158 void CL_InputBox::backspace()
00159 {
00160 impl->backspace();
00161 }
00162
00163 void CL_InputBox::del()
00164 {
00165 impl->del();
00166 }
00167
00168 void CL_InputBox::cut()
00169 {
00170 impl->cut();
00171 }
00172
00173 void CL_InputBox::move_cursor(int delta, bool mark)
00174 {
00175 impl->move_cursor(delta, mark);
00176 }
00177
00178 void CL_InputBox::move_cursor_word(int delta, bool mark)
00179 {
00180 impl->move_cursor_word(delta, mark);
00181 }
00182
00183 void CL_InputBox::home(bool mark)
00184 {
00185 impl->home(mark);
00186 }
00187
00188 void CL_InputBox::end(bool mark)
00189 {
00190 impl->end(mark);
00191 }
00192
00193 void CL_InputBox::set_edited(bool on)
00194 {
00195 impl->edited = on;
00196 }
00197
00199
00200
00201 CL_Signal_v1<const std::string &> &CL_InputBox::sig_changed()
00202 {
00203 return impl->sig_changed;
00204 }
00205
00206 CL_Signal_v1<const std::string &> &CL_InputBox::sig_return_pressed()
00207 {
00208 return impl->sig_return_pressed;
00209 }