Alarm browser improved
[public/netxms.git] / src / client / console / include / nxmc_api.h
1 #ifndef _nxmc_api_h_
2 #define _nxmc_api_h_
3
4 #pragma warning(disable: 4284)
5
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>
26 #include <wx/dynarray.h>
27 #include <wx/splitter.h>
28 #include <wx/treectrl.h>
29 #include <wx/listctrl.h>
30 #include <wx/notebook.h>
31 #include <wx/imaglist.h>
32 #endif
33
34
35 #ifdef _WIN32
36 #ifdef LIBNXMC_EXPORTS
37 #define LIBNXMC_EXPORTABLE __declspec(dllexport)
38 #else
39 #define LIBNXMC_EXPORTABLE __declspec(dllimport)
40 #endif
41 #else
42 #define LIBNXMC_EXPORTABLE
43 #endif
44
45
46 //
47 // Constants
48 //
49
50 #define MAX_PLUGIN_NAME_LEN 256
51 #define MAX_PLUGIN_VERSION_LEN 64
52 #define NXMC_PLUGIN_ID_LIMIT 100
53 #define NXMC_MAX_PLUGINS 100
54
55
56 //
57 // Integration points
58 //
59
60 #define NXMC_IP_CONTROL_PANEL 0x0001
61 #define NXMC_IP_MAIN_MENU 0x0002
62 #define NXMC_IP_PLUGIN_CONTEXT_MENU 0x0004
63
64
65 //
66 // Image lists
67 //
68
69 #define IMAGE_LIST_OBJECTS_SMALL 1
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
82
83
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
95 //
96 // Windows/UNIX compatibility defines
97 //
98
99 #ifdef _WIN32
100 #define NXMC_LIB_INSTANCE HINSTANCE
101 #define NXMC_LIB_INSTANCE_ARG(x) (x)
102 #define wxMAKEINTRESOURCE(x) MAKEINTRESOURCE(x)
103 #else
104 #define NXMC_LIB_INSTANCE int
105 #define NXMC_LIB_INSTANCE_ARG(x) 0
106 #define wxMAKEINTRESOURCE(x) NULL
107 #endif
108
109
110 //
111 // Plugin handle
112 //
113
114 typedef void * NXMC_PLUGIN_HANDLE;
115
116
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
134 typedef 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
191 //
192 // Predefined IDs
193 //
194
195 #define wxID_TREE_CTRL (wxID_HIGHEST + 500)
196 #define wxID_NOTEBOOK_CTRL (wxID_HIGHEST + 501)
197 #define wxID_LIST_CTRL (wxID_HIGHEST + 502)
198 #define wxID_TEXT_CTRL (wxID_HIGHEST + 503)
199
200
201 //
202 // Custom events
203 //
204
205 BEGIN_DECLARE_EVENT_TYPES()
206 DECLARE_EXPORTED_EVENT_TYPE(LIBNXMC_EXPORTABLE, nxEVT_REFRESH_VIEW, 0)
207 END_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)
216
217
218 //
219 // Menu/Control Panel item registration
220 //
221
222 class nxmcItemRegistration
223 {
224 private:
225 NXMC_PLUGIN_HANDLE m_plugin;
226 TCHAR *m_name;
227 int m_id;
228 int m_type;
229 void (*m_fpHandler)(int);
230
231 public:
232 nxmcItemRegistration(NXMC_PLUGIN_HANDLE plugin, const TCHAR *name, int id, int type, void (*fpHandler)(int));
233 ~nxmcItemRegistration();
234
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; }
239
240 void CallHandler(int param) { m_fpHandler(param); }
241 };
242
243 WX_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
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
264 //
265 // Code translation structure
266 //
267
268 struct CODE_TO_TEXT
269 {
270 int code;
271 TCHAR *text;
272 };
273
274
275 //
276 // Additional array and hash types
277 //
278
279 WX_DECLARE_HASH_MAP(DWORD, NXC_ALARM*, wxIntegerHash, wxIntegerEqual, nxAlarmList);
280
281
282 //
283 // Classes
284 //
285
286 #include "../libnxmc/nxview.h"
287 #include "../libnxmc/heading.h"
288
289
290 //
291 // Functions
292 //
293
294 void LIBNXMC_EXPORTABLE NXMCInitAUI(wxAuiManager *mgr, wxAuiNotebook *nb, wxWindow *defParent);
295 void LIBNXMC_EXPORTABLE NXMCInitializationComplete();
296
297 nxmcArrayOfRegItems LIBNXMC_EXPORTABLE &NXMCGetRegistrations();
298
299 bool LIBNXMC_EXPORTABLE NXMCLoadResources(const TCHAR *name, NXMC_LIB_INSTANCE instance, TCHAR *resName);
300
301 bool LIBNXMC_EXPORTABLE NXMCAddControlPanelItem(NXMC_PLUGIN_HANDLE handle, const TCHAR *name, int id);
302 bool LIBNXMC_EXPORTABLE NXMCAddViewMenuItem(NXMC_PLUGIN_HANDLE handle, const TCHAR *name, int id);
303
304 wxWindow LIBNXMC_EXPORTABLE *NXMCGetDefaultParent();
305 bool LIBNXMC_EXPORTABLE NXMCCreateView(nxView *view, int area);
306
307 void LIBNXMC_EXPORTABLE NXMCSetSession(NXC_SESSION session);
308 NXC_SESSION LIBNXMC_EXPORTABLE NXMCGetSession();
309
310 void LIBNXMC_EXPORTABLE InitViewTracker(wxAuiManager *mgr, wxAuiNotebook *nb);
311 void LIBNXMC_EXPORTABLE RegisterUniqueView(const TCHAR *name, nxView *view);
312 void LIBNXMC_EXPORTABLE UnregisterUniqueView(const TCHAR *name);
313 nxView LIBNXMC_EXPORTABLE *FindUniqueView(const TCHAR *name);
314 void LIBNXMC_EXPORTABLE ActivateView(nxView *view);
315
316 const TCHAR LIBNXMC_EXPORTABLE *NXMCCodeToText(int code, CODE_TO_TEXT *translator, const TCHAR *defaultText);
317 const TCHAR LIBNXMC_EXPORTABLE *NXMCGetStatusText(int status);
318 const TCHAR LIBNXMC_EXPORTABLE *NXMCGetStatusTextSmall(int status);
319 const TCHAR LIBNXMC_EXPORTABLE *NXMCGetAlarmStateName(int state);
320 const TCHAR LIBNXMC_EXPORTABLE *NXMCGetClassName(int objClass);
321 const TCHAR LIBNXMC_EXPORTABLE *NXMCGetIfTypeName(int type);
322 const TCHAR LIBNXMC_EXPORTABLE *NXMCGetNodeTypeName(int type);
323
324 void LIBNXMC_EXPORTABLE NXMCInitImageLists();
325 wxImageList LIBNXMC_EXPORTABLE *NXMCGetImageList(int list);
326 wxImageList LIBNXMC_EXPORTABLE *NXMCGetImageListCopy(int list);
327
328 void LIBNXMC_EXPORTABLE NXMCInitAlarms(DWORD count, NXC_ALARM *list);
329 void LIBNXMC_EXPORTABLE NXMCUpdateAlarms(DWORD code, NXC_ALARM *data);
330 nxAlarmList LIBNXMC_EXPORTABLE *NXMCGetAlarmList();
331 void LIBNXMC_EXPORTABLE NXMCUnlockAlarmList();
332
333 TCHAR LIBNXMC_EXPORTABLE *NXMCFormatTimeStamp(time_t timeStamp, TCHAR *buffer, int type);
334
335 void LIBNXMC_EXPORTABLE NXMCSaveListCtrlColumns(wxConfigBase *cfg, wxListCtrl &wndListCtrl, const TCHAR *prefix);
336 void LIBNXMC_EXPORTABLE NXMCLoadListCtrlColumns(wxConfigBase *cfg, wxListCtrl &wndListCtrl, const TCHAR *prefix);
337
338 #endif