123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294 |
- #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
|