KiCad PCB EDA Suite
PROPERTY_EDITOR_UNIT_BINDER Class Reference

Specialization for wxPropertyGrid, where we have no labels and units are displayed in the editor. More...

#include <unit_binder.h>

Inheritance diagram for PROPERTY_EDITOR_UNIT_BINDER:
UNIT_BINDER

Public Member Functions

 PROPERTY_EDITOR_UNIT_BINDER (EDA_DRAW_FRAME *aParent)
 
virtual ~PROPERTY_EDITOR_UNIT_BINDER ()
 
void SetControl (wxWindow *aControl)
 
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 init (UNITS_PROVIDER *aProvider)
 
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

wxWindow * m_eventSource
 
bool m_bindFocusEvent
 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
 
bool m_unitsInValue
 Units label should be included in value text. More...
 
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

Specialization for wxPropertyGrid, where we have no labels and units are displayed in the editor.

Definition at line 261 of file unit_binder.h.

Constructor & Destructor Documentation

◆ PROPERTY_EDITOR_UNIT_BINDER()

PROPERTY_EDITOR_UNIT_BINDER::PROPERTY_EDITOR_UNIT_BINDER ( EDA_DRAW_FRAME aParent)

Definition at line 633 of file unit_binder.cpp.

633 :
634 UNIT_BINDER( aParent, nullptr, nullptr, nullptr, true, false )
635{
636 m_unitsInValue = true;
637}
bool m_unitsInValue
Units label should be included in value text.
Definition: unit_binder.h:248
UNIT_BINDER(EDA_DRAW_FRAME *aParent, wxStaticText *aLabel, wxWindow *aValueCtrl, wxStaticText *aUnitLabel, bool aAllowEval=true, bool aBindFocusEvent=true)
Definition: unit_binder.cpp:40

References UNIT_BINDER::m_unitsInValue.

◆ ~PROPERTY_EDITOR_UNIT_BINDER()

PROPERTY_EDITOR_UNIT_BINDER::~PROPERTY_EDITOR_UNIT_BINDER ( )
virtual

Definition at line 640 of file unit_binder.cpp.

641{
642}

Member Function Documentation

◆ ChangeAngleValue()

void UNIT_BINDER::ChangeAngleValue ( const EDA_ANGLE aValue)
virtualinherited

Definition at line 441 of file unit_binder.cpp.

442{
443 ChangeDoubleValue( aValue.AsDegrees() );
444}
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 UNIT_BINDER::ChangeDoubleValue().

Referenced by DIALOG_PAD_PROPERTIES::initValues().

◆ ChangeDoubleValue()

void UNIT_BINDER::ChangeDoubleValue ( double  aValue)
virtualinherited

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 427 of file unit_binder.cpp.

428{
429 double displayValue = m_originTransforms.ToDisplay( aValue, m_coordType );
431 setPrecision( displayValue, false ),
432 false, m_dataType );
433
434 if( displayValue == 0 && m_negativeZero )
435 ChangeValue( wxT( "-" ) + textValue );
436 else
437 ChangeValue( textValue );
438}
virtual int ToDisplay(int aValue, COORD_TYPES_T aCoordType) const
ORIGIN_TRANSFORMS::COORD_TYPES_T m_coordType
Type of coordinate for display origin transforms.
Definition: unit_binder.h:254
const EDA_IU_SCALE * m_iuScale
Definition: unit_binder.h:233
bool m_negativeZero
Indicates "-0" should be displayed for 0.
Definition: unit_binder.h:235
ORIGIN_TRANSFORMS & m_originTransforms
A reference to an ORIGIN_TRANSFORMS object.
Definition: unit_binder.h:251
EDA_UNITS m_units
Definition: unit_binder.h:234
double setPrecision(double aValue, bool aValueUsesUserUnits)
When m_precision > 0 truncate the value aValue to show only m_precision digits in mantissa.
EDA_DATA_TYPE m_dataType
Definition: unit_binder.h:236
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:225

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

Referenced by UNIT_BINDER::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)
inherited

Definition at line 447 of file unit_binder.cpp.

