KiCad PCB EDA Suite
WX_UNIT_BINDER Class Reference

#include <wx_unit_binder.h>

Public Member Functions

 WX_UNIT_BINDER (wxWindow *aParent, wxTextEntry *aTextInput, wxStaticText *aUnitLabel, wxSpinButton *aSpinButton=NULL)
 Constructor. More...
 
virtual ~WX_UNIT_BINDER ()
 
virtual void SetValue (int aValue)
 Function SetValue Sets new value (in Internal Units) for the text field, taking care of units conversion. More...
 
virtual int GetValue () const
 Function GetValue Returns the current value in Internal Units. More...
 
bool Valid () const
 Function Valid Returns true if the text control contains a real number. More...
 
void Enable (bool aEnable)
 Function Enable Enables/diasables the binded widgets. More...
 

Protected Member Functions

void onTextChanged (wxEvent &aEvent)
 

Protected Attributes

wxTextEntry * m_textEntry
 

Text input control.

More...
 
wxStaticText * m_unitLabel
 

Label showing currently used units.

More...
 
EDA_UNITS_T m_units
 

Currently used units.

More...
 
int m_step
 

Step size (added/subtracted difference if spin buttons are used).

More...
 
int m_min
 
int m_max
 

Static Protected Attributes

static const wxString DEFAULT_VALUE
 

Default value (or non-specified)

More...
 

Detailed Description

Definition at line 35 of file wx_unit_binder.h.

Constructor & Destructor Documentation

WX_UNIT_BINDER::WX_UNIT_BINDER ( wxWindow *  aParent,
wxTextEntry *  aTextInput,
wxStaticText *  aUnitLabel,
wxSpinButton *  aSpinButton = NULL 
)

Constructor.

Parameters
aParentis the parent window.
aTextInputis the text input widget used to edit the given value (wxTextCtrl, wxComboBox, ...).
aUnitLabelis the units label displayed next to the text field.
aSpinButtonis an optional spin button (for adjusting the input value)

Definition at line 36 of file wx_unit_binder.cpp.

References GetAbbreviatedUnitsLabel(), m_textEntry, m_unitLabel, and m_units.

37  :
38  m_textEntry( aTextInput ),
39  m_unitLabel( aUnitLabel ),
41  m_step( 1 ),
42  m_min( 0 ),
43  m_max( 1 )
44 {
45  // Use the currently selected units
46  m_textEntry->SetValue( wxT( "0" ) );
48 }
EDA_UNITS_T m_units
Currently used units.
wxTextEntry * m_textEntry
Text input control.
int m_step
Step size (added/subtracted difference if spin buttons are used).
wxString GetAbbreviatedUnitsLabel(EDA_UNITS_T aUnit)
Definition: base_units.cpp:479
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:56
wxStaticText * m_unitLabel
Label showing currently used units.
WX_UNIT_BINDER::~WX_UNIT_BINDER ( )
virtual

Definition at line 51 of file wx_unit_binder.cpp.

52 {
53 }

Member Function Documentation

void WX_UNIT_BINDER::Enable ( bool  aEnable)

Function Enable Enables/diasables the binded widgets.

Definition at line 82 of file wx_unit_binder.cpp.

References m_textEntry, and m_unitLabel.

83 {
84  wxWindow* wxWin = dynamic_cast<wxWindow*> ( m_textEntry );
85  wxWin->Enable( aEnable );
86  m_unitLabel->Enable( aEnable );
87 }
wxTextEntry * m_textEntry
Text input control.
wxStaticText * m_unitLabel
Label showing currently used units.
int WX_UNIT_BINDER::GetValue ( ) const
virtual

Function GetValue Returns the current value in Internal Units.

Definition at line 66 of file wx_unit_binder.cpp.

References m_textEntry, m_units, and ValueFromString().

