26 #include <wx/clipbrd.h> 27 #include <wx/stattext.h> 28 #include <wx/textentry.h> 39 wxStaticText* aUnitLabel,
bool allowEval ) :
42 m_valueCtrl( aValueCtrl ),
43 m_unitLabel( aUnitLabel ),
45 m_originTransforms( aParent->GetOriginTransforms() ),
56 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>(
m_valueCtrl );
61 textEntry->ChangeValue( wxT(
"0" ) );
119 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>(
m_valueCtrl );
125 if( oldStr.length() )
127 textEntry->SetValue( oldStr );
140 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>(
m_valueCtrl );
147 wxString sel = textEntry->GetStringSelection();
153 if( wxTheClipboard->Open() )
155 bool clipTarget = wxTheClipboard->IsUsingPrimarySelection();
156 wxTheClipboard->UsePrimarySelection(
true );
157 wxTheClipboard->SetData(
new wxTextDataObject( sel ) );
158 wxTheClipboard->UsePrimarySelection( clipTarget );
159 wxTheClipboard->Close();
173 wxString desc = aLabel->GetLabel();
175 desc.EndsWith( wxT(
":" ), &desc );
192 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>(
m_valueCtrl );
210 textEntry->SelectAll();
212 wxPostEvent(
this, wxCommandEvent( DELAY_FOCUS ) );
224 textEntry->SelectAll();
226 wxPostEvent(
this, wxCommandEvent( DELAY_FOCUS ) );
237 double value = aValue;
253 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>(
m_valueCtrl );
254 wxStaticText* staticText = dynamic_cast<wxStaticText*>(
m_valueCtrl );
257 textEntry->SetValue( aValue );
258 else if( staticText )
259 staticText->SetLabel( aValue );
271 double value = aValue;
279 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>(
m_valueCtrl );
280 wxStaticText* staticText = dynamic_cast<wxStaticText*>(
m_valueCtrl );
283 textEntry->ChangeValue( aValue );
284 else if( staticText )
285 staticText->SetLabel( aValue );
297 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>(
m_valueCtrl );
298 wxStaticText* staticText = dynamic_cast<wxStaticText*>(
m_valueCtrl );
306 value = textEntry->GetValue();
308 else if( staticText )
309 value = staticText->GetLabel();
324 aValue = static_cast<double>( tmp ) /
scale;
326 if( !aValueUsesUserUnits )
336 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>(
m_valueCtrl );
337 wxStaticText* staticText = dynamic_cast<wxStaticText*>(
m_valueCtrl );
345 value = textEntry->GetValue();
347 else if( staticText )
349 value = staticText->GetLabel();
365 wxTextEntry* te = dynamic_cast<wxTextEntry*>(
m_valueCtrl );
376 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>(
m_valueCtrl );
377 wxStaticText* staticText = dynamic_cast<wxStaticText*>(
m_valueCtrl );
382 return textEntry->GetValue();
383 else if( staticText )
384 return staticText->GetLabel();
386 return wxEmptyString;
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
wxString m_errorMessage
< Validation support.
wxString GetOriginalText() const
Return the pre-evaluated text (or the current text if evaluation is not supported).
ORIGIN_TRANSFORMS::COORD_TYPES_T m_coordType
Type of coordinate for display origin transforms.
EDA_DRAW_FRAME * m_frame
The bound widgets.
UNIT_BINDER(EDA_DRAW_FRAME *aParent, wxStaticText *aLabel, wxWindow *aValueCtrl, wxStaticText *aUnitLabel, bool aAllowEval=true)
void delayedFocusHandler(wxCommandEvent &aEvent)
int GetUserUnits()
Returns the currently selected user unit value for the interface.
Implementation of conversion functions that require both schematic and board internal units.
This file is part of the common library.
wxString OriginalText() const
EDA_DATA_TYPE
The type of unit.
ORIGIN_TRANSFORMS & m_originTransforms
A reference to an ORIGIN_TRANSFORMS object.
void SetDataType(EDA_DATA_TYPE aDataType)
Used to override the datatype of the displayed property (default is DISTANCE)
bool m_needsEval
Selection start and end of the original text.
wxString GetAbbreviatedUnitsLabel(EDA_UNITS aUnit, EDA_DATA_TYPE aType)
Get the units string for a given units type.
bool IsIndeterminate() const
Return true if the control holds the indeterminate value (for instance, if it represents a multiple s...
wxDEFINE_EVENT(DELAY_FOCUS, wxCommandEvent)
The base class for create windows for drawing purpose.
wxString valueDescriptionFromLabel(wxStaticText *aLabel)
virtual void SetPrecision(int aLength)
Normally not needed, but can be used to set the precision when using internal units that are floats (...
EDA_UNITS m_units
< Currently used units.
void Show(bool aShow, bool aResize=false)
Show/hide the label, widget and units label.
bool Process(const wxString &aString)
long long int ValueFromString(EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application.
wxStaticText * m_unitLabel
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
virtual void SetUnits(EDA_UNITS aUnits)
Normally not needed (as the UNIT_BINDER inherits from the parent frame), but can be used to set to DE...
void onKillFocus(wxFocusEvent &aEvent)
double To_User_Unit(EDA_UNITS aUnit, double aValue)
Function To_User_Unit convert aValue in internal units to the appropriate user units defined by aUnit...
virtual bool Validate(double aMin, double aMax, EDA_UNITS aUnits=EDA_UNITS::UNSCALED)
Validate the control against the given range, informing the user of any errors found.
void onSetFocus(wxFocusEvent &aEvent)
void SetLabel(const wxString &aLabel)
void onUnitsChanged(wxCommandEvent &aEvent)
virtual void SetValue(int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
virtual long long int GetValue()
Return the current value in Internal Units.
wxString StringFromValue(EDA_UNITS aUnits, double aValue, bool aAddUnitSymbol, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
virtual void SetDoubleValue(double aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
virtual double GetDoubleValue()
Return the current value in Internal Units.
double setPrecision(double aValue, bool aValueUsesUserUnits)
When m_precision > 0 truncate the value aValue to show only m_precision digits in mantissa.
double DoubleValueFromString(EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType)
Function DoubleValueFromString converts aTextValue to a double.
#define INDETERMINATE_ACTION
#define INDETERMINATE_STATE
Used for holding indeterminate values, such as with multiple selections holding different values or c...
double From_User_Unit(EDA_UNITS aUnits, double aValue)
Return in internal units the value "val" given in a real unit such as "in", "mm" or "deg".
void Enable(bool aEnable)
Enable/disable the label, widget and units label.
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
virtual void ChangeValue(int aValue)
Change the value (in Internal Units) for the text field, taking care of units conversion but does not...