448{
449 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
450 wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_valueCtrl );
451
452 wxString value = aValue;
453
454 if( m_unitsInValue )
455 {
457 value += wxT( " " );
458
460 }
461
462 if( textEntry )
463 textEntry->ChangeValue( value );
464 else if( staticText )
465 staticText->SetLabel( value );
466
467 if( m_allowEval )
468 m_eval.Clear();
469
470 if( m_unitLabel )
472}
bool m_allowEval
Definition: unit_binder.h:242
wxStaticText * m_unitLabel
Can be nullptr.
Definition: unit_binder.h:230
wxWindow * m_valueCtrl
Definition: unit_binder.h:229
NUMERIC_EVALUATOR m_eval
Definition: unit_binder.h:241
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:128

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

◆ ChangeValue() [2/2]

◆ delayedFocusHandler()

void UNIT_BINDER::delayedFocusHandler ( wxCommandEvent &  aEvent)
protectedinherited

Definition at line 292 of file unit_binder.cpp.

293{
294 if( !m_errorMessage.IsEmpty() )
295 DisplayError( m_valueCtrl->GetParent(), m_errorMessage );
296
297 m_errorMessage = wxEmptyString;
298 m_valueCtrl->SetFocus();
299}
wxString m_errorMessage
Definition: unit_binder.h:239
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:300

References DisplayError(), UNIT_BINDER::m_errorMessage, and UNIT_BINDER::m_valueCtrl.

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

◆ Enable()

void UNIT_BINDER::Enable ( bool  aEnable)
inherited

Enable/disable the label, widget and units label.

Definition at line 593 of file unit_binder.cpp.

594{
595 m_label->Enable( aEnable );
596 m_valueCtrl->Enable( aEnable );
597
598 if( m_unitLabel )
599 m_unitLabel->Enable( aEnable );
600}
wxStaticText * m_label
Definition: unit_binder.h:228

References UNIT_BINDER::m_label, UNIT_BINDER::m_unitLabel, and UNIT_BINDER::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(), CONVERT_SETTINGS_DIALOG::onRadioButton(), 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(), DIALOG_TEXTBOX_PROPERTIES::TransferDataToWindow(), and CONVERT_SETTINGS_DIALOG::TransferDataToWindow().

◆ GetAngleValue()

◆ GetCoordType()

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

Get the origin transforms coordinate type.

Returns
the origin transforms coordinate type

Definition at line 179 of file unit_binder.h.

180 {
181 return m_coordType;
182 }

References UNIT_BINDER::m_coordType.

◆ GetDoubleValue()

double UNIT_BINDER::GetDoubleValue ( )
virtualinherited

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 524 of file unit_binder.cpp.

525{
526 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
527 wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_valueCtrl );
528 wxString value;
529
530 if( textEntry )
531 {
532 if( m_needsEval && m_eval.Process( textEntry->GetValue() ) )
533 value = m_eval.Result();
534 else
535 value = textEntry->GetValue();
536 }
537 else if( staticText )
538 {
539 value = staticText->GetLabel();
540 }
541 else
542 {
543 return 0.0;
544 }
545
547 value, m_dataType );
548 displayValue = setPrecision( displayValue, false );
549
550 return m_originTransforms.FromDisplay( displayValue, m_coordType );
551}
wxString Result() const
bool Process(const wxString &aString)
virtual int FromDisplay(int aValue, COORD_TYPES_T aCoordType) const
bool m_needsEval
Definition: unit_binder.h:243
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:445

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

Referenced by UNIT_BINDER::GetAngleValue(), DIALOG_POSITION_RELATIVE::getTranslationInIU(), DIALOG_MOVE_EXACT::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
inherited

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 571 of file unit_binder.cpp.

572{
573 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
574 wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_valueCtrl );
575
576 if( m_allowEval )
577 return m_eval.OriginalText();
578 else if( textEntry )
579 return textEntry->GetValue();
580 else if( staticText )
581 return staticText->GetLabel();
582 else
583 return wxEmptyString;
584}
wxString OriginalText() const

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

◆ GetValue()

long long int UNIT_BINDER::GetValue ( )
virtualinherited

Return the current value in Internal Units.

Definition at line 475 of file unit_binder.cpp.

476{
477 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
478 wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_valueCtrl );
479 wxString value;
480
481 if( textEntry )
482 {
483 if( m_needsEval && m_eval.Process( textEntry->GetValue() ) )
484 value = m_eval.Result();
485 else
486 value = textEntry->GetValue();
487 }
488 else if( staticText )
489 {
490 value = staticText->GetLabel();
491 }
492 else
493 {
494 return 0;
495 }
496
497 long long int displayValue = EDA_UNIT_UTILS::UI::ValueFromString( *m_iuScale, m_units, value,
498 m_dataType );
499 return m_originTransforms.FromDisplay( displayValue, m_coordType );
500}
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:525

References ORIGIN_TRANSFORMS::FromDisplay(), UNIT_BINDER::m_coordType, UNIT_BINDER::m_dataType, UNIT_BINDER::m_eval, UNIT_BINDER::m_iuScale, UNIT_BINDER::m_needsEval, UNIT_BINDER::m_originTransforms, UNIT_BINDER::m_units, UNIT_BINDER::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(), UNIT_BINDER::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(), CONVERT_SETTINGS_DIALOG::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::transferDataToPad(), TEARDROP_DIALOG::TransferToParamList(), DIALOG_PAD_PRIMITIVES_TRANSFORM::Transform(), PANEL_PREVIEW_3D_MODEL::updateBoardThickness(), DIALOG_DIMENSION_PROPERTIES::updateDimensionFromDialog(), DIALOG_GRAPHIC_ITEM_PROPERTIES::Validate(), UNIT_BINDER::Validate(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem(), and DIALOG_IMPORT_GFX::~DIALOG_IMPORT_GFX().

◆ init()

void UNIT_BINDER::init ( UNITS_PROVIDER aProvider)
protectedinherited

Definition at line 136 of file unit_binder.cpp.

137{
138 m_units = aProvider->GetUserUnits();
139 m_needsEval = false;
140 m_selStart = 0;
141 m_selEnd = 0;
142}
EDA_UNITS GetUserUnits() const
long m_selStart
Selection start and end of the original text.
Definition: unit_binder.h:245

References UNITS_PROVIDER::GetUserUnits(), UNIT_BINDER::m_needsEval, UNIT_BINDER::m_selEnd, UNIT_BINDER::m_selStart, and UNIT_BINDER::m_units.

Referenced by UNIT_BINDER::UNIT_BINDER().

◆ IsIndeterminate()

bool UNIT_BINDER::IsIndeterminate ( ) const
inherited

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

Definition at line 560 of file unit_binder.cpp.

561{
562 wxTextEntry* te = dynamic_cast<wxTextEntry*>( m_valueCtrl );
563
564 if( te )
565 return te->GetValue() == INDETERMINATE_STATE || te->GetValue() == INDETERMINATE_ACTION;
566
567 return false;
568}
#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 UNIT_BINDER::m_valueCtrl.

Referenced by UNIT_BINDER::onUnitsChanged(), 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)
protectedinherited

Definition at line 193 of file unit_binder.cpp.

194{
195 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
196
197 if( textEntry && ( textEntry->GetValue() == INDETERMINATE_ACTION
198 || textEntry->GetValue() == INDETERMINATE_STATE ) )
199 {
200 // These are tokens, not strings, so do a select all
201 textEntry->SelectAll();
202 }
203
204 // Needed at least on Windows to avoid hanging
205 aEvent.Skip();
206}

References INDETERMINATE_ACTION, INDETERMINATE_STATE, and UNIT_BINDER::m_valueCtrl.

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

◆ onKillFocus()

void UNIT_BINDER::onKillFocus ( wxFocusEvent &  aEvent)
protectedinherited

Definition at line 240 of file unit_binder.cpp.

241{
242 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
243
244 if( m_allowEval && textEntry )
245 {
246 if( m_eval.Process( textEntry->GetValue() ) )
247 {
248 textEntry->GetSelection( &m_selStart, &m_selEnd );
249
250 wxString value = m_eval.Result();
251
252 if( m_unitsInValue )
253 {
255 value += wxT( " " );
256
258 }
259
260 textEntry->ChangeValue( value );
261
262#ifdef __WXGTK__
263 // Manually copy the selected text to the primary selection clipboard
264 if( wxTheClipboard->Open() )
265 {
266 wxString sel = textEntry->GetStringSelection();
267 bool clipTarget = wxTheClipboard->IsUsingPrimarySelection();
268 wxTheClipboard->UsePrimarySelection( true );
269 wxTheClipboard->SetData( new wxTextDataObject( sel ) );
270 wxTheClipboard->UsePrimarySelection( clipTarget );
271 wxTheClipboard->Close();
272 }
273#endif
274 }
275
276 m_needsEval = false;
277 }
278
279 aEvent.Skip();
280}

References DEGREES, EDA_UNIT_UTILS::GetLabel(), UNIT_BINDER::m_allowEval, UNIT_BINDER::m_dataType, UNIT_BINDER::m_eval, UNIT_BINDER::m_needsEval, UNIT_BINDER::m_selEnd, UNIT_BINDER::m_selStart, UNIT_BINDER::m_units, UNIT_BINDER::m_unitsInValue, UNIT_BINDER::m_valueCtrl, PERCENT, NUMERIC_EVALUATOR::Process(), and NUMERIC_EVALUATOR::Result().

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

◆ onSetFocus()

void UNIT_BINDER::onSetFocus ( wxFocusEvent &  aEvent)
protectedinherited

Definition at line 209 of file unit_binder.cpp.

210{
211 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
212
213 if( textEntry )
214 {
215 if( m_allowEval )
216 {
217 wxString oldStr = m_eval.OriginalText();
218
219 if( oldStr.length() && oldStr != textEntry->GetValue() )
220 {
221 textEntry->SetValue( oldStr );
222 textEntry->SetSelection( m_selStart, m_selEnd );
223 }
224
225 m_needsEval = true;
226 }
227
228 if( textEntry->GetValue() == INDETERMINATE_ACTION
229 || textEntry->GetValue() == INDETERMINATE_STATE )
230 {
231 // These are tokens, not strings, so do a select all
232 textEntry->SelectAll();
233 }
234 }
235
236 aEvent.Skip();
237}

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

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

◆ onUnitsChanged()

void UNIT_BINDER::onUnitsChanged ( wxCommandEvent &  aEvent)
protectedinherited

Definition at line 172 of file unit_binder.cpp.

