api_skin.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. #ifndef __API_SKIN_H
  2. #define __API_SKIN_H
  3. #include <wasabicfg.h>
  4. #include <bfc/dispatch.h>
  5. class ifc_window;
  6. class GuiObject;
  7. class ColorThemeGroup;
  8. class ifc_xmlreaderparams;
  9. class SkinItem;
  10. #ifdef WASABI_COMPILE_CONFIG
  11. class CfgItem;
  12. #endif //WASABI_COMPILE_CONFIG
  13. #ifdef WASABI_COMPILE_WNDMGR
  14. class CfgItem;
  15. #endif //WASABI_COMPILE_WNDMGR
  16. #ifdef _WIN32
  17. #ifndef OSCURSOR
  18. #define OSCURSOR HICON
  19. #endif
  20. #elif defined(__APPLE__)
  21. #define OSCURSOR CGImageRef
  22. #endif
  23. class NOVTABLE api_skin : public Dispatchable
  24. {
  25. public:
  26. // skin colors
  27. ARGB32 skin_getColorElement(const wchar_t *type, const wchar_t **color_group = NULL);
  28. const ARGB32 *skin_getColorElementRef(const wchar_t *type, const wchar_t **color_group = NULL);
  29. const int *skin_getIterator();
  30. // possibly make a svc_skinloader
  31. void skin_switchSkin(const wchar_t *skin_name, const wchar_t *skin_path=NULL);
  32. void skin_unloadSkin();
  33. int loadSkinFile(const wchar_t *xmlfile);
  34. int loadGroupDefData(const wchar_t *groupdef, SkinItem **lastgroupitem);
  35. void unloadSkinPart(int skinpartid);
  36. const wchar_t *getSkinName();
  37. const wchar_t *getSkinPath();
  38. const wchar_t *getSkinsPath();
  39. const wchar_t *getDefaultSkinPath();
  40. // skin bitmaps
  41. ARGB32 *imgldr_requestSkinBitmap(const wchar_t *file, int *has_alpha, int *x, int *y, int *subw, int *subh, int *w, int *h, int cached);
  42. void imgldr_releaseSkinBitmap(ARGB32 *bmpbits);
  43. #ifdef WASABI_COMPILE_IMGLDR
  44. ARGB32 skin_getBitmapColor(const wchar_t *bitmapid);
  45. #endif
  46. // skin filters
  47. ARGB32 filterSkinColor(ARGB32 color, const wchar_t *elementid, const wchar_t *groupname);
  48. void reapplySkinFilters();
  49. int colortheme_getNumColorSets();
  50. const wchar_t *colortheme_enumColorSet(int n);
  51. int colortheme_getNumColorGroups(const wchar_t *colorset);
  52. const wchar_t *colortheme_enumColorGroupName(const wchar_t *colorset, int n);
  53. ColorThemeGroup *colortheme_enumColorGroup(int colorset, int n);
  54. ColorThemeGroup *colortheme_getColorGroup(const wchar_t *colorset, const wchar_t *colorgroup);
  55. void colortheme_setColorSet(const wchar_t *colorset);
  56. const wchar_t *colortheme_getColorSet();
  57. void colortheme_newColorSet(const wchar_t *set);
  58. void colortheme_updateColorSet(const wchar_t *set);
  59. void colortheme_renameColorSet(const wchar_t *set, const wchar_t *newname);
  60. void colortheme_deleteColorSet(const wchar_t *set);
  61. // groups
  62. ifc_window *group_create(const wchar_t *groupid, int scripts_enabled=1);
  63. int group_exists(const wchar_t *groupid);
  64. #ifdef WASABI_COMPILE_CONFIG
  65. ifc_window *group_create_cfg(const wchar_t *groupid, CfgItem *cfgitem, const wchar_t *attributename, int scripts_enabled=1);
  66. #endif // WASABI_COMPILE_CONFIG
  67. #ifdef WASABI_COMPILE_WNDMGR
  68. ifc_window *group_create_layout(const wchar_t *groupid, int scripts_enabled=1);
  69. #endif //WASABI_COMPILE_WNDMGR
  70. int group_destroy(ifc_window *group);
  71. int parse(const wchar_t *str, const wchar_t *how);
  72. GuiObject *xui_new(const wchar_t *classname);
  73. void xui_delete(GuiObject *o);
  74. OSCURSOR cursor_request(const wchar_t *id);
  75. int getNumGroupDefs();
  76. SkinItem *enumGroupDef(int n);
  77. ifc_window *group_createBySkinItem(SkinItem *groupitem, int scripts_enabled=1);
  78. SkinItem *getGroupDefAncestor(SkinItem *groupitem);
  79. int groupdef_getNumObjects(SkinItem *groupitem);
  80. SkinItem *groupdef_enumObject(SkinItem *item, int n);
  81. void skin_setLockUI(int l);
  82. int skin_getLockUI();
  83. double skin_getVersion();
  84. bool skin_isLoaded();
  85. enum {
  86. API_SKIN_SKIN_GETCOLORELEMENT = 0,
  87. API_SKIN_SKIN_GETCOLORELEMENTREF = 10,
  88. API_SKIN_SKIN_GETITERATOR = 20,
  89. API_SKIN_SKIN_SWITCHSKIN = 30,
  90. API_SKIN_SKIN_UNLOADSKIN = 35,
  91. API_SKIN_GETSKINNAME = 40,
  92. API_SKIN_GETSKINPATH = 50,
  93. API_SKIN_GETSKINSPATH = 60,
  94. API_SKIN_GETDEFAULTSKINPATH = 70,
  95. API_SKIN_IMGLDR_REQUESTSKINBITMAP = 80,
  96. API_SKIN_IMGLDR_RELEASESKINBITMAP = 90,
  97. API_SKIN_FILTERSKINCOLOR = 100,
  98. API_SKIN_REAPPLYSKINFILTERS = 110,
  99. API_SKIN_COLORTHEME_GETNUMCOLORSETS = 120,
  100. API_SKIN_COLORTHEME_ENUMCOLORSET = 130,
  101. API_SKIN_COLORTHEME_GETNUMCOLORGROUPS = 140,
  102. API_SKIN_COLORTHEME_ENUMCOLORGROUPNAME = 150,
  103. API_SKIN_COLORTHEME_ENUMCOLORGROUP = 160,
  104. API_SKIN_COLORTHEME_GETCOLORGROUP = 165,
  105. API_SKIN_COLORTHEME_SETCOLORSET = 170,
  106. API_SKIN_COLORTHEME_GETCOLORSET = 180,
  107. API_SKIN_COLORTHEME_NEWCOLORSET = 190,
  108. API_SKIN_COLORTHEME_RENAMESET = 191,
  109. API_SKIN_COLORTHEME_DELETE = 192,
  110. API_SKIN_COLORTHEME_UPDATECOLORSET = 193,
  111. API_SKIN_LOADSKINFILE = 200,
  112. API_SKIN_UNLOADSKINPART = 210,
  113. API_SKIN_GROUP_CREATE = 220,
  114. API_SKIN_GROUP_EXISTS = 225,
  115. #ifdef WASABI_COMPILE_CONFIG
  116. API_SKIN_GROUP_CREATE_CFG = 230,
  117. #endif // WASABI_COMPILE_CONFIG
  118. #ifdef WASABI_COMPILE_WNDMGR
  119. API_SKIN_GROUP_CREATE_LAYOUT = 240,
  120. #endif //WASABI_COMPILE_WNDMGR
  121. API_SKIN_GROUP_DESTROY = 250,
  122. API_SKIN_PARSE = 260,
  123. API_SKIN_XUI_NEW = 270,
  124. API_SKIN_XUI_DELETE = 280,
  125. API_SKIN_CURSOR_REQUEST = 290,
  126. API_SKIN_GETNUMGROUPS = 300,
  127. API_SKIN_ENUMGROUP = 310,
  128. API_SKIN_GROUP_CREATEBYITEM = 320,
  129. API_SKIN_GETGROUPANCESTOR = 330,
  130. API_SKIN_GROUPDEF_GETNUMOBJECTS = 340,
  131. API_SKIN_GROUPDEF_ENUMOBJECT = 350,
  132. API_SKIN_LOADGROUPDEFDATA = 360,
  133. API_SKIN_SETLOCKUI = 370,
  134. API_SKIN_GETLOCKUI = 380,
  135. API_SKIN_GETVERSION = 390,
  136. API_SKIN_GETBITMAPCOLOR = 400,
  137. API_SKIN_ISLOADED = 410,
  138. };
  139. };
  140. inline ARGB32 api_skin::skin_getColorElement(const wchar_t *type, const wchar_t **color_group) {
  141. return _call(API_SKIN_SKIN_GETCOLORELEMENT, (ARGB32)NULL, type, color_group);
  142. }
  143. inline const ARGB32 *api_skin::skin_getColorElementRef(const wchar_t *type, const wchar_t **color_group) {
  144. return _call(API_SKIN_SKIN_GETCOLORELEMENTREF, (ARGB32 *)NULL, type, color_group);
  145. }
  146. inline const int *api_skin::skin_getIterator() {
  147. return _call(API_SKIN_SKIN_GETITERATOR, (const int *)0);
  148. }
  149. inline void api_skin::skin_switchSkin(const wchar_t *skin_name, const wchar_t *skin_path) {
  150. _voidcall(API_SKIN_SKIN_SWITCHSKIN, skin_name, skin_path);
  151. }
  152. inline void api_skin::skin_unloadSkin() {
  153. _voidcall(API_SKIN_SKIN_UNLOADSKIN);
  154. }
  155. inline const wchar_t *api_skin::getSkinName() {
  156. return _call(API_SKIN_GETSKINNAME, (const wchar_t *)0);
  157. }
  158. inline const wchar_t *api_skin::getSkinPath() {
  159. return _call(API_SKIN_GETSKINPATH, (const wchar_t *)0);
  160. }
  161. inline const wchar_t *api_skin::getSkinsPath() {
  162. return _call(API_SKIN_GETSKINSPATH, (const wchar_t *)0);
  163. }
  164. inline const wchar_t *api_skin::getDefaultSkinPath() {
  165. return _call(API_SKIN_GETDEFAULTSKINPATH, (const wchar_t *)0);
  166. }
  167. inline ARGB32 *api_skin::imgldr_requestSkinBitmap(const wchar_t *file, int *has_alpha, int *x, int *y, int *subw, int *subh, int *w, int *h, int cached) {
  168. return _call(API_SKIN_IMGLDR_REQUESTSKINBITMAP, (ARGB32 *)NULL, file, has_alpha, x, y, subw, subh, w, h, cached);
  169. }
  170. inline void api_skin::imgldr_releaseSkinBitmap(ARGB32 *bmpbits) {
  171. _voidcall(API_SKIN_IMGLDR_RELEASESKINBITMAP, bmpbits);
  172. }
  173. inline ARGB32 api_skin::filterSkinColor(ARGB32 color, const wchar_t *elementid, const wchar_t *groupname) {
  174. return _call(API_SKIN_FILTERSKINCOLOR, (ARGB32)NULL, color, elementid, groupname);
  175. }
  176. inline void api_skin::reapplySkinFilters() {
  177. _voidcall(API_SKIN_REAPPLYSKINFILTERS);
  178. }
  179. inline int api_skin::colortheme_getNumColorSets() {
  180. return _call(API_SKIN_COLORTHEME_GETNUMCOLORSETS, (int)0);
  181. }
  182. inline const wchar_t *api_skin::colortheme_enumColorSet(int n) {
  183. return _call(API_SKIN_COLORTHEME_ENUMCOLORSET, (const wchar_t *)0, n);
  184. }
  185. inline int api_skin::colortheme_getNumColorGroups(const wchar_t *colorset) {
  186. return _call(API_SKIN_COLORTHEME_GETNUMCOLORGROUPS, (int)0, colorset);
  187. }
  188. inline const wchar_t *api_skin::colortheme_enumColorGroupName(const wchar_t *colorset, int n) {
  189. return _call(API_SKIN_COLORTHEME_ENUMCOLORGROUPNAME, (const wchar_t *)0, colorset, n);
  190. }
  191. inline ColorThemeGroup *api_skin::colortheme_enumColorGroup(int colorset, int n) {
  192. return _call(API_SKIN_COLORTHEME_ENUMCOLORGROUP, (ColorThemeGroup *)NULL, colorset, n);
  193. }
  194. inline ColorThemeGroup *api_skin::colortheme_getColorGroup(const wchar_t *colorset, const wchar_t *group) {
  195. return _call(API_SKIN_COLORTHEME_GETCOLORGROUP, (ColorThemeGroup *)NULL, colorset, group);
  196. }
  197. inline void api_skin::colortheme_setColorSet(const wchar_t *colorset)
  198. {
  199. _voidcall(API_SKIN_COLORTHEME_SETCOLORSET, colorset);
  200. }
  201. inline const wchar_t *api_skin::colortheme_getColorSet()
  202. {
  203. return _call(API_SKIN_COLORTHEME_GETCOLORSET, (const wchar_t *)0);
  204. }
  205. inline void api_skin::colortheme_newColorSet(const wchar_t *set) {
  206. _voidcall(API_SKIN_COLORTHEME_NEWCOLORSET, set);
  207. }
  208. inline void api_skin::colortheme_updateColorSet(const wchar_t *set) {
  209. _voidcall(API_SKIN_COLORTHEME_UPDATECOLORSET, set);
  210. }
  211. inline void api_skin::colortheme_renameColorSet(const wchar_t *set, const wchar_t *newname) {
  212. _voidcall(API_SKIN_COLORTHEME_RENAMESET, set, newname);
  213. }
  214. inline void api_skin::colortheme_deleteColorSet(const wchar_t *set) {
  215. _voidcall(API_SKIN_COLORTHEME_DELETE, set);
  216. }
  217. inline int api_skin::loadSkinFile(const wchar_t *xmlfile) {
  218. return _call(API_SKIN_LOADSKINFILE, (int)0, xmlfile);
  219. }
  220. inline void api_skin::unloadSkinPart(int skinpartid) {
  221. _voidcall(API_SKIN_UNLOADSKINPART, skinpartid);
  222. }
  223. inline ifc_window *api_skin::group_create(const wchar_t *groupid, int scripts_enabled) {
  224. return _call(API_SKIN_GROUP_CREATE, (ifc_window *)NULL, groupid, scripts_enabled);
  225. }
  226. inline int api_skin::group_exists(const wchar_t *groupid) {
  227. return _call(API_SKIN_GROUP_EXISTS, 1, groupid);
  228. }
  229. #ifdef WASABI_COMPILE_CONFIG
  230. inline ifc_window *api_skin::group_create_cfg(const wchar_t *groupid, CfgItem *cfgitem, const wchar_t *attributename, int scripts_enabled) {
  231. return _call(API_SKIN_GROUP_CREATE_CFG, (ifc_window *)NULL, groupid, cfgitem, attributename, scripts_enabled);
  232. }
  233. #endif // WASABI_COMPILE_CONFIG
  234. #ifdef WASABI_COMPILE_WNDMGR
  235. inline ifc_window *api_skin::group_create_layout(const wchar_t *groupid, int scripts_enabled) {
  236. return _call(API_SKIN_GROUP_CREATE_LAYOUT, (ifc_window *)NULL, groupid, scripts_enabled);
  237. }
  238. #endif //WASABI_COMPILE_WNDMGR
  239. inline int api_skin::group_destroy(ifc_window *group) {
  240. return _call(API_SKIN_GROUP_DESTROY, (int)0, group);
  241. }
  242. inline int api_skin::parse(const wchar_t *str, const wchar_t *how) {
  243. return _call(API_SKIN_PARSE, (int)0, str, how);
  244. }
  245. inline GuiObject *api_skin::xui_new(const wchar_t *classname) {
  246. return _call(API_SKIN_XUI_NEW, (GuiObject *)NULL, classname);
  247. }
  248. inline void api_skin::xui_delete(GuiObject *o) {
  249. _voidcall(API_SKIN_XUI_DELETE, o);
  250. }
  251. inline OSCURSOR api_skin::cursor_request(const wchar_t *id)
  252. {
  253. return _call(API_SKIN_CURSOR_REQUEST, (OSCURSOR)NULL, id);
  254. }
  255. inline int api_skin::getNumGroupDefs() {
  256. return _call(API_SKIN_GETNUMGROUPS, (int)0);
  257. }
  258. inline SkinItem *api_skin::enumGroupDef(int n) {
  259. return _call(API_SKIN_ENUMGROUP, (SkinItem *)NULL, n);
  260. }
  261. inline ifc_window *api_skin::group_createBySkinItem(SkinItem *item, int scripts_enabled) {
  262. return _call(API_SKIN_GROUP_CREATEBYITEM, (ifc_window *)NULL, item, scripts_enabled);
  263. }
  264. inline SkinItem *api_skin::getGroupDefAncestor(SkinItem *item) {
  265. return _call(API_SKIN_GETGROUPANCESTOR, (SkinItem *)NULL, item);
  266. }
  267. inline int api_skin::groupdef_getNumObjects(SkinItem *groupitem) {
  268. return _call(API_SKIN_GROUPDEF_GETNUMOBJECTS, 0, groupitem);
  269. }
  270. inline SkinItem *api_skin::groupdef_enumObject(SkinItem *item, int n) {
  271. return _call(API_SKIN_GROUPDEF_ENUMOBJECT, (SkinItem *)NULL, item, n);
  272. }
  273. inline int api_skin::loadGroupDefData(const wchar_t *groupdef, SkinItem **lastgroupitem) {
  274. return _call(API_SKIN_LOADGROUPDEFDATA, -1, groupdef, lastgroupitem);
  275. }
  276. inline void api_skin::skin_setLockUI(int l) {
  277. _voidcall(API_SKIN_SETLOCKUI, l);
  278. }
  279. inline int api_skin::skin_getLockUI() {
  280. return _call(API_SKIN_GETLOCKUI, 0);
  281. }
  282. inline double api_skin::skin_getVersion() {
  283. return _call(API_SKIN_GETVERSION, 0.8);
  284. }
  285. #ifdef WASABI_COMPILE_IMGLDR
  286. inline ARGB32 api_skin::skin_getBitmapColor(const wchar_t *bitmapid) {
  287. return _call(API_SKIN_GETBITMAPCOLOR, 0xFFFF00FF, bitmapid);
  288. }
  289. #endif
  290. inline bool api_skin::skin_isLoaded()
  291. {
  292. return _call(API_SKIN_ISLOADED, false);
  293. }
  294. class api_skinI : public api_skin
  295. {
  296. protected:
  297. api_skinI() {}
  298. virtual ~api_skinI() {}
  299. public:
  300. virtual ARGB32 skin_getColorElement(const wchar_t *type, const wchar_t **color_group = NULL)=0;
  301. virtual const ARGB32 *skin_getColorElementRef(const wchar_t *type, const wchar_t **color_group = NULL)=0;
  302. virtual const int *skin_getIterator()=0;
  303. virtual void skin_switchSkin(const wchar_t *skin_name, const wchar_t *skin_path=NULL)=0;
  304. virtual void skin_unloadSkin()=0;
  305. virtual const wchar_t *getSkinName()=0;
  306. virtual const wchar_t *getSkinPath()=0;
  307. virtual const wchar_t *getSkinsPath()=0;
  308. virtual const wchar_t *getDefaultSkinPath()=0;
  309. virtual ARGB32 *imgldr_requestSkinBitmap(const wchar_t *file, int *has_alpha, int *x, int *y, int *subw, int *subh, int *w, int *h, int cached)=0;
  310. virtual void imgldr_releaseSkinBitmap(ARGB32 *bmpbits)=0;
  311. virtual ARGB32 filterSkinColor(ARGB32 color, const wchar_t *elementid, const wchar_t *groupname)=0;
  312. virtual void reapplySkinFilters()=0;
  313. virtual int colortheme_getNumColorSets()=0;
  314. virtual const wchar_t *colortheme_enumColorSet(int n)=0;
  315. virtual int colortheme_getNumColorGroups(const wchar_t *colorset)=0;
  316. virtual const wchar_t *colortheme_enumColorGroupName(const wchar_t *colorset, int n)=0;
  317. virtual ColorThemeGroup *colortheme_enumColorGroup(int colorset, int n)=0;
  318. virtual ColorThemeGroup *colortheme_getColorGroup(const wchar_t *colorset, const wchar_t *group)=0;
  319. virtual void colortheme_setColorSet(const wchar_t *colorset)=0;
  320. virtual const wchar_t *colortheme_getColorSet()=0;
  321. virtual void colortheme_newColorSet(const wchar_t *set)=0;
  322. virtual void colortheme_updateColorSet(const wchar_t *set)=0;
  323. virtual void colortheme_renameColorSet(const wchar_t *set, const wchar_t *newname)=0;
  324. virtual void colortheme_deleteColorSet(const wchar_t *set)=0;
  325. virtual int loadSkinFile(const wchar_t *xmlfile)=0;
  326. virtual int loadGroupDefData(const wchar_t *groupdef, SkinItem **lastgroupitem)=0;
  327. virtual void unloadSkinPart(int skinpartid)=0;
  328. virtual ifc_window *group_create(const wchar_t *groupid, int scripts_enabled=1)=0;
  329. virtual int group_exists(const wchar_t *groupid)=0;
  330. #ifdef WASABI_COMPILE_CONFIG
  331. virtual ifc_window *group_create_cfg(const wchar_t *groupid, CfgItem *cfgitem, const wchar_t *attributename, int scripts_enabled=1)=0;
  332. #endif // WASABI_COMPILE_CONFIG
  333. #ifdef WASABI_COMPILE_WNDMGR
  334. virtual ifc_window *group_create_layout(const wchar_t *groupid, int scripts_enabled=1)=0;
  335. #endif //WASABI_COMPILE_WNDMGR
  336. virtual int group_destroy(ifc_window *group)=0;
  337. virtual int parse(const wchar_t *str, const wchar_t *how)=0;
  338. virtual GuiObject *xui_new(const wchar_t *classname)=0;
  339. virtual void xui_delete(GuiObject *o)=0;
  340. virtual OSCURSOR cursor_request(const wchar_t *id)=0;
  341. virtual int getNumGroupDefs()=0;
  342. virtual SkinItem *enumGroupDef(int n)=0;
  343. virtual ifc_window *group_createBySkinItem(SkinItem *item, int scripts_enabled=1)=0;
  344. virtual SkinItem *getGroupDefAncestor(SkinItem *groupitem)=0;
  345. virtual int groupdef_getNumObjects(SkinItem *groupitem)=0;
  346. virtual SkinItem *groupdef_enumObject(SkinItem *groupitem, int n)=0;
  347. virtual void skin_setLockUI(int l)=0;
  348. virtual int skin_getLockUI()=0;
  349. virtual double skin_getVersion()=0;
  350. #ifdef WASABI_COMPILE_IMGLDR
  351. virtual ARGB32 skin_getBitmapColor(const wchar_t *id)=0;
  352. #endif
  353. virtual bool skin_isLoaded()=0;
  354. protected:
  355. RECVS_DISPATCH;
  356. };
  357. // {F2398F09-63B0-4442-86C9-F8BC473F6DA7}
  358. static const GUID skinApiServiceGuid =
  359. { 0xf2398f09, 0x63b0, 0x4442, { 0x86, 0xc9, 0xf8, 0xbc, 0x47, 0x3f, 0x6d, 0xa7 } };
  360. extern api_skin *skinApi;
  361. #endif