1 /*
2  * This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
3  * http://www.gnu.org/licenses/lgpl-3.0.html
4  *
5  * $Revision: 11631 $
6  * $Id: sdk_events.cpp 11631 2019-04-20 16:54:57Z fuscated $
7  * $HeadURL: svn://svn.code.sf.net/p/codeblocks/code/branches/release-20.xx/src/sdk/sdk_events.cpp $
8  */
9 
10 #include "sdk_precomp.h"
11 
12 #ifndef CB_PRECOMP
13     #include "sdk_events.h"
14     #include "cbproject.h"
15     #include "editorbase.h"
16     #include "cbplugin.h"
17     #include "logmanager.h"
18 #endif
19 
20 
IMPLEMENT_DYNAMIC_CLASS(CodeBlocksEvent,wxEvent)21 IMPLEMENT_DYNAMIC_CLASS(CodeBlocksEvent, wxEvent)
22 IMPLEMENT_DYNAMIC_CLASS(CodeBlocksDockEvent, wxEvent)
23 IMPLEMENT_DYNAMIC_CLASS(CodeBlocksLayoutEvent, wxEvent)
24 IMPLEMENT_DYNAMIC_CLASS(CodeBlocksLogEvent, wxEvent)
25 IMPLEMENT_DYNAMIC_CLASS(CodeBlocksThreadEvent, wxCommandEvent)
26 
27 
28 CodeBlocksLogEvent::CodeBlocksLogEvent(wxEventType commandType, Logger* logger_in, const wxString& title_in, wxBitmap *icon_in)
29     : wxEvent(wxID_ANY, commandType),
30     logger(logger_in), logIndex(-1), icon(icon_in), title(title_in), window(nullptr)
31 {
32     // special case for add
33     if (commandType == cbEVT_ADD_LOG_WINDOW && logger)
34     {
35         if (Manager::Get()->GetLogManager()->FindIndex(logger) == LogManager::invalid_log)
36         {
37             logIndex = Manager::Get()->GetLogManager()->SetLog(logger);
38             cbAssert(logIndex != LogManager::invalid_log);
39             Manager::Get()->GetLogManager()->Slot(logIndex).title = title;
40             Manager::Get()->GetLogManager()->Slot(logIndex).icon = icon;
41             return;
42         }
43     }
44 
45     logIndex = Manager::Get()->GetLogManager()->FindIndex(logger);
46 }
47 
CodeBlocksLogEvent(wxEventType commandType,int logIndex_in,const wxString & title_in,wxBitmap * icon_in)48 CodeBlocksLogEvent::CodeBlocksLogEvent(wxEventType commandType, int logIndex_in, const wxString& title_in, wxBitmap *icon_in)
49     : wxEvent(wxID_ANY, commandType),
50     logger(nullptr), logIndex(logIndex_in), icon(icon_in), title(title_in), window(nullptr)
51 {
52     logger = Manager::Get()->GetLogManager()->Slot(logIndex).GetLogger();
53 }
54 
CodeBlocksLogEvent(wxEventType commandType,wxWindow * window_in,const wxString & title_in,wxBitmap * icon_in)55 CodeBlocksLogEvent::CodeBlocksLogEvent(wxEventType commandType, wxWindow* window_in, const wxString& title_in, wxBitmap *icon_in)
56     : wxEvent(wxID_ANY, commandType),
57     logger(nullptr), logIndex(-1), icon(icon_in), title(title_in), window(window_in)
58 {
59 }
60 
CodeBlocksLogEvent(const CodeBlocksLogEvent & rhs)61 CodeBlocksLogEvent::CodeBlocksLogEvent(const CodeBlocksLogEvent& rhs)
62     : wxEvent(wxID_ANY, rhs.GetEventType()), logger(rhs.logger), logIndex(rhs.logIndex), icon(rhs.icon), title(rhs.title), window(rhs.window)
63 {
64 }
65 
66 
67 // app events
68 const wxEventType cbEVT_APP_STARTUP_DONE = wxNewEventType();
69 const wxEventType cbEVT_APP_START_SHUTDOWN = wxNewEventType();
70 const wxEventType cbEVT_APP_ACTIVATED = wxNewEventType();
71 const wxEventType cbEVT_APP_DEACTIVATED = wxNewEventType();
72 const wxEventType cbEVT_APP_CMDLINE = wxNewEventType();
73 // plugin events
74 const wxEventType cbEVT_PLUGIN_ATTACHED = wxNewEventType();
75 const wxEventType cbEVT_PLUGIN_RELEASED = wxNewEventType();
76 const wxEventType cbEVT_PLUGIN_INSTALLED = wxNewEventType();
77 const wxEventType cbEVT_PLUGIN_UNINSTALLED = wxNewEventType();
78 const wxEventType cbEVT_PLUGIN_LOADING_COMPLETE = wxNewEventType();
79 // editor events
80 const wxEventType cbEVT_EDITOR_CLOSE = wxNewEventType();
81 const wxEventType cbEVT_EDITOR_OPEN = wxNewEventType();
82 const wxEventType cbEVT_EDITOR_SWITCHED = wxNewEventType();
83 const wxEventType cbEVT_EDITOR_ACTIVATED = wxNewEventType();
84 const wxEventType cbEVT_EDITOR_DEACTIVATED = wxNewEventType();
85 const wxEventType cbEVT_EDITOR_BEFORE_SAVE = wxNewEventType();
86 const wxEventType cbEVT_EDITOR_SAVE = wxNewEventType();
87 const wxEventType cbEVT_EDITOR_MODIFIED = wxNewEventType();
88 const wxEventType cbEVT_EDITOR_TOOLTIP = wxNewEventType();
89 const wxEventType cbEVT_EDITOR_TOOLTIP_CANCEL = wxNewEventType();
90 const wxEventType cbEVT_EDITOR_SPLIT = wxNewEventType();
91 const wxEventType cbEVT_EDITOR_UNSPLIT = wxNewEventType();
92 const wxEventType cbEVT_EDITOR_UPDATE_UI = wxNewEventType();
93 const wxEventType cbEVT_EDITOR_CC_DONE = wxNewEventType();
94 // project events
95 const wxEventType cbEVT_PROJECT_NEW = wxNewEventType();
96 const wxEventType cbEVT_PROJECT_CLOSE = wxNewEventType();
97 const wxEventType cbEVT_PROJECT_OPEN = wxNewEventType();
98 const wxEventType cbEVT_PROJECT_SAVE = wxNewEventType();
99 const wxEventType cbEVT_PROJECT_ACTIVATE = wxNewEventType();
100 const wxEventType cbEVT_PROJECT_BEGIN_ADD_FILES = wxNewEventType();
101 const wxEventType cbEVT_PROJECT_END_ADD_FILES = wxNewEventType();
102 const wxEventType cbEVT_PROJECT_BEGIN_REMOVE_FILES = wxNewEventType();
103 const wxEventType cbEVT_PROJECT_END_REMOVE_FILES = wxNewEventType();
104 const wxEventType cbEVT_PROJECT_FILE_ADDED = wxNewEventType();
105 const wxEventType cbEVT_PROJECT_FILE_REMOVED = wxNewEventType();
106 const wxEventType cbEVT_PROJECT_FILE_CHANGED = wxNewEventType();
107 const wxEventType cbEVT_PROJECT_POPUP_MENU = wxNewEventType();
108 const wxEventType cbEVT_PROJECT_TARGETS_MODIFIED = wxNewEventType();
109 const wxEventType cbEVT_PROJECT_RENAMED = wxNewEventType();
110 const wxEventType cbEVT_PROJECT_OPTIONS_CHANGED = wxNewEventType();
111 const wxEventType cbEVT_WORKSPACE_CHANGED = wxNewEventType();
112 const wxEventType cbEVT_WORKSPACE_LOADING_COMPLETE = wxNewEventType();
113 const wxEventType cbEVT_WORKSPACE_CLOSING_BEGIN = wxNewEventType();
114 const wxEventType cbEVT_WORKSPACE_CLOSING_COMPLETE = wxNewEventType();
115 // build targets events
116 const wxEventType cbEVT_BUILDTARGET_ADDED = wxNewEventType();
117 const wxEventType cbEVT_BUILDTARGET_REMOVED = wxNewEventType();
118 const wxEventType cbEVT_BUILDTARGET_RENAMED = wxNewEventType();
119 const wxEventType cbEVT_BUILDTARGET_SELECTED = wxNewEventType();
120 // pipedprocess events
121 const wxEventType cbEVT_PIPEDPROCESS_STDOUT = wxNewEventType();
122 const wxEventType cbEVT_PIPEDPROCESS_STDERR = wxNewEventType();
123 const wxEventType cbEVT_PIPEDPROCESS_TERMINATED = wxNewEventType();
124 // thread-pool events
125 const wxEventType cbEVT_THREADTASK_STARTED = wxNewEventType();
126 const wxEventType cbEVT_THREADTASK_ENDED = wxNewEventType();
127 const wxEventType cbEVT_THREADTASK_ALLDONE = wxNewEventType();
128 // request app to dock/undock a window
129 const wxEventType cbEVT_ADD_DOCK_WINDOW = wxNewEventType();
130 const wxEventType cbEVT_REMOVE_DOCK_WINDOW = wxNewEventType();
131 const wxEventType cbEVT_SHOW_DOCK_WINDOW = wxNewEventType();
132 const wxEventType cbEVT_HIDE_DOCK_WINDOW = wxNewEventType();
133 // force update current view layout
134 const wxEventType cbEVT_UPDATE_VIEW_LAYOUT = wxNewEventType();
135 // ask which is the current view layout
136 const wxEventType cbEVT_QUERY_VIEW_LAYOUT = wxNewEventType();
137 // request app to switch view layout
138 const wxEventType cbEVT_SWITCH_VIEW_LAYOUT = wxNewEventType();
139 // app notifies that a new layout has been applied
140 const wxEventType cbEVT_SWITCHED_VIEW_LAYOUT = wxNewEventType();
141 // app notifies that a docked window has been hidden/shown
142 const wxEventType cbEVT_DOCK_WINDOW_VISIBILITY = wxNewEventType();
143 // app notifies that the menubar is started being (re)created
144 const wxEventType cbEVT_MENUBAR_CREATE_BEGIN = wxNewEventType();
145 // app notifies that the menubar (re)creation ended
146 const wxEventType cbEVT_MENUBAR_CREATE_END = wxNewEventType();
147 // compiler-related events
148 const wxEventType cbEVT_COMPILER_STARTED = wxNewEventType();
149 const wxEventType cbEVT_COMPILER_FINISHED = wxNewEventType();
150 const wxEventType cbEVT_COMPILER_SET_BUILD_OPTIONS = wxNewEventType();
151 const wxEventType cbEVT_CLEAN_PROJECT_STARTED = wxNewEventType();
152 const wxEventType cbEVT_CLEAN_WORKSPACE_STARTED = wxNewEventType();
153 const wxEventType cbEVT_COMPILER_SETTINGS_CHANGED = wxNewEventType();
154 // request app to compile a single file
155 const wxEventType cbEVT_COMPILE_FILE_REQUEST = wxNewEventType();
156 // debugger-related events
157 const wxEventType cbEVT_DEBUGGER_STARTED = wxNewEventType();
158 const wxEventType cbEVT_DEBUGGER_PAUSED = wxNewEventType();
159 const wxEventType cbEVT_DEBUGGER_CONTINUED = wxNewEventType();
160 const wxEventType cbEVT_DEBUGGER_FINISHED = wxNewEventType();
161 const wxEventType cbEVT_DEBUGGER_CURSOR_CHANGED = wxNewEventType();
162 const wxEventType cbEVT_DEBUGGER_UPDATED = wxNewEventType();
163 
164 // logger-related events
165 const wxEventType cbEVT_ADD_LOG_WINDOW = wxNewEventType();
166 const wxEventType cbEVT_REMOVE_LOG_WINDOW = wxNewEventType();
167 const wxEventType cbEVT_HIDE_LOG_WINDOW = wxNewEventType();
168 const wxEventType cbEVT_SWITCH_TO_LOG_WINDOW = wxNewEventType();
169 const wxEventType cbEVT_GET_ACTIVE_LOG_WINDOW = wxNewEventType();
170 const wxEventType cbEVT_SHOW_LOG_MANAGER = wxNewEventType();
171 const wxEventType cbEVT_HIDE_LOG_MANAGER = wxNewEventType();
172 const wxEventType cbEVT_LOCK_LOG_MANAGER = wxNewEventType();
173 const wxEventType cbEVT_UNLOCK_LOG_MANAGER = wxNewEventType();
174 
175 //cbAUiNotebook related events
176 const wxEventType cbEVT_CBAUIBOOK_LEFT_DCLICK = wxNewEventType();
177 
178 // code-completion related events
179 const wxEventType cbEVT_COMPLETE_CODE = wxNewEventType();
180 const wxEventType cbEVT_SHOW_CALL_TIP = wxNewEventType();
181 
182 const wxEventType cbEVT_SETTINGS_CHANGED = wxNewEventType();
183