173{
174 EDA_BASE_FRAME* provider = static_cast<EDA_BASE_FRAME*>( aEvent.GetClientData() );
175
179 {
180 int temp = (int) GetValue();
181
182 SetUnits( provider->GetUserUnits() );
183 m_iuScale = &provider->GetIuScale();
184
185 if( !IsIndeterminate() )
186 SetValue( temp );
187 }
188
189 aEvent.Skip();
190}
The base frame for deriving all KiCad main window classes.
const EDA_IU_SCALE & GetIuScale() const
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...
bool IsIndeterminate() const
Return true if the control holds the indeterminate value (for instance, if it represents a multiple s...
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::GetIuScale(), UNITS_PROVIDER::GetUserUnits(), UNIT_BINDER::GetValue(), UNIT_BINDER::IsIndeterminate(), UNIT_BINDER::m_iuScale, UNIT_BINDER::m_units, PERCENT, UNIT_BINDER::SetUnits(), UNIT_BINDER::SetValue(), and UNSCALED.

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

◆ RequireEval()

void UNIT_BINDER::RequireEval ( )
inlineinherited

Force the binder to evaluate the text.

Definition at line 195 of file unit_binder.h.

196 {
197 m_needsEval = true;
198 }

References UNIT_BINDER::m_needsEval.

Referenced by DIALOG_MOVE_EXACT::DIALOG_MOVE_EXACT().

◆ SetAngleValue()

◆ SetControl()

void PROPERTY_EDITOR_UNIT_BINDER::SetControl ( wxWindow *  aControl)

Definition at line 644 of file unit_binder.cpp.

645{
646 m_valueCtrl = aControl;
647
648 if( m_valueCtrl )
649 {
650 m_valueCtrl->Bind( wxEVT_SET_FOCUS, &PROPERTY_EDITOR_UNIT_BINDER::onSetFocus, this );
651 m_valueCtrl->Bind( wxEVT_KILL_FOCUS, &PROPERTY_EDITOR_UNIT_BINDER::onKillFocus, this );
652 m_valueCtrl->Bind( wxEVT_LEFT_UP, &PROPERTY_EDITOR_UNIT_BINDER::onClick, this );
653
654 m_valueCtrl->Bind( wxEVT_SHOW,
655 [&]( wxShowEvent& e )
656 {
657 if( !e.IsShown() )
658 SetControl( nullptr );
659 } );
660 }
661}
void SetControl(wxWindow *aControl)
void onKillFocus(wxFocusEvent &aEvent)
void onClick(wxMouseEvent &aEvent)
void onSetFocus(wxFocusEvent &aEvent)

References UNIT_BINDER::m_valueCtrl, UNIT_BINDER::onClick(), UNIT_BINDER::onKillFocus(), UNIT_BINDER::onSetFocus(), and SetControl().

Referenced by SetControl().

◆ SetCoordType()

◆ SetDataType()

void UNIT_BINDER::SetDataType ( EDA_DATA_TYPE  aDataType)
inherited

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 163 of file unit_binder.cpp.

164{
165 m_dataType = aDataType;
166
167 if( m_unitLabel )
169}

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

Referenced by DIALOG_COPPER_ZONE::TransferDataToWindow().

◆ SetDoubleValue()

void UNIT_BINDER::SetDoubleValue ( double  aValue)
virtualinherited

◆ SetLabel()

void UNIT_BINDER::SetLabel ( const wxString &  aLabel)
inherited

Definition at line 587 of file unit_binder.cpp.

588{
589 m_label->SetLabel( aLabel );
590}

References UNIT_BINDER::m_label.

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

◆ SetNegativeZero()

◆ setPrecision()

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

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 503 of file unit_binder.cpp.

504{
505 if( m_precision > 1 )
506 {
507 int scale = pow( 10, m_precision );
508 int64_t tmp = aValue;
509 if( !aValueUsesUserUnits )
510 {
512 }
513
514 aValue = static_cast<double>( tmp ) / scale;
515
516 if( !aValueUsesUserUnits )
518 }
519
520 return aValue;
521}
int m_precision
0 to 6
Definition: unit_binder.h:237
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:385
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:190
const int scale

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

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

◆ SetPrecision()

void UNIT_BINDER::SetPrecision ( int  aLength)
virtualinherited

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 157 of file unit_binder.cpp.

158{
159 m_precision = std::min( aLength, 6 );
160}

References UNIT_BINDER::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)
virtualinherited

Normally not needed (as the UNIT_BINDER inherits from the parent frame), but can be used to set to DEGREES for angular controls.

Definition at line 145 of file unit_binder.cpp.

146{
147 m_units = aUnits;
148
150 m_eval.LocaleChanged(); // In case locale changed since last run
151
152 if( m_unitLabel )
154}
void SetDefaultUnits(EDA_UNITS aUnits)

References EDA_UNIT_UTILS::GetLabel(), NUMERIC_EVALUATOR::LocaleChanged(), UNIT_BINDER::m_dataType, UNIT_BINDER::m_eval, UNIT_BINDER::m_unitLabel, UNIT_BINDER::m_units, and NUMERIC_EVALUATOR::SetDefaultUnits().

