KiCad PCB EDA Suite
UNIT_BINDER Class Reference

#include <unit_binder.h>

Inheritance diagram for UNIT_BINDER:

Public Member Functions

 UNIT_BINDER (EDA_DRAW_FRAME *aParent, wxStaticText *aLabel, wxWindow *aValueCtrl, wxStaticText *aUnitLabel, bool aAllowEval=true)
 
 UNIT_BINDER (EDA_BASE_FRAME *aParent, const EDA_IU_SCALE &aIUScale, wxStaticText *aLabel, wxWindow *aValueCtrl, wxStaticText *aUnitLabel, bool aAllowEval=true)
 
 ~UNIT_BINDER () override
 
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 DEGREES for angular controls. More...
 
virtual void SetNegativeZero ()
 
virtual void SetPrecision (int aLength)
 Normally not needed, but can be used to set the precision when using internal units that are floats (not integers) like DEGREES or PERCENT. More...
 
void SetDataType (EDA_DATA_TYPE aDataType)
 Used to override the datatype of the displayed property (default is DISTANCE) More...
 
virtual void SetValue (long long int aValue)
 Set new value (in Internal Units) for the text field, taking care of units conversion. More...
 
void SetValue (const wxString &aValue)
 
virtual void SetDoubleValue (double aValue)
 Set new value (in Internal Units) for the text field, taking care of units conversion. More...
 
virtual void SetAngleValue (const EDA_ANGLE &aValue)
 
virtual void ChangeValue (int aValue)
 Set new value (in Internal Units) for the text field, taking care of units conversion WITHOUT triggering the update routine. More...
 
void ChangeValue (const wxString &aValue)
 
virtual void ChangeDoubleValue (double aValue)
 Set new value (in Internal Units) for the text field, taking care of units conversion WITHOUT triggering the update routine. More...
 
virtual void ChangeAngleValue (const EDA_ANGLE &aValue)
 
virtual long long int GetValue ()
 Return the current value in Internal Units. More...
 
virtual double GetDoubleValue ()
 Return the current value in Internal Units. More...
 
virtual EDA_ANGLE GetAngleValue ()
 
bool IsIndeterminate () const
 Return true if the control holds the indeterminate value (for instance, if it represents a multiple selection of differing values). More...
 
wxString GetOriginalText () const
 Return the pre-evaluated text (or the current text if evaluation is not supported). More...
 
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. More...
 
void SetLabel (const wxString &aLabel)
 
void Enable (bool aEnable)
 Enable/disable the label, widget and units label. More...
 
void Show (bool aShow, bool aResize=false)
 Show/hide the label, widget and units label. More...
 
ORIGIN_TRANSFORMS::COORD_TYPES_T GetCoordType () const
 Get the origin transforms coordinate type. More...
 
void SetCoordType (ORIGIN_TRANSFORMS::COORD_TYPES_T aCoordType)
 Set the current origin transform mode. More...
 
void RequireEval ()
 Force the binder to evaluate the text. More...
 

Protected Member Functions

void onClick (wxMouseEvent &aEvent)
 
void onSetFocus (wxFocusEvent &aEvent)
 
void onKillFocus (wxFocusEvent &aEvent)
 
void delayedFocusHandler (wxCommandEvent &aEvent)
 
void onUnitsChanged (wxCommandEvent &aEvent)
 
double setPrecision (double aValue, bool aValueUsesUserUnits)
 When m_precision > 0 truncate the value aValue to show only m_precision digits in mantissa. More...
 

Protected Attributes

EDA_BASE_FRAMEm_frame
 The bound widgets. More...
 
wxStaticText * m_label
 
wxWindow * m_valueCtrl
 
wxStaticText * m_unitLabel
 Can be nullptr. More...
 
const EDA_IU_SCALEm_iuScale
 
EDA_UNITS m_units
 
bool m_negativeZero
 Indicates "-0" should be displayed for 0. More...
 
EDA_DATA_TYPE m_dataType
 
int m_precision
 0 to 6 More...
 
wxString m_errorMessage
 
NUMERIC_EVALUATOR m_eval
 
bool m_allowEval
 
bool m_needsEval
 
long m_selStart
 Selection start and end of the original text. More...
 
long m_selEnd
 
ORIGIN_TRANSFORMSm_originTransforms
 A reference to an ORIGIN_TRANSFORMS object. More...
 
ORIGIN_TRANSFORMS::COORD_TYPES_T m_coordType
 Type of coordinate for display origin transforms. More...
 

Detailed Description

Definition at line 41 of file unit_binder.h.

Constructor & Destructor Documentation

◆ UNIT_BINDER() [1/2]

UNIT_BINDER::UNIT_BINDER ( EDA_DRAW_FRAME aParent,
wxStaticText *  aLabel,
wxWindow *  aValueCtrl,
wxStaticText *  aUnitLabel,
bool  aAllowEval = true 
)
Parameters
aParentis the parent EDA_BASE_FRAME, used to fetch units and coordinate systems.
aLabelis the static text used to label the text input widget (note: the label text, trimmed of its colon, will also be used in error messages)
aValueCtrlis the control used to edit or display the given value (wxTextCtrl, wxComboBox, wxStaticText, etc.).
aUnitLabelis the units label displayed after the text input widget Can be nullptr.
aAllowEvalindicates aTextInput's content should be eval'ed before storing

Definition at line 41 of file unit_binder.cpp.

42 :
43 UNIT_BINDER( aParent, aParent->GetIuScale(), aLabel, aValueCtrl, aUnitLabel, allowEval )
44{
45}
const EDA_IU_SCALE & GetIuScale() const
UNIT_BINDER(EDA_DRAW_FRAME *aParent, wxStaticText *aLabel, wxWindow *aValueCtrl, wxStaticText *aUnitLabel, bool aAllowEval=true)
Definition: unit_binder.cpp:41

◆ UNIT_BINDER() [2/2]

UNIT_BINDER::UNIT_BINDER ( EDA_BASE_FRAME aParent,
const EDA_IU_SCALE aIUScale,
wxStaticText *  aLabel,
wxWindow *  aValueCtrl,
wxStaticText *  aUnitLabel,
bool  aAllowEval = true 
)

