-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcbMemoryView.cpp
More file actions
187 lines (153 loc) · 6.17 KB
/
cbMemoryView.cpp
File metadata and controls
187 lines (153 loc) · 6.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#include <sdk.h> // Code::Blocks SDK
#include <cbdebugger_interfaces.h>
#include <macrosmanager.h>
#include <configurationpanel.h>
#include <debuggermanager.h>
#include <logmanager.h>
#include <projectloader_hooks.h>
#include "cbMemoryView.h"
typedef cbEventFunctor<cbMemoryView, CodeBlocksEvent> Functor;
// Register the plugin with Code::Blocks.
// We are using an anonymous namespace so we don't litter the global one.
namespace
{
PluginRegistrant<cbMemoryView> reg(_T("cbMemoryView"));
}
int ID_MEMORY_VIEW_WINDOW =wxNewId();
int ID_MEMORY_VIEW_ADD_PANEL =wxNewId();
int ID_MEMORY_VIEW_RENAME_PANEL =wxNewId();
// events handling
BEGIN_EVENT_TABLE(cbMemoryView, cbPlugin)
// add any events you want to handle here
EVT_AUINOTEBOOK_TAB_RIGHT_DOWN(ID_MEMORY_VIEW_WINDOW, cbMemoryView::OnRClick)
EVT_MENU(ID_MEMORY_VIEW_ADD_PANEL, cbMemoryView::OnAddPage)
EVT_MENU(ID_MEMORY_VIEW_RENAME_PANEL, cbMemoryView::OnRenamePage)
END_EVENT_TABLE()
// constructor
cbMemoryView::cbMemoryView()
{
// Make sure our resources are available.
// In the generated boilerplate code we have no resources but when
// we add some, it will be nice that this code is in place already ;)
if(!Manager::LoadResource(_T("cbMemoryView.zip")))
{
NotifyMissingFile(_T("cbMemoryView.zip"));
}
}
// destructor
cbMemoryView::~cbMemoryView()
{
}
void cbMemoryView::OnRClick(wxAuiNotebookEvent& event)
{
wxMenu ctx;
ctx.Append(ID_MEMORY_VIEW_ADD_PANEL, wxT("Add page"));
ctx.Append(ID_MEMORY_VIEW_RENAME_PANEL, wxT("Rename page"));
m_window->PopupMenu(&ctx);
}
void cbMemoryView::OnAddPage(wxCommandEvent& event)
{
m_window->AddPage(new MemoryPanel(m_window), wxT("Memory View") , false);
}
void cbMemoryView::OnRenamePage(wxCommandEvent& event)
{
int cur_page = m_window->GetSelection();
wxTextEntryDialog nameDlg(m_window, wxT("Name of the page:"), wxT("Memory view name"), m_window->GetPageText(cur_page));
if(nameDlg.ShowModal() == wxID_OK)
{
m_window->SetPageText(cur_page, nameDlg.GetValue());
}
}
void cbMemoryView::OnAttach()
{
// do whatever initialization you need for your plugin
// NOTE: after this function, the inherited member variable
// m_IsAttached will be TRUE...
// You should check for it in other functions, because if it
// is FALSE, it means that the application did *not* "load"
// (see: does not need) this plugin...
m_window = new wxAuiNotebook(Manager::Get()->GetAppWindow(),
ID_MEMORY_VIEW_WINDOW,
wxDefaultPosition,
wxDefaultSize,
wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_MOVE | wxAUI_NB_WINDOWLIST_BUTTON | wxAUI_NB_CLOSE_ON_ALL_TABS);
CodeBlocksDockEvent evt(cbEVT_ADD_DOCK_WINDOW);
evt.name = _T("MemoryView");
evt.title = _("Memory view window");
evt.pWindow = m_window;
evt.dockSide = CodeBlocksDockEvent::dsFloating;
evt.desiredSize.Set(400, 300);
evt.floatingSize.Set(400, 300);
evt.minimumSize.Set(200, 150);
Manager::Get()->ProcessEvent(evt);
CodeBlocksDockEvent evt2(cbEVT_SHOW_DOCK_WINDOW);
evt2.pWindow = m_window;
Manager::Get()->ProcessEvent(evt2);
m_MenuItem = new MemoryViewMenuItem(m_window);
Manager::Get()->GetDebuggerManager()->GetMenuHandler()->RegisterWindowMenu(wxT("Memory view"), wxT("Memory view"), m_MenuItem);
Manager::Get()->RegisterEventSink(cbEVT_DEBUGGER_UPDATED, new Functor(this, &cbMemoryView::OnDebuggerWinEvt));
Manager::Get()->RegisterEventSink(cbEVT_DEBUGGER_CURSOR_CHANGED, new Functor(this, &cbMemoryView::OnDebuggerCursorChanged));
m_window->AddPage(new MemoryPanel(m_window), wxT("Memory View") , false);
m_window->AddPage(new MemoryPanel(m_window), wxT("Memory View2") , false);
m_window->AddPage(new MemoryPanel(m_window), wxT("Memory View3") , false);
m_window->AddPage(new MemoryPanel(m_window), wxT("Memory View4") , false);
}
void cbMemoryView::OnRelease(bool appShutDown)
{
// do de-initialization for your plugin
// if appShutDown is true, the plugin is unloaded because Code::Blocks is being shut down,
// which means you must not use any of the SDK Managers
// NOTE: after this function, the inherited member variable
// m_IsAttached will be FALSE...
}
void cbMemoryView::BuildMenu(wxMenuBar* menuBar)
{
//The application is offering its menubar for your plugin,
//to add any menu items you want...
//Append any items you need in the menu...
//NOTE: Be careful in here... The application's menubar is at your disposal.
NotImplemented(_T("cbMemoryView::BuildMenu()"));
}
void cbMemoryView::BuildModuleMenu(const ModuleType type, wxMenu* menu, const FileTreeData* data)
{
//Some library module is ready to display a pop-up menu.
//Check the parameter \"type\" and see which module it is
//and append any items you need in the menu...
//TIP: for consistency, add a separator as the first item...
NotImplemented(_T("cbMemoryView::BuildModuleMenu()"));
}
bool cbMemoryView::BuildToolBar(wxToolBar* toolBar)
{
//The application is offering its toolbar for your plugin,
//to add any toolbar items you want...
//Append any items you need on the toolbar...
NotImplemented(_T("cbMemoryView::BuildToolBar()"));
// return true if you add toolbar items
return false;
}
void cbMemoryView::OnDebuggerCursorChanged(CodeBlocksEvent& evt)
{
Manager::Get()->GetLogManager()->Log(wxT("::OnDebuggerCursorChanged"));
for(size_t i = 0; i < m_window->GetPageCount(); ++i)
{
MemoryPanel* panel = dynamic_cast<MemoryPanel*>(m_window->GetPage(i));
if(panel)
{
panel->DebuggerCursorChanged();
}
}
}
void cbMemoryView::OnDebuggerWinEvt(CodeBlocksEvent& evt)
{
if (cbDebuggerPlugin::DebugWindows(evt.GetInt()) != cbDebuggerPlugin::DebugWindows::MemoryRange)
return;
Manager::Get()->GetLogManager()->Log(wxT("::OnDebuggerWinEvt"));
for(size_t i = 0; i < m_window->GetPageCount(); ++i)
{
MemoryPanel* panel = dynamic_cast<MemoryPanel*>(m_window->GetPage(i));
if(panel)
{
panel->UpdatePanel();
}
}
}