1
0

skinparse.cpp 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822
  1. #include <precomp.h>
  2. #include <api.h>
  3. #include <api/skin/widgets/mb/scriptbrowser.h>
  4. #include <api/skin/skinparse.h>
  5. #include <api/script/scriptmgr.h>
  6. //#include <api/wac/main.h>//CUT!!
  7. #include <api/skin/skinfont.h>
  8. #include <api/skin/skin.h>
  9. #include <api/skin/skinelem.h>
  10. #include <api/font/font.h>
  11. #include <api/wndmgr/snappnt.h>
  12. #include <bfc/parse/pathparse.h>
  13. #include <api/skin/guitree.h>
  14. #ifdef WASABI_COMPILE_COMPONENTS
  15. #include <api/wac/compon.h>
  16. #endif
  17. #include <api/service/svc_enum.h>
  18. #include <api/script/objects/guiobject.h>
  19. #ifdef WASABI_COMPILE_WNDMGR
  20. #include <api/wndmgr/autopopup.h>
  21. #endif
  22. #include <bfc/parse/paramparser.h>
  23. #include <api/skin/gammamgr.h>
  24. #include <bfc/util/profiler.h>
  25. #ifdef WASABI_COMPILE_LOCALES
  26. #include <api/locales/xlatstr.h>
  27. #include <api/locales/localesmgr.h>
  28. #else
  29. #define _
  30. #endif
  31. #include <bfc/string/stringdict.h>
  32. #include <api/skin/widgets.h>
  33. #ifdef _WIN32
  34. extern HINSTANCE hInstance;
  35. #endif
  36. #define COLOR_WHITE (0xffffff)
  37. #define COLOR_BLACK (0x000000)
  38. #define COLOR_ERROR (0xff00ff)
  39. // with alpha
  40. #define COLOR_WHITEA (0xffffffff)
  41. #define COLOR_BLACKA (0xff000000)
  42. #define COLOR_ERRORA (0xffff00ff)
  43. xml_tag taglist[] = {
  44. {L"groupdef", XML_TAG_GROUPDEF, 1},
  45. {L"group", XML_TAG_GROUP, 1},
  46. {L"cfggroup", XML_TAG_CFGGROUP, 1},
  47. {L"elements", XML_TAG_ELEMENTS, 1},
  48. {L"snappoint", XML_TAG_SNAPPOINT, 0},
  49. {L"script", XML_TAG_SCRIPT, 0},
  50. {L"container", XML_TAG_CONTAINER, 1},
  51. {L"layout", XML_TAG_LAYOUT, 1},
  52. {L"elements", XML_ELEMENTTAG_ELEMENTS, 1},
  53. {L"accelerators", XML_TAG_ACCELERATORS, 1},
  54. {L"accelerator", XML_TAG_ACCELERATOR, 1},
  55. {L"stringtable", XML_TAG_STRINGTABLE, 1},
  56. {L"stringentry", XML_TAG_STRINGENTRY, 1},
  57. };
  58. BEGIN_STRINGDICTIONARY(_resizevalues)
  59. SDI(L"top", RESIZE_TOP);
  60. SDI(L"left", RESIZE_LEFT);
  61. SDI(L"right", RESIZE_RIGHT);
  62. SDI(L"bottom", RESIZE_BOTTOM);
  63. SDI(L"topleft", RESIZE_TOPLEFT);
  64. SDI(L"topright", RESIZE_TOPRIGHT);
  65. SDI(L"bottomleft", RESIZE_BOTTOMLEFT);
  66. SDI(L"bottomright", RESIZE_BOTTOMRIGHT);
  67. END_STRINGDICTIONARY(_resizevalues, resizevalues)
  68. BEGIN_STRINGDICTIONARY(_parsetypes)
  69. SDI(L"resize", PARSETYPE_RESIZE);
  70. SDI(L"color", PARSETYPE_COLOR);
  71. SDI(L"coloralpha", PARSETYPE_COLORALPHA);
  72. SDI(L"regionop", PARSETYPE_REGIONOP);
  73. SDI(L"internal_action", PARSETYPE_INTERNALACTION);
  74. SDI(L"group_inheritance", PARSETYPE_GROUPINHERITANCE);
  75. END_STRINGDICTIONARY(_parsetypes, parsetypes)
  76. BEGIN_STRINGDICTIONARY(_actionlist)
  77. SDI(L"none", ACTION_NONE);
  78. #ifdef WA3COMPATIBILITY
  79. SDI(L"about", ACTION_ABOUT);
  80. SDI(L"mb_forward", ACTION_MB_FORWARD);
  81. SDI(L"mb_back", ACTION_MB_BACK);
  82. SDI(L"mb_url", ACTION_MB_URL);
  83. SDI(L"mb_home", ACTION_MB_HOME);
  84. SDI(L"mb_stop", ACTION_MB_STOP);
  85. SDI(L"mb_refresh", ACTION_MB_REFRESH);
  86. SDI(L"text_larger", ACTION_TEXT_LARGER);
  87. SDI(L"text_smaller", ACTION_TEXT_SMALLER);
  88. SDI(L"preferences", ACTION_PREFERENCES);
  89. SDI(L"view_file_info", ACTION_VIEW_FILE_INFO);
  90. SDI(L"doublesize", ACTION_DOUBLESIZE);
  91. SDI(L"add_bookmark", ACTION_ADD_BOOKMARK);
  92. SDI(L"menu", ACTION_MENU);
  93. SDI(L"sysmenu", ACTION_SYSMENU);
  94. SDI(L"windowmenu", ACTION_WINDOWMENU);
  95. SDI(L"controlmenu", ACTION_CONTROLMENU);
  96. #endif // wa3compatibility
  97. #ifdef WASABI_WIDGETS_COMPBUCK
  98. SDI(L"cb_next", ACTION_CB_NEXT);
  99. SDI(L"cb_prev", ACTION_CB_PREV);
  100. SDI(L"cb_prevpage", ACTION_CB_PREVPAGE);
  101. SDI(L"cb_nextpage", ACTION_CB_NEXTPAGE);
  102. #endif
  103. #ifdef WASABI_COMPILE_WNDMGR
  104. SDI(L"endmodal", ACTION_ENDMODAL);
  105. SDI(L"minimize", ACTION_MINIMIZE);
  106. SDI(L"maximize", ACTION_MAXIMIZE);
  107. SDI(L"close", ACTION_CLOSE);
  108. SDI(L"close_window", ACTION_CLOSE_WINDOW);
  109. SDI(L"switch", ACTION_SWITCH);
  110. SDI(L"toggle", ACTION_TOGGLE);
  111. SDI(L"reload_skin", ACTION_RELOAD_SKIN);
  112. SDI(L"enforce_minmax", ACTION_ENFORCEMINMAX);
  113. SDI(L"toggle_always_on_top", ACTION_TOGGLE_ALWAYS_ON_TOP);
  114. #endif // wndmgr
  115. END_STRINGDICTIONARY(_actionlist, actionlist)
  116. #ifdef WASABI_COMPILE_MEDIACORE
  117. BEGIN_STRINGDICTIONARY(_displaylist)
  118. SDI(L"songname", DISPLAY_SONGNAME);
  119. SDI(L"songinfo", DISPLAY_SONGINFO);
  120. SDI(L"songartist", DISPLAY_SONGARTIST);
  121. SDI(L"songtitle", DISPLAY_SONGTITLE);
  122. SDI(L"songalbum", DISPLAY_SONGALBUM);
  123. SDI(L"songlength", DISPLAY_SONGLENGTH);
  124. SDI(L"time", DISPLAY_TIME);
  125. SDI(L"timeelapsed", DISPLAY_TIME);
  126. SDI(L"timeremaining", DISPLAY_TIME);
  127. SDI(L"componentbucket", DISPLAY_CB);
  128. SDI(L"songbitrate", DISPLAY_SONGBITRATE);
  129. SDI(L"songsamplerate", DISPLAY_SONGSAMPLERATE);
  130. SDI(L"songinfo_localise", DISPLAY_SONGINFO_TRANSLATED);
  131. END_STRINGDICTIONARY(_displaylist, displaylist)
  132. #endif // mediacore
  133. static GUID staticguid;
  134. void SkinParser::initialize()
  135. {
  136. if (!quickxmltaglist.getNumItems())
  137. {
  138. for (int i = 0;i < sizeof(taglist) / sizeof(xml_tag);i++)
  139. quickxmltaglist.addItem(&taglist[i]);
  140. }
  141. // first two are for back compatibility
  142. skinXML.registerCallback(L"WinampAbstractionLayer", xmlReaderCallback);
  143. skinXML.registerCallback(L"WinampAbstractionLayer\f*", xmlReaderCallback);
  144. skinXML.registerCallback(L"WasabiXML", xmlReaderCallback);
  145. skinXML.registerCallback(L"WasabiXML\f*", xmlReaderCallback);
  146. guiTree = new GuiTree();
  147. xuiCache = new SvcCacheT<svc_xuiObject>;
  148. }
  149. void SkinParser::shutdown()
  150. {
  151. skinXML.unregisterCallback((void*)xmlReaderCallback);
  152. delete guiTree; guiTree = NULL;
  153. delete xuiCache; xuiCache = NULL;
  154. }
  155. #ifdef WASABI_COMPILE_WNDMGR
  156. void SkinParser::setInitialFocus()
  157. {
  158. for (int i = 0;i < containers.getNumItems();i++)
  159. {
  160. if (containers[i]->isVisible())
  161. {
  162. Layout *l = containers[i]->getCurrentLayout();
  163. if (l)
  164. {
  165. l->setFocus();
  166. return ;
  167. }
  168. }
  169. }
  170. #ifdef WIN32
  171. #ifdef WA3COMPATIBILITY
  172. SetFocus(Main::gethWnd());
  173. #endif //WA3COMPATIBILITY
  174. #else
  175. DebugString( "portme -- SkinParser::setInitialFocus\n" );
  176. #endif //WIN32
  177. }
  178. #endif
  179. #ifdef WASABI_COMPILE_WNDMGR
  180. // do not forget to popParserState(); before returning
  181. int SkinParser::loadContainers(const wchar_t *skin)
  182. {
  183. wchar_t olddir[WA_MAX_PATH] = {0};
  184. Wasabi::Std::getCurDir(olddir, WA_MAX_PATH);
  185. Wasabi::Std::setCurDir(WASABI_API_APP->path_getAppPath());
  186. int oldncontains = getNumContainers();
  187. pushParserState();
  188. allowscripts = 1;
  189. centerskin = 1;
  190. staticloading = 1;
  191. instantiatinggroup = 0;
  192. transcientcontainer = 0;
  193. inContainer = inLayout = 0;
  194. curGroup = NULL;
  195. recording_container = 0;
  196. recording_groupdef = 0;
  197. inElements = inGroup = inGroupDef = inAccelerators = inStringTable = 0;
  198. includepath = WASABI_API_SKIN->getSkinPath();
  199. loading_main_skinfile = 0;
  200. SkinElementsMgr::onBeforeLoadingSkinElements(includepath);
  201. GammaMgr::onBeforeLoadingGammaGroups();
  202. scriptId = WASABI_API_PALETTE->getSkinPartIterator();
  203. int skinType = Skin::checkSkin(skin);
  204. int retcode = 0;
  205. loading_main_skinfile = 1;
  206. switch (skinType)
  207. {
  208. case Skin::CHKSKIN_UNKNOWN:
  209. popParserState();
  210. break;
  211. #ifdef WA3COMPATIBILITY
  212. case Skin::CHKSKIN_ISWA2:
  213. retcode = XmlReader::loadFile("svc:wa2skinxml", includepath);
  214. break;
  215. #endif
  216. default:
  217. {
  218. retcode = skinXML.loadFile(StringPathCombine(includepath, L"skin.xml"), includepath);
  219. break;
  220. }
  221. }
  222. int n = guiTree->getNumObject(XML_TAG_CONTAINER);
  223. for (int i = 0;i < n;i++)
  224. {
  225. SkinItem *item = guiTree->getObject(XML_TAG_CONTAINER, i);
  226. if (item && item->getParams())
  227. {
  228. if (item->getParams()->getItemValueInt(L"dynamic"))
  229. {
  230. if (item->getParams()->getItemValueInt(L"default_visible"))
  231. {
  232. const wchar_t *name = item->getParams()->getItemValue(L"name");
  233. #ifdef ON_TWEAK_CONTAINER_NAMEW
  234. ON_TWEAK_CONTAINER_NAMEW(name);
  235. #endif
  236. wchar_t c[512]=L"-";
  237. #ifdef WASABI_COMPILE_CONFIG
  238. WASABI_API_CONFIG->getStringPrivate(StringPrintfW(L"everloaded/%s", name), c, 511, L"-");
  239. #endif
  240. c[510] = 0;
  241. if (c[0] == '-')
  242. {
  243. // never been created, create it now since it has default_visible
  244. staticloading = 0;
  245. /*Container *c = */instantiateDynamicContainer(item);
  246. staticloading = 1;
  247. }
  248. }
  249. }
  250. }
  251. }
  252. loading_main_skinfile = 0;
  253. Wasabi::Std::setCurDir(olddir);
  254. int ncontainersloaded = getNumContainers() - oldncontains;
  255. if (retcode == 0 || ncontainersloaded == 0)
  256. {
  257. return 0;
  258. }
  259. #ifdef WASABI_COMPILE_CONFIG
  260. WASABI_API_CONFIG->setStringPrivate(L"last_skin", Skin::getSkinName());
  261. #endif
  262. ASSERT(tha != NULL);
  263. SkinElementsMgr::onAfterLoadingSkinElements();
  264. GammaMgr::onAfterLoadingGammaGroups();
  265. #ifdef WASABI_COMPILE_COMPONENTS
  266. ComponentManager::broadcastNotify(WAC_NOTIFY_SKINGUILOADED, WASABI_API_PALETTE->getSkinPartIterator());
  267. #endif
  268. Skin::sendGuiLoadedCallback();
  269. popParserState();
  270. return ncontainersloaded;
  271. }
  272. void SkinParser::centerSkin()
  273. {
  274. RECT sr;
  275. if (centerskin && getSkinRect(&sr))
  276. {
  277. int l = getNumContainers();
  278. int w = (Wasabi::Std::getScreenWidth() - (sr.right - sr.left)) / 2;
  279. int h = (Wasabi::Std::getScreenHeight() - (sr.bottom - sr.top)) / 2;
  280. for (int i = 0;i < l;i++)
  281. {
  282. Container *c = enumContainer(i);
  283. if (!c->isVisible()) continue;
  284. Layout *l = c->getCurrentLayout();
  285. RECT r;
  286. l->getWindowRect(&r);
  287. r.left += w;
  288. r.right += w;
  289. r.bottom += h;
  290. r.top += h;
  291. l->move(r.left, r.top);
  292. }
  293. }
  294. foreach(containers)
  295. containers.getfor()->savePositions();
  296. endfor;
  297. }
  298. int SkinParser::getSkinRect(RECT *r, ifc_window *exclude)
  299. {
  300. if (!r) return 0;
  301. ZERO(*r);
  302. Container *cexcluded = NULL;
  303. if (exclude != NULL)
  304. {
  305. Layout *l = static_cast<Layout *>(exclude->getDesktopParent());
  306. if (l != NULL) cexcluded = l->getParentContainer();
  307. }
  308. int x = 99999, y = 99999, x2 = -1, y2 = -1;
  309. int l = getNumContainers();
  310. for (int i = 0;i < l;i++)
  311. {
  312. Container *c = enumContainer(i);
  313. if (c == cexcluded) continue;
  314. if (!c->isInited()) c->onInit();
  315. if (c->isDeleting() || !c->getCurrentLayout()) continue;
  316. int cx = c->getDefaultPositionX();
  317. int cy = c->getDefaultPositionY();
  318. if (cx == -1) cx = 0;
  319. if (cy == -1) cy = 0;
  320. RECT r;
  321. c->getWindowRect(&r);
  322. int cw = r.right - r.left;
  323. int ch = r.bottom - r.top;
  324. if (cx < x) x = cx;
  325. if (cy < y) y = cy;
  326. if ((cx + cw) > x2) x2 = cx + cw;
  327. if ((cy + ch) > y2) y2 = cy + ch;
  328. }
  329. if (x2 > 0 && y2 > 0 && x != 99999 && y != 99999)
  330. {
  331. Wasabi::Std::setRect(r, x, y, x2, y2);
  332. return 1;
  333. }
  334. return 0;
  335. }
  336. #endif
  337. // do not forget to popParserState(); before returning
  338. void SkinParser::loadScriptXml(const wchar_t *filename, int scriptid)
  339. {
  340. pushParserState();
  341. allowscripts = 1;
  342. instantiatinggroup = 0;
  343. #ifdef WASABI_COMPILE_WNDMGR
  344. transcientcontainer = 0;
  345. inContainer = inLayout = 0;
  346. #endif
  347. staticloading = 1;
  348. recording_container = 0;
  349. recording_groupdef = 0;
  350. curGroup = NULL;
  351. inElements = inGroup = inGroupDef = inAccelerators = inStringTable = 0;
  352. scriptId = scriptid;
  353. //CUT char file[WA_MAX_PATH];
  354. //CUT char drive[WA_MAX_PATH];
  355. //CUT char dir[WA_MAX_PATH];
  356. //CUT char fname[WA_MAX_PATH];
  357. //CUT char ext[WA_MAX_PATH];
  358. includepath.setValue(L"");
  359. wchar_t olddir[WA_MAX_PATH] = {0};
  360. Wasabi::Std::getCurDir(olddir, WA_MAX_PATH);
  361. Wasabi::Std::setCurDir(WASABI_API_APP->path_getAppPath());
  362. if (!WCSNICMP(filename, L"buf:", 4))
  363. {
  364. skinXML.loadFile(filename, includepath);
  365. }
  366. else
  367. {
  368. //CUT DebugString("filename is %s\n", filename);
  369. includepath = filename;
  370. includepath.RemovePath();
  371. skinXML.loadFile(filename /*file*/, includepath);
  372. }
  373. Wasabi::Std::setCurDir(olddir);
  374. popParserState();
  375. }
  376. #ifdef WASABI_COMPILE_WNDMGR
  377. // do not forget to popParserState(); before returning
  378. Container *SkinParser::loadContainerForWindowHolder(const wchar_t *groupid, GUID g, int initit, int transcient, const wchar_t *containerid, int container_flag)
  379. {
  380. ASSERTPR((g == INVALID_GUID || groupid == NULL) && (g != INVALID_GUID || groupid != NULL), "sorry, one or the other, indulge aristotle");
  381. pushParserState();
  382. allowscripts = 1;
  383. instantiatinggroup = 0;
  384. transcientcontainer = transcient;
  385. staticloading = 0;
  386. recording_container = 0;
  387. recording_groupdef = 0;
  388. curContainer = NULL;
  389. lastCreatedContainer = NULL;
  390. curGroup = NULL;
  391. inContainer = inLayout = inElements = inGroup = inGroupDef = inAccelerators = inStringTable = 0;
  392. scriptId = -1; //WASABI_API_PALETTE->getSkinPartIterator();
  393. SkinItem *found = NULL;
  394. SkinItem *generic = NULL;
  395. for (int i = guiTree->getNumObject(XML_TAG_CONTAINER) - 1;i >= 0 && found == NULL;i--)
  396. {
  397. SkinItem *item = guiTree->getObject(XML_TAG_CONTAINER, i);
  398. if (item == NULL) continue;
  399. ifc_xmlreaderparams *par = item->getParams();
  400. if (!par) continue;
  401. if (g != INVALID_GUID)
  402. {
  403. for (size_t j = 0;found == NULL && j != par->getNbItems();j++)
  404. {
  405. const wchar_t *p = par->getItemName(j);
  406. if (!WCSICMP(p, L"component") || !WCSICMP(p, L"hold"))
  407. {
  408. ParamParser pp(par->getItemValue(j));
  409. if (pp.hasGuid(g) && found == NULL)
  410. {
  411. found = item;
  412. break;
  413. }
  414. if (generic == NULL && (pp.hasGuid(GENERIC_GUID) || pp.hasString(L"@ALL@")))
  415. {
  416. generic = item;
  417. }
  418. }
  419. }
  420. }
  421. else if (groupid != NULL)
  422. {
  423. for (size_t j = 0;j != par->getNbItems() && found == NULL;j++)
  424. {
  425. const wchar_t *p = par->getItemName(j);
  426. if (!WCSICMP(p, L"hold"))
  427. {
  428. ParamParser pp(par->getItemValue(j));
  429. if (pp.hasString(groupid))
  430. {
  431. found = item;
  432. break;
  433. }
  434. if (pp.hasString(L"@ALL@"))
  435. {
  436. generic = item;
  437. }
  438. }
  439. }
  440. }
  441. }
  442. if (found == NULL && generic == NULL)
  443. {
  444. popParserState();
  445. return NULL;
  446. }
  447. if (!found)
  448. {
  449. if (containerid != NULL)
  450. {
  451. SkinItem *item = guiTree->getContainerById(containerid);
  452. if (item != NULL)
  453. {
  454. Container *c = instantiateDynamicContainer(item, initit);
  455. popParserState();
  456. return c;
  457. }
  458. }
  459. else
  460. {
  461. if (container_flag != 0) return NULL;
  462. }
  463. }
  464. Container *c = instantiateDynamicContainer(found != NULL ? found : generic, initit);
  465. popParserState();
  466. return c;
  467. }
  468. Container *SkinParser::instantiateDynamicContainer(SkinItem *containeritem, int initit)
  469. {
  470. int quit = 0;
  471. int guitreeid = guiTree->getObjectIdx(containeritem);
  472. for (int i = guitreeid;i < guiTree->getNumObject() && !quit;i++)
  473. {
  474. SkinItem *ii = guiTree->getList()->enumItem(i);
  475. ifc_xmlreaderparams *params = ii->getParams();
  476. const wchar_t *path = ii->getXmlRootPath();
  477. if (path)
  478. includepath = path;
  479. int object_type = guiTree->getObjectType(ii);
  480. const wchar_t *name = ii->getName();
  481. if (!params)
  482. {
  483. if (object_type == XML_TAG_CONTAINER)
  484. quit = 1;
  485. _onXmlEndElement(object_type, name);
  486. }
  487. else
  488. {
  489. _onXmlStartElement(object_type, name, params);
  490. }
  491. }
  492. return lastCreatedContainer;
  493. }
  494. // do not forget to popParserState(); before returning
  495. Container *SkinParser::newDynamicContainer(const wchar_t *containerid, int transcient)
  496. {
  497. pushParserState();
  498. allowscripts = 1;
  499. instantiatinggroup = 0;
  500. transcientcontainer = transcient;
  501. staticloading = 0;
  502. recording_container = 0;
  503. recording_groupdef = 0;
  504. curContainer = NULL;
  505. lastCreatedContainer = NULL;
  506. curGroup = NULL;
  507. inContainer = inLayout = inElements = inGroup = inGroupDef = inAccelerators = inStringTable = 0;
  508. scriptId = WASABI_API_PALETTE->getSkinPartIterator();
  509. SkinItem *found = NULL;
  510. for (int i = guiTree->getNumObject(XML_TAG_CONTAINER) - 1;i >= 0 && found == NULL;i--)
  511. {
  512. SkinItem *item = guiTree->getObject(XML_TAG_CONTAINER, i);
  513. ifc_xmlreaderparams *par = item->getParams();
  514. if (!par) continue;
  515. const wchar_t *p = par->getItemValue(L"id");
  516. if (!WCSICMP(p, containerid))
  517. {
  518. found = item;
  519. break;
  520. }
  521. }
  522. Container *c = NULL;
  523. if (found != NULL)
  524. c = instantiateDynamicContainer(found);
  525. popParserState();
  526. return c;
  527. }
  528. #endif
  529. // do not forget to popParserState(); before returning
  530. void SkinParser::fillGroup(Group *group, const wchar_t *groupid, SkinItem *specific_item, int params_only, int no_params, int scripts_enabled)
  531. {
  532. ASSERT(group != NULL);
  533. pushParserState();
  534. instantiatinggroup = 1;
  535. #ifdef WASABI_COMPILE_WNDMGR
  536. transcientcontainer = 0;
  537. #endif
  538. allowscripts = scripts_enabled;
  539. staticloading = 0;
  540. recording_container = 0;
  541. recording_groupdef = 0;
  542. lastCreatedGroup = NULL;
  543. scriptId = group->getSkinPartId();
  544. SkinItem *found = NULL;
  545. PtrList<ifc_xmlreaderparams> ancestor_param_list;
  546. found = specific_item == NULL ? guiTree->getGroupDef(groupid) : specific_item;
  547. if (found == NULL)
  548. {
  549. popParserState();
  550. return ;
  551. }
  552. curGroup = group;
  553. inGroup = 1;
  554. parseGroup(found, &ancestor_param_list, params_only);
  555. if (!no_params)
  556. {
  557. XmlObject *xo = static_cast<XmlObject *>(curGroup->getScriptObject()->vcpu_getInterface(xmlObjectGuid));
  558. for (int i = ancestor_param_list.getNumItems() - 1;i >= 0;i--)
  559. initXmlObject(xo, ancestor_param_list.enumItem(i), 1);
  560. }
  561. popParserState();
  562. }
  563. GuiObject *SkinParser::newDynamicGroup(const wchar_t *groupid, int grouptype, SkinItem *specific_item, int specific_scriptid, int scripts_enabled)
  564. {
  565. #ifdef WASABI_COMPILE_CONFIG
  566. int iscfggroup = (grouptype == GROUP_CFGGROUP);
  567. #endif
  568. #ifdef WASABI_COMPILE_WNDMGR
  569. int islayoutgroup = (grouptype == GROUP_LAYOUTGROUP);
  570. #endif
  571. Group *r = NULL;
  572. #ifdef WASABI_COMPILE_CONFIG
  573. if (!iscfggroup)
  574. {
  575. #endif
  576. #ifdef WASABI_COMPILE_WNDMGR
  577. if (!islayoutgroup)
  578. r = new Group;
  579. else
  580. {
  581. Layout *l = new Layout;
  582. r = l;
  583. l->setParentContainer(NULL);
  584. }
  585. #else // wndmgr
  586. r = new Group;
  587. #endif // wndmgr
  588. #ifdef WASABI_COMPILE_CONFIG
  589. }
  590. else
  591. r = new CfgGroup;
  592. #endif
  593. r->setSkinPartId(specific_scriptid > -1 ? specific_scriptid : WASABI_API_PALETTE->getSkinPartIterator());
  594. if (r != NULL)
  595. {
  596. r->setXmlParam(L"id", groupid);
  597. r->setGroupContent(groupid, specific_item, scripts_enabled);
  598. fillGroup(r, groupid, specific_item, 1, 0, scripts_enabled);
  599. return r->getGuiObject();
  600. }
  601. return NULL;
  602. }
  603. void SkinParser::pushParserState()
  604. {
  605. parser_status *p = new parser_status;
  606. #ifdef WASABI_COMPILE_WNDMGR
  607. p->curContainer = curContainer;
  608. p->curLayout = curLayout;
  609. p->inContainer = inContainer;
  610. p->inLayout = inLayout;
  611. p->transcientcontainer = transcientcontainer;
  612. #endif
  613. p->staticloading = staticloading;
  614. p->curGroup = curGroup;
  615. p->includepath = includepath;
  616. p->inElements = inElements;
  617. p->inGroup = inGroup;
  618. p->inGroupDef = inGroupDef;
  619. p->instantiatinggroup = instantiatinggroup;
  620. p->scriptid = scriptId;
  621. p->allowscripts = allowscripts;
  622. p->inAccelerators = inAccelerators;
  623. p->inStringTable = inStringTable;
  624. statusstack.addItem(p);
  625. }
  626. void SkinParser::popParserState()
  627. {
  628. ASSERT(statusstack.getNumItems() > 0);
  629. parser_status *p = statusstack.enumItem(statusstack.getNumItems() - 1);
  630. statusstack.removeByPos(statusstack.getNumItems() - 1);
  631. ASSERT(p != NULL);
  632. #ifdef WASABI_COMPILE_WNDMGR
  633. curContainer = p->curContainer;
  634. curLayout = p->curLayout;
  635. inContainer = p->inContainer;
  636. inLayout = p->inLayout;
  637. transcientcontainer = p->transcientcontainer;
  638. #endif
  639. curGroup = p->curGroup;
  640. includepath = p->includepath;
  641. inElements = p->inElements;
  642. inAccelerators = p->inAccelerators;
  643. inStringTable = p->inStringTable;
  644. inGroup = p->inGroup;
  645. inGroupDef = p->inGroupDef;
  646. staticloading = p->staticloading;
  647. instantiatinggroup = p->instantiatinggroup;
  648. scriptId = p->scriptid;
  649. allowscripts = p->allowscripts;
  650. delete p;
  651. }
  652. #ifdef WASABI_COMPILE_WNDMGR
  653. Container *SkinParser::getContainer(const wchar_t *id)
  654. {
  655. for (int i = 0;i < containers.getNumItems();i++)
  656. if (!WCSICMP(id, containers.enumItem(i)->getId()))
  657. return containers.enumItem(i);
  658. return NULL;
  659. }
  660. Layout *SkinParser::getLayout(const wchar_t *contlay)
  661. {
  662. PathParserW pp(contlay, L",");
  663. if (pp.getNumStrings() == 2)
  664. {
  665. Container *c = SkinParser::getContainer(pp.enumString(0));
  666. if (c)
  667. {
  668. Layout *l = c->getLayout(pp.enumString(1));
  669. if (l)
  670. {
  671. return l;
  672. }
  673. }
  674. }
  675. return NULL;
  676. }
  677. int SkinParser::script_getNumContainers()
  678. {
  679. return containers.getNumItems();
  680. }
  681. Container *SkinParser::script_enumContainer(int n)
  682. {
  683. return containers.enumItem(n);
  684. }
  685. int SkinParser::isContainer(Container *c)
  686. {
  687. return containers.haveItem(c);
  688. }
  689. Container *SkinParser::script_getContainer(const wchar_t *id)
  690. {
  691. for (int i = 0;i < containers.getNumItems();i++)
  692. {
  693. Container *c = containers.enumItem(i);
  694. if (c)
  695. {
  696. const wchar_t *c_id = containers.enumItem(i)->getId();
  697. if (c_id && !WCSICMP(id, c_id))
  698. return containers.enumItem(i);
  699. }
  700. }
  701. return NULL;
  702. }
  703. void SkinParser::componentToggled(GUID *g, int visible)
  704. {
  705. for (int i = 0;i < containers.getNumItems();i++)
  706. containers[i]->componentToggled(g, visible);
  707. }
  708. void SkinParser::sendNotifyToAllContainers(int notifymsg, int param1, int param2)
  709. {
  710. for (int i = 0;i < containers.getNumItems();i++)
  711. containers[i]->sendNotifyToAllLayouts(notifymsg, param1, param2);
  712. }
  713. void SkinParser::toggleContainer(int num)
  714. {
  715. if (num < 0) return ;
  716. if (num > containers.getNumItems()) return ;
  717. Container *c = containers[num];
  718. if (!c) return ;
  719. c->toggle();
  720. }
  721. void SkinParser::startupContainers(int scriptid)
  722. {
  723. for (int i = 0;i < containers.getNumItems();i++)
  724. {
  725. if (scriptid == -1 || containers[i]->getScriptId() == scriptid && !containers[i]->isDynamic())
  726. containers[i]->onInit();
  727. }
  728. }
  729. void SkinParser::showContainer(int num, int show)
  730. {
  731. if (num < 0) return ;
  732. if (num > containers.getNumItems()) return ;
  733. Container *c = containers[num];
  734. c->setVisible(show);
  735. }
  736. #endif // wndmgr
  737. int SkinParser::getHex(const wchar_t *p, int size)
  738. {
  739. int v = 0, i = 0;
  740. while (*p != 0 && *p != '-' && *p != '}')
  741. {
  742. unsigned int a = *p;
  743. if (a >= '0' && a <= '9') a -= '0';
  744. if (a >= 'a' && a <= 'f') a -= 'a' -10;
  745. if (a >= 'A' && a <= 'F') a -= 'A' -10;
  746. v = (v * 16) + a;
  747. p++;
  748. i++; if (size != -1 && i == size) return v;
  749. }
  750. return v;
  751. }
  752. #ifdef WASABI_COMPILE_WNDMGR
  753. int SkinParser::getComponentGuid(GUID *g, const wchar_t *p)
  754. {
  755. g->Data1 = getHex(p);
  756. while (*p != 0 && *p != '-') p++;
  757. if (*p == '-')
  758. {
  759. p++;
  760. g->Data2 = getHex(p);
  761. while (*p != 0 && *p != '-') p++;
  762. if (*p == '-')
  763. {
  764. p++;
  765. g->Data3 = getHex(p);
  766. while (*p != 0 && *p != '-') p++;
  767. if (*p == '-')
  768. {
  769. p++;
  770. g->Data4[0] = getHex(p, 2); p += 2;
  771. g->Data4[1] = getHex(p, 2); p += 3;
  772. g->Data4[2] = getHex(p, 2); p += 2;
  773. g->Data4[3] = getHex(p, 2); p += 2;
  774. g->Data4[4] = getHex(p, 2); p += 2;
  775. g->Data4[5] = getHex(p, 2); p += 2;
  776. g->Data4[6] = getHex(p, 2); p += 2;
  777. g->Data4[7] = getHex(p, 2);
  778. return 1;
  779. }
  780. }
  781. }
  782. return 0;
  783. }
  784. GUID *SkinParser::getComponentGuid(const wchar_t *id)
  785. {
  786. static GUID g;
  787. g = nsGUID::fromCharW(id);
  788. if (g == INVALID_GUID) return NULL;
  789. return &g;
  790. }
  791. #endif
  792. int SkinParser::parse(const wchar_t *str, const wchar_t *what)
  793. {
  794. int a = parsetypes.getId(what);
  795. if (a < 0) return WTOI(str);
  796. switch (a)
  797. {
  798. case PARSETYPE_RESIZE: return parseResize(str);
  799. case PARSETYPE_COLOR: return parseColor(str);
  800. case PARSETYPE_COLORALPHA: return parseColorAlpha(str);
  801. case PARSETYPE_REGIONOP: return parseRegionOp(str);
  802. case PARSETYPE_INTERNALACTION: return getAction(str);
  803. case PARSETYPE_GROUPINHERITANCE: return parseGroupInheritance(str);
  804. }
  805. // todo: add svc_intParser
  806. return 0;
  807. }
  808. int SkinParser::parseGroupInheritance(const wchar_t *str)
  809. {
  810. if (WCSCASEEQLSAFE(str, L"1")) return GROUP_INHERIT_ALL;
  811. if (WCSCASEEQLSAFE(str, L"0")) return GROUP_INHERIT_NOTHING;
  812. ParamParser pp(str);
  813. int v = 0;
  814. for (int i = 0;i < pp.getNumItems();i++)
  815. {
  816. const wchar_t *s = pp.enumItem(i);
  817. if (WCSCASEEQLSAFE(s, L"xui")) v |= GROUP_INHERIT_XUIOBJECTS;
  818. if (WCSCASEEQLSAFE(s, L"scripts")) v |= GROUP_INHERIT_SCRIPTS;
  819. if (WCSCASEEQLSAFE(s, L"params")) v |= GROUP_INHERIT_PARAMS;
  820. }
  821. return v;
  822. }
  823. ARGB32 SkinParser::parseColor(const wchar_t *color, int *error)
  824. {
  825. if (color == NULL || *color == '\0') { if (error) *error = 1; return COLOR_ERROR; }
  826. if (!WCSICMP(color, L"white")) return COLOR_WHITE;
  827. if (!WCSICMP(color, L"black")) return COLOR_BLACK;
  828. if (wcschr(color, ','))
  829. {
  830. int r = 0, g = 0, b = 0;
  831. if (swscanf(color, L"%d,%d,%d", &r, &g, &b) != 3) return COLOR_ERROR;
  832. return RGB(r, g, b); // our colors are reversed internally
  833. }
  834. if (*color == '#')
  835. {
  836. int r = 0, g = 0, b = 0;
  837. if (swscanf(color, L"#%02x%02x%02x", &r, &g, &b) != 3) return COLOR_ERROR;
  838. return RGB(r, g, b);
  839. }
  840. if (error) *error = 1;
  841. return COLOR_ERROR;
  842. }
  843. ARGB32 SkinParser::parseColorAlpha(const wchar_t *color)
  844. {
  845. if (color == NULL || *color == '\0') return COLOR_BLACKA;
  846. if (!WCSICMP(color, L"white")) return COLOR_WHITEA;
  847. if (!WCSICMP(color, L"black")) return COLOR_BLACKA;
  848. if (wcschr(color, ','))
  849. {
  850. int r = 0, g = 0, b = 0, a = 255;
  851. // note that 3 params is ok
  852. if (swscanf(color, L"%d,%d,%d,%d", &r, &g, &b, &a) < 3) return COLOR_ERRORA;
  853. ARGB32 ret = RGB(r, g, b); // our colors are reversed internally
  854. ret |= ((a & 0xff) << 24);
  855. return ret;
  856. }
  857. if (*color == '#')
  858. {
  859. int r = 0, g = 0, b = 0, a = 255;
  860. if (swscanf(color, L"#%02x%02x%02x%02x", &r, &g, &b, &a) < 3) return COLOR_ERRORA;
  861. ARGB32 ret = RGB(r, g, b); // our colors are reversed internally
  862. ret |= ((a & 0xff) << 24);
  863. return ret;
  864. }
  865. return COLOR_ERRORA;
  866. }
  867. #ifdef WASABI_COMPILE_WNDMGR
  868. void SkinParser::toggleContainer(const wchar_t *id)
  869. {
  870. // component toggling
  871. GUID *g;
  872. if (g = getComponentGuid(id))
  873. {
  874. GUID g2;
  875. MEMCPY(&g2, g, sizeof(GUID));
  876. WASABI_API_WNDMGR->skinwnd_toggleByGuid(g2);
  877. return ;
  878. }
  879. for (int i = 0;i < containers.getNumItems();i++)
  880. if (!WCSICMP(id, containers[i]->getId())) toggleContainer(i);
  881. }
  882. void SkinParser::showContainer(const wchar_t *id, int show)
  883. {
  884. // component guid
  885. /* GUID *g;
  886. if (g = getComponentGuid(id)) {
  887. WASABI_API_WNDMGR->setComponentVisible(*g, show);
  888. return;
  889. }*/
  890. foreach(containers)
  891. if (!WCSICMP(id, containers.getfor()->getId()))
  892. showContainer(foreach_index, show);
  893. endfor
  894. }
  895. #endif // wndmgr
  896. #pragma warning( disable : 4065 )
  897. int SkinParser::getAction(const wchar_t *action, const wchar_t **name)
  898. {
  899. //CT> this should be a binary search for more efficiency
  900. if (name != NULL) *name = NULL;
  901. int a = actionlist.getId(action);
  902. if (a == -1) return ACTION_NONE;
  903. // these strings are for accessibility when no text has been assigned to the control that triggers these actions
  904. if (name != NULL)
  905. {
  906. switch (a)
  907. {
  908. #ifdef WASABI_COMPILE_WNDMGR
  909. case ACTION_RELOAD_SKIN: *name = _(L"Reload skin"); break;
  910. case ACTION_MINIMIZE: *name = _(L"Minimize window"); break;
  911. case ACTION_MAXIMIZE: *name = _(L"Maximize window"); break;
  912. case ACTION_CLOSE: *name = _(L"Close"); break;
  913. case ACTION_SWITCH: *name = _(L"Switch to"); break;
  914. case ACTION_TOGGLE: *name = _(L"Toggle"); break;
  915. case ACTION_CLOSE_WINDOW: *name = _(L"Close window"); break;
  916. #endif
  917. #ifdef WA3COMPATIBILITY
  918. case ACTION_ABOUT: *name = _(L"About"); break;
  919. case ACTION_SYSMENU: *name = _(L"Open system menu"); break;
  920. case ACTION_CONTROLMENU: *name = _(L"Open control menu"); break;
  921. case ACTION_MENU: *name = _(L"Open menu"); break;
  922. case ACTION_WINDOWMENU: *name = _(L"Window menu"); break;
  923. case ACTION_MB_FORWARD: *name = _(L"Forward"); break;
  924. case ACTION_MB_BACK: *name = _(L"Back"); break;
  925. case ACTION_MB_URL: *name = _(L"Url"); break;
  926. case ACTION_MB_HOME: *name = _(L"Home"); break;
  927. case ACTION_MB_STOP: *name = _(L"Stop loading"); break;
  928. case ACTION_MB_REFRESH: *name = _(L"Refresh"); break;
  929. case ACTION_TEXT_LARGER: *name = _(L"Increase text size"); break;
  930. case ACTION_TEXT_SMALLER: *name = _(L"Decrease text size"); break;
  931. case ACTION_PREFERENCES: *name = _(L"Preferences"); break;
  932. case ACTION_TOGGLE_ALWAYS_ON_TOP: *name = _(L"Toggle Always on top"); break;
  933. case ACTION_VIEW_FILE_INFO: *name = _(L"View file info"); break;
  934. case ACTION_ADD_BOOKMARK: *name = _(L"Add bookmark"); break;
  935. case ACTION_DOUBLESIZE: *name = _(L"Toggle double size mode"); break;
  936. #endif
  937. #ifdef WASABI_WIDGETS_COMPBUCK
  938. case ACTION_CB_NEXT: *name = _(L"More"); break;
  939. case ACTION_CB_PREV: *name = _(L"More"); break;
  940. #endif
  941. default: break;
  942. }
  943. }
  944. return a;
  945. }
  946. #pragma warning( default : 4065 )
  947. #ifdef WASABI_COMPILE_MEDIACORE
  948. int SkinParser::getDisplay(const wchar_t *display)
  949. {
  950. int a = displaylist.getId(display);
  951. if (a == -1) return DISPLAY_SERVICE;
  952. return a;
  953. }
  954. #endif
  955. int SkinParser::getAlign(const wchar_t *align)
  956. {
  957. #ifdef _WIN32
  958. if (!WCSICMP(align, L"LEFT")) return ALIGN_LEFT;
  959. if (!WCSICMP(align, L"CENTER")) return ALIGN_CENTER;
  960. if (!WCSICMP(align, L"RIGHT")) return ALIGN_RIGHT;
  961. if (!WCSICMP(align, L"TOP")) return ALIGN_TOP;
  962. if (!WCSICMP(align, L"BOTTOM")) return ALIGN_BOTTOM;
  963. #else
  964. #warning port me
  965. #endif
  966. return DISPLAY_NONE;
  967. }
  968. int SkinParser::getOrientation(const wchar_t *orient)
  969. {
  970. if (!WCSICMP(orient, L"V") || !WCSICMP(orient, L"VERTICAL"))
  971. return ORIENTATION_VERTICAL;
  972. return ORIENTATION_HORIZONTAL;
  973. }
  974. // link guiobject to guiobject
  975. void SkinParser::initGuiObject(GuiObject *g, Group *pgroup)
  976. {
  977. ASSERT(pgroup);
  978. pgroup->addObject(g);
  979. }
  980. // This sends the params to the script object through its XmlObject
  981. // interface. Try not to add code here, but instead in setXmlParam/XmlInit
  982. // in the object itself
  983. void SkinParser::initXmlObject(XmlObject *o, ifc_xmlreaderparams *params, int no_id)
  984. {
  985. ASSERT(o);
  986. if (params)
  987. for (size_t i = 0;i != params->getNbItems();i++)
  988. if (!no_id || WCSICMP(params->getItemName(i), L"id")) // don't pass along id="blah" stuff
  989. o->setXmlParam(params->getItemName(i), params->getItemValue(i));
  990. // o->XmlInit(); //fg> now defered
  991. }
  992. #ifdef WASABI_COMPILE_WNDMGR
  993. // This sends the params to the script object through its XmlObject
  994. // interface. Try not to add code here, but instead in setXmlParam/XmlInit
  995. // in the object itself
  996. void SkinParser::initLayout(Layout *l, Container *pcont)
  997. {
  998. ASSERT(pcont);
  999. l->setParentContainer(pcont);
  1000. pcont->addLayout(l);
  1001. }
  1002. #endif
  1003. void SkinParser::xmlReaderCallback(int start, const wchar_t *xmltag, skin_xmlreaderparams *params)
  1004. {
  1005. if (start) onXmlStartElement(xmltag, params);
  1006. else onXmlEndElement(xmltag);
  1007. }
  1008. void SkinParser::onXmlStartElement(const wchar_t *name, skin_xmlreaderparams *params)
  1009. {
  1010. xml_tag *i = quickxmltaglist.findItem(name);
  1011. if (i) _onXmlStartElement(i->id, name, params);
  1012. else _onXmlStartElement(XML_TAG_UNKNOWN, name, params);
  1013. }
  1014. void SkinParser::onXmlEndElement(const wchar_t *name)
  1015. {
  1016. xml_tag *i = quickxmltaglist.findItem(name);
  1017. if (i)
  1018. {
  1019. if (i->needclosetag)
  1020. _onXmlEndElement(i->id, name);
  1021. } /*else
  1022. _onXmlEndElement(XML_TAG_UNKNOWN, name);*/ // not needed yet
  1023. }
  1024. void SkinParser::parseGroup(SkinItem *groupitem, PtrList<ifc_xmlreaderparams> *ancestor_param_list, int params_only, int overriding_inheritance_flags)
  1025. {
  1026. ifc_xmlreaderparams *par = groupitem->getParams();
  1027. const wchar_t *groupid = par->getItemValue(L"id");
  1028. const wchar_t *ic = par->getItemValue(L"inherit_content");
  1029. const wchar_t *og = par->getItemValue(L"inherit_group");
  1030. const wchar_t *ip = par->getItemValue(L"inherit_params");
  1031. int inheritance_flags = parseGroupInheritance(ic);
  1032. int inherit_params = 1;
  1033. if (ip != NULL && *ip != 0) inherit_params = WTOI(ip);
  1034. if ((og && *og) && (!ic || !*ic)) inheritance_flags = GROUP_INHERIT_ALLCONTENT;
  1035. if (inherit_params) inheritance_flags |= GROUP_INHERIT_PARAMS;
  1036. if (WCSCASEEQLSAFE(og, groupid)) og = NULL;
  1037. if (inheritance_flags != GROUP_INHERIT_NOTHING)
  1038. {
  1039. SkinItem *prior_item = NULL;
  1040. if (og != NULL && *og)
  1041. prior_item = guiTree->getGroupDef(og);
  1042. else
  1043. prior_item = guiTree->getGroupDefAncestor(groupitem);
  1044. if (prior_item != NULL)
  1045. parseGroup(prior_item, ancestor_param_list, params_only, inheritance_flags);
  1046. }
  1047. if (overriding_inheritance_flags & GROUP_INHERIT_PARAMS)
  1048. ancestor_param_list->addItem(groupitem->getParams());
  1049. if (!params_only)
  1050. {
  1051. int guitreeid = guiTree->getObjectIdx(groupitem);
  1052. for (int i = guitreeid + 1;i < guiTree->getNumObject();i++)
  1053. {
  1054. SkinItem *item = guiTree->getList()->enumItem(i);
  1055. ifc_xmlreaderparams *params = item->getParams();;
  1056. const wchar_t *path = item->getXmlRootPath();
  1057. if (path)
  1058. includepath = path;
  1059. int object_type = guiTree->getObjectType(item);
  1060. if (object_type == XML_TAG_GROUPDEF && !params) break;
  1061. if (object_type == XML_TAG_SCRIPT && !(overriding_inheritance_flags & GROUP_INHERIT_SCRIPTS)) continue;
  1062. if (object_type != XML_TAG_SCRIPT && !(overriding_inheritance_flags & GROUP_INHERIT_XUIOBJECTS)) continue;
  1063. const wchar_t *name = item->getName();
  1064. if (!params)
  1065. _onXmlEndElement(object_type, name);
  1066. else
  1067. _onXmlStartElement(object_type, name, params);
  1068. }
  1069. }
  1070. }
  1071. void SkinParser::_onXmlStartElement(int object_type, const wchar_t *object_name, ifc_xmlreaderparams *params)
  1072. {
  1073. GuiObject *g = NULL; // We'll need to build a GUI object
  1074. XmlObject *x = NULL;
  1075. Group *g_group = NULL;
  1076. if (object_type == XML_TAG_UNKNOWN)
  1077. {
  1078. if (loading_main_skinfile && (!WCSICMP(object_name, L"WinampAbstractionLayer") || !WCSICMP(object_name, L"WasabiXML")))
  1079. {
  1080. skinversion = WTOF(params->getItemValue(L"version"));
  1081. }
  1082. }
  1083. /*#ifdef WASABI_COMPILE_WNDMGR
  1084. int isacontainer = 0;
  1085. #endif // wndmgr*/
  1086. if (object_type == XML_TAG_GROUPDEF)
  1087. {
  1088. if (staticloading)
  1089. {
  1090. recording_groupdef++;
  1091. }
  1092. inGroupDef++;
  1093. }
  1094. if (object_type == XML_TAG_ACCELERATORS)
  1095. {
  1096. const wchar_t *section = params->getItemValue(L"section");
  1097. if (!section)
  1098. LocalesManager::setAcceleratorSection(L"general");
  1099. else
  1100. LocalesManager::setAcceleratorSection(section);
  1101. inAccelerators = 1;
  1102. }
  1103. if (object_type == XML_TAG_STRINGTABLE)
  1104. {
  1105. const wchar_t *section = params->getItemValue(L"id");
  1106. if (!section)
  1107. LocalesManager::SetStringTable(L"nullsoft.wasabi");
  1108. else
  1109. LocalesManager::SetStringTable(section);
  1110. inStringTable = 1;
  1111. }
  1112. if (inStringTable && object_type == XML_TAG_STRINGENTRY)
  1113. {
  1114. const wchar_t *b = params->getItemValue(L"id");
  1115. const wchar_t *a = params->getItemValue(L"string");
  1116. if (b && a)
  1117. {
  1118. LocalesManager::AddString(WTOI(b), a);
  1119. }
  1120. }
  1121. if (inAccelerators && object_type == XML_TAG_ACCELERATOR)
  1122. {
  1123. const wchar_t *b = params->getItemValue(L"bind");
  1124. const wchar_t *a = params->getItemValue(L"action");
  1125. if (b && a)
  1126. {
  1127. //LocalesManager::addAccelerator(b, a);
  1128. //Martin> this is a temporary fix to protect skin.xml from overriding the language pack accels
  1129. LocalesManager::addAcceleratorFromSkin(b, a);
  1130. }
  1131. }
  1132. if ((!recording_container && !recording_groupdef) && !inGroupDef)
  1133. {
  1134. if (object_type == XML_TAG_SCRIPT)
  1135. {
  1136. // const char *id = params->getItemValue(L"id");
  1137. if (1)
  1138. {
  1139. if (allowscripts)
  1140. {
  1141. int vcpuid = Script::addScript(includepath, params->getItemValue(L"file"), params->getItemValue(L"id"));
  1142. if (vcpuid != -1)
  1143. {
  1144. Script::setScriptParam(vcpuid, params->getItemValue(L"param"));
  1145. Script::setParentGroup(vcpuid, curGroup);
  1146. Script::setSkinPartId(vcpuid, scriptId);
  1147. if (curGroup != NULL)
  1148. curGroup->addScript(vcpuid);
  1149. else // todo: schedule this for the end of skinparse, after all layouts are inited
  1150. SOM::getSystemObjectByScriptId(vcpuid)->onLoad();
  1151. }
  1152. }
  1153. }
  1154. }
  1155. }
  1156. #ifdef WASABI_COMPILE_WNDMGR
  1157. if ((!recording_groupdef && !recording_container) && (inContainer || inGroup) && !inGroupDef)
  1158. { // Am I in a container definition ?
  1159. if (inLayout || inGroup)
  1160. { // Am I in a layout or in a group ?
  1161. #else // wndmgr
  1162. if ((!recording_groupdef && !recording_container) && inGroup && !inGroupDef)
  1163. {
  1164. { // Am I in definition ?
  1165. #endif // wndmgr
  1166. // Create appropriate GuiObject descendant
  1167. if (object_type == XML_TAG_GROUP || object_type == XML_TAG_CFGGROUP)
  1168. {
  1169. Group *old = curGroup;
  1170. GuiObject *newgrp = newDynamicGroup(params->getItemValue(L"id"), (object_type == XML_TAG_CFGGROUP) ? GROUP_CFGGROUP : GROUP_GROUP);
  1171. if (newgrp)
  1172. {
  1173. x = static_cast<XmlObject *>(newgrp->guiobject_getScriptObject()->vcpu_getInterface(xmlObjectGuid));
  1174. g = newgrp;
  1175. }
  1176. curGroup = old;
  1177. }
  1178. #ifdef WASABI_COMPILE_WNDMGR
  1179. else if (object_type == XML_TAG_SNAPPOINT)
  1180. {
  1181. x = new SnapPoint(curLayout, curContainer);
  1182. }
  1183. #endif
  1184. else if (object_type != XML_TAG_UNKNOWN)
  1185. {
  1186. g = NULL;
  1187. }
  1188. else
  1189. {
  1190. SkinItem *item = guiTree->getXuiGroupDef(object_name);
  1191. if (item != NULL)
  1192. {
  1193. Group *old = curGroup;
  1194. const wchar_t *grpid = NULL;
  1195. if (item->getParams() != NULL)
  1196. grpid = item->getParams()->getItemValue(L"id");
  1197. GuiObject *newgrp = NULL;
  1198. if (grpid == NULL)
  1199. newgrp = newDynamicGroup(params->getItemValue(L"id"), GROUP_GROUP, item);
  1200. else
  1201. newgrp = newDynamicGroup(grpid, GROUP_GROUP, NULL, -1, allowscripts);
  1202. if (newgrp)
  1203. {
  1204. x = static_cast<XmlObject *>(newgrp->guiobject_getScriptObject()->vcpu_getInterface(xmlObjectGuid));
  1205. g = newgrp;
  1206. }
  1207. curGroup = old;
  1208. }
  1209. else
  1210. {
  1211. g = createExternalGuiObject(object_name, &x, params);
  1212. }
  1213. }
  1214. }
  1215. #ifdef WASABI_COMPILE_WNDMGR
  1216. else
  1217. { // if inlayout
  1218. if (object_type == XML_TAG_LAYOUT)
  1219. { // Now enters a new layout
  1220. curLayout = new Layout;
  1221. curGroup = curLayout;
  1222. inLayout = 1;
  1223. initLayout(curLayout, curContainer);
  1224. x = static_cast<XmlObject *>(curLayout->getGuiObject()->guiobject_getScriptObject()->vcpu_getInterface(xmlObjectGuid));
  1225. }
  1226. }
  1227. #endif // wndmgr
  1228. }
  1229. #ifdef WASABI_COMPILE_WNDMGR
  1230. else
  1231. { // if inContainer
  1232. if (inElements)
  1233. {
  1234. // do nothing
  1235. }
  1236. else if (object_type == XML_TAG_CONTAINER)
  1237. {
  1238. //isacontainer = 1;
  1239. const wchar_t *d = params->getItemValue(L"dynamic");
  1240. int dyn = WASABI_WNDMGR_ALLCONTAINERSDYNAMIC ? 1 : (d ? WTOI(d) : 0);
  1241. if (dyn && staticloading)
  1242. {
  1243. recording_container = 1;
  1244. }
  1245. else
  1246. {
  1247. inContainer = 1;
  1248. curContainer = new Container(scriptId);
  1249. curContainer->setId(params->getItemValue(L"id"));
  1250. containers.addItem(curContainer);
  1251. #ifdef _DEBUG
  1252. DebugStringW(L"new Container - skinpartid = %d\n", scriptId);
  1253. #endif
  1254. if (transcientcontainer) curContainer->setTranscient(1);
  1255. x = curContainer;
  1256. }
  1257. }
  1258. else
  1259. {
  1260. if (object_type == XML_TAG_SCRIPTS)
  1261. inScripts = 1;
  1262. else if (object_type == XML_TAG_ELEMENTS)
  1263. inElements = 1;
  1264. }
  1265. } // if container else
  1266. #endif // wndmgr
  1267. if (g_group)
  1268. {
  1269. curGroup = g_group;
  1270. }
  1271. else if (g)
  1272. initGuiObject(g, curGroup);
  1273. if (x)
  1274. initXmlObject(x, params);
  1275. if (recording_container || recording_groupdef)
  1276. guiTree->addItem(object_type, object_name, params, scriptId, includepath.v());
  1277. }
  1278. void SkinParser::_onXmlEndElement(int object_type, const wchar_t *name)
  1279. {
  1280. if (recording_container || recording_groupdef)
  1281. guiTree->addItem(object_type, name, NULL, scriptId, includepath);
  1282. if (object_type == XML_TAG_GROUPDEF)
  1283. {
  1284. lastCreatedGroup = curGroup;
  1285. if (staticloading)
  1286. recording_groupdef--;
  1287. if (recording_groupdef < 0) recording_groupdef = 0;
  1288. inGroup = 0;
  1289. inGroupDef--;
  1290. curGroup = NULL;
  1291. }
  1292. #ifdef WASABI_COMPILE_WNDMGR
  1293. if (object_type == XML_TAG_CONTAINER)
  1294. {
  1295. if (inContainer)
  1296. {
  1297. //if (!curContainer->isDynamic()) containers.addItem(curContainer); //FG>script
  1298. //containers.addItem(curContainer);
  1299. lastCreatedContainer = curContainer;
  1300. curContainer = NULL;
  1301. inContainer = 0;
  1302. }
  1303. recording_container = 0;
  1304. if (recording_groupdef)
  1305. {
  1306. WASABI_API_WNDMGR->messageBox(L"container closed but group still open, closing group", L"error in xml data", 0, NULL, NULL);
  1307. recording_groupdef = 0;
  1308. }
  1309. }
  1310. if (inLayout && object_type == XML_TAG_LAYOUT)
  1311. {
  1312. #ifdef WA3COMPATIBILITY
  1313. curLayout->setForwardMsgWnd(WASABI_API_WND->main_getRootWnd()->gethWnd());
  1314. #endif
  1315. curLayout->setAutoResizeAfterInit(1);
  1316. #ifndef WA3COMPATIBILITY
  1317. #ifdef _WIN32
  1318. curLayout->init(hInstance, curLayout->getCustomOwner() ? curLayout->getCustomOwner()->gethWnd() : WASABI_API_WND->main_getRootWnd()->gethWnd(), TRUE);
  1319. #else
  1320. #warning port me
  1321. curLayout->init(0, curLayout->getCustomOwner() ? curLayout->getCustomOwner()->gethWnd() : WASABI_API_WND->main_getRootWnd()->gethWnd(), TRUE);
  1322. #endif
  1323. #else
  1324. curLayout->init(hInstance, curLayout->getCustomOwner() ? curLayout->getCustomOwner()->gethWnd() : Main::gethWnd(), TRUE);
  1325. #endif
  1326. curLayout->getGuiObject()->guiobject_onStartup();
  1327. curLayout = NULL;
  1328. inLayout = 0;
  1329. curGroup = NULL;
  1330. }
  1331. #endif
  1332. if (inScripts && object_type == XML_TAG_SCRIPTS)
  1333. {
  1334. inScripts = 0;
  1335. }
  1336. if (inElements && object_type == XML_TAG_ELEMENTS)
  1337. {
  1338. inElements = 0;
  1339. }
  1340. if (inAccelerators && object_type == XML_TAG_ACCELERATORS)
  1341. {
  1342. LocalesManager::setAcceleratorSection(L"");
  1343. inAccelerators = 0;
  1344. }
  1345. if (inStringTable && object_type == XML_TAG_STRINGTABLE)
  1346. {
  1347. LocalesManager::SetStringTable(L"");
  1348. inStringTable = 0;
  1349. }
  1350. }
  1351. #ifdef WASABI_COMPILE_WNDMGR
  1352. int SkinParser::verifyContainer(Container *c)
  1353. {
  1354. for (int i = 0;i < containers.getNumItems();i++)
  1355. {
  1356. if (containers.enumItem(i) == c)
  1357. return 1;
  1358. }
  1359. return 0;
  1360. }
  1361. #endif
  1362. int SkinParser::parseResize(const wchar_t *r)
  1363. {
  1364. int a = resizevalues.getId(r);
  1365. if (a < 0) return WTOI(r);
  1366. return a;
  1367. }
  1368. int SkinParser::parseRegionOp(const wchar_t *r)
  1369. {
  1370. if (!WCSICMP(r, L"or")) return REGIONOP_OR;
  1371. if (!WCSICMP(r, L"and")) return REGIONOP_AND;
  1372. if (!WCSICMP(r, L"sub")) return REGIONOP_SUB;
  1373. if (!WCSICMP(r, L"sub2")) return REGIONOP_SUB2;
  1374. return WTOI(r);
  1375. }
  1376. void SkinParser::cleanupScript(int scriptid)
  1377. {
  1378. if (scriptid == -1) scriptid = WASABI_API_PALETTE->getSkinPartIterator();
  1379. int i;
  1380. for (i = 0;i < SOM::getNumSystemObjects();i++)
  1381. {
  1382. if (SOM::getSystemObject(i)->getSkinPartId() == scriptid)
  1383. {
  1384. int vcpu = SOM::getSystemObject(i)->getScriptId();
  1385. Script::unloadScript(vcpu);
  1386. i--;
  1387. }
  1388. }
  1389. #ifdef WASABI_COMPILE_WNDMGR
  1390. for (i = 0;i < containers.getNumItems();i++)
  1391. {
  1392. Container *c = containers[i];
  1393. if (c->getScriptId() == scriptid)
  1394. {
  1395. c->setDeleting();
  1396. delete c; // c autodeletes from containers
  1397. i--;
  1398. }
  1399. }
  1400. #endif
  1401. guiTree->removeSkinPart(scriptid);
  1402. #ifdef WASABI_COMPILE_WNDMGR
  1403. AutoPopup::removeSkinPart(scriptid);
  1404. #endif
  1405. }
  1406. #ifdef WASABI_COMPILE_WNDMGR
  1407. void SkinParser::unloadAllContainers()
  1408. {
  1409. foreach(containers)
  1410. containers.getfor()->setDeleting();
  1411. endfor;
  1412. containers.deleteAllSafe();
  1413. //script_containers.removeAll();
  1414. }
  1415. #endif
  1416. void SkinParser::cleanUp()
  1417. {
  1418. #ifdef WASABI_COMPILE_WNDMGR
  1419. AutoPopup::removeAllAddons();
  1420. #endif
  1421. Script::unloadAllScripts();
  1422. #ifdef WASABI_COMPILE_WNDMGR
  1423. unloadAllContainers();
  1424. #endif
  1425. guiTree->reset();
  1426. }
  1427. #ifdef WASABI_COMPILE_WNDMGR
  1428. int SkinParser::getNumContainers()
  1429. {
  1430. return containers.getNumItems();
  1431. }
  1432. Container *SkinParser::enumContainer(int n)
  1433. {
  1434. return containers.enumItem(n);
  1435. }
  1436. #endif
  1437. const wchar_t *SkinParser::getXmlRootPath()
  1438. {
  1439. return includepath;
  1440. }
  1441. #ifdef WASABI_COMPILE_WNDMGR
  1442. const wchar_t *SkinParser::getCurrentContainerId()
  1443. {
  1444. if (curContainer) return curContainer->getId();
  1445. return NULL;
  1446. }
  1447. const wchar_t *SkinParser::getCurrentGroupId()
  1448. {
  1449. if (curGroup) return curGroup->getGuiObject()->guiobject_getId();
  1450. return NULL;
  1451. }
  1452. #endif
  1453. GuiObject *SkinParser::createExternalGuiObject(const wchar_t *object_name, XmlObject **x, ifc_xmlreaderparams *params)
  1454. {
  1455. svc_xuiObject *svc = NULL;
  1456. waServiceFactory *sf = xuiCache->findServiceFactory(object_name);
  1457. if (sf != NULL)
  1458. svc = castService<svc_xuiObject>(sf, FALSE);
  1459. else
  1460. {
  1461. XuiObjectSvcEnum xose(object_name);
  1462. svc = xose.getNext(FALSE);
  1463. sf = xose.getLastFactory();
  1464. }
  1465. if (svc != NULL)
  1466. {
  1467. GuiObject *go = svc->instantiate(object_name, params);
  1468. if (!go) return NULL;
  1469. go->guiobject_setXuiService(svc);
  1470. go->guiobject_setXuiServiceFactory(sf);
  1471. ScriptObject *so = go->guiobject_getScriptObject();
  1472. ASSERTPR(so != NULL, "tell francis to fix scriptobjectless xuiobjects");
  1473. if (x) *x = static_cast<XmlObject *>(so->vcpu_getInterface(xmlObjectGuid));
  1474. return go;
  1475. }
  1476. return NULL;
  1477. }
  1478. void SkinParser::destroyGuiObject(GuiObject *o)
  1479. {
  1480. svc_xuiObject *svc = o->guiobject_getXuiService();
  1481. if (!svc)
  1482. {
  1483. ScriptObject *so = o->guiobject_getScriptObject();
  1484. ASSERT(so != NULL);
  1485. GuiObjectWnd *go = static_cast<GuiObjectWnd *>(so->vcpu_getInterface(guiObjectWndGuid));
  1486. ASSERT(go != NULL);
  1487. delete go;
  1488. }
  1489. else
  1490. {
  1491. waServiceFactory *sf = o->guiobject_getXuiServiceFactory();
  1492. svc->destroy(o);
  1493. sf->releaseInterface(svc);
  1494. }
  1495. }
  1496. #ifdef WASABI_COMPILE_WNDMGR
  1497. void SkinParser::focusFirst()
  1498. {
  1499. foreach(containers)
  1500. for (int j = 0;j < containers.getfor()->getNumLayouts();j++)
  1501. {
  1502. Layout *l = containers.getfor()->enumLayout(j);
  1503. if (l != NULL && l->isVisible())
  1504. {
  1505. l->setFocus();
  1506. return ;
  1507. }
  1508. }
  1509. endfor;
  1510. }
  1511. #ifdef WA3COMPATIBILITY
  1512. // non portable, the skin might be missing/buggy as hell, we need to use the os' msgbox
  1513. void SkinParser::emmergencyReloadDefaultSkin()
  1514. {
  1515. if (!Main::revert_on_error)
  1516. {
  1517. if (!STRCASEEQLSAFE("Default", WASABI_API_SKIN->getSkinName()))
  1518. {
  1519. WASABI_API_WND->appdeactivation_setbypass(1);
  1520. Std::messageBox(StringPrintfW(L"Failed to load the skin (%s). Did you remove it ?\nThis could also be due to missing components (ie: wa2skin.wac for winamp 2 skins), please check the skin's documentation.\nReverting to default skin.", WASABI_API_SKIN->getSkinName()), "Error", 0);
  1521. WASABI_API_WND->appdeactivation_setbypass(0);
  1522. Skin::toggleSkin("Default");
  1523. }
  1524. else
  1525. {
  1526. WASABI_API_WND->appdeactivation_setbypass(1);
  1527. Std::messageBox("The default skin did not load any user interface! Ooch! What should I do ? Oh well, good luck...", "Danger Danger Will Robinson!", 0);
  1528. WASABI_API_WND->appdeactivation_setbypass(0);
  1529. }
  1530. }
  1531. }
  1532. #endif
  1533. #endif
  1534. GuiObject *SkinParser::xui_new(const wchar_t *classname)
  1535. {
  1536. SkinItem *item = guiTree->getXuiGroupDef(classname);
  1537. if (item != NULL)
  1538. {
  1539. Group *old = curGroup;
  1540. const wchar_t *grpid = NULL;
  1541. if (item->getParams() != NULL)
  1542. grpid = item->getParams()->getItemValue(L"id");
  1543. GuiObject *newgrp = NULL;
  1544. if (grpid != NULL)
  1545. newgrp = newDynamicGroup(grpid, GROUP_GROUP);
  1546. curGroup = old;
  1547. if (newgrp != NULL) return newgrp;
  1548. }
  1549. return createExternalGuiObject(classname, NULL, NULL);
  1550. }
  1551. void SkinParser::xui_delete(GuiObject *o)
  1552. {
  1553. destroyGuiObject(o);
  1554. }
  1555. double SkinParser::getSkinVersion()
  1556. {
  1557. return skinversion;
  1558. }
  1559. void SkinParser::setAllLayoutsRatio(double ra)
  1560. {
  1561. foreach(containers)
  1562. Container *c = containers.getfor();
  1563. int n = c->getNumLayouts();
  1564. for (int i = 0;i < n;i++)
  1565. {
  1566. Layout *l = c->enumLayout(i);
  1567. if (l->getNoParent() != 1)
  1568. l->setRenderRatio(ra);
  1569. }
  1570. endfor;
  1571. }
  1572. void SkinParser::setAllLayoutsTransparency(int v)
  1573. {
  1574. foreach(containers)
  1575. Container *c = containers.getfor();
  1576. int n = c->getNumLayouts();
  1577. for (int i = 0;i < n;i++)
  1578. {
  1579. Layout *l = c->enumLayout(i);
  1580. if (l->getNoParent() != 1)
  1581. l->setAlpha(v);
  1582. }
  1583. endfor;
  1584. }
  1585. Layout *SkinParser::getMainLayout()
  1586. {
  1587. foreach(containers)
  1588. Container *c = containers.getfor();
  1589. if (!c->isMainContainer()) continue;
  1590. return c->enumLayout(0);
  1591. endfor;
  1592. return NULL;
  1593. }
  1594. /*
  1595. void SkinParser::setAllLayoutsAutoOpacify(int ao, int force) {
  1596. foreach(containers)
  1597. Container *c = containers.getfor();
  1598. int n = c->getNumLayouts();
  1599. for (int i=0;i<n;i++) {
  1600. Layout *l = c->enumLayout(i);
  1601. if (l->getNoParent() != 1)
  1602. l->setAutoOpacify(ao, force);
  1603. }
  1604. endfor;
  1605. }
  1606. void SkinParser::setAllLayoutsOverrideAlpha(int oa) {
  1607. foreach(containers)
  1608. Container *c = containers.getfor();
  1609. int n = c->getNumLayouts();
  1610. for (int i=0;i<n;i++) {
  1611. Layout *l = c->enumLayout(i);
  1612. if (l->isInited() && l->isTransparencySafe() && l->getTransparencyOverride() == -1) {
  1613. if (l->getNoParent() != 1)
  1614. l->setTransparency(oa);
  1615. }
  1616. }
  1617. endfor;
  1618. }
  1619. */
  1620. Group *SkinParser::curGroup, *SkinParser::lastCreatedGroup;
  1621. int SkinParser::inScripts = 0, SkinParser::inElements = 0, SkinParser::inGroupDef = 0, SkinParser::inGroup = 0, SkinParser::inAccelerators = 0, SkinParser::inStringTable = 0;
  1622. int SkinParser::scriptId = 0;
  1623. int SkinParser::recording_container = 0;
  1624. int SkinParser::recording_groupdef = 0;
  1625. int SkinParser::staticloading = 0;
  1626. PtrList<parser_status> SkinParser::statusstack;
  1627. int SkinParser::instantiatinggroup = 0;
  1628. int SkinParser::allowscripts = 0;
  1629. skin_xmlreaderparams *SkinParser::groupparams = NULL;
  1630. PtrListQuickSorted<xml_tag, XmlTagComp> SkinParser::quickxmltaglist;
  1631. double SkinParser::skinversion = 0.0;
  1632. #ifdef WASABI_COMPILE_WNDMGR
  1633. Container *SkinParser::curContainer, *SkinParser::lastCreatedContainer;
  1634. Layout *SkinParser::curLayout;
  1635. int SkinParser::inContainer, SkinParser::inLayout;
  1636. //PtrList<Container> SkinParser::script_containers;
  1637. PtrList<Container> SkinParser::containers;
  1638. int SkinParser::centerskin;
  1639. int SkinParser::transcientcontainer;
  1640. SvcCacheT<svc_xuiObject> *SkinParser::xuiCache;
  1641. int SkinParser::loading_main_skinfile = 0;
  1642. StringW SkinParser::includepath;
  1643. #endif