| 1 |
////////////////////////////////////////////////////////////////////////////// |
| 2 |
////////////////////////////////////////////////////////////////////////////// |
| 3 |
// |
| 4 |
// copyright : (C) 2014 Eran Ifrah |
| 5 |
// file name : event_notifier.h |
| 6 |
// |
| 7 |
// ------------------------------------------------------------------------- |
| 8 |
// A |
| 9 |
// _____ _ _ _ _ |
| 10 |
// / __ \ | | | | (_) | |
| 11 |
// | / \/ ___ __| | ___| | _| |_ ___ |
| 12 |
// | | / _ \ / _ |/ _ \ | | | __/ _ ) |
| 13 |
// | \__/\ (_) | (_| | __/ |___| | || __/ |
| 14 |
// \____/\___/ \__,_|\___\_____/_|\__\___| |
| 15 |
// |
| 16 |
// F i l e |
| 17 |
// |
| 18 |
// This program is free software; you can redistribute it and/or modify |
| 19 |
// it under the terms of the GNU General Public License as published by |
| 20 |
// the Free Software Foundation; either version 2 of the License, or |
| 21 |
// (at your option) any later version. |
| 22 |
// |
| 23 |
////////////////////////////////////////////////////////////////////////////// |
| 24 |
////////////////////////////////////////////////////////////////////////////// |
| 25 |
|
| 26 |
#ifndef EVENTNOTIFIER_H |
| 27 |
#define EVENTNOTIFIER_H |
| 28 |
|
| 29 |
#include <wx/event.h> |
| 30 |
#if wxUSE_GUI |
| 31 |
#include <wx/frame.h> |
| 32 |
#endif |
| 33 |
#include "codelite_exports.h" |
| 34 |
|
| 35 |
class WXDLLIMPEXP_CL EventNotifier : public wxEvtHandler |
| 36 |
{ |
| 37 |
bool _eventsDiabled; |
| 38 |
|
| 39 |
private: |
| 40 |
EventNotifier(); |
| 41 |
virtual ~EventNotifier(); |
| 42 |
|
| 43 |
public: |
| 44 |
static EventNotifier* Get(); |
| 45 |
static void Release(); |
| 46 |
|
| 47 |
virtual void AddPendingEvent(const wxEvent& event); |
| 48 |
virtual bool ProcessEvent(wxEvent &event); |
| 49 |
|
| 50 |
void DisableEvents(bool b) { |
| 51 |
_eventsDiabled = b; |
| 52 |
} |
| 53 |
|
| 54 |
bool IsEventsDiabled() const { |
| 55 |
return _eventsDiabled; |
| 56 |
} |
| 57 |
#if wxUSE_GUI |
| 58 |
wxFrame* TopFrame(); |
| 59 |
#endif |
| 60 |
bool SendCommandEvent(int eventId, void *clientData); |
| 61 |
void PostCommandEvent(int eventId, void *clientData); |
| 62 |
bool SendCommandEvent(int eventId, void *clientData, const wxString &s); |
| 63 |
|
| 64 |
// -------------------------------------------------------- |
| 65 |
// About the following functions: |
| 66 |
// the below functions are meant to provide an easy |
| 67 |
// way to fire codelite's plugins events without the need |
| 68 |
// to create the event on the stack. |
| 69 |
// Post* are meant as Asnyc event ("AddPendingEvent") |
| 70 |
// While Notify* are synchronous event ("ProcessEvent") |
| 71 |
//--------------------------------------------------------- |
| 72 |
|
| 73 |
/** |
| 74 |
* @brief post a wxEVT_FILE_SAVED event |
| 75 |
*/ |
| 76 |
void PostFileSavedEvent( const wxString &filename ); |
| 77 |
|
| 78 |
/** |
| 79 |
* @brief post a wxEVT_CMD_RELOAD_EXTERNALLY_MODIFIED_NOPROMPT or wxEVT_CMD_RELOAD_EXTERNALLY_MODIFIED |
| 80 |
* @param prompt |
| 81 |
*/ |
| 82 |
void PostReloadExternallyModifiedEvent( bool prompt = true ); |
| 83 |
|
| 84 |
/** |
| 85 |
* @brief post a wxEVT_PROJ_FILE_REMOVED event |
| 86 |
*/ |
| 87 |
void PostFileRemovedEvent( const wxArrayString &files ); |
| 88 |
|
| 89 |
/** |
| 90 |
* @brief send a wxEVT_WORKSPACE_RELOAD_STARTED event (sync event) |
| 91 |
*/ |
| 92 |
void NotifyWorkspaceReloadStartEvet(const wxString &workspaceFile); |
| 93 |
|
| 94 |
/** |
| 95 |
* @brief send a wxEVT_WORKSPACE_RELOAD_ENDED event (sync event) |
| 96 |
*/ |
| 97 |
void NotifyWorkspaceReloadEndEvent(const wxString &workspaceFile); |
| 98 |
}; |
| 99 |
|
| 100 |
#endif // EVENTNOTIFIER_H |