[main]    [up]  

WxExtLib - TextCtrlSliderPairValidators.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: #ifndef _INCLUDED_TextCtrlSliderPairValidators_h
00042: #define _INCLUDED_TextCtrlSliderPairValidators_h
00043: 
00044: #if defined(__GNUG__) && (!defined(__APPLE__)) && (!(defined M_NoPragmaInterface))
00045: #   pragma interface "TextCtrlSliderPairValidators.h"
00046: #endif
00047: 
00048: #include "WxExtLibConfig.h"
00049: 
00050: #include <wx/defs.h>
00051: 
00052: #include <wx/textctrl.h>
00053: #include <wx/slider.h>
00054: #include <wx/validate.h>
00055: 
00056: #include "StatusValidators.h"
00057: 
00058: //-------------------------------------------------------------------------
00059: 
00060: #define M_IsDefineExportMagic 1
00061: #    include "WxExtLibAliases.h"
00062: #undef M_IsDefineExportMagic
00063: 
00064: //-------------------------------------------------------------------------
00065: 
00066: // wxTextCtrlSliderPairTextCtrlValidator/wxTextCtrlSliderPairSliderValidator:
00067: // - allow mutual update if one of both associated controls (wxTextCtrl or
00068: //   wxSlider) is changed by users input 
00069: // - if entered text is valid: associated slider is updated immediately;
00070: //   otherwise the user will get immediate feedback via wxStatusMessageTarget
00071: //   (wxTextCtrlSliderPairTextCtrlValidator is derived from
00072: //   wxNumberValidator/wxTextCtrlStatusValidator)
00073: // - both required controls and both required validators can be created with
00074: //   minimum effort by calling wxExtDialog::addTextCtrlSliderPairWithLabel()
00075: 
00076: class wxTextCtrlSliderPairTextCtrlValidator;
00077: class wxTextCtrlSliderPairSliderValidator;
00078: 
00079: //-------------------------------------------------------------------------
00080: 
00081: class M_WxExtLib_ExportDecl wxTextCtrlSliderPairTextCtrlValidator: public wxNumberValidator
00082: {
00083: DECLARE_DYNAMIC_CLASS(wxTextCtrlSliderPairTextCtrlValidator)
00084: public:
00085: 
00086:     wxTextCtrlSliderPairTextCtrlValidator () ;
00087:     wxTextCtrlSliderPairTextCtrlValidator(long * LongValue, long MinLong, long MaxLong,
00088:                                           wxStatusMessageTarget * StatusMessageTarget,
00089:                                           const wxString & FieldNameString);
00090:     wxTextCtrlSliderPairTextCtrlValidator(const wxTextCtrlSliderPairTextCtrlValidator & TextCtrlSliderPairTextCtrlValidator);
00091: 
00092:     ~wxTextCtrlSliderPairTextCtrlValidator();
00093: 
00094:     virtual wxObject *Clone() const { return new wxTextCtrlSliderPairTextCtrlValidator(*this); }
00095:     bool Copy(const wxTextCtrlSliderPairTextCtrlValidator & TextCtrlSliderPairTextCtrlValidator);
00096: 
00097:     // set associated slider validator
00098:     void setAssociatedSliderValidator (wxTextCtrlSliderPairSliderValidator * AssociatedSliderValidator);
00099: 
00100:     virtual bool TransferToWindow();
00101: 
00102:     virtual void handleValidInput ();
00103: 
00104:     void informSliderChange (long TempLong);
00105: 
00106: DECLARE_EVENT_TABLE()
00107: 
00108: protected:
00109:     wxTextCtrlSliderPairSliderValidator * m_AssociatedSliderValidator;
00110: };
00111: 
00112: //-------------------------------------------------------------------------
00113: 
00114: class M_WxExtLib_ExportDecl wxTextCtrlSliderPairSliderValidator: public wxValidator
00115: {
00116: DECLARE_DYNAMIC_CLASS(wxTextCtrlSliderPairSliderValidator)
00117: public:
00118: 
00119:     wxTextCtrlSliderPairSliderValidator () ;
00120:     wxTextCtrlSliderPairSliderValidator(const wxTextCtrlSliderPairSliderValidator& TextCtrlSliderPairSliderValidator);
00121: 
00122:     ~wxTextCtrlSliderPairSliderValidator();
00123: 
00124:     virtual wxObject *Clone() const { return new wxTextCtrlSliderPairSliderValidator(*this); }
00125:     bool Copy(const wxTextCtrlSliderPairSliderValidator & TextCtrlSliderPairSliderValidator);
00126: 
00127:     // validate and transfer from/to window
00128:     virtual bool Validate(wxWindow *parent);
00129:     virtual bool TransferToWindow();
00130:     virtual bool TransferFromWindow();
00131: 
00132:     // events to handle changes in the slider position
00133:     void OnScrollEvent(wxScrollEvent & Event);
00134: 
00135:     // set associated slider validator
00136:     void setAssociatedTextCtrlValidator (wxTextCtrlSliderPairTextCtrlValidator * AssociatedTextCtrlValidator);
00137: 
00138:     void informTextCtrlChange (long TempLong);
00139: 
00140: DECLARE_EVENT_TABLE()
00141: 
00142: protected:
00143:     wxTextCtrlSliderPairTextCtrlValidator * m_AssociatedTextCtrlValidator;
00144: 
00145:     bool m_IsLastSliderPositionValid;
00146:     long m_LastSliderPositionLong;
00147: };
00148: 
00149: //-------------------------------------------------------------------------
00150: 
00151: #define M_IsUndefExportMagic 1
00152: #    include "WxExtLibAliases.h"
00153: #undef M_IsUndefExportMagic
00154: 
00155: //-------------------------------------------------------------------------
00156: 
00157: #endif
00158:   // _INCLUDED_TextCtrlSliderPairValidators_h
00159: 
00160: //-------------------------------------------------------------------------
00161: 
  [main]    [up]  
DaicasWeb v.1.50.0102  //   Daniel Käps  //   April 12, 2007  //   Impressum / Imprint 
http://www.daicas.net/WxExtLib/src/TextCtrlSliderPairValidators.h.html