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
70 // Gives enough room to display a value in inches in textEntry
71 // 3 digits + '.' + 10 digits
72 wxSize minSize = m_valueCtrl->GetMinSize();
73 int minWidth = dc.GetTextExtent( wxT( "XXX.XXXXXXXXXX" ) ).GetWidth();
74
75 if( minSize.GetWidth() < minWidth )
76 m_valueCtrl->SetMinSize( wxSize( minWidth, minSize.GetHeight() ) );
77
78 // Use ChangeValue() instead of SetValue() so we don't generate events.
79 if( m_negativeZero )
80 textEntry->ChangeValue( wxT( "-0" ) );
81 else
82 textEntry->ChangeValue( wxT( "0" ) );
83 }
84
85 if( m_unitLabel )
87
88 if( m_valueCtrl )
89 {
90 m_valueCtrl->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( UNIT_BINDER::onSetFocus ),
91 nullptr, this );
92 m_valueCtrl->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( UNIT_BINDER::onKillFocus ),
93 nullptr, this );
94 m_valueCtrl->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( UNIT_BINDER::onClick ),
95 nullptr, this );
96 }
97
99 {
100 Connect( DELAY_FOCUS, wxCommandEventHandler( UNIT_BINDER::delayedFocusHandler ), nullptr,
101 this );
102 }
103
104 if( aEventSource )
105 {
106 aEventSource->Connect( EDA_EVT_UNITS_CHANGED,
107 wxCommandEventHandler( UNIT_BINDER::onUnitsChanged ),
108 nullptr, this );
109 }
110}
111
112
114{
115 if( m_bindFocusEvent )
116 {
117 Disconnect( DELAY_FOCUS, wxCommandEventHandler( UNIT_BINDER::delayedFocusHandler ), nullptr,
118 this );
119 }
120
121 if( m_valueCtrl )
122 {
123 m_valueCtrl->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( UNIT_BINDER::onSetFocus ),
124 nullptr, this );
125 m_valueCtrl->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( UNIT_BINDER::onKillFocus ),
126 nullptr, this );
127 m_valueCtrl->Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( UNIT_BINDER::onClick ),
128 nullptr, this );
129 }
130}
131
132
134{
135 m_units = aProvider->GetUserUnits();
136 m_needsEval = false;
137 m_selStart = 0;
138 m_selEnd = 0;
139}
140
141
143{
144 m_units = aUnits;
145
147 m_eval.LocaleChanged(); // In case locale changed since last run
148
149 if( m_unitLabel )
151}
152
153
154void UNIT_BINDER::SetPrecision( int aLength )
155{
156 m_precision = std::min( aLength, 6 );
157}
158
159
161{
162 m_dataType = aDataType;
163
164 if( m_unitLabel )
166}
167
168
169void UNIT_BINDER::onUnitsChanged( wxCommandEvent& aEvent )
170{
171 EDA_BASE_FRAME* provider = static_cast<EDA_BASE_FRAME*>( aEvent.GetClientData() );
172
173 if( m_units != EDA_UNITS::UNSCALED
174 && m_units != EDA_UNITS::DEGREES
175 && m_units != EDA_UNITS::PERCENT )
176 {
177 int temp = GetIntValue();
178
179 SetUnits( provider->GetUserUnits() );
180 m_iuScale = &provider->GetIuScale();
181
182 if( !IsIndeterminate() )
183 SetValue( temp );
184 }
185
186 aEvent.Skip();
187}
188
189
190void UNIT_BINDER::onClick( wxMouseEvent& aEvent )
191{
192 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
193
194 if( textEntry && ( textEntry->GetValue() == INDETERMINATE_ACTION
195 || textEntry->GetValue() == INDETERMINATE_STATE ) )
196 {
197 // These are tokens, not strings, so do a select all
198 textEntry->SelectAll();
199 }
200
201 // Needed at least on Windows to avoid hanging
202 aEvent.Skip();
203}
204
205
206void UNIT_BINDER::onSetFocus( wxFocusEvent& aEvent )
207{
208 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
209
210 if( textEntry )
211 {
212 if( m_allowEval )
213 {
214 wxString oldStr = m_eval.OriginalText();
215
216 if( oldStr.length() && oldStr != textEntry->GetValue() )
217 {
218 textEntry->ChangeValue( oldStr );
219 textEntry->SetSelection( m_selStart, m_selEnd );
220 }
221
222 m_needsEval = true;
223 }
224
225 if( textEntry->GetValue() == INDETERMINATE_ACTION
226 || textEntry->GetValue() == INDETERMINATE_STATE )
227 {
228 // These are tokens, not strings, so do a select all
229 textEntry->SelectAll();
230 }
231 }
232
233 aEvent.Skip();
234}
235
236
237void UNIT_BINDER::onKillFocus( wxFocusEvent& aEvent )
238{
239 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
240
241 if( m_allowEval && textEntry )
242 {
243 wxString value = textEntry->GetValue();
244
245 if( !value.IsEmpty() && m_eval.Process( value ) )
246 {
247 textEntry->GetSelection( &m_selStart, &m_selEnd );
248
249 value = m_eval.Result();
250
251 if( m_unitsInValue && !value.IsEmpty() )
252 {
253 if( !( m_units == EDA_UNITS::DEGREES || m_units == EDA_UNITS::PERCENT ) )
254 value += wxT( " " );
255
257 }
258
259 textEntry->ChangeValue( value );
260
261#ifdef __WXGTK__
262 // Manually copy the selected text to the primary selection clipboard
263 if( wxTheClipboard->Open() )
264 {
265 wxString sel = textEntry->GetStringSelection();
266 bool clipTarget = wxTheClipboard->IsUsingPrimarySelection();
267 wxTheClipboard->UsePrimarySelection( true );
268 wxTheClipboard->SetData( new wxTextDataObject( sel ) );
269 wxTheClipboard->UsePrimarySelection( clipTarget );
270 wxTheClipboard->Close();
271 }
272#endif
273 }
274
275 m_needsEval = false;
276 }
277
278 aEvent.Skip();
279}
280
281
282wxString valueDescriptionFromLabel( wxStaticText* aLabel )
283{
284 wxString desc = aLabel->GetLabel();
285
286 desc.EndsWith( wxT( ":" ), &desc );
287 return desc;
288}
289
290
291void UNIT_BINDER::delayedFocusHandler( wxCommandEvent& )
292{
293 if( !m_errorMessage.IsEmpty() )
294 DisplayError( m_valueCtrl->GetParent(), m_errorMessage );
295
296 m_errorMessage = wxEmptyString;
297 m_valueCtrl->SetFocus();
298}
299
300
301bool UNIT_BINDER::Validate( double aMin, double aMax, EDA_UNITS aUnits )
302{
303 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
304
305 if( !textEntry
306 || textEntry->GetValue() == INDETERMINATE_ACTION
307 || textEntry->GetValue() == INDETERMINATE_STATE )
308 {
309 return true;
310 }
311
312 // TODO: Validate() does not currently support m_dataType being anything other than DISTANCE
313 // Note: aMin and aMax are not always given in internal units
314 if( GetValue() < EDA_UNIT_UTILS::UI::FromUserUnit( *m_iuScale, aUnits, aMin ) )
315 {
316 double val_min_iu = EDA_UNIT_UTILS::UI::FromUserUnit( *m_iuScale, aUnits, aMin );
317 m_errorMessage = wxString::Format( _( "%s must be at least %s." ),
320 val_min_iu,
321 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,
338 true ) );
339
340 textEntry->SelectAll();
341
342 // Don't focus directly; we might be inside a KillFocus event handler
343 wxPostEvent( this, wxCommandEvent( DELAY_FOCUS ) );
344
345 return false;
346 }
347
348 return true;
349}
350
351
352void UNIT_BINDER::SetValue( long long int aValue )
353{
354 double displayValue = m_originTransforms.ToDisplay( aValue, m_coordType );
355 wxString textValue = EDA_UNIT_UTILS::UI::StringFromValue( *m_iuScale, m_units, displayValue,
356 false, m_dataType );
357
358 if( displayValue == 0 && m_negativeZero )
359 SetValue( wxT( "-" ) + textValue );
360 else
361 SetValue( textValue );
362}
363
364
365void UNIT_BINDER::SetDoubleValue( double aValue )
366{
367 double displayValue = m_originTransforms.ToDisplay( aValue, m_coordType );
369 setPrecision( displayValue, false ),
370 false, m_dataType );
371
372 if( displayValue == 0 && !std::signbit( displayValue ) && m_negativeZero )
373 SetValue( wxT( "-" ) + textValue );
374 else
375 SetValue( textValue );
376}
377
378
380{
381 SetDoubleValue( aValue.AsDegrees() );
382}
383
384
385void UNIT_BINDER::SetValue( const wxString& aValue )
386{
387 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
388 wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_valueCtrl );
389
390 wxString value = aValue;
391
392 if( m_unitsInValue && !value.IsEmpty() )
393 {
394 if( !( m_units == EDA_UNITS::DEGREES || m_units == EDA_UNITS::PERCENT ) )
395 value += wxT( " " );
396
398 }
399
400 if( textEntry )
401 textEntry->SetValue( value );
402 else if( staticText )
403 staticText->SetLabel( value );
404
405 if( m_allowEval )
406 m_eval.Clear();
407
408 if( m_unitLabel )
410
411}
412
413
414void UNIT_BINDER::ChangeValue( int aValue )
415{
416 double displayValue = m_originTransforms.ToDisplay( aValue, m_coordType );
418 setPrecision( displayValue, false ),
419 false, m_dataType );
420
421 if( displayValue == 0 && m_negativeZero )
422 ChangeValue( wxT( "-" ) + textValue );
423 else
424 ChangeValue( textValue );
425}
426
427
429{
430 double displayValue = m_originTransforms.ToDisplay( aValue, m_coordType );
432 setPrecision( displayValue, false ),
433 false, m_dataType );
434
435 if( displayValue == 0 && !std::signbit( displayValue ) && m_negativeZero )
436 ChangeValue( wxT( "-" ) + textValue );
437 else
438 ChangeValue( textValue );
439}
440
441
443{
444 ChangeDoubleValue( aValue.AsDegrees() );
445}
446
447
448void UNIT_BINDER::ChangeValue( const wxString& aValue )
449{
450 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
451 wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_valueCtrl );
452
453 wxString value = aValue;
454
455 if( m_unitsInValue && !value.IsEmpty() )
456 {
457 if( !( m_units == EDA_UNITS::DEGREES || m_units == EDA_UNITS::PERCENT ) )
458 value += wxT( " " );
459
461 }
462
463 if( textEntry )
464 textEntry->ChangeValue( value );
465 else if( staticText )
466 staticText->SetLabel( value );
467
468 if( m_allowEval )
469 m_eval.Clear();
470
471 if( m_unitLabel )
473}
474
475
477{
478 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
479 wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_valueCtrl );
480 wxString value;
481
482 if( textEntry )
483 {
484 value = textEntry->GetValue();
485
486 if( m_needsEval && !value.IsEmpty() && m_eval.Process( value ) )
487 value = m_eval.Result();
488 else
489 value = textEntry->GetValue();
490 }
491 else if( staticText )
492 {
493 value = staticText->GetLabel();
494 }
495 else
496 {
497 return 0;
498 }
499
500 long long int displayValue = EDA_UNIT_UTILS::UI::ValueFromString( *m_iuScale, m_units, value,
501 m_dataType );
502 return m_originTransforms.FromDisplay( displayValue, m_coordType );
503}
504
505
506double UNIT_BINDER::setPrecision( double aValue, bool aValueUsesUserUnits )
507{
508 if( m_precision > 1 )
509 {
510 int scale = pow( 10, m_precision );
511 int64_t tmp = aValue;
512 if( !aValueUsesUserUnits )
513 {
515 }
516
517 aValue = static_cast<double>( tmp ) / scale;
518
519 if( !aValueUsesUserUnits )
521 }
522
523 return aValue;
524}
525
526
528{
529 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
530 wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_valueCtrl );
531 wxString value;
532
533 if( textEntry )
534 {
535 value = textEntry->GetValue();
536
537 if( m_needsEval && !value.IsEmpty() && m_eval.Process( value ) )
538 value = m_eval.Result();
539 else
540 value = textEntry->GetValue();
541 }
542 else if( staticText )
543 {
544 value = staticText->GetLabel();
545 }
546 else
547 {
548 return 0.0;
549 }
550
552 value, m_dataType );
553 displayValue = setPrecision( displayValue, false );
554
555 return m_originTransforms.FromDisplay( displayValue, m_coordType );
556}
557
558
560{
562}
563
564
566{
567 wxTextEntry* te = dynamic_cast<wxTextEntry*>( m_valueCtrl );
568
569 if( te )
570 return te->GetValue() == INDETERMINATE_STATE || te->GetValue() == INDETERMINATE_ACTION;
571
572 return false;
573}
574
575
577{
578 wxTextEntry* te = dynamic_cast<wxTextEntry*>( m_valueCtrl );
579
580 if( te )
581 return te->GetValue().IsEmpty();
582
583 return false;
584}
585
586
587void UNIT_BINDER::SetLabel( const wxString& aLabel )
588{
589 m_label->SetLabel( aLabel );
590}
591
592
593void UNIT_BINDER::Enable( bool aEnable )
594{
595 if( m_label )
596 m_label->Enable( aEnable );
597
598 m_valueCtrl->Enable( aEnable );
599
600 if( m_unitLabel )
601 m_unitLabel->Enable( aEnable );
602}
603
604
605void UNIT_BINDER::Show( bool aShow, bool aResize )
606{
607 m_label->Show( aShow );
608 m_valueCtrl->Show( aShow );
609
610 if( m_unitLabel )
611 m_unitLabel->Show( aShow );
612
613 if( aResize )
614 {
615 if( aShow )
616 {
617 m_label->SetSize( -1, -1 );
618 m_valueCtrl->SetSize( -1, -1 );
619
620 if( m_unitLabel )
621 m_unitLabel->SetSize( -1, -1 );
622 }
623 else
624 {
625 m_label->SetSize( 0, 0 );
626 m_valueCtrl->SetSize( 0, 0 );
627
628 if( m_unitLabel )
629 m_unitLabel->SetSize( 0, 0 );
630 }
631 }
632}
633
634
636 UNIT_BINDER( aParent, nullptr, nullptr, nullptr, true, false )
637{
638 m_unitsInValue = true;
639}
640
641
643{
644}
645
647{
648 m_valueCtrl = aControl;
649
650 if( m_valueCtrl )
651 {
652 m_valueCtrl->Bind( wxEVT_SET_FOCUS, &PROPERTY_EDITOR_UNIT_BINDER::onSetFocus, this );
653 m_valueCtrl->Bind( wxEVT_KILL_FOCUS, &PROPERTY_EDITOR_UNIT_BINDER::onKillFocus, this );
654 m_valueCtrl->Bind( wxEVT_LEFT_UP, &PROPERTY_EDITOR_UNIT_BINDER::onClick, this );
655
656 m_valueCtrl->Bind( wxEVT_SHOW,
657 [&]( wxShowEvent& e )
658 {
659 if( !e.IsShown() )
660 SetControl( nullptr );
661 } );
662 }
663}
double AsDegrees() const
Definition: eda_angle.h:155
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:254
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...
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:242
const EDA_IU_SCALE * m_iuScale
Definition: unit_binder.h:233
wxString m_errorMessage
Definition: unit_binder.h:239
virtual EDA_ANGLE GetAngleValue()
bool m_negativeZero
Indicates "-0" should be displayed for 0.
Definition: unit_binder.h:235
int m_precision
0 to 6
Definition: unit_binder.h:237
wxStaticText * m_unitLabel
Can be nullptr.
Definition: unit_binder.h:230
bool m_unitsInValue
Units label should be included in value text.
Definition: unit_binder.h:248
wxWindow * m_valueCtrl
Definition: unit_binder.h:229
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:228
ORIGIN_TRANSFORMS & m_originTransforms
A reference to an ORIGIN_TRANSFORMS object.
Definition: unit_binder.h:251
bool m_bindFocusEvent
The bound widgets.
Definition: unit_binder.h:225
long m_selStart
Selection start and end of the original text.
Definition: unit_binder.h:245
EDA_UNITS m_units
Definition: unit_binder.h:234
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:243
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:236
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:241
bool IsNull() const
Return true if the control holds no value (ie: empty string, not 0).
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:170
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:38
EDA_UNITS
Definition: eda_units.h:46
KICOMMON_API double FromUserUnit(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnit, double aValue)
Return in internal units the value aValue given in a real unit such as "in", "mm",...
Definition: eda_units.cpp:510
KICOMMON_API 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:671
KICOMMON_API 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:300
KICOMMON_API 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:576
KICOMMON_API 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:259
KICOMMON_API 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:155
int GetUserUnits()
Return the currently selected user unit value for the interface.
const int scale
#define INDETERMINATE_ACTION
Definition: ui_common.h:46
#define INDETERMINATE_STATE
Used for holding indeterminate values, such as with multiple selections holding different values or c...
Definition: ui_common.h:45
wxDEFINE_EVENT(DELAY_FOCUS, wxCommandEvent)
wxString valueDescriptionFromLabel(wxStaticText *aLabel)