WxExtLib - StatusValidators.h
00001: // -*- c++ -*-
00002: /*
00003: -------------------------------------------------------------------------
00004: This file is part of WxWidgetsExtensions library.
00005: -------------------------------------------------------------------------
00006:
00007: WxExtLib (WxWidgetsExtensions) library
00008: -----------------------------
00009:
00010: COPYRIGHT NOTICE:
00011:
00012: WxExtLib library Copyright (c) 2003-2007 Daniel Käps
00013:
00014: The WxWidgetsExtensions library and associated documentation files (the
00015: "Software") is provided "AS IS". The author(s) disclaim all
00016: warranties, expressed or implied, including, without limitation, the
00017: warranties of merchantability and of fitness for any purpose. The
00018: author(s) assume no liability for direct, indirect, incidental,
00019: special, exemplary, or consequential damages, which may result from
00020: the use of or other dealings in the Software, even if advised of the
00021: possibility of such damage.
00022:
00023: Permission is hereby granted, free of charge, to any person obtaining
00024: a copy of this Software, to deal in the Software without restriction,
00025: including without limitation the rights to use, copy, modify, merge,
00026: publish, distribute, sublicense, and/or sell copies of the Software,
00027: and to permit persons to whom the Software is furnished to do so,
00028: subject to the following conditions:
00029:
00030: 1. The origin of this source code must not be misrepresented.
00031: 2. Altered versions must be plainly marked as such and must not be
00032: misrepresented as being the original source.
00033: 3. This Copyright notice may not be removed or altered from any
00034: source or altered source distribution.
00035:
00036: End of WxExtLib library Copyright Notice
00037:
00038: -------------------------------------------------------------------------
00039: */
00040:
00041: #if (!defined M_StatusValidators_IsEmitGenericDeclarations)
00042:
00043: #ifndef _INCLUDED_StatusValidators_h
00044: #define _INCLUDED_StatusValidators_h
00045:
00046: #if defined(__GNUG__) && (!defined(__APPLE__)) && (!(defined M_NoPragmaInterface))
00047: # pragma interface "StatusValidators.h"
00048: #endif
00049:
00050: #include "WxExtLibConfig.h"
00051:
00052: #include <wx/defs.h>
00053:
00054: #ifndef WX_PRECOMP
00055: # include <wx/validate.h>
00056: # include <wx/textctrl.h>
00057: #endif
00058:
00059: #include <wx/valgen.h>
00060: #include <wx/datetime.h>
00061:
00062: #include "WxMisc.h"
00063:
00064: //-------------------------------------------------------------------------
00065:
00066: #define M_IsDefineExportMagic 1
00067: # include "WxExtLibAliases.h"
00068: #undef M_IsDefineExportMagic
00069:
00070: //-------------------------------------------------------------------------
00071:
00072: // wxStatusMessageTarget
00073: // - used to output status messages - normally directed to
00074: // a wxTextCtrl
00075: // - may also display a message box (can be enabled/disabled
00076: // with enableShowMessageBox())
00077: class wxStatusMessageTarget: public wxObject
00078: {
00079: DECLARE_DYNAMIC_CLASS(wxStatusMessageTarget)
00080: public:
00081:
00082: // constructors:
00083: // - ErrorMessageMultiLineText may be NULL and can be set later
00084: // by calling setOutput()
00085: wxStatusMessageTarget () ;
00086: wxStatusMessageTarget(wxMultiLineText * ErrorMessageMultiLineText,
00087: const wxString & NonErrorMessageString);
00088: wxStatusMessageTarget(const wxStatusMessageTarget& StatusMessageTarget);
00089:
00090: ~wxStatusMessageTarget();
00091:
00092: virtual wxObject *Clone() const { return new wxStatusMessageTarget(*this); }
00093: bool Copy(const wxStatusMessageTarget & StatusMessageTarget);
00094:
00095: //-- functions to set and display the error message to some status text output control
00096: // setMessage(): currently, the old message is replaced by the new message
00097: virtual void setMessage (const wxString & MessageString, bool IsError);
00098:
00099: virtual void display (wxWindow * ParentWindow);
00100: virtual void clear ();
00101:
00102: void enableShowMessageBox (bool IsShowMessageBoxEnabled);
00103: bool isShowMessageBoxEnabled ();
00104:
00105: void setStatusOutput (wxMultiLineText * ErrorMessageMultiLineText);
00106: void setNonErrorMessageString (const wxString & NonErrorMessageString);
00107:
00108: protected:
00109: wxMultiLineText * m_ErrorMessageMultiLineText;
00110: wxString m_NonErrorMessageString;
00111: wxString m_MessageString;
00112: bool m_IsError;
00113:
00114: bool m_IsShowMessageBoxEnabled;
00115: };
00116:
00117: //-------------------------------------------------------------------------
00118:
00119: // wxROGenericValidator: Read-Only GenericValidator
00120: // (ignores the text in the control - transfers only to the control, but not
00121: // from the control)
00122: class wxROGenericValidator: public wxGenericValidator
00123: {
00124: DECLARE_CLASS(wxROGenericValidator)
00125: public:
00126: // TODO: one could also provide constructors which take const VARTYPE pointers,
00127: // because the values won't be modified anyway
00128: wxROGenericValidator(bool* val);
00129: wxROGenericValidator(int* val);
00130: wxROGenericValidator(wxString* val);
00131: wxROGenericValidator(wxArrayInt* val);
00132:
00133: virtual wxObject *Clone() const { return new wxROGenericValidator(*this); }
00134:
00135: virtual bool Validate(wxWindow * WXUNUSED(parent)) { return true; }
00136: virtual bool TransferFromWindow() { return true; }
00137: };
00138:
00139: //-------------------------------------------------------------------------
00140:
00141: // wxTextCtrlStatusValidator:
00142: // - base class for validators (such as wxNumberValidator)
00143: // - immediate feedback of validity of entered text via
00144: // wxStatusMessageTarget
00145: class wxTextCtrlStatusValidator: public wxValidator
00146: {
00147: DECLARE_ABSTRACT_CLASS(wxTextCtrlStatusValidator)
00148: public:
00149: enum
00150: {
00151: IsEmptyAllowed = 0x01,
00152: IsFilterInputChars = 0x02 // currently unused
00153: };
00154:
00155: wxTextCtrlStatusValidator();
00156: wxTextCtrlStatusValidator(wxStatusMessageTarget * StatusMessageTarget,
00157: int Flags = 0);
00158: wxTextCtrlStatusValidator(const wxTextCtrlStatusValidator& TextCtrlStatusValidator);
00159:
00160: ~wxTextCtrlStatusValidator();
00161:
00162: bool Copy(const wxTextCtrlStatusValidator & TextCtrlStatusValidator);
00163:
00164: // overridable helper functions to get/set content of TextCtrl
00165: virtual void getTextCtrlContent (wxString & TextCtrlContentString);
00166: virtual void setTextCtrlContent (const wxString & TextCtrlContentString);
00167:
00168: // conversions to/from strings
00169: virtual void transferToWindow (wxString & TextCtrlContentString) = 0;
00170: virtual bool transferFromWindowTemporary (const wxString & TextCtrlContentString,
00171: wxString & ErrorMessageString,
00172: bool IsTextCtrlChangeEvent=false) = 0;
00173: virtual bool transferFromWindowPersistent (const wxString & TextCtrlContentString,
00174: wxString & ErrorMessageString) = 0;
00175:
00176: // function to display the error message to some status text output control
00177: virtual void showStatusMessage (const wxString & ErrorMessageString, bool IsError,
00178: wxWindow * ParentWindow);
00179:
00180: // validation and transfer to/from the control
00181: virtual bool Validate(wxWindow *parent);
00182: virtual bool TransferToWindow();
00183: virtual bool TransferFromWindow();
00184:
00185: // events to filter keystrokes and to show status message
00186: void OnChar(wxKeyEvent& Event);
00187: void OnTextChanged(wxCommandEvent& Event);
00188: void OnComboBoxSelected(wxCommandEvent& Event);
00189: void OnChoiceSelected(wxCommandEvent& Event);
00190:
00191: DECLARE_EVENT_TABLE()
00192:
00193: protected:
00194: wxStatusMessageTarget * m_StatusMessageTarget;
00195: int m_Flags;
00196: bool m_IsInsideOnTextChanged;
00197:
00198: bool checkValidator() const;
00199: };
00200:
00201: //-------------------------------------------------------------------------
00202:
00203: class wxTextCtrlStatusValidatorTrait
00204: {
00205: // DECLARE_ABSTRACT_CLASS(wxTraitedTextCtrlStatusValidator)
00206: public:
00207: virtual ~wxTextCtrlStatusValidatorTrait() { };
00208:
00209: virtual void convertToString (wxString & TextCtrlContentString) = 0;
00210: virtual bool convertFromStringTemporary (const wxString & TextCtrlContentString,
00211: wxString & ErrorMessageString,
00212: bool IsTextCtrlChangeEvent) = 0;
00213: virtual bool convertFromStringPersistent (const wxString & TextCtrlContentString,
00214: wxString & ErrorMessageString) = 0;
00215: };
00216:
00217: //-------------------------------------------------------------------------
00218:
00219: class wxTraitedTextCtrlStatusValidator: public wxTextCtrlStatusValidator
00220: {
00221: DECLARE_ABSTRACT_CLASS(wxTraitedTextCtrlStatusValidator)
00222: public:
00223: wxTraitedTextCtrlStatusValidator();
00224: wxTraitedTextCtrlStatusValidator(wxTextCtrlStatusValidatorTrait * TextCtrlStatusValidatorTrait,
00225: wxStatusMessageTarget * StatusMessageTarget,
00226: int Flags);
00227: wxTraitedTextCtrlStatusValidator(const wxTraitedTextCtrlStatusValidator& TraitedTextCtrlStatusValidator);
00228:
00229: ~wxTraitedTextCtrlStatusValidator();
00230:
00231: // virtual wxObject *Clone() const { return new wxTraitedTextCtrlStatusValidator(*this); }
00232: bool Copy(const wxTraitedTextCtrlStatusValidator & TraitedTextCtrlStatusValidator);
00233:
00234: // conversions to/from strings
00235: virtual void transferToWindow (wxString & TextCtrlContentString);
00236: virtual bool transferFromWindowTemporary (const wxString & TextCtrlContentString,
00237: wxString & ErrorMessageString,
00238: bool IsTextCtrlChangeEvent=false);
00239: virtual bool transferFromWindowPersistent (const wxString & TextCtrlContentString,
00240: wxString & ErrorMessageString);
00241:
00242: virtual void handleValidInput ();
00243:
00244: DECLARE_EVENT_TABLE()
00245:
00246: protected:
00247: wxTextCtrlStatusValidatorTrait * m_TextCtrlStatusValidatorTrait;
00248:
00249: bool checkValidator() const;
00250: };
00251:
00252: //-------------------------------------------------------------------------
00253:
00254: #define M_IsUndefExportMagic 1
00255: # include "WxExtLibAliases.h"
00256: #undef M_IsUndefExportMagic
00257:
00258: //=========================================================================
00259:
00260: #define M_StatusValidators_IsEmitGenericDeclarations
00261:
00262: //-------------------------------------------------------------------------
00263:
00264: // declare wxBasictypeValidatorTrait_wxInt16
00265: #define M_BasictypeValidatorTrait wxBasictypeValidatorTrait_wxInt16
00266: #define M_BasictypeValidatorTrait_Basictype wxInt16
00267: #define M_BasictypeValidatorTrait_ExportDecl M_WxExtLib_ExportDecl
00268: #include "StatusValidators.h"
00269: #undef M_BasictypeValidatorTrait
00270: #undef M_BasictypeValidatorTrait_Basictype
00271: #undef M_BasictypeValidatorTrait_ExportDecl
00272:
00273: // declare wxBasictypeValidatorTrait_wxUint16
00274: #define M_BasictypeValidatorTrait wxBasictypeValidatorTrait_wxUint16
00275: #define M_BasictypeValidatorTrait_Basictype wxUint16
00276: #define M_BasictypeValidatorTrait_ExportDecl M_WxExtLib_ExportDecl
00277: #include "StatusValidators.h"
00278: #undef M_BasictypeValidatorTrait
00279: #undef M_BasictypeValidatorTrait_Basictype
00280: #undef M_BasictypeValidatorTrait_ExportDecl
00281:
00282: // declare wxBasictypeValidatorTrait_wxInt32
00283: #define M_BasictypeValidatorTrait wxBasictypeValidatorTrait_wxInt32
00284: #define M_BasictypeValidatorTrait_Basictype wxInt32
00285: #define M_BasictypeValidatorTrait_ExportDecl M_WxExtLib_ExportDecl
00286: #include "StatusValidators.h"
00287: #undef M_BasictypeValidatorTrait
00288: #undef M_BasictypeValidatorTrait_Basictype
00289: #undef M_BasictypeValidatorTrait_ExportDecl
00290:
00291: // declare wxBasictypeValidatorTrait_wxUint32
00292: #define M_BasictypeValidatorTrait wxBasictypeValidatorTrait_wxUint32
00293: #define M_BasictypeValidatorTrait_Basictype wxUint32
00294: #define M_BasictypeValidatorTrait_ExportDecl M_WxExtLib_ExportDecl
00295: #include "StatusValidators.h"
00296: #undef M_BasictypeValidatorTrait
00297: #undef M_BasictypeValidatorTrait_Basictype
00298: #undef M_BasictypeValidatorTrait_ExportDecl
00299:
00300: // declare wxBasictypeValidatorTrait_short
00301: #define M_BasictypeValidatorTrait wxBasictypeValidatorTrait_short
00302: #define M_BasictypeValidatorTrait_Basictype short
00303: #define M_BasictypeValidatorTrait_ExportDecl M_WxExtLib_ExportDecl
00304: #include "StatusValidators.h"
00305: #undef M_BasictypeValidatorTrait
00306: #undef M_BasictypeValidatorTrait_Basictype
00307: #undef M_BasictypeValidatorTrait_ExportDecl
00308:
00309: // declare wxBasictypeValidatorTrait_ushort
00310: #define M_BasictypeValidatorTrait wxBasictypeValidatorTrait_ushort
00311: #define M_BasictypeValidatorTrait_Basictype unsigned short
00312: #define M_BasictypeValidatorTrait_ExportDecl M_WxExtLib_ExportDecl
00313: #include "StatusValidators.h"
00314: #undef M_BasictypeValidatorTrait
00315: #undef M_BasictypeValidatorTrait_Basictype
00316: #undef M_BasictypeValidatorTrait_ExportDecl
00317:
00318: // declare wxBasictypeValidatorTrait_int
00319: #define M_BasictypeValidatorTrait wxBasictypeValidatorTrait_int
00320: #define M_BasictypeValidatorTrait_Basictype int
00321: #define M_BasictypeValidatorTrait_ExportDecl M_WxExtLib_ExportDecl
00322: #include "StatusValidators.h"
00323: #undef M_BasictypeValidatorTrait
00324: #undef M_BasictypeValidatorTrait_Basictype
00325: #undef M_BasictypeValidatorTrait_ExportDecl
00326:
00327: // declare wxBasictypeValidatorTrait_uint
00328: #define M_BasictypeValidatorTrait wxBasictypeValidatorTrait_uint
00329: #define M_BasictypeValidatorTrait_Basictype unsigned int
00330: #define M_BasictypeValidatorTrait_ExportDecl M_WxExtLib_ExportDecl
00331: #include "StatusValidators.h"
00332: #undef M_BasictypeValidatorTrait
00333: #undef M_BasictypeValidatorTrait_Basictype
00334: #undef M_BasictypeValidatorTrait_ExportDecl
00335:
00336: // declare wxBasictypeValidatorTrait_long
00337: #define M_BasictypeValidatorTrait wxBasictypeValidatorTrait_long
00338: #define M_BasictypeValidatorTrait_Basictype long
00339: #define M_BasictypeValidatorTrait_ExportDecl M_WxExtLib_ExportDecl
00340: #include "StatusValidators.h"
00341: #undef M_BasictypeValidatorTrait
00342: #undef M_BasictypeValidatorTrait_Basictype
00343: #undef M_BasictypeValidatorTrait_ExportDecl
00344:
00345: // declare wxBasictypeValidatorTrait_ulong
00346: #define M_BasictypeValidatorTrait wxBasictypeValidatorTrait_ulong
00347: #define M_BasictypeValidatorTrait_Basictype unsigned long
00348: #define M_BasictypeValidatorTrait_ExportDecl M_WxExtLib_ExportDecl
00349: #include "StatusValidators.h"
00350: #undef M_BasictypeValidatorTrait
00351: #undef M_BasictypeValidatorTrait_Basictype
00352: #undef M_BasictypeValidatorTrait_ExportDecl
00353:
00354: // // CHECK wxFloat32 always is 'float', wxFloat64 always is 'double'? provide typedefs?
00355: // declare wxBasictypeValidatorTrait_wxFloat32
00356: #define M_BasictypeValidatorTrait wxBasictypeValidatorTrait_wxFloat32
00357: #define M_BasictypeValidatorTrait_Basictype wxFloat32
00358: #define M_BasictypeValidatorTrait_ExportDecl M_WxExtLib_ExportDecl
00359: #include "StatusValidators.h"
00360: #undef M_BasictypeValidatorTrait
00361: #undef M_BasictypeValidatorTrait_Basictype
00362: #undef M_BasictypeValidatorTrait_ExportDecl
00363:
00364: // declare wxBasictypeValidatorTrait_wxFloat64
00365: #define M_BasictypeValidatorTrait wxBasictypeValidatorTrait_wxFloat64
00366: #define M_BasictypeValidatorTrait_Basictype wxFloat64
00367: #define M_BasictypeValidatorTrait_ExportDecl M_WxExtLib_ExportDecl
00368: #include "StatusValidators.h"
00369: #undef M_BasictypeValidatorTrait
00370: #undef M_BasictypeValidatorTrait_Basictype
00371: #undef M_BasictypeValidatorTrait_ExportDecl
00372:
00373: // declare wxBasictypeValidatorTrait_wxStringBase
00374: #define M_BasictypeValidatorTrait wxBasictypeValidatorTrait_wxStringBase
00375: #define M_BasictypeValidatorTrait_Basictype wxString
00376: #define M_BasictypeValidatorTrait_ExportDecl M_WxExtLib_ExportDecl
00377: #include "StatusValidators.h"
00378: #undef M_BasictypeValidatorTrait
00379: #undef M_BasictypeValidatorTrait_Basictype
00380: #undef M_BasictypeValidatorTrait_ExportDecl
00381:
00382: // declare wxBasictypeValidatorTrait_wxDateTime
00383: #define M_BasictypeValidatorTrait wxBasictypeValidatorTrait_wxDateTime
00384: #define M_BasictypeValidatorTrait_Basictype wxDateTime
00385: #define M_BasictypeValidatorTrait_ExportDecl M_WxExtLib_ExportDecl
00386: #include "StatusValidators.h"
00387: #undef M_BasictypeValidatorTrait
00388: #undef M_BasictypeValidatorTrait_Basictype
00389: #undef M_BasictypeValidatorTrait_ExportDecl
00390:
00391: //-------------------------------------------------------------------------
00392:
00393: #undef M_StatusValidators_IsEmitGenericDeclarations
00394:
00395: //=========================================================================
00396:
00397: class wxBasictypeValidatorTrait_wxString
00398: : public wxBasictypeValidatorTrait_wxStringBase
00399: {
00400: public:
00401: #if 0
00402: // HACK repeat those flag values from wxTextCtrlStatusValidatorTrait classes
00403: // for ease of use
00404: enum
00405: {
00406: // repeated flags:
00407: IsEmptyAllowed = 0x01,
00408: /* IsFilterInputChars = 0x02 // currently unused */
00409: IsWritebackToCopy = 0x04,
00410: IsReadFromCopy = 0x08,
00411: IsIgnoreMinimum = 0x10,
00412: IsIgnoreMaximum = 0x20,
00413: IsNoTrimRight = 0x40,
00414: IsNoTrimLeft = 0x80,
00415: IsNoTrim = 0xc0 /* == IsNoTrimRight | IsNoTrimLeft */
00416: };
00417: #endif
00418:
00419: wxBasictypeValidatorTrait_wxString();
00420:
00421: // setMinStringLength()
00422: // - default is 0
00423: void setMinStringLength (int MinStringLength);
00424: // setMaxStringLength()
00425: // - MaxStringLength == -1 means unlimited length
00426: // - default is -1
00427: void setMaxStringLength (int MaxStringLength);
00428:
00429: void setAllowedInputCharset (const wxString & CharsetString);
00430: // given charset description is included in error messages when input
00431: // is incorrect
00432: void setAllowedInputCharsetDescription (const wxString & CharsetDescriptionString);
00433:
00434: // override this function already defined in base class to add further
00435: // checks on string length
00436: virtual bool convertFromStringHelper (const wxString & TextCtrlContentString,
00437: wxString * TrimmedInputStringPtr,
00438: wxString & ErrorMessageString);
00439:
00440: virtual void getErrorMessageString (wxString & ErrorMessageString);
00441:
00442: private:
00443: int m_MinStringLength;
00444: int m_MaxStringLength;
00445:
00446: wxString m_AllowedCharsetString;
00447: wxString m_AllowedCharsetDescriptionString;
00448: };
00449:
00450: //=========================================================================
00451:
00452: #define M_IsDefineExportMagic 1
00453: # include "WxExtLibAliases.h"
00454: #undef M_IsDefineExportMagic
00455:
00456: //-------------------------------------------------------------------------
00457:
00458: // NOTE wxNumberValidatorVariant could be possibly replaced by wxVariant (which
00459: // is much more powerful), but wxVariant possibly has poorer performance
00460: // (maybe it is better to add a wxVariant type to wxNumberValidatorVariant)
00461: class wxNumberValidatorVariant
00462: {
00463: public:
00464: wxNumberValidatorVariant ();
00465:
00466: enum EType { UndefinedType, LongType, DoubleType /*, VariantType */ };
00467:
00468: bool getIsLong () const;
00469: bool getIsDouble () const;
00470:
00471: long getLong () const;
00472: double getDouble () const;
00473: void getLong (long * Long) const;
00474: void getDouble (double * Double) const;
00475: void setLong (long Long);
00476: void setDouble (const double & Double);
00477:
00478: bool operator== (const wxNumberValidatorVariant & Variant) const;
00479:
00480: private:
00481: EType m_Type;
00482:
00483: // (variables of different types could be made part of a union)
00484: long m_Long;
00485: double m_Double;
00486: };
00487:
00488: //-------------------------------------------------------------------------
00489:
00490: // wxNumberValidator
00491: // - support for integer, long or double type values
00492: // - values are checked if they are within the specified range
00493: // [Min, Max]
00494: // - immediate feedback is given to the user via the associated
00495: // wxStatusMessageTarget if string entered in the wxTextCtrl
00496: // doesn't represent a valid input
00497: // - support for 'Undefined value':
00498: // - A special value may be choosen to (internally) indicate that
00499: // the value is 'Undefined' (or 'unset').
00500: // - To use it, the "IsEmptyAllowed" flag must be set.
00501: // - The Undefined value is printed as empty string. The user
00502: // can enter the Undefined value by leaving the wxTextCtrl empty.
00503: // - Note: the Undefined value should be, of course, outside
00504: // the range [Min, Max] of valid values.
00505: class wxNumberValidator: public wxTraitedTextCtrlStatusValidator
00506: {
00507: DECLARE_DYNAMIC_CLASS(wxNumberValidator)
00508: public:
00509: // HACK repeat those flag values from wxTextCtrlStatusValidatorTrait classes
00510: // for ease of use
00511: enum
00512: {
00513: IsEmptyAllowed = 0x01,
00514: /* IsFilterInputChars = 0x02 // currently unused */
00515: IsWritebackToCopy = 0x04,
00516: IsReadFromCopy = 0x08,
00517: IsIgnoreMinimum = 0x10,
00518: IsIgnoreMaximum = 0x20,
00519: IsNoTrimRight = 0x40,
00520: IsNoTrimLeft = 0x80,
00521: IsNoTrim = 0xc0 /* == IsNoTrimRight | IsNoTrimLeft */
00522: };
00523:
00524: wxNumberValidator();
00525: wxNumberValidator(int * IntegerValue, int MinInteger, int MaxInteger,
00526: wxStatusMessageTarget * StatusMessageTarget,
00527: const wxString & FieldNameString,
00528: int Flags = 0, int UndefinedInteger = 0);
00529: wxNumberValidator(long * LongValue, long MinLong, long MaxLong,
00530: wxStatusMessageTarget * StatusMessageTarget,
00531: const wxString & FieldNameString,
00532: int Flags = 0, long UndefinedLong = 0);
00533: wxNumberValidator(double * DoubleValue, double MinDouble, double MaxDouble,
00534: wxStatusMessageTarget * StatusMessageTarget,
00535: const wxString & FieldNameString,
00536: int Flags = 0,
00537: const wxString & FormatString = "%f",
00538: double UndefinedDouble = 0.);
00539: wxNumberValidator(const wxNumberValidator& NumberValidator);
00540:
00541: ~wxNumberValidator();
00542:
00543: virtual wxObject *Clone() const { return new wxNumberValidator(*this); }
00544: bool Copy(const wxNumberValidator & NumberValidator);
00545:
00546: // some helper functions
00547:
00548: DECLARE_EVENT_TABLE()
00549:
00550: protected:
00551: wxBasictypeValidatorTrait_int m_IntBasictypeValidatorTrait;
00552: wxBasictypeValidatorTrait_long m_LongBasictypeValidatorTrait;
00553: wxBasictypeValidatorTrait_wxFloat64 m_DoubleBasictypeValidatorTrait;
00554: };
00555:
00556: //-------------------------------------------------------------------------
00557:
00558: #define M_IsUndefExportMagic 1
00559: # include "WxExtLibAliases.h"
00560: #undef M_IsUndefExportMagic
00561:
00562: //=========================================================================
00563:
00564: #define M_StatusValidators_IsEmitGenericDeclarations
00565:
00566: //-------------------------------------------------------------------------
00567:
00568: // declare wxTraitedIntValidator
00569: #define M_TraitedTextCtrlStatusValidatorImpl wxTraitedIntValidator
00570: #define M_TraitedTextCtrlStatusValidatorImpl_BasictypeValidatorTrait wxBasictypeValidatorTrait_int
00571: #define M_TraitedTextCtrlStatusValidatorImpl_Basictype int
00572: #define M_TraitedTextCtrlStatusValidatorImpl_ExportDecl M_WxExtLib_ExportDecl
00573: #include "StatusValidators.h"
00574: #undef M_TraitedTextCtrlStatusValidatorImpl
00575: #undef M_TraitedTextCtrlStatusValidatorImpl_BasictypeValidatorTrait
00576: #undef M_TraitedTextCtrlStatusValidatorImpl_Basictype
00577: #undef M_TraitedTextCtrlStatusValidatorImpl_ExportDecl
00578:
00579: // declare wxTraitedUintValidator
00580: #define M_TraitedTextCtrlStatusValidatorImpl wxTraitedUintValidator
00581: #define M_TraitedTextCtrlStatusValidatorImpl_BasictypeValidatorTrait wxBasictypeValidatorTrait_uint
00582: #define M_TraitedTextCtrlStatusValidatorImpl_Basictype unsigned int
00583: #define M_TraitedTextCtrlStatusValidatorImpl_ExportDecl M_WxExtLib_ExportDecl
00584: #include "StatusValidators.h"
00585: #undef M_TraitedTextCtrlStatusValidatorImpl
00586: #undef M_TraitedTextCtrlStatusValidatorImpl_BasictypeValidatorTrait
00587: #undef M_TraitedTextCtrlStatusValidatorImpl_Basictype
00588: #undef M_TraitedTextCtrlStatusValidatorImpl_ExportDecl
00589:
00590: // declare wxTraitedLongValidator
00591: #define M_TraitedTextCtrlStatusValidatorImpl wxTraitedLongValidator
00592: #define M_TraitedTextCtrlStatusValidatorImpl_BasictypeValidatorTrait wxBasictypeValidatorTrait_long
00593: #define M_TraitedTextCtrlStatusValidatorImpl_Basictype long
00594: #define M_TraitedTextCtrlStatusValidatorImpl_ExportDecl M_WxExtLib_ExportDecl
00595: #include "StatusValidators.h"
00596: #undef M_TraitedTextCtrlStatusValidatorImpl
00597: #undef M_TraitedTextCtrlStatusValidatorImpl_BasictypeValidatorTrait
00598: #undef M_TraitedTextCtrlStatusValidatorImpl_Basictype
00599: #undef M_TraitedTextCtrlStatusValidatorImpl_ExportDecl
00600:
00601: // declare wxTraitedUlongValidator
00602: #define M_TraitedTextCtrlStatusValidatorImpl wxTraitedUlongValidator
00603: #define M_TraitedTextCtrlStatusValidatorImpl_BasictypeValidatorTrait wxBasictypeValidatorTrait_ulong
00604: #define M_TraitedTextCtrlStatusValidatorImpl_Basictype unsigned long
00605: #define M_TraitedTextCtrlStatusValidatorImpl_ExportDecl M_WxExtLib_ExportDecl
00606: #include "StatusValidators.h"
00607: #undef M_TraitedTextCtrlStatusValidatorImpl
00608: #undef M_TraitedTextCtrlStatusValidatorImpl_BasictypeValidatorTrait
00609: #undef M_TraitedTextCtrlStatusValidatorImpl_Basictype
00610: #undef M_TraitedTextCtrlStatusValidatorImpl_ExportDecl
00611:
00612: // declare wxTraitedStringValidatorBase
00613: #define M_TraitedTextCtrlStatusValidatorImpl wxTraitedStringValidatorBase
00614: #define M_TraitedTextCtrlStatusValidatorImpl_BasictypeValidatorTrait wxBasictypeValidatorTrait_wxString
00615: #define M_TraitedTextCtrlStatusValidatorImpl_Basictype wxString
00616: #define M_TraitedTextCtrlStatusValidatorImpl_ExportDecl M_WxExtLib_ExportDecl
00617: #include "StatusValidators.h"
00618: #undef M_TraitedTextCtrlStatusValidatorImpl
00619: #undef M_TraitedTextCtrlStatusValidatorImpl_BasictypeValidatorTrait
00620: #undef M_TraitedTextCtrlStatusValidatorImpl_Basictype
00621: #undef M_TraitedTextCtrlStatusValidatorImpl_ExportDecl
00622:
00623: // declare wxTraitedDateTimeValidatorBase
00624: #define M_TraitedTextCtrlStatusValidatorImpl wxTraitedDateTimeValidatorBase
00625: #define M_TraitedTextCtrlStatusValidatorImpl_BasictypeValidatorTrait wxBasictypeValidatorTrait_wxDateTime
00626: #define M_TraitedTextCtrlStatusValidatorImpl_Basictype wxDateTime
00627: #define M_TraitedTextCtrlStatusValidatorImpl_ExportDecl M_WxExtLib_ExportDecl
00628: #include "StatusValidators.h"
00629: #undef M_TraitedTextCtrlStatusValidatorImpl
00630: #undef M_TraitedTextCtrlStatusValidatorImpl_BasictypeValidatorTrait
00631: #undef M_TraitedTextCtrlStatusValidatorImpl_Basictype
00632: #undef M_TraitedTextCtrlStatusValidatorImpl_ExportDecl
00633:
00634: //-------------------------------------------------------------------------
00635:
00636: #undef M_StatusValidators_IsEmitGenericDeclarations
00637:
00638:
00639: // // TEST
00640: // DECLARE_CLASS_wxTraitedTextCtrlStatusValidatorImpl(wxTraitedStringValidatorBase,
00641: // wxBasictypeValidatorTrait_wxStringBase, wxString)
00642:
00643: //=========================================================================
00644:
00645: #define M_IsDefineExportMagic 1
00646: # include "WxExtLibAliases.h"
00647: #undef M_IsDefineExportMagic
00648:
00649: //-------------------------------------------------------------------------
00650:
00651: // wxRONumberValidator: Read-Only NumberValidator
00652: // (ignores input made into the wxTextCtrl - transfers only to the window,
00653: // not back)
00654: class wxRONumberValidator: public wxNumberValidator
00655: {
00656: DECLARE_DYNAMIC_CLASS(wxRONumberValidator)
00657: public:
00658:
00659: wxRONumberValidator ();
00660: wxRONumberValidator (int * IntegerValue,
00661: int Flags = 0, int UndefinedInteger = 0);
00662: wxRONumberValidator (long * LongValue,
00663: int Flags = 0, int UndefinedLong = 0);
00664:
00665: virtual wxObject *Clone() const { return new wxRONumberValidator(*this); }
00666:
00667: // no validation shall be made for window content
00668: virtual bool Validate(wxWindow * WXUNUSED(ParentWindow)) { return true; }
00669: // no data shall be transferred from the window
00670: virtual bool TransferFromWindow() { return true; }
00671:
00672: };
00673:
00674: //-------------------------------------------------------------------------
00675:
00676: class wxTraitedStringValidator: public wxTraitedStringValidatorBase
00677: {
00678: DECLARE_DYNAMIC_CLASS(wxTraitedStringValidator)
00679: public:
00680: wxTraitedStringValidator ();
00681: wxTraitedStringValidator(wxString * StringPtr,
00682: wxStatusMessageTarget * StatusMessageTarget,
00683: const wxString & FieldNameString,
00684: int MaxStringLength = -1,
00685: int Flags = 0,
00686: const wxString & UndefinedString = wxEmptyString);
00687: virtual ~wxTraitedStringValidator() { };
00688: wxTraitedStringValidator(const wxTraitedStringValidator& TraitedTextCtrlStatusValidatorImpl);
00689:
00690: virtual wxObject *Clone() const { return new wxTraitedStringValidator(*this); }
00691: bool Copy(const wxTraitedStringValidator & TraitedStringValidator);
00692:
00693: DECLARE_EVENT_TABLE()
00694: protected:
00695: };
00696:
00697: //-------------------------------------------------------------------------
00698:
00699: typedef wxTraitedStringValidator wxStringValidator;
00700:
00701: //-------------------------------------------------------------------------
00702:
00703: // wxTraitedDateTimeValidator:
00704: // - validate from/to wxDateTime using specified date/time format
00705: // string (defaulting to a simple ISO style date/time)
00706: class wxTraitedDateTimeValidator: public wxTraitedDateTimeValidatorBase
00707: {
00708: DECLARE_DYNAMIC_CLASS(wxTraitedDateTimeValidator)
00709: public:
00710: // - default for DateTimeFormatString (if empty):
00711: // ISO date and time ("%Y-%m-%d %H:%M:%S)
00712: wxTraitedDateTimeValidator ();
00713: wxTraitedDateTimeValidator(wxDateTime * DateTimePtr,
00714: wxStatusMessageTarget * StatusMessageTarget,
00715: const wxString & FieldNameString,
00716: int Flags = 0,
00717: const wxString & DateTimeFormatString = wxEmptyString);
00718: wxTraitedDateTimeValidator (wxDateTime * DateTimePtr,
00719: wxDateTime MinDateTime, wxDateTime MaxDateTime,
00720: wxStatusMessageTarget * StatusMessageTarget,
00721: const wxString & FieldNameString,
00722: int Flags, wxDateTime UndefinedDateTime,
00723: const wxString & DateTimeFormatString = wxEmptyString);
00724:
00725: virtual ~wxTraitedDateTimeValidator() { };
00726: wxTraitedDateTimeValidator(const wxTraitedDateTimeValidator& TraitedTextCtrlStatusValidatorImpl);
00727:
00728: virtual wxObject *Clone() const { return new wxTraitedDateTimeValidator(*this); }
00729: bool Copy(const wxTraitedDateTimeValidator & TraitedDateTimeValidator);
00730:
00731: DECLARE_EVENT_TABLE()
00732: protected:
00733: };
00734:
00735: //-------------------------------------------------------------------------
00736:
00737: typedef wxTraitedDateTimeValidator wxDateTimeValidator;
00738:
00739: //-------------------------------------------------------------------------
00740:
00741: // wxNonTraitedDateTimeValidator
00742: // - currently can be used for date input/output only (without time)
00743: // - for problem of day-month/month-day order of wxDateTime depending
00744: // on the locale see notes in the source code
00745: class wxNonTraitedDateTimeValidator: public wxTextCtrlStatusValidator
00746: {
00747: DECLARE_DYNAMIC_CLASS(wxNonTraitedDateTimeValidator)
00748: public:
00749: wxNonTraitedDateTimeValidator();
00750: wxNonTraitedDateTimeValidator(wxDateTime * DateTimeValue,
00751: wxStatusMessageTarget * StatusMessageTarget,
00752: const wxString & FieldNameString,
00753: int Flags = 0);
00754: wxNonTraitedDateTimeValidator(const wxNonTraitedDateTimeValidator& NonTraitedDateTimeValidator);
00755: ~wxNonTraitedDateTimeValidator();
00756:
00757: virtual wxObject *Clone() const { return new wxNonTraitedDateTimeValidator(*this); }
00758: bool Copy(const wxNonTraitedDateTimeValidator & NonTraitedDateTimeValidator);
00759:
00760: // conversions to/from strings
00761: virtual void transferToWindow (wxString & TextCtrlContentString);
00762: virtual bool transferFromWindowTemporary (const wxString & TextCtrlContentString,
00763: wxString & ErrorMessageString,
00764: bool IsTextCtrlChangeEvent=false);
00765: virtual bool transferFromWindowPersistent (const wxString & TextCtrlContentString,
00766: wxString & ErrorMessageString);
00767:
00768: // some helper functions
00769: virtual void transferToWindowHelper (const wxDateTime & DateTime,
00770: wxString & TextCtrlContentString);
00771: virtual bool transferFromWindowHelper (const wxString & TextCtrlContentString,
00772: wxDateTime * DateTime, wxString & ErrorMessageString);
00773: // checkValue() might be overwritten to do further checks
00774: virtual bool checkValue (const wxDateTime & DateTime);
00775: virtual void getErrorMessageString (const wxDateTime & DateTime, wxString & ErrorMessageString);
00776:
00777: virtual void handleValidInput (const wxDateTime & DateTime);
00778:
00779: DECLARE_EVENT_TABLE()
00780:
00781: protected:
00782: wxDateTime * m_DateTimeValue;
00783: wxString m_FieldNameString;
00784: };
00785:
00786: //-------------------------------------------------------------------------
00787:
00788: // wxNonTraitedStringValidator
00789: // - NOTE: this class is superseeded by wxTraitedStringValidator,
00790: // which is now aliased as wxStringValidator
00791: class wxNonTraitedStringValidator: public wxTextCtrlStatusValidator
00792: {
00793: DECLARE_DYNAMIC_CLASS(wxNonTraitedStringValidator)
00794: public:
00795: wxNonTraitedStringValidator();
00796: // DEF MaxStringLength == -1 to indicate an unlimited string length
00797: wxNonTraitedStringValidator(wxString * StringValue,
00798: wxStatusMessageTarget * StatusMessageTarget,
00799: const wxString & FieldNameString,
00800: int MaxStringLength = -1,
00801: int Flags = 0,
00802: const wxString & UndefinedString = wxEmptyString);
00803: wxNonTraitedStringValidator(const wxNonTraitedStringValidator& StringValidator);
00804:
00805: ~wxNonTraitedStringValidator();
00806:
00807: virtual wxObject *Clone() const { return new wxNonTraitedStringValidator(*this); }
00808: bool Copy (const wxNonTraitedStringValidator & StringValidator);
00809:
00810: // conversions to/from strings
00811: virtual void transferToWindow (wxString & TextCtrlContentString);
00812: virtual bool transferFromWindowTemporary (const wxString & TextCtrlContentString,
00813: wxString & ErrorMessageString,
00814: bool IsTextCtrlChangeEvent=false);
00815: virtual bool transferFromWindowPersistent (const wxString & TextCtrlContentString,
00816: wxString & ErrorMessageString);
00817:
00818: // some helper functions
00819: virtual void transferToWindowHelper (const wxString & String,
00820: wxString & TextCtrlContentString);
00821: virtual bool transferFromWindowHelper (const wxString & TextCtrlContentString,
00822: wxString * String, wxString & ErrorMessageString);
00823: virtual bool checkValue (const wxString & String);
00824: virtual void getErrorMessageString (const wxString & String,
00825: wxString & ErrorMessageString);
00826:
00827: virtual void handleValidInput (const wxString & String);
00828:
00829: DECLARE_EVENT_TABLE()
00830:
00831: protected:
00832: wxString * m_StringValue;
00833: wxString m_FieldNameString;
00834: int m_MaxStringLength;
00835: wxString m_UndefinedString;
00836: };
00837:
00838: //=========================================================================
00839:
00840: class wxFilenameValidatorTrait : public wxBasictypeValidatorTrait_wxString
00841: {
00842: /* DECLARE_ABSTRACT_CLASS(wxFilenameValidatorTrait) */
00843: public:
00844: enum
00845: {
00846: /* not yet supported: IsNoImmediateCheck = 0x01, */
00847: IsNormalize = 0x02,
00848: IsStoreRelative = 0x04,
00849: IsStoreNoRelativeParentDir = 0x08,
00850: /* IsShowRelative = 0x10, */
00851: /* IsShowNoRelativeParentDir = 0x20, */
00852:
00853: IsErrorIfInvalid = 0x0100,
00854: IsErrorIfNotFile = 0x0200,
00855: /* IsErrorIfExisting = 0x0400, */
00856: /* IsErrorIfDirectory = 0x0800, */
00857: IsErrorIfNotDirectory = 0x1000
00858: };
00859:
00860: wxFilenameValidatorTrait ();
00861: /* wxFilenameValidatorTrait (wxString * FilenameStringPtr,
00862: const wxString & FieldNameString,
00863: int BasictypeValidatorTraitFlags,
00864: int FilenameValidatorTraitFlags,
00865: const wxString & UndefinedFilenameString); */
00866: void init (wxString * FilenameStringPtr,
00867: const wxString & FieldNameString,
00868: int BasictypeValidatorTraitFlags,
00869: int FilenameValidatorTraitFlags,
00870: const wxString & RelativeRefPathString,
00871: int NormalizeFlags);
00872: // next init() function is required to make this class work with
00873: // wxTraitedTextCtrlStatusValidatorImpl:
00874: void init (wxString * BasictypeValuePtr, wxString MinBasictype, wxString MaxBasictype,
00875: const wxString & FieldNameString,
00876: int Flags, wxString UndefinedBasictype,
00877: const wxString & FormatString = wxEmptyString);
00878: virtual ~wxFilenameValidatorTrait() { };
00879:
00880: bool convertFromStringHelper (const wxString & TextCtrlContentString,
00881: wxString * FilenameStringPtr,
00882: wxString & ErrorMessageString);
00883:
00884: /* protected: */
00885: int m_FilenameValidatorTraitFlags;
00886: wxString m_RelativeRefPathString;
00887: int m_NormalizeFlags;
00888: };
00889:
00890: //-------------------------------------------------------------------------
00891:
00892: #define M_IsUndefExportMagic 1
00893: # include "WxExtLibAliases.h"
00894: #undef M_IsUndefExportMagic
00895:
00896: //=========================================================================
00897:
00898: #define M_StatusValidators_IsEmitGenericDeclarations
00899:
00900: // declare wxFilenameValidatorBase
00901: #define M_TraitedTextCtrlStatusValidatorImpl wxFilenameValidatorBase
00902: #define M_TraitedTextCtrlStatusValidatorImpl_BasictypeValidatorTrait wxFilenameValidatorTrait
00903: #define M_TraitedTextCtrlStatusValidatorImpl_Basictype wxString
00904: #define M_TraitedTextCtrlStatusValidatorImpl_ExportDecl M_WxExtLib_ExportDecl
00905: #include "StatusValidators.h"
00906: #undef M_TraitedTextCtrlStatusValidatorImpl
00907: #undef M_TraitedTextCtrlStatusValidatorImpl_BasictypeValidatorTrait
00908: #undef M_TraitedTextCtrlStatusValidatorImpl_Basictype
00909: #undef M_TraitedTextCtrlStatusValidatorImpl_ExportDecl
00910:
00911: #undef M_StatusValidators_IsEmitGenericDeclarations
00912:
00913: // DECLARE_CLASS_wxTraitedTextCtrlStatusValidatorImpl(wxFilenameValidatorBase,
00914: // wxFilenameValidatorTrait, wxString)
00915:
00916: //=========================================================================
00917:
00918: #define M_IsDefineExportMagic 1
00919: # include "WxExtLibAliases.h"
00920: #undef M_IsDefineExportMagic
00921:
00922: //-------------------------------------------------------------------------
00923:
00924: // wxFilenameValidator:
00925: // - support validation of file or directory names, with
00926: // optional checks for existence/non-existence in file system
00927: // and from/to relative/absolute path resolution
00928: class wxFilenameValidator: public wxFilenameValidatorBase
00929: {
00930: DECLARE_DYNAMIC_CLASS(wxFilenameValidator)
00931: public:
00932: wxFilenameValidator ();
00933: wxFilenameValidator (wxString * FilenameStringPtr,
00934: wxStatusMessageTarget * StatusMessageTarget,
00935: const wxString & FieldNameString,
00936: int BasictypeValidatorTraitFlags,
00937: int FilenameValidatorTraitFlags,
00938: const wxString & RelativeRefPathString,
00939: int NormalizeFlags);
00940: virtual ~wxFilenameValidator() { };
00941: wxFilenameValidator(const wxFilenameValidator& TraitedTextCtrlStatusValidatorImpl);
00942:
00943: virtual wxObject *Clone() const { return new wxFilenameValidator(*this); }
00944: bool Copy(const wxFilenameValidator & FilenameValidator);
00945:
00946: DECLARE_EVENT_TABLE()
00947: protected:
00948: };
00949:
00950: //=========================================================================
00951:
00952: extern void wxBasictypeValidatorTrait_convertULongToString (const char * WXUNUSED(FormatString),
00953: unsigned long ULong,
00954: wxString & String);
00955: extern void wxBasictypeValidatorTrait_convertLongToString (const char * WXUNUSED(FormatString),
00956: long Long,
00957: wxString & String);
00958: extern void wxBasictypeValidatorTrait_convertDoubleToString (const char * FormatString,
00959: double Double,
00960: wxString & String);
00961:
00962: //-------------------------------------------------------------------------
00963:
00964: extern bool wxBasictypeValidatorTrait_convertStringToLong (const char * WXUNUSED(DefaultScanfString),
00965: const wxString & TrimmedString,
00966: long & Long);
00967: extern bool wxBasictypeValidatorTrait_convertStringToULong (const char * WXUNUSED(DefaultScanfString),
00968: const wxString & TrimmedString,
00969: unsigned long & ULong);
00970: extern bool wxBasictypeValidatorTrait_convertStringToString (const char * WXUNUSED(DefaultScanfString),
00971: const wxString & TrimmedInputString,
00972: wxString & OutputString);
00973: extern bool wxBasictypeValidatorTrait_convertStringToFloat (const char * WXUNUSED(DefaultScanfString),
00974: const wxString & TrimmedInputString,
00975: float & Float);
00976: extern bool wxBasictypeValidatorTrait_convertStringToDouble (const char * WXUNUSED(DefaultScanfString), double,
00977: const wxString & TrimmedInputString,
00978: double & Double);
00979:
00980: extern bool wxBasictypeValidatorTrait_convertStringToWxInt16 (const char * WXUNUSED(DefaultScanfString),
00981: const wxString & TrimmedInputString,
00982: wxInt16 & Int16);
00983: extern bool wxBasictypeValidatorTrait_convertStringToWxUint16 (const char * WXUNUSED(DefaultScanfString),
00984: const wxString & TrimmedInputString,
00985: wxUint16 & Uint16);
00986: extern bool wxBasictypeValidatorTrait_convertStringToWxInt32 (const char * WXUNUSED(DefaultScanfString),
00987: const wxString & TrimmedInputString,
00988: wxInt32 & Int32);
00989: extern bool wxBasictypeValidatorTrait_convertStringToWxUint32 (const char * WXUNUSED(DefaultScanfString),
00990: const wxString & TrimmedInputString,
00991: wxUint32 & Uint32);
00992:
00993: extern bool wxBasictypeValidatorTrait_convertStringToShort (const char * WXUNUSED(DefaultScanfString),
00994: const wxString & TrimmedInputString,
00995: short & Short);
00996: extern bool wxBasictypeValidatorTrait_convertStringToUShort (const char * WXUNUSED(DefaultScanfString),
00997: const wxString & TrimmedInputString,
00998: unsigned short & Ushort);
00999: extern bool wxBasictypeValidatorTrait_convertStringToInt (const char * WXUNUSED(DefaultScanfString),
01000: const wxString & TrimmedInputString,
01001: int & Int);
01002: extern bool wxBasictypeValidatorTrait_convertStringToUInt (const char * WXUNUSED(DefaultScanfString),
01003: const wxString & TrimmedInputString,
01004: unsigned int & Uint);
01005:
01006: //-------------------------------------------------------------------------
01007:
01008: class wxComboBox;
01009:
01010: extern void updateComboBoxSelectionFromText (wxComboBox * ComboBox,
01011: const wxString & TextCtrlString, bool IsForce);
01012:
01013: //-------------------------------------------------------------------------
01014:
01015: // set focus to specified Window and activate (set selection to) book-pages
01016: // of any parents which are of type wxBookCtrl (wxNotebook for wx < 2.5.0)
01017: extern void setFocusAndSelectParentBookPages (wxWindow * Window);
01018:
01019: //-------------------------------------------------------------------------
01020:
01021: // helper functions
01022: // since TransferDataToWindow() and TransferFromWindow() only validate
01023: // child windows of specified window
01024: extern void transferDataToControl (wxWindow * Window);
01025: extern bool validateControl (wxWindow * Window);
01026: extern bool transferDataFromControl (wxWindow * Window);
01027:
01028: //=========================================================================
01029:
01030: /* pick up macro definitions from implementation file:
01031: available macro definitions:
01032:
01033: IMPLEMENT_CLASS_wxBasictypeValidatorTrait(TClassname,TBasictype,DefaultFormatString,
01034: DefaultScanfString,PrintCommand,ParseCommand)
01035:
01036: IMPLEMENT_CLASS_wxTraitedTextCtrlStatusValidatorImpl(TClassname,TBasictypeValidatorTrait,TBasictype)
01037:
01038: // to "instatiate" the macros without compilation problems, inclusion of
01039: // following headers may be required (see included headers in .cpp files)
01040: //
01041: // For compilers that support precompilation, includes "wx.h".
01042: // #include "wx/wxprec.h"
01043: //
01044: // #ifdef __BORLANDC__
01045: // #pragma hdrstop
01046: // #endif
01047: //
01048: // #ifndef WX_PRECOMP
01049: // // WARN removed stdio.h - it should not be required (or may be it is required?)
01050: // // maybe it doesn't hurt
01051: // #include <stdio.h>
01052: // #include "wx/textctrl.h"
01053: // #include "wx/utils.h"
01054: // #include "wx/msgdlg.h"
01055: // #include "wx/intl.h"
01056: // #endif
01057:
01058: */
01059: //#ifndef _TEMPLATEINCLUDE_StatusValidators_cpp
01060: //# define _TEMPLATEINCLUDE_StatusValidators_cpp
01061: //# include "StatusValidators.cpp"
01062: //# undef _TEMPLATEINCLUDE_StatusValidators_cpp
01063: //#endif
01064:
01065: //-------------------------------------------------------------------------
01066:
01067: #define M_IsUndefExportMagic 1
01068: # include "WxExtLibAliases.h"
01069: #undef M_IsUndefExportMagic
01070:
01071: //=========================================================================
01072:
01073: #endif // _INCLUDED_StringValidator_h
01074:
01075: //=========================================================================
01076:
01077: #else // !defined M_StatusValidators_IsEmitGenericDeclarations
01078:
01079: //=========================================================================
01080:
01081: #define M_IsDefinePPMacros 1
01082: # include "pp_basics.h"
01083: // #undef M_IsDefinePPMacros
01084:
01085: //-------------------------------------------------------------------------
01086:
01087: #if (defined M_BasictypeValidatorTrait)
01088:
01089: // define a few shortcuts
01090: #define M_Basictype M_BasictypeValidatorTrait_Basictype
01091:
01092: //-------------------------------------------------------------------------
01093:
01094: // M_BasictypeValidatorTrait
01095: // - trait class for use with wxTraitedTextCtrlStatusValidator
01096: // and related classes
01097: // possible improvements:
01098: // - add change-indication flags (for Touched, Modified) (or alternatively,
01099: // add function getIsModified() which compares against m_CopyBasictype
01100: // or *m_BasictypeValuePtr)
01101: // - however, Touched state can be obtained quite easy too by overriding
01102: // handleWatchedControlChange() and using wxWindowAdder::setIsWatchControl()
01103: class M_BasictypeValidatorTrait_ExportDecl M_BasictypeValidatorTrait : public wxTextCtrlStatusValidatorTrait
01104: {
01105: /* DECLARE_ABSTRACT_CLASS(M_BasictypeValidatorTrait) */
01106: public:
01107: enum
01108: {
01109: IsEmptyAllowed = 0x01,
01110: /* IsFilterInputChars = 0x02 // currently unused */
01111: IsWritebackToCopy = 0x04,
01112: IsReadFromCopy = 0x08,
01113: IsIgnoreMinimum = 0x10,
01114: IsIgnoreMaximum = 0x20,
01115: IsNoTrimLeft = 0x40,
01116: IsNoTrimRight = 0x80,
01117: IsNoTrim = 0xc0 /* == IsNoTrimLeft | IsNoTrimRight */
01118: };
01119:
01120: M_BasictypeValidatorTrait ();
01121: M_BasictypeValidatorTrait (M_Basictype * BasictypeValuePtr, M_Basictype MinBasictype, M_Basictype MaxBasictype,
01122: const wxString & FieldNameString,
01123: int Flags, M_Basictype UndefinedBasictype,
01124: const wxString & FormatString = wxEmptyString);
01125: /* the constructor taking a reference to current value (instead of pointer to non-const)
01126: has automatically the IsWritebackToCopy and IsReadFromCopy flags set. Some care must be
01127: taken to call the desired constructor */
01128: M_BasictypeValidatorTrait (const M_Basictype & BasictypeValueRef, M_Basictype MinBasictype, M_Basictype MaxBasictype,
01129: const wxString & FieldNameString,
01130: int Flags, M_Basictype UndefinedBasictype,
01131: const wxString & FormatString = wxEmptyString);
01132: virtual ~M_BasictypeValidatorTrait() { };
01133:
01134: void init (M_Basictype * BasictypeValuePtr, M_Basictype MinBasictype, M_Basictype MaxBasictype,
01135: const wxString & FieldNameString,
01136: int Flags, M_Basictype UndefinedBasictype,
01137: const wxString & FormatString = wxEmptyString);
01138: /* see notes about pointer vs. reference 1st argument at constructor */
01139: void init (const M_Basictype & BasictypeValueRef, M_Basictype MinBasictype, M_Basictype MaxBasictype,
01140: const wxString & FieldNameString,
01141: int Flags, M_Basictype UndefinedBasictype,
01142: const wxString & FormatString = wxEmptyString);
01143:
01144: virtual void convertToString (wxString & TextCtrlContentString);
01145: virtual bool convertFromStringTemporary (const wxString & TextCtrlContentString,
01146: wxString & ErrorMessageString,
01147: bool IsTextCtrlChangeEvent);
01148: virtual bool convertFromStringPersistent (const wxString & TextCtrlContentString,
01149: wxString & ErrorMessageString);
01150:
01151: virtual bool convertFromStringHelper (const wxString & TextCtrlContentString,
01152: M_Basictype * BasictypePtr,
01153: wxString & ErrorMessageString);
01154:
01155: M_Basictype getCopyValue ();
01156:
01157: virtual bool getIsUndefinedValue (const M_Basictype & Basictype);
01158: virtual bool checkValueRange (const M_Basictype & Basictype);
01159: virtual void getErrorMessageString (wxString & ErrorMessageString);
01160:
01161: virtual void convertBasictypeToString (const M_Basictype & Basictype,
01162: wxString & String);
01163: virtual bool convertStringToBasictype (const wxString & String,
01164: M_Basictype & Basictype);
01165:
01166: /* protected: */
01167: M_Basictype * m_BasictypeValuePtr;
01168: M_Basictype m_CopyBasictype;
01169: M_Basictype m_MinBasictype;
01170: M_Basictype m_MaxBasictype;
01171: M_Basictype m_UndefinedBasictype;
01172: M_Basictype m_LastValidationBasicType;
01173:
01174: int m_Flags;
01175: wxString m_FieldNameString;
01176: wxString m_FormatString;
01177: };
01178:
01179: //-------------------------------------------------------------------------
01180:
01181: // undefine shortcuts
01182: #undef M_Basictype
01183: #undef M_BasictypeValidatorTrait
01184:
01185: #endif // defined M_BasictypeValidatorTrait
01186:
01187: //=========================================================================
01188:
01189: #if (defined M_TraitedTextCtrlStatusValidatorImpl_Basictype)
01190:
01191: // define a few shortcuts
01192: #define M_Basictype M_TraitedTextCtrlStatusValidatorImpl_Basictype
01193: #define M_BasictypeValidatorTrait M_TraitedTextCtrlStatusValidatorImpl_BasictypeValidatorTrait
01194:
01195: //-------------------------------------------------------------------------
01196:
01197: // TEST: to get macro stringize, concat work as expected:
01198: // #define DECLARE_DYNAMIC_CLASS_HELPER(X) DECLARE_DYNAMIC_CLASS(X)
01199: // alternative:
01200: // use M_PP_eval1()
01201:
01202: // wxTraitedTextCtrlStatusValidatorImpl
01203: // - generic version for easy employment of user-defined wxTextCtrlStatusValidatorTrait
01204: // classes
01205: class M_TraitedTextCtrlStatusValidatorImpl_ExportDecl M_TraitedTextCtrlStatusValidatorImpl: public wxTraitedTextCtrlStatusValidator
01206: {
01207: // DECLARE_DYNAMIC_CLASS_HELPER(M_TraitedTextCtrlStatusValidatorImpl)
01208: M_PP_eval1 (DECLARE_DYNAMIC_CLASS, M_TraitedTextCtrlStatusValidatorImpl)
01209: public:
01210: /* HACK repeat those flag values from wxTextCtrlStatusValidatorTrait classes */
01211: /* for ease of use */
01212: enum
01213: {
01214: IsEmptyAllowed = 0x01,
01215: /* IsFilterInputChars = 0x02 // currently unused */
01216: IsWritebackToCopy = 0x04,
01217: IsReadFromCopy = 0x08,
01218: IsIgnoreMinimum = 0x10,
01219: IsIgnoreMaximum = 0x20,
01220: IsNoTrimLeft = 0x40,
01221: IsNoTrimRight = 0x80,
01222: IsNoTrim = 0xc0 /* == IsNoTrimLeft | IsNoTrimRight */
01223: };
01224:
01225: M_TraitedTextCtrlStatusValidatorImpl();
01226: M_TraitedTextCtrlStatusValidatorImpl(M_Basictype * BasictypeValue,
01227: M_Basictype MinBasictype, M_Basictype MaxBasictype,
01228: wxStatusMessageTarget * StatusMessageTarget,
01229: const wxString & FieldNameString,
01230: int Flags, M_Basictype UndefinedBasictype,
01231: const wxString & FormatString = wxEmptyString);
01232: M_TraitedTextCtrlStatusValidatorImpl(const M_TraitedTextCtrlStatusValidatorImpl
01233: & TraitedTextCtrlStatusValidatorImpl);
01234:
01235: ~M_TraitedTextCtrlStatusValidatorImpl();
01236:
01237: virtual wxObject *Clone() const { return new M_TraitedTextCtrlStatusValidatorImpl(*this); }
01238: bool Copy(const M_TraitedTextCtrlStatusValidatorImpl & TraitedTextCtrlStatusValidatorImpl);
01239:
01240: DECLARE_EVENT_TABLE()
01241:
01242: protected:
01243: M_BasictypeValidatorTrait m_BasictypeValidatorTrait;
01244: };
01245:
01246: //#undef DECLARE_DYNAMIC_CLASS_HELPER
01247:
01248: //-------------------------------------------------------------------------
01249:
01250: // undefine shortcuts
01251: #undef M_Basictype
01252: #undef M_BasictypeValidatorTrait
01253:
01254: #endif // defined M_TraitedTextCtrlStatusValidatorImpl
01255:
01256: //=========================================================================
01257:
01258: // #define M_IsUndefPPMacros 1
01259: // # include "pp_basics.h"
01260: // #undef M_IsUndefPPMacros
01261:
01262: //-------------------------------------------------------------------------
01263:
01264: #endif // else defined M_StatusValidators_IsEmitGenericDeclarations
01265:
01266: //=========================================================================
01267: