![]() |
MechSys
1.0
Computing library for simulations in continuum and discrete mechanics
|
00001 /************************************************************************ 00002 * MechSys - Open Library for Mechanical Systems * 00003 * Copyright (C) 2005 Dorival M. Pedroso, Raul Durand * 00004 * Copyright (C) 2009 Sergio Galindo * 00005 * * 00006 * This program is free software: you can redistribute it and/or modify * 00007 * it under the terms of the GNU General Public License as published by * 00008 * the Free Software Foundation, either version 3 of the License, or * 00009 * any later version. * 00010 * * 00011 * This program is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00014 * GNU General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU General Public License * 00017 * along with this program. If not, see <http://www.gnu.org/licenses/> * 00018 ************************************************************************/ 00019 00020 #ifndef MECHSYS_WXSTRINGVALIDATOR_H 00021 #define MECHSYS_WXSTRINGVALIDATOR_H 00022 00023 // wxWidgets 00024 #include <wx/textctrl.h> 00025 #include <wx/validate.h> 00026 00027 // MechSys 00028 #include <mechsys/util/string.h> 00029 00030 class WxStringValidator : public wxValidator 00031 { 00032 public: 00033 WxStringValidator (String * ptStr=NULL) : wxValidator(), pStr(ptStr) {} 00034 WxStringValidator (WxStringValidator const & Other) { pStr=Other.pStr; } 00035 virtual ~WxStringValidator() {} 00036 00037 virtual wxObject * Clone () const { return new WxStringValidator(*this); } 00038 virtual bool TransferFromWindow (); 00039 virtual bool TransferToWindow (); 00040 virtual bool Validate (wxWindow * parent) { return true; } 00041 00042 WxStringValidator & operator= (WxStringValidator const & Other) { pStr=Other.pStr; return (*this); } 00043 00044 private: 00045 String * pStr; 00046 DECLARE_DYNAMIC_CLASS(WxStringValidator) 00047 DECLARE_EVENT_TABLE() 00048 }; 00049 00050 00052 00053 00054 IMPLEMENT_DYNAMIC_CLASS(WxStringValidator, wxValidator) 00055 00056 BEGIN_EVENT_TABLE(WxStringValidator, wxValidator) 00057 END_EVENT_TABLE() 00058 00059 bool WxStringValidator::TransferFromWindow() 00060 { 00061 (*pStr) = static_cast<wxTextCtrl*>(m_validatorWindow)->GetValue().ToStdString(); 00062 return true; 00063 } 00064 00065 bool WxStringValidator::TransferToWindow() 00066 { 00067 static_cast<wxTextCtrl*>(m_validatorWindow)->SetValue((*pStr)); 00068 return true; 00069 } 00070 00071 #endif