11#include <owl/validate.rh>
65 if (!is.fail() && !is.eof())
71 is.setstate(is.failbit);
89 auto hasMinus = validChars.Has(minus);
90 auto hasPlus = validChars.Has(plus);
94 if ((range.Min < 0) != hasMinus)
104 if ((range.Max > 0) != hasPlus)
120 WARN(range.Min > range.Max,
_T(
"TRangeValidator has a minimum value of ") << range.Min
121 <<
_T(
" that is greater than the maximum value of ") << range.Max
122 <<
_T(
"; swapped values will be used."));
123 std::sort(&range.Min, &range.Max + 1);
124 ValidateMagnitudeFilter_(range, validChars);
138 Range.Min = minValue;
139 ValidateMagnitudeFilter_(Range, ValidChars);
151 Range.Max = maxValue;
152 ValidateMagnitudeFilter_(Range, ValidChars);
161 ValidateRange_(Range, ValidChars);
183 ValidateRange_(Range, ValidChars);
189 const auto value = ParseInteger_(is);
190 return !is.fail() && value >= Range.Min && value <= Range.Max;
208 if (!buffer && direction !=
tdSizeData)
return 0;
211 const auto value = ParseInteger_(is);
212 WARN(is.fail(),
_T(
"ParseInteger_ failed"));
216 wsprintf(s,
_T(
"%ld"), *(
TExtent*)buffer);
235 {
return e < r.Min ? r.Min : e > r.Max ? r.Max : e; };
237 ValidateRange_(Range, ValidChars);
239 const auto value = ParseInteger_(is);
240 WARN(is.fail(),
_T(
"ParseInteger_ failed"));
241 const auto newValue = clamp(value + amount, Range);
243 return newValue - value;
248#if OWL_PERSISTENT_STREAMS
257 is >> GetObject()->Range.Min >> GetObject()->Range.Max;
265TRangeValidator::Streamer::Write(opstream& os)
const
268 os << GetObject()->Range.Min << GetObject()->Range.Max;
Definition of class TAppDictionary.
Definition of class TApplication.
#define WARN(condition, message)
#define PRECONDITION(condition)
Derived from TBitSet, TCharSet sets and clears bytes for a group of characters.
A streamable class, TFilterValidator checks an input field as the user types into it.
TFilterValidator(const TCharSet &validChars)
Let the compiler know that the following template instances will be defined elsewhere.
bool IsValid(LPCTSTR str)
IsValid overrides TValidator's virtuals and returns true if all characters in str are in the set of a...
Determines whether the data typed by a user falls within a designated range of integers.
void SetMax(TExtent maxValue)
Sets the maximum number the validator can accept.
bool IsValid(LPCTSTR str)
We first validate the range, because of the asynchronous manner in which SetMin and SetMax could be c...
void Error(TWindow *owner)
Overrides TValidator's virtual function and displays a message box indicating that the entered value ...
int Adjust(tstring &text, int &begPos, int &endPos, int amount)
We first validate the range, because of the asynchronous manner in which SetMin and SetMax could be c...
TRangeValidator(TExtent minValue, TExtent maxValue)
Constructs a range validator object using minValue and maxValue as the range of possible values.
void SetRange(const TRange &range)
Sets the minimum and maximum number the validator can accept.
uint Transfer(TCHAR *str, void *buffer, TTransferDirection direction)
Incorporates the three types, tdSizeData, tdGetData, and tdSetData, that a range validator can handle...
void SetMin(TExtent minValue)
Sets the minimum number the validator can accept.
uint16 Options
A bitmap member used to control options for various descendants of TValidator.
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
tstring LoadString(uint id) const
auto FormatMessageBox(const tstring &formatStr, const tstring &caption, uint flags,...) const -> int
ipstream, a specialized input stream derivative of pstream, is the base class for reading (extracting...
Definition of class TFrameWindow.
void ReadBaseObject(Base *base, ipstream &in)
void WriteBaseObject(Base *base, opstream &out)
@ voTransfer
Option to perform conversion & transfer.
TTransferDirection
The TTransferDirection enum describes the constants that the transfer function uses to determine how ...
@ tdSizeData
Return the size of data transferred by the class.
@ tdSetData
Set data from the buffer into the window.
@ tdGetData
Get data from the window into the buffer.
Object Windows Library (OWLNext Core).
std::istringstream tistringstream
auto to_tstring(const T &v) -> tstring
IMPLEMENT_STREAMABLE1(TApplication, TModule)