Referenced by DIALOG_TRACK_VIA_PROPERTIES::Apply(), DIALOG_TRACK_VIA_SIZE::check(), DIALOG_TRACK_VIA_PROPERTIES::check(), DIALOG_PNS_LENGTH_TUNING_SETTINGS::OnOkClick(), DIALOG_PNS_DIFF_PAIR_DIMENSIONS::OnOkClick(), and DIALOG_TRACK_VIA_SIZE::onOkClick().

67 {
68  wxString s = m_textEntry->GetValue();
69 
70  return ValueFromString( m_units, s );
71 }
EDA_UNITS_T m_units
Currently used units.
wxTextEntry * m_textEntry
Text input control.
int ValueFromString(EDA_UNITS_T aUnits, const wxString &aTextValue)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application...
Definition: base_units.cpp:368
void WX_UNIT_BINDER::onTextChanged ( wxEvent &  aEvent)
protected
void WX_UNIT_BINDER::SetValue ( int  aValue)
virtual

Function SetValue Sets new value (in Internal Units) for the text field, taking care of units conversion.

Parameters
aValueis the new value.

Definition at line 56 of file wx_unit_binder.cpp.

References GetAbbreviatedUnitsLabel(), m_textEntry, m_unitLabel, m_units, and StringFromValue().

Referenced by DIALOG_PNS_DIFF_PAIR_DIMENSIONS::DIALOG_PNS_DIFF_PAIR_DIMENSIONS(), DIALOG_PNS_LENGTH_TUNING_SETTINGS::DIALOG_PNS_LENGTH_TUNING_SETTINGS(), DIALOG_TRACK_VIA_SIZE::DIALOG_TRACK_VIA_SIZE(), and DIALOG_TRACK_VIA_PROPERTIES::setCommonVal().

57 {
58  wxString s = StringFromValue( m_units, aValue, false );
59 
60  m_textEntry->SetValue( s );
61 
63 }
wxString StringFromValue(EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymbol)
Function StringFromValue returns the string from aValue according to units (inch, mm ...
Definition: base_units.cpp:203
EDA_UNITS_T m_units
Currently used units.
wxTextEntry * m_textEntry
Text input control.
wxString GetAbbreviatedUnitsLabel(EDA_UNITS_T aUnit)
Definition: base_units.cpp:479
wxStaticText * m_unitLabel
Label showing currently used units.
bool WX_UNIT_BINDER::Valid ( ) const

Function Valid Returns true if the text control contains a real number.

Definition at line 74 of file wx_unit_binder.cpp.

References dummy(), and m_textEntry.

Referenced by DIALOG_TRACK_VIA_PROPERTIES::Apply(), and DIALOG_TRACK_VIA_PROPERTIES::check().

75 {
76  double dummy;
77 
78  return m_textEntry->GetValue().ToDouble( &dummy );
79 }
wxTextEntry * m_textEntry
Text input control.
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...

Member Data Documentation

const wxString WX_UNIT_BINDER::DEFAULT_VALUE
staticprotected

Default value (or non-specified)

Definition at line 94 of file wx_unit_binder.h.

int WX_UNIT_BINDER::m_max
protected

Definition at line 91 of file wx_unit_binder.h.

int WX_UNIT_BINDER::m_min
protected

Definition at line 90 of file wx_unit_binder.h.

int WX_UNIT_BINDER::m_step
protected

Step size (added/subtracted difference if spin buttons are used).

Definition at line 89 of file wx_unit_binder.h.

wxTextEntry* WX_UNIT_BINDER::m_textEntry
protected

Text input control.

Definition at line 80 of file wx_unit_binder.h.

Referenced by Enable(), GetValue(), SetValue(), Valid(), and WX_UNIT_BINDER().

wxStaticText* WX_UNIT_BINDER::m_unitLabel
protected

Label showing currently used units.

Definition at line 83 of file wx_unit_binder.h.

Referenced by Enable(), SetValue(), and WX_UNIT_BINDER().

EDA_UNITS_T WX_UNIT_BINDER::m_units
protected

Currently used units.

Definition at line 86 of file wx_unit_binder.h.

Referenced by GetValue(), SetValue(), and WX_UNIT_BINDER().


The documentation for this class was generated from the following files: