~thomir-deactivatedaccount/cegui/fix-build

« back to all changes in this revision

Viewing changes to cegui/src/elements/CEGUIEditboxProperties.cpp

  • Committer: Thomi Richards
  • Date: 2013-02-06 22:13:36 UTC
  • Revision ID: thomi.richards@canonical.com-20130206221336-rsmud4k50g6nzv50
InitialĀ codeĀ import.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***********************************************************************
 
2
        filename:       CEGUIEditboxProperties.cpp
 
3
        created:        9/7/2004
 
4
        author:         Paul D Turner
 
5
        
 
6
        purpose:        Implements properties for the Editbox class
 
7
*************************************************************************/
 
8
/***************************************************************************
 
9
 *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
 
10
 *
 
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:
 
18
 *
 
19
 *   The above copyright notice and this permission notice shall be
 
20
 *   included in all copies or substantial portions of the Software.
 
21
 *
 
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"
 
34
#include <cstdlib>
 
35
#include <cstdio>
 
36
 
 
37
 
 
38
// Start of CEGUI namespace section
 
39
namespace CEGUI
 
40
{
 
41
 
 
42
// Start of EditboxProperties namespace section
 
43
namespace EditboxProperties
 
44
{
 
45
 
 
46
String ReadOnly::get(const PropertyReceiver* receiver) const
 
47
{
 
48
        return PropertyHelper::boolToString(static_cast<const Editbox*>(receiver)->isReadOnly());
 
49
}
 
50
 
 
51
 
 
52
void ReadOnly::set(PropertyReceiver* receiver, const String& value)
 
53
{
 
54
        static_cast<Editbox*>(receiver)->setReadOnly(PropertyHelper::stringToBool(value));
 
55
}
 
56
 
 
57
 
 
58
String MaskText::get(const PropertyReceiver* receiver) const
 
59
{
 
60
        return PropertyHelper::boolToString(static_cast<const Editbox*>(receiver)->isTextMasked());
 
61
}
 
62
 
 
63
 
 
64
void MaskText::set(PropertyReceiver* receiver, const String& value)
 
65
{
 
66
        static_cast<Editbox*>(receiver)->setTextMasked(PropertyHelper::stringToBool(value));
 
67
}
 
68
 
 
69
 
 
70
String MaskCodepoint::get(const PropertyReceiver* receiver) const
 
71
{
 
72
        return PropertyHelper::uintToString(static_cast<const Editbox*>(receiver)->getMaskCodePoint());
 
73
}
 
74
 
 
75
 
 
76
void MaskCodepoint::set(PropertyReceiver* receiver, const String& value)
 
77
{
 
78
        static_cast<Editbox*>(receiver)->setMaskCodePoint(PropertyHelper::stringToUint(value));
 
79
}
 
80
 
 
81
 
 
82
String ValidationString::get(const PropertyReceiver* receiver) const
 
83
{
 
84
        return static_cast<const Editbox*>(receiver)->getValidationString();
 
85
}
 
86
 
 
87
 
 
88
void ValidationString::set(PropertyReceiver* receiver, const String& value)
 
89
{
 
90
        static_cast<Editbox*>(receiver)->setValidationString(value);
 
91
}
 
92
 
 
93
 
 
94
String CaratIndex::get(const PropertyReceiver* receiver) const
 
95
{
 
96
        return PropertyHelper::uintToString(static_cast<uint>(static_cast<const Editbox*>(receiver)->getCaratIndex()));
 
97
}
 
98
 
 
99
 
 
100
void CaratIndex::set(PropertyReceiver* receiver, const String& value)
 
101
{
 
102
        static_cast<Editbox*>(receiver)->setCaratIndex(PropertyHelper::stringToUint(value));
 
103
}
 
104
 
 
105
 
 
106
String SelectionStart::get(const PropertyReceiver* receiver) const
 
107
{
 
108
        return PropertyHelper::uintToString(static_cast<uint>(static_cast<const Editbox*>(receiver)->getSelectionStartIndex()));
 
109
}
 
110
 
 
111
 
 
112
void SelectionStart::set(PropertyReceiver* receiver, const String& value)
 
113
{
 
114
        Editbox* eb = static_cast<Editbox*>(receiver);
 
115
        uint selStart = PropertyHelper::stringToUint(value);
 
116
        eb->setSelection(selStart, selStart + eb->getSelectionLength());
 
117
}
 
118
 
 
119
 
 
120
String SelectionLength::get(const PropertyReceiver* receiver) const
 
121
{
 
122
        return PropertyHelper::uintToString(static_cast<uint>(static_cast<const Editbox*>(receiver)->getSelectionLength()));
 
123
}
 
124
 
 
125
 
 
126
void SelectionLength::set(PropertyReceiver* receiver, const String& value)
 
127
{
 
128
        Editbox* eb = static_cast<Editbox*>(receiver);
 
129
        uint selLen = PropertyHelper::stringToUint(value);
 
130
        eb->setSelection(eb->getSelectionStartIndex(), eb->getSelectionStartIndex() + selLen);
 
131
}
 
132
 
 
133
 
 
134
String MaxTextLength::get(const PropertyReceiver* receiver) const
 
135
{
 
136
        return PropertyHelper::uintToString(static_cast<uint>(static_cast<const Editbox*>(receiver)->getMaxTextLength()));
 
137
}
 
138
 
 
139
 
 
140
void MaxTextLength::set(PropertyReceiver* receiver, const String& value)
 
141
{
 
142
        static_cast<Editbox*>(receiver)->setMaxTextLength(PropertyHelper::stringToUint(value));
 
143
}
 
144
 
 
145
} // End of  EditboxProperties namespace section
 
146
 
 
147
} // End of  CEGUI namespace section