KiCad PCB EDA Suite
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 __UNIT_BINDER_H_
26 #define __UNIT_BINDER_H_
27 
28 #include <common.h>
29 #include <base_units.h>
30 #include <base_struct.h>
32 
33 
34 class wxTextEntry;
35 class wxSpinButton;
36 class wxStaticText;
37 
38 
39 class UNIT_BINDER : public wxEvtHandler
40 {
41 public:
42 
54  UNIT_BINDER( EDA_DRAW_FRAME* aParent,
55  wxStaticText* aLabel, wxWindow* aValue, wxStaticText* aUnitLabel,
56  bool aUseMils = false, bool aAllowEval = true );
57 
63  virtual void SetUnits( EDA_UNITS_T aUnits, bool aUseMils = false );
64 
70  virtual void SetValue( int aValue );
71 
72  void SetValue( wxString aValue );
73 
80  virtual void ChangeValue( int aValue );
81 
82  void ChangeValue( wxString aValue );
83 
88  virtual long long int GetValue();
89 
95  bool IsIndeterminate() const;
96 
105  virtual bool Validate( long long int aMin, long long int aMax, bool setFocusOnError = true );
106 
107  void SetLabel( const wxString& aLabel );
108 
113  void Enable( bool aEnable );
114 
122  void Show( bool aShow, bool aResize = false );
123 
124 protected:
125 
126  void onSetFocus( wxFocusEvent& aEvent );
127  void onKillFocus( wxFocusEvent& aEvent );
128  void delayedFocusHandler( wxCommandEvent& aEvent );
129 
131  wxStaticText* m_label;
132  wxWindow* m_value;
133  wxStaticText* m_unitLabel;
134 
137  bool m_useMils;
138 
140  wxString m_errorMessage;
141 
146 
149  long m_selEnd;
150 };
151 
152 #endif /* __UNIT_BINDER_H_ */
wxString m_errorMessage
Validation support.
Definition: unit_binder.h:140
void delayedFocusHandler(wxCommandEvent &aEvent)
wxWindow * m_value
Definition: unit_binder.h:132
Implementation of conversion functions that require both schematic and board internal units.
virtual void SetUnits(EDA_UNITS_T aUnits, bool aUseMils=false)
Function SetUnits Normally not needed (as the UNIT_BINDER inherits from the parent frame),...
Definition: unit_binder.cpp:68
bool m_needsEval
Definition: unit_binder.h:145
bool IsIndeterminate() const
Function IsIndeterminate Returns true if the control holds the indeterminate value (for instance,...
The base class for create windows for drawing purpose.
void Show(bool aShow, bool aResize=false)
Function Show Shows/hides the label, widget and units label.
wxStaticText * m_label
The bound widgets
Definition: unit_binder.h:131
UNIT_BINDER(EDA_DRAW_FRAME *aParent, wxStaticText *aLabel, wxWindow *aValue, wxStaticText *aUnitLabel, bool aUseMils=false, bool aAllowEval=true)
Constructor.
Definition: unit_binder.cpp:37
wxStaticText * m_unitLabel
Definition: unit_binder.h:133
NUMERIC_EVALUATOR m_eval
Evaluator
Definition: unit_binder.h:143
bool m_useMils
Definition: unit_binder.h:137
virtual bool Validate(long long int aMin, long long int aMax, bool setFocusOnError=true)
Function Validate Validates the control against the given range, informing the user of any errors fou...
bool m_allowEval
Definition: unit_binder.h:144
void onKillFocus(wxFocusEvent &aEvent)
Definition: unit_binder.cpp:97
void onSetFocus(wxFocusEvent &aEvent)
Definition: unit_binder.cpp:76
void SetLabel(const wxString &aLabel)
virtual void SetValue(int aValue)
Function SetValue Sets new value (in Internal Units) for the text field, taking care of units convers...
EDA_UNITS_T m_units
Currently used units.
Definition: unit_binder.h:136
The common library.
virtual long long int GetValue()
Function GetValue Returns the current value in Internal Units.
long m_selStart
Selection start and end of the original text
Definition: unit_binder.h:148
EDA_UNITS_T
Definition: common.h:133
void Enable(bool aEnable)
Function Enable Enables/diasables the label, widget and units label.
virtual void ChangeValue(int aValue)
Function ChangeValue Changes the value (in Internal Units) for the text field, taking care of units c...