libyui
3.0.5
Main Page
Classes
Files
File List
All
Classes
Functions
Variables
Enumerations
Friends
YIntField.h
1
/*
2
Copyright (C) 2000-2012 Novell, Inc
3
This library is free software; you can redistribute it and/or modify
4
it under the terms of the GNU Lesser General Public License as
5
published by the Free Software Foundation; either version 2.1 of the
6
License, or (at your option) version 3.0 of the License. This library
7
is distributed in the hope that it will be useful, but WITHOUT ANY
8
WARRANTY; without even the implied warranty of MERCHANTABILITY or
9
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10
License for more details. You should have received a copy of the GNU
11
Lesser General Public License along with this library; if not, write
12
to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13
Floor, Boston, MA 02110-1301 USA
14
*/
15
16
17
/*-/
18
19
File: YIntField.h
20
21
Author: Stefan Hundhammer <sh@suse.de>
22
23
/-*/
24
25
#ifndef YIntField_h
26
#define YIntField_h
27
28
#include "YWidget.h"
29
30
class
YIntFieldPrivate
;
31
32
33
34
/**
35
* IntField: Input field for integer values. Enforces input range between a
36
* specified minimum and maximum value.
37
**/
38
class
YIntField
:
public
YWidget
39
{
40
protected
:
41
/**
42
* Constructor.
43
*
44
* Create an IntField with 'label' as the caption, and the specified minimum
45
* and maximum values.
46
*
47
* Note that YWidgetFactory::createIntField() also has an 'initialValue'
48
* parameter that is not used here (because the current value is not stored
49
* in this base class, but in the derived class).
50
**/
51
YIntField
(
YWidget
*
parent
,
52
const
std::string &
label
,
53
int
minValue
,
54
int
maxValue
);
55
56
public
:
57
/**
58
* Destructor.
59
**/
60
virtual
~YIntField
();
61
62
/**
63
* Return a descriptive name of this widget class for logging,
64
* debugging etc.
65
**/
66
virtual
const
char
*
widgetClass
()
const
{
return
"YIntField"
; }
67
68
/**
69
* Get the current value (the number entered by the user or set from the
70
* outside) of this IntField.
71
*
72
* Derived classes are required to implement this.
73
**/
74
virtual
int
value
() = 0;
75
76
/**
77
* Set the current value (the number entered by the user or set from the
78
* outside) of this IntField. This method enforces 'val to be between
79
* minValue and maxValue.
80
**/
81
void
setValue
(
int
val ) {
setValueInternal
(
enforceRange
( val ) ); }
82
83
protected
:
84
85
/**
86
* Set the current value (the number entered by the user or set from the
87
* outside) of this IntField. 'val' is guaranteed to be between minValue
88
* and maxValue; no further checks are required.
89
*
90
* Derived classes are required to implement this method.
91
**/
92
virtual
void
setValueInternal
(
int
val ) = 0;
93
94
/**
95
* Enforce 'val' to be between minValue and maxValue.
96
* Return a value that is in range. This does not change the internally
97
* stored value of this IntField in any way.
98
**/
99
int
enforceRange
(
int
val )
const
;
100
101
public
:
102
103
/**
104
* Return the minimum value.
105
**/
106
int
minValue
()
const
;
107
108
/**
109
* Set a new minimum value. If the current value is less than that, it will
110
* be set to the new minimum.
111
**/
112
void
setMinValue
(
int
val );
113
114
/**
115
* Return the maximum value.
116
**/
117
int
maxValue
()
const
;
118
119
/**
120
* Set a new maximum value. If the current value is greater than that, it
121
* will be set to the new maximum.
122
**/
123
void
setMaxValue
(
int
val );
124
125
/**
126
* Get the label (the caption above the input field).
127
**/
128
std::string
label
()
const
;
129
130
/**
131
* Set the label (the caption above the input field).
132
*
133
* Derived classes are free to reimplement this, but they should call this
134
* base class method at the end of the overloaded function.
135
**/
136
virtual
void
setLabel
(
const
std::string & label );
137
138
/**
139
* Set a property.
140
* Reimplemented from YWidget.
141
*
142
* This function may throw YUIPropertyExceptions.
143
*
144
* This function returns 'true' if the value was successfully set and
145
* 'false' if that value requires special handling (not in error cases:
146
* those are covered by exceptions).
147
**/
148
virtual
bool
setProperty
(
const
std::string & propertyName,
149
const
YPropertyValue
& val );
150
151
/**
152
* Get a property.
153
* Reimplemented from YWidget.
154
*
155
* This method may throw YUIPropertyExceptions.
156
**/
157
virtual
YPropertyValue
getProperty
(
const
std::string & propertyName );
158
159
/**
160
* Return this class's property set.
161
* This also initializes the property upon the first call.
162
*
163
* Reimplemented from YWidget.
164
**/
165
virtual
const
YPropertySet
&
propertySet
();
166
167
/**
168
* Get the string of this widget that holds the keyboard shortcut.
169
*
170
* Reimplemented from YWidget.
171
**/
172
virtual
std::string
shortcutString
()
const
{
return
label
(); }
173
174
/**
175
* Set the string of this widget that holds the keyboard shortcut.
176
*
177
* Reimplemented from YWidget.
178
**/
179
virtual
void
setShortcutString
(
const
std::string & str )
180
{
setLabel
( str ); }
181
182
/**
183
* The name of the widget property that will return user input.
184
* Inherited from YWidget.
185
**/
186
const
char
*
userInputProperty
() {
return
YUIProperty_Value; }
187
188
189
private
:
190
191
ImplPtr<YIntFieldPrivate>
priv;
192
};
193
194
195
#endif // YIntField_h
src
YIntField.h
Generated by
1.8.3.1