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, see <https://www.gnu.org/licenses/>.
20 */
21
22#ifndef KIWAY_PLAYER_H_
23#define KIWAY_PLAYER_H_
24
25#include <wx/frame.h>
26
27#include <vector>
28#include <kiway_holder.h>
29#include <eda_base_frame.h>
30
31class KIWAY;
32class PROJECT;
33struct KIFACE;
34class KIFACE_BASE;
35class TOOL_MANAGER;
37
38class wxGUIEventLoop;
39class wxSocketServer;
40class wxSocketBase;
41class wxSocketEvent;
42class wxCmdLineParser;
43
44
57{
58public:
59 KIWAY_PLAYER( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
60 const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
61 long aStyle, const wxString& aFrameName, const EDA_IU_SCALE& aIuScale );
62
63 ~KIWAY_PLAYER() throw();
64
65 // For the aCtl argument of OpenProjectFiles()
66#define KICTL_NONKICAD_ONLY (1<<0)
67#define KICTL_KICAD_ONLY (1<<1)
68#define KICTL_CREATE (1<<2)
69#define KICTL_IMPORT_LIB (1<<3)
70#define KICTL_REVERT (1<<4)
71
105 virtual bool OpenProjectFiles( const std::vector<wxString>& aFileList, int aCtl = 0 )
106 {
107 // overload me for your wxFrame type.
108
109 // Any overload should probably do this also:
110 // Prj().MaybeLoadProjectSettings();
111
112 // Then update the window title.
113
114 return false;
115 }
116
117
131 virtual bool ShowModal( wxString* aResult = nullptr,
132 wxWindow* aResultantFocusWindow = nullptr );
133
139 virtual void KiwayMailIn( KIWAY_MAIL_EVENT& aEvent );
140
144 bool Destroy() override;
145
146 bool IsModal() const override { return m_modal; }
147 void SetModal( bool aIsModal ) { m_modal = aIsModal; }
148
154 bool IsDismissed();
155
156 void DismissModal( bool aRetVal, const wxString& aResult = wxEmptyString );
157
158 /* interprocess communication */
159 void CreateServer( int service, bool local = true );
160 void OnSockRequest( wxSocketEvent& evt );
161 void OnSockRequestServer( wxSocketEvent& evt );
162
169 virtual void ExecuteRemoteCommand( const char* cmdline ){}
170
171protected:
172
174 void kiway_express( KIWAY_MAIL_EVENT& aEvent );
175
176 // variables for modal behavior support, only used by a few derivatives.
177 bool m_modal; // true if frame is intended to be modal, not modeless
178
180 wxGUIEventLoop* m_modal_loop;
181 wxWindow* m_modal_resultant_parent; // the window caller in modal mode
183 bool m_modal_ret_val; // true if a selection was made
184
185 wxSocketServer* m_socketServer;
186 std::vector<wxSocketBase*> m_sockets;
187
188 DECLARE_EVENT_TABLE()
189};
190
191#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:35
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition kiway_mail.h:34
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:311
Container for project specific data.
Definition project.h:62
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:29
Implement a participant in the KIWAY alchemy.
Definition kiway.h:152