KiCad PCB EDA Suite
Loading...
Searching...
No Matches
kiway_player.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 * Copyright (C) 2023 CERN (www.cern.ch)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#ifndef KIWAY_PLAYER_H_
27#define KIWAY_PLAYER_H_
28
29#include <wx/frame.h>
30
31#include <vector>
32#include <kiway_holder.h>
33#include <eda_base_frame.h>
34
35class KIWAY;
36class PROJECT;
37struct KIFACE;
38class KIFACE_BASE;
39class TOOL_MANAGER;
41
42class wxGUIEventLoop;
43class wxSocketServer;
44class wxSocketBase;
45class wxSocketEvent;
46class wxCmdLineParser;
47
48
61{
62public:
63 KIWAY_PLAYER( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
64 const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
65 long aStyle, const wxString& aFrameName, const EDA_IU_SCALE& aIuScale );
66
67 ~KIWAY_PLAYER() throw();
68
69 // For the aCtl argument of OpenProjectFiles()
70#define KICTL_NONKICAD_ONLY (1<<0)
71#define KICTL_KICAD_ONLY (1<<1)
72#define KICTL_CREATE (1<<2)
73#define KICTL_IMPORT_LIB (1<<3)
74#define KICTL_REVERT (1<<4)
75
109 virtual bool OpenProjectFiles( const std::vector<wxString>& aFileList, int aCtl = 0 )
110 {
111 // overload me for your wxFrame type.
112
113 // Any overload should probably do this also:
114 // Prj().MaybeLoadProjectSettings();
115
116 // Then update the window title.
117
118 return false;
119 }
120
121
135 virtual bool ShowModal( wxString* aResult = nullptr,
136 wxWindow* aResultantFocusWindow = nullptr );
137
143 virtual void KiwayMailIn( KIWAY_MAIL_EVENT& aEvent );
144
148 bool Destroy() override;
149
150 bool IsModal() const override { return m_modal; }
151 void SetModal( bool aIsModal ) { m_modal = aIsModal; }
152
158 bool IsDismissed();
159
160 void DismissModal( bool aRetVal, const wxString& aResult = wxEmptyString );
161
162 /* interprocess communication */
163 void CreateServer( int service, bool local = true );
164 void OnSockRequest( wxSocketEvent& evt );
165 void OnSockRequestServer( wxSocketEvent& evt );
166
173 virtual void ExecuteRemoteCommand( const char* cmdline ){}
174
175protected:
176
178 void kiway_express( KIWAY_MAIL_EVENT& aEvent );
179
180 // variables for modal behavior support, only used by a few derivatives.
181 bool m_modal; // true if frame is intended to be modal, not modeless
182
184 wxGUIEventLoop* m_modal_loop;
185 wxWindow* m_modal_resultant_parent; // the window caller in modal mode
187 bool m_modal_ret_val; // true if a selection was made
188
189 wxSocketServer* m_socketServer;
190 std::vector<wxSocketBase*> m_sockets;
191
192 DECLARE_EVENT_TABLE()
193};
194
195#endif // KIWAY_PLAYER_H_
EDA_BASE_FRAME(wxWindow *aParent, FRAME_T aFrameType, const wxString &aTitle, const wxPoint &aPos, const wxSize &aSize, long aStyle, const wxString &aFrameName, KIWAY *aKiway, const EDA_IU_SCALE &aIuScale)
A KIFACE implementation.
Definition kiface_base.h:39
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition kiway_mail.h:38
virtual bool ShowModal(wxString *aResult=nullptr, wxWindow *aResultantFocusWindow=nullptr)
Show this wxFrame as if it were a modal dialog, with all other instantiated wxFrames disabled until t...
wxString m_modal_string
virtual void ExecuteRemoteCommand(const char *cmdline)
Execute a remote command sent via socket (to port KICAD_PCB_PORT_SERVICE_NUMBER, currently 4242).
void CreateServer(int service, bool local=true)
virtual void KiwayMailIn(KIWAY_MAIL_EVENT &aEvent)
Receive #KIWAY_ROUTED_EVENT messages from other players.
wxWindow * m_modal_resultant_parent
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)
void SetModal(bool aIsModal)
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
virtual bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Open a project or set of files given by aFileList.
wxGUIEventLoop * m_modal_loop
Points to nested event_loop. NULL means not modal and dismissed.
std::vector< wxSocketBase * > m_sockets
void DismissModal(bool aRetVal, const wxString &aResult=wxEmptyString)
void OnSockRequestServer(wxSocketEvent &evt)
void OnSockRequest(wxSocketEvent &evt)
bool IsModal() const override
Return true if the frame is shown in our modal mode and false if the frame is shown as an usual frame...
void kiway_express(KIWAY_MAIL_EVENT &aEvent)
Event handler, routes to derivative specific virtual KiwayMailIn().
wxSocketServer * m_socketServer
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:315
Container for project specific data.
Definition project.h:66
Master controller class:
Base window classes and related definitions.
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition frame_type.h:33
Implement a participant in the KIWAY alchemy.
Definition kiway.h:156