KiCad PCB EDA Suite
EDA_GRAPHIC_TEXT_CTRL Class Reference

Class EDA_GRAPHIC_TEXT_CTRL is a custom text edit control to edit/enter Kicad dimensions ( INCHES or MM ) More...

#include <dialog_helpers.h>

Public Member Functions

 EDA_GRAPHIC_TEXT_CTRL (wxWindow *parent, const wxString &Title, const wxString &TextToEdit, int textsize, EDA_UNITS_T user_unit, wxBoxSizer *BoxSizer, int framelen=200)
 
 ~EDA_GRAPHIC_TEXT_CTRL ()
 
const wxString GetText () const
 
int GetTextSize ()
 
void Enable (bool state)
 
void SetTitle (const wxString &title)
 
void SetFocus ()
 
void SetValue (const wxString &value)
 
void SetValue (int value)
 

Static Public Member Functions

static wxString FormatSize (EDA_UNITS_T user_unit, int textSize)
 Function FormatSize formats a string containing the size in the desired units. More...
 
static int ParseSize (const wxString &sizeText, EDA_UNITS_T user_unit)
 

Public Attributes

EDA_UNITS_T m_UserUnit
 
wxTextCtrl * m_FrameText
 
wxTextCtrl * m_FrameSize
 

Private Attributes

wxStaticText * m_Title
 

Detailed Description

Class EDA_GRAPHIC_TEXT_CTRL is a custom text edit control to edit/enter Kicad dimensions ( INCHES or MM )

Definition at line 112 of file dialog_helpers.h.

Constructor & Destructor Documentation

EDA_GRAPHIC_TEXT_CTRL::EDA_GRAPHIC_TEXT_CTRL ( wxWindow *  parent,
const wxString &  Title,
const wxString &  TextToEdit,
int  textsize,
EDA_UNITS_T  user_unit,
wxBoxSizer *  BoxSizer,
int  framelen = 200 
)

Definition at line 39 of file wxwineda.cpp.

References FormatSize(), GetChars(), m_FrameSize, m_FrameText, m_Title, m_UserUnit, and ReturnUnitSymbol().

