KiCad PCB EDA Suite
EDA_VALUE_CTRL Class Reference

#include <dialog_helpers.h>

Public Member Functions

 EDA_VALUE_CTRL (wxWindow *parent, const wxString &title, int value, EDA_UNITS_T user_unit, wxBoxSizer *BoxSizer)
 
 ~EDA_VALUE_CTRL ()
 
int GetValue ()
 
void SetValue (int new_value)
 
void Enable (bool enbl)
 
void SetToolTip (const wxString &text)
 

Public Attributes

EDA_UNITS_T m_UserUnit
 
int m_Value
 
wxTextCtrl * m_ValueCtrl
 

Private Attributes

wxStaticText * m_Text
 

Detailed Description

Definition at line 193 of file dialog_helpers.h.

Constructor & Destructor Documentation

EDA_VALUE_CTRL::EDA_VALUE_CTRL ( wxWindow *  parent,
const wxString &  title,
int  value,
EDA_UNITS_T  user_unit,
wxBoxSizer *  BoxSizer 
)

Definition at line 269 of file wxwineda.cpp.

References m_Text, m_UserUnit, m_Value, m_ValueCtrl, ReturnUnitSymbol(), and StringFromValue().

271 {
272  wxString label = title;
273 
274  m_UserUnit = user_unit;
275  m_Value = value;
276  label += ReturnUnitSymbol( m_UserUnit );
277 
278  m_Text = new wxStaticText( parent, -1, label );
279 
280  BoxSizer->Add( m_Text, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
281 
282  wxString stringvalue = StringFromValue( m_UserUnit, m_Value );
283  m_ValueCtrl = new wxTextCtrl( parent, -1, stringvalue );
284 
285  BoxSizer->Add( m_ValueCtrl,
286  0,
287  wxGROW | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM,
288  5 );
289 }
wxString ReturnUnitSymbol(EDA_UNITS_T aUnit, const wxString &formatString)
Returns the units symbol.
Definition: base_units.cpp:425
EDA_UNITS_T m_UserUnit
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:204
wxTextCtrl * m_ValueCtrl
wxStaticText * m_Text
EDA_VALUE_CTRL::~EDA_VALUE_CTRL ( )

Definition at line 292 of file wxwineda.cpp.

References m_Text, and m_ValueCtrl.

293 {
294  delete m_ValueCtrl;
295  delete m_Text;
296 }
wxTextCtrl * m_ValueCtrl
wxStaticText * m_Text

Member Function Documentation

void EDA_VALUE_CTRL::Enable ( bool  enbl)

Definition at line 320 of file wxwineda.cpp.

References m_Text, and m_ValueCtrl.

321 {
322  m_ValueCtrl->Enable( enbl );
323  m_Text->Enable( enbl );
324 }
wxTextCtrl * m_ValueCtrl
wxStaticText * m_Text
int EDA_VALUE_CTRL::GetValue ( )

Definition at line 299 of file wxwineda.cpp.

References m_UserUnit, m_ValueCtrl, and ValueFromString().

300 {
301  int coord;
302  wxString txtvalue = m_ValueCtrl->GetValue();
303 
304  coord = ValueFromString( m_UserUnit, txtvalue );
305  return coord;
306 }
EDA_UNITS_T m_UserUnit
wxTextCtrl * m_ValueCtrl
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:369
void EDA_VALUE_CTRL::SetToolTip ( const wxString &  text)
inline

Definition at line 212 of file dialog_helpers.h.

213  {
214  m_ValueCtrl->SetToolTip( text );
215  }
wxTextCtrl * m_ValueCtrl
void EDA_VALUE_CTRL::SetValue ( int  new_value)

Definition at line 309 of file wxwineda.cpp.

References m_UserUnit, m_Value, m_ValueCtrl, and StringFromValue().

310 {
311  wxString buffer;
312 
313  m_Value = new_value;
314 
315  buffer = StringFromValue( m_UserUnit, m_Value );
316  m_ValueCtrl->SetValue( buffer );
317 }
EDA_UNITS_T m_UserUnit
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:204
wxTextCtrl * m_ValueCtrl

Member Data Documentation

wxStaticText* EDA_VALUE_CTRL::m_Text
private

Definition at line 200 of file dialog_helpers.h.

Referenced by EDA_VALUE_CTRL(), Enable(), and ~EDA_VALUE_CTRL().

EDA_UNITS_T EDA_VALUE_CTRL::m_UserUnit

Definition at line 196 of file dialog_helpers.h.

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

int EDA_VALUE_CTRL::m_Value

Definition at line 197 of file dialog_helpers.h.

Referenced by EDA_VALUE_CTRL(), and SetValue().

wxTextCtrl* EDA_VALUE_CTRL::m_ValueCtrl

Definition at line 198 of file dialog_helpers.h.

Referenced by EDA_VALUE_CTRL(), Enable(), GetValue(), SetValue(), and ~EDA_VALUE_CTRL().


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