1 /* Reverse Engineer's Hex Editor 2 * Copyright (C) 2020 Daniel Collins <solemnwarning@solemnwarning.net> 3 * 4 * This program is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License version 2 as published by 6 * the Free Software Foundation. 7 * 8 * This program is distributed in the hope that it will be useful, but WITHOUT 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 * more details. 12 * 13 * You should have received a copy of the GNU General Public License along with 14 * this program; if not, write to the Free Software Foundation, Inc., 51 15 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 */ 17 18 #ifndef REHEX_EVENTS_HPP 19 #define REHEX_EVENTS_HPP 20 21 #include <sys/types.h> 22 #include <wx/event.h> 23 #include <wx/window.h> 24 25 #include "document.hpp" 26 27 namespace REHex 28 { 29 class OffsetLengthEvent: public wxEvent 30 { 31 public: 32 const off_t offset; 33 const off_t length; 34 35 OffsetLengthEvent(wxWindow *source, wxEventType event, off_t offset, off_t length); 36 OffsetLengthEvent(wxObject *source, wxEventType event, off_t offset, off_t length); 37 38 virtual wxEvent *Clone() const override; 39 }; 40 41 typedef void (wxEvtHandler::*OffsetLengthEventFunction)(OffsetLengthEvent&); 42 43 #define EVT_OFFSETLENGTH(id, type, func) \ 44 wx__DECLARE_EVT1(type, id, wxEVENT_HANDLER_CAST(OffsetLengthEventFunction, func)) 45 46 class CursorUpdateEvent: public wxEvent 47 { 48 public: 49 const off_t cursor_pos; 50 const Document::CursorState cursor_state; 51 52 CursorUpdateEvent(wxWindow *source, off_t cursor_pos, Document::CursorState cursor_state); 53 CursorUpdateEvent(wxObject *source, off_t cursor_pos, Document::CursorState cursor_state); 54 55 virtual wxEvent *Clone() const override; 56 }; 57 58 typedef void (wxEvtHandler::*CursorUpdateEventFunction)(CursorUpdateEvent&); 59 60 #define EVT_CURSORUPDATE(id, func) \ 61 wx__DECLARE_EVT1(CURSOR_UPDATE, id, wxEVENT_HANDLER_CAST(CursorUpdateEventFunction, func)) 62 63 /** 64 * @brief Event raised by a Document when its title changes. 65 */ 66 class DocumentTitleEvent: public wxEvent 67 { 68 public: 69 const std::string title; /**< @brief The new document title. */ 70 71 DocumentTitleEvent(wxWindow *source, const std::string &title); 72 DocumentTitleEvent(wxObject *source, const std::string &title); 73 74 virtual wxEvent *Clone() const override; 75 }; 76 77 typedef void (wxEvtHandler::*DocumentTitleEventFunction)(DocumentTitleEvent&); 78 79 #define EVT_DOCUMENTTITLE(id, func) \ 80 wx__DECLARE_EVT1(DOCUMENT_TITLE_CHANGED, id, wxEVENT_HANDLER_CAST(DocumentTitleEventFunction, func)) 81 82 /** 83 * @brief Event raised by the App when the font size adjustment is changed. 84 */ 85 class FontSizeAdjustmentEvent: public wxEvent 86 { 87 public: 88 const int font_size_adjustment; /**< @brief The new font size adjustment value. */ 89 90 FontSizeAdjustmentEvent(int font_size_adjustment); 91 92 virtual wxEvent *Clone() const override; 93 }; 94 95 typedef void (wxEvtHandler::*FontSizeAdjustmentEventFunction)(FontSizeAdjustmentEvent&); 96 97 #define EVT_FONTSIZEADJUSTMENT(func) \ 98 wx__DECLARE_EVT1(FONT_SIZE_ADJUSTMENT_CHANGED, wxID_ANY, wxEVENT_HANDLER_CAST(FontSizeAdjustmentEventFunction, func)) 99 100 wxDECLARE_EVENT(COMMENT_LEFT_CLICK, OffsetLengthEvent); 101 wxDECLARE_EVENT(COMMENT_RIGHT_CLICK, OffsetLengthEvent); 102 wxDECLARE_EVENT(DATA_RIGHT_CLICK, wxCommandEvent); 103 104 wxDECLARE_EVENT(DATA_ERASING, OffsetLengthEvent); 105 wxDECLARE_EVENT(DATA_ERASE, OffsetLengthEvent); 106 wxDECLARE_EVENT(DATA_ERASE_ABORTED, OffsetLengthEvent); 107 wxDECLARE_EVENT(DATA_INSERTING, OffsetLengthEvent); 108 wxDECLARE_EVENT(DATA_INSERT, OffsetLengthEvent); 109 wxDECLARE_EVENT(DATA_INSERT_ABORTED, OffsetLengthEvent); 110 wxDECLARE_EVENT(DATA_OVERWRITING, OffsetLengthEvent); 111 wxDECLARE_EVENT(DATA_OVERWRITE, OffsetLengthEvent); 112 wxDECLARE_EVENT(DATA_OVERWRITE_ABORTED, OffsetLengthEvent); 113 114 wxDECLARE_EVENT(CURSOR_UPDATE, CursorUpdateEvent); 115 116 wxDECLARE_EVENT(DOCUMENT_TITLE_CHANGED, DocumentTitleEvent); 117 118 wxDECLARE_EVENT(FONT_SIZE_ADJUSTMENT_CHANGED, FontSizeAdjustmentEvent); 119 120 wxDECLARE_EVENT(PALETTE_CHANGED, wxCommandEvent); 121 } 122 123 #endif /* !REHEX_EVENTS_HPP */ 124