2011-10-13 19:56:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-03-03 14:53:47 +00:00
|
|
|
* Copyright (C) 2009-2015 Jean-Pierre Charras, jp.charras wanadoo.fr
|
2017-09-21 12:58:08 +00:00
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
|
2022-09-26 16:54:42 +00:00
|
|
|
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-13 19:56:32 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-09-01 12:54:34 +00:00
|
|
|
/**
|
2018-01-29 12:38:23 +00:00
|
|
|
* @file eda_base_frame.h
|
2011-09-01 12:54:34 +00:00
|
|
|
* @brief Base window classes and related definitions.
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2019-12-19 14:22:42 +00:00
|
|
|
#ifndef EDA_BASE_FRAME_H_
|
|
|
|
#define EDA_BASE_FRAME_H_
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2009-01-29 14:26:20 +00:00
|
|
|
#include <vector>
|
2022-09-14 22:28:09 +00:00
|
|
|
#include <map>
|
2009-01-29 14:26:20 +00:00
|
|
|
|
2009-11-02 22:24:55 +00:00
|
|
|
#include <wx/aui/aui.h>
|
2021-07-29 09:47:43 +00:00
|
|
|
#include <layer_ids.h>
|
2014-04-19 18:47:20 +00:00
|
|
|
#include <frame_type.h>
|
2019-06-09 21:57:23 +00:00
|
|
|
#include <hotkeys_basic.h>
|
2019-06-08 22:14:57 +00:00
|
|
|
#include <kiway_holder.h>
|
2020-04-19 00:51:49 +00:00
|
|
|
#include <tool/tools_holder.h>
|
2020-03-16 11:05:01 +00:00
|
|
|
#include <widgets/ui_common.h>
|
2021-08-01 20:51:08 +00:00
|
|
|
#include <widgets/infobar.h>
|
2020-07-13 11:21:40 +00:00
|
|
|
#include <undo_redo_container.h>
|
2022-09-19 16:09:59 +00:00
|
|
|
#include <units_provider.h>
|
2021-08-29 23:33:08 +00:00
|
|
|
#include <origin_transforms.h>
|
2007-10-10 18:01:14 +00:00
|
|
|
|
2013-11-15 09:28:31 +00:00
|
|
|
// Option for main frames
|
2009-01-29 14:26:20 +00:00
|
|
|
#define KICAD_DEFAULT_DRAWFRAME_STYLE wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-10-15 13:25:57 +00:00
|
|
|
|
2021-06-11 09:17:52 +00:00
|
|
|
#define VIEWER3D_FRAMENAME wxT( "Viewer3DFrameName" )
|
|
|
|
#define QUALIFIED_VIEWER3D_FRAMENAME( parent ) \
|
|
|
|
( wxString( VIEWER3D_FRAMENAME ) + wxT( ":" ) + parent->GetName() )
|
|
|
|
|
2019-06-14 10:55:54 +00:00
|
|
|
#define KICAD_MANAGER_FRAME_NAME wxT( "KicadFrame" )
|
|
|
|
|
2021-06-11 09:17:52 +00:00
|
|
|
|
2021-06-03 22:32:32 +00:00
|
|
|
class wxChoice;
|
2021-06-03 22:54:48 +00:00
|
|
|
class wxEvent;
|
2021-06-03 22:32:32 +00:00
|
|
|
class wxFileName;
|
2010-12-08 20:12:46 +00:00
|
|
|
class EDA_ITEM;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
class EDA_DRAW_PANEL_GAL;
|
2011-04-12 14:19:59 +00:00
|
|
|
class EDA_MSG_PANEL;
|
2007-06-05 12:10:51 +00:00
|
|
|
class BASE_SCREEN;
|
2020-01-12 18:40:50 +00:00
|
|
|
class PARAM_CFG;
|
2011-12-22 21:57:50 +00:00
|
|
|
class PAGE_INFO;
|
2009-08-29 10:20:48 +00:00
|
|
|
class PLOTTER;
|
2012-01-09 08:35:06 +00:00
|
|
|
class TITLE_BLOCK;
|
2013-01-12 17:32:24 +00:00
|
|
|
class MSG_PANEL_ITEM;
|
2015-04-30 08:46:02 +00:00
|
|
|
class TOOL_MANAGER;
|
|
|
|
class TOOL_DISPATCHER;
|
2017-02-21 12:42:08 +00:00
|
|
|
class ACTIONS;
|
2018-05-14 17:34:18 +00:00
|
|
|
class PAGED_DIALOG;
|
2018-07-19 19:15:40 +00:00
|
|
|
class DIALOG_EDIT_LIBRARY_TABLES;
|
2019-06-09 21:57:23 +00:00
|
|
|
class PANEL_HOTKEYS_EDITOR;
|
2019-11-23 16:54:48 +00:00
|
|
|
class FILE_HISTORY;
|
2020-01-13 01:44:19 +00:00
|
|
|
class SETTINGS_MANAGER;
|
2020-10-24 14:45:37 +00:00
|
|
|
class SEARCH_STACK;
|
2020-01-13 01:44:19 +00:00
|
|
|
class APP_SETTINGS_BASE;
|
|
|
|
struct WINDOW_SETTINGS;
|
2020-08-24 02:01:14 +00:00
|
|
|
struct WINDOW_STATE;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2020-07-13 11:21:40 +00:00
|
|
|
#define DEFAULT_MAX_UNDO_ITEMS 0
|
|
|
|
#define ABS_MAX_UNDO_ITEMS (INT_MAX / 2)
|
|
|
|
|
2020-07-27 22:42:23 +00:00
|
|
|
/// This is the handler functor for the update UI events
|
|
|
|
typedef std::function< void( wxUpdateUIEvent& ) > UIUpdateHandler;
|
|
|
|
|
2020-04-13 01:27:47 +00:00
|
|
|
wxDECLARE_EVENT( UNITS_CHANGED, wxCommandEvent );
|
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
|
2011-09-01 12:54:34 +00:00
|
|
|
/**
|
2019-05-13 18:33:30 +00:00
|
|
|
* The base frame for deriving all KiCad main window classes.
|
|
|
|
*
|
|
|
|
* This class is not intended to be used directly. It provides support for automatic calls
|
|
|
|
* to SaveSettings() function. SaveSettings() for a derived class can choose to do nothing,
|
|
|
|
* or rely on basic SaveSettings() support in this base class to do most of the work by
|
2020-12-18 14:04:03 +00:00
|
|
|
* calling it from the derived class's SaveSettings(). This class is not a #KIWAY_PLAYER
|
|
|
|
* because #KICAD_MANAGER_FRAME is derived from it and that class is not a player.
|
2011-09-01 12:54:34 +00:00
|
|
|
*/
|
2022-09-19 16:09:59 +00:00
|
|
|
class EDA_BASE_FRAME : public wxFrame, public TOOLS_HOLDER, public KIWAY_HOLDER,
|
|
|
|
public UNITS_PROVIDER
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-06-08 02:55:30 +00:00
|
|
|
/**
|
|
|
|
* Specifies whether we are interacting with the undo or redo stacks
|
|
|
|
*/
|
|
|
|
enum UNDO_REDO_LIST
|
|
|
|
{
|
|
|
|
UNDO_LIST,
|
|
|
|
REDO_LIST
|
|
|
|
};
|
|
|
|
|
2020-12-18 14:04:03 +00:00
|
|
|
EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType, const wxString& aTitle,
|
|
|
|
const wxPoint& aPos, const wxSize& aSize, long aStyle,
|
2022-09-19 16:09:59 +00:00
|
|
|
const wxString& aFrameName, KIWAY* aKiway, const EDA_IU_SCALE& aIuScale );
|
2021-03-15 21:56:13 +00:00
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
~EDA_BASE_FRAME();
|
2007-10-01 15:37:42 +00:00
|
|
|
|
2020-04-13 01:27:47 +00:00
|
|
|
void ChangeUserUnits( EDA_UNITS aUnits );
|
2019-06-08 22:14:57 +00:00
|
|
|
|
2020-06-23 10:21:16 +00:00
|
|
|
virtual void ToggleUserUnits() { }
|
2020-05-02 13:36:29 +00:00
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
/**
|
|
|
|
* Return a reference to the default ORIGIN_TRANSFORMS object
|
|
|
|
*/
|
|
|
|
virtual ORIGIN_TRANSFORMS& GetOriginTransforms() { return m_originTransforms; }
|
|
|
|
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
SETTINGS_MANAGER* GetSettingsManager() const { return m_settingsManager; }
|
|
|
|
|
2020-12-14 13:33:51 +00:00
|
|
|
virtual SEVERITY GetSeverity( int aErrorCode ) const { return RPT_SEVERITY_UNDEFINED; }
|
2020-03-16 11:05:01 +00:00
|
|
|
|
2011-10-13 19:56:32 +00:00
|
|
|
/**
|
2019-05-13 18:33:30 +00:00
|
|
|
* Override the default process event handler to implement the auto save feature.
|
2011-10-13 19:56:32 +00:00
|
|
|
*
|
2019-07-25 16:48:11 +00:00
|
|
|
* @warning If you override this function in a derived class, make sure you call down to
|
|
|
|
* this or the auto save feature will be disabled.
|
2011-10-13 19:56:32 +00:00
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
bool ProcessEvent( wxEvent& aEvent ) override;
|
2014-05-04 18:22:27 +00:00
|
|
|
|
2019-06-09 13:12:44 +00:00
|
|
|
/**
|
|
|
|
* Capture the key event before it is sent to the GUI.
|
|
|
|
*
|
2019-07-25 16:48:11 +00:00
|
|
|
* The basic frame does not capture this event. Editor frames should override this event
|
|
|
|
* function to capture and filter these keys when they are used as hotkeys, and skip it if
|
|
|
|
* the key is not used as hotkey (otherwise the key events will be not sent to menus).
|
2019-06-09 13:12:44 +00:00
|
|
|
*/
|
2021-05-03 20:07:16 +00:00
|
|
|
virtual void OnCharHook( wxKeyEvent& aKeyEvent );
|
2019-06-09 13:12:44 +00:00
|
|
|
|
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* The #TOOL_DISPATCHER needs these to work around some issues in wxWidgets where the menu
|
2020-03-24 01:01:23 +00:00
|
|
|
* events aren't captured by the menus themselves.
|
2019-06-09 13:12:44 +00:00
|
|
|
*/
|
2020-03-24 01:01:23 +00:00
|
|
|
void OnMenuEvent( wxMenuEvent& event );
|
2019-06-09 13:12:44 +00:00
|
|
|
|
2020-07-27 22:42:23 +00:00
|
|
|
/**
|
|
|
|
* Register a UI update handler for the control with ID @c aID
|
|
|
|
*
|
|
|
|
* @param aID is the control ID to register the handler for
|
|
|
|
* @param aConditions are the UI conditions to use for the control states
|
|
|
|
*/
|
2020-09-26 23:55:59 +00:00
|
|
|
virtual void RegisterUIUpdateHandler( int aID, const ACTION_CONDITIONS& aConditions ) override;
|
2020-07-27 22:42:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Unregister a UI handler for a given ID that was registered using @c RegisterUIUpdateHandler
|
|
|
|
*
|
|
|
|
* @param aID is the control ID to unregister the handler for
|
|
|
|
*/
|
2020-09-26 23:55:59 +00:00
|
|
|
virtual void UnregisterUIUpdateHandler( int aID ) override;
|
2020-07-27 22:42:23 +00:00
|
|
|
|
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Handle events generated when the UI is trying to figure out the current state of the
|
|
|
|
* UI controls related to #TOOL_ACTIONS (e.g. enabled, checked, etc.).
|
2020-07-27 22:42:23 +00:00
|
|
|
*
|
|
|
|
* @param aEvent is the wxUpdateUIEvent to be processed.
|
|
|
|
* @param aFrame is the frame to get the selection from
|
2020-12-18 14:04:03 +00:00
|
|
|
* @param aCond are the #UI SELECTION_CONDITIONS used
|
2020-07-27 22:42:23 +00:00
|
|
|
*/
|
|
|
|
static void HandleUpdateUIEvent( wxUpdateUIEvent& aEvent, EDA_BASE_FRAME* aFrame,
|
|
|
|
ACTION_CONDITIONS aCond );
|
|
|
|
|
2020-02-21 22:57:32 +00:00
|
|
|
virtual void OnMove( wxMoveEvent& aEvent )
|
|
|
|
{
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
|
|
|
|
2021-06-18 03:04:34 +00:00
|
|
|
virtual void OnSize( wxSizeEvent& aEvent );
|
|
|
|
|
2020-04-26 23:14:12 +00:00
|
|
|
void OnMaximize( wxMaximizeEvent& aEvent );
|
|
|
|
|
2021-12-02 20:19:15 +00:00
|
|
|
int GetAutoSaveInterval() const;
|
2011-10-13 19:56:32 +00:00
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
bool IsType( FRAME_T aType ) const { return m_ident == aType; }
|
2021-05-07 15:06:31 +00:00
|
|
|
FRAME_T GetFrameType() const { return m_ident; }
|
2011-10-13 19:56:32 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Return a #SEARCH_STACK pertaining to entire program.
|
2019-06-09 21:57:23 +00:00
|
|
|
*
|
|
|
|
* This is overloaded in #KICAD_MANAGER_FRAME
|
|
|
|
*/
|
|
|
|
virtual const SEARCH_STACK& sys_search();
|
2016-09-24 00:44:52 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
virtual wxString help_name();
|
2010-08-24 17:26:51 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
void OnKicadAbout( wxCommandEvent& event );
|
2021-05-29 16:09:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays the preferences and settings of all opened editors paged dialog
|
|
|
|
*/
|
2021-06-07 19:45:17 +00:00
|
|
|
void OnPreferences( wxCommandEvent& event );
|
2018-05-14 17:34:18 +00:00
|
|
|
|
2011-09-01 12:54:34 +00:00
|
|
|
void PrintMsg( const wxString& text );
|
2009-04-07 11:53:58 +00:00
|
|
|
|
2020-12-22 21:35:25 +00:00
|
|
|
void CreateInfoBar();
|
|
|
|
|
|
|
|
void FinishAUIInitialization();
|
|
|
|
|
2020-12-04 13:45:14 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* @return the #WX_INFOBAR that can be displayed on the top of the canvas.
|
2020-12-04 13:45:14 +00:00
|
|
|
*/
|
2020-06-27 11:57:40 +00:00
|
|
|
WX_INFOBAR* GetInfoBar() { return m_infoBar; }
|
|
|
|
|
2020-12-04 13:45:14 +00:00
|
|
|
/**
|
2021-01-04 17:51:50 +00:00
|
|
|
* Show the #WX_INFOBAR displayed on the top of the canvas with a message and an error
|
|
|
|
* icon on the left of the infobar, and an optional closebox to the right.
|
2020-12-18 14:04:03 +00:00
|
|
|
*
|
|
|
|
* The infobar will be closed after a timeout.
|
|
|
|
*
|
2021-01-04 17:51:50 +00:00
|
|
|
* @param aErrorMsg is the message to display.
|
2020-12-18 14:04:03 +00:00
|
|
|
* @param aShowCloseButton true to show a close button on the right of the #WX_INFOBAR.
|
2020-12-04 13:45:14 +00:00
|
|
|
*/
|
2021-08-01 20:51:08 +00:00
|
|
|
void ShowInfoBarError( const wxString& aErrorMsg, bool aShowCloseButton = false,
|
|
|
|
WX_INFOBAR::MESSAGE_TYPE aType = WX_INFOBAR::MESSAGE_TYPE::GENERIC );
|
2020-12-04 13:45:14 +00:00
|
|
|
|
2021-01-04 17:51:50 +00:00
|
|
|
/**
|
|
|
|
* Show the #WX_INFOBAR displayed on the top of the canvas with a message and an error
|
|
|
|
* icon on the left of the infobar, and an optional closebox to the right.
|
|
|
|
*
|
|
|
|
* The infobar will be closed after a timeout.
|
|
|
|
*
|
|
|
|
* This version accepts a callback which will be called when the infobar is dismissed
|
|
|
|
* (either as a result of user action or a timeout). This can be useful when the caller
|
|
|
|
* wants to make other decorations in the canvas to highlight the error.
|
|
|
|
*
|
|
|
|
* @param aErrorMsg is the message to display.
|
|
|
|
* @param aShowCloseButton true to show a close button on the right of the #WX_INFOBAR.
|
|
|
|
* @param aCallback a callback to be called when the infobar is dismissed.
|
|
|
|
*/
|
|
|
|
void ShowInfoBarError( const wxString& aErrorMsg, bool aShowCloseButton,
|
|
|
|
std::function<void(void)> aCallback );
|
|
|
|
|
2020-12-04 13:45:14 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Show the #WX_INFOBAR displayed on the top of the canvas with a message and a warning
|
|
|
|
* icon on the left of the infobar.
|
|
|
|
*
|
|
|
|
* The infobar will be closed after a timeout.
|
|
|
|
*
|
|
|
|
* @param aErrorMsg is the message to display.
|
|
|
|
* @param aShowCloseButton true to show a close button on the right of the #WX_INFOBAR.
|
2020-12-04 13:45:14 +00:00
|
|
|
*/
|
|
|
|
void ShowInfoBarWarning( const wxString& aWarningMsg, bool aShowCloseButton = false );
|
|
|
|
|
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Show the #WX_INFOBAR displayed on the top of the canvas with a message and an info
|
|
|
|
* icon on the left of the infobar.
|
|
|
|
*
|
|
|
|
* The infobar will be closed after a timeout.
|
|
|
|
*
|
|
|
|
* @param aErrorMsg is the message to display.
|
|
|
|
* @param aShowCloseButton true to show a close button on the right of the #WX_INFOBAR.
|
2020-12-04 13:45:14 +00:00
|
|
|
*/
|
|
|
|
void ShowInfoBarMsg( const wxString& aMsg, bool aShowCloseButton = false );
|
2020-08-31 13:19:57 +00:00
|
|
|
|
2018-05-14 17:34:18 +00:00
|
|
|
/**
|
2020-01-13 01:44:19 +00:00
|
|
|
* Returns the settings object used in SaveSettings(), and is overloaded in
|
2020-12-18 14:04:03 +00:00
|
|
|
* #KICAD_MANAGER_FRAME.
|
2019-05-14 12:39:34 +00:00
|
|
|
*/
|
2020-04-12 23:09:17 +00:00
|
|
|
virtual APP_SETTINGS_BASE* config() const;
|
2019-05-14 12:39:34 +00:00
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
void LoadWindowState( const wxString& aFileName );
|
2020-01-13 01:44:19 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Load window settings from the given settings object.
|
|
|
|
*
|
|
|
|
* Normally called by #LoadSettings() unless the window in question is a child window
|
|
|
|
* that* stores its settings somewhere other than #APP_SETTINGS_BASE::m_Window.
|
2020-01-13 01:44:19 +00:00
|
|
|
*/
|
2020-08-24 02:01:14 +00:00
|
|
|
void LoadWindowSettings( const WINDOW_SETTINGS* aCfg );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Save window settings to the given settings object.
|
|
|
|
*
|
|
|
|
* Normally called by #SaveSettings unless the window in question is a child window that
|
|
|
|
* stores its settings somewhere other than #APP_SETTINGS_BASE::m_Window.
|
2020-01-13 01:44:19 +00:00
|
|
|
*/
|
|
|
|
void SaveWindowSettings( WINDOW_SETTINGS* aCfg );
|
|
|
|
|
2011-10-13 19:56:32 +00:00
|
|
|
/**
|
2019-05-13 18:33:30 +00:00
|
|
|
* Load common frame parameters from a configuration file.
|
2011-10-13 19:56:32 +00:00
|
|
|
*
|
2020-12-18 14:04:03 +00:00
|
|
|
* Don't forget to call the base method or your frames won't remember their positions
|
|
|
|
* and sizes.
|
2011-10-13 19:56:32 +00:00
|
|
|
*/
|
2020-01-13 01:44:19 +00:00
|
|
|
virtual void LoadSettings( APP_SETTINGS_BASE* aCfg );
|
2011-10-13 19:56:32 +00:00
|
|
|
|
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Save common frame parameters to a configuration data file.
|
2011-10-13 19:56:32 +00:00
|
|
|
*
|
2020-12-18 14:04:03 +00:00
|
|
|
* Don't forget to call the base class's SaveSettings() from your derived
|
|
|
|
* #SaveSettings() otherwise the frames won't remember their positions and sizes.
|
2011-10-13 19:56:32 +00:00
|
|
|
*/
|
2020-01-13 01:44:19 +00:00
|
|
|
virtual void SaveSettings( APP_SETTINGS_BASE* aCfg );
|
|
|
|
|
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Return a pointer to the window settings for this frame.
|
|
|
|
*
|
2020-01-13 01:44:19 +00:00
|
|
|
* By default, points to aCfg->m_Window for top-level frames.
|
2020-12-18 14:04:03 +00:00
|
|
|
*
|
2020-01-13 01:44:19 +00:00
|
|
|
* @param aCfg is this frame's config object
|
|
|
|
*/
|
|
|
|
virtual WINDOW_SETTINGS* GetWindowSettings( APP_SETTINGS_BASE* aCfg );
|
2009-04-07 11:53:58 +00:00
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Load frame state info from a configuration file
|
|
|
|
*/
|
2020-08-24 02:01:14 +00:00
|
|
|
virtual void LoadWindowState( const WINDOW_STATE& aState );
|
|
|
|
|
2015-08-31 06:43:33 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Get the configuration base name.
|
|
|
|
*
|
|
|
|
* This is usually the name of the frame set by CTOR, except for frames shown in
|
|
|
|
* multiple modes in which case the m_configName must be set to the base name so
|
|
|
|
* that a single configuration can be used.
|
|
|
|
*
|
2019-11-23 16:54:48 +00:00
|
|
|
* @return a base name prefix used in Load/Save settings to build the full name of keys
|
2020-12-18 14:04:03 +00:00
|
|
|
* used in configuration.
|
2015-08-31 06:43:33 +00:00
|
|
|
*/
|
2020-03-24 01:01:23 +00:00
|
|
|
wxString ConfigBaseName() override
|
2015-08-31 06:43:33 +00:00
|
|
|
{
|
2019-06-08 22:14:57 +00:00
|
|
|
wxString baseCfgName = m_configName.IsEmpty() ? GetName() : m_configName;
|
2015-08-31 06:43:33 +00:00
|
|
|
return baseCfgName;
|
|
|
|
}
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
/**
|
2019-05-13 18:33:30 +00:00
|
|
|
* Save changes to the project settings to the project (.pro) file.
|
|
|
|
*
|
2013-07-19 18:27:22 +00:00
|
|
|
* The method is virtual so you can override it to call the suitable save method.
|
2020-12-18 14:04:03 +00:00
|
|
|
* The base method does nothing.
|
|
|
|
*
|
|
|
|
* @param aAskForSave true to open a dialog before saving the settings.
|
2013-07-19 18:27:22 +00:00
|
|
|
*/
|
2020-02-28 00:05:40 +00:00
|
|
|
virtual void SaveProjectSettings() {};
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2019-06-10 15:58:32 +00:00
|
|
|
* Prompt the user for a hotkey file to read, and read it.
|
2019-05-13 18:33:30 +00:00
|
|
|
*
|
2020-12-18 14:04:03 +00:00
|
|
|
* @param aActionMap current hotkey map (over which the imported hotkeys will be applied).
|
|
|
|
* @param aDefaultShortname a default short name (extension not needed) like
|
|
|
|
* Eeschema, KiCad...
|
2010-08-28 18:02:24 +00:00
|
|
|
*/
|
2019-06-10 15:58:32 +00:00
|
|
|
void ImportHotkeyConfigFromFile( std::map<std::string, TOOL_ACTION*> aActionMap,
|
2015-03-02 17:29:18 +00:00
|
|
|
const wxString& aDefaultShortname );
|
2010-08-28 18:02:24 +00:00
|
|
|
|
2011-03-17 19:14:45 +00:00
|
|
|
/**
|
2019-05-13 18:33:30 +00:00
|
|
|
* Fetches the file name from the file history list.
|
|
|
|
*
|
|
|
|
* This removes the selected file, if this file does not exist. The menu is also updated,
|
2020-12-18 14:04:03 +00:00
|
|
|
* if #FILE_HISTORY::UseMenu was called at initialization time.
|
2019-05-13 18:33:30 +00:00
|
|
|
*
|
2011-03-25 19:16:05 +00:00
|
|
|
* @param cmdId The command ID associated with the \a aFileHistory object.
|
|
|
|
* @param type Please document me!
|
2019-11-23 16:54:48 +00:00
|
|
|
* @param aFileHistory The FILE_HISTORY in use. If null, the main application file
|
2011-03-25 19:16:05 +00:00
|
|
|
* history is used
|
2011-03-17 19:14:45 +00:00
|
|
|
* @return a wxString containing the selected filename
|
|
|
|
*/
|
2011-09-01 12:54:34 +00:00
|
|
|
wxString GetFileFromHistory( int cmdId, const wxString& type,
|
2020-05-16 21:47:01 +00:00
|
|
|
FILE_HISTORY* aFileHistory = nullptr );
|
2011-03-17 19:14:45 +00:00
|
|
|
|
2020-02-25 15:46:56 +00:00
|
|
|
/**
|
|
|
|
* Removes all files from the file history.
|
|
|
|
*
|
|
|
|
* @param aFileHistory The FILE_HISTORY in use. If null, the main application file
|
|
|
|
* history is used
|
|
|
|
*/
|
2020-05-16 21:47:01 +00:00
|
|
|
void ClearFileHistory( FILE_HISTORY* aFileHistory = nullptr );
|
2020-02-25 15:46:56 +00:00
|
|
|
|
2011-03-17 19:14:45 +00:00
|
|
|
/**
|
2019-05-13 18:33:30 +00:00
|
|
|
* Update the list of recently opened files.
|
|
|
|
*
|
2019-11-23 16:54:48 +00:00
|
|
|
* The menu is also updated, if FILE_HISTORY::UseMenu was called at init time.
|
2019-05-13 18:33:30 +00:00
|
|
|
*
|
2011-03-25 19:16:05 +00:00
|
|
|
* @param FullFileName The full file name including the path.
|
2020-12-18 14:04:03 +00:00
|
|
|
* @param aFileHistory The FILE_HISTORY in use. If NULL, the main application file
|
|
|
|
* history is used.
|
2011-03-17 19:14:45 +00:00
|
|
|
*/
|
2020-05-16 21:47:01 +00:00
|
|
|
void UpdateFileHistory( const wxString& FullFileName, FILE_HISTORY* aFileHistory = nullptr );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the frame's main file history.
|
|
|
|
*
|
|
|
|
* @return the main file history
|
|
|
|
*/
|
|
|
|
FILE_HISTORY& GetFileHistory()
|
|
|
|
{
|
|
|
|
return *m_fileHistory;
|
|
|
|
}
|
2011-03-17 19:14:45 +00:00
|
|
|
|
2015-09-25 19:38:09 +00:00
|
|
|
void SetMruPath( const wxString& aPath ) { m_mruPath = aPath; }
|
|
|
|
|
|
|
|
wxString GetMruPath() const { return m_mruPath; }
|
|
|
|
|
2020-05-16 23:08:01 +00:00
|
|
|
/**
|
|
|
|
* Get the full filename + path of the currently opened file in the frame.
|
2020-12-18 14:04:03 +00:00
|
|
|
*
|
2020-05-16 23:08:01 +00:00
|
|
|
* If no file is open, an empty string is returned.
|
|
|
|
*
|
|
|
|
* @return the filename and full path to the open file
|
|
|
|
*/
|
|
|
|
virtual wxString GetCurrentFileName() const { return wxEmptyString; }
|
|
|
|
|
2011-04-17 13:54:17 +00:00
|
|
|
/**
|
2019-05-13 18:33:30 +00:00
|
|
|
* Recreates the menu bar.
|
|
|
|
*
|
2021-03-26 15:50:08 +00:00
|
|
|
* Needed when the language or icons are changed
|
2011-04-17 13:54:17 +00:00
|
|
|
*/
|
2009-04-07 11:53:58 +00:00
|
|
|
virtual void ReCreateMenuBar();
|
2011-08-18 19:25:12 +00:00
|
|
|
|
2019-05-18 10:27:36 +00:00
|
|
|
/**
|
|
|
|
* Adds the standard KiCad help menu to the menubar.
|
|
|
|
*/
|
|
|
|
void AddStandardHelpMenu( wxMenuBar* aMenuBar );
|
|
|
|
|
2011-08-18 19:25:12 +00:00
|
|
|
/**
|
2019-05-13 18:33:30 +00:00
|
|
|
* Checks if \a aFileName can be written.
|
2020-12-18 14:04:03 +00:00
|
|
|
*
|
2019-07-25 16:48:11 +00:00
|
|
|
* The function performs a number of tests on \a aFileName to verify that it can be saved.
|
|
|
|
* If \a aFileName defines a path with no file name, them the path is tested for user write
|
|
|
|
* permission. If \a aFileName defines a file name that does not exist in the path, the
|
|
|
|
* path is tested for user write permission. If \a aFileName defines a file that already
|
|
|
|
* exits, the file name is tested for user write permissions.
|
2020-12-18 14:04:03 +00:00
|
|
|
*>
|
2019-07-25 16:48:11 +00:00
|
|
|
* @note The file name path must be set or an assertion will be raised on debug builds and
|
|
|
|
* return false on release builds.
|
2011-08-18 19:25:12 +00:00
|
|
|
* @param aFileName The full path and/or file name of the file to test.
|
2021-11-17 02:02:23 +00:00
|
|
|
* @param aVerbose If true will show an error dialog if the file is not writable
|
2011-08-18 19:25:12 +00:00
|
|
|
* @return False if \a aFileName cannot be written.
|
|
|
|
*/
|
2021-11-17 02:02:23 +00:00
|
|
|
bool IsWritable( const wxFileName& aFileName, bool aVerbose = true );
|
2011-10-15 13:25:57 +00:00
|
|
|
|
|
|
|
/**
|
2019-07-25 16:48:11 +00:00
|
|
|
* Check if an auto save file exists for \a aFileName and takes the appropriate action
|
|
|
|
* depending on the user input.
|
2020-12-18 14:04:03 +00:00
|
|
|
*
|
2019-07-25 16:48:11 +00:00
|
|
|
* If an auto save file exists for \a aFileName, the user is prompted if they wish to
|
|
|
|
* replace file \a aFileName with the auto saved file. If the user chooses to replace the
|
|
|
|
* file, the backup file of \a aFileName is removed, \a aFileName is renamed to the backup
|
|
|
|
* file name, and the auto save file is renamed to \a aFileName. If user chooses to keep
|
|
|
|
* the existing version of \a aFileName, the auto save file is removed.
|
2020-12-18 14:04:03 +00:00
|
|
|
*
|
2011-10-15 13:25:57 +00:00
|
|
|
* @param aFileName A wxFileName object containing the file name to check.
|
|
|
|
*/
|
2021-10-13 18:48:28 +00:00
|
|
|
virtual void CheckForAutoSaveFile( const wxFileName& aFileName );
|
2012-09-11 19:03:21 +00:00
|
|
|
|
2019-06-09 12:18:11 +00:00
|
|
|
/**
|
|
|
|
* Update the status bar information.
|
|
|
|
*
|
2019-11-23 16:54:48 +00:00
|
|
|
* The status bar can draw itself. This is not a drawing function per se, but rather
|
|
|
|
* updates lines of text held by the components within the status bar which is owned
|
2019-06-09 12:18:11 +00:00
|
|
|
* by the wxFrame.
|
|
|
|
*/
|
|
|
|
virtual void UpdateStatusBar() { }
|
|
|
|
|
2012-09-11 19:03:21 +00:00
|
|
|
/**
|
2019-05-13 18:33:30 +00:00
|
|
|
* Redraw the menus and what not in current language.
|
2012-09-11 19:03:21 +00:00
|
|
|
*/
|
2021-07-23 19:15:55 +00:00
|
|
|
void ShowChangedLanguage() override;
|
2017-01-17 05:57:53 +00:00
|
|
|
|
2017-03-03 13:18:07 +00:00
|
|
|
/**
|
2018-05-14 17:34:18 +00:00
|
|
|
* Notification event that some of the common (suite-wide) settings have changed.
|
|
|
|
* Update menus, toolbars, local variables, etc.
|
2017-03-02 13:46:18 +00:00
|
|
|
*/
|
2020-07-17 20:04:14 +00:00
|
|
|
void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;
|
2019-05-13 18:33:30 +00:00
|
|
|
|
2021-03-22 04:50:42 +00:00
|
|
|
/**
|
|
|
|
* Process light/dark theme change.
|
|
|
|
*/
|
|
|
|
virtual void ThemeChanged();
|
|
|
|
|
2020-08-09 18:49:26 +00:00
|
|
|
/**
|
|
|
|
* Notification event that the project has changed.
|
|
|
|
*/
|
|
|
|
virtual void ProjectChanged() {}
|
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
const wxString& GetAboutTitle() const { return m_aboutTitle; }
|
2019-12-19 14:11:11 +00:00
|
|
|
|
2019-12-19 15:34:01 +00:00
|
|
|
/**
|
|
|
|
* Get if the contents of the frame have been modified since the last save.
|
|
|
|
*
|
|
|
|
* @return true if the contents of the frame have not been saved
|
|
|
|
*/
|
2021-05-27 23:07:48 +00:00
|
|
|
virtual bool IsContentModified() const;
|
2020-05-06 13:51:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the undecorated window size that can be used for restoring the window size.
|
|
|
|
*
|
|
|
|
* This is needed for GTK, since the normal wxWidgets GetSize() call will return
|
|
|
|
* a window size that includes the window decorations added by the window manager.
|
|
|
|
*
|
|
|
|
* @return the undecorated window size
|
|
|
|
*/
|
|
|
|
wxSize GetWindowSize();
|
2020-07-13 11:21:40 +00:00
|
|
|
|
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Remove the \a aItemCount of old commands from \a aList and delete commands, pickers
|
|
|
|
* and picked items if needed.
|
|
|
|
*
|
|
|
|
* Because picked items must be deleted only if they are not in use, this is a virtual
|
|
|
|
* pure function that must be created for #SCH_SCREEN and #PCB_SCREEN. Commands are
|
|
|
|
* deleted from the older to the last.
|
|
|
|
*
|
|
|
|
* @param aList = the #UNDO_REDO_CONTAINER of commands.
|
|
|
|
* @param aItemCount number of old commands to delete. -1 to remove all old commands
|
|
|
|
* this will empty the list of commands.
|
2020-07-13 11:21:40 +00:00
|
|
|
*/
|
2020-07-13 13:50:35 +00:00
|
|
|
virtual void ClearUndoORRedoList( UNDO_REDO_LIST aList, int aItemCount = -1 )
|
2020-07-13 11:21:40 +00:00
|
|
|
{ }
|
|
|
|
|
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Clear the undo and redo list using #ClearUndoORRedoList()
|
|
|
|
*
|
|
|
|
* Picked items are deleted by ClearUndoORRedoList() according to their status.
|
2020-07-13 11:21:40 +00:00
|
|
|
*/
|
|
|
|
virtual void ClearUndoRedoList();
|
|
|
|
|
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Add a command to undo in the undo list.
|
|
|
|
*
|
|
|
|
* Delete the very old commands when the max count of undo commands is reached.
|
2020-07-13 11:21:40 +00:00
|
|
|
*/
|
|
|
|
virtual void PushCommandToUndoList( PICKED_ITEMS_LIST* aItem );
|
|
|
|
|
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Add a command to redo in the redo list.
|
|
|
|
*
|
|
|
|
* Delete the very old commands when the max count of redo commands is reached.
|
2020-07-13 11:21:40 +00:00
|
|
|
*/
|
|
|
|
virtual void PushCommandToRedoList( PICKED_ITEMS_LIST* aItem );
|
|
|
|
|
2020-12-18 14:04:03 +00:00
|
|
|
/**
|
|
|
|
* Return the last command to undo and remove it from list, nothing is deleted.
|
2020-07-13 11:21:40 +00:00
|
|
|
*/
|
|
|
|
virtual PICKED_ITEMS_LIST* PopCommandFromUndoList();
|
|
|
|
|
2020-12-18 14:04:03 +00:00
|
|
|
/**
|
|
|
|
* Return the last command to undo and remove it from list, nothing is deleted.
|
2020-07-13 11:21:40 +00:00
|
|
|
*/
|
|
|
|
virtual PICKED_ITEMS_LIST* PopCommandFromRedoList();
|
|
|
|
|
2020-07-29 23:50:25 +00:00
|
|
|
virtual int GetUndoCommandCount() const { return m_undoList.m_CommandsList.size(); }
|
|
|
|
virtual int GetRedoCommandCount() const { return m_redoList.m_CommandsList.size(); }
|
2020-07-13 11:21:40 +00:00
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
int GetMaxUndoItems() const { return m_undoRedoCountMax; }
|
2020-08-24 02:01:14 +00:00
|
|
|
|
2022-10-10 13:03:10 +00:00
|
|
|
/**
|
|
|
|
* Must be called after a model change in order to set the "modify" flag and do other
|
|
|
|
* frame-specific processing.
|
|
|
|
*/
|
|
|
|
virtual void OnModify();
|
|
|
|
|
2020-08-24 02:10:05 +00:00
|
|
|
bool NonUserClose( bool aForce )
|
|
|
|
{
|
|
|
|
m_isNonUserClose = true;
|
|
|
|
return Close( aForce );
|
|
|
|
}
|
2020-12-18 14:04:03 +00:00
|
|
|
|
2021-03-26 15:50:08 +00:00
|
|
|
/**
|
|
|
|
* Update the UI in response to a change in the system colors.
|
|
|
|
*/
|
|
|
|
virtual void HandleSystemColorChange();
|
|
|
|
|
2020-12-18 14:04:03 +00:00
|
|
|
protected:
|
|
|
|
///< Default style flags used for wxAUI toolbars.
|
|
|
|
static constexpr int KICAD_AUI_TB_STYLE = wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_PLAIN_BACKGROUND;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the string to prepend to a file name for automatic save.
|
|
|
|
*/
|
|
|
|
static wxString GetAutoSaveFilePrefix()
|
|
|
|
{
|
|
|
|
return wxT( "_autosave-" );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle the auto save timer event.
|
|
|
|
*/
|
|
|
|
void onAutoSaveTimer( wxTimerEvent& aEvent );
|
|
|
|
|
2022-03-31 19:03:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle a window iconize event.
|
2022-09-14 22:28:09 +00:00
|
|
|
*
|
2022-03-31 19:03:41 +00:00
|
|
|
* @param aEvent is the data for the event.
|
|
|
|
*/
|
|
|
|
virtual void handleIconizeEvent( wxIconizeEvent& aEvent ) {}
|
|
|
|
void onIconize( wxIconizeEvent& aEvent );
|
|
|
|
|
2020-12-18 14:04:03 +00:00
|
|
|
/**
|
|
|
|
* Return the auto save status of the application.
|
|
|
|
*
|
|
|
|
* Override this function if your derived frame supports automatic file saving.
|
|
|
|
*/
|
2022-10-10 13:03:10 +00:00
|
|
|
virtual bool isAutoSaveRequired() const { return m_autoSaveRequired; }
|
2020-12-18 14:04:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This should be overridden by the derived class to handle the auto save feature.
|
|
|
|
*
|
|
|
|
* @return true if the auto save was successful otherwise false.
|
|
|
|
*/
|
|
|
|
virtual bool doAutoSave();
|
|
|
|
|
|
|
|
virtual bool canCloseWindow( wxCloseEvent& aCloseEvent ) { return true; }
|
|
|
|
virtual void doCloseWindow() { }
|
|
|
|
|
2021-03-26 15:50:08 +00:00
|
|
|
void onSystemColorChange( wxSysColourChangedEvent& aEvent );
|
|
|
|
|
2020-12-18 14:04:03 +00:00
|
|
|
/**
|
|
|
|
* Called when when the units setting has changed to allow for any derived classes
|
|
|
|
* to handle refreshing and controls that have units based measurements in them.
|
|
|
|
*
|
|
|
|
* The default version only updates the status bar. Don't forget to call the default
|
|
|
|
* in your derived class or the status bar will not get updated properly.
|
|
|
|
*/
|
|
|
|
virtual void unitsChangeRefresh() { }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Setup the UI conditions for the various actions and their controls in this frame.
|
|
|
|
*/
|
|
|
|
virtual void setupUIConditions();
|
|
|
|
|
2021-02-09 19:41:36 +00:00
|
|
|
/**
|
|
|
|
* Sets the common key-pair for exiting the application (Ctrl-Q) and ties it
|
|
|
|
* to the wxID_EXIT event id.
|
|
|
|
*
|
|
|
|
* This is useful in sub-applications to pass the event up to a non-owning window.
|
|
|
|
*/
|
|
|
|
void initExitKey();
|
|
|
|
|
2021-06-18 03:04:34 +00:00
|
|
|
void ensureWindowIsOnScreen();
|
|
|
|
|
2022-09-14 22:28:09 +00:00
|
|
|
/**
|
|
|
|
* Handles event fired when a file is dropped to the window.
|
|
|
|
* In this base class, stores the path of files accepted.
|
|
|
|
* Calls DoWithAcceptedFiles() to execute actions on files.
|
|
|
|
*/
|
|
|
|
virtual void OnDropFiles( wxDropFilesEvent& aEvent );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute action on accepted dropped file.
|
|
|
|
* Called in OnDropFiles and should be populated with
|
|
|
|
* the action to execute in inherited classes.
|
|
|
|
*/
|
|
|
|
virtual void DoWithAcceptedFiles();
|
|
|
|
std::vector<wxFileName> m_AcceptedFiles;
|
|
|
|
|
2020-12-18 14:04:03 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* (with its unexpected name so it does not collide with the real OnWindowClose()
|
|
|
|
* function provided in derived classes) is called just before a window
|
|
|
|
* closing, and is used to call a derivation specific SaveSettings().
|
|
|
|
*
|
|
|
|
* #SaveSettings() is called for all derived wxFrames in this base class overload.
|
|
|
|
* Calling it from a destructor is deprecated since the wxFrame's position is not
|
|
|
|
* available in the destructor on linux. In other words, you should not need to
|
|
|
|
* call #SaveSettings() anywhere, except in this one function found only in this class.
|
|
|
|
*/
|
|
|
|
void windowClosing( wxCloseEvent& event );
|
|
|
|
|
2021-03-15 21:56:13 +00:00
|
|
|
/**
|
|
|
|
* Collect common initialization functions used in all CTORs
|
|
|
|
*/
|
|
|
|
void commonInit( FRAME_T aFrameType );
|
|
|
|
|
2020-12-18 14:04:03 +00:00
|
|
|
wxWindow* findQuasiModalDialog();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if the frame is shown in our modal mode and false if the frame is
|
|
|
|
* shown as an usual frame.
|
|
|
|
*
|
|
|
|
* In modal mode, the caller that created the frame is responsible to Destroy()
|
|
|
|
* this frame after closing.
|
|
|
|
*/
|
|
|
|
virtual bool IsModal() const { return false; }
|
|
|
|
|
2021-09-06 02:22:27 +00:00
|
|
|
#ifdef _WIN32
|
2021-09-06 02:12:59 +00:00
|
|
|
/**
|
|
|
|
* Windows specific override of the wxWidgets message handler for a window
|
|
|
|
*/
|
|
|
|
WXLRESULT MSWWindowProc( WXUINT message, WXWPARAM wParam, WXLPARAM lParam ) override;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
protected:
|
2020-12-18 14:04:03 +00:00
|
|
|
FRAME_T m_ident; // Id Type (pcb, schematic, library..)
|
|
|
|
wxPoint m_framePos;
|
|
|
|
wxSize m_frameSize;
|
|
|
|
bool m_maximizeByDefault;
|
2021-06-18 03:04:34 +00:00
|
|
|
int m_displayIndex;
|
2020-12-18 14:04:03 +00:00
|
|
|
|
|
|
|
// These contain the frame size and position for when it is not maximized
|
|
|
|
wxPoint m_normalFramePos;
|
|
|
|
wxSize m_normalFrameSize;
|
|
|
|
|
|
|
|
wxString m_aboutTitle; // Name of program displayed in About.
|
|
|
|
|
|
|
|
wxAuiManager m_auimgr;
|
|
|
|
wxString m_perspective; // wxAuiManager perspective.
|
|
|
|
|
|
|
|
WX_INFOBAR* m_infoBar; // Infobar for the frame
|
|
|
|
|
|
|
|
wxString m_configName; // Prefix used to identify some params (frame size...)
|
|
|
|
// and to name some config files (legacy hotkey files)
|
|
|
|
|
|
|
|
SETTINGS_MANAGER* m_settingsManager;
|
|
|
|
|
|
|
|
FILE_HISTORY* m_fileHistory; // The frame's recently opened file list
|
|
|
|
|
2021-12-02 20:19:15 +00:00
|
|
|
bool m_supportsAutoSave;
|
2022-10-10 11:04:19 +00:00
|
|
|
bool m_autoSavePending;
|
2022-10-10 13:03:10 +00:00
|
|
|
bool m_autoSaveRequired;
|
2020-12-18 14:04:03 +00:00
|
|
|
wxTimer* m_autoSaveTimer;
|
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
int m_undoRedoCountMax; // undo/Redo command Max depth
|
2020-12-18 14:04:03 +00:00
|
|
|
|
|
|
|
UNDO_REDO_CONTAINER m_undoList; // Objects list for the undo command (old data)
|
|
|
|
UNDO_REDO_CONTAINER m_redoList; // Objects list for the redo command (old data)
|
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
wxString m_mruPath; // Most recently used path.
|
2020-12-18 14:04:03 +00:00
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
ORIGIN_TRANSFORMS m_originTransforms; // Default display origin transforms object.
|
2020-12-18 14:04:03 +00:00
|
|
|
|
|
|
|
///< Map containing the UI update handlers registered with wx for each action.
|
|
|
|
std::map<int, UIUpdateHandler> m_uiUpdateMap;
|
|
|
|
|
|
|
|
///< Set by the close window event handler after frames are asked if they can close.
|
|
|
|
///< Allows other functions when called to know our state is cleanup.
|
|
|
|
bool m_isClosing;
|
|
|
|
|
|
|
|
///< Set by #NonUserClose() to indicate that the user did not request the current close.
|
|
|
|
bool m_isNonUserClose;
|
2022-09-14 22:28:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Associates files extensions with action to execute.
|
|
|
|
*/
|
|
|
|
std::map<const wxString, TOOL_ACTION*> m_acceptedExts;
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-09-15 18:25:44 +00:00
|
|
|
/**
|
2011-09-30 18:15:37 +00:00
|
|
|
* Specialization of the wxAuiPaneInfo class for KiCad panels.
|
2011-09-15 18:25:44 +00:00
|
|
|
*
|
|
|
|
* Documentation for wxAui is poor at this time. The following notes spring from errors made in
|
2011-09-30 18:15:37 +00:00
|
|
|
* previous KiCad implementations:
|
2011-09-15 18:25:44 +00:00
|
|
|
*
|
|
|
|
* wxAuiPaneInfo.ToolbarPane() and .Defaults() are used to clear and then prepare the objects so
|
|
|
|
* only use them once at the beginning of configuration..
|
|
|
|
*
|
|
|
|
* Panels are organized in layers, from 0 (close to the center) and increasing outward. Note
|
|
|
|
* that for ToolbarPanes, layer 0 considered a special default value, and ToolbarPanes on
|
|
|
|
* layer 0 are pushed to layer 10 automatically. Use Layer 1 for the inner layer as a work-
|
|
|
|
* around.
|
|
|
|
*
|
|
|
|
* Each panel has rows, starting at 0. Each row has positions starting at 0. Each item in a panel
|
Fix source comment/doc typos (follow-up)
Found via `codespell -q 3 -S *.po,./thirdparty -L aactual,acount,aline,alocation,alog,anormal,anumber,aother,apoints,aparent,aray,dout,einstance,modul,ot,overide,serie,te,,tesselate,tesselator,tht`
2021-07-03 22:37:31 +00:00
|
|
|
* can have its row and position set.
|
2011-09-15 18:25:44 +00:00
|
|
|
*
|
2011-11-07 19:04:24 +00:00
|
|
|
* Eventually panels will be movable. Each initialization function sets up the panel for this,
|
2011-09-15 18:25:44 +00:00
|
|
|
* then after a //==// break has additional calls to anchor toolbars in a way that matches
|
|
|
|
* present functionality.
|
|
|
|
*/
|
2018-08-11 16:04:46 +00:00
|
|
|
class EDA_PANE : public wxAuiPaneInfo
|
2011-09-15 18:25:44 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-08-11 16:04:46 +00:00
|
|
|
EDA_PANE()
|
|
|
|
{
|
|
|
|
Gripper( false );
|
|
|
|
CloseButton( false );
|
|
|
|
PaneBorder( false );
|
|
|
|
}
|
2011-09-15 18:25:44 +00:00
|
|
|
|
|
|
|
/**
|
2018-08-11 16:04:46 +00:00
|
|
|
* Turn *this to a horizontal toolbar for KiCad.
|
2011-09-15 18:25:44 +00:00
|
|
|
*/
|
2018-08-11 16:04:46 +00:00
|
|
|
EDA_PANE& HToolbar()
|
2011-09-15 18:25:44 +00:00
|
|
|
{
|
2018-08-11 16:04:46 +00:00
|
|
|
SetFlag( optionToolbar, true );
|
|
|
|
CaptionVisible( false );
|
|
|
|
TopDockable().BottomDockable();
|
2011-09-15 18:25:44 +00:00
|
|
|
DockFixed( true );
|
|
|
|
Movable( false );
|
2018-08-11 16:04:46 +00:00
|
|
|
Resizable( true ); // expand to fit available space
|
2011-09-15 18:25:44 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-08-11 16:04:46 +00:00
|
|
|
* Turn *this into a vertical toolbar for KiCad.
|
2011-09-15 18:25:44 +00:00
|
|
|
*/
|
2018-08-11 16:04:46 +00:00
|
|
|
EDA_PANE& VToolbar()
|
2011-09-15 18:25:44 +00:00
|
|
|
{
|
2018-08-11 16:04:46 +00:00
|
|
|
SetFlag( optionToolbar, true );
|
|
|
|
CaptionVisible( false );
|
|
|
|
LeftDockable().RightDockable();
|
2011-09-15 18:25:44 +00:00
|
|
|
DockFixed( true );
|
|
|
|
Movable( false );
|
2018-08-11 16:04:46 +00:00
|
|
|
Resizable( true ); // expand to fit available space
|
2011-09-15 18:25:44 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-08-11 16:04:46 +00:00
|
|
|
* Turn *this into a captioned palette suitable for a symbol tree, layers manager, etc.
|
2011-09-15 18:25:44 +00:00
|
|
|
*/
|
2018-08-11 16:04:46 +00:00
|
|
|
EDA_PANE& Palette()
|
2011-09-15 18:25:44 +00:00
|
|
|
{
|
2018-08-11 16:04:46 +00:00
|
|
|
CaptionVisible( true );
|
|
|
|
PaneBorder( true );
|
2011-09-15 18:25:44 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-08-11 16:04:46 +00:00
|
|
|
* Turn *this into an undecorated pane suitable for a drawing canvas.
|
2011-09-15 18:25:44 +00:00
|
|
|
*/
|
2018-08-11 16:04:46 +00:00
|
|
|
EDA_PANE& Canvas()
|
2011-09-15 18:25:44 +00:00
|
|
|
{
|
2018-08-11 16:04:46 +00:00
|
|
|
CaptionVisible( false );
|
|
|
|
Layer( 0 );
|
|
|
|
PaneBorder( true );
|
|
|
|
Resizable( true ); // expand to fit available space
|
2011-09-15 18:25:44 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-08-11 16:04:46 +00:00
|
|
|
* Turn *this into a messages pane for KiCad.
|
2011-09-15 18:25:44 +00:00
|
|
|
*/
|
2018-08-11 16:04:46 +00:00
|
|
|
EDA_PANE& Messages()
|
2011-09-15 18:25:44 +00:00
|
|
|
{
|
|
|
|
CaptionVisible( false );
|
2018-08-11 16:04:46 +00:00
|
|
|
BottomDockable( true );
|
|
|
|
DockFixed( true );
|
|
|
|
Movable( false );
|
|
|
|
Resizable( true ); // expand to fit available space
|
2011-09-15 18:25:44 +00:00
|
|
|
return *this;
|
|
|
|
}
|
2020-05-18 23:44:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Turn *this into a infobar for KiCad.
|
|
|
|
*/
|
|
|
|
EDA_PANE& InfoBar()
|
|
|
|
{
|
|
|
|
CaptionVisible( false );
|
|
|
|
Movable( false );
|
|
|
|
Resizable( true );
|
2020-05-21 17:22:12 +00:00
|
|
|
PaneBorder( false );
|
|
|
|
DockFixed( true );
|
2020-05-18 23:44:58 +00:00
|
|
|
return *this;
|
|
|
|
}
|
2011-09-15 18:25:44 +00:00
|
|
|
};
|
|
|
|
|
2019-12-19 14:22:42 +00:00
|
|
|
#endif // EDA_BASE_FRAME_H_
|