1
0

widgets.cpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. #include <precomp.h>
  2. #include <api/skin/widgets.h>
  3. #include <api/skin/widgets/group.h>
  4. #ifdef WASABI_WIDGETS_LAYER
  5. #include <api/skin/widgets/layer.h>
  6. #endif
  7. #ifdef WASABI_WIDGETS_ANIMLAYER
  8. #include <api/skin/widgets/animlayer.h>
  9. #endif
  10. #ifdef WASABI_WIDGETS_BUTTON
  11. #include <api/skin/widgets/button.h>
  12. #endif
  13. #ifdef WASABI_WIDGETS_TGBUTTON
  14. #include <api/skin/widgets/tgbutton.h>
  15. #endif
  16. #ifdef WASABI_WIDGETS_GUIOBJECT
  17. #include <api/script/objects/guiobj.h>
  18. #endif
  19. #ifdef WASABI_WIDGETS_GROUPLIST
  20. #include <api/skin/widgets/grouplist.h>
  21. #endif
  22. #ifdef WASABI_WIDGETS_MOUSEREDIR
  23. #include <api/skin/widgets/mouseredir.h>
  24. #endif
  25. #ifdef WASABI_WIDGETS_SLIDER
  26. #include <api/skin/widgets/pslider.h>
  27. #endif
  28. #ifdef WASABI_WIDGETS_MEDIASLIDERS
  29. #include <api/skin/widgets/seqband.h>
  30. #include <api/skin/widgets/seqpreamp.h>
  31. #include <api/skin/widgets/svolbar.h>
  32. #include <api/skin/widgets/sseeker.h>
  33. #include <api/skin/widgets/spanbar.h>
  34. #endif
  35. #ifdef WASABI_WIDGETS_MEDIAVIS
  36. #include <api/skin/widgets/sa.h>
  37. #endif
  38. #ifdef WASABI_WIDGETS_MEDIAEQCURVE
  39. #include <api/skin/widgets/seqvis.h>
  40. #endif
  41. #ifdef WASABI_WIDGETS_MEDIASTATUS
  42. #include <api/skin/widgets/sstatus.h>
  43. #endif
  44. #ifdef _WIN32
  45. #include <api/skin/widgets/wa2/xuiwa2slider.h>
  46. #endif
  47. #ifdef WASABI_WIDGETS_SVCWND
  48. #include <api/skin/widgets/script/svcwnd.h>
  49. #endif
  50. #ifdef WASABI_WIDGETS_TEXT
  51. #include <api/skin/widgets/text.h>
  52. #endif
  53. #ifdef WASABI_WIDGETS_EDIT
  54. #include <api/skin/widgets/edit.h>
  55. #endif
  56. #ifdef WASABI_WIDGETS_TITLEBAR
  57. #include <api/skin/widgets/title.h>
  58. #endif
  59. #ifdef WASABI_WIDGETS_COMPBUCK
  60. #include <api/skin/widgets/compbuck2.h>
  61. #endif
  62. #ifdef WASABI_WIDGETS_BROWSER
  63. #include <api/skin/widgets/mb/xuibrowser.h>
  64. #ifdef WASABI_WIDGETS_BROWSERSVC
  65. #include <api/skin/widgets/mb/iebrowser.h>
  66. #include <api/skin/widgets/mb/mbsvc.h>
  67. #endif
  68. #endif
  69. #ifdef WASABI_WIDGETS_FRAME
  70. #include <api/skin/widgets/xuiframe.h>
  71. #endif
  72. #ifdef WASABI_WIDGETS_GRID
  73. #include <api/skin/widgets/xuigrid.h>
  74. #endif
  75. #ifdef WASABI_WIDGETS_QUERYDRAG
  76. #include <api/skin/widgets/xuiquerydrag.h>
  77. #endif
  78. #ifdef WASABI_WIDGETS_QUERYLIST
  79. #include <api/skin/widgets/db/xuiquerylist.h>
  80. #endif
  81. #ifdef WASABI_WIDGETS_FILTERLIST
  82. #include <api/skin/widgets/db/xuifilterlist.h>
  83. #endif
  84. #ifdef WASABI_WIDGETS_QUERYLINE
  85. #include <api/skin/widgets/db/xuiqueryline.h>
  86. #endif
  87. #ifdef WASABI_WIDGETS_WNDHOLDER
  88. #include <api/skin/widgets/xuiwndholder.h>
  89. #endif
  90. #ifdef WASABI_COMPILE_WNDMGR
  91. #ifdef WASABI_WIDGETS_LAYOUTSTATUS
  92. #include <api/skin/widgets/xuistatus.h>
  93. #endif
  94. #endif // wndmgr
  95. #ifdef WASABI_WIDGETS_TABSHEET
  96. #include <api/skin/widgets/xuitabsheet.h>
  97. #endif
  98. #ifdef WASABI_WIDGETS_CHECKBOX
  99. #include <api/skin/widgets/xuicheckbox.h>
  100. #endif
  101. #ifdef WASABI_WIDGETS_TITLEBOX
  102. #include <api/skin/widgets/xuititlebox.h>
  103. #endif
  104. #ifdef WASABI_WIDGETS_CUSTOMOBJECT
  105. #include <api/skin/widgets/xuicustomobject.h>
  106. #endif
  107. #ifdef WASABI_WIDGETS_OSWNDHOST
  108. #include <api/skin/widgets/xuioswndhost.h>
  109. #endif
  110. #ifdef WASABI_WIDGETS_RADIOGROUP
  111. #include <api/skin/widgets/xuiradiogroup.h>
  112. #endif
  113. #ifdef WASABI_TOOLOBJECT_HIDEOBJECT
  114. #include <api/skin/widgets/xuihideobject.h>
  115. #endif
  116. #ifdef WASABI_TOOLOBJECT_SENDPARAMS
  117. #include <api/skin/widgets/xuisendparams.h>
  118. #endif
  119. #ifdef WASABI_TOOLOBJECT_ADDPARAMS
  120. #include <api/skin/widgets/xuiaddparams.h>
  121. #endif
  122. #ifdef WASABI_WIDGETS_LIST
  123. #include <api/skin/widgets/xuilist.h>
  124. #endif
  125. #ifdef WASABI_WIDGETS_TREE
  126. #include <api/skin/widgets/xuitree.h>
  127. #endif
  128. #ifdef WASABI_WIDGETS_DROPDOWNLIST
  129. #include <api/skin/widgets/xuidropdownlist.h>
  130. #endif
  131. #ifdef WASABI_WIDGETS_COMBOBOX
  132. #include <api/skin/widgets/xuicombobox.h>
  133. #endif
  134. #ifdef WASABI_WIDGETS_HISTORYEDITBOX
  135. #include <api/skin/widgets/xuihistoryedit.h>
  136. #endif
  137. #ifdef WASABI_WIDGETS_OBJECTDIRECTORY
  138. #include <api/skin/widgets/xuiobjdirwnd.h>
  139. #endif
  140. #ifdef WASABI_WIDGETS_RECTANGLE
  141. #include <api/skin/widgets/xuirect.h>
  142. #endif
  143. #ifdef WASABI_WIDGETS_PATHPICKER
  144. #include <api/skin/widgets/xuipathpicker.h>
  145. #endif
  146. #ifdef WASABI_WIDGETS_GRADIENT
  147. #include <api/skin/widgets/xuigradientwnd.h>
  148. #endif
  149. #ifdef WASABI_WIDGETS_MENU
  150. #include <api/skin/widgets/xuimenu.h>
  151. #endif
  152. #include <api/skin/widgets/xuidownloadslist.h>
  153. #ifdef WASABI_COMPILE_STATSWND
  154. #include <api/skin/widgets/stats/xuistats.h>
  155. #include <api/skin/widgets/stats/statswnd.h>
  156. #endif
  157. extern StringW g_resourcepath;
  158. Widgets::Widgets() {
  159. count = 0;
  160. registerService(new XuiObjectCreator<GuiObjectXuiSvc>);
  161. #ifdef WASABI_WIDGETS_LAYER
  162. registerService(new XuiObjectCreator<LayerXuiSvc>);
  163. #endif
  164. #ifdef WASABI_WIDGETS_ANIMLAYER
  165. registerService(new XuiObjectCreator<AnimLayerXuiSvc>);
  166. #endif
  167. #ifdef WASABI_WIDGETS_BUTTON
  168. registerService(new XuiObjectCreator<ButtonXuiSvc>);
  169. #endif
  170. #ifdef WASABI_WIDGETS_TGBUTTON
  171. registerService(new XuiObjectCreator<ToggleButtonXuiSvc>);
  172. registerService(new XuiObjectCreator<nStatesTgButtonXuiSvc>);
  173. #endif
  174. #ifdef WASABI_WIDGETS_GROUPLIST
  175. registerService(new XuiObjectCreator<GroupListXuiSvc>);
  176. #endif
  177. #ifdef WASABI_WIDGETS_MOUSEREDIR
  178. registerService(new XuiObjectCreator<MouseRedirXuiSvc>);
  179. #endif
  180. #ifdef WASABI_WIDGETS_SLIDER
  181. registerService(new XuiObjectCreator<SliderXuiSvc>);
  182. #endif
  183. #ifdef _WIN32
  184. registerService(new XuiObjectCreator<Wa2SliderXuiSvc>);
  185. #endif
  186. #ifdef WASABI_WIDGETS_MEDIASLIDERS
  187. registerService(new XuiObjectCreator<EqBandXuiSvc>);
  188. registerService(new XuiObjectCreator<EqPreAmpXuiSvc>);
  189. registerService(new XuiObjectCreator<VolBarXuiSvc>);
  190. registerService(new XuiObjectCreator<SeekBarXuiSvc>);
  191. registerService(new XuiObjectCreator<PanBarXuiSvc>);
  192. #endif
  193. #ifdef WASABI_WIDGETS_MEDIAVIS
  194. registerService(new XuiObjectCreator<VisXuiSvc>);
  195. #endif
  196. #ifdef WASABI_WIDGETS_MEDIAEQCURVE
  197. registerService(new XuiObjectCreator<EqVisXuiSvc>);
  198. #endif
  199. #ifdef WASABI_WIDGETS_MEDIASTATUS
  200. registerService(new XuiObjectCreator<StatusXuiSvc>);
  201. #endif
  202. #ifdef WASABI_WIDGETS_SVCWND
  203. registerService(new XuiObjectCreator<SvcWndXuiSvc>);
  204. #endif
  205. #ifdef WASABI_WIDGETS_TEXT
  206. registerService(new XuiObjectCreator<TextXuiSvc>);
  207. #endif
  208. #ifdef WASABI_WIDGETS_EDIT
  209. registerService(new XuiObjectCreator<EditXuiSvc>);
  210. #endif
  211. #ifdef WASABI_WIDGETS_TITLEBAR
  212. registerService(new XuiObjectCreator<TitleBarXuiSvc>);
  213. #endif
  214. #ifdef WASABI_WIDGETS_COMPBUCK
  215. registerService(new XuiObjectCreator<ComponentBucketXuiSvc>);
  216. #endif
  217. #ifdef WASABI_WIDGETS_BROWSER
  218. registerService(new XuiObjectCreator<BrowserXuiSvc>);
  219. #ifdef WASABI_WIDGETS_BROWSERSVC
  220. registerService(new waServiceFactoryT<svc_miniBrowser, MbSvc>);
  221. #endif
  222. #endif
  223. #ifdef WASABI_WIDGETS_FRAME
  224. registerService(new XuiObjectCreator<FrameXuiSvc>);
  225. #endif
  226. #ifdef WASABI_WIDGETS_GRID
  227. registerService(new XuiObjectCreator<GridXuiSvc>);
  228. #endif
  229. #ifdef WASABI_WIDGETS_QUERYDRAG
  230. registerService(new XuiObjectCreator<QueryDragXuiSvc>);
  231. #endif
  232. #ifdef WASABI_COMPILE_METADB
  233. #ifdef WASABI_WIDGETS_QUERYLIST
  234. registerService(new XuiObjectCreator<QueryListXuiSvc>);
  235. #endif
  236. #ifdef WASABI_WIDGETS_FILTERLIST
  237. registerService(new XuiObjectCreator<FilterListXuiSvc>);
  238. #endif
  239. #ifdef WASABI_WIDGETS_QUERYLINE
  240. registerService(new XuiObjectCreator<QueryLineXuiSvc>);
  241. #endif
  242. #endif // metadb
  243. #ifdef WASABI_WIDGETS_WNDHOLDER
  244. registerService(new XuiObjectCreator<WindowHolderXuiSvc>);
  245. registerService(new XuiObjectCreator<WindowHolderXuiSvc2>);
  246. #endif // components
  247. #ifdef WASABI_COMPILE_WNDMGR
  248. #ifdef WASABI_WIDGETS_LAYOUTSTATUS
  249. registerService(new XuiObjectCreator<LayoutStatusXuiSvc>);
  250. #endif
  251. #endif // wndmgr
  252. #ifdef WASABI_WIDGETS_TABSHEET
  253. registerService(new XuiObjectCreator<ScriptTabSheetXuiSvc>);
  254. #endif
  255. #ifdef WASABI_WIDGETS_CHECKBOX
  256. registerService(new XuiObjectCreator<ScriptCheckBoxXuiSvc>);
  257. #endif
  258. #ifdef WASABI_WIDGETS_TITLEBOX
  259. registerService(new XuiObjectCreator<ScriptTitleBoxXuiSvc>);
  260. #endif
  261. #ifdef WASABI_WIDGETS_CUSTOMOBJECT
  262. registerService(new XuiObjectCreator<CustomObjectXuiSvc>);
  263. #endif
  264. #ifdef WASABI_WIDGETS_OSWNDHOST
  265. registerService(new XuiObjectCreator<OSWndHostXuiSvc>);
  266. #endif
  267. #ifdef WASABI_WIDGETS_RADIOGROUP
  268. registerService(new XuiObjectCreator<ScriptRadioGroupXuiSvc>);
  269. #endif
  270. #ifdef WASABI_TOOLOBJECT_HIDEOBJECT
  271. registerService(new XuiObjectCreator<HideObjectXuiSvc>);
  272. #endif
  273. #ifdef WASABI_TOOLOBJECT_SENDPARAMS
  274. registerService(new XuiObjectCreator<SendParamsXuiSvc>);
  275. #endif
  276. #ifdef WASABI_TOOLOBJECT_ADDPARAMS
  277. registerService(new XuiObjectCreator<AddParamsXuiSvc>);
  278. #endif
  279. #ifdef WASABI_WIDGETS_LIST
  280. registerService(new XuiObjectCreator<ScriptListXuiSvc>);
  281. #endif
  282. #ifdef WASABI_WIDGETS_TREE
  283. registerService(new XuiObjectCreator<ScriptTreeXuiSvc>);
  284. #endif
  285. #ifdef WASABI_WIDGETS_DROPDOWNLIST
  286. registerService(new XuiObjectCreator<DropDownListXuiSvc>);
  287. #endif
  288. #ifdef WASABI_WIDGETS_COMBOBOX
  289. registerService(new XuiObjectCreator<ComboBoxXuiSvc>);
  290. #endif
  291. #ifdef WASABI_WIDGETS_HISTORYEDITBOX
  292. registerService(new XuiObjectCreator<HistoryEditXuiSvc>);
  293. #endif
  294. #ifdef WASABI_WIDGETS_OBJECTDIRECTORY
  295. registerService(new XuiObjectCreator<ScriptObjDirWndXuiSvc>);
  296. #endif
  297. #ifdef WASABI_WIDGETS_RECTANGLE
  298. registerService(new XuiObjectCreator<ScriptRectXuiSvc>);
  299. #endif
  300. #ifdef WASABI_WIDGETS_PATHPICKER
  301. registerService(new XuiObjectCreator<PathPickerXuiSvc>);
  302. #endif
  303. #ifdef WASABI_WIDGETS_GRADIENT
  304. registerService(new XuiObjectCreator<GradientWndXuiSvc>);
  305. #endif
  306. #ifdef WASABI_WIDGETS_MENU
  307. registerService(new XuiObjectCreator<MenuXuiSvc>);
  308. #endif
  309. //registerService(new XuiObjectCreator<DownloadsListXuiSvc>);
  310. #ifdef WASABI_COMPILE_WNDMGR
  311. //registerSkinFile("xml/msgbox/msgbox.xml");
  312. #endif
  313. #ifdef WASABI_WIDGETS_TOOLTIPS
  314. //registerSkinFile("xml/tooltips/tooltips.xml");
  315. #endif
  316. #ifdef WASABI_COMPILE_STATSWND
  317. registerService(new XuiObjectCreator<XuiStatsXuiSvc>);
  318. statswnd = new StatsWnd();
  319. #endif
  320. //loadResources();
  321. WASABI_API_SYSCB->syscb_registerCallback(static_cast<SysCallbackI *>(this));
  322. }
  323. Widgets::~Widgets() {
  324. #ifdef WASABI_COMPILE_STATSWND
  325. delete statswnd;
  326. #endif
  327. WASABI_API_SYSCB->syscb_deregisterCallback(static_cast<SysCallbackI *>(this));
  328. if (WASABI_API_SVC != NULL)
  329. {
  330. int i=factories.getNumItems();
  331. while (i--)
  332. WASABI_API_SVC->service_deregister(factories[i]);
  333. }
  334. factories.deleteAll();
  335. }
  336. void Widgets::registerService(waServiceFactoryI *f)
  337. {
  338. WASABI_API_SVC->service_register(f);
  339. factories.addItem(f);
  340. }
  341. int Widgets::skincb_onBeforeLoadingElements() {
  342. if (count++ > 0) // if 0, we're already loaded so that the lib is usable without 'a skin'
  343. loadResources();
  344. return 1;
  345. }
  346. void Widgets::loadResources()
  347. {
  348. // TODO: benski> want to put this into gen_ff somewhere, instead.
  349. WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,L"xml\\winamp\\cover\\cover.xml"));
  350. WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,L"xml\\winamp\\thinger\\thinger.xml"));
  351. #ifndef WA3COMPATIBILITY // ifNdef
  352. WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,L"xml\\wasabi\\wasabi.xml"));
  353. #endif
  354. #ifdef WASABI_WIDGETS_PATHPICKER
  355. WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,L"xml\\pathpicker\\pathpicker.xml"));
  356. #endif
  357. #ifdef WASABI_WIDGETS_LAYOUTSTATUS
  358. WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,L"xml\\statusbar\\statusbar.xml"));
  359. #endif
  360. #ifdef WASABI_WIDGETS_TABSHEET
  361. WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,L"xml\\tabsheet\\tabsheet.xml"));
  362. #endif
  363. #ifdef WASABI_WIDGETS_CHECKBOX
  364. WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,L"xml\\checkbox\\checkbox.xml"));
  365. #endif
  366. #ifdef WASABI_WIDGETS_TITLEBOX
  367. WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,L"xml\\titlebox\\titlebox.xml"));
  368. #endif
  369. #ifdef WASABI_WIDGETS_DROPDOWNLIST
  370. WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,L"xml\\dropdownlist\\dropdownlist.xml"));
  371. #endif
  372. #ifdef WASABI_WIDGETS_COMBOBOX
  373. WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,L"xml\\combobox\\combobox.xml"));
  374. #endif
  375. #ifdef WASABI_WIDGETS_HISTORYEDITBOX
  376. WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,L"xml\\historyeditbox\\historyeditbox.xml"));
  377. #endif
  378. #ifdef WASABI_WIDGETS_TOOLTIPS
  379. WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,L"xml\\tooltips\\tooltips.xml"));
  380. #endif
  381. #ifdef WASABI_COMPILE_WNDMGR
  382. //WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,"xml\\msgbox\\msgbox.xml"));
  383. #endif
  384. WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,L"xml\\about\\about.xml"));
  385. }