Referenced by DIALOG_CREATE_ARRAY::DIALOG_CREATE_ARRAY(), DIALOG_DIMENSION_PROPERTIES::DIALOG_DIMENSION_PROPERTIES(), DIALOG_FOOTPRINT_PROPERTIES::DIALOG_FOOTPRINT_PROPERTIES(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR(), DIALOG_GRAPHIC_ITEM_PROPERTIES::DIALOG_GRAPHIC_ITEM_PROPERTIES(), DIALOG_MOVE_EXACT::DIALOG_MOVE_EXACT(), DIALOG_PAD_PRIMITIVES_TRANSFORM::DIALOG_PAD_PRIMITIVES_TRANSFORM(), DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES(), DIALOG_PNS_LENGTH_TUNING_SETTINGS::DIALOG_PNS_LENGTH_TUNING_SETTINGS(), DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES(), DIALOG_TEXTBOX_PROPERTIES::DIALOG_TEXTBOX_PROPERTIES(), UNIT_BINDER::onUnitsChanged(), PANEL_EDIT_OPTIONS::PANEL_EDIT_OPTIONS(), PANEL_SETUP_MASK_AND_PASTE::PANEL_SETUP_MASK_AND_PASTE(), PANEL_SETUP_FORMATTING::TransferDataToWindow(), DIALOG_COPPER_ZONE::TransferDataToWindow(), DIALOG_NON_COPPER_ZONES_EDITOR::TransferDataToWindow(), DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataToWindow(), DIALOG_MOVE_EXACT::updateDialogControls(), and DIALOG_POSITION_RELATIVE::updateDialogControls().

◆ SetValue() [1/2]

void UNIT_BINDER::SetValue ( const wxString &  aValue)
inherited

Definition at line 384 of file unit_binder.cpp.

385{
386 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
387 wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_valueCtrl );
388
389 wxString value = aValue;
390
391 if( m_unitsInValue )
392 {
394 value += wxT( " " );
395
397 }
398
399 if( textEntry )
400 textEntry->SetValue( value );
401 else if( staticText )
402 staticText->SetLabel( value );
403
404 if( m_allowEval )
405 m_eval.Clear();
406
407 if( m_unitLabel )
409
410}

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

◆ SetValue() [2/2]

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

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

Definition at line 351 of file unit_binder.cpp.

352{
353 double displayValue = m_originTransforms.ToDisplay( aValue, m_coordType );
354 wxString textValue = EDA_UNIT_UTILS::UI::StringFromValue( *m_iuScale, m_units, displayValue,
355 false, m_dataType );
356
357 if( displayValue == 0 && m_negativeZero )
358 SetValue( wxT( "-" ) + textValue );
359 else
360 SetValue( textValue );
361}

References UNIT_BINDER::m_coordType, UNIT_BINDER::m_dataType, UNIT_BINDER::m_iuScale, UNIT_BINDER::m_negativeZero, UNIT_BINDER::m_originTransforms, UNIT_BINDER::m_units, UNIT_BINDER::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(), UNIT_BINDER::onUnitsChanged(), MWAVE_POLYGONAL_SHAPE_DLG::ReadDataShapeDescr(), DIALOG_JUNCTION_PROPS::resetDefaults(), DIALOG_LINE_PROPERTIES::resetDefaults(), DIALOG_WIRE_BUS_PROPERTIES::resetDefaults(), UNIT_BINDER::SetDoubleValue(), DIALOG_LIB_NEW_SYMBOL::SetPinTextPosition(), UNIT_BINDER::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(), CONVERT_SETTINGS_DIALOG::TransferDataToWindow(), and WX_UNIT_ENTRY_DIALOG::WX_UNIT_ENTRY_DIALOG().

◆ Show()

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

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 603 of file unit_binder.cpp.

604{
605 m_label->Show( aShow );
606 m_valueCtrl->Show( aShow );
607
608 if( m_unitLabel )
609 m_unitLabel->Show( aShow );
610
611 if( aResize )
612 {
613 if( aShow )
614 {
615 m_label->SetSize( -1, -1 );
616 m_valueCtrl->SetSize( -1, -1 );
617
618 if( m_unitLabel )
619 m_unitLabel->SetSize( -1, -1 );
620 }
621 else
622 {
623 m_label->SetSize( 0, 0 );
624 m_valueCtrl->SetSize( 0, 0 );
625
626 if( m_unitLabel )
627 m_unitLabel->SetSize( 0, 0 );
628 }
629 }
630}

References UNIT_BINDER::m_label, UNIT_BINDER::m_unitLabel, and UNIT_BINDER::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 
)
virtualinherited

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 302 of file unit_binder.cpp.

