skinembed.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733
  1. #include <precomp.h>
  2. #include "skinembed.h"
  3. #include <api/wndmgr/layout.h>
  4. #include <api/wnd/wndclass/wndholder.h>
  5. #include <api/skin/skinparse.h>
  6. #include <api/wnd/wndtrack.h>
  7. #include <api/config/items/cfgitemi.h>
  8. #include <api/config/items/attrint.h>
  9. #include <bfc/named.h>
  10. #include <api/wndmgr/autopopup.h>
  11. #include <api/syscb/callbacks/wndcb.h>
  12. #include <api/wndmgr/skinwnd.h>
  13. #include <api/script/scriptmgr.h>
  14. #include <bfc/critsec.h>
  15. CriticalSection skinembed_cs;
  16. SkinEmbedder *skinEmbedder = NULL;
  17. SkinEmbedder::SkinEmbedder()
  18. {
  19. ASSERTPR(skinEmbedder == NULL, "only one skin embedder please!");
  20. skinEmbedder = this;
  21. }
  22. SkinEmbedder::~SkinEmbedder()
  23. {
  24. inserted.deleteAll();
  25. allofthem.deleteAll();
  26. }
  27. int SkinEmbedder::toggle(GUID g, const wchar_t *prefered_container, int container_flag, RECT *r, int transcient)
  28. {
  29. ifc_window *w = enumItem(g, 0);
  30. if (w != NULL)
  31. {
  32. destroy(w, r);
  33. return 0;
  34. }
  35. ifc_window *wnd = create(g, NULL, prefered_container, container_flag, r, transcient);
  36. if (wnd == NULL)
  37. {
  38. #ifdef ON_CREATE_EXTERNAL_WINDOW_GUID
  39. int y;
  40. ON_CREATE_EXTERNAL_WINDOW_GUID(g, y);
  41. #endif
  42. }
  43. return 1;
  44. }
  45. int SkinEmbedder::toggle(const wchar_t *groupid, const wchar_t *prefered_container, int container_flag, RECT *r, int transcient)
  46. {
  47. ifc_window *w = enumItem(groupid, 0);
  48. if (w != NULL)
  49. {
  50. destroy(w, r);
  51. return 0;
  52. }
  53. create(INVALID_GUID, groupid, prefered_container, container_flag, r, transcient);
  54. return 1;
  55. }
  56. ifc_window *SkinEmbedder::create(GUID g, const wchar_t *prefered_container, int container_flag, RECT *r, int transcient, int starthidden, int *isnew)
  57. {
  58. return create(g, NULL, prefered_container, container_flag, r, transcient, starthidden, isnew);
  59. }
  60. ifc_window *SkinEmbedder::create(const wchar_t *groupid, const wchar_t *prefered_container, int container_flag, RECT *r, int transcient, int starthidden, int *isnew)
  61. {
  62. return create(INVALID_GUID, groupid, prefered_container, container_flag, r, transcient, starthidden, isnew);
  63. }
  64. WindowHolder *SkinEmbedder::getSuitableWindowHolder(GUID g, const wchar_t *group_id, Container *cont, Layout *lay, int _visible, int _dynamic, int _empty, int _hasself, int _autoavail)
  65. {
  66. foreach(wndholders)
  67. WindowHolder *h = wndholders.getfor();
  68. ifc_window *w = h->getRootWndPtr()->getDesktopParent();
  69. int dyn = 1;
  70. int visible = 0;
  71. int hasself = 0;
  72. int empty = 0;
  73. int autoavail = h->wndholder_isAutoAvailable();
  74. Layout *l = (NULL != w) ? static_cast<Layout *>(w->getInterface(layoutGuid)) : NULL;
  75. Container *c = NULL;
  76. if (l)
  77. {
  78. c = l->getParentContainer();
  79. if (c)
  80. {
  81. dyn = c->isDynamic();
  82. }
  83. }
  84. if (NULL == w || !w->isInited()) visible = -1;
  85. else
  86. {
  87. if (_visible == 1)
  88. {
  89. if (h->getRootWndPtr()->isVisible()) visible = 1;
  90. }
  91. else if (_visible == 0)
  92. {
  93. if (w->isVisible()) visible = 1;
  94. }
  95. }
  96. if (!h->getCurRootWnd()) empty = 1;
  97. if (g != INVALID_GUID)
  98. {
  99. if (g == h->getCurGuid())
  100. hasself = 1;
  101. }
  102. else if (group_id && h->getCurGroupId())
  103. {
  104. if (!WCSICMP(group_id, h->getCurGroupId()))
  105. hasself = 1;
  106. }
  107. if (_visible != -1)
  108. {
  109. if (visible != _visible) continue;
  110. }
  111. if (_dynamic != -1)
  112. {
  113. if (_dynamic != dyn) continue;
  114. }
  115. if (_empty != -1)
  116. {
  117. if (empty != _empty) continue;
  118. }
  119. if (_hasself != -1)
  120. {
  121. if (hasself != _hasself) continue;
  122. }
  123. if (_autoavail != -1)
  124. {
  125. if (autoavail != _autoavail) continue;
  126. }
  127. if (cont != NULL)
  128. {
  129. if (c != cont) continue;
  130. }
  131. if (lay != NULL)
  132. {
  133. if (l != lay) continue;
  134. }
  135. if (g != INVALID_GUID)
  136. {
  137. if (h->wantGuid(g)) return h;
  138. }
  139. else if (group_id)
  140. {
  141. if (h->wantGroup(group_id)) return h;
  142. }
  143. endfor;
  144. return NULL;
  145. }
  146. ifc_window *SkinEmbedder::create(GUID g, const wchar_t *groupid, const wchar_t *prefered_container, int container_flag, RECT *r, int transcient, int starthidden, int *isnew)
  147. {
  148. // InCriticalSection in_cs(&skinembed_cs);
  149. foreach(in_deferred_callback)
  150. SkinEmbedEntry *e = in_deferred_callback.getfor();
  151. if ((e->guid != INVALID_GUID && e->guid == g) || WCSCASEEQLSAFE(groupid, e->groupid))
  152. {
  153. #ifdef _DEBUG
  154. DebugStringW(L"trying to show a window that is being destroyed, hm, try again later\n");
  155. #endif
  156. // too soon! try later dude
  157. return NULL;
  158. }
  159. endfor;
  160. RECT destrect = {0};
  161. if (isnew) *isnew = 0;
  162. WindowHolder *wh = NULL;
  163. // todo: get from c++ callback
  164. if (SOM::checkAbortShowHideWindow(g, 1))
  165. return NULL;
  166. if (g != INVALID_GUID)
  167. wh = SOM::getSuitableWindowHolderFromScript(g);
  168. if (!wh) wh = getSuitableWindowHolder(g, groupid, NULL, NULL, 1 /*visible*/, 0 /*static*/, 1 /*empty*/, -1 /*donttest*/, -1 /*donttest*/);
  169. if (!wh) wh = getSuitableWindowHolder(g, groupid, NULL, NULL, 0 /*hidden*/, 0 /*static*/, 0 /*notempty*/, 1 /*hasself*/, -1 /*donttest*/);
  170. if (!wh) wh = getSuitableWindowHolder(g, groupid, NULL, NULL, 0 /*hidden*/, 0 /*static*/, 1 /*empty*/, -1 /*donttest*/, 1 /*autoavail*/);
  171. if (!wh) wh = getSuitableWindowHolder(g, groupid, NULL, NULL, 1 /*visible*/, 1 /*dynamic*/, 1 /*empty*/, -1 /*donttest*/, -1 /*donttest*/);
  172. ifc_window *whrw = wh ? wh->getRootWndPtr() : NULL;
  173. Container *cont = NULL;
  174. Layout *lay = NULL;
  175. ifc_window *wnd = NULL;
  176. int newcont = 0;
  177. if (!wh)
  178. { // no hidden static container, so lets create a dynamic one
  179. if (isnew) *isnew = 1;
  180. if (container_flag == 0 && (prefered_container == NULL || !*prefered_container))
  181. {
  182. prefered_container = AutoPopup::getDefaultContainerParams(groupid, g, &container_flag);
  183. }
  184. if (container_flag == 0 && (prefered_container == NULL || !*prefered_container))
  185. {
  186. prefered_container = WASABI_DEFAULT_STDCONTAINER;
  187. }
  188. cont = SkinParser::loadContainerForWindowHolder(groupid, g, 0, transcient, prefered_container, container_flag);
  189. if (cont)
  190. {
  191. cont->setTranscient(transcient);
  192. newcont = 1;
  193. lay = cont->enumLayout(0);
  194. /* if (prefered_layout) { // find its target layout
  195. cont->setDefaultLayout(prefered_layout);
  196. lay = cont->getLayout(prefered_layout);
  197. if (!lay) {
  198. if (!layout_flag) // see if we can fallback
  199. lay = cont->enumLayout(0);
  200. else {
  201. destroyContainer(cont); // deferred
  202. api->console_outputString(9, StringPrintf("could not find the requested layout (%s) to host the window", prefered_container));
  203. return NULL;
  204. }
  205. }*/
  206. }
  207. else
  208. {
  209. DebugStringW(L"no container found to hold the window... not even a default one :/\n");
  210. }
  211. wh = getSuitableWindowHolder(g, groupid, cont, lay, -1 /*donttest*/, -1 /*donttest*/, 0 /*notempty*/, 1 /*hasself*/, -1 /*donttest*/);
  212. if (!wh) wh = getSuitableWindowHolder(g, groupid, cont, lay, -1 /*donttest*/, -1 /*donttest*/, 1 /*empty*/, -1 /*donttest*/, -1 /*donttest*/);
  213. whrw = wh ? wh->getRootWndPtr() : NULL;
  214. }
  215. if (wh)
  216. {
  217. GuiObject *o = static_cast<GuiObject *>(whrw->getInterface(guiObjectGuid));
  218. ASSERT(o != NULL);
  219. if (o)
  220. {
  221. lay = o->guiobject_getParentLayout();
  222. if (lay)
  223. cont = lay->getParentContainer();
  224. }
  225. if ((g != INVALID_GUID && (g == wh->getCurGuid())) || (groupid && (wh->getCurGroupId() == groupid)))
  226. wnd = wh->getCurRootWnd();
  227. else
  228. {
  229. if (wh->getCurRootWnd())
  230. wh->onRemoveWindow();
  231. wnd = wh->onInsertWindow(g, groupid);
  232. }
  233. }
  234. if (!wnd)
  235. {
  236. if (cont)
  237. {
  238. if (!WCSCASEEQLSAFE(cont->getId(), L"main"))
  239. cont->close();
  240. }
  241. return NULL;
  242. }
  243. //int anim = 1;
  244. //if (wh && !whrw->getAnimatedRects()) anim = 0; // FIXME!!
  245. if (lay && r)
  246. {
  247. lay->getWindowRect(&destrect);
  248. }
  249. if (cont /*&& cont->isDynamic()*/)
  250. {
  251. const wchar_t *text = wnd->getRootWndName();
  252. cont->setTranscient(transcient);
  253. if (text != NULL)
  254. if (cont->isDynamic()) cont->setName(text);
  255. if (cont->isDynamic() && !transcient) cont->resetLayouts();
  256. if (newcont) cont->onInit(1);
  257. }
  258. #ifdef WASABI_COMPILE_CONFIG
  259. // {280876CF-48C0-40bc-8E86-73CE6BB462E5}
  260. const GUID options_guid =
  261. { 0x280876cf, 0x48c0, 0x40bc, { 0x8e, 0x86, 0x73, 0xce, 0x6b, 0xb4, 0x62, 0xe5 } };
  262. CfgItem *cfgitem = WASABI_API_CONFIG->config_getCfgItemByGuid(options_guid);
  263. int findopenrect = _int_getValue(cfgitem, L"Find open rect");
  264. #else
  265. int findopenrect = WASABI_WNDMGR_FINDOPENRECT;
  266. #endif
  267. if (wh && findopenrect)
  268. {
  269. if (lay)
  270. {
  271. RECT rl;
  272. lay->getWindowRect(&rl);
  273. RECT nr = windowTracker->findOpenRect(rl, lay);
  274. destrect = nr; // rewrite destrect
  275. int w = rl.right - rl.left;
  276. int h = rl.bottom - rl.top;
  277. lay->divRatio(&w, &h);
  278. nr.right = nr.left + w;
  279. nr.bottom = nr.top + h;
  280. lay->resizeToRect(&nr);
  281. }
  282. }
  283. if (wh)
  284. {
  285. if (r)
  286. /*if (anim)*/ WASABI_API_WNDMGR->drawAnimatedRects(r, &destrect);
  287. /*else
  288. {
  289. RECT r;
  290. r.left = destrect.left + (destrect.right - destrect.left) / 2 - 1;
  291. r.top = destrect.top + (destrect.bottom - destrect.top) / 2 + 1;
  292. r.right = r.left + 2;
  293. r.bottom = r.top + 2;
  294. if (anim) WASABI_API_WNDMGR->drawAnimatedRects(&r, &destrect);
  295. }*/
  296. }
  297. if (!starthidden)
  298. {
  299. if (cont && cont->isVisible())
  300. { // we were already shown, duh
  301. // cont->setVisible(0);
  302. }
  303. else
  304. {
  305. if (cont) cont->setVisible(1);
  306. else if (lay) lay->setVisible(1);
  307. }
  308. }
  309. if (wnd && newcont && !transcient)
  310. {
  311. inserted.addItem(new SkinEmbedEntry(wnd->getDependencyPtr(), wnd, g, groupid, prefered_container, container_flag, cont, wh));
  312. viewer_addViewItem(wnd->getDependencyPtr());
  313. }
  314. if (!transcient && wnd)
  315. allofthem.addItem(new SkinEmbedEntry(wnd->getDependencyPtr(), wnd, g, groupid, prefered_container, container_flag, cont, wh));
  316. return wnd;
  317. }
  318. void SkinEmbedder::destroy(ifc_window *w, RECT *r)
  319. {
  320. int donecheck = 0;
  321. SkinEmbedEntry *e = NULL;
  322. for (int i = 0; i < allofthem.getNumItems();i++)
  323. {
  324. e = allofthem.enumItem(i);
  325. if (e->wnd == w)
  326. {
  327. donecheck = 1;
  328. if (SOM::checkAbortShowHideWindow(e->guid, 0))
  329. return ;
  330. break;
  331. }
  332. }
  333. if (WASABI_API_WND->rootwndIsValid(w))
  334. {
  335. if (!donecheck)
  336. {
  337. ifc_window *ww = w->findWindowByInterface(windowHolderGuid);
  338. if (ww)
  339. {
  340. WindowHolder *wh = static_cast<WindowHolder*>(ww->getInterface(windowHolderGuid));
  341. if (wh)
  342. {
  343. GUID g = wh->getCurGuid();
  344. if (g != INVALID_GUID)
  345. {
  346. donecheck = 1;
  347. if (SOM::checkAbortShowHideWindow(g, 0))
  348. return ;
  349. }
  350. }
  351. }
  352. }
  353. }
  354. // checkAbort can render w invalid !!! check again
  355. if (WASABI_API_WND->rootwndIsValid(w))
  356. {
  357. ifc_window *wnd = w->getDesktopParent();
  358. GuiObject *go = static_cast<GuiObject *>(wnd->getInterface(guiObjectGuid));
  359. if (go)
  360. {
  361. Layout *l = go->guiobject_getParentLayout();
  362. if (l)
  363. {
  364. Container *c = l->getParentContainer();
  365. if (c)
  366. {
  367. if (!WCSCASEEQLSAFE(c->getId(), L"main"))
  368. {
  369. c->close(); // deferred if needed
  370. }
  371. else
  372. {
  373. softclose:
  374. ifc_window *wnd = w->findWindowByInterface(windowHolderGuid);
  375. if (wnd != NULL)
  376. {
  377. WindowHolder *wh = static_cast<WindowHolder *>(wnd->getInterface(windowHolderGuid));
  378. if (wh != NULL)
  379. {
  380. wh->onRemoveWindow(1);
  381. }
  382. }
  383. }
  384. }
  385. else goto softclose;
  386. }
  387. }
  388. }
  389. }
  390. int SkinEmbedder::getNumItems(GUID g)
  391. {
  392. int n = 0;
  393. for (int i = 0;i < wndholders.getNumItems();i++)
  394. if (wndholders.enumItem(i)->getRootWndPtr()->isVisible() && wndholders.enumItem(i)->getCurGuid() == g) n++;
  395. return n;
  396. }
  397. int SkinEmbedder::getNumItems(const wchar_t *groupid)
  398. {
  399. int n = 0;
  400. for (int i = 0;i < wndholders.getNumItems();i++)
  401. {
  402. WindowHolder *wh = wndholders.enumItem(i);
  403. if (wh->getRootWndPtr()->isVisible()
  404. && WCSCASEEQLSAFE(wh->getCurGroupId(), groupid))
  405. n++;
  406. }
  407. return n;
  408. }
  409. ifc_window *SkinEmbedder::enumItem(GUID g, int n)
  410. {
  411. ASSERT(n >= 0);
  412. for (int i = 0;i < wndholders.getNumItems();i++)
  413. {
  414. WindowHolder *wh = wndholders.enumItem(i);
  415. if (wh->getCurGuid() == g)
  416. {
  417. ifc_window *w = wh->getRootWndPtr();
  418. Container *c = NULL;
  419. if (w)
  420. {
  421. w = w->getDesktopParent();
  422. if (w)
  423. {
  424. Layout *l = static_cast<Layout *>(w->getInterface(layoutGuid));
  425. if (l)
  426. {
  427. c = l->getParentContainer();
  428. }
  429. }
  430. }
  431. if (c && c->isVisible() || (!c && wndholders.enumItem(i)->getRootWndPtr()->isVisible()))
  432. {
  433. if (n == 0)
  434. return wndholders.enumItem(i)->getCurRootWnd();
  435. n--;
  436. }
  437. }
  438. }
  439. return NULL;
  440. }
  441. ifc_window *SkinEmbedder::enumItem(const wchar_t *groupid, int n)
  442. {
  443. ASSERT(n >= 0);
  444. for (int i = 0;i < wndholders.getNumItems();i++)
  445. {
  446. WindowHolder *wh = wndholders.enumItem(i);
  447. const wchar_t *curgroupid = wndholders[i]->getCurGroupId();
  448. if (WCSCASEEQLSAFE(curgroupid, groupid))
  449. {
  450. ifc_window *w = wh->getRootWndPtr();
  451. Container *c = NULL;
  452. if (w)
  453. {
  454. w = w->getDesktopParent();
  455. if (w)
  456. {
  457. Layout *l = static_cast<Layout *>(w->getInterface(layoutGuid));
  458. if (l)
  459. {
  460. c = l->getParentContainer();
  461. }
  462. }
  463. }
  464. if (c && c->isVisible() || (!c && wndholders.enumItem(i)->getRootWndPtr()->isVisible()))
  465. {
  466. if (n == 0)
  467. return wndholders.enumItem(i)->getCurRootWnd();
  468. n--;
  469. }
  470. }
  471. }
  472. return NULL;
  473. }
  474. void SkinEmbedder::registerWindowHolder(WindowHolder *wh)
  475. {
  476. if (wndholders.haveItem(wh)) return ;
  477. wndholders.addItem(wh);
  478. }
  479. void SkinEmbedder::unregisterWindowHolder(WindowHolder *wh)
  480. {
  481. if (!wndholders.haveItem(wh)) return ;
  482. wndholders.removeItem(wh);
  483. }
  484. int SkinEmbedder::viewer_onItemDeleted(api_dependent *item)
  485. {
  486. foreach(in_deferred_callback)
  487. if (in_deferred_callback.getfor()->dep == item)
  488. in_deferred_callback.removeByPos(foreach_index);
  489. endfor
  490. foreach(inserted)
  491. SkinEmbedEntry *e = inserted.getfor();
  492. if (e->dep == item)
  493. {
  494. inserted.removeItem(e);
  495. allofthem.removeItem(e);
  496. delete e;
  497. break;
  498. }
  499. endfor;
  500. foreach(allofthem)
  501. SkinEmbedEntry *e = allofthem.getfor();
  502. if (e->dep == item)
  503. {
  504. allofthem.removeItem(e);
  505. delete e;
  506. break;
  507. }
  508. endfor;
  509. return 1;
  510. }
  511. void SkinEmbedder::cancelDestroyContainer(Container *c)
  512. {
  513. if (!cancel_deferred_destroy.haveItem(c)) cancel_deferred_destroy.addItem(c);
  514. }
  515. void SkinEmbedder::destroyContainer(Container *o)
  516. {
  517. ASSERT(o);
  518. //fg>disabled as of 11/4/2003, side effect of cancelling fullscreen video (ie, notifier while playing video fullscreen)
  519. //delt with the problem in basewnd directly
  520. //#ifdef WIN32
  521. //SetFocus(NULL); // FG> this avoids Win32 calling directly WM_KILLFOCUS into a child's wndproc (couldn't they just have posted the damn msg ?), who would then call some of his parent's virtual functions while it is being deleted
  522. // perhaps it would be good to add a generic way to disable most child wnd messages while the parent is being deleted
  523. //#endif
  524. cancel_deferred_destroy.removeItem(o);
  525. foreach(inserted)
  526. SkinEmbedEntry *e = inserted.getfor();
  527. if (e->container == o)
  528. {
  529. if (!in_deferred_callback.haveItem(e))
  530. in_deferred_callback.addItem(e);
  531. break;
  532. }
  533. endfor
  534. deferred_destroy.addItem(o);
  535. timerclient_setTimer(CB_DESTROYCONTAINER, 20);
  536. //o->setVisible(0);
  537. //timerclient_postDeferredCallback(CB_DESTROYCONTAINER, (intptr_t)o);
  538. }
  539. void SkinEmbedder::timerclient_timerCallback(int id)
  540. {
  541. if (id == CB_DESTROYCONTAINER)
  542. {
  543. foreach(deferred_destroy)
  544. Container *c = deferred_destroy.getfor();
  545. foreach(in_deferred_callback)
  546. if (in_deferred_callback.getfor()->container == c)
  547. {
  548. in_deferred_callback.removeByPos(foreach_index);
  549. }
  550. endfor;
  551. if (cancel_deferred_destroy.haveItem(c))
  552. {
  553. continue;
  554. }
  555. if (SkinParser::isContainer(c)) // otherwise i'ts already gone while we were waiting for the callback, duh!
  556. delete c;
  557. endfor
  558. cancel_deferred_destroy.removeAll();
  559. deferred_destroy.removeAll();
  560. timerclient_killTimer(CB_DESTROYCONTAINER);
  561. return ;
  562. }
  563. TimerClientDI::timerclient_timerCallback(id);
  564. }
  565. int SkinEmbedder::timerclient_onDeferredCallback(intptr_t p1, intptr_t p2)
  566. {
  567. return TimerClientDI::timerclient_onDeferredCallback(p1, p2);
  568. }
  569. #ifdef WASABI_COMPILE_CONFIG
  570. void SkinEmbedder::saveState()
  571. {
  572. int i = 0;
  573. wchar_t t[1024] = {0};
  574. foreach(inserted)
  575. SkinEmbedEntry *e = inserted.getfor();
  576. if (e->guid != INVALID_GUID)
  577. {
  578. nsGUID::toCharW(e->guid, t);
  579. }
  580. else
  581. {
  582. WCSCPYN(t, e->groupid, 1024);
  583. }
  584. WASABI_API_CONFIG->setStringPrivate(StringPrintfW(L"wndstatus/id/%d", i), t);
  585. WASABI_API_CONFIG->setStringPrivate(StringPrintfW(L"wndstatus/layout/%d", i), !e->layout.isempty() ? e->layout.getValue() : L"");
  586. WASABI_API_CONFIG->setIntPrivate(StringPrintfW(L"wndstatus/flag/%d", i), e->required);
  587. i++;
  588. endfor;
  589. WASABI_API_CONFIG->setStringPrivate(StringPrintfW(L"wndstatus/id/%d", i), L"");
  590. WASABI_API_CONFIG->setStringPrivate(StringPrintfW(L"wndstatus/layout/%d", i), L"");
  591. WASABI_API_CONFIG->setIntPrivate(StringPrintfW(L"wndstatus/flag/%d", i), 0);
  592. }
  593. void SkinEmbedder::restoreSavedState()
  594. {
  595. int i = 0;
  596. wchar_t t[1024] = {0};
  597. wchar_t l[256] = {0};
  598. while (1)
  599. {
  600. WASABI_API_CONFIG->getStringPrivate(StringPrintfW(L"wndstatus/id/%d", i), t, 1024, L"");
  601. if (!*t) break;
  602. WASABI_API_CONFIG->getStringPrivate(StringPrintfW(L"wndstatus/layout/%d", i), l, 256, L"");
  603. int flag = WASABI_API_CONFIG->getIntPrivate(StringPrintfW(L"wndstatus/flag/%d", i), 0);
  604. GUID g = nsGUID::fromCharW(t);
  605. //ifc_window *created = NULL;
  606. //int tried = 0;
  607. if (g != INVALID_GUID)
  608. {
  609. ifc_window *w = enumItem(g, 0);
  610. if (w == NULL)
  611. {
  612. //tried = 1;
  613. /*created = */create(g, l, flag);
  614. }
  615. }
  616. else
  617. {
  618. ifc_window *w = enumItem(t, 0);
  619. if (w == NULL)
  620. {
  621. //tried = 1;
  622. /*created = */create(t, l, flag);
  623. }
  624. }
  625. /* if (tried && !created) {
  626. for (int j=0;j<inserted.getNumItems();j++) {
  627. SkinEmbedEntry *e = inserted.enumItem(j);
  628. int yes = 0;
  629. if (g != INVALID_GUID) {
  630. if (e->guid == g && e->required == flag && STRCASEEQLSAFE(e->layout, l))
  631. yes = 1;
  632. } else {
  633. if (STRCASEEQLSAFE(e->groupid, t) && e->required == flag && STRCASEEQLSAFE(e->layout, l))
  634. yes = 1;
  635. }
  636. if (yes) {
  637. inserted.removeByPos(j);
  638. j--;
  639. delete e;
  640. }
  641. }
  642. }*/
  643. i++;
  644. }
  645. }
  646. #endif
  647. void SkinEmbedder::attachToSkin(ifc_window *w, int side, int size)
  648. {
  649. RECT r;
  650. if (w == NULL) return ;
  651. ifc_window *_w = w->getDesktopParent();
  652. if (_w == NULL) _w = w;
  653. SkinParser::getSkinRect(&r, _w);
  654. switch (side)
  655. {
  656. case SKINWND_ATTACH_RIGHT:
  657. _w->resize(r.right, r.top, size, r.bottom - r.top);
  658. break;
  659. case SKINWND_ATTACH_TOP:
  660. _w->resize(r.left, r.top - size, r.right - r.left, size);
  661. break;
  662. case SKINWND_ATTACH_LEFT:
  663. _w->resize(r.left - size, r.top, size, r.bottom - r.top);
  664. break;
  665. case SKINWND_ATTACH_BOTTOM:
  666. _w->resize(r.left, r.bottom, r.right - r.left, size);
  667. break;
  668. }
  669. }
  670. PtrList<SkinEmbedEntry> SkinEmbedder::in_deferred_callback;
  671. PtrList<Container> SkinEmbedder::cancel_deferred_destroy;
  672. PtrList<Container> SkinEmbedder::deferred_destroy;