Alarm browser improved
[public/netxms.git] / src / client / console / include / nxmc_api.h
CommitLineData
4560d8bd
VK
1#ifndef _nxmc_api_h_
2#define _nxmc_api_h_
3
f2a439ef
VK
4#pragma warning(disable: 4284)
5
4560d8bd
VK
6#define WXUSINGDLL
7
8#ifdef _WIN32
9#include <wx/msw/winundef.h>
10#endif
11
12#include <wx/wx.h>
13
14#ifndef WX_PRECOMP
15#include <wx/app.h>
16#include <wx/frame.h>
17#include <wx/artprov.h>
18#include <wx/xrc/xmlres.h>
19#include <wx/filesys.h>
20#include <wx/fs_arc.h>
21#include <wx/fs_mem.h>
22#include <wx/aui/aui.h>
23#include <wx/dir.h>
24#include <wx/config.h>
25#include <wx/stdpaths.h>
dd36615b 26#include <wx/dynarray.h>
12476e2a
VK
27#include <wx/splitter.h>
28#include <wx/treectrl.h>
f2a439ef 29#include <wx/listctrl.h>
f974a50a 30#include <wx/notebook.h>
2621270d 31#include <wx/imaglist.h>
4560d8bd
VK
32#endif
33
34
d99ee887 35#ifdef _WIN32
4560d8bd
VK
36#ifdef LIBNXMC_EXPORTS
37#define LIBNXMC_EXPORTABLE __declspec(dllexport)
38#else
39#define LIBNXMC_EXPORTABLE __declspec(dllimport)
40#endif
d99ee887
VK
41#else
42#define LIBNXMC_EXPORTABLE
43#endif
4560d8bd
VK
44
45
46//
47// Constants
48//
49
50#define MAX_PLUGIN_NAME_LEN 256
51#define MAX_PLUGIN_VERSION_LEN 64
e44986e5
VK
52#define NXMC_PLUGIN_ID_LIMIT 100
53#define NXMC_MAX_PLUGINS 100
4560d8bd
VK
54
55
56//
57// Integration points
58//
59
e44986e5
VK
60#define NXMC_IP_CONTROL_PANEL 0x0001
61#define NXMC_IP_MAIN_MENU 0x0002
62#define NXMC_IP_PLUGIN_CONTEXT_MENU 0x0004
4560d8bd
VK
63
64
2621270d
VK
65//
66// Image lists
67//
68
e44986e5 69#define IMAGE_LIST_OBJECTS_SMALL 1
f2a439ef
VK
70#define IMAGE_LIST_OBJECTS_NORMAL 2
71#define IMAGE_LIST_STATUS_SMALL 3
72
73
74//
75// Timestamp formats
76//
77
78#define TS_LONG_DATE_TIME 0
79#define TS_LONG_TIME 1
80#define TS_DAY_AND_MONTH 2
81#define TS_MONTH 3
2621270d
VK
82
83
4560d8bd
VK
84//
85// Export definition
86//
87
88#ifdef _WIN32
89#define NXMC_PLUGIN_EXPORT __declspec(dllexport)
90#else
91#define NXMC_PLUGIN_EXPORT
92#endif
93
94
f2a439ef 95//
e44986e5 96// Windows/UNIX compatibility defines
f2a439ef
VK
97//
98
99#ifdef _WIN32
e44986e5
VK
100#define NXMC_LIB_INSTANCE HINSTANCE
101#define NXMC_LIB_INSTANCE_ARG(x) (x)
102#define wxMAKEINTRESOURCE(x) MAKEINTRESOURCE(x)
f2a439ef 103#else
e44986e5
VK
104#define NXMC_LIB_INSTANCE int
105#define NXMC_LIB_INSTANCE_ARG(x) 0
106#define wxMAKEINTRESOURCE(x) NULL
f2a439ef
VK
107#endif
108
109
3dd59bed
VK
110//
111// Plugin handle
112//
113
114typedef void * NXMC_PLUGIN_HANDLE;
115
116
4560d8bd
VK
117//
118// Macros for declaring plugin entry point
119//
120
121#define NXMC_IMPLEMENT_PLUGIN_REGISTRATION(n,v,f) \
122 extern "C" void NXMC_PLUGIN_EXPORT nxmcRegisterPlugin(NXMC_PLUGIN_INFO *p) \
123 { \
124 nx_strncpy(p->name, n, MAX_PLUGIN_NAME_LEN); \
125 nx_strncpy(p->version, v, MAX_PLUGIN_VERSION_LEN); \
126 p->flags = f; \
127 }
128
129
130//
131// Plugin registration structure
132//
133
134typedef struct
135{
136 TCHAR name[MAX_PLUGIN_NAME_LEN];
137 TCHAR version[MAX_PLUGIN_VERSION_LEN];
138 DWORD flags;
139} NXMC_PLUGIN_INFO;
140
141
142//
143// Data exchange macros
144//
145
146#define DX_GET_TEXTCTRL(id,var) \
147 { \
148 var = XRCCTRL(*this,id,wxTextCtrl)->GetValue(); \
149 }
150#define DX_SET_TEXTCTRL(id,var) \
151 { \
152 XRCCTRL(*this,id,wxTextCtrl)->SetValue(var); \
153 }
154
155#define DX_GET_CHECKBOX(id,var) \
156 { \
157 var = XRCCTRL(*this,id,wxCheckBox)->IsChecked(); \
158 }
159#define DX_SET_CHECKBOX(id,var) \
160 { \
161 XRCCTRL(*this,id,wxCheckBox)->SetValue(var); \
162 }
163
164#define DX_GET_STATIC(id,var) \
165 { \
166 var = XRCCTRL(*this,id,wxStaticText)->GetLabel(); \
167 }
168#define DX_SET_STATIC(id,var) \
169 { \
170 XRCCTRL(*this,id,wxStaticText)->SetLabel(var); \
171 }
172
173#define DX_GET_COMBOBOX(id,var) \
174 { \
175 var = XRCCTRL(*this,id,wxComboBox)->GetValue(); \
176 }
177#define DX_SET_COMBOBOX(id,var) \
178 { \
179 XRCCTRL(*this,id,wxComboBox)->SetValue(var); \
180 }
181
182
183//
184// Additional event table macros
185//
186
187#define EVT_NC_RIGHT_DOWN(func) wx__DECLARE_EVT0(wxEVT_NC_RIGHT_DOWN, wxMouseEventHandler(func))
188#define EVT_NC_RIGHT_UP(func) wx__DECLARE_EVT0(wxEVT_NC_RIGHT_UP, wxMouseEventHandler(func))
189
190
12476e2a
VK
191//
192// Predefined IDs
193//
194
195#define wxID_TREE_CTRL (wxID_HIGHEST + 500)
f974a50a 196#define wxID_NOTEBOOK_CTRL (wxID_HIGHEST + 501)
f2a439ef 197#define wxID_LIST_CTRL (wxID_HIGHEST + 502)
e1ebe70d 198#define wxID_TEXT_CTRL (wxID_HIGHEST + 503)
f974a50a
VK
199
200
201//
202// Custom events
203//
204
205BEGIN_DECLARE_EVENT_TYPES()
2621270d 206 DECLARE_EXPORTED_EVENT_TYPE(LIBNXMC_EXPORTABLE, nxEVT_REFRESH_VIEW, 0)
f974a50a
VK
207END_DECLARE_EVENT_TYPES()
208
209#define EVT_LIBNXMC_EVENT(evt, fn) \
210 DECLARE_EVENT_TABLE_ENTRY( \
211 evt, wxID_ANY, wxID_ANY, \
212 (wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent(wxCommandEventFunction, &fn), \
213 (wxObject *) NULL \
214 ),
215#define EVT_NX_REFRESH_VIEW(fn) EVT_LIBNXMC_EVENT(nxEVT_REFRESH_VIEW, fn)
12476e2a
VK
216
217
dd36615b
VK
218//
219// Menu/Control Panel item registration
220//
221
222class nxmcItemRegistration
223{
224private:
3dd59bed 225 NXMC_PLUGIN_HANDLE m_plugin;
dd36615b
VK
226 TCHAR *m_name;
227 int m_id;
228 int m_type;
229 void (*m_fpHandler)(int);
230
231public:
3dd59bed 232 nxmcItemRegistration(NXMC_PLUGIN_HANDLE plugin, const TCHAR *name, int id, int type, void (*fpHandler)(int));
dd36615b
VK
233 ~nxmcItemRegistration();
234
3dd59bed
VK
235 const TCHAR *GetName() { return m_name; }
236 int GetType() { return m_type; }
237 int GetId() { return m_id; }
238 NXMC_PLUGIN_HANDLE GetPlugin() { return m_plugin; }
dd36615b
VK
239
240 void CallHandler(int param) { m_fpHandler(param); }
241};
242
243WX_DECLARE_OBJARRAY(nxmcItemRegistration, nxmcArrayOfRegItems);
244
245
246//
247// Registration item types
248//
249
250#define REGITEM_VIEW_MENU 0
251#define REGITEM_CONTROL_PANEL 1
252
253
3dd59bed
VK
254//
255// View creation areas
256//
257
258#define VIEWAREA_MAIN 0
259#define VIEWAREA_DOCKED 1
260#define VIEWAREA_FLOATING 2
261#define VIEWAREA_DETACHED 3
262
263
f2a439ef
VK
264//
265// Code translation structure
266//
267
268struct CODE_TO_TEXT
269{
270 int code;
271 TCHAR *text;
272};
273
274
275//
e1ebe70d 276// Additional array and hash types
f2a439ef
VK
277//
278
e1ebe70d 279WX_DECLARE_HASH_MAP(DWORD, NXC_ALARM*, wxIntegerHash, wxIntegerEqual, nxAlarmList);
f2a439ef
VK
280
281
4560d8bd
VK
282//
283// Classes
284//
285
286#include "../libnxmc/nxview.h"
f2a439ef 287#include "../libnxmc/heading.h"
4560d8bd
VK
288
289
290//
291// Functions
292//
293
12476e2a 294void LIBNXMC_EXPORTABLE NXMCInitAUI(wxAuiManager *mgr, wxAuiNotebook *nb, wxWindow *defParent);
3dd59bed
VK
295void LIBNXMC_EXPORTABLE NXMCInitializationComplete();
296
297nxmcArrayOfRegItems LIBNXMC_EXPORTABLE &NXMCGetRegistrations();
298
f2a439ef
VK
299bool LIBNXMC_EXPORTABLE NXMCLoadResources(const TCHAR *name, NXMC_LIB_INSTANCE instance, TCHAR *resName);
300
3dd59bed
VK
301bool LIBNXMC_EXPORTABLE NXMCAddControlPanelItem(NXMC_PLUGIN_HANDLE handle, const TCHAR *name, int id);
302bool LIBNXMC_EXPORTABLE NXMCAddViewMenuItem(NXMC_PLUGIN_HANDLE handle, const TCHAR *name, int id);
dd36615b 303
12476e2a
VK
304wxWindow LIBNXMC_EXPORTABLE *NXMCGetDefaultParent();
305bool LIBNXMC_EXPORTABLE NXMCCreateView(nxView *view, int area);
dd36615b 306
f974a50a
VK
307void LIBNXMC_EXPORTABLE NXMCSetSession(NXC_SESSION session);
308NXC_SESSION LIBNXMC_EXPORTABLE NXMCGetSession();
309
4560d8bd
VK
310void LIBNXMC_EXPORTABLE InitViewTracker(wxAuiManager *mgr, wxAuiNotebook *nb);
311void LIBNXMC_EXPORTABLE RegisterUniqueView(const TCHAR *name, nxView *view);
312void LIBNXMC_EXPORTABLE UnregisterUniqueView(const TCHAR *name);
313nxView LIBNXMC_EXPORTABLE *FindUniqueView(const TCHAR *name);
314void LIBNXMC_EXPORTABLE ActivateView(nxView *view);
315
f2a439ef 316const TCHAR LIBNXMC_EXPORTABLE *NXMCCodeToText(int code, CODE_TO_TEXT *translator, const TCHAR *defaultText);
f974a50a
VK
317const TCHAR LIBNXMC_EXPORTABLE *NXMCGetStatusText(int status);
318const TCHAR LIBNXMC_EXPORTABLE *NXMCGetStatusTextSmall(int status);
f2a439ef
VK
319const TCHAR LIBNXMC_EXPORTABLE *NXMCGetAlarmStateName(int state);
320const TCHAR LIBNXMC_EXPORTABLE *NXMCGetClassName(int objClass);
321const TCHAR LIBNXMC_EXPORTABLE *NXMCGetIfTypeName(int type);
322const TCHAR LIBNXMC_EXPORTABLE *NXMCGetNodeTypeName(int type);
4560d8bd 323
2621270d
VK
324void LIBNXMC_EXPORTABLE NXMCInitImageLists();
325wxImageList LIBNXMC_EXPORTABLE *NXMCGetImageList(int list);
f2a439ef 326wxImageList LIBNXMC_EXPORTABLE *NXMCGetImageListCopy(int list);
2621270d 327
f2a439ef
VK
328void LIBNXMC_EXPORTABLE NXMCInitAlarms(DWORD count, NXC_ALARM *list);
329void LIBNXMC_EXPORTABLE NXMCUpdateAlarms(DWORD code, NXC_ALARM *data);
e1ebe70d 330nxAlarmList LIBNXMC_EXPORTABLE *NXMCGetAlarmList();
f2a439ef
VK
331void LIBNXMC_EXPORTABLE NXMCUnlockAlarmList();
332
333TCHAR LIBNXMC_EXPORTABLE *NXMCFormatTimeStamp(time_t timeStamp, TCHAR *buffer, int type);
f974a50a 334
7bdfc49b
VK
335void LIBNXMC_EXPORTABLE NXMCSaveListCtrlColumns(wxConfigBase *cfg, wxListCtrl &wndListCtrl, const TCHAR *prefix);
336void LIBNXMC_EXPORTABLE NXMCLoadListCtrlColumns(wxConfigBase *cfg, wxListCtrl &wndListCtrl, const TCHAR *prefix);
337
f2a439ef 338#endif