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 if( m_eval.Process( textEntry->GetValue() ) )
244 {
245 textEntry->GetSelection( &m_selStart, &m_selEnd );
246
247 wxString value = m_eval.Result();
248
249 if( m_unitsInValue )
250 {
251 if( !( m_units == EDA_UNITS::DEGREES || m_units == EDA_UNITS::PERCENT ) )
252 value += wxT( " " );
253
255 }
256
257 textEntry->ChangeValue( value );
258
259#ifdef __WXGTK__
260 // Manually copy the selected text to the primary selection clipboard
261 if( wxTheClipboard->Open() )
262 {
263 wxString sel = textEntry->GetStringSelection();
264 bool clipTarget = wxTheClipboard->IsUsingPrimarySelection();
265 wxTheClipboard->UsePrimarySelection( true );
266 wxTheClipboard->SetData( new wxTextDataObject( sel ) );
267 wxTheClipboard->UsePrimarySelection( clipTarget );
268 wxTheClipboard->Close();
269 }
270#endif
271 }
272
273 m_needsEval = false;
274 }
275
276 aEvent.Skip();
277}
278
279
280wxString valueDescriptionFromLabel( wxStaticText* aLabel )
281{
282 wxString desc = aLabel->GetLabel();
283
284 desc.EndsWith( wxT( ":" ), &desc );
285 return desc;
286}
287
288
289void UNIT_BINDER::delayedFocusHandler( wxCommandEvent& )
290{
291 if( !m_errorMessage.IsEmpty() )
292 DisplayError( m_valueCtrl->GetParent(), m_errorMessage );
293
294 m_errorMessage = wxEmptyString;
295 m_valueCtrl->SetFocus();
296}
297
298
299bool UNIT_BINDER::Validate( double aMin, double aMax, EDA_UNITS aUnits )
300{
301 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
302
303 if( !textEntry
304 || textEntry->GetValue() == INDETERMINATE_ACTION
305 || textEntry->GetValue() == INDETERMINATE_STATE )
306 {
307 return true;
308 }
309
310 // TODO: Validate() does not currently support m_dataType being anything other than DISTANCE
311 // Note: aMin and aMax are not always given in internal units
312 if( GetValue() < EDA_UNIT_UTILS::UI::FromUserUnit( *m_iuScale, aUnits, aMin ) )
313 {
314 double val_min_iu = EDA_UNIT_UTILS::UI::FromUserUnit( *m_iuScale, aUnits, aMin );
315 m_errorMessage = wxString::Format( _( "%s must be at least %s." ),
318 val_min_iu,
319 true ) );
320
321 textEntry->SelectAll();
322
323 // Don't focus directly; we might be inside a KillFocus event handler
324 wxPostEvent( this, wxCommandEvent( DELAY_FOCUS ) );
325
326 return false;
327 }
328
329 if( GetValue() > EDA_UNIT_UTILS::UI::FromUserUnit( *m_iuScale, aUnits, aMax ) )
330 {
331 double val_max_iu = EDA_UNIT_UTILS::UI::FromUserUnit( *m_iuScale, aUnits, aMax );
332 m_errorMessage = wxString::Format( _( "%s must be less than %s." ),
335 val_max_iu,
336 true ) );
337
338 textEntry->SelectAll();
339
340 // Don't focus directly; we might be inside a KillFocus event handler
341 wxPostEvent( this, wxCommandEvent( DELAY_FOCUS ) );
342
343 return false;
344 }
345
346 return true;
347}
348
349
350void UNIT_BINDER::SetValue( long long int aValue )
351{
352 double displayValue = m_originTransforms.ToDisplay( aValue, m_coordType );
353 wxString textValue = EDA_UNIT_UTILS::UI::StringFromValue( *m_iuScale, m_units, displayValue,
354 false, m_dataType );
355
356 if( displayValue == 0 && m_negativeZero )
357 SetValue( wxT( "-" ) + textValue );
358 else
359 SetValue( textValue );
360}
361
362
363void UNIT_BINDER::SetDoubleValue( double aValue )
364{
365 double displayValue = m_originTransforms.ToDisplay( aValue, m_coordType );
367 setPrecision( displayValue, false ),
368 false, m_dataType );
369
370 if( displayValue == 0 && !std::signbit( displayValue ) && m_negativeZero )
371 SetValue( wxT( "-" ) + textValue );
372 else
373 SetValue( textValue );
374}
375
376
378{
379 SetDoubleValue( aValue.AsDegrees() );
380}
381
382
383void UNIT_BINDER::SetValue( const wxString& aValue )
384{
385 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
386 wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_valueCtrl );
387
388 wxString value = aValue;
389
390 if( m_unitsInValue )
391 {
392 if( !( m_units == EDA_UNITS::DEGREES || m_units == EDA_UNITS::PERCENT ) )
393 value += wxT( " " );
394
396 }
397
398 if( textEntry )
399 textEntry->SetValue( value );
400 else if( staticText )
401 staticText->SetLabel( value );
402
403 if( m_allowEval )
404 m_eval.Clear();
405
406 if( m_unitLabel )
408
409}
410
411
412void UNIT_BINDER::ChangeValue( int aValue )
413{
414 double displayValue = m_originTransforms.ToDisplay( aValue, m_coordType );
416 setPrecision( displayValue, false ),
417 false, m_dataType );
418
419 if( displayValue == 0 && m_negativeZero )
420 ChangeValue( wxT( "-" ) + textValue );
421 else
422 ChangeValue( textValue );
423}
424
425
427{
428 double displayValue = m_originTransforms.ToDisplay( aValue, m_coordType );
430 setPrecision( displayValue, false ),
431 false, m_dataType );
432
433 if( displayValue == 0 && !std::signbit( displayValue ) && m_negativeZero )
434 ChangeValue( wxT( "-" ) + textValue );
435 else
436 ChangeValue( textValue );
437}
438
439
441{
442 ChangeDoubleValue( aValue.AsDegrees() );
443}
444
445
446void UNIT_BINDER::ChangeValue( const wxString& aValue )
447{
448 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
449 wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_valueCtrl );
450
451 wxString value = aValue;
452
453 if( m_unitsInValue )
454 {
455 if( !( m_units == EDA_UNITS::DEGREES || m_units == EDA_UNITS::PERCENT ) )
456 value += wxT( " " );
457
459 }
460
461 if( textEntry )
462 textEntry->ChangeValue( value );
463 else if( staticText )
464 staticText->SetLabel( value );
465
466 if( m_allowEval )
467 m_eval.Clear();
468
469 if( m_unitLabel )
471}
472
473
475{
476 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
477 wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_valueCtrl );
478 wxString value;
479
480 if( textEntry )
481 {
482 if( m_needsEval && m_eval.Process( textEntry->GetValue() ) )
483 value = m_eval.Result();
484 else
485 value = textEntry->GetValue();
486 }
487 else if( staticText )
488 {
489 value = staticText->GetLabel();
490 }
491 else
492 {
493 return 0;
494 }
495
496 long long int displayValue = EDA_UNIT_UTILS::UI::ValueFromString( *m_iuScale, m_units, value,
497 m_dataType );
498 return m_originTransforms.FromDisplay( displayValue, m_coordType );
499}
500
501
502double UNIT_BINDER::setPrecision( double aValue, bool aValueUsesUserUnits )
503{
504 if( m_precision > 1 )
505 {
506 int scale = pow( 10, m_precision );
507 int64_t tmp = aValue;
508 if( !aValueUsesUserUnits )
509 {
511 }
512
513 aValue = static_cast<double>( tmp ) / scale;
514
515 if( !aValueUsesUserUnits )
517 }
518
519 return aValue;
520}
521
522
524{
525 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
526 wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_valueCtrl );
527 wxString value;
528
529 if( textEntry )
530 {
531 if( m_needsEval && m_eval.Process( textEntry->GetValue() ) )
532 value = m_eval.Result();
533 else
534 value = textEntry->GetValue();
535 }
536 else if( staticText )
537 {
538 value = staticText->GetLabel();
539 }
540 else
541 {
542 return 0.0;
543 }
544
546 value, m_dataType );
547 displayValue = setPrecision( displayValue, false );
548
549 return m_originTransforms.FromDisplay( displayValue, m_coordType );
550}
551
552
554{
556}
557
558
560{
561 wxTextEntry* te = dynamic_cast<wxTextEntry*>( m_valueCtrl );
562
563 if( te )
564 return te->GetValue() == INDETERMINATE_STATE || te->GetValue() == INDETERMINATE_ACTION;
565
566 return false;
567}
568
569
571{
572 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
573 wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_valueCtrl );
574
575 if( m_allowEval )
576 return m_eval.OriginalText();
577 else if( textEntry )
578 return textEntry->GetValue();
579 else if( staticText )
580 return staticText->GetLabel();
581 else
582 return wxEmptyString;
583}
584
585
586void UNIT_BINDER::SetLabel( const wxString& aLabel )
587{
588 m_label->SetLabel( aLabel );
589}
590
591
592void UNIT_BINDER::Enable( bool aEnable )
593{
594 if( m_label )
595 m_label->Enable( aEnable );
596
597 m_valueCtrl->Enable( aEnable );
598
599 if( m_unitLabel )
600 m_unitLabel->Enable( aEnable );
601}
602
603
604void UNIT_BINDER::Show( bool aShow, bool aResize )
605{
606 m_label->Show( aShow );
607 m_valueCtrl->Show( aShow );
608
609 if( m_unitLabel )
610 m_unitLabel->Show( aShow );
611
612 if( aResize )
613 {
614 if( aShow )
615 {
616 m_label->SetSize( -1, -1 );
617 m_valueCtrl->SetSize( -1, -1 );
618
619 if( m_unitLabel )
620 m_unitLabel->SetSize( -1, -1 );
621 }
622 else
623 {
624 m_label->SetSize( 0, 0 );
625 m_valueCtrl->SetSize( 0, 0 );
626
627 if( m_unitLabel )
628 m_unitLabel->SetSize( 0, 0 );
629 }
630 }
631}
632
633
635 UNIT_BINDER( aParent, nullptr, nullptr, nullptr, true, false )
636{
637 m_unitsInValue = true;
638}
639
640
642{
643}
644
646{
647 m_valueCtrl = aControl;
648
649 if( m_valueCtrl )
650 {
651 m_valueCtrl->Bind( wxEVT_SET_FOCUS, &PROPERTY_EDITOR_UNIT_BINDER::onSetFocus, this );
652 m_valueCtrl->Bind( wxEVT_KILL_FOCUS, &PROPERTY_EDITOR_UNIT_BINDER::onKillFocus, this );
653 m_valueCtrl->Bind( wxEVT_LEFT_UP, &PROPERTY_EDITOR_UNIT_BINDER::onClick, this );
654
655 m_valueCtrl->Bind( wxEVT_SHOW,
656 [&]( wxShowEvent& e )
657 {
658 if( !e.IsShown() )
659 SetControl( nullptr );
660 } );
661 }
662}
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:280
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:499
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:660
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:284
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:565
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:243
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:139
int GetUserUnits()
Return the currently selected user unit value for the interface.
const int scale
#define INDETERMINATE_ACTION
Definition: ui_common.h:45
#define INDETERMINATE_STATE
Used for holding indeterminate values, such as with multiple selections holding different values or c...
Definition: ui_common.h:44
wxDEFINE_EVENT(DELAY_FOCUS, wxCommandEvent)
wxString valueDescriptionFromLabel(wxStaticText *aLabel)