KiCad PCB EDA Suite
kicad_manager_frame.cpp File Reference
#include "kicad_id.h"
#include "pcm.h"
#include "pgm_kicad.h"
#include "project_tree_pane.h"
#include "widgets/bitmap_button.h"
#include <advanced_config.h>
#include <bitmaps.h>
#include <build_version.h>
#include <dialogs/panel_kicad_launcher.h>
#include <eda_base_frame.h>
#include <executable_names.h>
#include <file_history.h>
#include <policy_keys.h>
#include <gestfich.h>
#include <kiplatform/app.h>
#include <kiplatform/policy.h>
#include <kiway.h>
#include <kiway_express.h>
#include <launch_ext.h>
#include <reporter.h>
#include <project/project_local_settings.h>
#include <sch_file_versions.h>
#include <settings/settings_manager.h>
#include <tool/action_manager.h>
#include <tool/action_toolbar.h>
#include <tool/common_control.h>
#include <tool/tool_dispatcher.h>
#include <tool/tool_manager.h>
#include <tools/kicad_manager_actions.h>
#include <tools/kicad_manager_control.h>
#include <wildcards_and_files_ext.h>
#include <widgets/app_progress_dialog.h>
#include <wx/ffile.h>
#include <wx/filedlg.h>
#include <wx/dcclient.h>
#include <wx/dnd.h>
#include <wx/process.h>
#include <atomic>
#include <../pcbnew/plugins/kicad/pcb_plugin.h>
#include "kicad_manager_frame.h"
#include "settings/kicad_settings.h"
#include <wx/xml/xml.h>

Go to the source code of this file.

Macros

#define SEP()   wxFileName::GetPathSeparator()
 
#define ENABLE(x)   ACTION_CONDITIONS().Enable( x )
 

Functions

 EVT_MENU_RANGE (ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, KICAD_MANAGER_FRAME::language_change) KICAD_MANAGER_FRAME
 

Macro Definition Documentation

◆ ENABLE

#define ENABLE (   x)    ACTION_CONDITIONS().Enable( x )

◆ SEP

#define SEP ( )    wxFileName::GetPathSeparator()

Definition at line 80 of file kicad_manager_frame.cpp.

Function Documentation

◆ EVT_MENU_RANGE()

Definition at line 99 of file kicad_manager_frame.cpp.

