1
0

wac.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. #ifndef _WAC_H
  2. #define _WAC_H
  3. #include <api/wac/compdb.h>//CUT
  4. #include <bfc/ptrlist.h>
  5. #include <api/config/items/cfgitemi.h>
  6. class ifc_canvas; // see canvas.h
  7. class CfgItem; // see cfgitem
  8. class CfgItemI;
  9. class ComponentAPI; // see api.h
  10. class api_window; // see rootwnd.h
  11. class LoadableResource; // see below
  12. // this tells wasabi what version of the SDK we're compiled with
  13. // this number will be incremented every once in a while. when it is, you'll
  14. // have to recompile
  15. // 5 -> build #471
  16. // 6 -> build rc1
  17. // 7 -> build 484 (rc5)
  18. // 8 -> Winamp 5.23 (build 608)
  19. // 9 -> Winamp 5.4
  20. #define WA_COMPONENT_VERSION 9
  21. #define DB_DENY 0
  22. #define DB_ALLOW 1
  23. // commands for onNotify below
  24. #define WAC_NOTIFY_NOP 0
  25. #define WAC_NOTIFY_ACTIVATE 10
  26. #define WAC_NOTIFY_DEACTIVATE 20
  27. #define WAC_NOTIFY_FULLSCREEN 30
  28. #define WAC_NOTIFY_RESTORE 40
  29. #define WAC_NOTIFY_ENTERRESIZE 50
  30. #define WAC_NOTIFY_LEAVERESIZE 51
  31. #define WAC_NOTIFY_SYSTRAYDONE 60
  32. #define WAC_NOTIFY_POPUPDONE 61
  33. #define WAC_NOTIFY_BASETEXTUREWINDOW 78
  34. #define WAC_NOTIFY_LOADEARLY 90
  35. #define WAC_NOTIFY_MENU_COMMAND 10000
  36. // this message is sent when service runlevel notifies are sent
  37. // param1 = msg
  38. // param2 = param1
  39. // param3 = param2
  40. #define WAC_NOTIFY_SERVICE_NOTIFY 100
  41. #define WAC_NOTIFY_SKINUNLOADING 0xE300 // before unloading current skin
  42. #define WAC_NOTIFY_SWITCHINGSKIN 0xE301 // right after unloading current skin and right before loading new one, getSkinName/Path points to new skin
  43. #define WAC_NOTIFY_SKINELEMENTSLOADED 0xE302 // after skin elements definitions are loaded
  44. #define WAC_NOTIFY_BEFORELOADINGSKINELEMENTS 0xE303 // before skin elements definitions are loaded, trap this to load your elements/groups and let people override them
  45. #define WAC_NOTIFY_SKINGUILOADED 0xE304 // after skin GUI objects are loaded from xml
  46. #define WAC_NOTIFY_SKINLOADED 0xE305 // after skin is fully loaded
  47. enum {
  48. RSF_STATIC=0,
  49. RSF_RELATIVETOWAC=1,
  50. RSF_RELATIVETOTHEME=2,
  51. };
  52. // -----------
  53. #include <bfc/dispatch.h>
  54. class NOVTABLE WaComponent : public Dispatchable {
  55. public:
  56. // provide your component name & other info here
  57. const wchar_t *getName() { return _call(GETNAME, (wchar_t *)NULL); }
  58. GUID getGUID() { return _call(GETGUID, INVALID_GUID); }
  59. #ifdef WASABINOMAINAPI
  60. void registerServices(api_service *a) { _voidcall(REGISTERSERVICES2, a); }
  61. #else
  62. void registerServices(ComponentAPI *a) { _voidcall(REGISTERSERVICES, a); }
  63. #endif
  64. void deregisterServices() { _voidcall(DEREGISTERSERVICES); }
  65. void onCreate() { _voidcall(ONCREATE); }
  66. void onDestroy() { _voidcall(ONDESTROY); }
  67. //DEPRECATED: will go away
  68. api_window *createWindow(int n, api_window *parentWnd) { return _call(CREATEWINDOW, (api_window*)NULL, n, parentWnd); }
  69. int onNotify(int cmd, int param1=0, int param2=0, int param3=0, int param4=0){
  70. return _call(ONNOTIFY, 0, cmd, param1, param2, param3, param4);
  71. }
  72. // everything after cmd is for future expansion
  73. int onCommand(const wchar_t *cmd, int param1, int param2, void *ptr, int ptrlen){
  74. return _call(ONCOMMAND, 0, cmd, param1, param2, ptr, ptrlen);
  75. }
  76. // gets the CfgItem * from WAComponentClient
  77. CfgItem *getCfgInterface(int n) {
  78. return _call(GETCFGINTERFACE, (CfgItem*)NULL, n);
  79. }
  80. // saves the OSMODULEHANDLE of your WAC for you
  81. void setOSModuleHandle(OSMODULEHANDLE modulehandle) {
  82. _voidcall(SETOSMODULEHANDLE, modulehandle);
  83. }
  84. OSMODULEHANDLE getOSModuleHandle() {
  85. return _call(GETOSMODULEHANDLE, (OSMODULEHANDLE)0);
  86. }
  87. // saves the path of your WAC for you
  88. void setComponentPath(const wchar_t *path) {
  89. _voidcall(SETPATH, path);
  90. }
  91. const wchar_t *getComponentPath() {
  92. return _call(GETPATH, (const wchar_t *)NULL);
  93. }
  94. enum {
  95. GETNAME=100,
  96. GETGUID=120,
  97. REGISTERSERVICES=200,
  98. REGISTERSERVICES2=210,
  99. ONCREATE=400,
  100. ONDESTROY=410,
  101. CREATEWINDOW=420,
  102. ONNOTIFY=500,
  103. ONCOMMAND=600,
  104. GETCFGINTERFACE=800,
  105. SETHINSTANCE=900, SETOSMODULEHANDLE=900, // note dups for back-compat
  106. GETHINSTANCE=910, GETOSMODULEHANDLE=910, // note dups for back-compat
  107. DEREGISTERSERVICES=1000,
  108. SETPATH=1100,
  109. GETPATH=1200,
  110. };
  111. };
  112. // hides the dispatchable interface
  113. class NOVTABLE WaComponentI : public WaComponent {
  114. protected:
  115. WaComponentI() {} // protect constructor
  116. public:
  117. virtual const wchar_t *getName()=0;
  118. virtual GUID getGUID()=0;
  119. #ifdef WASABINOMAINAPI
  120. virtual void registerServices(api_service *)=0;
  121. #else
  122. virtual void registerServices(ComponentAPI *)=0;
  123. #endif
  124. virtual int RegisterServicesSafeModeOk()=0;
  125. virtual void deregisterServices()=0;
  126. virtual void onCreate()=0;
  127. virtual void onDestroy()=0;
  128. virtual api_window *createWindow(int n, api_window *parentWnd)=0; //DEPRECATED
  129. virtual int onNotify(int cmd, int param1, int param2, int param3, int param4)=0;
  130. virtual int onCommand(const wchar_t *cmd, int param1, int param2, void *ptr, int ptrlen)=0;
  131. virtual CfgItem *getCfgInterface(int n)=0;
  132. virtual void setOSModuleHandle(OSMODULEHANDLE moduleHandle)=0;
  133. virtual OSMODULEHANDLE getOSModuleHandle()=0;
  134. virtual void setComponentPath(const wchar_t *path)=0;
  135. virtual const wchar_t *getComponentPath()=0;
  136. private:
  137. virtual void internal_onDestroy()=0;
  138. virtual int internal_onNotify(int cmd, int param1, int param2, int param3, int param4)=0; // calls thru to onNotify after processing
  139. RECVS_DISPATCH;
  140. };
  141. class waServiceFactoryI;
  142. /**
  143. */
  144. class NOVTABLE WAComponentClient : public WaComponentI, public CfgItemI
  145. {
  146. protected:
  147. WAComponentClient(const wchar_t *name=NULL);
  148. public:
  149. virtual ~WAComponentClient() {}
  150. // provide your component name & other info here
  151. virtual const wchar_t *getName(); //OVERRIDE ME (or just set name in constructor)
  152. virtual GUID getGUID()=0; // be sure to override this one //OVERRIDE ME
  153. #ifdef WASABINOMAINAPI
  154. void registerServices(api_service *); // don't override
  155. #else
  156. void registerServices(ComponentAPI *); // don't override
  157. #endif
  158. int RegisterServicesSafeModeOk();
  159. void deregisterServices(); // don't override
  160. // override these to receive notifications
  161. virtual void onRegisterServices() {}// register extra services here
  162. virtual void onCreate() {} // init stuff
  163. virtual void onDestroy() {} // destroy everything here, not in ~
  164. //DEPRECATED: will go away
  165. // this is moving to svc_wndcreate
  166. virtual api_window *createWindow(int n, api_window *parentWnd) { return NULL; }
  167. // OVERRIDE ME for various events
  168. virtual int onNotify(int cmd, int param1, int param2, int param3, int param4) { return 0; }
  169. // everything after cmd is for future expansion
  170. virtual int onCommand(const wchar_t *cmd, int param1, int param2, void *ptr, int ptrlen) { return 0; }
  171. // config ptr... you can override this and provide a different *
  172. // otherwise 'this' will be returned
  173. virtual CfgItem *getCfgInterface(int n);
  174. // saves the OSMODULEHANDLE of your WAC for you
  175. void setOSModuleHandle(OSMODULEHANDLE moduleHandle) { OSModuleHandle = moduleHandle; };
  176. OSMODULEHANDLE getOSModuleHandle() { return OSModuleHandle; }
  177. void setComponentPath(const wchar_t *path) { componentpath = path; };
  178. const wchar_t *getComponentPath() { return componentpath; }
  179. OSMODULEHANDLE gethInstance() { return getOSModuleHandle(); } //DEPRECATED
  180. // various options to register during your constructor, like services,
  181. // skin parts, and autopop guids. just register them and forget them
  182. void registerService(waServiceFactoryI* service);
  183. void registerSkinFile(const wchar_t *filename, int relative=RSF_RELATIVETOWAC);
  184. /* benski> cut
  185. void registerAutoPopup(GUID guid, const wchar_t *description, const wchar_t *prefered_container=NULL, int container_required=FALSE);
  186. void registerAutoPopup(const wchar_t *groupid, const wchar_t *description, const wchar_t *container_layout=NULL, int container_required=FALSE);
  187. void registerCfgItem(CfgItemI *cfgitem, int autodelete=FALSE);
  188. void registerExtension(const wchar_t *extension, const wchar_t *description, const wchar_t *family=NULL);
  189. void registerCallback(SysCallback *_callback, void *_param = NULL);
  190. void registerPrefGroup(const wchar_t *groupname, const wchar_t *dest, GUID pref_guid, GUID pref_guid_parent=INVALID_GUID);*/
  191. // or register your own resource types here
  192. void registerResource(LoadableResource *res);
  193. virtual void onSkinLoaded() {}
  194. private:
  195. virtual void internal_onDestroy();
  196. virtual int internal_onNotify(int cmd, int param1, int param2, int param3, int param4);
  197. OSMODULEHANDLE OSModuleHandle;
  198. int postregisterservices; // if 1, onRegisterServices has been called
  199. PtrList<LoadableResource> resources;
  200. StringW componentpath;
  201. };
  202. extern "C" {
  203. typedef void (*WACINIT)(OSMODULEHANDLE);
  204. typedef UINT (*WACGETVERSION)(void); // returns the interface version component was compiled with
  205. typedef WaComponent *(*WACENUMCOMPONENT)(int n);
  206. };
  207. class LoadableResource {
  208. public:
  209. virtual ~LoadableResource() {}
  210. virtual int deleteOnShutdown() { return TRUE; } // return FALSE if you're static
  211. virtual void onRegisterServices() {}
  212. virtual void onDeregisterServices() {} // unload during this one
  213. virtual void beforeLoadingSkinElements() {}
  214. };
  215. #endif