1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
|
/*
$Id: inputbox.cpp,v 1.43 2001/12/27 23:11:23 mbn Exp $
ClanGUI, copyrights by various people. Have a look in the CREDITS file.
This sourcecode is distributed using the Library GNU Public Licence,
version 2 or (at your option) any later version. Please read LICENSE
for details.
*/
#include "precomp.h"
#include "API/GUI/inputbox.h"
#include "API/GUI/component_options.h"
#include "API/GUI/stylemanager.h"
#include "inputbox_generic.h"
/////////////////////////////////////////////////////////////////////////////
// Construction:
CL_InputBox::CL_InputBox(
CL_Component *parent,
CL_StyleManager *style)
: CL_Component(parent, style), impl(NULL)
{
impl = new CL_InputBox_Generic(this, std::string(), false, false, 1024);
get_style_manager()->connect_styles("inputbox", this);
}
CL_InputBox::CL_InputBox(
const CL_Rect &pos,
const std::string &text,
CL_Component *parent,
CL_StyleManager *style)
: CL_Component(pos, parent, style), impl(NULL)
{
impl = new CL_InputBox_Generic(this, text, false, false, 0);
get_style_manager()->connect_styles("inputbox", this);
}
CL_InputBox::CL_InputBox(
const CL_Rect &pos,
CL_Component *parent,
CL_StyleManager *style)
: CL_Component(pos, parent, style), impl(NULL)
{
impl = new CL_InputBox_Generic(this, "", false, false, 0);
get_style_manager()->connect_styles("inputbox", this);
}
CL_InputBox::~CL_InputBox()
{
delete impl;
}
/////////////////////////////////////////////////////////////////////////////
// Attributes:
int CL_InputBox::get_length() const
{
return impl->text.size();
}
const std::string &CL_InputBox::get_text() const
{
return impl->text;
}
const std::string &CL_InputBox::get_marked_text() const
{
return impl->get_marked_text();
}
bool CL_InputBox::has_marked_text() const
{
return (get_selection_length() > 0);
}
int CL_InputBox::get_selection_start() const
{
return impl->get_selection_start();
}
int CL_InputBox::get_selection_length() const
{
return impl->get_selection_length();
}
int CL_InputBox::get_max_length() const
{
return impl->max_length;
}
bool CL_InputBox::in_password_mode() const
{
return impl->password_mode;
}
bool CL_InputBox::is_read_only() const
{
return impl->read_only;
}
int CL_InputBox::get_cursor_position() const
{
return impl->cursor_position;
}
bool CL_InputBox::is_edited() const
{
return impl->edited;
}
/////////////////////////////////////////////////////////////////////////////
// Operations:
void CL_InputBox::set_text(const std::string &text)
{
impl->set_text(text);
}
void CL_InputBox::set_text(int number)
{
char buf[20];
sprintf(buf, "%d", number);
impl->set_text(buf);
}
void CL_InputBox::set_text(double number)
{
char buf[20];
sprintf(buf, "%f", number);
impl->set_text(buf);
}
void CL_InputBox::set_max_length(int length)
{
impl->set_max_length(length);
}
void CL_InputBox::set_password_mode(bool enable)
{
impl->password_mode = enable;
}
void CL_InputBox::set_read_only(bool enable)
{
impl->read_only = enable;
}
void CL_InputBox::select_all()
{
impl->select_all();
}
void CL_InputBox::deselect()
{
impl->deselect();
}
void CL_InputBox::set_selection(int start, int length)
{
impl->set_selection(start, length);
}
void CL_InputBox::set_cursor_position(int pos)
{
impl->set_cursor_position(pos);
}
void CL_InputBox::clear()
{
impl->set_text("");
}
void CL_InputBox::backspace()
{
impl->backspace();
}
void CL_InputBox::del()
{
impl->del();
}
void CL_InputBox::cut()
{
impl->cut();
}
void CL_InputBox::move_cursor(int delta, bool mark)
{
impl->move_cursor(delta, mark);
}
void CL_InputBox::move_cursor_word(int delta, bool mark)
{
impl->move_cursor_word(delta, mark);
}
void CL_InputBox::home(bool mark)
{
impl->home(mark);
}
void CL_InputBox::end(bool mark)
{
impl->end(mark);
}
void CL_InputBox::set_edited(bool on)
{
impl->edited = on;
}
/////////////////////////////////////////////////////////////////////////////
// Signals:
CL_Signal_v1<const std::string &> &CL_InputBox::sig_changed()
{
return impl->sig_changed;
}
CL_Signal_v0 &CL_InputBox::sig_return_pressed()
{
return impl->sig_return_pressed;
}
CL_Signal_v0 &CL_InputBox::sig_activity()
{
return impl->sig_activity;
}
|