46 {
47  m_UserUnit = user_unit;
48  m_Title = NULL;
49 
50  m_Title = new wxStaticText( parent, -1, Title );
51 
52  BoxSizer->Add( m_Title, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
53 
54  m_FrameText = new wxTextCtrl( parent, -1, TextToEdit );
55 
56  BoxSizer->Add( m_FrameText, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
57 
58  if( !Title.IsEmpty() )
59  {
60  wxString msg;
61  msg.Printf( _( "Size%s" ), GetChars( ReturnUnitSymbol( m_UserUnit ) ) );
62  wxStaticText* text = new wxStaticText( parent, -1, msg );
63 
64  BoxSizer->Add( text, 0, wxGROW | wxLEFT | wxRIGHT, 5 );
65  }
66 
67  wxString value = FormatSize( m_UserUnit, textsize );
68 
69  m_FrameSize = new wxTextCtrl( parent, -1, value, wxDefaultPosition, wxSize( 70, -1 ) );
70 
71  BoxSizer->Add( m_FrameSize, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
72 }
wxTextCtrl * m_FrameText
wxString ReturnUnitSymbol(EDA_UNITS_T aUnit, const wxString &formatString)
Returns the units symbol.
Definition: base_units.cpp:420
wxStaticText * m_Title
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
wxTextCtrl * m_FrameSize
static wxString FormatSize(EDA_UNITS_T user_unit, int textSize)
Function FormatSize formats a string containing the size in the desired units.
Definition: wxwineda.cpp:84
EDA_GRAPHIC_TEXT_CTRL::~EDA_GRAPHIC_TEXT_CTRL ( )

Definition at line 75 of file wxwineda.cpp.

76 {
77  /* no, these are deleted by the BoxSizer
78  delete m_FrameText;
79  delete m_Title;
80  */
81 }

Member Function Documentation

void EDA_GRAPHIC_TEXT_CTRL::Enable ( bool  state)

Definition at line 146 of file wxwineda.cpp.

References m_FrameText.

147 {
148  m_FrameText->Enable( state );
149 }
wxTextCtrl * m_FrameText
wxString EDA_GRAPHIC_TEXT_CTRL::FormatSize ( EDA_UNITS_T  user_unit,
int  textSize 
)
static

Function FormatSize formats a string containing the size in the desired units.

Definition at line 84 of file wxwineda.cpp.

References StringFromValue().

Referenced by DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel(), DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel(), EDA_GRAPHIC_TEXT_CTRL(), and SetValue().

85 {
86  // Limiting the size of the text of reasonable values.
87  if( textSize < 10 )
88  textSize = 10;
89 
90  if( textSize > 3000 )
91  textSize = 3000;
92 
93  return StringFromValue( aUnit, textSize );
94 }
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
const wxString EDA_GRAPHIC_TEXT_CTRL::GetText ( ) const

Definition at line 116 of file wxwineda.cpp.

References m_FrameText.

117 {
118  wxString text = m_FrameText->GetValue();
119  return text;
120 }
wxTextCtrl * m_FrameText
int EDA_GRAPHIC_TEXT_CTRL::GetTextSize ( void  )

Definition at line 140 of file wxwineda.cpp.

References m_FrameSize, m_UserUnit, and ParseSize().

141 {
142  return ParseSize( m_FrameSize->GetValue(), m_UserUnit );
143 }
static int ParseSize(const wxString &sizeText, EDA_UNITS_T user_unit)
Definition: wxwineda.cpp:123
wxTextCtrl * m_FrameSize
int EDA_GRAPHIC_TEXT_CTRL::ParseSize ( const wxString &  sizeText,
EDA_UNITS_T  user_unit 
)
static

Definition at line 123 of file wxwineda.cpp.

References ValueFromString().

Referenced by DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField(), DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField(), and GetTextSize().

124 {
125  int textsize;
126 
127  textsize = ValueFromString( aUnit, sizeText );
128 
129  // Limit to reasonable size
130  if( textsize < 10 )
131  textsize = 10;
132 
133  if( textsize > 3000 )
134  textsize = 3000;
135 
136  return textsize;
137 }
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 EDA_GRAPHIC_TEXT_CTRL::SetFocus ( )
inline

Definition at line 134 of file dialog_helpers.h.

134 { m_FrameText->SetFocus(); }
wxTextCtrl * m_FrameText
void EDA_GRAPHIC_TEXT_CTRL::SetTitle ( const wxString &  title)

Definition at line 97 of file wxwineda.cpp.

References m_Title.

98 {
99  m_Title->SetLabel( title );
100 }
wxStaticText * m_Title
void EDA_GRAPHIC_TEXT_CTRL::SetValue ( const wxString &  value)

Definition at line 103 of file wxwineda.cpp.

References m_FrameText.

104 {
105  m_FrameText->SetValue( value );
106 }
wxTextCtrl * m_FrameText
void EDA_GRAPHIC_TEXT_CTRL::SetValue ( int  value)

Definition at line 109 of file wxwineda.cpp.

References FormatSize(), m_FrameSize, and m_UserUnit.

110 {
111  wxString value = FormatSize( m_UserUnit, textSize );
112  m_FrameSize->SetValue( value );
113 }
wxTextCtrl * m_FrameSize
static wxString FormatSize(EDA_UNITS_T user_unit, int textSize)
Function FormatSize formats a string containing the size in the desired units.
Definition: wxwineda.cpp:84

Member Data Documentation

wxTextCtrl* EDA_GRAPHIC_TEXT_CTRL::m_FrameSize

Definition at line 118 of file dialog_helpers.h.

Referenced by EDA_GRAPHIC_TEXT_CTRL(), GetTextSize(), and SetValue().

wxTextCtrl* EDA_GRAPHIC_TEXT_CTRL::m_FrameText

Definition at line 117 of file dialog_helpers.h.

Referenced by EDA_GRAPHIC_TEXT_CTRL(), Enable(), GetText(), and SetValue().

wxStaticText* EDA_GRAPHIC_TEXT_CTRL::m_Title
private

Definition at line 120 of file dialog_helpers.h.

Referenced by EDA_GRAPHIC_TEXT_CTRL(), and SetTitle().

EDA_UNITS_T EDA_GRAPHIC_TEXT_CTRL::m_UserUnit

Definition at line 115 of file dialog_helpers.h.

Referenced by EDA_GRAPHIC_TEXT_CTRL(), GetTextSize(), and SetValue().


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