KiCad PCB EDA Suite
Loading...
Searching...
No Matches
unit_binder.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2014-2015 CERN
5 * Copyright (C) 2020-2023 KiCad Developers, see AUTHORS.txt for contributors.
6 * Author: Maciej Suminski <[email protected]>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include <wx/clipbrd.h>
27#include <wx/stattext.h>
28#include <wx/textentry.h>
29#include <eda_units.h>
30#include <eda_draw_frame.h>
31#include <confirm.h>
32
33#include "widgets/unit_binder.h"
34#include "wx/dcclient.h"
35
36
37wxDEFINE_EVENT( DELAY_FOCUS, wxCommandEvent );
38
39
40UNIT_BINDER::UNIT_BINDER( EDA_DRAW_FRAME* aParent, wxStaticText* aLabel, wxWindow* aValueCtrl,
41 wxStaticText* aUnitLabel, bool allowEval, bool aBindFrameEvents ) :
42 UNIT_BINDER( aParent, aParent, aLabel, aValueCtrl, aUnitLabel, allowEval, aBindFrameEvents )
43{
44}
45
46UNIT_BINDER::UNIT_BINDER( UNITS_PROVIDER* aUnitsProvider, wxWindow* aEventSource,
47 wxStaticText* aLabel, wxWindow* aValueCtrl, wxStaticText* aUnitLabel,
48 bool aAllowEval, bool aBindFocusEvent ) :
49 m_bindFocusEvent( aBindFocusEvent ),
50 m_label( aLabel ),
51 m_valueCtrl( aValueCtrl ),
52 m_unitLabel( aUnitLabel ),
53 m_iuScale( &aUnitsProvider->GetIuScale() ),
54 m_negativeZero( false ),
55 m_dataType( EDA_DATA_TYPE::DISTANCE ),
56 m_precision( 0 ),
57 m_eval( aUnitsProvider->GetUserUnits() ),
58 m_unitsInValue( false ),
59 m_originTransforms( aUnitsProvider->GetOriginTransforms() ),
60 m_coordType( ORIGIN_TRANSFORMS::NOT_A_COORD )
61{
62 init( aUnitsProvider );
63 m_allowEval = aAllowEval && ( !m_valueCtrl || dynamic_cast<wxTextEntry*>( m_valueCtrl ) );
64 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
65
66 if( textEntry )
67 {
68 wxClientDC dc( m_valueCtrl );
69 wxSize minSize = m_valueCtrl->GetMinSize();
70 int minWidth = dc.GetTextExtent( wxT( "XXX.XXXXXXX" ) ).GetWidth();
71
72 if( minSize.GetWidth() < minWidth )
73 m_valueCtrl->SetMinSize( wxSize( minWidth, minSize.GetHeight() ) );
74
75 // Use ChangeValue() instead of SetValue() so we don't generate events.
76 if( m_negativeZero )
77 textEntry->ChangeValue( wxT( "-0" ) );
78 else
79 textEntry->ChangeValue( wxT( "0" ) );
80 }
81
82 if( m_unitLabel )
84
85 if( m_valueCtrl )
86 {
87 m_valueCtrl->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( UNIT_BINDER::onSetFocus ),
88 nullptr, this );
89 m_valueCtrl->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( UNIT_BINDER::onKillFocus ),
90 nullptr, this );
91 m_valueCtrl->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( UNIT_BINDER::onClick ),
92 nullptr, this );
93 }
94
96 {
97 Connect( DELAY_FOCUS, wxCommandEventHandler( UNIT_BINDER::delayedFocusHandler ), nullptr,
98 this );
99 }
100
101 if( aEventSource )
102 {
103 aEventSource->Connect( EDA_EVT_UNITS_CHANGED,
104 wxCommandEventHandler( UNIT_BINDER::onUnitsChanged ),
105 nullptr, this );
106 }
107}
108
109
111{
112 if( m_bindFocusEvent )
113 {
114 Disconnect( DELAY_FOCUS, wxCommandEventHandler( UNIT_BINDER::delayedFocusHandler ), nullptr,
115 this );
116 }
117
118 if( m_valueCtrl )
119 {
120 m_valueCtrl->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( UNIT_BINDER::onSetFocus ),
121 nullptr, this );
122 m_valueCtrl->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( UNIT_BINDER::onKillFocus ),
123 nullptr, this );
124 m_valueCtrl->Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( UNIT_BINDER::onClick ),
125 nullptr, this );
126 }
127}
128
129
131{
132 m_units = aProvider->GetUserUnits();
133 m_needsEval = false;
134 m_selStart = 0;
135 m_selEnd = 0;
136}
137
138
140{
141 m_units = aUnits;
142
144 m_eval.LocaleChanged(); // In case locale changed since last run
145
146 if( m_unitLabel )
148}
149
150
151void UNIT_BINDER::SetPrecision( int aLength )
152{
153 m_precision = std::min( aLength, 6 );
154}
155
156
158{
159 m_dataType = aDataType;
160
161 if( m_unitLabel )
163}
164
165
166void UNIT_BINDER::onUnitsChanged( wxCommandEvent& aEvent )
167{
168 EDA_BASE_FRAME* provider = static_cast<EDA_BASE_FRAME*>( aEvent.GetClientData() );
169
170 if( m_units != EDA_UNITS::UNSCALED
171 && m_units != EDA_UNITS::DEGREES
172 && m_units != EDA_UNITS::PERCENT )
173 {
174 int temp = GetIntValue();
175
176 SetUnits( provider->GetUserUnits() );
177 m_iuScale = &provider->GetIuScale();
178
179 if( !IsIndeterminate() )
180 SetValue( temp );
181 }
182
183 aEvent.Skip();
184}
185
186
187void UNIT_BINDER::onClick( wxMouseEvent& aEvent )
188{
189 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
190
191 if( textEntry && ( textEntry->GetValue() == INDETERMINATE_ACTION
192 || textEntry->GetValue() == INDETERMINATE_STATE ) )
193 {
194 // These are tokens, not strings, so do a select all
195 textEntry->SelectAll();
196 }
197
198 // Needed at least on Windows to avoid hanging
199 aEvent.Skip();
200}
201
202
203void UNIT_BINDER::onSetFocus( wxFocusEvent& aEvent )
204{
205 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
206
207 if( textEntry )
208 {
209 if( m_allowEval )
210 {
211 wxString oldStr = m_eval.OriginalText();
212
213 if( oldStr.length() && oldStr != textEntry->GetValue() )
214 {
215 textEntry->SetValue( oldStr );
216 textEntry->SetSelection( m_selStart, m_selEnd );
217 }
218
219 m_needsEval = true;
220 }
221
222 if( textEntry->GetValue() == INDETERMINATE_ACTION
223 || textEntry->GetValue() == INDETERMINATE_STATE )
224 {
225 // These are tokens, not strings, so do a select all
226 textEntry->SelectAll();
227 }
228 }
229
230 aEvent.Skip();
231}
232
233
234void UNIT_BINDER::onKillFocus( wxFocusEvent& aEvent )
235{
236 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
237
238 if( m_allowEval && textEntry )
239 {
240 if( m_eval.Process( textEntry->GetValue() ) )
241 {
242 textEntry->GetSelection( &m_selStart, &m_selEnd );
243
244 wxString value = m_eval.Result();
245
246 if( m_unitsInValue )
247 {
248 if( !( m_units == EDA_UNITS::DEGREES || m_units == EDA_UNITS::PERCENT ) )
249 value += wxT( " " );
250
252 }
253
254 textEntry->ChangeValue( value );
255
256#ifdef __WXGTK__
257 // Manually copy the selected text to the primary selection clipboard
258 if( wxTheClipboard->Open() )
259 {
260 wxString sel = textEntry->GetStringSelection();
261 bool clipTarget = wxTheClipboard->IsUsingPrimarySelection();
262 wxTheClipboard->UsePrimarySelection( true );
263 wxTheClipboard->SetData( new wxTextDataObject( sel ) );
264 wxTheClipboard->UsePrimarySelection( clipTarget );
265 wxTheClipboard->Close();
266 }
267#endif
268 }
269
270 m_needsEval = false;
271 }
272
273 aEvent.Skip();
274}
275
276
277wxString valueDescriptionFromLabel( wxStaticText* aLabel )
278{
279 wxString desc = aLabel->GetLabel();
280
281 desc.EndsWith( wxT( ":" ), &desc );
282 return desc;
283}
284
285
286void UNIT_BINDER::delayedFocusHandler( wxCommandEvent& )
287{
288 if( !m_errorMessage.IsEmpty() )
289 DisplayError( m_valueCtrl->GetParent(), m_errorMessage );
290
291 m_errorMessage = wxEmptyString;
292 m_valueCtrl->SetFocus();
293}
294
295
296bool UNIT_BINDER::Validate( double aMin, double aMax, EDA_UNITS aUnits )
297{
298 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
299
300 if( !textEntry
301 || textEntry->GetValue() == INDETERMINATE_ACTION
302 || textEntry->GetValue() == INDETERMINATE_STATE )
303 {
304 return true;
305 }
306
307 // TODO: Validate() does not currently support m_dataType being anything other than DISTANCE
308 // Note: aMin and aMax are not always given in internal units
309 if( GetValue() < EDA_UNIT_UTILS::UI::FromUserUnit( *m_iuScale, aUnits, aMin ) )
310 {
311 double val_min_iu = EDA_UNIT_UTILS::UI::FromUserUnit( *m_iuScale, aUnits, aMin );
312 m_errorMessage = wxString::Format( _( "%s must be at least %s." ),
315 val_min_iu,
316 true ) );
317
318 textEntry->SelectAll();
319
320 // Don't focus directly; we might be inside a KillFocus event handler
321 wxPostEvent( this, wxCommandEvent( DELAY_FOCUS ) );
322
323 return false;
324 }
325
326 if( GetValue() > EDA_UNIT_UTILS::UI::FromUserUnit( *m_iuScale, aUnits, aMax ) )
327 {
328 double val_max_iu = EDA_UNIT_UTILS::UI::FromUserUnit( *m_iuScale, aUnits, aMax );
329 m_errorMessage = wxString::Format( _( "%s must be less than %s." ),
332 val_max_iu,
333 true ) );
334
335 textEntry->SelectAll();
336
337 // Don't focus directly; we might be inside a KillFocus event handler
338 wxPostEvent( this, wxCommandEvent( DELAY_FOCUS ) );
339
340 return false;
341 }
342
343 return true;
344}
345
346
347void UNIT_BINDER::SetValue( long long int aValue )
348{
349 double displayValue = m_originTransforms.ToDisplay( aValue, m_coordType );
350 wxString textValue = EDA_UNIT_UTILS::UI::StringFromValue( *m_iuScale, m_units, displayValue,
351 false, m_dataType );
352
353 if( displayValue == 0 && m_negativeZero )
354 SetValue( wxT( "-" ) + textValue );
355 else
356 SetValue( textValue );
357}
358
359
360void UNIT_BINDER::SetDoubleValue( double aValue )
361{
362 double displayValue = m_originTransforms.ToDisplay( aValue, m_coordType );
364 setPrecision( displayValue, false ),
365 false, m_dataType );
366
367 if( displayValue == 0 && !std::signbit( displayValue ) && m_negativeZero )
368 SetValue( wxT( "-" ) + textValue );
369 else
370 SetValue( textValue );
371}
372
373
375{
376 SetDoubleValue( aValue.AsDegrees() );
377}
378
379
380void UNIT_BINDER::SetValue( const wxString& aValue )
381{
382 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
383 wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_valueCtrl );
384
385 wxString value = aValue;
386
387 if( m_unitsInValue )
388 {
389 if( !( m_units == EDA_UNITS::DEGREES || m_units == EDA_UNITS::PERCENT ) )
390 value += wxT( " " );
391
393 }
394
395 if( textEntry )
396 textEntry->SetValue( value );
397 else if( staticText )
398 staticText->SetLabel( value );
399
400 if( m_allowEval )
401 m_eval.Clear();
402
403 if( m_unitLabel )
405
406}
407
408
409void UNIT_BINDER::ChangeValue( int aValue )
410{
411 double displayValue = m_originTransforms.ToDisplay( aValue, m_coordType );
413 setPrecision( displayValue, false ),
414 false, m_dataType );
415
416 if( displayValue == 0 && m_negativeZero )
417 ChangeValue( wxT( "-" ) + textValue );
418 else
419 ChangeValue( textValue );
420}
421
422
424{
425 double displayValue = m_originTransforms.ToDisplay( aValue, m_coordType );
427 setPrecision( displayValue, false ),
428 false, m_dataType );
429
430 if( displayValue == 0 && !std::signbit( displayValue ) && m_negativeZero )
431 ChangeValue( wxT( "-" ) + textValue );
432 else
433 ChangeValue( textValue );
434}
435
436
438{
439 ChangeDoubleValue( aValue.AsDegrees() );
440}
441
442
443void UNIT_BINDER::ChangeValue( const wxString& aValue )
444{
445 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
446 wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_valueCtrl );
447
448 wxString value = aValue;
449
450 if( m_unitsInValue )
451 {
452 if( !( m_units == EDA_UNITS::DEGREES || m_units == EDA_UNITS::PERCENT ) )
453 value += wxT( " " );
454
456 }
457
458 if( textEntry )
459 textEntry->ChangeValue( value );
460 else if( staticText )
461 staticText->SetLabel( value );
462
463 if( m_allowEval )
464 m_eval.Clear();
465
466 if( m_unitLabel )
468}
469
470
472{
473 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
474 wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_valueCtrl );
475 wxString value;
476
477 if( textEntry )
478 {
479 if( m_needsEval && m_eval.Process( textEntry->GetValue() ) )
480 value = m_eval.Result();
481 else
482 value = textEntry->GetValue();
483 }
484 else if( staticText )
485 {
486 value = staticText->GetLabel();
487 }
488 else
489 {
490 return 0;
491 }
492
493 long long int displayValue = EDA_UNIT_UTILS::UI::ValueFromString( *m_iuScale, m_units, value,
494 m_dataType );
495 return m_originTransforms.FromDisplay( displayValue, m_coordType );
496}
497
498
499double UNIT_BINDER::setPrecision( double aValue, bool aValueUsesUserUnits )
500{
501 if( m_precision > 1 )
502 {
503 int scale = pow( 10, m_precision );
504 int64_t tmp = aValue;
505 if( !aValueUsesUserUnits )
506 {
508 }
509
510 aValue = static_cast<double>( tmp ) / scale;
511
512 if( !aValueUsesUserUnits )
514 }
515
516 return aValue;
517}
518
519
521{
522 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
523 wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_valueCtrl );
524 wxString value;
525
526 if( textEntry )
527 {
528 if( m_needsEval && m_eval.Process( textEntry->GetValue() ) )
529 value = m_eval.Result();
530 else
531 value = textEntry->GetValue();
532 }
533 else if( staticText )
534 {
535 value = staticText->GetLabel();
536 }
537 else
538 {
539 return 0.0;
540 }
541
543 value, m_dataType );
544 displayValue = setPrecision( displayValue, false );
545
546 return m_originTransforms.FromDisplay( displayValue, m_coordType );
547}
548
549
551{
553}
554
555
557{
558 wxTextEntry* te = dynamic_cast<wxTextEntry*>( m_valueCtrl );
559
560 if( te )
561 return te->GetValue() == INDETERMINATE_STATE || te->GetValue() == INDETERMINATE_ACTION;
562
563 return false;
564}
565
566
568{
569 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
570 wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_valueCtrl );
571
572 if( m_allowEval )
573 return m_eval.OriginalText();
574 else if( textEntry )
575 return textEntry->GetValue();
576 else if( staticText )
577 return staticText->GetLabel();
578 else
579 return wxEmptyString;
580}
581
582
583void UNIT_BINDER::SetLabel( const wxString& aLabel )
584{
585 m_label->SetLabel( aLabel );
586}
587
588
589void UNIT_BINDER::Enable( bool aEnable )
590{
591 m_label->Enable( aEnable );
592 m_valueCtrl->Enable( aEnable );
593
594 if( m_unitLabel )
595 m_unitLabel->Enable( aEnable );
596}
597
598
599void UNIT_BINDER::Show( bool aShow, bool aResize )
600{
601 m_label->Show( aShow );
602 m_valueCtrl->Show( aShow );
603
604 if( m_unitLabel )
605 m_unitLabel->Show( aShow );
606
607 if( aResize )
608 {
609 if( aShow )
610 {
611 m_label->SetSize( -1, -1 );
612 m_valueCtrl->SetSize( -1, -1 );
613
614 if( m_unitLabel )
615 m_unitLabel->SetSize( -1, -1 );
616 }
617 else
618 {
619 m_label->SetSize( 0, 0 );
620 m_valueCtrl->SetSize( 0, 0 );
621
622 if( m_unitLabel )
623 m_unitLabel->SetSize( 0, 0 );
624 }
625 }
626}
627
628
630 UNIT_BINDER( aParent, nullptr, nullptr, nullptr, true, false )
631{
632 m_unitsInValue = true;
633}
634
635
637{
638}
639
641{
642 m_valueCtrl = aControl;
643
644 if( m_valueCtrl )
645 {
646 m_valueCtrl->Bind( wxEVT_SET_FOCUS, &PROPERTY_EDITOR_UNIT_BINDER::onSetFocus, this );
647 m_valueCtrl->Bind( wxEVT_KILL_FOCUS, &PROPERTY_EDITOR_UNIT_BINDER::onKillFocus, this );
648 m_valueCtrl->Bind( wxEVT_LEFT_UP, &PROPERTY_EDITOR_UNIT_BINDER::onClick, this );
649
650 m_valueCtrl->Bind( wxEVT_SHOW,
651 [&]( wxShowEvent& e )
652 {
653 if( !e.IsShown() )
654 SetControl( nullptr );
655 } );
656 }
657}
double AsDegrees() const
Definition: eda_angle.h:149
The base frame for deriving all KiCad main window classes.
The base class for create windows for drawing purpose.
wxString OriginalText() const
wxString Result() const
void SetDefaultUnits(EDA_UNITS aUnits)
bool Process(const wxString &aString)
A class to perform either relative or absolute display origin transforms for a single axis of a point...
virtual int FromDisplay(int aValue, COORD_TYPES_T aCoordType) const
virtual int ToDisplay(int aValue, COORD_TYPES_T aCoordType) const
void SetControl(wxWindow *aControl)
PROPERTY_EDITOR_UNIT_BINDER(EDA_DRAW_FRAME *aParent)
const EDA_IU_SCALE & GetIuScale() const
EDA_UNITS GetUserUnits() const
ORIGIN_TRANSFORMS::COORD_TYPES_T m_coordType
Type of coordinate for display origin transforms.
Definition: unit_binder.h:255
int GetIntValue()
Definition: unit_binder.h:127
virtual void ChangeDoubleValue(double aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion WITHOUT trigger...
wxString GetOriginalText() const
Return the pre-evaluated text (or the current text if evaluation is not supported).
void onKillFocus(wxFocusEvent &aEvent)
virtual long long int GetValue()
Return the current value in Internal Units.
void Enable(bool aEnable)
Enable/disable the label, widget and units label.
void onClick(wxMouseEvent &aEvent)
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...
bool m_allowEval
Definition: unit_binder.h:243
const EDA_IU_SCALE * m_iuScale
Definition: unit_binder.h:234
wxString m_errorMessage
Definition: unit_binder.h:240
virtual EDA_ANGLE GetAngleValue()
bool m_negativeZero
Indicates "-0" should be displayed for 0.
Definition: unit_binder.h:236
int m_precision
0 to 6
Definition: unit_binder.h:238
wxStaticText * m_unitLabel
Can be nullptr.
Definition: unit_binder.h:231
bool m_unitsInValue
Units label should be included in value text.
Definition: unit_binder.h:249
wxWindow * m_valueCtrl
Definition: unit_binder.h:230
void onSetFocus(wxFocusEvent &aEvent)
UNIT_BINDER(EDA_DRAW_FRAME *aParent, wxStaticText *aLabel, wxWindow *aValueCtrl, wxStaticText *aUnitLabel, bool aAllowEval=true, bool aBindFocusEvent=true)
Definition: unit_binder.cpp:40
wxStaticText * m_label
Definition: unit_binder.h:229
ORIGIN_TRANSFORMS & m_originTransforms
A reference to an ORIGIN_TRANSFORMS object.
Definition: unit_binder.h:252
bool m_bindFocusEvent
The bound widgets.
Definition: unit_binder.h:226
long m_selStart
Selection start and end of the original text.
Definition: unit_binder.h:246
EDA_UNITS m_units
Definition: unit_binder.h:235
virtual double GetDoubleValue()
Return the current value in Internal Units.
double setPrecision(double aValue, bool aValueUsesUserUnits)
When m_precision > 0 truncate the value aValue to show only m_precision digits in mantissa.
bool IsIndeterminate() const
Return true if the control holds the indeterminate value (for instance, if it represents a multiple s...
bool m_needsEval
Definition: unit_binder.h:244
void SetDataType(EDA_DATA_TYPE aDataType)
Used to override the datatype of the displayed property (default is DISTANCE)
void delayedFocusHandler(wxCommandEvent &aEvent)
EDA_DATA_TYPE m_dataType
Definition: unit_binder.h:237
virtual void SetAngleValue(const EDA_ANGLE &aValue)
void SetLabel(const wxString &aLabel)
void init(UNITS_PROVIDER *aProvider)
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.
virtual ~UNIT_BINDER() override
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.
NUMERIC_EVALUATOR m_eval
Definition: unit_binder.h:242
void onUnitsChanged(wxCommandEvent &aEvent)
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:283
This file is part of the common library.
const int minSize
Push and Shove router track width and via size dialog.
#define _(s)
@ DEGREES_T
Definition: eda_angle.h:31
EDA_DATA_TYPE
The type of unit.
Definition: eda_units.h:36
EDA_UNITS
Definition: eda_units.h:43
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
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
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
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
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
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
int GetUserUnits()
Return the currently selected user unit value for the interface.
const int scale
#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
wxDEFINE_EVENT(DELAY_FOCUS, wxCommandEvent)
wxString valueDescriptionFromLabel(wxStaticText *aLabel)