KiCad PCB EDA Suite
kiway_express.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 <dick@softplc.com>
5  * Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #ifndef KIWAY_EXPRESS_H_
26 #define KIWAY_EXPRESS_H_
27 
28 // @see http://wiki.wxwidgets.org/Custom_Events_Tutorial
29 
30 #include <wx/wx.h>
31 #include <frame_type.h>
32 #include <mail_type.h>
33 
34 
39 class KIWAY_EXPRESS : public wxEvent
40 {
41 public:
46  FRAME_T Dest() { return m_destination; }
47 
53  {
54  return (MAIL_T) GetId(); // re-purposed control id.
55  }
56 
62  const std::string& GetPayload() { return m_payload; }
63  void SetPayload( const std::string& aPayload ) { m_payload = aPayload; }
64 
65  KIWAY_EXPRESS* Clone() const override { return new KIWAY_EXPRESS( *this ); }
66 
67  //KIWAY_EXPRESS() {}
68 
69  KIWAY_EXPRESS( FRAME_T aDestination,
70  MAIL_T aCommand,
71  const std::string& aPayload,
72  wxWindow* aSource = NULL );
73 
74  KIWAY_EXPRESS( const KIWAY_EXPRESS& anOther );
75 
79  static const wxEventType wxEVENT_ID;
80 
81  //DECLARE_DYNAMIC_CLASS( KIWAY_EXPRESS )
82 
83 private:
85  std::string m_payload;
86 
87  // possible new ideas here.
88 };
89 
90 
91 typedef void ( wxEvtHandler::*kiwayExpressFunction )( KIWAY_EXPRESS& );
92 
93 #define wxKiwayExressHandler(func) \
94  (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(kiwayExpressFunction, &func)
95 
96 
97 #define EVT_KIWAY_EXPRESS( func ) \
98  DECLARE_EVENT_TABLE_ENTRY( \
99  KIWAY_EXPRESS::wxEVENT_ID, -1, -1, \
100  (wxObjectEventFunction) \
101  (kiwayExpressFunction) & func, \
102  (wxObject*) NULL ),
103 
104 
105 #endif // KIWAY_EXPRESS_H_
KIWAY_EXPRESS(FRAME_T aDestination, MAIL_T aCommand, const std::string &aPayload, wxWindow *aSource=NULL)
std::string m_payload
very often s-expression text, but not always
Definition: kiway_express.h:85
Class KIWAY_EXPRESS carries a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition: kiway_express.h:39
void(wxEvtHandler::* kiwayExpressFunction)(KIWAY_EXPRESS &)
Definition: kiway_express.h:91
static const wxEventType wxEVENT_ID
The wxEventType argument to wxEvent() and identifies an event class in a hurry.
Definition: kiway_express.h:79
FRAME_T
Enum FRAME_T is the set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:34
void SetPayload(const std::string &aPayload)
Definition: kiway_express.h:63
FRAME_T m_destination
could have been a bitmap indicating multiple recipients
Definition: kiway_express.h:84
MAIL_T
Enum MAIL_T is the set of mail types sendable via KIWAY::ExpressMail() and supplied as the aCommand p...
Definition: mail_type.h:37
const std::string & GetPayload()
Function Payload returns the payload, which can be any text but it typicall self identifying s-expres...
Definition: kiway_express.h:62
FRAME_T Dest()
Function Dest returns the destination player id of the message.
Definition: kiway_express.h:46
KIWAY_EXPRESS * Clone() const override
Definition: kiway_express.h:65
MAIL_T Command()
Function Command returns the MAIL_T associated with this mail.
Definition: kiway_express.h:52