303{
304 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
305
306 if( !textEntry
307 || textEntry->GetValue() == INDETERMINATE_ACTION
308 || textEntry->GetValue() == INDETERMINATE_STATE )
309 {
310 return true;
311 }
312
313 // TODO: Validate() does not currently support m_dataType being anything other than DISTANCE
314 // Note: aMin and aMax are not always given in internal units
315 if( GetValue() < EDA_UNIT_UTILS::UI::FromUserUnit( *m_iuScale, aUnits, aMin ) )
316 {
317 double val_min_iu = EDA_UNIT_UTILS::UI::FromUserUnit( *m_iuScale, aUnits, aMin );
318 m_errorMessage = wxString::Format( _( "%s must be at least %s." ),
321 val_min_iu, true ) );
322
323 textEntry->SelectAll();
324
325 // Don't focus directly; we might be inside a KillFocus event handler
326 wxPostEvent( this, wxCommandEvent( DELAY_FOCUS ) );
327
328 return false;
329 }
330
331 if( GetValue() > EDA_UNIT_UTILS::UI::FromUserUnit( *m_iuScale, aUnits, aMax ) )
332 {
333 double val_max_iu = EDA_UNIT_UTILS::UI::FromUserUnit( *m_iuScale, aUnits, aMax );
334 m_errorMessage = wxString::Format( _( "%s must be less than %s." ),
337 val_max_iu, true ) );
338
339 textEntry->SelectAll();
340
341 // Don't focus directly; we might be inside a KillFocus event handler
342 wxPostEvent( this, wxCommandEvent( DELAY_FOCUS ) );
343
344 return false;
345 }
346
347 return true;
348}
#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(), UNIT_BINDER::GetValue(), INDETERMINATE_ACTION, INDETERMINATE_STATE, UNIT_BINDER::m_errorMessage, UNIT_BINDER::m_iuScale, UNIT_BINDER::m_label, UNIT_BINDER::m_units, UNIT_BINDER::m_valueCtrl, EDA_UNIT_UTILS::UI::StringFromValue(), and valueDescriptionFromLabel().

Referenced by DIALOG_PNS_LENGTH_TUNING_SETTINGS::AcceptOptions(), DIALOG_COPPER_ZONE::AcceptOptions(), PROPERTIES_FRAME::CopyPrmsFromPanelToGeneral(), PROPERTIES_FRAME::CopyPrmsFromPanelToItem(), 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

◆ m_bindFocusEvent

bool UNIT_BINDER::m_bindFocusEvent
protectedinherited

The bound widgets.

Definition at line 225 of file unit_binder.h.

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

◆ m_coordType

◆ m_dataType

◆ m_errorMessage

wxString UNIT_BINDER::m_errorMessage
protectedinherited

Definition at line 239 of file unit_binder.h.

Referenced by UNIT_BINDER::delayedFocusHandler(), and UNIT_BINDER::Validate().

◆ m_eval

◆ m_eventSource

wxWindow* UNIT_BINDER::m_eventSource
protectedinherited

Definition at line 224 of file unit_binder.h.

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

◆ m_iuScale

◆ m_label

wxStaticText* UNIT_BINDER::m_label
protectedinherited

◆ m_needsEval

bool UNIT_BINDER::m_needsEval
protectedinherited

◆ m_negativeZero

bool UNIT_BINDER::m_negativeZero
protectedinherited

◆ m_originTransforms

◆ m_precision

int UNIT_BINDER::m_precision
protectedinherited

0 to 6

Definition at line 237 of file unit_binder.h.

Referenced by UNIT_BINDER::setPrecision(), and UNIT_BINDER::SetPrecision().

◆ m_selEnd

long UNIT_BINDER::m_selEnd
protectedinherited

◆ m_selStart

long UNIT_BINDER::m_selStart
protectedinherited

Selection start and end of the original text.

Definition at line 245 of file unit_binder.h.

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

◆ m_unitLabel

wxStaticText* UNIT_BINDER::m_unitLabel
protectedinherited

◆ m_units

◆ m_unitsInValue

bool UNIT_BINDER::m_unitsInValue
protectedinherited

Units label should be included in value text.

Definition at line 248 of file unit_binder.h.

Referenced by UNIT_BINDER::ChangeValue(), UNIT_BINDER::onKillFocus(), PROPERTY_EDITOR_UNIT_BINDER(), and UNIT_BINDER::SetValue().

◆ m_valueCtrl


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