2
* This program source code file is part of KiCad, a free EDA CAD application.
4
* Copyright (C) 2014 CERN
5
* Author: Maciej Suminski <maciej.suminski@cern.ch>
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.
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.
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
29
#include <wx/spinbutt.h>
40
class WX_UNIT_TEXT : public wxPanel
45
* @param aParent is the parent window.
46
* @param aLabel is the label displayed next to the text input control.
47
* @param aValue is the initial value for the control.
48
* @param aStep is the step size when using spin buttons.
50
WX_UNIT_TEXT( wxWindow* aParent, const wxString& aLabel = _( "Size:" ),
51
double aValue = 0.0, double aStep = 0.1 );
53
virtual ~WX_UNIT_TEXT();
57
* Changes the units used by the control.
58
* @param aUnits is the new unit to be used.
59
* @param aConvert decides if the current value should be converted to the value in new units
60
* or should it stay the same.
62
void SetUnits( EDA_UNITS_T aUnits, bool aConvert = false );
66
* Sets new value for the control.
67
* @param aValue is the new value.
69
virtual void SetValue( double aValue );
73
* Returns the current value using specified units (if currently used units are different, then
74
* they are converted first).
75
* @param aUnits is the wanted unit.
77
//virtual double GetValue( EDA_UNITS_T aUnits ) const;
81
* Returns the current value in currently used units.
83
virtual boost::optional<double> GetValue() const;
87
* Returns currently used units.
89
EDA_UNITS_T GetUnits() const
96
* Sets the difference introduced by a single spin button click.
97
* @param aStep is new step size.
99
void SetStep( double aStep )
101
assert( aStep > 0.0 );
108
* Returns the difference introduced by a single spin button click.
110
double GetStep() const
116
///> Spin up button click event handler.
117
void onSpinUpEvent( wxSpinEvent& aEvent );
119
///> Spin down button click event handler.
120
void onSpinDownEvent( wxSpinEvent& aEvent );
122
///> Label for the input (e.g. "Size:")
123
wxStaticText* m_inputLabel;
125
///> Text input control.
126
wxTextCtrl* m_inputValue;
128
///> Spin buttons for changing the value using mouse.
129
wxSpinButton* m_spinButton;
131
///> Label showing currently used units.
132
wxStaticText* m_unitLabel;
134
///> Currently used units.
137
///> Step size (added/subtracted difference if spin buttons are used).
140
///> Default value (or non-specified)
141
static const wxString DEFAULT_VALUE;
144
#endif /* WXUNITTEXT_H_ */