-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSourceTrail.cpp
124 lines (110 loc) · 3.42 KB
/
SourceTrail.cpp
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
#include "sdk.h" // Code::Blocks SDK
#include <configurationpanel.h>
#include "SourceTrail.h"
#include "stclient.h"
#include <wx/log.h>
// Register the plugin with Code::Blocks.
// We are using an anonymous namespace so we don't litter the global one.
namespace
{
PluginRegistrant<SourceTrail> reg(_T("SourceTrail"));
int idSetActive = wxNewId();
}
// events handling
BEGIN_EVENT_TABLE(SourceTrail, cbPlugin)
EVT_MENU(idSetActive, SourceTrail::OnSetActive)
END_EVENT_TABLE()
// constructor
SourceTrail::SourceTrail()
{
// 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("SourceTrail.zip")))
{
NotifyMissingFile(_T("SourceTrail.zip"));
}
m_FileNewMenu = 0;
wxLogMessage(wxT("SourceTrail::SourceTrail"));
}
// destructor
SourceTrail::~SourceTrail()
{
}
void SourceTrail::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...
wxLogMessage(wxT("SourceTrail::OnAttach"));
Manager::Get()->GetLogManager()->Log(wxT("Create Client"));
m_pClient = new stClient(6666,6667);
m_pClient->StartServer();
cbPlugin::OnAttach();
}
void SourceTrail::OnRelease(bool appShutDown)
{
wxLogMessage(wxT("SourceTrail::OnRelease"));
// 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...
delete m_pClient;
if (m_FileNewMenu)
{
m_FileNewMenu->Delete(idSetActive);
m_FileNewMenu = 0;
}
cbPlugin::OnRelease(appShutDown);
}
void SourceTrail::BuildMenu(wxMenuBar* menuBar)
{
wxLogMessage(wxT("SourceTrail::BuildMenu"));
if (m_FileNewMenu)
{
m_FileNewMenu->Delete(idSetActive);
m_FileNewMenu = 0;
}
const int pos = menuBar->FindMenu(_("&Edit"));
if (pos != wxNOT_FOUND)
{
wxMenu* pEditMenu = menuBar->GetMenu(pos);
pEditMenu->AppendSeparator();
pEditMenu->Append( idSetActive, _( "SourceTrail: Show Token" ), _( "Send the token under the caret to SourceTrail" ) );
}
else
wxLogMessage(_T("Could not find Edit Menu!"));
}
void SourceTrail::BuildModuleMenu(const ModuleType type, wxMenu* menu, const FileTreeData* data)
{
if ( !menu || !IsAttached() )
return;
switch ( type )
{
case mtEditorManager:
menu->AppendSeparator();
menu->Append( idSetActive, _( "SourceTrail: Show Token" ), _( "Send the token under the caret to SourceTrail" ) );
}
}
//
//bool SourceTrail::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("SourceTrail::BuildToolBar()"));
//
// // return true if you add toolbar items
// return false;
//}
void SourceTrail::OnSetActive(wxCommandEvent& event)
{
if(m_pClient)
{
m_pClient->SendLocation();
}
}