KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pg_editors.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <eda_draw_frame.h>
27#include <widgets/ui_common.h>
28#include <widgets/unit_binder.h>
29#include <bitmaps.h>
30#include <frame_type.h>
31#include <kiway_player.h>
32#include <kiway.h>
33#include <wx/filedlg.h>
34#include <wx/intl.h>
35#include <eda_doc.h>
36#include <kiplatform/ui.h>
37#include <kiway_mail.h>
38
39#include <wx/button.h>
40#include <wx/bmpbuttn.h>
41
42#include <wx/log.h>
43
44const wxString PG_UNIT_EDITOR::EDITOR_NAME = wxS( "KiCadUnitEditor" );
45const wxString PG_CHECKBOX_EDITOR::EDITOR_NAME = wxS( "KiCadCheckboxEditor" );
46const wxString PG_COLOR_EDITOR::EDITOR_NAME = wxS( "KiCadColorEditor" );
47const wxString PG_RATIO_EDITOR::EDITOR_NAME = wxS( "KiCadRatioEditor" );
48const wxString PG_FPID_EDITOR::EDITOR_NAME = wxS( "KiCadFpidEditor" );
49const wxString PG_URL_EDITOR::EDITOR_NAME = wxS( "KiCadUrlEditor" );
50
51
53 wxPGTextCtrlEditor(),
54 m_frame( aFrame )
55{
56 m_unitBinder = std::make_unique<PROPERTY_EDITOR_UNIT_BINDER>( m_frame );
57 m_unitBinder->SetUnits( m_frame->GetUserUnits() );
58
60}
61
62
66
67
69{
70 if( !aFrame )
71 return EDITOR_NAME + "NoFrame";
72
73 return EDITOR_NAME + aFrame->GetName();
74}
75
76
78{
79 m_frame = aFrame;
80
81 if( aFrame )
82 {
83 m_unitBinder = std::make_unique<PROPERTY_EDITOR_UNIT_BINDER>( m_frame );
84 m_unitBinder->SetUnits( m_frame->GetUserUnits() );
85 }
86 else
87 {
88 m_unitBinder = nullptr;
89 }
90}
91
92
93wxPGWindowList PG_UNIT_EDITOR::CreateControls( wxPropertyGrid* aPropGrid, wxPGProperty* aProperty,
94 const wxPoint& aPos, const wxSize& aSize ) const
95{
96 wxASSERT( m_unitBinder );
97
98#if wxCHECK_VERSION( 3, 3, 0 )
99 wxString text = aProperty->GetValueAsString( wxPGPropValFormatFlags::EditableValue );
100#else
101 wxString text = aProperty->GetValueAsString( wxPG_EDITABLE_VALUE );
102#endif
103 wxWindow* win = aPropGrid->GenerateEditorTextCtrl( aPos, aSize, text, nullptr, 0,
104 aProperty->GetMaxLength() );
105 wxPGWindowList ret( win, nullptr );
106
107 m_unitBinder->SetControl( win );
108 m_unitBinder->RequireEval();
109 m_unitBinder->SetUnits( m_frame->GetUserUnits() );
110
111 if( PGPROPERTY_DISTANCE* prop = dynamic_cast<PGPROPERTY_DISTANCE*>( aProperty ) )
112 {
113 m_unitBinder->SetCoordType( prop->CoordType() );
114 }
115 else if( dynamic_cast<PGPROPERTY_AREA*>( aProperty) != nullptr )
116 {
117 m_unitBinder->SetDataType( EDA_DATA_TYPE::AREA );
118 }
119 else if( dynamic_cast<PGPROPERTY_ANGLE*>( aProperty ) != nullptr )
120 {
122 m_unitBinder->SetDataType( EDA_DATA_TYPE::ANGLE );
123 m_unitBinder->SetUnits( EDA_UNITS::DEGREES );
124 }
125 else if( dynamic_cast<PGPROPERTY_TIME*>( aProperty ) != nullptr )
126 {
127 m_unitBinder->SetUnits( EDA_UNITS::PS );
128 }
129
130 UpdateControl( aProperty, win );
131
132 return ret;
133}
134
135
136void PG_UNIT_EDITOR::UpdateControl( wxPGProperty* aProperty, wxWindow* aCtrl ) const
137{
138 wxVariant var = aProperty->GetValue();
139
140 // Shown as a mix, not blank. Set on the control since the binder would append units
141 if( aProperty->IsValueUnspecified() )
142 {
143 if( wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( aCtrl ) )
144 textEntry->ChangeValue( INDETERMINATE_STATE );
145
146 return;
147 }
148
149 if( PGPROPERTY_ANGLE* angleProp = dynamic_cast<PGPROPERTY_ANGLE*>( aProperty ) )
150 {
151 if( var.GetType() == wxT( "EDA_ANGLE" ) )
152 {
153 EDA_ANGLE_VARIANT_DATA* angleData =
154 static_cast<EDA_ANGLE_VARIANT_DATA*>( var.GetData() );
155 m_unitBinder->ChangeAngleValue( angleData->Angle() );
156 }
157 else if( !aProperty->IsValueUnspecified() )
158 {
159 double scale = angleProp->GetScale();
160 m_unitBinder->ChangeDoubleValue( var.GetDouble() / scale );
161 }
162 }
163 else if( var.GetType() == wxT( "std::optional<int>" ) )
164 {
165 auto* variantData = static_cast<STD_OPTIONAL_INT_VARIANT_DATA*>( var.GetData() );
166
167 if( variantData->OptValue().has_value() )
168 m_unitBinder->ChangeValue( variantData->OptValue().value() );
169 else
170 m_unitBinder->ChangeValue( wxEmptyString );
171 }
172 else if( var.GetType() == wxPG_VARIANT_TYPE_LONG )
173 {
174 m_unitBinder->ChangeValue( var.GetLong() );
175 }
176 else if( var.GetType() == wxPG_VARIANT_TYPE_LONGLONG )
177 {
178 m_unitBinder->ChangeDoubleValue( var.GetLongLong().ToDouble() );
179 }
180 else if( var.GetType() == wxPG_VARIANT_TYPE_DOUBLE )
181 {
182 m_unitBinder->ChangeValue( var.GetDouble() );
183 }
184 else if( var.GetType() == wxT( "EDA_ANGLE" ) )
185 {
186 EDA_ANGLE_VARIANT_DATA* angleData = static_cast<EDA_ANGLE_VARIANT_DATA*>( var.GetData() );
187 m_unitBinder->ChangeAngleValue( angleData->Angle() );
188 }
189 else if( !aProperty->IsValueUnspecified() )
190 {
191 wxFAIL_MSG( wxT( "PG_UNIT_EDITOR should only be used with numeric properties!" ) );
192 }
193}
194
195
196bool PG_UNIT_EDITOR::OnEvent( wxPropertyGrid* aPropGrid, wxPGProperty* aProperty,
197 wxWindow* aCtrl, wxEvent& aEvent ) const
198{
199 if( aEvent.GetEventType() == wxEVT_LEFT_UP )
200 {
201 if( wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( aCtrl ) )
202 {
203 if( !textCtrl->HasFocus() )
204 {
205 textCtrl->SelectAll();
206 return false;
207 }
208 }
209 }
210
211 return wxPGTextCtrlEditor::OnEvent( aPropGrid, aProperty, aCtrl, aEvent );
212}
213
214
215bool PG_UNIT_EDITOR::GetValueFromControl( wxVariant& aVariant, wxPGProperty* aProperty,
216 wxWindow* aCtrl ) const
217{
218 if( !m_unitBinder )
219 return false;
220
221 wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( aCtrl );
222 wxCHECK_MSG( textCtrl, false, "PG_UNIT_EDITOR requires a text control!" );
223 wxString textVal = textCtrl->GetValue();
224
225 if( textVal == wxT( "<...>" ) )
226 {
227 aVariant.MakeNull();
228 return true;
229 }
230
231 // A mixed value left as it was is not an edit
232 if( textVal == INDETERMINATE_STATE )
233 return false;
234
235 bool changed;
236
237 if( dynamic_cast<PGPROPERTY_ANGLE*>( aProperty ) != nullptr )
238 {
239 EDA_ANGLE angle = m_unitBinder->GetAngleValue();
240
241 if( aVariant.GetType() == wxT( "EDA_ANGLE" ) )
242 {
243 EDA_ANGLE_VARIANT_DATA* ad = static_cast<EDA_ANGLE_VARIANT_DATA*>( aVariant.GetData() );
244 changed = ( aVariant.IsNull() || angle != ad->Angle() );
245
246 if( changed )
247 {
248 ad->SetAngle( angle );
249 m_unitBinder->SetAngleValue( angle );
250 }
251 }
252 else
253 {
254 PGPROPERTY_ANGLE* angleProp = static_cast<PGPROPERTY_ANGLE*>( aProperty );
255 double scaledValue = angle.AsDegrees() * angleProp->GetScale();
256
257 changed = ( aVariant.IsNull() || scaledValue != aVariant.GetDouble() );
258
259 if( changed )
260 {
261 aVariant = scaledValue;
262 m_unitBinder->SetDoubleValue( angle.AsDegrees() );
263 }
264 }
265 }
266 else if( dynamic_cast<PGPROPERTY_AREA*>( aProperty ) != nullptr )
267 {
268 wxLongLongNative result = m_unitBinder->GetValue();
269 changed = ( aVariant.IsNull() || result != aVariant.GetLongLong() );
270
271 if( changed )
272 {
273 aVariant = result;
274 m_unitBinder->SetDoubleValue( result.ToDouble() );
275 }
276 }
277 else if( aVariant.GetType() == wxT( "std::optional<int>" ) )
278 {
279 auto* variantData = static_cast<STD_OPTIONAL_INT_VARIANT_DATA*>( aVariant.GetData() );
280 std::optional<int> result;
281
282 if( m_unitBinder->IsNull() )
283 {
284 changed = ( aVariant.IsNull() || variantData->OptValue().has_value() );
285
286 if( changed )
287 {
288 aVariant = wxVariant( std::optional<int>() );
289 m_unitBinder->SetValue( wxEmptyString );
290 }
291 }
292 else
293 {
294 result = std::optional<int>( m_unitBinder->GetIntValue() );
295 changed = ( aVariant.IsNull() || result != variantData->OptValue() );
296
297 if( changed )
298 {
299 aVariant = wxVariant( result );
300 m_unitBinder->SetValue( result.value() );
301 }
302 }
303 }
304 else
305 {
306 long result = m_unitBinder->GetValue();
307 changed = ( aVariant.IsNull() || result != aVariant.GetLong() );
308
309 if( changed )
310 {
311 aVariant = result;
312 m_unitBinder->SetValue( result );
313 }
314 }
315
316 // Changing unspecified always causes event (returning true here should be enough to trigger it).
317 if( !changed && aVariant.IsNull() )
318 changed = true;
319
320 return changed;
321}
322
323
325 wxPGCheckBoxEditor()
326{
327}
328
329
330wxPGWindowList PG_CHECKBOX_EDITOR::CreateControls( wxPropertyGrid* aGrid, wxPGProperty* aProperty,
331 const wxPoint& aPos, const wxSize& aSize ) const
332{
333 // Override wx behavior and toggle unspecified checkboxes to "true"
334 // CreateControls for a checkbox editor is only triggered when the user activates the checkbox
335 // Set the value to false here; the base class will then trigger an event setting it true.
336 if( aProperty->IsValueUnspecified() )
337 aProperty->SetValueFromInt( 0 );
338
339 return wxPGCheckBoxEditor::CreateControls( aGrid, aProperty, aPos, aSize );
340}
341
342
343bool PG_COLOR_EDITOR::OnEvent( wxPropertyGrid* aGrid, wxPGProperty* aProperty, wxWindow* aWindow,
344 wxEvent& aEvent ) const
345{
346 return false;
347}
348
349
350wxPGWindowList PG_COLOR_EDITOR::CreateControls( wxPropertyGrid* aGrid, wxPGProperty* aProperty,
351 const wxPoint& aPos, const wxSize& aSize ) const
352{
353 auto colorProp = dynamic_cast<PGPROPERTY_COLOR4D*>( aProperty );
354
355 if( !colorProp )
356 return nullptr;
357
358 KIGFX::COLOR4D color = colorFromProperty( aProperty );
359 KIGFX::COLOR4D defColor = colorFromVariant( colorProp->GetDefaultValue() );
360
361 COLOR_SWATCH* editor = new COLOR_SWATCH( aGrid->GetPanel(), color, wxID_ANY,
362 colorProp->GetBackgroundColor(), defColor,
363 SWATCH_LARGE, true );
364 editor->SetPosition( aPos );
365 editor->SetSize( aSize );
366
367 // Capture property name instead of pointer to avoid dangling pointer if grid is rebuilt
368 wxString propName = colorProp->GetName();
369
370 editor->Bind( COLOR_SWATCH_CHANGED,
371 [=]( wxCommandEvent& aEvt )
372 {
373 wxPGProperty* prop = aGrid->GetPropertyByName( propName );
374
375 if( prop )
376 {
377 wxVariant val;
378 auto data = new COLOR4D_VARIANT_DATA( editor->GetSwatchColor() );
379 val.SetData( data );
380 aGrid->ChangePropertyValue( prop, val );
381 }
382 } );
383
384#if wxCHECK_VERSION( 3, 3, 0 )
385 if( aGrid->GetInternalFlags() & wxPropertyGrid::wxPG_FL_ACTIVATION_BY_CLICK )
386#else
387 if( aGrid->GetInternalFlags() & wxPG_FL_ACTIVATION_BY_CLICK )
388#endif
389 {
390 aGrid->CallAfter(
391 [=]()
392 {
393 editor->GetNewSwatchColor();
394
395 wxPGProperty* prop = aGrid->GetPropertyByName( propName );
396
397 if( prop )
398 aGrid->DrawItem( prop );
399 } );
400 }
401
402 return editor;
403}
404
405
406void PG_COLOR_EDITOR::UpdateControl( wxPGProperty* aProperty, wxWindow* aCtrl ) const
407{
408 if( auto swatch = dynamic_cast<COLOR_SWATCH*>( aCtrl ) )
409 swatch->SetSwatchColor( colorFromProperty( aProperty ), false );
410}
411
412
413KIGFX::COLOR4D PG_COLOR_EDITOR::colorFromVariant( const wxVariant& aVariant ) const
414{
416 COLOR4D_VARIANT_DATA* data = nullptr;
417
418 if( aVariant.IsType( wxS( "COLOR4D" ) ) )
419 {
420 data = static_cast<COLOR4D_VARIANT_DATA*>( aVariant.GetData() );
421 color = data->Color();
422 }
423
424 return color;
425}
426
427
429{
430 return colorFromVariant( aProperty->GetValue() );
431}
432
433
434bool PG_RATIO_EDITOR::GetValueFromControl( wxVariant& aVariant, wxPGProperty* aProperty,
435 wxWindow* aCtrl ) const
436{
437 wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( aCtrl );
438 wxCHECK_MSG( textCtrl, false, "PG_RATIO_EDITOR requires a text control!" );
439 wxString textVal = textCtrl->GetValue();
440
441 if( textVal == wxT( "<...>" ) )
442 {
443 aVariant.MakeNull();
444 return true;
445 }
446
447 bool changed;
448
449 if( aVariant.GetType() == wxT( "std::optional<double>" ) )
450 {
451 auto* variantData = static_cast<STD_OPTIONAL_DOUBLE_VARIANT_DATA*>( aVariant.GetData() );
452
453 if( textVal.empty() )
454 {
455 changed = ( aVariant.IsNull() || variantData->OptValue().has_value() );
456
457 if( changed )
458 aVariant = wxVariant( std::optional<double>() );
459 }
460 else
461 {
462 // One could argue that 1.0 would be a better default for a ratio, but we currently
463 // only use this for solder paste margins, where 0.0 makes more sense.
464 double dblValue = 0.0;
465 textVal.ToDouble( &dblValue );
466 std::optional<double> result( dblValue );
467 changed = ( aVariant.IsNull() || result != variantData->OptValue() );
468
469 if( changed )
470 {
471 aVariant = wxVariant( result );
472 textCtrl->SetValue( wxString::Format( wxS( "%g" ), dblValue ) );
473 }
474 }
475 }
476 else
477 {
478 // One could argue that 1.0 would be a better default for a ratio, but we currently
479 // only use this for solder paste margins, where 0.0 makes more sense.
480 double result = 0.0;
481 textVal.ToDouble( &result );
482 changed = ( aVariant.IsNull() || result != aVariant.GetDouble() );
483
484 if( changed )
485 {
486 aVariant = result;
487 textCtrl->SetValue( wxString::Format( wxS( "%g" ), result ) );
488 }
489 }
490
491 // Changing unspecified always causes event (returning true here should be enough to trigger it).
492 if( !changed && aVariant.IsNull() )
493 changed = true;
494
495 return changed;
496}
497
498
499void PG_RATIO_EDITOR::UpdateControl( wxPGProperty* aProperty, wxWindow* aCtrl ) const
500{
501 wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( aCtrl );
502 wxVariant var = aProperty->GetValue();
503
504 wxCHECK_MSG( textCtrl, /*void*/, wxT( "PG_RATIO_EDITOR must be used with a textCtrl!" ) );
505
506 if( var.GetType() == wxT( "std::optional<double>" ) )
507 {
508 auto* variantData = static_cast<STD_OPTIONAL_DOUBLE_VARIANT_DATA*>( var.GetData() );
509 wxString strValue;
510
511 if( variantData->OptValue().has_value() )
512 strValue = wxString::Format( wxS( "%g" ), variantData->OptValue().value() );
513
514 textCtrl->ChangeValue( strValue );
515 }
516 else if( var.GetType() == wxPG_VARIANT_TYPE_DOUBLE )
517 {
518 textCtrl->ChangeValue( wxString::Format( wxS( "%g" ), var.GetDouble() ) );
519 }
520 else if( !aProperty->IsValueUnspecified() )
521 {
522 wxFAIL_MSG( wxT( "PG_RATIO_EDITOR should only be used with scale-free numeric properties!" ) );
523 }
524}
525
526
527PG_FPID_EDITOR::PG_FPID_EDITOR( EDA_DRAW_FRAME* aFrame, const std::function<std::string()>& aNetlistCallback ) :
528 m_frame( aFrame ),
529 m_netlistCallback( aNetlistCallback )
530{
531 m_editorName = BuildEditorName( aFrame );
532}
533
534
536{
537 m_frame = aFrame;
538 m_editorName = BuildEditorName( aFrame );
539}
540
541
542void PG_FPID_EDITOR::UpdateCallback( const std::function<std::string()>& aNetlistCallback )
543{
544 m_netlistCallback = aNetlistCallback;
545}
546
547
549{
550 if( !aFrame )
551 return EDITOR_NAME + "NoFrame";
552
553 return EDITOR_NAME + aFrame->GetName();
554}
555
556
557wxPGWindowList PG_FPID_EDITOR::CreateControls( wxPropertyGrid* aGrid, wxPGProperty* aProperty,
558 const wxPoint& aPos, const wxSize& aSize ) const
559{
560 wxPGMultiButton* buttons = new wxPGMultiButton( aGrid, aSize );
561 buttons->Add( KiBitmap( BITMAPS::small_library ) );
562 buttons->Finalize( aGrid, aPos );
563 wxSize textSize = buttons->GetPrimarySize();
564 wxWindow* textCtrl = aGrid->GenerateEditorTextCtrl( aPos, textSize, aProperty->GetValueAsString(),
565 nullptr, 0, aProperty->GetMaxLength() );
566 wxPGWindowList ret( textCtrl, buttons );
567 return ret;
568}
569
570
571bool PG_FPID_EDITOR::OnEvent( wxPropertyGrid* aGrid, wxPGProperty* aProperty, wxWindow* aCtrl,
572 wxEvent& aEvent ) const
573{
574 if( aEvent.GetEventType() == wxEVT_BUTTON )
575 {
576 if( !m_frame )
577 return true;
578
579 wxString fpid = aProperty->GetValue().GetString();
580
581 if( KIWAY_PLAYER* frame = m_frame->Kiway().Player( FRAME_FOOTPRINT_CHOOSER, true, m_frame ) )
582 {
583 // Create symbol netlist for footprint picker
584 std::string symbolNetlist = m_netlistCallback();
585
586 if( !symbolNetlist.empty() )
587 {
589 frame->KiwayMailIn( event );
590 }
591
592 if( frame->ShowModal( &fpid, m_frame ) )
593 aGrid->ChangePropertyValue( aProperty, fpid );
594
595 frame->Destroy();
596 }
597
598 return true;
599 }
600
601 return wxPGTextCtrlEditor::OnEvent( aGrid, aProperty, aCtrl, aEvent );
602}
603
604
606{
607 m_editorName = BuildEditorName( aFrame );
608}
609
610
612{
613 m_frame = aFrame;
614 m_editorName = BuildEditorName( aFrame );
615}
616
617
619{
620 if( !aFrame )
621 return EDITOR_NAME + "NoFrame";
622
623 return EDITOR_NAME + aFrame->GetName();
624}
625
626
627wxPGWindowList PG_URL_EDITOR::CreateControls( wxPropertyGrid* aGrid, wxPGProperty* aProperty,
628 const wxPoint& aPos, const wxSize& aSize ) const
629{
630 wxPGMultiButton* buttons = new wxPGMultiButton( aGrid, aSize );
631 // Use a folder icon when no datasheet is set; otherwise use a globe icon.
632 wxString urlValue = aProperty->GetValueAsString();
633 bool hasUrl = !( urlValue.IsEmpty() || urlValue == wxS( "~" ) );
634 buttons->Add( KiBitmap( hasUrl ? BITMAPS::www : BITMAPS::small_folder ) );
635 buttons->Finalize( aGrid, aPos );
636 wxSize textSize = buttons->GetPrimarySize();
637 wxWindow* textCtrl = aGrid->GenerateEditorTextCtrl( aPos, textSize,
638 aProperty->GetValueAsString(), nullptr, 0,
639 aProperty->GetMaxLength() );
640 wxPGWindowList ret( textCtrl, buttons );
641 return ret;
642}
643
644
645bool PG_URL_EDITOR::OnEvent( wxPropertyGrid* aGrid, wxPGProperty* aProperty, wxWindow* aCtrl,
646 wxEvent& aEvent ) const
647{
648 if( aEvent.GetEventType() == wxEVT_BUTTON )
649 {
650 if( !m_frame )
651 return true;
652
653 wxString filename = aProperty->GetValue().GetString();
654
655 if( filename.IsEmpty() || filename == wxS( "~" ) )
656 {
657 wxFileDialog openFileDialog( m_frame, _( "Open file" ), wxS( "" ), wxS( "" ),
658 _( "All Files" ) + wxS( " (*.*)|*.*" ),
659 wxFD_OPEN | wxFD_FILE_MUST_EXIST );
660
662
663 if( openFileDialog.ShowModal() == wxID_OK )
664 {
665 filename = openFileDialog.GetPath();
666 aGrid->ChangePropertyValue( aProperty, wxString::Format( wxS( "file://%s" ),
667 filename ) );
668 }
669 }
670 else
671 {
672 GetAssociatedDocument( m_frame, filename, &m_frame->Prj() );
673 }
674
675 // Update the button icon to reflect presence/absence of URL
676 if( wxObject* src = aEvent.GetEventObject() )
677 {
678 wxString newUrl = aProperty->GetValueAsString();
679 bool hasUrl = !( newUrl.IsEmpty() || newUrl == wxS( "~" ) );
680 auto bmp = KiBitmap( hasUrl ? BITMAPS::www : BITMAPS::small_folder );
681
682 if( wxWindow* win = wxDynamicCast( src, wxWindow ) )
683 {
684 if( wxBitmapButton* bb = wxDynamicCast( win, wxBitmapButton ) )
685 {
686 bb->SetBitmap( bmp );
687 }
688 else if( wxButton* b = wxDynamicCast( win, wxButton ) )
689 {
690 b->SetBitmap( bmp );
691 }
692 else if( wxWindow* parent = win->GetParent() )
693 {
694 if( wxPGMultiButton* buttons = wxDynamicCast( parent, wxPGMultiButton ) )
695 {
696 wxWindow* btn0 = buttons->GetButton( 0 );
697 if( wxBitmapButton* bb0 = wxDynamicCast( btn0, wxBitmapButton ) )
698 bb0->SetBitmap( bmp );
699 else if( wxButton* b0 = wxDynamicCast( btn0, wxButton ) )
700 b0->SetBitmap( bmp );
701 }
702 }
703 }
704 }
705 return true;
706 }
707
708 return wxPGTextCtrlEditor::OnEvent( aGrid, aProperty, aCtrl, aEvent );
709}
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition bitmap.cpp:100
const KIGFX::COLOR4D & Color()
A simple color swatch of the kind used to set layer colors.
const EDA_ANGLE & Angle()
void SetAngle(const EDA_ANGLE &aAngle)
double AsDegrees() const
Definition eda_angle.h:115
The base class for create windows for drawing purpose.
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition color4d.h:400
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition kiway_mail.h:34
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Customized wxPGProperty class to handle angles.
double GetScale() const
Customized abstract wxPGProperty class to handle coordinate/size units.
wxPGWindowList CreateControls(wxPropertyGrid *aGrid, wxPGProperty *aProperty, const wxPoint &aPos, const wxSize &aSize) const override
static const wxString EDITOR_NAME
Definition pg_editors.h:75
static const wxString EDITOR_NAME
Definition pg_editors.h:91
wxPGWindowList CreateControls(wxPropertyGrid *aGrid, wxPGProperty *aProperty, const wxPoint &aPos, const wxSize &aSize) const override
bool OnEvent(wxPropertyGrid *aGrid, wxPGProperty *aProperty, wxWindow *aWindow, wxEvent &aEvent) const override
KIGFX::COLOR4D colorFromVariant(const wxVariant &aVariant) const
void UpdateControl(wxPGProperty *aProperty, wxWindow *aCtrl) const override
KIGFX::COLOR4D colorFromProperty(wxPGProperty *aProperty) const
wxString m_editorName
Definition pg_editors.h:153
void UpdateFrame(EDA_DRAW_FRAME *aFrame)
std::function< std::string()> m_netlistCallback
Definition pg_editors.h:154
PG_FPID_EDITOR(EDA_DRAW_FRAME *aFrame, const std::function< std::string()> &aNetlistCallback)
void UpdateCallback(const std::function< std::string()> &aNetlistCallback)
wxPGWindowList CreateControls(wxPropertyGrid *aGrid, wxPGProperty *aProperty, const wxPoint &aPos, const wxSize &aSize) const override
static const wxString EDITOR_NAME
Definition pg_editors.h:131
EDA_DRAW_FRAME * m_frame
Definition pg_editors.h:152
static wxString BuildEditorName(EDA_DRAW_FRAME *aFrame)
bool OnEvent(wxPropertyGrid *aGrid, wxPGProperty *aProperty, wxWindow *aCtrl, wxEvent &aEvent) const override
bool GetValueFromControl(wxVariant &aVariant, wxPGProperty *aProperty, wxWindow *aCtrl) const override
static const wxString EDITOR_NAME
Definition pg_editors.h:117
void UpdateControl(wxPGProperty *aProperty, wxWindow *aCtrl) const override
std::unique_ptr< PROPERTY_EDITOR_UNIT_BINDER > m_unitBinder
Definition pg_editors.h:66
wxPGWindowList CreateControls(wxPropertyGrid *aPropGrid, wxPGProperty *aProperty, const wxPoint &aPos, const wxSize &aSize) const override
static const wxString EDITOR_NAME
Definition pg_editors.h:34
void UpdateControl(wxPGProperty *aProperty, wxWindow *aCtrl) const override
void UpdateFrame(EDA_DRAW_FRAME *aFrame)
When restarting an editor, the instance of PG_UNIT_EDITOR may be the same but the referenced frame is...
EDA_DRAW_FRAME * m_frame
Definition pg_editors.h:64
PG_UNIT_EDITOR(EDA_DRAW_FRAME *aFrame)
bool GetValueFromControl(wxVariant &aVariant, wxPGProperty *aProperty, wxWindow *aCtrl) const override
wxString m_editorName
Definition pg_editors.h:68
bool OnEvent(wxPropertyGrid *aPropGrid, wxPGProperty *aProperty, wxWindow *aCtrl, wxEvent &aEvent) const override
static wxString BuildEditorName(EDA_DRAW_FRAME *aFrame)
virtual ~PG_UNIT_EDITOR()
static const wxString EDITOR_NAME
Definition pg_editors.h:161
PG_URL_EDITOR(EDA_DRAW_FRAME *aFrame)
wxString m_editorName
Definition pg_editors.h:181
static wxString BuildEditorName(EDA_DRAW_FRAME *aFrame)
void UpdateFrame(EDA_DRAW_FRAME *aFrame)
EDA_DRAW_FRAME * m_frame
Definition pg_editors.h:180
wxPGWindowList CreateControls(wxPropertyGrid *aGrid, wxPGProperty *aProperty, const wxPoint &aPos, const wxSize &aSize) const override
bool OnEvent(wxPropertyGrid *aGrid, wxPGProperty *aProperty, wxWindow *aCtrl, wxEvent &aEvent) const override
@ SWATCH_LARGE
#define _(s)
bool GetAssociatedDocument(wxWindow *aParent, const wxString &aDocName, PROJECT *aProject, SEARCH_STACK *aPaths, std::vector< EMBEDDED_FILES * > aFilesStack)
Open a document (file) with the suitable browser.
Definition eda_doc.cpp:59
This file is part of the common library.
@ FRAME_FOOTPRINT_CHOOSER
Definition frame_type.h:40
@ MAIL_SYMBOL_NETLIST
Definition mail_type.h:41
void AllowNetworkFileSystems(wxDialog *aDialog)
Configure a file dialog to show network and virtual file systems.
Definition wxgtk/ui.cpp:741
static std::string strValue(double aValue)
const int scale
wxString result
Test unit parsing edge cases and error handling.
Functions to provide common constants and other functions to assist in making a consistent UI.
#define INDETERMINATE_STATE
Used for holding indeterminate values, such as with multiple selections holding different values or c...
Definition ui_common.h:48