You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
3.3 KiB

12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
  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. #ifndef KIWAY_EXPRESS_H_
  25. #define KIWAY_EXPRESS_H_
  26. // @see http://wiki.wxwidgets.org/Custom_Events_Tutorial
  27. #include <wx/wx.h>
  28. #include <frame_type.h>
  29. #include <mail_type.h>
  30. /**
  31. * KIWAY_EXPRESS
  32. * carries a payload from one KIWAY_PLAYER to another within a PROJECT.
  33. */
  34. class KIWAY_EXPRESS : public wxEvent
  35. {
  36. public:
  37. /**
  38. * Function Dest
  39. * returns the destination player id of the message.
  40. */
  41. FRAME_T Dest() { return m_destination; }
  42. /**
  43. * Function Command
  44. * returns the MAIL_T associated with this mail.
  45. */
  46. MAIL_T Command()
  47. {
  48. return (MAIL_T) GetId(); // re-purposed control id.
  49. }
  50. /**
  51. * Function Payload
  52. * returns the payload, which can be any text but it typicall self
  53. * identifying s-expression.
  54. */
  55. std::string& GetPayload() { return m_payload; }
  56. void SetPayload( const std::string& aPayload ) { m_payload = aPayload; }
  57. KIWAY_EXPRESS* Clone() const override { return new KIWAY_EXPRESS( *this ); }
  58. //KIWAY_EXPRESS() {}
  59. KIWAY_EXPRESS( FRAME_T aDestination, MAIL_T aCommand, std::string& aPayload,
  60. wxWindow* aSource = NULL );
  61. KIWAY_EXPRESS( const KIWAY_EXPRESS& anOther );
  62. /// The wxEventType argument to wxEvent() and identifies an event class
  63. /// in a hurry. These wxEventTypes also allow a common class to be used
  64. /// multiple ways. Should be allocated at startup by wxNewEventType();
  65. static const wxEventType wxEVENT_ID;
  66. //DECLARE_DYNAMIC_CLASS( KIWAY_EXPRESS )
  67. private:
  68. FRAME_T m_destination; ///< could have been a bitmap indicating multiple recipients
  69. std::string& m_payload; ///< very often s-expression text, but not always
  70. // possible new ideas here.
  71. };
  72. typedef void ( wxEvtHandler::*kiwayExpressFunction )( KIWAY_EXPRESS& );
  73. /// Typecast an event handler for the KIWAY_EXPRESS event class
  74. #define kiwayExpressHandler( func ) wxEVENT_HANDLER_CAST( kiwayExpressFunction, func )
  75. /// Event table definition for the KIWAY_EXPRESS event class
  76. #define EVT_KIWAY_EXPRESS( func ) \
  77. wx__DECLARE_EVT0( KIWAY_EXPRESS::wxEVENT_ID, kiwayExpressHandler( func ) )
  78. #endif // KIWAY_EXPRESS_H_