118 :
121 m_leftWin( nullptr ),
122 m_launcher( nullptr ),
123 m_mainToolBar( nullptr )
124{
125 m_active_project = false;
126 m_leftWinWidth = 250; // Default value
127 m_aboutTitle = "KiCad";
128
129 // JPC: A very ugly hack to fix an issue on Linux: if the wxbase315u_xml_gcc_custom.so is
130 // used **only** in PCM, it is not found in some cases at run time.
131 // So just use it in the main module to avoid a not found issue
132 // wxbase315u_xml_gcc_custom shared object when launching Kicad
133 wxXmlDocument dummy;
134
135 // Create the status line (bottom of the frame). Left half is for project name; right half
136 // is for Reporter (currently used by archiver/unarchiver and PCM).
137 CreateStatusBar( 2 );
138 GetStatusBar()->SetFont( KIUI::GetStatusFont( this ) );
139
140 // Give an icon
141 wxIcon icon;
142 wxIconBundle icon_bundle;
143
144 if( IsNightlyVersion())
145 {
146 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly ) );
147 icon_bundle.AddIcon( icon );
148 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly_32 ) );
149 icon_bundle.AddIcon( icon );
150 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly_16 ) );
151 icon_bundle.AddIcon( icon );
152 }
153 else
154 {
155 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad ) );
156 icon_bundle.AddIcon( icon );
157 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_32 ) );
158 icon_bundle.AddIcon( icon );
159 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_16 ) );
160 icon_bundle.AddIcon( icon );
161 }
162
163 SetIcons( icon_bundle );
164
165 // Load the settings
166 LoadSettings( config() );
167
168 m_pcmButton = nullptr;
169 m_pcmUpdateCount = 0;
170 m_pcm = std::make_shared<PLUGIN_CONTENT_MANAGER>(
171 [this]( int aUpdateCount )
172 {
173 m_pcmUpdateCount = aUpdateCount;
174 CallAfter(
175 [this]()
176 {
177 updatePcmButtonBadge();
178 } );
179 },
180 [this]( const wxString aText )
181 {
182 CallAfter(
183 [aText, this]()
184 {
185 SetStatusText( aText, 1 );
186 } );
187 } );
188 m_pcm->SetRepositoryList( kicadSettings()->m_PcmRepositories );
189
190 // Left window: is the box which display tree project
191 m_leftWin = new PROJECT_TREE_PANE( this );
192
193 setupTools();
194 setupUIConditions();
195
196 m_launcher = new PANEL_KICAD_LAUNCHER( this );
197
198 RecreateBaseHToolbar();
199 ReCreateMenuBar();
200
201 m_auimgr.SetManagedWindow( this );
202 m_auimgr.SetFlags( wxAUI_MGR_LIVE_RESIZE );
203
204 m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Left()
205 .Layer( 2 ) );
206
207 // BestSize() does not always set the actual pane size of m_leftWin to the required value.
208 // It happens when m_leftWin is too large (roughly > 1/3 of the kicad manager frame width.
209 // (Well, BestSize() sets the best size... not the window size)
210 // A trick is to use MinSize() to set the required pane width,
211 // and after give a reasonable MinSize value
212 m_auimgr.AddPane( m_leftWin, EDA_PANE().Palette().Name( "ProjectTree" ).Left().Layer( 1 )
213 .Caption( _( "Project Files" ) ).PaneBorder( false )
214 .MinSize( m_leftWinWidth, -1 ).BestSize( m_leftWinWidth, -1 ) );
215
216 m_auimgr.AddPane( m_launcher, EDA_PANE().Canvas().Name( "Launcher" ).Center()
217 .Caption( _( "Editors" ) ).PaneBorder( false )
218 .MinSize( m_launcher->GetBestSize() ) );
219
220 m_auimgr.Update();
221
222 // Now the actual m_leftWin size is set, give it a reasonable min width
223 m_auimgr.GetPane( m_leftWin ).MinSize( 250, -1 );
224
225 wxSizer* mainSizer = GetSizer();
226
227 // Only fit the initial window size the first time KiCad is run.
228 if( mainSizer && config()->m_Window.state.size_x == 0 && config()->m_Window.state.size_y == 0 )
229 mainSizer->Fit( this );
230
231 if( ADVANCED_CFG::GetCfg().m_HideVersionFromTitle )
232 SetTitle( wxT( "KiCad" ) );
233 else
234 SetTitle( wxString( "KiCad " ) + GetMajorMinorVersion() );
235
236 // Do not let the messages window have initial focus
237 m_leftWin->SetFocus();
238
239 // Init for dropping files
242
243 // Gerber files
244 // Note that all gerber files are aliased as GerberFileExtension
248
249 // Eagle files import
250 m_acceptedExts.emplace( EagleSchematicFileExtension,
253
254 // Cadstar files import
255 m_acceptedExts.emplace( CadstarSchematicFileExtension,
258
259 DragAcceptFiles( true );
260
261 // Ensure the window is on top
262 Raise();
263}
constexpr EDA_IU_SCALE unityScale
Definition: base_units.h:112
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:106
@ icon_kicad_16
@ icon_kicad_nightly
@ icon_kicad_32
@ icon_kicad_nightly_32
@ icon_kicad_nightly_16
wxString GetMajorMinorVersion()
Get only the major and minor version in a string major.minor.
bool IsNightlyVersion()
Check if the build is meant to be nightly.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
The base frame for deriving all KiCad main window classes.
Specialization of the wxAuiPaneInfo class for KiCad panels.
static TOOL_ACTION viewDroppedGerbers
static TOOL_ACTION loadProject
static TOOL_ACTION importNonKicadProj
PROJECT_TREE_PANE Window to display the tree files.
#define _(s)
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define KICAD_MANAGER_FRAME_NAME
@ KICAD_MAIN_FRAME_T
Definition: frame_type.h:64
const std::string CadstarPcbFileExtension
const std::string GerberJobFileExtension
const std::string DrillFileExtension
const std::string EagleSchematicFileExtension
const std::string LegacyProjectFileExtension
const std::string ProjectFileExtension
const std::string EaglePcbFileExtension
const std::string CadstarSchematicFileExtension
const std::string GerberFileExtension
KIWAY Kiway
wxFont GetStatusFont(wxWindow *aWindow)
Definition: ui_common.cpp:132
std::vector< FAB_LAYER_COLOR > dummy

References _, CadstarPcbFileExtension, CadstarSchematicFileExtension, PCAD2KICAD::Center, config, DrillFileExtension, dummy, EaglePcbFileExtension, EagleSchematicFileExtension, GerberFileExtension, GerberJobFileExtension, ADVANCED_CFG::GetCfg(), GetMajorMinorVersion(), KIUI::GetStatusFont(), icon_kicad, icon_kicad_16, icon_kicad_32, icon_kicad_nightly, icon_kicad_nightly_16, icon_kicad_nightly_32, KICAD_MANAGER_ACTIONS::importNonKicadProj, IsNightlyVersion(), KiBitmap(), PCAD2KICAD::Left, LegacyProjectFileExtension, KICAD_MANAGER_ACTIONS::loadProject, ProjectFileExtension, and KICAD_MANAGER_ACTIONS::viewDroppedGerbers.