22#ifndef __UNIT_BINDER_H_
23#define __UNIT_BINDER_H_
55 wxStaticText* aLabel, wxWindow* aValueCtrl, wxStaticText* aUnitLabel,
56 bool aAllowEval =
true,
bool aBindFocusEvent =
true );
59 wxStaticText* aLabel, wxWindow* aValueCtrl, wxStaticText* aUnitLabel,
60 bool aAllowEval =
true,
bool aBindFocusEvent =
true );
95 virtual void SetValue(
long long int aValue );
97 void SetValue(
const wxString& aValue );
129 virtual long long int GetValue()
const;
133 const long long int value =
GetValue();
134 const long long int clamped =
135 std::clamp<long long>( value,
static_cast<long long>( std::numeric_limits<int>::lowest() ),
136 static_cast<long long>( std::numeric_limits<int>::max() ) );
138 return static_cast<int>( clamped );
156 virtual void SetOptionsList( std::span<const long long int> aOptions );
182 void SetLabel(
const wxString& aLabel );
187 void Enable(
bool aEnable );
195 void Show(
bool aShow,
bool aResize =
false );
224 void onClick( wxMouseEvent& aEvent );
246 double setPrecision(
double aValue,
bool aValueUsesUserUnits )
const;
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
The base frame for deriving all KiCad main window classes.
The base class for create windows for drawing purpose.
void SetControl(wxWindow *aControl)
PROPERTY_EDITOR_UNIT_BINDER(EDA_DRAW_FRAME *aParent)
virtual ~PROPERTY_EDITOR_UNIT_BINDER()
double setPrecision(double aValue, bool aValueUsesUserUnits) const
When m_precision > 0 truncate the value aValue to show only m_precision digits in mantissa.
ORIGIN_TRANSFORMS::COORD_TYPES_T m_coordType
Type of coordinate for display origin transforms.
wxString getTextForValue(long long int aValue) const
virtual void ChangeDoubleValue(double aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion WITHOUT trigger...
void onKillFocus(wxFocusEvent &aEvent)
void Enable(bool aEnable)
Enable/disable the label, widget and units label.
void onClick(wxMouseEvent &aEvent)
DIALOG_SHIM * m_dialogShim
The dialog this binder registered itself with, or nullptr if it isn't owned by a dialog.
virtual void SetPrecision(int aLength)
Normally not needed, but can be used to set the precision when using internal units that are floats (...
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 double GetDoubleValue() const
Return the current value in Internal Units.
wxString getTextForDoubleValue(double aValue) const
const EDA_IU_SCALE * m_iuScale
Currently used units.
virtual EDA_ANGLE GetAngleValue()
bool m_negativeZero
Indicates "-0" should be displayed for 0.
virtual long long int GetValue() const
Return the current value in Internal Units.
wxStaticText * m_unitLabel
Can be nullptr.
virtual void SetNegativeZero()
bool m_unitsInValue
Units label should be included in value text.
void onSetFocus(wxFocusEvent &aEvent)
void onComboBox(wxCommandEvent &aEvent)
UNIT_BINDER(EDA_DRAW_FRAME *aParent, wxStaticText *aLabel, wxWindow *aValueCtrl, wxStaticText *aUnitLabel, bool aAllowEval=true, bool aBindFocusEvent=true)
wxStaticText * m_label
The bound widgets.
ORIGIN_TRANSFORMS & m_originTransforms
A reference to an ORIGIN_TRANSFORMS object.
long m_selStart
Selection start and end of the original text.
virtual void SetDoubleOptionsList(std::span< const double > aOptions)
void onValueCtrlDestroyed(wxWindowDestroyEvent &aEvent)
virtual void SetOptionsList(std::span< const long long int > aOptions)
Set the list of options for a combobox control.
bool IsIndeterminate() const
Return true if the control holds the indeterminate value (for instance, if it represents a multiple s...
void SetDataType(EDA_DATA_TYPE aDataType)
Used to override the datatype of the displayed property (default is DISTANCE)
void RequireEval()
Force the binder to evaluate the text.
void delayedFocusHandler(wxCommandEvent &aEvent)
ORIGIN_TRANSFORMS::COORD_TYPES_T GetCoordType() const
Get the origin transforms coordinate type.
virtual void SetAngleValue(const EDA_ANGLE &aValue)
void SetLabel(const wxString &aLabel)
virtual void ChangeAngleValue(const EDA_ANGLE &aValue)
virtual void SetDoubleValue(double aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
void DetachFromDialogShim()
Sever the back-reference to the owning dialog.
virtual ~UNIT_BINDER() override
bool UnitsInvariant() const
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.
virtual void ChangeValue(int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion WITHOUT trigger...
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
void Show(bool aShow, bool aResize=false)
Show/hide the label, widget and units label.
void SetCoordType(ORIGIN_TRANSFORMS::COORD_TYPES_T aCoordType)
Set the current origin transform mode.
bool IsNull() const
Return true if the control holds no value (ie: empty string, not 0).
void onUnitsChanged(wxCommandEvent &aEvent)
EDA_DATA_TYPE
The type of unit.