Definition at line 47 of file unit_binder.cpp.

49 :
50 m_frame( aParent ),
51 m_label( aLabel ),
52 m_valueCtrl( aValueCtrl ),
53 m_unitLabel( aUnitLabel ),
54 m_iuScale( aIUScale ),
55 m_negativeZero( false ),
57 m_precision( 0 ),
58 m_eval( aParent->GetUserUnits() ),
61{
62 m_units = aParent->GetUserUnits();
63 m_allowEval = allowEval && dynamic_cast<wxTextEntry*>( m_valueCtrl );
64 m_needsEval = false;
65 m_selStart = 0;
66 m_selEnd = 0;
67
68 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
69
70 if( textEntry )
71 {
72 // Use ChangeValue() instead of SetValue() so we don't generate events.
73 if( m_negativeZero )
74 textEntry->ChangeValue( wxT( "-0" ) );
75 else
76 textEntry->ChangeValue( wxT( "0" ) );
77 }
78
79 if( m_unitLabel )
81
82 m_valueCtrl->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( UNIT_BINDER::onSetFocus ),
83 nullptr, this );
84 m_valueCtrl->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( UNIT_BINDER::onKillFocus ),
85 nullptr, this );
86 m_valueCtrl->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( UNIT_BINDER::onClick ), nullptr,
87 this );
88 Connect( DELAY_FOCUS, wxCommandEventHandler( UNIT_BINDER::delayedFocusHandler ), nullptr,
89 this );
90
91 m_frame->Connect( UNITS_CHANGED, wxCommandEventHandler( UNIT_BINDER::onUnitsChanged ),
92 nullptr, this );
93}
virtual ORIGIN_TRANSFORMS & GetOriginTransforms()
Return a reference to the default ORIGIN_TRANSFORMS object.
EDA_UNITS GetUserUnits() const
ORIGIN_TRANSFORMS::COORD_TYPES_T m_coordType
Type of coordinate for display origin transforms.
Definition: unit_binder.h:248
EDA_BASE_FRAME * m_frame
The bound widgets.
Definition: unit_binder.h:221
void onKillFocus(wxFocusEvent &aEvent)
void onClick(wxMouseEvent &aEvent)
bool m_allowEval
Definition: unit_binder.h:238
bool m_negativeZero
Indicates "-0" should be displayed for 0.
Definition: unit_binder.h:231
int m_precision
0 to 6
Definition: unit_binder.h:233
wxStaticText * m_unitLabel
Can be nullptr.
Definition: unit_binder.h:226
wxWindow * m_valueCtrl
Definition: unit_binder.h:225
void onSetFocus(wxFocusEvent &aEvent)
wxStaticText * m_label
Definition: unit_binder.h:224
ORIGIN_TRANSFORMS & m_originTransforms
A reference to an ORIGIN_TRANSFORMS object.
Definition: unit_binder.h:245
long m_selStart
Selection start and end of the original text.
Definition: unit_binder.h:241
EDA_UNITS m_units
Definition: unit_binder.h:230
bool m_needsEval
Definition: unit_binder.h:239
void delayedFocusHandler(wxCommandEvent &aEvent)
EDA_DATA_TYPE m_dataType
Definition: unit_binder.h:232
NUMERIC_EVALUATOR m_eval
Definition: unit_binder.h:237
const EDA_IU_SCALE & m_iuScale
Definition: unit_binder.h:229
void onUnitsChanged(wxCommandEvent &aEvent)
wxString GetLabel(EDA_UNITS aUnits, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Get the units string for a given units type.
Definition: eda_units.cpp:129

References delayedFocusHandler(), DISTANCE, EDA_UNIT_UTILS::GetLabel(), UNITS_PROVIDER::GetUserUnits(), m_allowEval, m_dataType, m_frame, m_needsEval, m_negativeZero, m_selEnd, m_selStart, m_unitLabel, m_units, m_valueCtrl, onClick(), onKillFocus(), onSetFocus(), and onUnitsChanged().

◆ ~UNIT_BINDER()

UNIT_BINDER::~UNIT_BINDER ( )
override

Definition at line 96 of file unit_binder.cpp.

97{
98 m_frame->Disconnect( UNITS_CHANGED, wxCommandEventHandler( UNIT_BINDER::onUnitsChanged ),
99 nullptr, this );
100}

References m_frame, and onUnitsChanged().

Member Function Documentation

◆ ChangeAngleValue()

void UNIT_BINDER::ChangeAngleValue ( const EDA_ANGLE aValue)
virtual

Definition at line 370 of file unit_binder.cpp.

371{
372 ChangeDoubleValue( aValue.AsDegrees() );
373}
double AsDegrees() const
Definition: eda_angle.h:149
virtual void ChangeDoubleValue(double aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion WITHOUT trigger...

References EDA_ANGLE::AsDegrees(), and ChangeDoubleValue().

Referenced by DIALOG_PAD_PROPERTIES::initValues().

◆ ChangeDoubleValue()

void UNIT_BINDER::ChangeDoubleValue ( double  aValue)
virtual

Set new value (in Internal Units) for the text field, taking care of units conversion WITHOUT triggering the update routine.

The value will be truncated according to the precision set by SetPrecision() (if not <= 0).

Definition at line 356 of file unit_binder.cpp.

357{
358 double displayValue = m_originTransforms.ToDisplay( aValue, m_coordType );
360 setPrecision( displayValue, false ),
361 false, m_dataType );
362
363 if( displayValue == 0 && m_negativeZero )
364 ChangeValue( wxT( "-" ) + textValue );
365 else
366 ChangeValue( textValue );
367}
virtual int ToDisplay(int aValue, COORD_TYPES_T aCoordType) const
double setPrecision(double aValue, bool aValueUsesUserUnits)
When m_precision > 0 truncate the value aValue to show only m_precision digits in mantissa.
virtual void ChangeValue(int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion WITHOUT trigger...
wxString StringFromValue(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, double aValue, bool aAddUnitsText=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Returns the string from aValue according to aUnits (inch, mm ...) for display.
Definition: eda_units.cpp:233

References ChangeValue(), m_coordType, m_dataType, m_iuScale, m_negativeZero, m_originTransforms, m_units, setPrecision(), EDA_UNIT_UTILS::UI::StringFromValue(), and ORIGIN_TRANSFORMS::ToDisplay().

Referenced by ChangeAngleValue(), DIALOG_PAD_PROPERTIES::initValues(), DIALOG_PAD_PROPERTIES::onCornerRadiusChange(), DIALOG_PAD_PROPERTIES::OnPadShapeSelection(), and DIALOG_PAD_PROPERTIES::updateRoundRectCornerValues().

◆ ChangeValue() [1/2]

void UNIT_BINDER::ChangeValue ( const wxString &  aValue)

Definition at line 376 of file unit_binder.cpp.

377{
378 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
379 wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_valueCtrl );
380
381 if( textEntry )
382 textEntry->ChangeValue( aValue );
383 else if( staticText )
384 staticText->SetLabel( aValue );
385
386 if( m_allowEval )
387 m_eval.Clear();
388
389 if( m_unitLabel )
391}

References NUMERIC_EVALUATOR::Clear(), EDA_UNIT_UTILS::GetLabel(), m_allowEval, m_dataType, m_eval, m_unitLabel, m_units, and m_valueCtrl.

◆ ChangeValue() [2/2]

void UNIT_BINDER::ChangeValue ( int  aValue)
virtual

◆ delayedFocusHandler()

void UNIT_BINDER::delayedFocusHandler ( wxCommandEvent &  aEvent)
protected

Definition at line 232 of file unit_binder.cpp.

233{
234 if( !m_errorMessage.IsEmpty() )
235 DisplayError( m_valueCtrl->GetParent(), m_errorMessage );
236
237 m_errorMessage = wxEmptyString;
238 m_valueCtrl->SetFocus();
239}
wxString m_errorMessage
Definition: unit_binder.h:235
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:280

References DisplayError(), m_errorMessage, and m_valueCtrl.

Referenced by UNIT_BINDER().

◆ Enable()

void UNIT_BINDER::Enable ( bool  aEnable)

Enable/disable the label, widget and units label.

Definition at line 512 of file unit_binder.cpp.

513{
514 m_label->Enable( aEnable );
515 m_valueCtrl->Enable( aEnable );
516
517 if( m_unitLabel )
518 m_unitLabel->Enable( aEnable );
519}

References m_label, m_unitLabel, and m_valueCtrl.

Referenced by DIALOG_COPPER_ZONE::DIALOG_COPPER_ZONE(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::onActionButtonChange(), DIALOG_LIB_SHAPE_PROPERTIES::onBorderChecked(), DIALOG_SHAPE_PROPERTIES::onBorderChecked(), DIALOG_TEXT_PROPERTIES::onBorderChecked(), DIALOG_LIB_TEXTBOX_PROPERTIES::onBorderChecked(), DIALOG_TEXTBOX_PROPERTIES::onBorderChecked(), DIALOG_IMPORT_GFX::onFilename(), DIALOG_PAD_PROPERTIES::OnPadShapeSelection(), DIALOG_PAGES_SETTINGS::OnPaperSizeChoice(), DIALOG_COPPER_ZONE::OnRemoveIslandsSelection(), DIALOG_NON_COPPER_ZONES_EDITOR::OnStyleSelection(), DIALOG_TRACK_VIA_PROPERTIES::onTrackNetclassCheck(), DIALOG_LIB_SYMBOL_PROPERTIES::OnUpdateUI(), DIALOG_PLOT_SCHEMATIC::OnUpdateUI(), DIALOG_PAD_PROPERTIES::OnUpdateUI(), DIALOG_TRACK_VIA_PROPERTIES::onViaNetclassCheck(), DIALOG_IMPORT_GFX::originOptionOnUpdateUI(), DIALOG_PLOT::SetPlotFormat(), DIALOG_LIB_SHAPE_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataToWindow(), DIALOG_SHAPE_PROPERTIES::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_WIRE_BUS_PROPERTIES::TransferDataToWindow(), DIALOG_COPPER_ZONE::TransferDataToWindow(), and DIALOG_TEXTBOX_PROPERTIES::TransferDataToWindow().

◆ GetAngleValue()

◆ GetCoordType()

ORIGIN_TRANSFORMS::COORD_TYPES_T UNIT_BINDER::GetCoordType ( ) const
inline

Get the origin transforms coordinate type.

Returns
the origin transforms coordinate type

Definition at line 178 of file unit_binder.h.

179 {
180 return m_coordType;
181 }

References m_coordType.

◆ GetDoubleValue()

double UNIT_BINDER::GetDoubleValue ( )
virtual

Return the current value in Internal Units.

The returned value will be truncated according to the precision set by SetPrecision() (if not <= 0)

Definition at line 443 of file unit_binder.cpp.

444{
445 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
446 wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_valueCtrl );
447 wxString value;
448
449 if( textEntry )
450 {
451 if( m_needsEval && m_eval.Process( textEntry->GetValue() ) )
452 value = m_eval.Result();
453 else
454 value = textEntry->GetValue();
455 }
456 else if( staticText )
457 {
458 value = staticText->GetLabel();
459 }
460 else
461 {
462 return 0.0;
463 }
464
466 value, m_dataType );
467 displayValue = setPrecision( displayValue, false );
468
469 return m_originTransforms.FromDisplay( displayValue, m_coordType );
470}
wxString Result() const
bool Process(const wxString &aString)
virtual int FromDisplay(int aValue, COORD_TYPES_T aCoordType) const
double DoubleValueFromString(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Function DoubleValueFromString converts aTextValue to a double.
Definition: eda_units.cpp:451

References EDA_UNIT_UTILS::UI::DoubleValueFromString(), ORIGIN_TRANSFORMS::FromDisplay(), m_coordType, m_dataType, m_eval, m_iuScale, m_needsEval, m_originTransforms, m_units, m_valueCtrl, NUMERIC_EVALUATOR::Process(), NUMERIC_EVALUATOR::Result(), and setPrecision().

Referenced by GetAngleValue(), DIALOG_MOVE_EXACT::GetTranslationInIU(), DIALOG_POSITION_RELATIVE::GetTranslationInIU(), DIALOG_POSITION_RELATIVE::OnClear(), DIALOG_POSITION_RELATIVE::OnOkClick(), DIALOG_MOVE_EXACT::OnPolarChanged(), DIALOG_POSITION_RELATIVE::OnPolarChanged(), DIALOG_MOVE_EXACT::OnTextChanged(), DIALOG_PAD_PROPERTIES::padValuesOK(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataFromWindow(), PANEL_SETUP_MASK_AND_PASTE::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::transferDataToPad(), and DIALOG_GRAPHIC_ITEM_PROPERTIES::Validate().

◆ GetOriginalText()

wxString UNIT_BINDER::GetOriginalText ( ) const

Return the pre-evaluated text (or the current text if evaluation is not supported).

Used primarily to remember values between dialog invocations.

Definition at line 490 of file unit_binder.cpp.

491{
492 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
493 wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_valueCtrl );
494
495 if( m_allowEval )
496 return m_eval.OriginalText();
497 else if( textEntry )
498 return textEntry->GetValue();
499 else if( staticText )
500 return staticText->GetLabel();
501 else
502 return wxEmptyString;
503}
wxString OriginalText() const

References m_allowEval, m_eval, m_valueCtrl, and NUMERIC_EVALUATOR::OriginalText().

◆ GetValue()

long long int UNIT_BINDER::GetValue ( )
virtual

Return the current value in Internal Units.

Definition at line 394 of file unit_binder.cpp.

395{
396 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
397 wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_valueCtrl );
398 wxString value;
399
400 if( textEntry )
401 {
402 if( m_needsEval && m_eval.Process( textEntry->GetValue() ) )
403 value = m_eval.Result();
404 else
405 value = textEntry->GetValue();
406 }
407 else if( staticText )
408 {
409 value = staticText->GetLabel();
410 }
411 else
412 {
413 return 0;
414 }
415
416 long long int displayValue = EDA_UNIT_UTILS::UI::ValueFromString( m_iuScale, m_units, value,
417 m_dataType );
418 return m_originTransforms.FromDisplay( displayValue, m_coordType );
419}
long long int ValueFromString(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application.
Definition: eda_units.cpp:530

References ORIGIN_TRANSFORMS::FromDisplay(), m_coordType, m_dataType, m_eval, m_iuScale, m_needsEval, m_originTransforms, m_units, m_valueCtrl, NUMERIC_EVALUATOR::Process(), NUMERIC_EVALUATOR::Result(), and EDA_UNIT_UTILS::UI::ValueFromString().

Referenced by DIALOG_PNS_LENGTH_TUNING_SETTINGS::AcceptOptions(), DIALOG_COPPER_ZONE::AcceptOptions(), DIALOG_PLOT::applyPlotSettings(), DIALOG_CREATE_ARRAY::calculateCircularArrayProperties(), PROPERTIES_FRAME::CopyPrmsFromPanelToGeneral(), PROPERTIES_FRAME::CopyPrmsFromPanelToItem(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), DIALOG_PAGES_SETTINGS::GetCustomSizeMilsFromDialog(), DIALOG_LIB_NEW_SYMBOL::GetPinTextPosition(), DIALOG_PLOT_SCHEMATIC::getPlotOptions(), TEARDROP_DIALOG::GetTeardropMaxHeightRect(), TEARDROP_DIALOG::GetTeardropMaxHeightRound(), TEARDROP_DIALOG::GetTeardropMaxHeightTrack(), TEARDROP_DIALOG::GetTeardropMaxLenRect(), TEARDROP_DIALOG::GetTeardropMaxLenRound(), TEARDROP_DIALOG::GetTeardropMaxLenTrack(), WX_UNIT_ENTRY_DIALOG::GetValue(), DIALOG_DIMENSION_PROPERTIES::onBoldToggle(), DIALOG_TEXT_PROPERTIES::onBoldToggle(), DIALOG_TEXTBOX_PROPERTIES::onBoldToggle(), DIALOG_LIB_SHAPE_PROPERTIES::onBorderChecked(), DIALOG_SHAPE_PROPERTIES::onBorderChecked(), DIALOG_TEXT_PROPERTIES::onBorderChecked(), DIALOG_LIB_TEXTBOX_PROPERTIES::onBorderChecked(), DIALOG_TEXTBOX_PROPERTIES::onBorderChecked(), DIALOG_PAD_PROPERTIES::onCornerRadiusChange(), DIALOG_DIMENSION_PROPERTIES::onFontSelected(), DIALOG_TEXT_PROPERTIES::onFontSelected(), DIALOG_TEXTBOX_PROPERTIES::onFontSelected(), DIALOG_PAD_PRIMITIVE_POLY_PROPS::onPaintPolyPanel(), DIALOG_PIN_PROPERTIES::OnPropertiesChange(), DIALOG_DIMENSION_PROPERTIES::onThickness(), DIALOG_TEXT_PROPERTIES::onThickness(), DIALOG_TEXTBOX_PROPERTIES::onThickness(), onUnitsChanged(), DIALOG_PAD_PROPERTIES::PadTypeSelected(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), DIALOG_PLOT_SCHEMATIC::setHpglPenWidth(), DIALOG_FIELD_PROPERTIES::TransferDataFromWindow(), DIALOG_IMAGE_PROPERTIES::TransferDataFromWindow(), DIALOG_JUNCTION_PROPS::TransferDataFromWindow(), DIALOG_LABEL_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_SHAPE_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataFromWindow(), DIALOG_LINE_PROPERTIES::TransferDataFromWindow(), DIALOG_PIN_PROPERTIES::TransferDataFromWindow(), DIALOG_SHAPE_PROPERTIES::TransferDataFromWindow(), DIALOG_SHEET_PIN_PROPERTIES::TransferDataFromWindow(), DIALOG_SHEET_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_WIRE_BUS_PROPERTIES::TransferDataFromWindow(), PANEL_EESCHEMA_EDITING_OPTIONS::TransferDataFromWindow(), PANEL_SETUP_FORMATTING::TransferDataFromWindow(), PANEL_SYM_EDITING_OPTIONS::TransferDataFromWindow(), DIALOG_GRID_SETTINGS::TransferDataFromWindow(), DIALOG_COPPER_ZONE::TransferDataFromWindow(), DIALOG_CREATE_ARRAY::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataFromWindow(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow(), DIALOG_NON_COPPER_ZONES_EDITOR::TransferDataFromWindow(), DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PRIMITIVE_POLY_PROPS::TransferDataFromWindow(), DIALOG_PNS_DIFF_PAIR_DIMENSIONS::TransferDataFromWindow(), DIALOG_PNS_LENGTH_TUNING_SETTINGS::TransferDataFromWindow(), DIALOG_RULE_AREA_PROPERTIES::TransferDataFromWindow(), DIALOG_TARGET_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow(), DIALOG_TRACK_VIA_PROPERTIES::TransferDataFromWindow(), DIALOG_TRACK_VIA_SIZE::TransferDataFromWindow(), PANEL_SETUP_CONSTRAINTS::TransferDataFromWindow(), PANEL_SETUP_MASK_AND_PASTE::TransferDataFromWindow(), PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataFromWindow(), DIALOG_IMPORT_GFX::TransferDataFromWindow(), MWAVE_POLYGONAL_SHAPE_DLG::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::transferDataToPad(), TEARDROP_DIALOG::TransferToParamList(), DIALOG_PAD_PRIMITIVES_TRANSFORM::Transform(), DIALOG_DIMENSION_PROPERTIES::updateDimensionFromDialog(), DIALOG_GRAPHIC_ITEM_PROPERTIES::Validate(), Validate(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem(), and DIALOG_IMPORT_GFX::~DIALOG_IMPORT_GFX().

◆ IsIndeterminate()

bool UNIT_BINDER::IsIndeterminate ( ) const

Return true if the control holds the indeterminate value (for instance, if it represents a multiple selection of differing values).

Definition at line 479 of file unit_binder.cpp.

480{
481 wxTextEntry* te = dynamic_cast<wxTextEntry*>( m_valueCtrl );
482
483 if( te )
484 return te->GetValue() == INDETERMINATE_STATE || te->GetValue() == INDETERMINATE_ACTION;
485
486 return false;
487}
#define INDETERMINATE_ACTION
Definition: ui_common.h:43
#define INDETERMINATE_STATE
Used for holding indeterminate values, such as with multiple selections holding different values or c...
Definition: ui_common.h:42

References INDETERMINATE_ACTION, INDETERMINATE_STATE, and m_valueCtrl.

Referenced by DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), DIALOG_JUNCTION_PROPS::TransferDataFromWindow(), DIALOG_LIB_SHAPE_PROPERTIES::TransferDataFromWindow(), DIALOG_LINE_PROPERTIES::TransferDataFromWindow(), DIALOG_WIRE_BUS_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow(), DIALOG_TRACK_VIA_PROPERTIES::TransferDataFromWindow(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ onClick()

void UNIT_BINDER::onClick ( wxMouseEvent &  aEvent)
protected

Definition at line 144 of file unit_binder.cpp.

145{
146 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
147
148 if( textEntry && ( textEntry->GetValue() == INDETERMINATE_ACTION
149 || textEntry->GetValue() == INDETERMINATE_STATE ) )
150 {
151 // These are tokens, not strings, so do a select all
152 textEntry->SelectAll();
153 }
154
155 // Needed at least on Windows to avoid hanging
156 aEvent.Skip();
157}

References INDETERMINATE_ACTION, INDETERMINATE_STATE, and m_valueCtrl.

Referenced by UNIT_BINDER().

◆ onKillFocus()

void UNIT_BINDER::onKillFocus ( wxFocusEvent &  aEvent)
protected

Definition at line 191 of file unit_binder.cpp.

192{
193 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
194
195 if( m_allowEval && textEntry )
196 {
197 if( m_eval.Process( textEntry->GetValue() ) )
198 {
199 textEntry->GetSelection( &m_selStart, &m_selEnd );
200 textEntry->ChangeValue( m_eval.Result() );
201
202#ifdef __WXGTK__
203 // Manually copy the selected text to the primary selection clipboard
204 if( wxTheClipboard->Open() )
205 {
206 wxString sel = textEntry->GetStringSelection();
207 bool clipTarget = wxTheClipboard->IsUsingPrimarySelection();
208 wxTheClipboard->UsePrimarySelection( true );
209 wxTheClipboard->SetData( new wxTextDataObject( sel ) );
210 wxTheClipboard->UsePrimarySelection( clipTarget );
211 wxTheClipboard->Close();
212 }
213#endif
214 }
215
216 m_needsEval = false;
217 }
218
219 aEvent.Skip();
220}

References m_allowEval, m_eval, m_needsEval, m_selEnd, m_selStart, m_valueCtrl, NUMERIC_EVALUATOR::Process(), and NUMERIC_EVALUATOR::Result().

Referenced by UNIT_BINDER().

◆ onSetFocus()

void UNIT_BINDER::onSetFocus ( wxFocusEvent &  aEvent)
protected

Definition at line 160 of file unit_binder.cpp.

161{
162 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
163
164 if( textEntry )
165 {
166 if( m_allowEval )
167 {
168 wxString oldStr = m_eval.OriginalText();
169
170 if( oldStr.length() && oldStr != textEntry->GetValue() )
171 {
172 textEntry->SetValue( oldStr );
173 textEntry->SetSelection( m_selStart, m_selEnd );
174 }
175
176 m_needsEval = true;
177 }
178
179 if( textEntry->GetValue() == INDETERMINATE_ACTION
180 || textEntry->GetValue() == INDETERMINATE_STATE )
181 {
182 // These are tokens, not strings, so do a select all
183 textEntry->SelectAll();
184 }
185 }
186
187 aEvent.Skip();
188}

References INDETERMINATE_ACTION, INDETERMINATE_STATE, m_allowEval, m_eval, m_needsEval, m_selEnd, m_selStart, m_valueCtrl, and NUMERIC_EVALUATOR::OriginalText().

Referenced by UNIT_BINDER().

◆ onUnitsChanged()

void UNIT_BINDER::onUnitsChanged ( wxCommandEvent &  aEvent)
protected

Definition at line 127 of file unit_binder.cpp.

128{
132 {
133 int temp = (int) GetValue();
134
136
137 SetValue( temp );
138 }
139
140 aEvent.Skip();
141}
virtual long long int GetValue()
Return the current value in Internal Units.
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...
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.

References DEGREES, UNITS_PROVIDER::GetUserUnits(), GetValue(), m_frame, m_units, PERCENT, SetUnits(), SetValue(), and UNSCALED.

Referenced by UNIT_BINDER(), and ~UNIT_BINDER().

◆ RequireEval()

void UNIT_BINDER::RequireEval ( )
inline

Force the binder to evaluate the text.

Definition at line 194 of file unit_binder.h.

195 {
196 m_needsEval = true;
197 }

References m_needsEval.

Referenced by DIALOG_MOVE_EXACT::DIALOG_MOVE_EXACT().

◆ SetAngleValue()

◆ SetCoordType()

◆ SetDataType()

void UNIT_BINDER::SetDataType ( EDA_DATA_TYPE  aDataType)

Used to override the datatype of the displayed property (default is DISTANCE)

Parameters
aDataTypeis the datatype to use for the units text display

Definition at line 118 of file unit_binder.cpp.

119{
120 m_dataType = aDataType;
121
122 if( m_unitLabel )
124}

References EDA_UNIT_UTILS::GetLabel(), m_dataType, m_unitLabel, and m_units.

Referenced by DIALOG_COPPER_ZONE::TransferDataToWindow().

◆ SetDoubleValue()

◆ SetLabel()

void UNIT_BINDER::SetLabel ( const wxString &  aLabel)

Definition at line 506 of file unit_binder.cpp.

507{
508 m_label->SetLabel( aLabel );
509}

References m_label.

Referenced by DIALOG_MOVE_EXACT::updateDialogControls(), and DIALOG_POSITION_RELATIVE::updateDialogControls().

◆ SetNegativeZero()

◆ setPrecision()

double UNIT_BINDER::setPrecision ( double  aValue,
bool  aValueUsesUserUnits 
)
protected

When m_precision > 0 truncate the value aValue to show only m_precision digits in mantissa.

used in GetDoubleValue to return a rounded value. Mainly for units set to DEGREES.

Parameters
aValueis the value to modify.
aValueUsesUserUnitsmust be set to true if aValue is a user value, and set to false if aValue is a internal unit value.
Returns
the "rounded" value.

Definition at line 422 of file unit_binder.cpp.

423{
424 if( m_precision > 1 )
425 {
426 int scale = pow( 10, m_precision );
427 int64_t tmp = aValue;
428 if( !aValueUsesUserUnits )
429 {
431 }
432
433 aValue = static_cast<double>( tmp ) / scale;
434
435 if( !aValueUsesUserUnits )
437 }
438
439 return aValue;
440}
double FromUserUnit(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnit, double aValue)
Return in internal units the value "val" given in a real unit such as "in", "mm" or "deg".
Definition: eda_units.cpp:393
double ToUserUnit(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnit, double aValue)
Function To_User_Unit convert aValue in internal units to the appropriate user units defined by aUnit...
Definition: eda_units.cpp:198
const int scale

References EDA_UNIT_UTILS::UI::FromUserUnit(), m_iuScale, m_precision, m_units, scale, and EDA_UNIT_UTILS::UI::ToUserUnit().

Referenced by ChangeDoubleValue(), ChangeValue(), GetDoubleValue(), and SetDoubleValue().

◆ SetPrecision()

void UNIT_BINDER::SetPrecision ( int  aLength)
virtual

Normally not needed, but can be used to set the precision when using internal units that are floats (not integers) like DEGREES or PERCENT.

Not used for integer values in IU

Parameters
aLengthis the number of digits for mantissa (0 = no truncation) must be <= 6

Definition at line 112 of file unit_binder.cpp.

113{
114 m_precision = std::min( aLength, 6 );
115}

References m_precision.

Referenced by DIALOG_DIMENSION_PROPERTIES::DIALOG_DIMENSION_PROPERTIES(), DIALOG_FOOTPRINT_PROPERTIES::DIALOG_FOOTPRINT_PROPERTIES(), DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES(), DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES(), and DIALOG_TEXTBOX_PROPERTIES::DIALOG_TEXTBOX_PROPERTIES().

◆ SetUnits()

void UNIT_BINDER::SetUnits ( EDA_UNITS  aUnits)
virtual

◆ SetValue() [1/2]

void UNIT_BINDER::SetValue ( const wxString &  aValue)

Definition at line 324 of file unit_binder.cpp.

325{
326 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
327 wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_valueCtrl );
328
329 if( textEntry )
330 textEntry->SetValue( aValue );
331 else if( staticText )
332 staticText->SetLabel( aValue );
333
334 if( m_allowEval )
335 m_eval.Clear();
336
337 if( m_unitLabel )
339}

References NUMERIC_EVALUATOR::Clear(), EDA_UNIT_UTILS::GetLabel(), m_allowEval, m_dataType, m_eval, m_unitLabel, m_units, and m_valueCtrl.

◆ SetValue() [2/2]

void UNIT_BINDER::SetValue ( long long int  aValue)
virtual

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

Definition at line 291 of file unit_binder.cpp.

292{
293 double displayValue = m_originTransforms.ToDisplay( aValue, m_coordType );
294 wxString textValue = EDA_UNIT_UTILS::UI::StringFromValue( m_iuScale, m_units, displayValue,
295 false, m_dataType );
296
297 if( displayValue == 0 && m_negativeZero )
298 SetValue( wxT( "-" ) + textValue );
299 else
300 SetValue( textValue );
301}

References m_coordType, m_dataType, m_iuScale, m_negativeZero, m_originTransforms, m_units, SetValue(), EDA_UNIT_UTILS::UI::StringFromValue(), and ORIGIN_TRANSFORMS::ToDisplay().

Referenced by DIALOG_COPPER_ZONE::AcceptOptions(), DIALOG_PLOT::applyPlotSettings(), DIALOG_CREATE_ARRAY::calculateCircularArrayProperties(), DIALOG_IMPORT_GFX::DIALOG_IMPORT_GFX(), DIALOG_LIB_NEW_SYMBOL::DIALOG_LIB_NEW_SYMBOL(), DIALOG_MOVE_EXACT::DIALOG_MOVE_EXACT(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), PANEL_SETUP_FORMATTING::ImportSettingsFrom(), DIALOG_PLOT::init_Dialog(), DIALOG_PLOT_SCHEMATIC::initDlg(), PANEL_EESCHEMA_EDITING_OPTIONS::loadEEschemaSettings(), PANEL_SYM_EDITING_OPTIONS::loadSymEditorSettings(), DIALOG_LIB_SHAPE_PROPERTIES::onBorderChecked(), DIALOG_SHAPE_PROPERTIES::onBorderChecked(), DIALOG_TEXT_PROPERTIES::onBorderChecked(), DIALOG_LIB_TEXTBOX_PROPERTIES::onBorderChecked(), DIALOG_TEXTBOX_PROPERTIES::onBorderChecked(), DIALOG_MOVE_EXACT::OnClear(), DIALOG_POSITION_RELATIVE::OnClear(), DIALOG_PAD_PROPERTIES::OnOffsetCheckbox(), DIALOG_PAD_PROPERTIES::OnPadToDieCheckbox(), DIALOG_GRID_SETTINGS::OnResetGridOriginClick(), onUnitsChanged(), MWAVE_POLYGONAL_SHAPE_DLG::ReadDataShapeDescr(), DIALOG_JUNCTION_PROPS::resetDefaults(), DIALOG_LINE_PROPERTIES::resetDefaults(), DIALOG_WIRE_BUS_PROPERTIES::resetDefaults(), SetDoubleValue(), DIALOG_LIB_NEW_SYMBOL::SetPinTextPosition(), SetValue(), TEARDROP_DIALOG::TEARDROP_DIALOG(), DIALOG_FIELD_PROPERTIES::TransferDataToWindow(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataToWindow(), DIALOG_IMAGE_PROPERTIES::TransferDataToWindow(), DIALOG_JUNCTION_PROPS::TransferDataToWindow(), DIALOG_LABEL_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_SHAPE_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataToWindow(), DIALOG_LINE_PROPERTIES::TransferDataToWindow(), DIALOG_PIN_PROPERTIES::TransferDataToWindow(), DIALOG_SHAPE_PROPERTIES::TransferDataToWindow(), DIALOG_SHEET_PIN_PROPERTIES::TransferDataToWindow(), DIALOG_SHEET_PROPERTIES::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_WIRE_BUS_PROPERTIES::TransferDataToWindow(), PANEL_SETUP_FORMATTING::TransferDataToWindow(), DIALOG_GRID_SETTINGS::TransferDataToWindow(), DIALOG_PAGES_SETTINGS::TransferDataToWindow(), DIALOG_COPPER_ZONE::TransferDataToWindow(), DIALOG_DIMENSION_PROPERTIES::TransferDataToWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataToWindow(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataToWindow(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow(), DIALOG_NON_COPPER_ZONES_EDITOR::TransferDataToWindow(), DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataToWindow(), DIALOG_PAD_PRIMITIVE_POLY_PROPS::TransferDataToWindow(), DIALOG_PNS_DIFF_PAIR_DIMENSIONS::TransferDataToWindow(), DIALOG_PNS_LENGTH_TUNING_SETTINGS::TransferDataToWindow(), DIALOG_RULE_AREA_PROPERTIES::TransferDataToWindow(), DIALOG_TARGET_PROPERTIES::TransferDataToWindow(), DIALOG_TEXTBOX_PROPERTIES::TransferDataToWindow(), DIALOG_TRACK_VIA_SIZE::TransferDataToWindow(), PANEL_SETUP_CONSTRAINTS::TransferDataToWindow(), PANEL_SETUP_MASK_AND_PASTE::TransferDataToWindow(), PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataToWindow(), and WX_UNIT_ENTRY_DIALOG::WX_UNIT_ENTRY_DIALOG().

◆ Show()

void UNIT_BINDER::Show ( bool  aShow,
bool  aResize = false 
)

Show/hide the label, widget and units label.

Parameters
aShowcalled for the Show() routine in wx
aResizeif true, the element will be sized to 0 on hide and -1 on show

Definition at line 522 of file unit_binder.cpp.

523{
524 m_label->Show( aShow );
525 m_valueCtrl->Show( aShow );
526
527 if( m_unitLabel )
528 m_unitLabel->Show( aShow );
529
530 if( aResize )
531 {
532 if( aShow )
533 {
534 m_label->SetSize( -1, -1 );
535 m_valueCtrl->SetSize( -1, -1 );
536
537 if( m_unitLabel )
538 m_unitLabel->SetSize( -1, -1 );
539 }
540 else
541 {
542 m_label->SetSize( 0, 0 );
543 m_valueCtrl->SetSize( 0, 0 );
544
545 if( m_unitLabel )
546 m_unitLabel->SetSize( 0, 0 );
547 }
548 }
549}

References m_label, m_unitLabel, and m_valueCtrl.

Referenced by PROPERTIES_FRAME::CopyPrmsFromItemToPanel(), DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES(), DIALOG_DIMENSION_PROPERTIES::onFontSelected(), DIALOG_TEXT_PROPERTIES::onFontSelected(), DIALOG_TEXTBOX_PROPERTIES::onFontSelected(), DIALOG_PAD_PROPERTIES::OnUpdateUI(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow(), DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataToWindow(), DIALOG_PAD_PROPERTIES::updateHoleControls(), and DIALOG_PAD_PROPERTIES::updatePadSizeControls().

◆ Validate()

bool UNIT_BINDER::Validate ( double  aMin,
double  aMax,
EDA_UNITS  aUnits = EDA_UNITS::UNSCALED 
)
virtual

Validate the control against the given range, informing the user of any errors found.

Parameters
aMina minimum value for validation
aMaxa maximum value for validation
aUnitsthe units of the min/max parameters (use UNSCALED for internal units)
Returns
false on error.

Definition at line 242 of file unit_binder.cpp.

243{
244 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
245
246 if( !textEntry
247 || textEntry->GetValue() == INDETERMINATE_ACTION
248 || textEntry->GetValue() == INDETERMINATE_STATE )
249 {
250 return true;
251 }
252
253 // TODO: Validate() does not currently support m_dataType being anything other than DISTANCE
254 // Note: aMin and aMax are not always given in internal units
255 if( GetValue() < EDA_UNIT_UTILS::UI::FromUserUnit( m_iuScale, aUnits, aMin ) )
256 {
257 double val_min_iu = EDA_UNIT_UTILS::UI::FromUserUnit( m_iuScale, aUnits, aMin );
258 m_errorMessage = wxString::Format( _( "%s must be at least %s." ),
261 val_min_iu, true ) );
262
263 textEntry->SelectAll();
264
265 // Don't focus directly; we might be inside a KillFocus event handler
266 wxPostEvent( this, wxCommandEvent( DELAY_FOCUS ) );
267
268 return false;
269 }
270
271 if( GetValue() > EDA_UNIT_UTILS::UI::FromUserUnit( m_iuScale, aUnits, aMax ) )
272 {
273 double val_max_iu = EDA_UNIT_UTILS::UI::FromUserUnit( m_iuScale, aUnits, aMax );
274 m_errorMessage = wxString::Format( _( "%s must be less than %s." ),
277 val_max_iu, true ) );
278
279 textEntry->SelectAll();
280
281 // Don't focus directly; we might be inside a KillFocus event handler
282 wxPostEvent( this, wxCommandEvent( DELAY_FOCUS ) );
283
284 return false;
285 }
286
287 return true;
288}
#define _(s)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
wxString valueDescriptionFromLabel(wxStaticText *aLabel)

References _, Format(), EDA_UNIT_UTILS::UI::FromUserUnit(), GetValue(), INDETERMINATE_ACTION, INDETERMINATE_STATE, m_errorMessage, m_iuScale, m_label, m_units, m_valueCtrl, EDA_UNIT_UTILS::UI::StringFromValue(), and valueDescriptionFromLabel().

Referenced by DIALOG_PNS_LENGTH_TUNING_SETTINGS::AcceptOptions(), DIALOG_COPPER_ZONE::AcceptOptions(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataFromWindow(), DIALOG_LABEL_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_GRID_SETTINGS::TransferDataFromWindow(), DIALOG_PAGES_SETTINGS::TransferDataFromWindow(), DIALOG_NON_COPPER_ZONES_EDITOR::TransferDataFromWindow(), DIALOG_RULE_AREA_PROPERTIES::TransferDataFromWindow(), DIALOG_TARGET_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow(), DIALOG_TRACK_VIA_PROPERTIES::TransferDataFromWindow(), PANEL_SETUP_CONSTRAINTS::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::transferDataToPad(), DIALOG_FOOTPRINT_PROPERTIES::Validate(), and DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::Validate().

Member Data Documentation

◆ m_allowEval

bool UNIT_BINDER::m_allowEval
protected

◆ m_coordType

ORIGIN_TRANSFORMS::COORD_TYPES_T UNIT_BINDER::m_coordType
protected

Type of coordinate for display origin transforms.

Definition at line 248 of file unit_binder.h.

Referenced by ChangeDoubleValue(), ChangeValue(), GetCoordType(), GetDoubleValue(), GetValue(), SetCoordType(), SetDoubleValue(), and SetValue().

◆ m_dataType

EDA_DATA_TYPE UNIT_BINDER::m_dataType
protected

◆ m_errorMessage

wxString UNIT_BINDER::m_errorMessage
protected

Definition at line 235 of file unit_binder.h.

Referenced by delayedFocusHandler(), and Validate().

◆ m_eval

NUMERIC_EVALUATOR UNIT_BINDER::m_eval
protected

◆ m_frame

EDA_BASE_FRAME* UNIT_BINDER::m_frame
protected

The bound widgets.

Definition at line 221 of file unit_binder.h.

Referenced by onUnitsChanged(), UNIT_BINDER(), and ~UNIT_BINDER().

◆ m_iuScale

const EDA_IU_SCALE& UNIT_BINDER::m_iuScale
protected

◆ m_label

wxStaticText* UNIT_BINDER::m_label
protected

Definition at line 224 of file unit_binder.h.

Referenced by Enable(), SetLabel(), Show(), and Validate().

◆ m_needsEval

bool UNIT_BINDER::m_needsEval
protected

◆ m_negativeZero

bool UNIT_BINDER::m_negativeZero
protected

Indicates "-0" should be displayed for 0.

Definition at line 231 of file unit_binder.h.

Referenced by ChangeDoubleValue(), ChangeValue(), SetDoubleValue(), SetNegativeZero(), SetValue(), and UNIT_BINDER().

◆ m_originTransforms

ORIGIN_TRANSFORMS& UNIT_BINDER::m_originTransforms
protected

A reference to an ORIGIN_TRANSFORMS object.

Definition at line 245 of file unit_binder.h.

Referenced by ChangeDoubleValue(), ChangeValue(), GetDoubleValue(), GetValue(), SetDoubleValue(), and SetValue().

◆ m_precision

int UNIT_BINDER::m_precision
protected

0 to 6

Definition at line 233 of file unit_binder.h.

Referenced by setPrecision(), and SetPrecision().

◆ m_selEnd

long UNIT_BINDER::m_selEnd
protected

Definition at line 242 of file unit_binder.h.

Referenced by onKillFocus(), onSetFocus(), and UNIT_BINDER().

◆ m_selStart

long UNIT_BINDER::m_selStart
protected

Selection start and end of the original text.

Definition at line 241 of file unit_binder.h.

Referenced by onKillFocus(), onSetFocus(), and UNIT_BINDER().

◆ m_unitLabel

wxStaticText* UNIT_BINDER::m_unitLabel
protected

Can be nullptr.

Currently used units.

Definition at line 226 of file unit_binder.h.

Referenced by ChangeValue(), Enable(), SetDataType(), SetUnits(), SetValue(), Show(), and UNIT_BINDER().

◆ m_units

◆ m_valueCtrl


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