1
/***********************************************************************
2
filename: CEGUIEditboxProperties.cpp
6
purpose: Implements properties for the Editbox class
7
*************************************************************************/
8
/***************************************************************************
9
* Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
11
* Permission is hereby granted, free of charge, to any person obtaining
12
* a copy of this software and associated documentation files (the
13
* "Software"), to deal in the Software without restriction, including
14
* without limitation the rights to use, copy, modify, merge, publish,
15
* distribute, sublicense, and/or sell copies of the Software, and to
16
* permit persons to whom the Software is furnished to do so, subject to
17
* the following conditions:
19
* The above copyright notice and this permission notice shall be
20
* included in all copies or substantial portions of the Software.
22
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28
* OTHER DEALINGS IN THE SOFTWARE.
29
***************************************************************************/
30
#include "elements/CEGUIEditboxProperties.h"
31
#include "elements/CEGUIEditbox.h"
32
#include "CEGUIPropertyHelper.h"
33
#include "CEGUIExceptions.h"
38
// Start of CEGUI namespace section
42
// Start of EditboxProperties namespace section
43
namespace EditboxProperties
46
String ReadOnly::get(const PropertyReceiver* receiver) const
48
return PropertyHelper::boolToString(static_cast<const Editbox*>(receiver)->isReadOnly());
52
void ReadOnly::set(PropertyReceiver* receiver, const String& value)
54
static_cast<Editbox*>(receiver)->setReadOnly(PropertyHelper::stringToBool(value));
58
String MaskText::get(const PropertyReceiver* receiver) const
60
return PropertyHelper::boolToString(static_cast<const Editbox*>(receiver)->isTextMasked());
64
void MaskText::set(PropertyReceiver* receiver, const String& value)
66
static_cast<Editbox*>(receiver)->setTextMasked(PropertyHelper::stringToBool(value));
70
String MaskCodepoint::get(const PropertyReceiver* receiver) const
72
return PropertyHelper::uintToString(static_cast<const Editbox*>(receiver)->getMaskCodePoint());
76
void MaskCodepoint::set(PropertyReceiver* receiver, const String& value)
78
static_cast<Editbox*>(receiver)->setMaskCodePoint(PropertyHelper::stringToUint(value));
82
String ValidationString::get(const PropertyReceiver* receiver) const
84
return static_cast<const Editbox*>(receiver)->getValidationString();
88
void ValidationString::set(PropertyReceiver* receiver, const String& value)
90
static_cast<Editbox*>(receiver)->setValidationString(value);
94
String CaratIndex::get(const PropertyReceiver* receiver) const
96
return PropertyHelper::uintToString(static_cast<uint>(static_cast<const Editbox*>(receiver)->getCaratIndex()));
100
void CaratIndex::set(PropertyReceiver* receiver, const String& value)
102
static_cast<Editbox*>(receiver)->setCaratIndex(PropertyHelper::stringToUint(value));
106
String SelectionStart::get(const PropertyReceiver* receiver) const
108
return PropertyHelper::uintToString(static_cast<uint>(static_cast<const Editbox*>(receiver)->getSelectionStartIndex()));
112
void SelectionStart::set(PropertyReceiver* receiver, const String& value)
114
Editbox* eb = static_cast<Editbox*>(receiver);
115
uint selStart = PropertyHelper::stringToUint(value);
116
eb->setSelection(selStart, selStart + eb->getSelectionLength());
120
String SelectionLength::get(const PropertyReceiver* receiver) const
122
return PropertyHelper::uintToString(static_cast<uint>(static_cast<const Editbox*>(receiver)->getSelectionLength()));
126
void SelectionLength::set(PropertyReceiver* receiver, const String& value)
128
Editbox* eb = static_cast<Editbox*>(receiver);
129
uint selLen = PropertyHelper::stringToUint(value);
130
eb->setSelection(eb->getSelectionStartIndex(), eb->getSelectionStartIndex() + selLen);
134
String MaxTextLength::get(const PropertyReceiver* receiver) const
136
return PropertyHelper::uintToString(static_cast<uint>(static_cast<const Editbox*>(receiver)->getMaxTextLength()));
140
void MaxTextLength::set(PropertyReceiver* receiver, const String& value)
142
static_cast<Editbox*>(receiver)->setMaxTextLength(PropertyHelper::stringToUint(value));
145
} // End of EditboxProperties namespace section
147
} // End of CEGUI namespace section