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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
|
#ifndef _SVC_OBJECTDIR_H
#define _SVC_OBJECTDIR_H
#include <bfc/dispatch.h>
#include <bfc/string/StringW.h>
#include <api/service/services.h>
#include <api/syscb/callbacks/runlevelcb.h>
// there is class ObjectDir in bfc/wnds, you should derive from it
// also class ContextCmdObjDir
typedef size_t ObjectHandle;
#define INVALID_OBJECT_HANDLE ((ObjectHandle)0)
#define DD_OBJECTDIR L"service:svc_objectDir"
class ifc_window;
class ifc_dependent;
class BaseCanvas;
class svc_objectDir : public Dispatchable
{
public:
static int getServiceType() { return WaSvc::OBJECTDIR; }
static const wchar_t *dragitem_getDatatype() { return DD_OBJECTDIR; }
static const GUID *depend_getClassGuid() {
// {2364D110-0F12-40d4-BBAE-D2DA174751B5}
static const GUID ret =
{ 0x2364d110, 0xf12, 0x40d4, { 0xbb, 0xae, 0xd2, 0xda, 0x17, 0x47, 0x51, 0xb5 } };
return &ret;
}
api_dependent *getDependencyPtr();
const wchar_t *getDirType();
int getNumObjects();
ObjectHandle enumObject(int n);
void *getObject(ObjectHandle handle);
const wchar_t *getObjectLabel(ObjectHandle handle);
int setObjectLabel(ObjectHandle handle, const wchar_t *newlabel);
ObjectHandle insertObject(const wchar_t *parameter=NULL, const wchar_t *label=NULL, const wchar_t *path=NULL);
int removeObject(ObjectHandle handle);
void clearAll();
const wchar_t *getObjectPath(ObjectHandle handle);
const wchar_t *getObjectDisplayGroup(ObjectHandle handle);
const wchar_t *getObjectIcon(ObjectHandle handle);
int getObjectSelectable(ObjectHandle handle);
int getObjectSortOrder(ObjectHandle handle); // -32767..32767
// tagging
int tagObject(const wchar_t *tag, ObjectHandle handle, int exclusive=FALSE);
int untagObject(const wchar_t *tag, ObjectHandle handle);
ObjectHandle enumObjectByTag(const wchar_t *tag, int n);
int isTagged(const wchar_t *tag, ObjectHandle handle);
int onAction(int action, ifc_window *from, const wchar_t *target, ObjectHandle handle);
enum {
ODACTION_SELECTED=100,
ODACTION_DESELECTED=200,
ODACTION_CONTEXTMENU=300,
};
int contextMenu(ifc_window *from, int x, int y, ObjectHandle handle);
void onPrerender(ObjectHandle handle, const RECT *r, BaseCanvas *c, int style);
void onPostrender(ObjectHandle handle, const RECT *r, BaseCanvas *c, int style);
// render styles
enum {
RENDERSTYLE_TREEWND=10,
};
// dependency events, param is handle of object in question
enum {
Event_OBJECT_ADDED=100,
Event_OBJECT_REMOVED=110,
Event_OBJECT_LABELCHANGE=200,
Event_OBJECT_ICONCHANGE=300,
Event_OBJECT_PATHCHANGE=400,
Event_OBJECT_SELECTABLECHANGE=500,
Event_OBJECT_SORTORDERCHANGE=600,
Event_OBJECT_TAGCHANGE=700,
};
// dispatchable codes
enum {
GETDEPENDENCYPTR=100,
GETNUMOBJECTS=200,
ENUMOBJECT=300,
GETOBJECT=400,
GETOBJECTLABEL=500,
SETOBJECTLABEL=510,
INSERTOBJECT=600,
REMOVEOBJECT=610,
CLEARALL=700,
GETDIRTYPE=800,
ONACTION=900,
ONPRERENDER=1000,
ONPOSTRENDER=1010,
GETOBJECTPATH=1100,
GETOBJECTDISPLAYGROUP=1200,
GETOBJECTICON=1300,
GETOBJECTSELECTABLE=1400,
GETOBJECTSORTORDER=1500,
TAGOBJECT=1600,
UNTAGOBJECT=1700,
ENUMOBJECTBYTAG=1800,
ISTAGGED=1900,
CONTEXTMENU=3000,
};
};
inline
api_dependent *svc_objectDir::getDependencyPtr() {
return _call(GETDEPENDENCYPTR, (api_dependent*)NULL);
}
inline
const wchar_t *svc_objectDir::getDirType() {
return _call(GETDIRTYPE, (const wchar_t *)NULL);
}
inline
int svc_objectDir::getNumObjects() {
return _call(GETNUMOBJECTS, 0);
}
inline
ObjectHandle svc_objectDir::enumObject(int n) {
return _call(ENUMOBJECT, INVALID_OBJECT_HANDLE, n);
}
inline
void *svc_objectDir::getObject(ObjectHandle handle) {
return _call(GETOBJECT, (void*)NULL, handle);
}
inline
const wchar_t *svc_objectDir::getObjectLabel(ObjectHandle handle) {
return _call(GETOBJECTLABEL, (const wchar_t *)NULL, handle);
}
inline
int svc_objectDir::setObjectLabel(ObjectHandle handle, const wchar_t *newlabel) {
return _call(SETOBJECTLABEL, 0, handle, newlabel);
}
inline
ObjectHandle svc_objectDir::insertObject(const wchar_t *parameter, const wchar_t *label, const wchar_t *path) {
return _call(INSERTOBJECT, INVALID_OBJECT_HANDLE, parameter, label, path);
}
inline
int svc_objectDir::removeObject(ObjectHandle handle) {
return _call(REMOVEOBJECT, 0, handle);
}
inline
void svc_objectDir::clearAll() {
_voidcall(CLEARALL);
}
inline
const wchar_t *svc_objectDir::getObjectPath(ObjectHandle handle) {
return _call(GETOBJECTPATH, (const wchar_t *)NULL, handle);
}
inline
const wchar_t *svc_objectDir::getObjectDisplayGroup(ObjectHandle handle) {
return _call(GETOBJECTDISPLAYGROUP, L"", handle);
}
inline
const wchar_t *svc_objectDir::getObjectIcon(ObjectHandle handle) {
return _call(GETOBJECTICON, (const wchar_t *)NULL, handle);
}
inline
int svc_objectDir::getObjectSelectable(ObjectHandle handle) {
return _call(GETOBJECTSELECTABLE, TRUE, handle);
}
inline
int svc_objectDir::getObjectSortOrder(ObjectHandle handle) {
return _call(GETOBJECTSORTORDER, 0, handle);
}
inline
int svc_objectDir::tagObject(const wchar_t *tag, ObjectHandle handle, int exclusive) {
return _call(TAGOBJECT, 0, tag, handle, exclusive);
}
inline
int svc_objectDir::untagObject(const wchar_t *tag, ObjectHandle handle) {
return _call(UNTAGOBJECT, 0, tag, handle);
}
inline
ObjectHandle svc_objectDir::enumObjectByTag(const wchar_t *tag, int n) {
return _call(ENUMOBJECTBYTAG, INVALID_OBJECT_HANDLE, tag, n);
}
inline
int svc_objectDir::isTagged(const wchar_t *tag, ObjectHandle handle) {
return _call(ISTAGGED, 0, tag, handle);
}
inline
int svc_objectDir::onAction(int action, ifc_window *from, const wchar_t *target, ObjectHandle handle) {
return _call(ONACTION, 0, action, from, target, handle);
}
inline
int svc_objectDir::contextMenu(ifc_window *from, int x, int y, ObjectHandle handle) {
return _call(CONTEXTMENU, 0, from, x, y, handle);
}
inline
void svc_objectDir::onPrerender(ObjectHandle handle, const RECT *r, BaseCanvas *c, int style) {
_voidcall(ONPRERENDER, handle, r, c, style);
}
inline
void svc_objectDir::onPostrender(ObjectHandle handle, const RECT *r, BaseCanvas *c, int style) {
_voidcall(ONPOSTRENDER, handle, r, c, style);
}
/**
Service implementation. Usually you'll derive from ObjectDir, not this.
You can still derive from this if you want to fully implement the interface yourself for some reason though.
@see ObjectDir
*/
class svc_objectDirI : public svc_objectDir {
public:
virtual api_dependent *getDependencyPtr()=0;
virtual const wchar_t *getDirType()=0;
virtual int getNumObjects()=0;
virtual ObjectHandle enumObject(int n)=0;
virtual void *getObject(ObjectHandle handle)=0;
virtual const wchar_t *getObjectLabel(ObjectHandle handle)=0;
virtual int setObjectLabel(ObjectHandle handle, const wchar_t *newlabel)=0;
virtual ObjectHandle insertObject(const wchar_t *parameter=NULL, const wchar_t *label=NULL, const wchar_t *path=NULL)=0;
virtual int removeObject(ObjectHandle handle)=0;
virtual void clearAll()=0;
virtual const wchar_t *getObjectPath(ObjectHandle handle)=0;
virtual const wchar_t *getObjectDisplayGroup(ObjectHandle handle)=0;
virtual const wchar_t *getObjectIcon(ObjectHandle handle)=0;
virtual int getObjectSelectable(ObjectHandle handle)=0;
virtual int getObjectSortOrder(ObjectHandle handle)=0;
virtual int tagObject(const wchar_t *tag, ObjectHandle handle, int exclusive=FALSE)=0;
virtual int untagObject(const wchar_t *tag, ObjectHandle handle)=0;
virtual ObjectHandle enumObjectByTag(const wchar_t *tag, int n)=0;
virtual int isTagged(const wchar_t *tag, ObjectHandle handle)=0;
virtual int onAction(int action, ifc_window *from, const wchar_t *target, ObjectHandle handle)=0;
// return -1 to request renaming the item, 0 normally
virtual int contextMenu(ifc_window *from, int x, int y, ObjectHandle handle)=0;
virtual void onPrerender(ObjectHandle handle, const RECT *r, BaseCanvas *c, int style) { }
virtual void onPostrender(ObjectHandle handle, const RECT *r, BaseCanvas *c, int style) { }
protected:
RECVS_DISPATCH;
};
#include <api/service/servicei.h>
template <class T>
class ObjectDirCreator : public waServiceFactoryTSingle<svc_objectDir, T> { };
#include <api/service/svc_enum.h>
class ObjectDirEnum : public SvcEnumT<svc_objectDir> {
public:
ObjectDirEnum(const wchar_t *_name) : name(_name) {}
virtual int testService(svc_objectDir *svc) {
return !WCSICMP(svc->getDirType(), name);
}
private:
StringW name;
};
#endif
|