KiCad PCB EDA Suite
wx_unit_binder.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2014-2015 CERN
5  * Author: Maciej Suminski <maciej.suminski@cern.ch>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #ifndef __WX_UNIT_BINDER_H_
26 #define __WX_UNIT_BINDER_H_
27 
28 #include <common.h>
29 #include <wx/spinbutt.h>
30 
31 class wxTextEntry;
32 class wxSpinButton;
33 class wxStaticText;
34 
36 {
37 public:
38 
46  WX_UNIT_BINDER( wxWindow* aParent, wxTextEntry* aTextInput, wxStaticText* aUnitLabel, wxSpinButton* aSpinButton = NULL );
47 
48  virtual ~WX_UNIT_BINDER();
49 
55  virtual void SetValue( int aValue );
56 
61  virtual int GetValue() const;
62 
67  bool Valid() const;
68 
73  void Enable( bool aEnable );
74 
75 protected:
76 
77  void onTextChanged( wxEvent& aEvent );
78 
80  wxTextEntry* m_textEntry;
81 
83  wxStaticText* m_unitLabel;
84 
87 
89  int m_step;
90  int m_min;
91  int m_max;
92 
94  static const wxString DEFAULT_VALUE;
95 };
96 
97 #endif /* __WX_UNIT_BINDER_H_ */
EDA_UNITS_T m_units
Currently used units.
wxTextEntry * m_textEntry
Text input control.
bool Valid() const
Function Valid Returns true if the text control contains a real number.
virtual ~WX_UNIT_BINDER()
int m_step
Step size (added/subtracted difference if spin buttons are used).
virtual void SetValue(int aValue)
Function SetValue Sets new value (in Internal Units) for the text field, taking care of units convers...
void Enable(bool aEnable)
Function Enable Enables/diasables the binded widgets.
void onTextChanged(wxEvent &aEvent)
virtual int GetValue() const
Function GetValue Returns the current value in Internal Units.
wxStaticText * m_unitLabel
Label showing currently used units.
The common library.
static const wxString DEFAULT_VALUE
Default value (or non-specified)
WX_UNIT_BINDER(wxWindow *aParent, wxTextEntry *aTextInput, wxStaticText *aUnitLabel, wxSpinButton *aSpinButton=NULL)
Constructor.
EDA_UNITS_T
Definition: common.h:144