KiCad PCB EDA Suite
Loading...
Searching...
No Matches
eda_draw_frame.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) 2004-2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2008 Wayne Stambaugh <[email protected]>
6 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
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, see <https://www.gnu.org/licenses/>.
20 */
21
23#include <base_screen.h>
24#include <bitmaps.h>
25#include <bitmap_store.h>
26#include <confirm.h>
27#include <core/arraydim.h>
28#include <core/kicad_algo.h>
29#include <dialog_shim.h>
31#include <eda_draw_frame.h>
32#include <eda_search_data.h>
33#include <file_history.h>
35#include <id.h>
36#include <kiface_base.h>
37#include <kiplatform/ui.h>
38#include <lockfile.h>
39#include <macros.h>
40#include <math/vector2wx.h>
41#include <page_info.h>
42#include <paths.h>
43#include <pgm_base.h>
44#include <reporter.h>
45#include <render_settings.h>
50#include <title_block.h>
51#include <tool/actions.h>
52#include <tool/action_toolbar.h>
53#include <tool/common_tools.h>
54#include <tool/grid_helper.h>
55#include <tool/grid_menu.h>
58#include <tool/tool_manager.h>
59#include <tool/tool_menu.h>
60#include <tool/zoom_menu.h>
61#include <trace_helpers.h>
62#include <view/view.h>
64#include <view/view_controls.h>
65#include <widgets/kistatusbar.h>
66#include <widgets/msgpanel.h>
71#include <project.h>
72#include <wx/event.h>
73#include <widgets/ui_common.h>
74#include <widgets/search_pane.h>
75#include <wx/dirdlg.h>
76#include <wx/filedlg.h>
77#include <wx/debug.h>
78#include <wx/socket.h>
79
80#include <wx/fdrepdlg.h>
82
83#define FR_HISTORY_LIST_CNT 10
84
85
86BEGIN_EVENT_TABLE( EDA_DRAW_FRAME, KIWAY_PLAYER )
89
90 EVT_ACTIVATE( EDA_DRAW_FRAME::onActivate )
91END_EVENT_TABLE()
92
93
94std::set<EDA_DRAW_PANEL_GAL::GAL_TYPE> EDA_DRAW_FRAME::m_failedCanvases;
95
96
97EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
98 const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
99 long aStyle, const wxString& aFrameName, const EDA_IU_SCALE& aIuScale ) :
100 KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName, aIuScale ),
101 m_socketServer( nullptr ),
103{
104 m_gridSelectBox = nullptr;
105 m_zoomSelectBox = nullptr;
106 m_zoomCustomEntry = wxNOT_FOUND;
107 m_overrideLocksCb = nullptr;
108 m_searchPane = nullptr;
110
112 m_canvas = nullptr;
113 m_toolDispatcher = nullptr;
114 m_messagePanel = nullptr;
115 m_currentScreen = nullptr;
116 m_showBorderAndTitleBlock = false; // true to display reference sheet.
117 m_gridColor = COLOR4D( DARKGRAY ); // Default grid color
118 m_drawBgColor = COLOR4D( BLACK ); // the background color of the draw canvas:
119 // BLACK for Pcbnew, BLACK or WHITE for Eeschema
120 m_colorSettings = nullptr;
121 m_polarCoords = false;
122 m_findReplaceData = std::make_unique<EDA_SEARCH_DATA>();
123 m_hotkeyPopup = nullptr;
124 m_propertiesPanel = nullptr;
125 m_netInspectorPanel = nullptr;
126 m_gitCommitPane = nullptr;
127
129
130 m_auimgr.SetFlags( wxAUI_MGR_DEFAULT );
131
132 if( ( aStyle & wxFRAME_NO_TASKBAR ) == 0 )
133 {
134 CreateStatusBar( 8 )->SetDoubleBuffered( true );
135
136 GetStatusBar()->SetFont( KIUI::GetStatusFont( this ) );
137
138 // set the size of the status bar subwindows:
140 }
141
142 m_messagePanel = new EDA_MSG_PANEL( this, -1, wxPoint( 0, m_frameSize.y ), wxDefaultSize );
143 m_messagePanel->SetBackgroundColour( COLOR4D( LIGHTGRAY ).ToColour() );
144 m_msgFrameHeight = m_messagePanel->GetBestSize().y;
145
146 // Create child subwindows.
147 GetClientSize( &m_frameSize.x, &m_frameSize.y );
148 m_framePos.x = m_framePos.y = 0;
150
152
153 Bind( wxEVT_DPI_CHANGED,
154 [&]( wxDPIChangedEvent& aEvent )
155 {
156 if( ( GetWindowStyle() & wxFRAME_NO_TASKBAR ) == 0 )
158
159 wxMoveEvent dummy;
160 OnMove( dummy );
161
162 // we need to kludge the msg panel to the correct size again
163 // especially important even for first launches as the constructor of the window
164 // here usually doesn't have the correct dpi awareness yet
166 m_msgFrameHeight = m_messagePanel->GetBestSize().y;
168
169 m_messagePanel->SetPosition( wxPoint( 0, m_frameSize.y ) );
171
172 aEvent.Skip();
173 } );
174}
175
176
178{
179 if( m_failedCanvases.empty() )
181
182 delete m_actions;
183 delete m_toolManager;
184 delete m_toolDispatcher;
185 delete m_canvas;
186
187 delete m_currentScreen;
188 m_currentScreen = nullptr;
189
190 m_auimgr.UnInit();
191
192 ReleaseFile();
193}
194
195
200
201
203{
205
206 // Grid selection
207 auto gridSelectorFactory =
208 [this]( ACTION_TOOLBAR* aToolbar )
209 {
210 if( !m_gridSelectBox )
211 m_gridSelectBox = new wxChoice( aToolbar, ID_ON_GRID_SELECT );
212
214
215 aToolbar->Add( m_gridSelectBox );
216 };
217
219
220 // Zoom selection
221 auto zoomSelectorFactory =
222 [this]( ACTION_TOOLBAR* aToolbar )
223 {
224 if( !m_zoomSelectBox )
225 m_zoomSelectBox = new wxChoice( aToolbar, ID_ON_ZOOM_SELECT );
226
228 aToolbar->Add( m_zoomSelectBox );
229 };
230
232
233 auto overrideLocksFactory =
234 [this]( ACTION_TOOLBAR* aToolbar )
235 {
236 if( !m_overrideLocksCb )
237 {
238 m_overrideLocksCb = new wxCheckBox( aToolbar, ID_ON_OVERRIDE_LOCKS, _( "Override locks" ) );
239
240 // Clicking the checkbox takes focus off the canvas, so return it
241 m_overrideLocksCb->Bind( wxEVT_CHECKBOX,
242 [this]( wxCommandEvent& aEvent )
243 {
244 if( m_toolManager )
246
247 if( m_canvas )
248 m_canvas->SetFocus();
249
250 aEvent.Skip();
251 } );
252 }
253
254 aToolbar->Add( m_overrideLocksCb );
255 };
256
258}
259
260
262{
263 switch( aId )
264 {
265 case ID_ON_GRID_SELECT: m_gridSelectBox = nullptr; break;
266 case ID_ON_ZOOM_SELECT: m_zoomSelectBox = nullptr; break;
267 case ID_ON_OVERRIDE_LOCKS: m_overrideLocksCb = nullptr; break;
268 }
269}
270
271
273{
274 if( m_file_checker )
275 m_file_checker->UnlockFile();
276}
277
278
279bool EDA_DRAW_FRAME::LockFile( const wxString& aFileName )
280{
281 // We need to explicitly reset here to get the deletion before we create a new unique_ptr that
282 // may be for the same file.
283 m_file_checker.reset();
284
285 m_file_checker = std::make_unique<LOCKFILE>( aFileName );
286
287 // If the file is valid, return true. This could mean that the file is locked or it could mean
288 // that the file is read-only.
289 return m_file_checker->Valid();
290}
291
292
294{
295 // Notify all tools the units have changed
296 if( m_toolManager )
298
302
303 switch( GetUserUnits() )
304 {
305 default:
309 }
310}
311
312
314{
315 if( m_toolManager->GetTool<COMMON_TOOLS>() )
316 {
318 m_toolManager->GetTool<COMMON_TOOLS>()->ToggleUnits( dummy );
319 }
320 else
321 {
323 }
324}
325
326
328{
330
331 COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
333
334 if( m_supportsAutoSave && m_autoSaveTimer->IsRunning() )
335 {
336 if( GetAutoSaveInterval() > 0 )
337 {
338 m_autoSaveTimer->Start( GetAutoSaveInterval() * 1000, wxTIMER_ONE_SHOT );
339 }
340 else
341 {
342 m_autoSaveTimer->Stop();
343 m_autoSavePending = false;
344 }
345 }
346
347 viewControls->LoadSettings();
349
350 m_galDisplayOptions.ReadCommonConfig( *settings, this );
351
354
355 if( m_lastToolbarIconSize == 0
357 {
360 }
361
362 // A rendering engine change in Preferences applies in place
364
365 // Version control can have just been turned on or off.
367
368 if( m_gitCommitPane )
369 m_gitCommitPane->ReloadAdvancedWindow();
370
371 // Notify all tools the preferences have changed
372 if( m_toolManager )
374}
375
376
378{
379 if( m_messagePanel )
380 m_messagePanel->EraseMsgBox();
381}
382
383
385{
388
389 if( m_gridSelectBox == nullptr )
390 return;
391
392 // Update grid values with the current units setting.
393 m_gridSelectBox->Clear();
394 wxArrayString gridsList;
395
396 wxCHECK( config(), /* void */ );
397
398 GRID_MENU::BuildChoiceList( &gridsList, GetWindowSettings( config() ), this );
399
400 for( const wxString& grid : gridsList )
401 m_gridSelectBox->Append( grid );
402
403 m_gridSelectBox->Append( wxT( "---" ) );
404 m_gridSelectBox->Append( _( "Edit Grids..." ) );
405
406 m_gridSelectBox->SetSelection( GetWindowSettings( config() )->grid.last_size_idx );
407}
408
409
410void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
411{
412 // No need to update the grid select box if it doesn't exist or the grid setting change
413 // was made using the select box.
414 if( m_gridSelectBox == nullptr )
415 return;
416
417 wxCHECK( config(), /* void */ );
418
420 idx = std::clamp( idx, 0, (int) m_gridSelectBox->GetCount() - 1 );
421
422 if( idx != m_gridSelectBox->GetSelection() )
423 m_gridSelectBox->SetSelection( idx );
424}
425
426
427
428void EDA_DRAW_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent )
429{
431}
432
433
435{
436 if( m_zoomSelectBox == nullptr )
437 return;
438
439 double zoom = GetCanvas()->GetGAL()->GetZoomFactor();
440
441 wxCHECK( config(), /* void */ );
442
443 const std::vector<double>& zoomList = GetWindowSettings( config() )->zoom_factors;
444 int preset = wxNOT_FOUND;
445
446 for( size_t jj = 0; jj < zoomList.size(); ++jj )
447 {
448 if( zoomList[jj] == zoom )
449 {
450 preset = (int) jj + 1; // index 0 is Zoom Auto
451 break;
452 }
453 }
454
455 if( preset != wxNOT_FOUND )
456 {
457 // Zoom is on a preset, so drop the custom entry and select the preset.
458 if( m_zoomCustomEntry != wxNOT_FOUND )
459 {
461 m_zoomCustomEntry = wxNOT_FOUND;
462 }
463
464 if( m_zoomSelectBox->GetSelection() != preset )
465 m_zoomSelectBox->SetSelection( preset );
466 }
467 else
468 {
469 // Off-preset zoom, show the exact value in its own entry just below Zoom Auto.
470 wxString text = wxString::Format( _( "Zoom %.2f" ), zoom );
471
472 if( m_zoomCustomEntry == wxNOT_FOUND )
473 m_zoomCustomEntry = m_zoomSelectBox->Insert( text, 1 );
474 else if( m_zoomSelectBox->GetString( m_zoomCustomEntry ) != text )
476
477 if( m_zoomSelectBox->GetSelection() != m_zoomCustomEntry )
478 m_zoomSelectBox->SetSelection( m_zoomCustomEntry );
479 }
480}
481
482
483void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
484{
485 wxCHECK_RET( m_gridSelectBox, wxS( "m_gridSelectBox uninitialized" ) );
486
487 int idx = m_gridSelectBox->GetCurrentSelection();
488
489 if( idx == int( m_gridSelectBox->GetCount() ) - 2 )
490 {
491 // wxWidgets will check the separator, which we don't want.
492 // Re-check the current grid.
493 wxUpdateUIEvent dummy;
495 }
496 else if( idx == int( m_gridSelectBox->GetCount() ) - 1 )
497 {
498 // wxWidgets will check the Grid Settings... entry, which we don't want.
499 // Re-check the current grid.
500 wxUpdateUIEvent dummy;
502
503 // Give a time-slice to close the menu before opening the dialog.
504 // (Only matters on some versions of GTK.)
505 wxSafeYield();
506
508 }
509 else
510 {
511 m_toolManager->RunAction( ACTIONS::gridPreset, idx );
512 }
513
515 m_canvas->Refresh();
516
517 // Needed on Windows because clicking on m_gridSelectBox remove the focus from m_canvas
518 // (Windows specific
519 m_canvas->SetFocus();
520}
521
522
524{
526 return m_overrideLocksCb->GetValue();
527
528 return false;
529}
530
531
533{
534 APP_SETTINGS_BASE* cfg = config();
535
536 if( !cfg )
537 return true;
538
539 return GetWindowSettings( cfg )->grid.show;
540}
541
542
544{
545 wxCHECK( config(), /* void */ );
546
547 GetWindowSettings( config() )->grid.show = aVisible;
548
549 // Update the display with the new grid
550 if( GetCanvas() )
551 {
552 // Check to ensure these exist, since this function could be called before
553 // the GAL and View have been created
554 if( GetCanvas()->GetGAL() )
555 GetCanvas()->GetGAL()->SetGridVisibility( aVisible );
556
557 if( GetCanvas()->GetView() )
559
560 GetCanvas()->Refresh();
561 }
562}
563
564
566{
567 APP_SETTINGS_BASE* cfg = config();
568
569 if( !cfg )
570 return false;
571
573}
574
575
577{
578 wxCHECK( config(), /* void */ );
579
581}
582
583
584std::unique_ptr<GRID_HELPER> EDA_DRAW_FRAME::MakeGridHelper()
585{
586 return nullptr;
587}
588
589
591{
592 if( m_zoomSelectBox == nullptr )
593 return;
594
595 double zoom = m_canvas->GetGAL()->GetZoomFactor();
596
597 m_zoomSelectBox->Clear();
598 m_zoomSelectBox->Append( _( "Zoom Auto" ) );
599 m_zoomSelectBox->SetSelection( 0 );
600 m_zoomCustomEntry = wxNOT_FOUND;
601
602 wxCHECK( config(), /* void */ );
603
604 for( unsigned ii = 0; ii < GetWindowSettings( config() )->zoom_factors.size(); ++ii )
605 {
606 double current = GetWindowSettings( config() )->zoom_factors[ii];
607
608 m_zoomSelectBox->Append( wxString::Format( _( "Zoom %.2f" ), current ) );
609
610 if( zoom == current )
611 m_zoomSelectBox->SetSelection( (int) ii + 1 );
612 }
613}
614
615
616void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event )
617{
618 wxCHECK_RET( m_zoomSelectBox, wxS( "m_zoomSelectBox uninitialized" ) );
619
620 int id = m_zoomSelectBox->GetCurrentSelection();
621
622 if( id < 0 || id >= (int) m_zoomSelectBox->GetCount() )
623 return;
624
625 // Picking the custom entry means keep the current zoom, so nothing to do.
626 if( id == m_zoomCustomEntry )
627 return;
628
629 // The custom entry pushes the presets down by one, so shift back to the real preset id.
630 int preset = id;
631
632 if( m_zoomCustomEntry != wxNOT_FOUND && id > m_zoomCustomEntry )
633 preset = id - 1;
634
635 m_toolManager->RunAction( ACTIONS::zoomPreset, preset );
637 m_canvas->Refresh();
638
639 // Needed on Windows (only) because clicking on m_zoomSelectBox removes the focus from m_canvas
640 m_canvas->SetFocus();
641}
642
643
644void EDA_DRAW_FRAME::OnMove( wxMoveEvent& aEvent )
645{
646 // If the window is moved to a different display, the scaling factor may change
647 double oldFactor = m_galDisplayOptions.m_scaleFactor;
648 m_galDisplayOptions.UpdateScaleFactor();
649
650 if( oldFactor != m_galDisplayOptions.m_scaleFactor && m_canvas )
651 {
652 // wx has not laid the frame out for the new DPI yet, so defer until the canvas has
653 // reached its final size
654 EDA_DRAW_PANEL_GAL* canvas = GetCanvas();
655
656 canvas->CallAfter( [canvas]() { canvas->ResizeGal( true ); } );
657 }
658
659 aEvent.Skip();
660}
661
662
664{
665 COMMON_TOOLS* commonTools = m_toolManager->GetTool<COMMON_TOOLS>();
666 CONDITIONAL_MENU& aMenu = aToolMenu.GetMenu();
667
668 aMenu.AddSeparator( 1000 );
669
670 std::shared_ptr<ZOOM_MENU> zoomMenu = std::make_shared<ZOOM_MENU>( this );
671 zoomMenu->SetTool( commonTools );
672 aToolMenu.RegisterSubMenu( zoomMenu );
673
674 std::shared_ptr<GRID_MENU> gridMenu = std::make_shared<GRID_MENU>( this );
675 gridMenu->SetTool( commonTools );
676 aToolMenu.RegisterSubMenu( gridMenu );
677
678 aMenu.AddMenu( zoomMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
679 aMenu.AddMenu( gridMenu.get(), SELECTION_CONDITIONS::ShowAlways, 1000 );
680}
681
682
683void EDA_DRAW_FRAME::DisplayToolMsg( const wxString& msg )
684{
685 if( m_isClosing )
686 return;
687
688 SetStatusText( msg, 6 );
689}
690
691
692void EDA_DRAW_FRAME::DisplayConstraintsMsg( const wxString& msg )
693{
694 if( m_isClosing )
695 return;
696
697 SetStatusText( msg, 7 );
698}
699
700
702{
703 if( m_isClosing )
704 return;
705
706 wxString msg;
707
708 GRID_SETTINGS& gridSettings = GetWindowSettings( config() )->grid;
709 int currentIdx = gridSettings.last_size_idx;
710
711 msg.Printf( _( "grid %s" ), gridSettings.grids[currentIdx].UserUnitsMessageText( this, false ) );
712
713 SetStatusText( msg, 4 );
714}
715
716
718{
719 if( m_isClosing )
720 return;
721
722 wxString msg;
723
724 switch( GetUserUnits() )
725 {
726 case EDA_UNITS::INCH: msg = _( "inches" ); break;
727 case EDA_UNITS::MILS: msg = _( "mils" ); break;
728 case EDA_UNITS::MM: msg = _( "mm" ); break;
729 default: msg = _( "Units" ); break;
730 }
731
732 SetStatusText( msg, 5 );
733}
734
735
736void EDA_DRAW_FRAME::OnSize( wxSizeEvent& SizeEv )
737{
738 EDA_BASE_FRAME::OnSize( SizeEv );
739
740 m_frameSize = GetClientSize( );
741
742 SizeEv.Skip();
743}
744
745
747{
748 constexpr int numLocalFields = 8;
749
750 wxStatusBar* stsbar = GetStatusBar();
751 int spacer = KIUI::GetTextSize( wxT( "M" ), stsbar ).x;
752
753 // Note this is a KISTATUSBAR and there are fields to the right of the ones we know about
754 int totalFields = stsbar->GetFieldsCount();
755
756 std::vector<int> dims = {
757 // remainder of status bar on far left is set to a default or whatever is left over.
758 -2,
759
760 // When using GetTextSize() remember the width of character '1' is not the same
761 // as the width of '0' unless the font is fixed width, and it usually won't be.
762
763 // zoom:
764 KIUI::GetTextSize( wxT( "Z 762000" ), stsbar ).x + spacer,
765
766 // cursor coords
767 KIUI::GetTextSize( wxT( "X 00000.0000 Y 00000.0000" ), stsbar ).x + spacer,
768
769 // delta distances
770 KIUI::GetTextSize( wxT( "dx 00000.0000 dy 00000.0000 dist 00000.0000" ), stsbar ).x + spacer,
771
772 // grid size
773 KIUI::GetTextSize( wxT( "grid 0000.0000 x 0000.0000" ), stsbar ).x + spacer,
774
775 // units display, Inches is bigger than mm
776 KIUI::GetTextSize( _( "Inches" ), stsbar ).x + spacer,
777
778 // Size for the "Current Tool" panel
779 -1,
780
781 // constraint mode
782 KIUI::GetTextSize( _( "Constrain to H, V, 45" ), stsbar).x + spacer
783 };
784
785 for( int idx = numLocalFields; idx < totalFields; ++idx )
786 dims.emplace_back( stsbar->GetStatusWidth( idx ) );
787
788 SetStatusWidths( dims.size(), dims.data() );
789}
790
791
792wxStatusBar* EDA_DRAW_FRAME::OnCreateStatusBar( int number, long style, wxWindowID id, const wxString& name )
793{
794 return new KISTATUSBAR( number, this, id, KISTATUSBAR::STYLE_FLAGS::WARNING_ICON );
795}
796
797
799{
800 if( m_isClosing )
801 return;
802
803 SetStatusText( GetZoomLevelIndicator(), 1 );
804
805 // Update-UI events come at most every m_UpdateUIEventInterval, so the last step of a zoom
806 // could leave the box one step behind the status bar until the mouse moves
808
809 // Absolute and relative cursor positions are handled by overloading this function and
810 // handling the internal to user units conversion at the appropriate level.
811
812 // refresh units display
814}
815
816
818{
819 // returns a human readable value which can be displayed as zoom
820 // level indicator in dialogs.
821 double zoom = m_canvas->GetGAL()->GetZoomFactor();
822 return wxString::Format( wxT( "Z %.2f" ), zoom );
823}
824
825
827{
829
831 WINDOW_SETTINGS* window = GetWindowSettings( aCfg );
832
833 // Read units used in dialogs and toolbars
834 SetUserUnits( static_cast<EDA_UNITS>( aCfg->m_System.units ) );
835
837
838 m_galDisplayOptions.ReadConfig( *cmnCfg, *window, this );
839
840 m_findReplaceData->findString = aCfg->m_FindReplace.find_string;
841 m_findReplaceData->replaceString = aCfg->m_FindReplace.replace_string;
842 m_findReplaceData->matchMode = static_cast<EDA_SEARCH_MATCH_MODE>( aCfg->m_FindReplace.match_mode );
843 m_findReplaceData->matchCase = aCfg->m_FindReplace.match_case;
844 m_findReplaceData->searchAndReplace = aCfg->m_FindReplace.search_and_replace;
845
846 for( const wxString& s : aCfg->m_FindReplace.find_history )
848
849 for( const wxString& s : aCfg->m_FindReplace.replace_history )
851
853}
854
855
857{
859
860 WINDOW_SETTINGS* window = GetWindowSettings( aCfg );
861
862 aCfg->m_System.units = static_cast<int>( GetUserUnits() );
864
865 m_galDisplayOptions.WriteConfig( *window );
866
867 aCfg->m_FindReplace.search_and_replace = m_findReplaceData->searchAndReplace;
868
869 aCfg->m_FindReplace.find_string = m_findReplaceData->findString;
870 aCfg->m_FindReplace.replace_string = m_findReplaceData->replaceString;
871
872 aCfg->m_FindReplace.find_history.clear();
873 aCfg->m_FindReplace.replace_history.clear();
874
875 for( size_t i = 0; i < m_findStringHistoryList.GetCount() && i < FR_HISTORY_LIST_CNT; i++ )
876 aCfg->m_FindReplace.find_history.push_back( m_findStringHistoryList[ i ].ToStdString() );
877
878 for( size_t i = 0; i < m_replaceStringHistoryList.GetCount() && i < FR_HISTORY_LIST_CNT; i++ )
879 aCfg->m_FindReplace.replace_history.push_back( m_replaceStringHistoryList[ i ].ToStdString() );
880
881 // Save the units used in this frame
882 if( m_toolManager )
883 {
884 if( COMMON_TOOLS* cmnTool = m_toolManager->GetTool<COMMON_TOOLS>() )
885 {
886 aCfg->m_System.last_imperial_units = static_cast<int>( cmnTool->GetLastImperialUnits() );
887 aCfg->m_System.last_metric_units = static_cast<int>( cmnTool->GetLastMetricUnits() );
888 }
889 }
890}
891
892
893void EDA_DRAW_FRAME::AppendMsgPanel( const wxString& aTextUpper, const wxString& aTextLower, int aPadding )
894{
896 m_messagePanel->AppendMessage( aTextUpper, aTextLower, aPadding );
897}
898
899
901{
903 m_messagePanel->EraseMsgBox();
904}
905
906
907void EDA_DRAW_FRAME::SetMsgPanel( const std::vector<MSG_PANEL_ITEM>& aList )
908{
910 {
911 m_messagePanel->EraseMsgBox();
912
913 for( const MSG_PANEL_ITEM& item : aList )
914 m_messagePanel->AppendMessage( item );
915 }
916}
917
918
919void EDA_DRAW_FRAME::SetMsgPanel( const wxString& aTextUpper, const wxString& aTextLower, int aPadding )
920{
922 {
923 m_messagePanel->EraseMsgBox();
924 m_messagePanel->AppendMessage( aTextUpper, aTextLower, aPadding );
925 }
926}
927
928
930{
931 wxCHECK_RET( aItem, wxT( "Invalid EDA_ITEM pointer. Bad programmer." ) );
932
933 std::vector<MSG_PANEL_ITEM> items;
934 aItem->GetMsgPanelInfo( this, items );
935 SetMsgPanel( items );
936}
937
938
942
943
945{
946 GetCanvas()->SetEvtHandlerEnabled( true );
948}
949
950
958
959
961{
963
964 if( COMMON_SETTINGS* cfg = Pgm().GetCommonSettings() )
965 canvasType = EDA_DRAW_PANEL_GAL::ResolveStoredCanvasType( cfg->m_Graphics.canvas_type );
966
967 wxString envCanvasType;
968
969 if( wxGetEnv( "KICAD_SOFTWARE_RENDERING", &envCanvasType ) )
970 {
971 if( envCanvasType.CmpNoCase( "1" ) == 0
972 || envCanvasType.CmpNoCase( "true" ) == 0
973 || envCanvasType.CmpNoCase( "yes" ) == 0 )
974 {
975 // Force software rendering if the environment variable is set
977 }
978 }
979
980#ifdef __WXMAC__
981 // Cairo doesn't handle Retina displays, so it is not a valid screen backend on Mac
982 if( canvasType == EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO )
984#endif
985
986 return canvasType;
987}
988
989
991{
992 // Not all classes derived from EDA_DRAW_FRAME can save the canvas type, because some
993 // have a fixed type, or do not have a option to set the canvas type (they inherit from
994 // a parent frame)
995 static std::vector<FRAME_T> s_allowedFrames = { FRAME_SCH,
1001
1002 if( !alg::contains( s_allowedFrames, m_ident ) )
1003 return false;
1004
1005 if( wxGetEnv( "KICAD_SOFTWARE_RENDERING", nullptr ) )
1006 {
1007 // If the environment variable is set, don't save the canvas type.
1008 return false;
1009 }
1010
1011 if( aCanvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE || aCanvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
1012 {
1013 wxASSERT( false );
1014 return false;
1015 }
1016
1017 if( COMMON_SETTINGS* cfg = Pgm().GetCommonSettings() )
1018 {
1019 cfg->m_Graphics.canvas_type = static_cast<int>( aCanvasType );
1020 return true;
1021 }
1022
1023 return false;
1024}
1025
1026
1028{
1029 const VECTOR2I& gridOrigin = GetGridOrigin();
1030 VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize();
1031
1032 double xOffset = fmod( gridOrigin.x, gridSize.x );
1033 int x = KiROUND( (aPosition.x - xOffset) / gridSize.x );
1034 double yOffset = fmod( gridOrigin.y, gridSize.y );
1035 int y = KiROUND( (aPosition.y - yOffset) / gridSize.y );
1036
1037 return KiROUND( x * gridSize.x + xOffset, y * gridSize.y + yOffset );
1038}
1039
1040
1042{
1043 const VECTOR2I& gridOrigin = GetGridOrigin();
1044 VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize() / 2.0;
1045
1046 double xOffset = fmod( gridOrigin.x, gridSize.x );
1047 int x = KiROUND( (aPosition.x - xOffset) / gridSize.x );
1048 double yOffset = fmod( gridOrigin.y, gridSize.y );
1049 int y = KiROUND( (aPosition.y - yOffset) / gridSize.y );
1050
1051 return KiROUND( x * gridSize.x + xOffset, y * gridSize.y + yOffset );
1052}
1053
1054
1055const BOX2I EDA_DRAW_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
1056{
1057 return BOX2I();
1058}
1059
1060
1062{
1063 // To be implemented by subclasses.
1064}
1065
1066
1067void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer )
1068{
1070}
1071
1072
1073std::vector<wxWindow*> EDA_DRAW_FRAME::findDialogs()
1074{
1075 std::vector<wxWindow*> dialogs;
1076
1077 for( wxWindow* window : GetChildren() )
1078 {
1079 if( dynamic_cast<DIALOG_SHIM*>( window ) )
1080 dialogs.push_back( window );
1081 }
1082
1083 return dialogs;
1084}
1085
1086
1087void EDA_DRAW_FRAME::FocusOnLocation( const VECTOR2I& aPos, bool aAllowScroll )
1088{
1089 bool centerView = false;
1090 std::vector<BOX2D> dialogScreenRects;
1091
1092 if( aAllowScroll )
1093 {
1094 BOX2D r = GetCanvas()->GetView()->GetViewport();
1095
1096 // Center if we're off the current view, or within 10% of its edge
1097 r.Inflate( - r.GetWidth() / 10.0 );
1098
1099 if( !r.Contains( aPos ) )
1100 centerView = true;
1101
1102 for( wxWindow* dialog : findDialogs() )
1103 {
1104 dialogScreenRects.emplace_back( ToVECTOR2D( GetCanvas()->ScreenToClient( dialog->GetScreenPosition() ) ),
1105 ToVECTOR2D( dialog->GetSize() ) );
1106 }
1107
1108 // Center if we're behind an obscuring dialog, or within 10% of its edge
1109 for( BOX2D rect : dialogScreenRects )
1110 {
1111 rect.Inflate( rect.GetWidth() / 10 );
1112
1113 if( rect.Contains( GetCanvas()->GetView()->ToScreen( aPos ) ) )
1114 centerView = true;
1115 }
1116 }
1117
1118 if( centerView )
1119 {
1120 try
1121 {
1122 GetCanvas()->GetView()->SetCenter( aPos, dialogScreenRects );
1123 }
1124 catch( const Clipper2Lib::Clipper2Exception& e )
1125 {
1126 wxFAIL_MSG( wxString::Format( wxT( "Clipper2 exception occurred centering object: %s" ), e.what() ) );
1127 }
1128 }
1129
1131}
1132
1133
1134void PrintDrawingSheet( const RENDER_SETTINGS* aSettings, const PAGE_INFO& aPageInfo,
1135 const wxString& aSheetName, const wxString& aSheetPath,
1136 const wxString& aFileName, const TITLE_BLOCK& aTitleBlock,
1137 const std::map<wxString, wxString>* aProperties, int aSheetCount,
1138 const wxString& aPageNumber, double aMils2Iu, const PROJECT* aProject,
1139 const wxString& aSheetLayer, bool aIsFirstPage )
1140{
1142
1143 drawList.SetDefaultPenSize( aSettings->GetDefaultPenWidth() );
1144 drawList.SetPlotterMilsToIUfactor( aMils2Iu );
1145 drawList.SetPageNumber( aPageNumber );
1146 drawList.SetSheetCount( aSheetCount );
1147 drawList.SetFileName( aFileName );
1148 drawList.SetSheetName( aSheetName );
1149 drawList.SetSheetPath( aSheetPath );
1150 drawList.SetSheetLayer( aSheetLayer );
1151 drawList.SetProject( aProject );
1152 drawList.SetIsFirstPage( aIsFirstPage );
1153 drawList.SetProperties( aProperties );
1154
1155 drawList.BuildDrawItemsList( aPageInfo, aTitleBlock );
1156
1157 // Draw item list
1158 drawList.Print( aSettings );
1159}
1160
1161
1163 const std::map<wxString, wxString>* aProperties,
1164 double aMils2Iu, const wxString &aFilename,
1165 const wxString &aSheetLayer )
1166{
1168 return;
1169
1170 wxDC* DC = aSettings->GetPrintDC();
1171 wxPoint origin = DC->GetDeviceOrigin();
1172
1173 if( origin.y > 0 )
1174 {
1175 DC->SetDeviceOrigin( 0, 0 );
1176 DC->SetAxisOrientation( true, false );
1177 }
1178
1180 aFilename, GetTitleBlock(), aProperties, aScreen->GetPageCount(),
1181 aScreen->GetPageNumber(), aMils2Iu, &Prj(), aSheetLayer,
1182 aScreen->GetVirtualPageNumber() == 1 );
1183
1184 if( origin.y > 0 )
1185 {
1186 DC->SetDeviceOrigin( origin.x, origin.y );
1187 DC->SetAxisOrientation( true, true );
1188 }
1189}
1190
1191
1193{
1194 // Virtual function. Base class implementation returns an empty string.
1195 return wxEmptyString;
1196}
1197
1198
1200{
1201 // Virtual function. Base class implementation returns an empty string.
1202 return wxEmptyString;
1203}
1204
1205
1206bool EDA_DRAW_FRAME::LibraryFileBrowser( const wxString& aTitle, bool doOpen, wxFileName& aFilename,
1207 const wxString& wildcard, const wxString& ext,
1208 bool isDirectory, FILEDLG_HOOK_NEW_LIBRARY* aFileDlgHook )
1209{
1210 aFilename.SetExt( ext );
1211
1212 wxString defaultDir = aFilename.GetPath();
1213
1214 if( defaultDir.IsEmpty() )
1215 defaultDir = GetMruPath();
1216
1217 if( isDirectory && doOpen )
1218 {
1219 wxDirDialog dlg( this, aTitle, defaultDir, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
1220
1221 if( dlg.ShowModal() == wxID_CANCEL )
1222 return false;
1223
1224 aFilename = dlg.GetPath();
1225 aFilename.SetExt( ext );
1226 }
1227 else
1228 {
1229 // Ensure the file has a dummy name, otherwise GTK will display the regex from the filter
1230 if( aFilename.GetName().empty() )
1231 aFilename.SetName( wxS( "Library" ) );
1232
1233 wxFileDialog dlg( this, aTitle, defaultDir, aFilename.GetFullName(), wildcard,
1234 doOpen ? wxFD_OPEN | wxFD_FILE_MUST_EXIST
1235 : wxFD_SAVE | wxFD_CHANGE_DIR | wxFD_OVERWRITE_PROMPT );
1236
1237 if( aFileDlgHook )
1238 dlg.SetCustomizeHook( *aFileDlgHook );
1239
1241
1242 if( dlg.ShowModal() == wxID_CANCEL )
1243 return false;
1244
1245 aFilename = dlg.GetPath();
1246 aFilename.SetExt( ext );
1247 }
1248
1249 SetMruPath( aFilename.GetPath() );
1250
1251 return true;
1252}
1253
1254
1256{
1258
1259 if( m_searchPane )
1260 {
1261 wxAuiPaneInfo& search_pane_info = m_auimgr.GetPane( m_searchPane );
1262 search_pane_info.Caption( _( "Search" ) );
1263 }
1264
1265 if( m_propertiesPanel )
1266 {
1267 wxAuiPaneInfo& properties_pane_info = m_auimgr.GetPane( m_propertiesPanel );
1268 properties_pane_info.Caption( _( "Properties" ) );
1269 }
1270
1272 {
1273 wxAuiPaneInfo& net_inspector_panel_info = m_auimgr.GetPane( m_netInspectorPanel );
1274 net_inspector_panel_info.Caption( _( "Net Inspector" ) );
1275 }
1276}
1277
1278
1280{
1281 if( m_isClosing || !m_propertiesPanel || !m_propertiesPanel->IsShownOnScreen() )
1282 return;
1283
1284 m_propertiesPanel->UpdateData();
1285}
1286
1287
1289{
1290 return m_gitCommitPane && m_auimgr.GetPane( GitCommitPaneName() ).IsShown();
1291}
1292
1293
1295{
1296 if( !m_gitCommitPane )
1297 return;
1298
1299 wxAuiPaneInfo& pane = m_auimgr.GetPane( GitCommitPaneName() );
1300 bool show = !pane.IsShown();
1301
1302 pane.Show( show );
1303
1304 if( show )
1306
1307 m_auimgr.Update();
1308}
1309
1310
1312{
1313 if( !IsGitCommitPaneShown() )
1314 return;
1315
1316 // Gated on the preference so no editor binds a repository behind it.
1317 if( Pgm().GetCommonSettings()->m_Git.enableGit )
1319
1320 // Refreshed either way, or turning the preference off never reaches the panel.
1321 m_gitCommitPane->RefreshFileList();
1322}
1323
1324
1329
1330
1332{
1333 if( !m_colorSettings || aForceRefresh )
1334 {
1336 const_cast<EDA_DRAW_FRAME*>( this )->m_colorSettings = colorSettings;
1337 }
1338
1339 return m_colorSettings;
1340}
1341
1342
1344{
1346
1347 ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
1348 EDITOR_CONDITIONS cond( this );
1349
1350 wxASSERT( mgr );
1351
1355}
1356
1357
1359 const std::function<bool( const SELECTION& )>& aEnable )
1360{
1361 ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
1362 const std::string arcToolPrefix = aDrawArc.GetName();
1363
1364 // Every arc tool action extends the plain action's name, so one compare covers them all
1365 const SELECTION_CONDITION arcToolActive =
1366 [this, arcToolPrefix]( const SELECTION& )
1367 {
1368 return CurrentToolName().starts_with( arcToolPrefix );
1369 };
1370
1372
1373 do
1374 {
1375 const SELECTION_CONDITION inMode =
1376 [this, mode]( const SELECTION& )
1377 {
1378 APP_SETTINGS_BASE* cfg = config();
1379
1380 return cfg && cfg->m_ArcDrawMode == mode;
1381 };
1382
1383 if( const TOOL_ACTION* action = drawArcAction( mode ) )
1384 mgr->SetConditions( *action, ACTION_CONDITIONS().Enable( aEnable ).Check( inMode && arcToolActive ) );
1385
1386 mode = IncrementArcDrawMode( mode );
1387 } while( mode != ARC_DRAW_MODE::CENTER_START_END );
1388}
1389
1390
1392{
1393 APP_SETTINGS_BASE* cfg = config();
1394
1395 // The arc group would otherwise start on its first entry and overwrite the saved mode
1396 if( const TOOL_ACTION* action = cfg ? drawArcAction( cfg->m_ArcDrawMode ) : nullptr )
1397 SelectToolbarAction( *action );
1398}
1399
1400
1402{
1403 COMMON_TOOLS* cmnTool = m_toolManager->GetTool<COMMON_TOOLS>();
1404
1405 if( cmnTool )
1406 {
1407 // Tell the tool what the units used last session
1408 cmnTool->SetLastUnits( static_cast<EDA_UNITS>( aCfg->m_System.last_imperial_units ) );
1409 cmnTool->SetLastUnits( static_cast<EDA_UNITS>( aCfg->m_System.last_metric_units ) );
1410 }
1411
1412 // Tell the tool what units the frame is currently using
1413 switch( static_cast<EDA_UNITS>( aCfg->m_System.units ) )
1414 {
1415 default:
1416 case EDA_UNITS::MM: m_toolManager->RunAction( ACTIONS::millimetersUnits ); break;
1417 case EDA_UNITS::INCH: m_toolManager->RunAction( ACTIONS::inchesUnits ); break;
1418 case EDA_UNITS::MILS: m_toolManager->RunAction( ACTIONS::milsUnits ); break;
1419 }
1420}
1421
1422
1423void EDA_DRAW_FRAME::GetUnitPair( EDA_UNITS& aPrimaryUnit, EDA_UNITS& aSecondaryUnits )
1424{
1425 COMMON_TOOLS* cmnTool = m_toolManager->GetTool<COMMON_TOOLS>();
1426
1427 aPrimaryUnit = GetUserUnits();
1428 aSecondaryUnits = EDA_UNITS::MILS;
1429
1430 if( EDA_UNIT_UTILS::IsImperialUnit( aPrimaryUnit ) )
1431 {
1432 if( cmnTool )
1433 aSecondaryUnits = cmnTool->GetLastMetricUnits();
1434 else
1435 aSecondaryUnits = EDA_UNITS::MM;
1436 }
1437 else
1438 {
1439 if( cmnTool )
1440 aSecondaryUnits = cmnTool->GetLastImperialUnits();
1441 else
1442 aSecondaryUnits = EDA_UNITS::MILS;
1443 }
1444}
1445
1446
1448{
1450
1451 // A canvas that failed this session falls back without changing the saved preference
1452 if( CanvasFailed( m_canvasType ) )
1454
1455 if( m_canvasType != GetCanvas()->GetBackend() )
1456 {
1457 // SwitchCanvas overwrites m_canvasType with whatever backend it ended up on
1459
1460 // Try to switch (will automatically fallback if necessary)
1461 SwitchCanvas( requested );
1462
1463 if( GetCanvas()->GetBackend() != requested )
1464 {
1466 m_failedCanvases.insert( requested ); // Store failure for other EDA_DRAW_FRAMEs
1467 }
1468 }
1469}
1470
1471
1472void EDA_DRAW_FRAME::handleActivateEvent( wxActivateEvent& aEvent )
1473{
1474 // Force a refresh of the message panel to ensure that the text is the right color
1475 // when the window activates
1476 if( !IsIconized() )
1477 m_messagePanel->Refresh();
1478}
1479
1480
1481void EDA_DRAW_FRAME::onActivate( wxActivateEvent& aEvent )
1482{
1483 handleActivateEvent( aEvent );
1484
1485 aEvent.Skip();
1486}
1487
1488
1489bool EDA_DRAW_FRAME::SaveCanvasImageToFile( const wxString& aFileName, BITMAP_TYPE aBitmapType )
1490{
1491 wxImage image;
1492
1493
1494 if( !GetCanvas()->GetScreenshot( image ) )
1495 {
1496 wxSize image_size = GetCanvas()->GetClientSize();
1497 wxClientDC dc( GetCanvas() );
1498 wxBitmap bitmap( image_size.x, image_size.y );
1499 wxMemoryDC memdc;
1500
1501 memdc.SelectObject( bitmap );
1502 memdc.Blit( 0, 0, image_size.x, image_size.y, &dc, 0, 0 );
1503 memdc.SelectObject( wxNullBitmap );
1504
1505 image = bitmap.ConvertToImage();
1506 }
1507
1508 wxBitmapType type = wxBITMAP_TYPE_PNG;
1509 switch( aBitmapType )
1510 {
1511 case BITMAP_TYPE::PNG: type = wxBITMAP_TYPE_PNG; break;
1512 case BITMAP_TYPE::BMP: type = wxBITMAP_TYPE_BMP; break;
1513 case BITMAP_TYPE::JPG: type = wxBITMAP_TYPE_JPEG; break;
1514 }
1515
1516 bool retv = image.SaveFile( aFileName, type );
1517
1518 image.Destroy();
1519 return retv;
1520}
1521
1522
1524{
1525 wxCHECK( aCfg, aAction.show_button );
1526
1527 for( const auto& [identifier, visible] : aCfg->m_Plugins.actions )
1528 {
1529 if( identifier == aAction.identifier )
1530 return visible;
1531 }
1532
1533 return aAction.show_button;
1534}
1535
1536
1537std::vector<const PLUGIN_ACTION*> EDA_DRAW_FRAME::GetOrderedPluginActions( PLUGIN_ACTION_SCOPE aScope,
1538 APP_SETTINGS_BASE* aCfg )
1539{
1540 std::vector<const PLUGIN_ACTION*> actions;
1541 wxCHECK( aCfg, actions );
1542
1544 std::vector<const PLUGIN_ACTION*> unsorted = mgr.GetActionsForScope( aScope );
1545 std::map<wxString, const PLUGIN_ACTION*> actionMap;
1546 std::set<const PLUGIN_ACTION*> handled;
1547
1548 for( const PLUGIN_ACTION* action : unsorted )
1549 actionMap[action->identifier] = action;
1550
1551 for( const auto& identifier : aCfg->m_Plugins.actions | std::views::keys )
1552 {
1553 if( actionMap.contains( identifier ) )
1554 {
1555 const PLUGIN_ACTION* action = actionMap[ identifier ];
1556 actions.emplace_back( action );
1557 handled.insert( action );
1558 }
1559 }
1560
1561 for( const auto& action : actionMap | std::views::values )
1562 {
1563 if( !handled.contains( action ) )
1564 actions.emplace_back( action );
1565 }
1566
1567 return actions;
1568}
1569
1570
1572{
1573 wxCHECK( aMenu, 0 );
1574
1576
1577 mgr.MenuBindings( m_ident ).clear();
1578
1579 std::vector<const PLUGIN_ACTION*> actions = GetOrderedPluginActions( PluginActionScope(), config() );
1580
1581 size_t count = 0;
1582
1583 for( const PLUGIN_ACTION* action : actions )
1584 {
1585 const std::vector<wxImage>& images =
1586 KIPLATFORM::UI::IsDarkTheme() && !action->icon_dark.empty() ? action->icon_dark : action->icon_light;
1587
1589 wxBitmapBundle icon;
1590
1591 if( images.empty() )
1592 {
1593 icon = KiBitmapBundleDef( BITMAPS::puzzle_piece, iconSize );
1594 }
1595 else
1596 {
1597 wxVector<wxBitmap> bitmaps;
1598
1599 for( const wxImage& img : images )
1600 bitmaps.push_back( wxBitmap( img ) );
1601
1602 icon = BITMAP_STORE::MakeBitmapBundleDef( bitmaps, iconSize );
1603 }
1604
1605 if( !icon.IsOk() )
1606 continue;
1607
1608 wxMenuItem* item = KIUI::AddMenuItem( aMenu, wxID_ANY, action->name, action->description, icon );
1609
1610 Connect( item->GetId(), wxEVT_COMMAND_MENU_SELECTED,
1611 wxCommandEventHandler( EDA_DRAW_FRAME::OnApiPluginInvoke ) );
1612
1613 mgr.MenuBindings( m_ident ).insert( { item->GetId(), action->identifier } );
1614
1615 ++count;
1616 }
1617
1618 return count;
1619}
1620
1621
1623{
1625
1626 mgr.ButtonBindings( m_ident ).clear();
1627
1628 std::vector<const PLUGIN_ACTION*> actions = GetOrderedPluginActions( PluginActionScope(), config() );
1629
1631
1632 for( const PLUGIN_ACTION* action : actions )
1633 {
1634 if( !IsPluginActionButtonVisible( *action, config() ) )
1635 continue;
1636
1637 const std::vector<wxImage>& images = KIPLATFORM::UI::IsDarkTheme() && !action->icon_dark.empty()
1638 ? action->icon_dark
1639 : action->icon_light;
1640
1641 if( images.empty() )
1642 continue;
1643
1644 wxVector<wxBitmap> bitmaps;
1645
1646 for( const wxImage& img : images )
1647 bitmaps.push_back( wxBitmap( img ) );
1648
1649 wxBitmapBundle icon = BITMAP_STORE::MakeBitmapBundleDef( bitmaps, iconSize );
1650
1651 if( !icon.IsOk() )
1652 continue;
1653
1654 wxAuiToolBarItem* button = aToolbar->AddTool( wxID_ANY, wxEmptyString, icon, action->name );
1655
1656 Connect( button->GetId(), wxEVT_COMMAND_MENU_SELECTED,
1657 wxCommandEventHandler( EDA_DRAW_FRAME::OnApiPluginInvoke ) );
1658
1659 mgr.ButtonBindings( m_ident ).insert( { button->GetId(), action->identifier } );
1660 }
1661}
1662
1663
1664void EDA_DRAW_FRAME::OnApiPluginInvoke( wxCommandEvent& aEvent )
1665{
1667
1668 std::optional<wxString> identifier;
1669
1670 if( mgr.ButtonBindings( m_ident ).contains( aEvent.GetId() ) )
1671 identifier = mgr.ButtonBindings( m_ident ).at( aEvent.GetId() );
1672 else if( mgr.MenuBindings( m_ident ).contains( aEvent.GetId() ) )
1673 identifier = mgr.MenuBindings( m_ident ).at( aEvent.GetId() );
1674
1675 if( !identifier )
1676 return;
1677
1678 std::shared_ptr<REPORTER> reporter;
1679
1680 if( KISTATUSBAR* statusBar = dynamic_cast<KISTATUSBAR*>( GetStatusBar() ) )
1681 reporter = std::make_shared<STATUSBAR_WARNING_REPORTER>( statusBar, wxS( "plugin" ) );
1682
1683 mgr.InvokeAction( *identifier, reporter );
1684}
const char * name
ARC_DRAW_MODE
Construction sequence used when interactively drawing a circular arc.
@ CENTER_START_END
Center, then start (sets radius), then sweep to the end.
ARC_DRAW_MODE IncrementArcDrawMode(ARC_DRAW_MODE aMode)
Return the next mode in the cycle order used by the cycle-mode action.
BASE_SCREEN class implementation.
constexpr EDA_IU_SCALE unityScale
Definition base_units.h:131
wxBitmapBundle KiBitmapBundleDef(BITMAPS aBitmap, int aDefHeight)
Construct and return a bitmap bundle for the given icon ID, with the default bitmap size being aDefHe...
Definition bitmap.cpp:112
BITMAP_TYPE
BOX2< VECTOR2I > BOX2I
Definition box2.h:917
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:985
BOX2< VECTOR2D > BOX2D
Definition box2.h:918
static TOOL_ACTION gridProperties
Definition actions.h:197
static TOOL_ACTION millimetersUnits
Definition actions.h:203
static TOOL_ACTION updatePreferences
Definition actions.h:277
static TOOL_ACTION gridPreset
Definition actions.h:194
static TOOL_ACTION updateUnits
Definition actions.h:204
static TOOL_ACTION milsUnits
Definition actions.h:202
static TOOL_ACTION inchesUnits
Definition actions.h:201
static TOOL_ACTION zoomFitScreen
Definition actions.h:139
static TOOL_ACTION zoomPreset
Definition actions.h:142
Manage TOOL_ACTION objects.
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
Define the structure of a menu based on ACTIONs.
Definition action_menu.h:43
static ACTION_TOOLBAR_CONTROL gridSelect
static ACTION_TOOLBAR_CONTROL overrideLocks
static ACTION_TOOLBAR_CONTROL zoomSelect
Define the structure of a toolbar with buttons that invoke ACTIONs.
Responsible for loading plugin definitions for API-based plugins (ones that do not run inside KiCad i...
void InvokeAction(const wxString &aIdentifier, std::shared_ptr< REPORTER > aReporter=nullptr)
std::vector< const PLUGIN_ACTION * > GetActionsForScope(PLUGIN_ACTION_SCOPE aScope)
std::map< int, wxString > & ButtonBindings(FRAME_T aFrame)
std::map< int, wxString > & MenuBindings(FRAME_T aFrame)
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
ARC_DRAW_MODE m_ArcDrawMode
Construction sequence last used by the arc drawing tool in this application.
FIND_REPLACE m_FindReplace
Handles how to draw a screen (a board, a schematic ...)
Definition base_screen.h:37
int GetPageCount() const
Definition base_screen.h:68
int GetVirtualPageNumber() const
Definition base_screen.h:71
const wxString & GetPageNumber() const
static wxBitmapBundle MakeBitmapBundleDef(const wxVector< wxBitmap > &aBitmaps, int aDefHeight)
Constructs a bitmap bundle from the given bitmaps.
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition box2.h:556
constexpr size_type GetWidth() const
Definition box2.h:217
constexpr bool Contains(const Vec &aPoint) const
Definition box2.h:171
Color settings are a bit different than most of the settings objects in that there can be more than o...
APPEARANCE m_Appearance
Handles action that are shared between different applications.
void SetLastUnits(EDA_UNITS aUnit)
EDA_UNITS GetLastImperialUnits()
EDA_UNITS GetLastMetricUnits()
void AddSeparator(int aOrder=ANY_ORDER)
Add a separator to the menu.
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition dialog_shim.h:81
Store the list of graphic items: rect, lines, polygons and texts to draw/plot the title block and fra...
void SetPlotterMilsToIUfactor(double aMils2Iu)
Set the scalar to convert pages units (mils) to plot units.
void BuildDrawItemsList(const PAGE_INFO &aPageInfo, const TITLE_BLOCK &aTitleBlock)
Drawing or plot the drawing sheet.
void SetSheetPath(const wxString &aSheetPath)
Set the sheet path to draw/plot.
void SetFileName(const wxString &aFileName)
Set the filename to draw/plot.
void SetDefaultPenSize(int aPenSize)
void Print(const RENDER_SETTINGS *aSettings)
Draws the item list created by BuildDrawItemsList.
void SetSheetName(const wxString &aSheetName)
Set the sheet name to draw/plot.
void SetIsFirstPage(bool aIsFirstPage)
Set if the page is the first page.
void SetProperties(const std::map< wxString, wxString > *aProps)
Set properties used for text variable resolution.
void SetSheetLayer(const wxString &aSheetLayer)
Set the sheet layer to draw/plot.
void SetSheetCount(int aSheetCount)
Set the value of the count of sheets, for basic inscriptions.
void SetPageNumber(const wxString &aPageNumber)
Set the value of the sheet number.
void SetProject(const PROJECT *aProject)
void SelectToolbarAction(const TOOL_ACTION &aAction) override
Select the given action in the toolbar group which contains it, if any.
virtual APP_SETTINGS_BASE * config() const
Return the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
virtual WINDOW_SETTINGS * GetWindowSettings(APP_SETTINGS_BASE *aCfg)
Return a pointer to the window settings for this frame.
void OnToolbarSizeChanged()
Update toolbars if desired toolbar icon changed.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
static const wxString GitCommitPaneName()
Named here rather than beside the editors' other panes, because the project manager docks this one to...
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
void ChangeUserUnits(EDA_UNITS aUnits)
void RegisterCustomToolbarControlFactory(const ACTION_TOOLBAR_CONTROL &aControlDesc, const ACTION_TOOLBAR_CONTROL_FACTORY &aControlFactory)
Register a creation factory for toolbar controls that are present in this frame.
virtual void configureToolbars()
wxTimer * m_autoSaveTimer
wxAuiManager m_auimgr
int GetMaxUndoItems() const
virtual void LoadSettings(APP_SETTINGS_BASE *aCfg)
Load common frame parameters from a configuration file.
wxString GetMruPath() const
virtual void OnSize(wxSizeEvent &aEvent)
int GetAutoSaveInterval() const
virtual void SaveSettings(APP_SETTINGS_BASE *aCfg)
Save common frame parameters to a configuration data file.
void SetMruPath(const wxString &aPath)
bool m_isClosing
Set by the close window event handler after frames are asked if they can close.
The base class for create windows for drawing purpose.
virtual const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const
Return bounding box of document with option to not include some items.
wxCheckBox * m_overrideLocksCb
wxArrayString m_replaceStringHistoryList
virtual void ClearMsgPanel()
Clear all messages from the message panel.
static std::vector< const PLUGIN_ACTION * > GetOrderedPluginActions(PLUGIN_ACTION_SCOPE aScope, APP_SETTINGS_BASE *aCfg)
Return ordered list of plugin actions for display in the toolbar.
void configureToolbars() override
EDA_DRAW_PANEL_GAL * m_canvas
virtual void ActivateGalCanvas()
Use to start up the GAL drawing canvas.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
static bool CanvasFailed(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvas)
GIT_COMMIT_PANE * m_gitCommitPane
GAL_DISPLAY_OPTIONS_IMPL m_galDisplayOptions
This the frame's interface to setting GAL display options.
virtual const TITLE_BLOCK & GetTitleBlock() const =0
void onActivate(wxActivateEvent &aEvent)
COLOR_SETTINGS * m_colorSettings
wxChoice * m_gridSelectBox
void AddStandardSubMenus(TOOL_MENU &aMenu)
Construct a "basic" menu for a tool, containing only items that apply to all tools (e....
void ReleaseFile()
Release the current file marked in use.
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
The current canvas type.
virtual wxString GetFullScreenDesc() const
void OnSelectGrid(wxCommandEvent &event)
Command event handler for selecting grid sizes.
void DisplayToolMsg(const wxString &msg) override
std::unique_ptr< LOCKFILE > m_file_checker
Prevents opening same file multiple times.
void OnUpdateSelectZoom(wxUpdateUIEvent &aEvent)
Update the checked item in the zoom wxchoice.
virtual const PAGE_INFO & GetPageSettings() const =0
void DisplayUnitsMsg()
Display current unit pane in the status bar.
void setupUnits(APP_SETTINGS_BASE *aCfg)
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
void setArcModeConditions(const TOOL_ACTION &aDrawArc, const std::function< bool(const SELECTION &)> &aEnable)
Check each arc mode's tool action while the arc tool runs in that mode.
void UpdateGridSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
bool LockFile(const wxString &aFileName)
Mark a schematic file as being in use.
virtual void HardRedraw()
Rebuild the GAL and redraws the screen.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
bool SaveCanvasImageToFile(const wxString &aFileName, BITMAP_TYPE aBitmapType)
Save the current view as an image file.
void UpdateZoomSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Change the current rendering backend.
virtual void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
const wxString GetZoomLevelIndicator() const
Return a human readable value for display in dialogs.
virtual void OnSelectZoom(wxCommandEvent &event)
Set the zoom factor when selected by the zoom list box in the main tool bar.
virtual void resolveCanvasType()
Determine the canvas type to load (with prompt if required) and initializes m_canvasType.
BASE_SCREEN * m_currentScreen
current used SCREEN
virtual wxString GetScreenDesc() const
VECTOR2I GetNearestGridPosition(const VECTOR2I &aPosition) const
Return the nearest aGridSize location to aPosition.
void SyncZoomSelectBox()
Show the current zoom in the zoom wxchoice, as a preset or as its own entry.
EDA_MSG_PANEL * m_messagePanel
virtual const VECTOR2I & GetGridOrigin() const =0
Return the absolute coordinates of the origin of the snap grid.
void RefreshGitCommitPane()
Attach the git session if needed and refresh the version-control pane, when it is shown.
bool saveCanvasTypeSetting(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Store the canvas type in the application settings.
virtual const TOOL_ACTION * drawArcAction(ARC_DRAW_MODE aMode) const
The action that starts the arc tool in aMode, or nullptr in a frame without an arc tool.
EDA_DRAW_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, const wxString &aTitle, const wxPoint &aPos, const wxSize &aSize, long aStyle, const wxString &aFrameName, const EDA_IU_SCALE &aIuScale)
virtual void Zoom_Automatique(bool aWarpPointer)
Redraw the screen with best zoom level and the best centering that shows all the page or the board.
NET_INSPECTOR_PANEL * m_netInspectorPanel
bool LibraryFileBrowser(const wxString &aTitle, bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory, FILEDLG_HOOK_NEW_LIBRARY *aFileDlgHook=nullptr)
virtual void SetGridVisibility(bool aVisible)
virtual void handleActivateEvent(wxActivateEvent &aEvent)
Handle a window activation event.
virtual void AddApiPluginTools(ACTION_TOOLBAR *aToolbar)
Append actions from API plugins to the given toolbar.
virtual void OnApiPluginInvoke(wxCommandEvent &aEvent)
Handler for activating an API plugin (via toolbar or menu).
virtual void UpdateMsgPanel()
Redraw the message panel.
wxStatusBar * OnCreateStatusBar(int number, long style, wxWindowID id, const wxString &name) override
Create the status line (like a wxStatusBar).
virtual COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const
Returns a pointer to the active color theme settings.
void ToggleUserUnits() override
void FocusOnLocation(const VECTOR2I &aPos, bool aAllowScroll=true)
Useful to focus on a particular location, in find functions.
virtual void CreateHotkeyPopup()
void UpdateStatusBar() override
Update the status bar information.
void syncToolbarSelections() override
Called after the toolbars are rebuilt so a frame can select the group entries that reflect its saved ...
void GetUnitPair(EDA_UNITS &aPrimaryUnit, EDA_UNITS &aSecondaryUnits) override
Get the pair or units in current use.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
void PrintDrawingSheet(const RENDER_SETTINGS *aSettings, BASE_SCREEN *aScreen, const std::map< wxString, wxString > *aProperties, double aMils2Iu, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
Print the drawing-sheet (frame and title block).
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
wxSocketServer * m_socketServer
SEARCH_PANE * m_searchPane
EDA_SEARCH_DATA & GetFindReplaceData()
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
void OnMove(wxMoveEvent &aEvent) override
std::vector< wxWindow * > findDialogs()
virtual void DisplayGridMsg()
Display current grid size in the status bar.
EDA_DRAW_PANEL_GAL::GAL_TYPE loadCanvasTypeSetting()
Return the canvas type stored in the application settings.
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
wxArrayString m_findStringHistoryList
static std::set< EDA_DRAW_PANEL_GAL::GAL_TYPE > m_failedCanvases
The canvases that have failed in any EDA_DRAW_FRAME this session.
wxChoice * m_zoomSelectBox
size_t AddApiPluginMenuItems(ACTION_MENU *aMenu)
Append actions from API plugins to the given menu.
virtual std::unique_ptr< GRID_HELPER > MakeGridHelper()
virtual PLUGIN_ACTION_SCOPE PluginActionScope() const
std::unique_ptr< EDA_SEARCH_DATA > m_findReplaceData
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
void DisplayConstraintsMsg(const wxString &msg)
void AppendMsgPanel(const wxString &aTextUpper, const wxString &aTextLower, int aPadding=6)
Append a message to the message panel.
virtual void SetGridOverrides(bool aOverride)
PROPERTIES_PANEL * m_propertiesPanel
bool m_showBorderAndTitleBlock
VECTOR2I GetNearestHalfGridPosition(const VECTOR2I &aPosition) const
Return the nearest aGridSize / 2 location to aPosition.
void ClearToolbarControl(int aId) override
bool GetOverrideLocks() const
HOTKEY_CYCLE_POPUP * m_hotkeyPopup
virtual void UpdateProperties()
void OnUpdateSelectGrid(wxUpdateUIEvent &aEvent)
Update the checked item in the grid wxchoice.
static bool IsPluginActionButtonVisible(const PLUGIN_ACTION &aAction, APP_SETTINGS_BASE *aCfg)
static constexpr GAL_TYPE GAL_FALLBACK
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the KIGFX::VIEW_CONTROLS instance used in the panel.
virtual KIGFX::VIEW * GetView() const
Return a pointer to the KIGFX::VIEW instance used in the panel.
void ResizeGal(bool aForce=false)
Resize the GAL to the current client size of this panel.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
@ GAL_TYPE_LAST
Sentinel, do not use as a parameter.
@ GAL_TYPE_OPENGL
OpenGL implementation.
@ GAL_TYPE_CAIRO
Cairo implementation.
@ GAL_TYPE_NONE
GAL not used (the legacy wxDC engine is used)
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
void UpdateTouchpadGestureHandler()
Apply the current native touchpad gesture preference to the active backend window.
virtual bool SwitchBackend(GAL_TYPE aGalType)
Switch method of rendering graphics.
void StartDrawing()
Begin drawing if it was stopped previously.
static GAL_TYPE ResolveStoredCanvasType(int aStoredCanvasType)
Convert a stored canvas type setting into a backend that can actually be used.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
virtual void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition eda_item.h:296
A panel to display various information messages.
Definition msgpanel.h:97
Class that groups generic conditions for editor states.
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Create a functor that tests if the frame has the specified units.
static const TOOL_EVENT SelectedEvent
Definition actions.h:347
static void BuildChoiceList(wxArrayString *aGridsList, WINDOW_SETTINGS *aCfg, EDA_DRAW_FRAME *aParent)
Definition grid_menu.cpp:79
Similar to EDA_VIEW_SWITCHER, this dialog is a popup that shows feedback when using a hotkey to cycle...
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
double GetZoomFactor() const
const VECTOR2D & GetGridSize() const
Return the grid size.
void SetGridVisibility(bool aVisibility)
Set the visibility setting of the grid.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void LoadSettings()
Load new settings from program common settings.
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
Definition view.cpp:860
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition view.cpp:970
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition view.h:729
KISTATUSBAR is a wxStatusBar suitable for Kicad manager.
Definition kistatusbar.h:50
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
KIWAY_PLAYER(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, const wxString &aTitle, const wxPoint &aPos, const wxSize &aSize, long aStyle, const wxString &aFrameName, const EDA_IU_SCALE &aIuScale)
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:348
EDA_MSG_PANEL items for displaying messages.
Definition msgpanel.h:50
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition page_info.h:75
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition pgm_base.cpp:600
virtual API_PLUGIN_MANAGER & GetPluginManager() const
Definition pgm_base.h:140
Container for project specific data.
Definition project.h:63
virtual bool AttachGitRepository()
Find the Git repository containing the project directory and bind it to the session.
Definition project.cpp:94
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Definition title_block.h:38
TOOL_MANAGER * m_toolManager
std::string CurrentToolName() const
TOOL_DISPATCHER * m_toolDispatcher
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
ACTIONS * m_actions
Represent a single user action.
const std::string & GetName() const
Return name of the action.
Generic, UI-independent tool event.
Definition tool_event.h:167
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Manage a CONDITIONAL_MENU and some number of CONTEXT_MENUs as sub-menus.
Definition tool_menu.h:39
CONDITIONAL_MENU & GetMenu()
Definition tool_menu.cpp:40
void RegisterSubMenu(std::shared_ptr< ACTION_MENU > aSubMenu)
Store a submenu of this menu model.
Definition tool_menu.cpp:46
EDA_UNITS GetUserUnits() const
void SetUserUnits(EDA_UNITS aUnits)
@ LIGHTGRAY
Definition color4d.h:43
@ DARKGRAY
Definition color4d.h:42
@ BLACK
Definition color4d.h:40
@ FOR_CANVAS
Definition common.h:92
This file is part of the common library.
#define _(s)
#define DEFAULT_MAX_UNDO_ITEMS
#define FR_HISTORY_LIST_CNT
Maximum size of the find/replace history stacks.
void PrintDrawingSheet(const RENDER_SETTINGS *aSettings, const PAGE_INFO &aPageInfo, const wxString &aSheetName, const wxString &aSheetPath, const wxString &aFileName, const TITLE_BLOCK &aTitleBlock, const std::map< wxString, wxString > *aProperties, int aSheetCount, const wxString &aPageNumber, double aMils2Iu, const PROJECT *aProject, const wxString &aSheetLayer, bool aIsFirstPage)
Print the border and title block.
EDA_SEARCH_MATCH_MODE
EDA_UNITS
Definition eda_units.h:45
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition frame_type.h:29
@ FRAME_PCB_EDITOR
Definition frame_type.h:38
@ FRAME_SCH_SYMBOL_EDITOR
Definition frame_type.h:31
@ FRAME_SCH
Definition frame_type.h:30
@ FRAME_PL_EDITOR
Definition frame_type.h:55
@ FRAME_FOOTPRINT_EDITOR
Definition frame_type.h:39
@ FRAME_GERBER
Definition frame_type.h:53
@ ID_ON_GRID_SELECT
Definition id.h:113
@ ID_ON_ZOOM_SELECT
Definition id.h:112
@ ID_ON_OVERRIDE_LOCKS
Definition id.h:114
This file contains miscellaneous commonly used macros and functions.
Message panel definition file.
KICOMMON_API bool IsImperialUnit(EDA_UNITS aUnit)
Definition eda_units.cpp:43
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
Definition definitions.h:34
bool IsDarkTheme()
Determine if the desktop interface is currently using a dark theme or a light theme.
Definition wxgtk/ui.cpp:57
void AllowNetworkFileSystems(wxDialog *aDialog)
Configure a file dialog to show network and virtual file systems.
Definition wxgtk/ui.cpp:741
KICOMMON_API wxFont GetStatusFont(wxWindow *aWindow)
KICOMMON_API wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmapBundle &aImage, wxItemKind aType=wxITEM_NORMAL)
Create and insert a menu item with an icon into aMenu.
KICOMMON_API wxSize GetTextSize(const wxString &aSingleLine, wxWindow *aWindow)
Return the size of aSingleLine of text when it is rendered in aWindow using whatever font is currentl...
Definition ui_common.cpp:80
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition kicad_algo.h:96
STL namespace.
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE
PLUGIN_ACTION_SCOPE
std::function< bool(const SELECTION &)> SELECTION_CONDITION
Functor type that checks a specific condition for selected items.
#define DEFAULT_THEME
std::vector< FAB_LAYER_COLOR > dummy
Functors that can be used to figure out how the action controls should be displayed in the UI and if ...
std::vector< wxString > replace_history
std::vector< wxString > find_history
std::vector< std::pair< wxString, bool > > actions
Ordered list of plugin actions mapped to whether or not they are shown in the toolbar.
std::vector< GRID > grids
An action performed by a plugin via the IPC API.
Definition api_plugin.h:74
wxString identifier
Definition api_plugin.h:79
Store the common settings that are saved and loaded for each window / frame.
GRID_SETTINGS grid
std::vector< double > zoom_factors
DATABASE_CONNECTION dc(odbcBackend(cs))
IbisParser parser & reporter
wxLogTrace helper definitions.
Functions to provide common constants and other functions to assist in making a consistent UI.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
VECTOR2< double > VECTOR2D
Definition vector2d.h:707
VECTOR2D ToVECTOR2D(const wxPoint &aPoint)
Definition vector2wx.h:36
static PIECE rect(double aLeft, double aTop, double aRight, double aBottom, bool aMixed=false)