1
0

layout.cpp 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586
  1. #include <precomp.h>
  2. #include <api/skin/widgets/mb/scriptbrowser.h>
  3. #include <tataki/bitmap/bitmap.h>
  4. #include <api/wnd/popup.h>
  5. #include <api/wndmgr/msgbox.h>
  6. #include <api/skin/widgets/group.h>
  7. #include "layout.h"
  8. #include <api/skin/skinparse.h>
  9. #include <api/skin/widgets/button.h>
  10. #include <api/core/buttons.h>
  11. #include <api/wnd/wndtrack.h>
  12. //#include <api/wac/main.h> //CUT!
  13. #include <api/skin/widgets/compbuck2.h>
  14. #include <api/wac/compon.h>
  15. #include <api/skin/skin.h>
  16. #include <api/wnd/notifmsg.h>
  17. #include <api/config/items/intarray.h>
  18. #include <api/config/items/cfgitem.h>
  19. #include <api/config/options.h>
  20. #include <api/script/script.h>
  21. #include <api/script/scriptmgr.h>
  22. #include <bfc/parse/pathparse.h>
  23. #include <api/skin/groupmgr.h>
  24. #include <api/wndmgr/skinembed.h>
  25. #include <api/skin/skinparse.h>
  26. #include <api/service/svcs/svc_action.h>
  27. #include <api/config/items/attrbool.h>
  28. #include <api/config/items/attrint.h>
  29. #include <api/wndmgr/alphamgr.h>
  30. #include <bfc/wasabi_std_wnd.h>
  31. #include <api/wnd/PaintCanvas.h>
  32. #ifdef _WIN32
  33. #include <windowsx.h> // for SetWindowRedraw
  34. #endif
  35. #ifdef WASABINOMAINAPI
  36. #include <api/wndmgr/gc.h>
  37. #include <api/syscb/callbacks/gccb.h>
  38. #endif
  39. #ifndef WM_MOUSEWHEEL
  40. #define WM_MOUSEWHEEL 0x20A
  41. #endif
  42. #define TIMER_SETTINGCHANGED 0x8791
  43. #define TIMER_AUTOOPACIFY 0x8792
  44. #define TIMER_AUTOOPACIFY2 0x8793
  45. #define TIMER_OFFSCREENCHECK 0x8794
  46. #define TIMER_TRANSPARENCY_AUTOON 0x8795
  47. #define TIMER_SAVE_POSITION 0x8796
  48. #define TIMER_SAVE_ALL_POSITIONS 0x8797
  49. #ifdef WASABI_COMPILE_CONFIG
  50. extern _bool cfg_uioptions_linkallalpha;
  51. extern _bool cfg_uioptions_linkallratio;
  52. extern _int cfg_uioptions_autoopacitylinked;
  53. extern _int cfg_uioptions_autoopacitytime;
  54. extern _int cfg_uioptions_extendautoopacity;
  55. extern _int cfg_uioptions_autoopacityfadein;
  56. extern _int cfg_uioptions_autoopacityfadeout;
  57. extern _int cfg_uioptions_linkedalpha;
  58. extern _bool cfg_options_appbarondrag;
  59. #endif
  60. AlphaMgr *alphaMgr = NULL;
  61. XMLParamPair Layout::params[] =
  62. {
  63. {LAYOUT_SETALPHA, L"ALPHA"},
  64. {LAYOUT_SETALPHABACKGROUND, L"ALPHABACKGROUND"},
  65. {LAYOUT_SETDESKTOPALPHA, L"DESKTOPALPHA"},
  66. {LAYOUT_FORCEALPHA, L"FORCEALPHA"},
  67. {LAYOUT_SETINDESKTOP, L"INDESKTOP"},
  68. {LAYOUT_SETLINKHEIGHT, L"LINKHEIGHT"},
  69. {LAYOUT_SETLINKWIDTH, L"LINKWIDTH"},
  70. {LAYOUT_SETLOCKTO, L"LOCKTO"},
  71. {LAYOUT_SETNOACTIVATION, L"NOACTIVATION"},
  72. {LAYOUT_NODOCK, L"NODOCK"},
  73. {LAYOUT_NOOFFSCREENCHECK, L"NOOFFSCREENCHECK"},
  74. {LAYOUT_NOPARENT, L"NOPARENT"},
  75. {LAYOUT_SETONTOP, L"ONTOP"},
  76. {LAYOUT_SETOSFRAME, L"OSFRAME"},
  77. {LAYOUT_SETOWNER, L"OWNER"},
  78. {LAYOUT_SNAPADJUSTBOTTOM, L"SNAPADJUSTBOTTOM"},
  79. {LAYOUT_SNAPADJUSTLEFT, L"SNAPADJUSTLEFT"},
  80. {LAYOUT_SNAPADJUSTRIGHT, L"SNAPADJUSTRIGHT"},
  81. {LAYOUT_SNAPADJUSTTOP, L"SNAPADJUSTTOP"},
  82. {LAYOUT_UNLINKED, L"UNLINKED"},
  83. {LAYOUT_RESIZABLE, L"RESIZABLE"},
  84. {LAYOUT_SCALABLE, L"SCALABLE"},
  85. };
  86. Layout::Layout()
  87. {
  88. getScriptObject()->vcpu_setInterface(layoutGuid, (void *)static_cast<Layout *>(this));
  89. getScriptObject()->vcpu_setInterface(guiResizableGuid, (void *)static_cast<GuiResizable *>(this));
  90. getScriptObject()->vcpu_setClassName(L"Layout");
  91. getScriptObject()->vcpu_setController(layoutController);
  92. #ifdef _WIN32
  93. forwardMsgWnd = INVALIDOSWINDOWHANDLE;
  94. #endif
  95. transparency_reenabled_at = 0;
  96. transparency_autooff = 0;
  97. captured = 0; resizing = 0;
  98. m_forceunlink = 0;
  99. inresize = 0;
  100. autoopacify = 0;
  101. x = 0; y = 0;
  102. #ifdef USEAPPBAR
  103. appbar_want_autohide = 1;
  104. appbar_want_alwaysontop = 1;
  105. m_allowsavedock = 0;
  106. #endif
  107. size_w = 0; size_h = 0;
  108. reg = NULL;
  109. //subregionlayers = new PtrList<Layer>;
  110. setStartHidden(TRUE);
  111. moving = 0;
  112. setVirtual(0);
  113. indesktop = 0;
  114. p_container = NULL;
  115. alpha = 255;
  116. linkedheight = NULL;
  117. linkedwidth = NULL;
  118. inlinkwidth = 0;
  119. inlinkheight = 0;
  120. wantactiv = 1;
  121. wantdesktopalpha = 0;
  122. alllayouts.addItem(this);
  123. galphadisabled = 0;
  124. lockedto = NULL;
  125. osframe = 0;
  126. scalelocked = 0;
  127. initontop = 0;
  128. wantredrawonresize = 1;
  129. getGuiObject()->guiobject_setMover(1);
  130. snap_adjust_left = snap_adjust_right = snap_adjust_top = snap_adjust_bottom = 0;
  131. disable_auto_alpha = 0;
  132. unlinked = 0;
  133. scaling = 0;
  134. transparencyoverride = -1;
  135. noparent = 0;
  136. forcealpha = 0;
  137. nodock = 0;
  138. resizable = 1;
  139. scalable = 1;
  140. nooffscreencheck = 0;
  141. m_w = m_h = m_endmovesize = 0;
  142. xuihandle = newXuiHandle();
  143. CreateXMLParameters(xuihandle);
  144. if (!alphaMgr)
  145. {
  146. alphaMgr = new AlphaMgr();
  147. #ifdef WASABI_COMPILE_CONFIG
  148. alphaMgr->setAllLinked(cfg_uioptions_linkallalpha.getValueAsInt());
  149. alphaMgr->setAutoOpacify(cfg_uioptions_autoopacitylinked.getValueAsInt());
  150. alphaMgr->setGlobalAlpha(cfg_uioptions_linkedalpha.getValueAsInt());
  151. alphaMgr->setHoldTime(cfg_uioptions_autoopacitytime.getValueAsInt());
  152. alphaMgr->setFadeInTime(cfg_uioptions_autoopacityfadein.getValueAsInt());
  153. alphaMgr->setFadeOutTime(cfg_uioptions_autoopacityfadeout.getValueAsInt());
  154. alphaMgr->setExtendAutoOpacity(cfg_uioptions_extendautoopacity.getValueAsInt());
  155. #endif
  156. }
  157. alphaMgr->addLayout(this);
  158. }
  159. void Layout::CreateXMLParameters(int master_handle)
  160. {
  161. //LAYOUT_SCRIPTPARENT::CreateXMLParameters(master_handle);
  162. int numParams = sizeof(params) / sizeof(params[0]);
  163. hintNumberOfParams(xuihandle, numParams);
  164. for (int i = 0;i < numParams;i++)
  165. addParam(xuihandle, params[i], XUI_ATTRIBUTE_IMPLIED);
  166. }
  167. Layout::~Layout()
  168. {
  169. if (transparency_reenabled_at) killTimer(TIMER_TRANSPARENCY_AUTOON);
  170. alphaMgr->removeLayout(this);
  171. killTimer(TIMER_OFFSCREENCHECK);
  172. if (lockedto) lockedto->removeLockedLayout(this);
  173. WASABI_API_WNDMGR->wndTrackRemove(this);
  174. if (reg) delete reg;
  175. alllayouts.removeItem(this);
  176. }
  177. int Layout::setXuiParam(int _xuihandle, int attrid, const wchar_t *paramname, const wchar_t *strvalue)
  178. {
  179. if (xuihandle != _xuihandle) return LAYOUT_PARENT::setXuiParam(_xuihandle, attrid, paramname, strvalue);
  180. switch (attrid)
  181. {
  182. case LAYOUT_SETDESKTOPALPHA:
  183. setWantDesktopAlpha(WTOI(strvalue));
  184. break;
  185. case LAYOUT_SETINDESKTOP:
  186. setInDesktop(WTOI(strvalue));
  187. break;
  188. case LAYOUT_SETALPHA:
  189. setAlpha(WTOI(strvalue));
  190. break;
  191. case LAYOUT_SETLINKWIDTH:
  192. setLinkWidth(strvalue);
  193. if (*strvalue && isPostOnInit() && isVisible()) onResize();
  194. break;
  195. case LAYOUT_SETLINKHEIGHT:
  196. setLinkHeight(strvalue);
  197. if (*strvalue && isPostOnInit() && isVisible()) onResize();
  198. break;
  199. case LAYOUT_SETOWNER:
  200. owner = strvalue;
  201. break;
  202. case LAYOUT_NOPARENT:
  203. setNoParent(WTOI(strvalue));
  204. break;
  205. case LAYOUT_FORCEALPHA:
  206. forcealpha = WTOI(strvalue);
  207. break;
  208. case LAYOUT_SETLOCKTO:
  209. lockto = strvalue;
  210. break;
  211. case LAYOUT_SETOSFRAME:
  212. osframe = WTOI(strvalue);
  213. break;
  214. case LAYOUT_SETALPHABACKGROUND:
  215. setAlphaBackground(strvalue);
  216. setWantDesktopAlpha(1);
  217. setDrawBackground(1);
  218. break;
  219. case LAYOUT_SETNOACTIVATION:
  220. wantactiv = WTOI(strvalue) ? 0 : 1;
  221. break;
  222. case LAYOUT_SETONTOP:
  223. initontop = WTOI(strvalue);
  224. if (isPostOnInit()) updateOnTop();
  225. break;
  226. case LAYOUT_SNAPADJUSTLEFT:
  227. snap_adjust_left = WTOI(strvalue);
  228. script_vcpu_onSnapAdjustChanged(SCRIPT_CALL, getScriptObject());
  229. #ifdef USEAPPBAR
  230. if (appbar_isDocked()) appbar_posChanged();
  231. #endif
  232. break;
  233. case LAYOUT_SNAPADJUSTTOP:
  234. snap_adjust_top = WTOI(strvalue);
  235. script_vcpu_onSnapAdjustChanged(SCRIPT_CALL, getScriptObject());
  236. #ifdef USEAPPBAR
  237. if (appbar_isDocked()) appbar_posChanged();
  238. #endif
  239. break;
  240. case LAYOUT_SNAPADJUSTRIGHT:
  241. snap_adjust_right = WTOI(strvalue);
  242. script_vcpu_onSnapAdjustChanged(SCRIPT_CALL, getScriptObject());
  243. #ifdef USEAPPBAR
  244. if (appbar_isDocked()) appbar_posChanged();
  245. #endif
  246. break;
  247. case LAYOUT_SNAPADJUSTBOTTOM:
  248. snap_adjust_bottom = WTOI(strvalue);
  249. script_vcpu_onSnapAdjustChanged(SCRIPT_CALL, getScriptObject());
  250. #ifdef USEAPPBAR
  251. if (appbar_isDocked()) appbar_posChanged();
  252. #endif
  253. break;
  254. case LAYOUT_UNLINKED:
  255. unlinked = WTOI(strvalue);
  256. if (!unlinked && isPostOnInit() && isVisible()) onResize();
  257. break;
  258. case LAYOUT_NODOCK:
  259. setNoDock(WTOI(strvalue));
  260. break;
  261. case LAYOUT_NOOFFSCREENCHECK:
  262. setNoOffscreenCheck(WTOI(strvalue));
  263. break;
  264. case LAYOUT_RESIZABLE:
  265. resizable = WTOI(strvalue);
  266. break;
  267. case LAYOUT_SCALABLE:
  268. scalable = WTOI(strvalue);
  269. break;
  270. default:
  271. return 0;
  272. }
  273. return 1;
  274. }
  275. void Layout::setLinkHeight(const wchar_t *layoutid)
  276. {
  277. linkedheight = layoutid;
  278. }
  279. void Layout::setLinkWidth(const wchar_t *layoutid)
  280. {
  281. linkedwidth = layoutid;
  282. }
  283. int Layout::onPostedMove()
  284. {
  285. updateLockedLayouts();
  286. int r = LAYOUT_PARENT::onPostedMove();
  287. Container *c = getParentContainer();
  288. if (isVisible() && c && c->isMainContainer())
  289. {
  290. #ifdef WASABI_ON_MAIN_MOVE
  291. WASABI_ON_MAIN_MOVE(gethWnd());
  292. #endif
  293. }
  294. return r;
  295. }
  296. void Layout::cancelCapture()
  297. {
  298. if (getCapture())
  299. endCapture();
  300. captured = 0;
  301. }
  302. int Layout::isOffscreen(ifc_window *w)
  303. {
  304. if (!w->isVisible()) return 0;
  305. if (nooffscreencheck) return 0;
  306. #ifdef USEAPPBAR
  307. if (appbar_isDocked()) return 0;
  308. #endif
  309. if (lockedto) return 0;
  310. RECT wr;
  311. w->getWindowRect(&wr);
  312. windowTracker->snapAdjustWindowRect(w, &wr);
  313. RECT r;
  314. int isontop = 0;
  315. if (w->getGuiObject())
  316. {
  317. isontop = WTOI(w->getGuiObject()->guiobject_getXmlParam(L"ontop"));
  318. #ifndef EXPERIMENTAL_INDEPENDENT_AOT
  319. if (WTOI(w->getGuiObject()->guiobject_getXmlParam(L"noparent")) == 0)
  320. isontop = 0;
  321. #endif
  322. }
  323. if (!isontop)
  324. {
  325. #ifdef WASABI_COMPILE_CONFIG
  326. extern _bool cfg_options_alwaysontop;
  327. isontop |= cfg_options_alwaysontop.getValueAsInt();
  328. #endif
  329. }
  330. Wasabi::Std::getViewport(&r, NULL, &wr, NULL, isontop);
  331. if (wr.right < r.left + 10 ||
  332. wr.bottom < r.top + 10 ||
  333. wr.left > r.right - 10 ||
  334. wr.top > r.bottom - 10)
  335. {
  336. return 1;
  337. } //////TO CONTINUE
  338. return 0;
  339. }
  340. void Layout::offscreenCheck()
  341. {
  342. int disabled = 0;
  343. #ifdef WASABI_CHECK_OFFSCREENCHECK_DISABLE
  344. WASABI_CHECK_OFFSCREENCHECK_DISABLE(disabled);
  345. #endif
  346. if (disabled) return ;
  347. if (!isVisible()) return ;
  348. if (moving || scaling || resizing) return ;
  349. if (isOffscreen(this))
  350. {
  351. windowTracker->startCooperativeMove(this);
  352. for (int i = 0;i < windowTracker->getNumDocked();i++)
  353. {
  354. ifc_window *w = windowTracker->enumDocked(i);
  355. Layout *l = static_cast<Layout*>(w->getInterface(layoutGuid));
  356. if (l != NULL)
  357. {
  358. if (l->getParentContainer() && l->getParentContainer()->isMainContainer())
  359. {
  360. if (!isOffscreen(l))
  361. {
  362. windowTracker->endCooperativeMove();
  363. return ;
  364. }
  365. }
  366. }
  367. }
  368. windowTracker->endCooperativeMove();
  369. RECT wr;
  370. getWindowRect(&wr);
  371. RECT nr = windowTracker->findOpenRect(wr);
  372. move(nr.left, nr.top);
  373. }
  374. }
  375. /**
  376. * This one only prevents UI resizings from layers!
  377. */
  378. int Layout::getResizable ()
  379. {
  380. return this->resizable;
  381. }
  382. /**
  383. * This one only prevents UI scalings from layers!
  384. */
  385. int Layout::getScalable ()
  386. {
  387. return this->scalable;
  388. }
  389. void Layout::setTransparencyOverride(int v)
  390. {
  391. transparencyoverride = v;
  392. if (v != -1) setTransparency(v); else updateTransparency();
  393. }
  394. #ifndef PI
  395. #define PI 3.1415926536
  396. #endif
  397. void Layout::timerCallback(int id)
  398. {
  399. if (id == TIMER_TRANSPARENCY_AUTOON)
  400. {
  401. if (!isTransparencySafe(1))
  402. {
  403. transparency_reenabled_at = 0;
  404. return ;
  405. }
  406. int n = Wasabi::Std::getTickCount() - transparency_reenabled_at;
  407. if (n < 1000) return ;
  408. else
  409. {
  410. killTimer(TIMER_TRANSPARENCY_AUTOON);
  411. transparency_autooff = 0;
  412. updateTransparency();
  413. transparency_reenabled_at = 0;
  414. }
  415. return ;
  416. }
  417. else if (id == TIMER_OFFSCREENCHECK)
  418. {
  419. offscreenCheck();
  420. return ;
  421. }
  422. else if (id == TIMER_SETTINGCHANGED)
  423. {
  424. killTimer(TIMER_SETTINGCHANGED);
  425. #ifdef _WIN32
  426. HWND parent;
  427. webserver = INVALIDOSWINDOWHANDLE;
  428. listview = INVALIDOSWINDOWHANDLE;
  429. getExplorerWindows(&parent, &listview, &webserver);
  430. if (!webserver) // active desktop now off, reposition this window zorder otherwise it will be behind the icons
  431. #ifdef WIN32
  432. SetWindowPos(gethWnd(), HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_DEFERERASE);
  433. #else
  434. bringToFront();
  435. #endif
  436. #endif
  437. }
  438. else if (id == TIMER_SAVE_ALL_POSITIONS)
  439. {
  440. killTimer(TIMER_SAVE_ALL_POSITIONS);
  441. saveAllPositions();
  442. // TODO: benski> not 100% sure we want to call into the script on the timer (maybe do it in endMove)
  443. //script_vcpu_onEndMove(SCRIPT_CALL, getScriptObject());
  444. return;
  445. }
  446. else if (id == TIMER_SAVE_POSITION)
  447. {
  448. killTimer(TIMER_SAVE_POSITION);
  449. savePosition();
  450. // TODO: benski> not 100% sure we want to call into the script on the timer (maybe do it in endMove)
  451. //script_vcpu_onEndMove(SCRIPT_CALL, getScriptObject());
  452. return;
  453. }
  454. else LAYOUT_PARENT::timerCallback(id);
  455. }
  456. void Layout::onMouseEnterLayout()
  457. {
  458. script_vcpu_onMouseEnterLayout(SCRIPT_CALL, getScriptObject());
  459. }
  460. void Layout::onMouseLeaveLayout()
  461. {
  462. script_vcpu_onMouseLeaveLayout(SCRIPT_CALL, getScriptObject());
  463. }
  464. void Layout::beginMove()
  465. {
  466. moving = 1;
  467. }
  468. void Layout::beginScale()
  469. {
  470. scaling = 1;
  471. }
  472. void Layout::beginResize()
  473. {
  474. resizing = 1;
  475. }
  476. void Layout::endMove()
  477. {
  478. if (m_endmovesize)
  479. {
  480. m_endmovesize = 0;
  481. RECT r;
  482. guiresizable_getRootWnd()->getWindowRect(&r);
  483. r.right = r.left + m_w;
  484. r.bottom = r.top + m_h;
  485. guiresizable_getRootWnd()->resizeToRect(&r);
  486. }
  487. moving = 0;
  488. // TODO: benski> do this on a resetable timer so it doesn't go so slowly
  489. if (WASABI_API_WNDMGR->wndTrackWasCooperative())
  490. setTimer(TIMER_SAVE_ALL_POSITIONS, 1000);
  491. // saveAllPositions();
  492. else
  493. setTimer(TIMER_SAVE_POSITION, 1000);
  494. //savePosition();
  495. // TODO: benski> not 100% sure we want to call into the script on the timer (maybe do it in endMove)
  496. script_vcpu_onEndMove(SCRIPT_CALL, getScriptObject());
  497. }
  498. void Layout::endScale()
  499. {
  500. scaling = 0;
  501. savePosition();
  502. fixPosition();
  503. }
  504. void Layout::endResize()
  505. {
  506. resizing = 0;
  507. RECT r;
  508. getClientRect(&r);
  509. RECT wr;
  510. getWindowRect(&wr);
  511. script_vcpu_onUserResize(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(wr.left), MAKE_SCRIPT_INT(wr.top), MAKE_SCRIPT_INT(r.right - r.left), MAKE_SCRIPT_INT(r.bottom - r.top));
  512. savePosition();
  513. }
  514. void Layout::onMove()
  515. {
  516. script_vcpu_onMove(SCRIPT_CALL, getScriptObject());
  517. }
  518. void Layout::setAutoOpacify(int a)
  519. {
  520. if (autoopacify == a) return ;
  521. autoopacify = a != -1 ? a : autoopacify;
  522. if (getParentContainer() && !getParentContainer()->isTranscient())
  523. {
  524. StringW tmp;
  525. tmp.printf(L"Skin:%s/Container:%s/Layout:%s/autoopacify", WASABI_API_SKIN->getSkinName(), getParentContainer()->getDescriptor(), getGuiObject()->guiobject_getId());
  526. IntArray::write(tmp, autoopacify);
  527. }
  528. updateTransparency();
  529. }
  530. void Layout::controlMenu()
  531. {
  532. PopupMenu pop;
  533. int x = 1;
  534. #ifdef WASABI_CHECK_CAN_EXIT
  535. WASABI_CHECK_CAN_EXIT(x)
  536. #endif
  537. if (getParentContainer() && getParentContainer()->isMainContainer())
  538. {
  539. if (x)
  540. {
  541. pop.addCommand(StringPrintfW(L"Exit %s", WASABI_API_APP->main_getAppName()), ACTION_CLOSE);
  542. pop.addSeparator();
  543. }
  544. }
  545. else
  546. {
  547. if (!getParentContainer() || getParentContainer()->canClose())
  548. {
  549. pop.addCommand(L"Close window", ACTION_CLOSE_WINDOW);
  550. pop.addSeparator();
  551. }
  552. }
  553. PopupMenu *scalemenu = new PopupMenu();
  554. scalemenu->addCommand(L"50%", ACTION_SCALE_50);
  555. scalemenu->addCommand(L"75%", ACTION_SCALE_75, FALSE, FALSE);
  556. scalemenu->addCommand(L"100%", ACTION_SCALE_100);
  557. scalemenu->addCommand(L"125%", ACTION_SCALE_125);
  558. scalemenu->addCommand(L"150%", ACTION_SCALE_150);
  559. scalemenu->addCommand(L"200%", ACTION_SCALE_200);
  560. scalemenu->addCommand(L"400%", ACTION_SCALE_400, FALSE, FALSE);
  561. pop.addSubMenu(scalemenu, L"Scale");
  562. PopupMenu *opaqmenu = new PopupMenu();
  563. opaqmenu->addCommand(L"Auto-fade", ACTION_AUTOOPACIFY, getAutoOpacify(), FALSE);
  564. opaqmenu->addSeparator();
  565. opaqmenu->addCommand(L"100%", ACTION_ALPHA_100, FALSE, FALSE);
  566. opaqmenu->addCommand(L"90%", ACTION_ALPHA_90, FALSE, FALSE);
  567. opaqmenu->addCommand(L"80%", ACTION_ALPHA_80, FALSE, FALSE);
  568. opaqmenu->addCommand(L"70%", ACTION_ALPHA_70, FALSE, FALSE);
  569. opaqmenu->addCommand(L"60%", ACTION_ALPHA_60, FALSE, FALSE);
  570. opaqmenu->addCommand(L"50%", ACTION_ALPHA_50, FALSE, FALSE);
  571. opaqmenu->addCommand(L"40%", ACTION_ALPHA_40, FALSE, FALSE);
  572. opaqmenu->addCommand(L"30%", ACTION_ALPHA_30, FALSE, FALSE);
  573. opaqmenu->addCommand(L"20%", ACTION_ALPHA_20, FALSE, FALSE);
  574. opaqmenu->addCommand(L"10%", ACTION_ALPHA_10, FALSE, FALSE);
  575. pop.addSubMenu(opaqmenu, L"Opacity", !isTransparencySafe());
  576. #ifdef EXPERIMENTAL_INDEPENDENT_AOT
  577. pop.addCommand(L"Always on top", ACTION_AOT, getAlwaysOnTop());
  578. #endif
  579. int r = pop.popAtMouse();
  580. if (r < 0) return ;
  581. onActionNotify(r, 0);
  582. }
  583. void Layout::fixPosition()
  584. {
  585. RECT r;
  586. getWindowRect(&r);
  587. RECT orig_r = r;
  588. RECT vr;
  589. RegionI reg;
  590. int i = 0;
  591. while (Wasabi::Std::enumViewports(i, &vr))
  592. {
  593. reg.addRect(&vr);
  594. i++;
  595. }
  596. RECT full;
  597. reg.getBox(&full);
  598. int dif = r.bottom - full.bottom;
  599. if (dif > 0) r.top -= dif;
  600. dif = r.right - full.right;
  601. if (dif > 0) r.left -= dif;
  602. dif = full.top - r.top;
  603. if (dif > 0) r.top += dif;
  604. dif = full.left - r.left;
  605. if (dif > 0) r.left += dif;
  606. if (orig_r.left != r.left || orig_r.top != r.top)
  607. resize(r.left, r.top, NOCHANGE, NOCHANGE);
  608. }
  609. void Layout::saveAllPositions()
  610. {
  611. // The positions are saved from the lastest to the first one
  612. // The 'Player' windows and the 'Main' windows are using the same prefix
  613. // In saving in decreasing order we are sure the lastest saved is the one for the Player
  614. for (int i = 0;i < SkinParser::script_getNumContainers();i++)
  615. {
  616. Container *c = SkinParser::script_enumContainer(i);
  617. for (int j = c->getNumLayouts() - 1;j >= 0 ;--j)
  618. {
  619. Layout *l = c->enumLayout(j);
  620. l->savePosition();
  621. }
  622. }
  623. }
  624. int Layout::forceTransparencyFlag()
  625. {
  626. return alphaMgr->needForcedTransparencyFlag(this);
  627. }
  628. void Layout::savePosition()
  629. {
  630. #ifdef WASABI_COMPILE_CONFIG
  631. if (!getParentContainer() || getParentContainer()->isTranscient())
  632. return ;
  633. if (!Wasabi::Std::Wnd::isValidWnd(getOsWindowHandle()))
  634. return ;
  635. StringW prefix = MakePrefix();
  636. StringPrintfW tmp( L"%s/odim", prefix.v() );
  637. SkinBitmap *baseTexture = getBaseTexture();
  638. if ( baseTexture )
  639. {
  640. IntArray::write( tmp, baseTexture->getWidth(), baseTexture->getHeight() );
  641. }
  642. else
  643. {
  644. IntArray::write( tmp, -2, -2 );
  645. }
  646. RECT r, rs;
  647. getClientRect(&r); // unscaled
  648. //DebugStringW( L"\nLayout::savePosition() - x = %d, y = %d, w = %d, h = %d \n", r.left, r.top, r.right - r.left, r.bottom - r.top );
  649. if (r.left == 0 && r.top == 0 && r.right == 0 && r.bottom == 0)
  650. return ;
  651. getWindowRect(&rs); // screen scaled (for x/y)
  652. tmp.printf(L"%s/rect", prefix.v());
  653. IntArray::write(tmp, rs.left, rs.top, r.right - r.left, r.bottom - r.top);
  654. //DebugStringW( L"Layout::savePosition() rect - x = %d, y = %d, w = %d, h = %d \n", rs.left, rs.top, r.right - r.left, r.bottom - r.top );
  655. getRestoredRect(&rs);
  656. tmp.printf(L"%s/restoredrect", prefix.v());
  657. IntArray::write(tmp, rs.left, rs.top, rs.right - rs.left, rs.bottom - rs.top);
  658. //DebugStringW( L"Layout::savePosition() restoredrect - x = %d, y = %d, w = %d, h = %d \n", rs.left, rs.top, rs.right - rs.left, rs.bottom - rs.top );
  659. tmp.printf(L"%s/maximized", prefix.v());
  660. // DebugString("isMaximized = %d\n", isMaximized());
  661. WASABI_API_CONFIG->setIntPrivate(tmp, isMaximized());
  662. tmp.printf(L"%s/r", prefix.v());
  663. WASABI_API_CONFIG->setStringPrivate(tmp, StringPrintfW(getRenderRatio()));
  664. tmp.printf(L"%s/sm", prefix.v());
  665. TextInfoCanvas textInfoCanvas(this);
  666. WASABI_API_CONFIG->setStringPrivate(tmp, StringPrintfW(textInfoCanvas.getSystemFontScale()));
  667. tmp.printf(L"%s/sl", prefix.v());
  668. WASABI_API_CONFIG->setStringPrivate(tmp, StringPrintfW(scalelocked));
  669. tmp.printf(L"%s/autoopacify", prefix.v());
  670. IntArray::write(tmp, autoopacify);
  671. #ifdef USEAPPBAR
  672. saveAppBarPosition();
  673. #endif
  674. #endif
  675. }
  676. #ifdef USEAPPBAR
  677. void Layout::saveAppBarPosition()
  678. {
  679. if (m_allowsavedock)
  680. {
  681. StringW prefix = MakePrefix();
  682. StringW wtmp = StringPrintfW(L"%s/appbar", prefix.v());
  683. WASABI_API_CONFIG->setIntPrivate(wtmp, appbar_getSide());
  684. wtmp.printf(L"%s/appbarontop", prefix.v());
  685. WASABI_API_CONFIG->setIntPrivate(wtmp, appbar_wantAlwaysOnTop());
  686. wtmp.printf(L"%s/appbarhidden", prefix.v());
  687. WASABI_API_CONFIG->setIntPrivate(wtmp, appbar_isHiding());
  688. wtmp.printf(L"%s/appbarisautohide", prefix.v());
  689. WASABI_API_CONFIG->setIntPrivate(wtmp, appbar_isAutoHiding());
  690. wtmp.printf(L"%s/appbarwantautohide", prefix.v());
  691. WASABI_API_CONFIG->setIntPrivate(wtmp, appbar_wantAutoHide());
  692. }
  693. }
  694. #endif
  695. void Layout::lockScale(int locked)
  696. {
  697. scalelocked = locked;
  698. StringW tmp;
  699. StringW prefix = MakePrefix();
  700. tmp.printf(L"%s/sl", prefix.v());
  701. WASABI_API_CONFIG->setStringPrivate(tmp, StringPrintfW(scalelocked));
  702. }
  703. void Layout::resize(int x, int y, int w, int h, int wantcb)
  704. {
  705. if (inresize) return ;
  706. inresize = 1;
  707. LAYOUT_PARENT::resize(x, y, w, h, wantcb);
  708. if (!lockedto)
  709. getGuiObject()->guiobject_setGuiPosition(&x, &y, &w, &h, NULL, NULL, NULL, NULL);
  710. inresize = 0;
  711. }
  712. void Layout::move(int x, int y)
  713. {
  714. //DebugStringW( L"Layout::move( x = %d, y = %d )\n", x, y );
  715. LAYOUT_PARENT::move(x, y);
  716. getGuiObject()->guiobject_setGuiPosition(&x, &y, NULL, NULL, NULL, NULL, NULL, NULL);
  717. }
  718. #define DC_CHECKLASTRESIZE 0x109
  719. #ifdef USEAPPBAR
  720. #define DC_LOADSAVEDDOCK 0x10A
  721. #endif
  722. #define DC_INVALIDATE 0x10B
  723. int Layout::onResize()
  724. {
  725. LAYOUT_PARENT::onResize();
  726. if (!abortSaving()) savePosition();
  727. RECT r;
  728. getClientRect(&r);
  729. if (!linkedwidth.isempty())
  730. {
  731. if (!inlinkwidth)
  732. {
  733. inlinkwidth = 1;
  734. RECT cr;
  735. Layout *l = getParentContainer() ? getParentContainer()->getLayout(linkedwidth) : NULL;
  736. if (l)
  737. {
  738. int _unlinked = l->isUnlinked();
  739. _unlinked |= isUnlinked();
  740. if (!_unlinked)
  741. {
  742. l->getClientRect(&cr);
  743. POINT pt;
  744. l->getPosition(&pt);
  745. l->resize(pt.x, pt.y, r.right - r.left, cr.bottom - cr.top);
  746. }
  747. }
  748. inlinkwidth = 0;
  749. }
  750. }
  751. if (!linkedheight.isempty())
  752. {
  753. if (!inlinkheight)
  754. {
  755. inlinkheight = 1;
  756. RECT cr;
  757. Layout *l = getParentContainer() ? getParentContainer()->getLayout(linkedheight) : NULL;
  758. if (l)
  759. {
  760. int _unlinked = l->isUnlinked();
  761. _unlinked |= isUnlinked();
  762. if (!_unlinked)
  763. {
  764. l->getClientRect(&cr);
  765. POINT pt;
  766. l->getPosition(&pt);
  767. l->resize(pt.x, pt.y, cr.right - cr.left, r.bottom - r.top);
  768. }
  769. }
  770. }
  771. inlinkheight = 0;
  772. }
  773. updateLockedLayouts();
  774. postDeferredCallback(DC_CHECKLASTRESIZE);
  775. return 1;
  776. }
  777. int Layout::onDeferredCallback(intptr_t p1, intptr_t p2)
  778. {
  779. /* if (p1 == DC_CHECKLASTRESIZE) {
  780. RECT vr;
  781. RECT r;
  782. RECT wr;
  783. Std::getViewport(&vr, NULL, NULL, gethWnd(), 1);
  784. if (renderRatioActive())
  785. divRatio(&vr);
  786. getClientRect(&r);
  787. r.bottom -= snap_adjust_bottom;
  788. r.top += snap_adjust_top;
  789. r.right -= snap_adjust_right;
  790. r.left += snap_adjust_left;
  791. getWindowRect(&wr);
  792. int n = 0;
  793. if (r.right-r.left > vr.right-vr.left) { r.right = r.left + vr.right-vr.left; n++; }
  794. if (r.bottom-r.top > vr.bottom-vr.top) { r.bottom = r.top + vr.bottom-vr.top; n++; }
  795. if (n) resize(wr.left, wr.top, r.right-r.left+snap_adjust_left+snap_adjust_right, r.bottom-r.top+snap_adjust_top+snap_adjust_bottom);
  796. } else */
  797. #ifdef USEAPPBAR
  798. if (p1 == DC_LOADSAVEDDOCK)
  799. {}
  800. #endif
  801. if (p1 == DC_INVALIDATE)
  802. {
  803. invalidate();
  804. }
  805. return LAYOUT_PARENT::onDeferredCallback(p1, p2);
  806. // return 1;
  807. }
  808. void Layout::updateLockedLayouts()
  809. {
  810. for (int i = 0;i < getNumLockedLayouts();i++)
  811. {
  812. Layout *l = enumLockedLayout(i);
  813. if (l->getRenderRatio() != getRenderRatio())
  814. l->setRenderRatio(getRenderRatio());
  815. int x, y, w, h;
  816. l->getGuiObject()->guiobject_getGuiPosition(&x, &y, &w, &h, NULL, NULL, NULL, NULL);
  817. RECT r;
  818. l->getClientRect(&r);
  819. if (w == AUTOWH) w = r.right - r.left;
  820. if (h == AUTOWH) h = r.bottom - r.top;
  821. POINT pt;
  822. l->getPosition(&pt);
  823. if (x == AUTOWH) x = pt.x; else clientToScreen(&x, NULL);
  824. if (y == AUTOWH) y = pt.y; else clientToScreen(NULL, &y);
  825. RECT cr;
  826. l->getWindowRect(&cr);
  827. if (cr.left != x || cr.top != y || cr.right != cr.left + w || cr.bottom != cr.top + h)
  828. l->Group::resize(x, y, w, h);
  829. }
  830. }
  831. int Layout::isClickThrough()
  832. {
  833. return 0;
  834. }
  835. #ifdef _WIN32
  836. LRESULT Layout::wndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  837. {
  838. #ifdef ON_CUSTOM_ALTF4
  839. if (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN)
  840. if (wParam == VK_F4)
  841. if (GetAsyncKeyState(VK_MENU)&0x8000) ON_CUSTOM_ALTF4;
  842. #endif
  843. if (uMsg == WM_KILLFOCUS || uMsg == WM_SETFOCUS)
  844. {
  845. alphaMgr->hoverCheck(this);
  846. }
  847. if (forwardMsgWnd != INVALIDOSWINDOWHANDLE)
  848. {
  849. switch (uMsg)
  850. {
  851. case WM_MOUSEWHEEL:
  852. return (SendMessageW(forwardMsgWnd, uMsg, wParam, 0x31337)); // 0x31337 avoid main window callback
  853. //case WM_DESTROY: //FG> commented out, makes wa quit when layout is destroyed
  854. case WM_CLOSE:
  855. return (SendMessageW(forwardMsgWnd, uMsg, wParam, lParam));
  856. case WM_SETTINGCHANGE:
  857. {
  858. if (!indesktop) break;
  859. setTimer(TIMER_SETTINGCHANGED, 1000);
  860. }
  861. break; //BU think this should be here eh
  862. #ifdef WIN32
  863. case 0x0319:
  864. { // hehe --BU
  865. if (lParam & 0x20000)
  866. FireAction(L"NEXT", NULL, 0, 0, NULL, 0, NULL, FALSE);
  867. else
  868. FireAction(L"PREV", NULL, 0, 0, NULL, 0, NULL, FALSE);
  869. }
  870. break;
  871. #endif
  872. /*
  873. WIP: This won't work anymore. What should we do about it? -- mig
  874. childNotify(NULL, CHILD_NOTIFY_LEFTPUSH, ACTION_NEXT);
  875. break;
  876. */
  877. }
  878. }
  879. return LAYOUT_PARENT::wndProc(hWnd, uMsg, wParam, lParam);
  880. }
  881. #else
  882. OSStatus Layout::eventHandler(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData)
  883. {
  884. return LAYOUT_PARENT::eventHandler(inHandlerCallRef, inEvent, inUserData);
  885. }
  886. #warning port me
  887. #endif
  888. /*int Layout::onRightButtonDown(int x, int y) {
  889. LAYOUT_PARENT::onRightButtonDown(x, y);
  890. // Main::appContextMenu(this, TRUE, isTransparencySafe());
  891. return 1;
  892. }*/
  893. ifc_window *Layout::getCustomOwner()
  894. {
  895. if (noparent) return NULL;
  896. if (owner.isempty()) return NULL;
  897. return SkinParser::getLayout(owner);
  898. }
  899. void Layout::addLockedLayout(Layout *l)
  900. {
  901. locked.addItem(l);
  902. updateLockedLayouts();
  903. }
  904. void Layout::removeLockedLayout(Layout *l)
  905. {
  906. locked.removeItem(l);
  907. }
  908. int Layout::getNumLockedLayouts()
  909. {
  910. return locked.getNumItems();
  911. }
  912. Layout *Layout::enumLockedLayout(int n)
  913. {
  914. return locked.enumItem(n);
  915. }
  916. int Layout::isLocked()
  917. {
  918. return (!lockto.isempty()
  919. #ifdef USEAPPBAR
  920. || cfg_options_appbarondrag == 0 && appbar_isDocked()
  921. #endif
  922. );
  923. }
  924. void Layout::lockTo(Layout *t)
  925. {
  926. if (t == NULL) return ;
  927. if (lockedto) lockedto->removeLockedLayout(this);
  928. lockedto = t;
  929. t->addLockedLayout(this);
  930. }
  931. Layout *Layout::getLockedTo()
  932. {
  933. return lockedto;
  934. }
  935. int Layout::reinit(OSMODULEHANDLE inst, OSWINDOWHANDLE parent, int nochild)
  936. {
  937. StringW osname = getOSWndName();
  938. ASSERTPR(!indesktop, "in desktop reinit failed");
  939. if (noparent)
  940. parent = NULL;
  941. int r = LAYOUT_PARENT::reinit(inst, parent, nochild);
  942. setOSWndName(osname);
  943. return r;
  944. }
  945. int Layout::init(OSMODULEHANDLE inst, OSWINDOWHANDLE parent, int nochild)
  946. {
  947. if (noparent) parent = NULL;
  948. if (!indesktop) return LAYOUT_PARENT::init(inst, parent, nochild);
  949. #ifdef _WIN32
  950. webserver = INVALIDOSWINDOWHANDLE;
  951. listview = INVALIDOSWINDOWHANDLE;
  952. getExplorerWindows(&parent, &listview, &webserver);
  953. if (!parent)
  954. {
  955. indesktop = 0;
  956. return LAYOUT_PARENT::init(inst, parent, nochild);
  957. }
  958. #endif
  959. nochild = 0;
  960. #ifdef _WIN32
  961. // if active desktop is off, that's all we can do, we'll be on top of the icons
  962. // if active desktop is on, but listview is not, we'll be on top of active desktop
  963. if (!webserver || !listview) return LAYOUT_PARENT::init(inst, parent, nochild);
  964. #endif
  965. #ifdef WIN32
  966. // find who we're gonna sit on top of
  967. HWND behind = listview;
  968. if (GetWindow(listview, GW_HWNDPREV))
  969. behind = GetWindow(listview, GW_HWNDPREV);
  970. #else
  971. DebugString( "portme -- Layout::init\n" );
  972. #endif
  973. int r = LAYOUT_PARENT::init(inst, parent, nochild);
  974. #ifdef WIN32
  975. SetWindowPos(gethWnd(), behind, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_DEFERERASE);
  976. #endif
  977. return r;
  978. }
  979. #ifdef WIN32
  980. void Layout::getExplorerWindows(OSWINDOWHANDLE *parent, OSWINDOWHANDLE *listview, OSWINDOWHANDLE *webserver)
  981. {
  982. *parent = NULL;
  983. *listview = NULL;
  984. *webserver = NULL;
  985. char classname[256] = "";
  986. HWND w;
  987. // find explorer window. todo: litestep support ?
  988. *parent = FindWindowA(NULL, "Program Manager");
  989. if (!*parent) return ;
  990. // find its first child for parenting
  991. *parent = GetWindow(*parent, GW_CHILD);
  992. if (!*parent) return ;
  993. // find the children
  994. w = GetWindow(*parent, GW_CHILD);
  995. while (w)
  996. {
  997. GetClassNameA(w, classname, 255);
  998. if (!*webserver && STRCASEEQL("Internet Explorer_Server", classname))
  999. *webserver = w;
  1000. if (!*listview && STRCASEEQL("SysListView32", classname))
  1001. *listview = w;
  1002. w = GetWindow(w, GW_HWNDNEXT);
  1003. }
  1004. }
  1005. #endif
  1006. int Layout::onInit()
  1007. {
  1008. LAYOUT_PARENT::onInit();
  1009. Container *c = getParentContainer();
  1010. if (c != NULL)
  1011. {
  1012. const wchar_t *s = c->getName();
  1013. if (s != NULL)
  1014. {
  1015. setOSWndName(s);
  1016. }
  1017. }
  1018. loadSavedState();
  1019. #ifdef WA3COMPATIBILITY
  1020. setIcon(WASABI_API_APP->main_getIcon(TRUE), TRUE);
  1021. setIcon(WASABI_API_APP->main_getIcon(FALSE), FALSE);
  1022. #endif
  1023. WASABI_API_WNDMGR->wndTrackAdd(this);
  1024. if (wantDesktopAlpha() && isDesktopAlphaSafe())
  1025. desktopAlpha_autoTurnOn();
  1026. if (getBaseTexture())
  1027. {
  1028. //RECT r = {0, 0, getBaseTexture()->getWidth(), getBaseTexture()->getHeight()};
  1029. delete reg;
  1030. #ifdef _WIN32
  1031. reg = new RegionI(getBaseTexture(), NULL, 0, 0, 0, 0, 0, 0, getDesktopAlpha() ? 1 : 255);
  1032. setRegion(reg);
  1033. #else
  1034. #warning port me
  1035. #endif
  1036. }
  1037. SystemObject::onCreateLayout(this);
  1038. if (!lockto.isempty()) lockTo(SkinParser::getLayout(lockto));
  1039. updateOnTop();
  1040. setNoOffscreenCheck( -1);
  1041. return 1;
  1042. }
  1043. void Layout::updateOnTop()
  1044. {
  1045. #ifdef USEAPPBAR
  1046. if (!appbar_isDocked())
  1047. #endif
  1048. {
  1049. #ifdef EXPERIMENTAL_INDEPENDENT_AOT
  1050. setAlwaysOnTop(initontop);
  1051. #else
  1052. if (noparent)
  1053. {
  1054. int disable = 0;
  1055. #ifdef WASABI_GET_TEMPDISABLE_AOT
  1056. WASABI_GET_TEMPDISABLE_AOT(disable);
  1057. #endif
  1058. #ifdef _WIN32
  1059. if (initontop && !disable) SetWindowPos(getOsWindowHandle(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOACTIVATE);
  1060. else SetWindowPos(getOsWindowHandle(), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOACTIVATE);
  1061. #else
  1062. #warning port me
  1063. #endif
  1064. }
  1065. #endif
  1066. }
  1067. }
  1068. void Layout::loadSavedState()
  1069. {
  1070. #ifdef WASABI_COMPILE_CONFIG
  1071. StringW tmp;
  1072. #endif
  1073. wchar_t t[64] = L"";
  1074. int ow = -1;
  1075. int oh = -1;
  1076. int ra = -1;
  1077. #ifdef WASABI_COMPILE_CONFIG
  1078. if (getParentContainer() && !getParentContainer()->isTranscient())
  1079. {
  1080. StringW prefix = MakePrefix();
  1081. tmp.printf(L"%s/odim", prefix.v());
  1082. IntArray::read(tmp, &ow, &oh);
  1083. tmp.printf(L"%s/alpha", prefix.v());
  1084. IntArray::read(tmp, &ra);
  1085. tmp.printf(L"%s/autoopacify", prefix.v());
  1086. IntArray::read(tmp, &autoopacify);
  1087. }
  1088. #endif
  1089. int from_scratch = 0;
  1090. if (Std::keyModifier(STDKEY_SHIFT) && Std::keyModifier(STDKEY_ALT) && Std::keyModifier(STDKEY_CONTROL)) from_scratch = 1;
  1091. #ifdef WASABI_COMPILE_CONFIG
  1092. if (getParentContainer() && !getParentContainer()->isTranscient())
  1093. {
  1094. StringW prefix = MakePrefix();
  1095. tmp.printf(L"%s/sl", prefix.v());
  1096. WASABI_API_CONFIG->getStringPrivate(tmp, t, 63, L"0");
  1097. lockScale(WTOI(t));
  1098. }
  1099. #endif
  1100. *t = 0;
  1101. #ifdef WASABI_COMPILE_CONFIG
  1102. if (getParentContainer() && !getParentContainer()->isTranscient())
  1103. {
  1104. StringW prefix = MakePrefix();
  1105. tmp.printf(L"%s/sm", prefix.v());
  1106. }
  1107. WASABI_API_CONFIG->getStringPrivate(tmp, t, 63, L"1.");
  1108. //double sm = (float)WTOF(t);
  1109. #else
  1110. //double sm = 1.0;
  1111. #endif
  1112. /*if (ABS(sm - Canvas::getSystemFontScale()) > 0.001)
  1113. from_scratch = 1;*/
  1114. if (Group::getBaseTexture() && alphabackground.getBitmap() != NULL)
  1115. {
  1116. if (Group::getBaseTexture()->getWidth() != alphabackground.getWidth() || Group::getBaseTexture()->getHeight() != alphabackground.getHeight())
  1117. {
  1118. ASSERTPR(0, StringPrintf("layout %S should have same size for background and alphabackground", getGuiObject()->guiobject_getParentLayout()->getGuiObject()->guiobject_getId()));
  1119. }
  1120. }
  1121. if ((ow != -2 && oh != -2) && (ow == -1 || oh == -1 || (getBaseTexture() && (ow != getBaseTexture()->getWidth() || oh != getBaseTexture()->getHeight()))))
  1122. from_scratch = 1;
  1123. int w = 0, h = 0;
  1124. int findrect = 0;
  1125. if (from_scratch || (getParentContainer() && getParentContainer()->isTranscient()))
  1126. {
  1127. if (getParentContainer())
  1128. {
  1129. int _x = getParentContainer()->getDefaultPositionX();
  1130. int _y = getParentContainer()->getDefaultPositionY();
  1131. x = _x == -1 ? x : _x;
  1132. y = _y == -1 ? y : _y;
  1133. if (x == -1 && y == -1) findrect = 1;
  1134. }
  1135. else
  1136. {
  1137. int _x, _y;
  1138. getGuiObject()->guiobject_getGuiPosition(&_x, &_y, NULL, NULL, NULL, NULL, NULL, NULL);
  1139. if (_x != AUTOWH && _x != NOCHANGE) x = _x;
  1140. if (_y != AUTOWH && _y != NOCHANGE) y = _y;
  1141. }
  1142. getGuiObject()->guiobject_getGuiPosition(NULL, NULL, &w, &h, NULL, NULL, NULL, NULL);
  1143. if (w == AUTOWH || h == AUTOWH)
  1144. {
  1145. w = getPreferences(SUGGESTED_W);
  1146. h = getPreferences(SUGGESTED_H);
  1147. int _minx = getPreferences(MINIMUM_W);
  1148. int _maxx = getPreferences(MAXIMUM_W);
  1149. int _miny = getPreferences(MINIMUM_H);
  1150. int _maxy = getPreferences(MAXIMUM_H);
  1151. if (_minx != AUTOWH && _maxx != AUTOWH && _minx > _maxx) _minx = _maxx;
  1152. if (_miny != AUTOWH && _maxy != AUTOWH && _miny > _maxy) _miny = _maxy;
  1153. if (w == AUTOWH && _minx != AUTOWH) w = _minx;
  1154. if (h == AUTOWH && _miny != AUTOWH) h = _miny;
  1155. TextInfoCanvas textInfoCanvas(this);
  1156. double fontScale = textInfoCanvas.getSystemFontScale();
  1157. if (w != AUTOWH && getGuiObject()->guiobject_getAutoSysMetricsW())
  1158. w = (int)((float)w * fontScale);
  1159. if (h != AUTOWH && getGuiObject()->guiobject_getAutoSysMetricsH())
  1160. h = (int)((float)h * fontScale);
  1161. }
  1162. }
  1163. else
  1164. {
  1165. if (getParentContainer())
  1166. {
  1167. if (getParentContainer()->isMainContainer()) //FG> could be a new component installed
  1168. SkinParser::noCenterSkin();
  1169. #ifdef WASABI_COMPILE_CONFIG
  1170. StringW prefix = MakePrefix();
  1171. tmp.printf(L"%s/rect", prefix.v());
  1172. IntArray::read(tmp, &x, &y, &w, &h);
  1173. RECT rr;
  1174. tmp.printf(L"%s/restoredrect", prefix.v());
  1175. IntArray::read(tmp, (int*)&rr.left, (int*)&rr.top, (int*)&rr.right, (int*)&rr.bottom);
  1176. rr.right += rr.left;
  1177. rr.bottom += rr.top;
  1178. tmp.printf(L"%s/maximized", prefix.v());
  1179. if (WASABI_API_CONFIG->getIntPrivate(tmp, 0)) setRestoredRect(&rr);
  1180. #endif
  1181. }
  1182. }
  1183. *t = 0;
  1184. double ratio = 1.0;
  1185. if (!from_scratch)
  1186. {
  1187. if (getParentContainer())
  1188. {
  1189. #ifdef WASABI_COMPILE_CONFIG
  1190. StringW prefix = MakePrefix();
  1191. tmp.printf(L"%s/r", prefix.v());
  1192. WASABI_API_CONFIG->getStringPrivate(tmp, t, 63, L"1.");
  1193. ratio = WTOF(t);
  1194. #else
  1195. ratio = 1.0f;
  1196. #endif
  1197. }
  1198. }
  1199. #ifdef ON_TWEAK_RENDER_RATIO
  1200. if (!scalelocked) ON_TWEAK_RENDER_RATIO(ratio);
  1201. #endif
  1202. if (w == 0 || h == 0 || from_scratch)
  1203. {
  1204. int _w = getPreferences(SUGGESTED_W);
  1205. w = _w == AUTOWH ? w : _w;
  1206. int _h = getPreferences(SUGGESTED_H);
  1207. h = _h == AUTOWH ? h : _h;
  1208. TextInfoCanvas textInfoCanvas(this);
  1209. double fontScale = textInfoCanvas.getSystemFontScale();
  1210. if (getGuiObject()->guiobject_getAutoSysMetricsW())
  1211. w = (int)((float)w * fontScale);
  1212. if (getGuiObject()->guiobject_getAutoSysMetricsH())
  1213. h = (int)((float)h * fontScale);
  1214. if (w == 0 || h == 0)
  1215. {
  1216. w = getBaseTexture()->getWidth();
  1217. h = getBaseTexture()->getHeight();
  1218. }
  1219. RECT sr = {x, y, x + w, y + h};
  1220. if (findrect)
  1221. sr = windowTracker->findOpenRect(Wasabi::Std::makeRect(0, 0, (int)((float)w * getRenderRatio()), (int)((float)h * getRenderRatio())), this);
  1222. sr.right = sr.left + w;
  1223. sr.bottom = sr.top + h;
  1224. BaseWnd::resize(&sr);
  1225. }
  1226. else
  1227. {
  1228. RECT cr;
  1229. getClientRect(&cr);
  1230. RECT r = {x, y, x + w, y + h};
  1231. BaseWnd::resize(&r);
  1232. }
  1233. setAlpha(from_scratch || ra == -1 ? alpha : ((ra < 254) ? ra : 255));
  1234. Layout *main = SkinParser::getMainLayout();
  1235. if (main != this && main
  1236. #ifdef WASABI_COMPILE_CONFIG
  1237. && cfg_uioptions_linkallratio.getValueAsInt()
  1238. #endif
  1239. && !noparent)
  1240. {
  1241. setRenderRatio(main->getRenderRatio());
  1242. }
  1243. else setRenderRatio(ratio);
  1244. setAutoOpacify(autoopacify);
  1245. #ifdef USEAPPBAR
  1246. postDeferredCallback(DC_LOADSAVEDDOCK);
  1247. if (getParentContainer() && !getParentContainer()->isTranscient())
  1248. {
  1249. StringW prefix = MakePrefix();
  1250. StringW tmp = StringPrintfW(L"%s/appbar", prefix.v());
  1251. int side = WASABI_API_CONFIG->getIntPrivate(tmp, APPBAR_NOTDOCKED);
  1252. tmp.printf(L"%s/appbarisautohide", prefix.v());
  1253. int is_autohide = WASABI_API_CONFIG->getIntPrivate(tmp, 0);
  1254. tmp.printf(L"%s/appbarwantautohide", prefix.v());
  1255. appbar_want_autohide = is_autohide || WASABI_API_CONFIG->getIntPrivate(tmp, 1);
  1256. tmp.printf(L"%s/appbarontop", prefix.v());
  1257. appbar_want_alwaysontop = WASABI_API_CONFIG->getIntPrivate(tmp, 1);
  1258. tmp.printf(L"%s/appbarhidden",prefix.v());
  1259. int curside = appbar_getSide();
  1260. if (side != curside)
  1261. {
  1262. if (side == APPBAR_NOTDOCKED)
  1263. // starting up docked ??
  1264. appbar_dock(side);
  1265. else
  1266. {
  1267. setNoParent(2);
  1268. BaseWnd::reinit();
  1269. appbar_dock(side);
  1270. }
  1271. }
  1272. }
  1273. m_allowsavedock = 1;
  1274. #endif
  1275. }
  1276. void Layout::setBaseTexture(const wchar_t *b, int regis)
  1277. {
  1278. LAYOUT_PARENT::setBaseTexture(b, 0); // 0, not regis!
  1279. if (!getDesktopAlpha() || ((wantDesktopAlpha()) && alphabackground.getBitmap() == NULL))
  1280. {
  1281. if (regis) WASABI_API_WND->skin_unregisterBaseTextureWindow(this);
  1282. if (getBaseTexture())
  1283. {
  1284. //RECT r = {0, 0, getBaseTexture()->getWidth(), getBaseTexture()->getHeight()};
  1285. delete reg;
  1286. #ifdef _WIN32
  1287. reg = new RegionI(getBaseTexture(), NULL, 0, 0, 0, 0, 0, 0, getDesktopAlpha() ? 1 : 255);
  1288. setRegion(reg);
  1289. #else
  1290. #warning port me
  1291. #endif
  1292. }
  1293. if (regis)
  1294. WASABI_API_WND->skin_registerBaseTextureWindow(this, getBackgroundStr());
  1295. }
  1296. }
  1297. void Layout::setWantDesktopAlpha(int want)
  1298. {
  1299. if (want && !Wasabi::Std::Wnd::isDesktopAlphaAvailable())
  1300. {
  1301. // WASABI_API_WNDMGR->messageBox("Desktop Alpha Blending is only available for Win2000/WinXP and above", "Sorry", MSGBOX_OK, NULL, NULL);
  1302. return ;
  1303. }
  1304. wantdesktopalpha = want;
  1305. if (wantdesktopalpha && isInited() && isDesktopAlphaSafe())
  1306. desktopAlpha_autoTurnOn();
  1307. else if (!wantdesktopalpha && getDesktopAlpha())
  1308. desktopAlpha_autoTurnOff();
  1309. }
  1310. int Layout::wantDesktopAlpha()
  1311. {
  1312. return wantdesktopalpha;
  1313. }
  1314. int Layout::handleDesktopAlpha()
  1315. {
  1316. return 1;
  1317. }
  1318. void Layout::onGuiObjectSetVisible(GuiObject *o, int visible)
  1319. {
  1320. if (disable_auto_alpha) return ;
  1321. if (!o || !o->guiobject_getRootWnd()) return ;
  1322. if (visible)
  1323. {
  1324. if (getDesktopAlpha())
  1325. {
  1326. if (!o->guiobject_getRootWnd()->handleDesktopAlpha())
  1327. {
  1328. desktopAlpha_autoTurnOff();
  1329. }
  1330. }
  1331. if (!transparency_autooff)
  1332. {
  1333. if (!o->guiobject_getRootWnd()->handleTransparency())
  1334. {
  1335. transparency_autoTurnOff();
  1336. }
  1337. }
  1338. }
  1339. else
  1340. { // !visible
  1341. if (!getDesktopAlpha() && wantDesktopAlpha())
  1342. {
  1343. if (isDesktopAlphaSafe())
  1344. desktopAlpha_autoTurnOn();
  1345. }
  1346. if (transparency_autooff)
  1347. {
  1348. if (isTransparencySafe(1))
  1349. transparency_autoTurnOn();
  1350. }
  1351. }
  1352. }
  1353. void Layout::desktopAlpha_autoTurnOn()
  1354. {
  1355. setDesktopAlpha(1);
  1356. WASABI_API_WND->skin_unregisterBaseTextureWindow(this);
  1357. if (getBaseTexture())
  1358. {
  1359. //RECT r = {0, 0, getBaseTexture()->getWidth(), getBaseTexture()->getHeight()};
  1360. delete reg;
  1361. #ifdef _WIN32
  1362. reg = new RegionI(getBaseTexture(), NULL, 0, 0, 0, 0, 0, 0, 1);
  1363. setRegion(reg);
  1364. #else
  1365. #warning port me
  1366. #endif
  1367. }
  1368. WASABI_API_WND->skin_registerBaseTextureWindow(this, alphabackground.getBitmap() ? alphabackgroundstr.getValue() : getBackgroundStr());
  1369. invalidate();
  1370. }
  1371. void Layout::desktopAlpha_autoTurnOff()
  1372. {
  1373. #ifdef WIN32
  1374. SetWindowRedraw(gethWnd(), FALSE);//LockWindowUpdate(gethWnd());
  1375. setDesktopAlpha(0);
  1376. WASABI_API_WND->skin_unregisterBaseTextureWindow(this);
  1377. if (getBaseTexture())
  1378. {
  1379. //RECT r = {0, 0, getBaseTexture()->getWidth(), getBaseTexture()->getHeight()};
  1380. delete reg;
  1381. reg = new RegionI(getBaseTexture(), NULL, 0, 0, 0, 0, 0, 0, 255);
  1382. setRegion(reg);
  1383. }
  1384. WASABI_API_WND->skin_registerBaseTextureWindow(this, getBackgroundStr());
  1385. SetWindowRedraw(gethWnd(), TRUE);//LockWindowUpdate(NULL);
  1386. invalidate();
  1387. #else
  1388. DebugString( "portme -- Layout::init\n" );
  1389. #endif
  1390. }
  1391. void Layout::transparency_autoTurnOn()
  1392. {
  1393. transparency_reenabled_at = Wasabi::Std::getTickCount();
  1394. setTimer(TIMER_TRANSPARENCY_AUTOON, 500);
  1395. }
  1396. void Layout::transparency_autoTurnOff()
  1397. {
  1398. transparency_autooff = 1;
  1399. killTimer(TIMER_TRANSPARENCY_AUTOON);
  1400. updateTransparency();
  1401. }
  1402. void Layout::onGlobalEnableDesktopAlpha(int enabled)
  1403. {
  1404. foreach(alllayouts)
  1405. alllayouts.getfor()->globalEnableDesktopAlpha(enabled);
  1406. endfor
  1407. #ifdef ON_TOGGLE_DESKTOPALPHA
  1408. ON_TOGGLE_DESKTOPALPHA(enabled);
  1409. #endif
  1410. }
  1411. void Layout::globalEnableDesktopAlpha(int enabled)
  1412. {
  1413. if (enabled)
  1414. {
  1415. galphadisabled = 0;
  1416. setWantDesktopAlpha(wantdesktopalpha);
  1417. }
  1418. else
  1419. {
  1420. galphadisabled = 1;
  1421. if (getDesktopAlpha())
  1422. desktopAlpha_autoTurnOff();
  1423. }
  1424. }
  1425. void Layout::setWantRedrawOnResize(int v)
  1426. {
  1427. if (wantredrawonresize == v) return ;
  1428. wantredrawonresize = v;
  1429. }
  1430. PtrList<Layout> Layout::alllayouts;
  1431. int Layout::onPaint(Canvas *canvas)
  1432. {
  1433. PaintCanvas paintcanvas;
  1434. if (canvas == NULL)
  1435. {
  1436. if (!paintcanvas.beginPaint(this)) return 0;
  1437. canvas = &paintcanvas;
  1438. }
  1439. RECT r;
  1440. if (!canvas->getClipBox(&r))
  1441. getClientRect(&r);
  1442. canvas->fillRect(&r, 0);
  1443. LAYOUT_PARENT::onPaint(canvas);
  1444. return 1;
  1445. }
  1446. /*WndHolder *Layout::getHolder() {
  1447. return this;
  1448. }*/
  1449. SkinBitmap *Layout::getBaseTexture()
  1450. {
  1451. #ifdef WASABI_COMPILE_CONFIG
  1452. // {9149C445-3C30-4e04-8433-5A518ED0FDDE}
  1453. const GUID uioptions_guid =
  1454. { 0x9149c445, 0x3c30, 0x4e04, { 0x84, 0x33, 0x5a, 0x51, 0x8e, 0xd0, 0xfd, 0xde } };
  1455. int alphaenabled = _intVal(WASABI_API_CONFIG->config_getCfgItemByGuid(uioptions_guid), L"Enable desktop alpha");
  1456. #else
  1457. int alphaenabled = WASABI_WNDMGR_DESKTOPALPHA;
  1458. #endif
  1459. if (!alphabackground.getBitmap() || !getDesktopAlpha() || !alphaenabled) return LAYOUT_PARENT::getBaseTexture();
  1460. return alphabackground.getBitmap();
  1461. }
  1462. int Layout::runAction(int actionid, const wchar_t *param)
  1463. {
  1464. switch (actionid)
  1465. {
  1466. case ACTION_SWITCH:
  1467. if (getParentContainer())
  1468. {
  1469. getParentContainer()->switchToLayout(param);
  1470. }
  1471. break;
  1472. case ACTION_TOGGLE:
  1473. SkinParser::toggleContainer(param);
  1474. break;
  1475. #ifdef WA3COMPATIBILITY
  1476. case ACTION_MENU:
  1477. Main::doMenu(param);
  1478. break;
  1479. #endif
  1480. case ACTION_ENDMODAL:
  1481. endModal(WTOI(param));
  1482. break;
  1483. case ACTION_CLOSE:
  1484. onActionNotify(ACTION_CLOSE);
  1485. break;
  1486. #ifdef WA3COMPATIBILITY
  1487. default:
  1488. if (actionid != 0)
  1489. Main::doAction(actionid);
  1490. break;
  1491. #else
  1492. case ACTION_MINIMIZE:
  1493. #ifdef _WIN32
  1494. ShowWindow(WASABI_API_WND->main_getRootWnd()->gethWnd(), SW_MINIMIZE);
  1495. #endif
  1496. break;
  1497. #endif
  1498. }
  1499. return 0;
  1500. }
  1501. int Layout::childNotify(ifc_window *child, int msg, intptr_t param1, intptr_t param2)
  1502. {
  1503. if (msg == ACTION_ENFORCEMINMAX)
  1504. {
  1505. loadSavedState();
  1506. return 0;
  1507. }
  1508. if (child != NULL)
  1509. {
  1510. int objId = child->getNotifyId();
  1511. if (msg == ChildNotify::BUTTON_LEFTPUSH)
  1512. {
  1513. switch (objId)
  1514. {
  1515. case ACTION_SWITCH:
  1516. case ACTION_TOGGLE:
  1517. case ACTION_MENU:
  1518. runAction(objId, ((Wasabi::Button *)child)->getParam());
  1519. break;
  1520. case ACTION_ENDMODAL:
  1521. {
  1522. StringPrintfW s(L"%d", (static_cast<ButtonWnd *>(child))->getModalRetCode());
  1523. runAction(ACTION_ENDMODAL, s);
  1524. }
  1525. break;
  1526. case ACTION_CLOSE:
  1527. runAction(ACTION_CLOSE);
  1528. break;
  1529. /*
  1530. #ifdef WA3COMPATIBILITY
  1531. case ACTION_EJECT:
  1532. runAction(ACTION_EJECT, "0");
  1533. break;
  1534. #endif
  1535. */
  1536. default:
  1537. runAction(objId);
  1538. break;
  1539. }
  1540. return 0;
  1541. }
  1542. if (msg == ChildNotify::BUTTON_RIGHTPUSH)
  1543. {
  1544. //FUCKO child->abortTip();
  1545. // POINT pt;
  1546. // Std::getMousePos(&pt);
  1547. // screenToClient(&pt);
  1548. // onRightButtonDown(pt.x, pt.y);
  1549. #pragma warning (disable: 4060)
  1550. switch (objId)
  1551. {
  1552. /*
  1553. #ifdef WA3COMPATIBILITY
  1554. case ACTION_EJECT: {
  1555. runAction(ACTION_EJECT, "1");
  1556. }
  1557. break;
  1558. #endif
  1559. */
  1560. }
  1561. #pragma warning (default: 4060)
  1562. return 0;
  1563. }
  1564. }
  1565. return LAYOUT_PARENT::childNotify(child, msg, param1, param2);
  1566. }
  1567. int Layout::onActionNotify(int action, intptr_t param)
  1568. {
  1569. switch (action)
  1570. {
  1571. #ifdef WA3COMPATIBILITY
  1572. case ACTION_SYSMENU:
  1573. Main::appContextMenu(this, TRUE, isDesktopAlphaSafe());
  1574. break;
  1575. case ACTION_CONTROLMENU:
  1576. controlMenu();
  1577. break;
  1578. case ACTION_WINDOWMENU:
  1579. Main::thingerContextMenu(this);
  1580. break;
  1581. #elif defined(WASABI_CUSTOM_CONTEXTMENUS)
  1582. case ACTION_SYSMENU:
  1583. extern void appContextMenu(ifc_window *w);
  1584. appContextMenu(this);
  1585. break;
  1586. case ACTION_CONTROLMENU:
  1587. extern void appControlMenu(ifc_window *w);
  1588. appControlMenu(this);
  1589. break;
  1590. #endif
  1591. case ACTION_SCALE_50: scaleTo(50); break;
  1592. case ACTION_SCALE_75: scaleTo(75); break;
  1593. case ACTION_SCALE_100: scaleTo(100); break;
  1594. case ACTION_SCALE_125: scaleTo(125); break;
  1595. case ACTION_SCALE_150: scaleTo(150); break;
  1596. case ACTION_SCALE_200: scaleTo(200); break;
  1597. case ACTION_SCALE_400: scaleTo(400); break;
  1598. case ACTION_ALPHA_10: setAlpha(25); break;
  1599. case ACTION_ALPHA_20: setAlpha(51); break;
  1600. case ACTION_ALPHA_30: setAlpha(76); break;
  1601. case ACTION_ALPHA_40: setAlpha(102); break;
  1602. case ACTION_ALPHA_50: setAlpha(127); break;
  1603. case ACTION_ALPHA_60: setAlpha(153); break;
  1604. case ACTION_ALPHA_70: setAlpha(178); break;
  1605. case ACTION_ALPHA_80: setAlpha(204); break;
  1606. case ACTION_ALPHA_90: setAlpha(229); break;
  1607. case ACTION_ALPHA_100: setAlpha(255); break;
  1608. case ACTION_AUTOOPACIFY: setAutoOpacify(!getAutoOpacify()); break;
  1609. #ifdef EXPERIMENTAL_INDEPENDENT_AOT
  1610. case ACTION_AOT: setAlwaysOnTop(!getAlwaysOnTop()); break;
  1611. #endif
  1612. case ACTION_CLOSE_WINDOW:
  1613. case ACTION_CLOSE:
  1614. if (getParentContainer() && getParentContainer()->isMainContainer())
  1615. {
  1616. int x = 1;
  1617. #ifdef WASABI_CHECK_CAN_EXIT
  1618. WASABI_CHECK_CAN_EXIT(x)
  1619. #endif
  1620. if (x)
  1621. {
  1622. WASABI_API_APP->main_shutdown();
  1623. }
  1624. }
  1625. else if (WASABI_API_WNDMGR->getModalWnd() != this)
  1626. {
  1627. if (!getParentContainer() || !getParentContainer()->isDynamic() || !getParentContainer()->canClose())
  1628. if (getParentContainer()) getParentContainer()->setVisible(FALSE); else setVisible(FALSE);
  1629. else
  1630. skinEmbedder->destroyContainer(getParentContainer());
  1631. }
  1632. else
  1633. {
  1634. endModal(MSGBOX_ABORTED);
  1635. }
  1636. break;
  1637. default: return 0;
  1638. }
  1639. return 1;
  1640. }
  1641. void Layout::containerToggled(const wchar_t *id, int visible)
  1642. {
  1643. #ifdef _WIN32
  1644. sendNotifyToAllChildren(WM_WA_CONTAINER_TOGGLED, (intptr_t)id, visible);
  1645. #else
  1646. #warning port me
  1647. #endif
  1648. }
  1649. void Layout::componentToggled(GUID *guid, int visible)
  1650. {
  1651. #ifdef _WIN32
  1652. sendNotifyToAllChildren(WM_WA_COMPONENT_TOGGLED, (intptr_t)guid, visible);
  1653. #else
  1654. #warning port me
  1655. #endif
  1656. }
  1657. void Layout::setAlphaBackground(const wchar_t *b)
  1658. {
  1659. alphabackgroundstr = b;
  1660. alphabackground.setBitmap(b);
  1661. #ifdef _WIN32
  1662. RegionI r(alphabackground.getBitmap());
  1663. setRegion(&r);
  1664. #else
  1665. #warning port me
  1666. #endif
  1667. }
  1668. /*void Layout::setWindowRegion(api_region *reg) {
  1669. LAYOUT_PARENT::setWindowRegion(reg);
  1670. if (getDesktopAlpha()) {
  1671. SetWindowRgn(gethWnd(), NULL, FALSE);
  1672. return;
  1673. }
  1674. if (!isInited()) return;
  1675. api_region *_r = getRegion();
  1676. if (getRenderRatio() != 1.0 && reg) {
  1677. api_region *clone = _r->clone();
  1678. clone->scale(getRenderRatio());
  1679. SetWindowRgn(gethWnd(), clone->makeWindowRegion(), TRUE);
  1680. _r->disposeClone(clone);
  1681. } else {
  1682. SetWindowRgn(gethWnd(), _r ? _r->makeWindowRegion() : NULL, TRUE);
  1683. }
  1684. }*/
  1685. void Layout::onSetDesktopAlpha(int a)
  1686. {
  1687. invalidateWindowRegion();
  1688. }
  1689. void Layout::onShow(void)
  1690. {
  1691. savePosition();
  1692. if (!WASABI_API_MAKI->vcpu_getComplete()) SystemObject::onShowLayout(this);
  1693. }
  1694. void Layout::onHide(void)
  1695. {
  1696. savePosition();
  1697. if (!WASABI_API_MAKI->vcpu_getComplete()) SystemObject::onHideLayout(this);
  1698. #ifndef WASABINOMAINAPI
  1699. api->hintGarbageCollect();
  1700. #else
  1701. WASABI_API_SYSCB->syscb_issueCallback(SysCallback::GC, GarbageCollectCallback::GARBAGECOLLECT);
  1702. #endif
  1703. if (getParentContainer() && getParentContainer()->wantRefocusApp()) SkinParser::focusFirst();
  1704. }
  1705. #ifdef _WIN32
  1706. LPARAM Layout::wndHolder_getParentParam(int i)
  1707. {
  1708. switch (i)
  1709. {
  1710. case 0: return (LPARAM)gethWnd();
  1711. case 1: return (LPARAM)static_cast<BaseWnd*>(this);
  1712. }
  1713. return 0;
  1714. }
  1715. #endif
  1716. void Layout::onSetVisible( int show )
  1717. {
  1718. disable_auto_alpha = 1;
  1719. LAYOUT_PARENT::onSetVisible( show );
  1720. if ( show )
  1721. onShow();
  1722. else
  1723. onHide();
  1724. Container *p = getParentContainer();
  1725. if ( p )
  1726. p->onChildSetLayoutVisible( this, show );
  1727. disable_auto_alpha = 0;
  1728. if ( wantDesktopAlpha() && isDesktopAlphaSafe() )
  1729. desktopAlpha_autoTurnOn();
  1730. }
  1731. void Layout::scaleTo(int s)
  1732. {
  1733. beginScale();
  1734. setRenderRatio((double)s / 100.0);
  1735. endScale();
  1736. }
  1737. void Layout::setRenderRatio(double s)
  1738. {
  1739. if (isPostOnInit()
  1740. #ifdef WASABI_COMPILE_CONFIG
  1741. && cfg_uioptions_linkallratio.getValueAsInt() == 1
  1742. #endif
  1743. && !broadcasting)
  1744. {
  1745. broadcasting = 1;
  1746. SkinParser::setAllLayoutsRatio(s);
  1747. broadcasting = 0;
  1748. return ;
  1749. }
  1750. if (getRenderRatio() == s) return ;
  1751. LAYOUT_PARENT::setRenderRatio(s);
  1752. if (reg) invalidateWindowRegion();
  1753. invalidate();
  1754. foreach(locked)
  1755. locked.getfor()->setRenderRatio(s);
  1756. endfor;
  1757. if (lockedto && lockedto->getRenderRatio() != getRenderRatio())
  1758. lockedto->setRenderRatio(getRenderRatio());
  1759. script_vcpu_onScale(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_DOUBLE(s));
  1760. if (!abortSaving()) savePosition();
  1761. }
  1762. void Layout::setAlpha(int a)
  1763. {
  1764. int old = alpha;
  1765. alpha = a;
  1766. updateTransparency();
  1767. #ifdef WASABI_COMPILE_CONFIG
  1768. if (old != alpha && getParentContainer())
  1769. {
  1770. StringPrintfW tmp(L"Skin:%s/Container:%s/Layout:%s/alpha", WASABI_API_SKIN->getSkinName(), getParentContainer()->getDescriptor(), getGuiObject()->guiobject_getId());
  1771. IntArray::write(tmp, alpha);
  1772. }
  1773. #endif
  1774. }
  1775. int Layout::getAlpha()
  1776. {
  1777. return alpha;
  1778. }
  1779. void Layout::setPaintingAlpha(int activealpha, int inactivealpha)
  1780. { // from basewnd, called by gui object
  1781. LAYOUT_PARENT::setAlpha(activealpha, inactivealpha);
  1782. updateTransparency();
  1783. }
  1784. int Layout::getPaintingAlpha()
  1785. { // from basewnd, called by gui object
  1786. return getAlpha();
  1787. }
  1788. int Layout::onActivate()
  1789. {
  1790. LAYOUT_PARENT::onActivate();
  1791. // activateChildren(1);
  1792. updateTransparency();
  1793. return 1;
  1794. }
  1795. int Layout::onKillFocus()
  1796. {
  1797. alphaMgr->hoverCheck(this);
  1798. int r = LAYOUT_PARENT::onKillFocus();
  1799. return r;
  1800. }
  1801. int Layout::onGetFocus()
  1802. {
  1803. alphaMgr->hoverCheck(this);
  1804. int r = LAYOUT_PARENT::onGetFocus();
  1805. return r;
  1806. }
  1807. int Layout::onDeactivate()
  1808. {
  1809. LAYOUT_PARENT::onDeactivate();
  1810. // activateChildren(0);
  1811. updateTransparency();
  1812. return 1;
  1813. }
  1814. void Layout::updateTransparency()
  1815. {
  1816. alphaMgr->updateTransparency(this);
  1817. }
  1818. /*
  1819. void Layout::activateChildren(int act) {
  1820. for (int i=0;i<gui_objects.getNumItems();i++) {
  1821. GuiObject *o = gui_objects.enumItem(i);
  1822. BaseWnd *b = NULL;
  1823. if (o)
  1824. b = o->getBaseWnd();
  1825. else
  1826. ASSERT(0);
  1827. if (b) {
  1828. if (act)
  1829. b->onActivate();
  1830. else
  1831. b->onDeactivate();
  1832. }
  1833. }
  1834. }*/
  1835. void Layout::center()
  1836. {
  1837. RECT r;
  1838. getNonClientRect(&r);
  1839. RECT vw;
  1840. Wasabi::Std::getViewport(&vw, NULL, NULL, gethWnd());
  1841. int x = ((vw.right - vw.left) - (r.right - r.left)) / 2;
  1842. int y = ((vw.bottom - vw.top) - (r.bottom - r.top)) / 2;
  1843. move(x, y);
  1844. }
  1845. void Layout::setParentContainer(Container *c)
  1846. {
  1847. p_container = c;
  1848. }
  1849. Container *Layout::getParentContainer()
  1850. {
  1851. return p_container;
  1852. }
  1853. int Layout::isLayout()
  1854. {
  1855. return 1;
  1856. }
  1857. void Layout::setInDesktop(int a)
  1858. {
  1859. ASSERTPR(!isInited(), "cannot change indesktop after init");
  1860. indesktop = a;
  1861. }
  1862. int Layout::getInDesktop()
  1863. {
  1864. return indesktop;
  1865. }
  1866. int Layout::isDesktopAlphaSafe()
  1867. {
  1868. #ifdef WASABI_COMPILE_CONFIG
  1869. if (galphadisabled) return 0;
  1870. // {9149C445-3C30-4e04-8433-5A518ED0FDDE}
  1871. const GUID uioptions_guid =
  1872. { 0x9149c445, 0x3c30, 0x4e04, { 0x84, 0x33, 0x5a, 0x51, 0x8e, 0xd0, 0xfd, 0xde } };
  1873. if (!_intVal(WASABI_API_CONFIG->config_getCfgItemByGuid(uioptions_guid), L"Enable desktop alpha")) return 0;
  1874. #else
  1875. if (!WASABI_WNDMGR_DESKTOPALPHA) return 0;
  1876. #endif
  1877. return LAYOUT_PARENT::isDesktopAlphaSafe();
  1878. }
  1879. void Layout::setStatusText(const wchar_t *txt, int overlay)
  1880. {
  1881. foreach(statuscbs)
  1882. statuscbs.getfor()->onSetStatusText(txt, overlay);
  1883. endfor;
  1884. }
  1885. void Layout::addAppCmds(AppCmds *commands)
  1886. {
  1887. foreach(statuscbs)
  1888. statuscbs.getfor()->onAddAppCmds(commands);
  1889. endfor;
  1890. }
  1891. void Layout::removeAppCmds(AppCmds *commands)
  1892. {
  1893. foreach(statuscbs)
  1894. statuscbs.getfor()->onRemoveAppCmds(commands);
  1895. endfor;
  1896. }
  1897. void Layout::pushCompleted(int max)
  1898. {
  1899. foreach(statuscbs)
  1900. statuscbs.getfor()->pushCompleted(max);
  1901. endfor;
  1902. }
  1903. void Layout::incCompleted(int add)
  1904. {
  1905. foreach(statuscbs)
  1906. statuscbs.getfor()->incCompleted(add);
  1907. endfor;
  1908. }
  1909. void Layout::setCompleted(int pos)
  1910. {
  1911. foreach(statuscbs)
  1912. statuscbs.getfor()->setCompleted(pos);
  1913. endfor;
  1914. }
  1915. void Layout::popCompleted()
  1916. {
  1917. foreach(statuscbs)
  1918. statuscbs.getfor()->popCompleted();
  1919. endfor;
  1920. }
  1921. void Layout::registerStatusCallback(GuiStatusCallback *lcb)
  1922. {
  1923. statuscbs.addItem(lcb);
  1924. viewer_addViewItem(lcb->status_getDependencyPtr());
  1925. }
  1926. int Layout::viewer_onItemDeleted(api_dependent *item)
  1927. {
  1928. for (int i = 0;i < statuscbs.getNumItems();i++)
  1929. if (statuscbs.enumItem(i)->status_getDependencyPtr() == item)
  1930. {
  1931. statuscbs.removeByPos(i--);
  1932. }
  1933. return 1;
  1934. }
  1935. void Layout::snapAdjust(int left, int right, int top, int bottom)
  1936. {
  1937. snap_adjust_left = left;
  1938. snap_adjust_top = top;
  1939. snap_adjust_right = right;
  1940. snap_adjust_bottom = bottom;
  1941. script_vcpu_onSnapAdjustChanged(SCRIPT_CALL, getScriptObject());
  1942. #ifdef USEAPPBAR
  1943. if (appbar_isDocked()) appbar_posChanged();
  1944. #endif
  1945. if (forceTransparencyFlag() || getAlpha() < 255) postDeferredCallback(DC_INVALIDATE);
  1946. }
  1947. void Layout::getSnapAdjust(RECT *r)
  1948. {
  1949. if (!r) return ;
  1950. r->left = snap_adjust_left;
  1951. r->top = snap_adjust_top;
  1952. r->right = snap_adjust_right;
  1953. r->bottom = snap_adjust_bottom;
  1954. }
  1955. int Layout::abortSaving()
  1956. {
  1957. GuiObject *o = getGuiObject();
  1958. if (o->guiobject_movingToTarget()) return 1;
  1959. return 0;
  1960. }
  1961. void Layout::setNoOffscreenCheck(int nocheck)
  1962. {
  1963. killTimer(TIMER_OFFSCREENCHECK);
  1964. if (nocheck != -1) nooffscreencheck = nocheck;
  1965. setTimer(TIMER_OFFSCREENCHECK, 2500);
  1966. }
  1967. #ifdef USEAPPBAR
  1968. void Layout::onDock(int side)
  1969. {
  1970. script_vcpu_onDock(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(side));
  1971. }
  1972. void Layout::onUnDock()
  1973. {
  1974. script_vcpu_onUndock(SCRIPT_CALL, getScriptObject());
  1975. }
  1976. void Layout::appbar_onDock(int side)
  1977. {
  1978. onDock(side);
  1979. savePosition();
  1980. }
  1981. void Layout::appbar_onUnDock()
  1982. {
  1983. onUnDock();
  1984. savePosition();
  1985. }
  1986. void Layout::appbar_onSlide()
  1987. {
  1988. savePosition();
  1989. }
  1990. int Layout::getAppBarAutoHide()
  1991. {
  1992. return appbar_want_autohide;
  1993. }
  1994. void Layout::setAppBarAutoHide(int ah)
  1995. {
  1996. appbar_want_autohide = ah;
  1997. if (appbar_isDocked()) appbar_updateAutoHide();
  1998. savePosition();
  1999. }
  2000. int Layout::getAppBarAlwaysOnTop()
  2001. {
  2002. return appbar_want_alwaysontop;
  2003. }
  2004. void Layout::setAppBarAlwaysOnTop(int aot)
  2005. {
  2006. appbar_want_alwaysontop = aot;
  2007. if (appbar_isDocked()) appbar_updateAlwaysOnTop();
  2008. savePosition();
  2009. }
  2010. #endif
  2011. // ------------------------------------------------------------------------
  2012. LayoutScriptController _layoutController;
  2013. LayoutScriptController *layoutController = &_layoutController;
  2014. // -- Functions table -------------------------------------
  2015. function_descriptor_struct LayoutScriptController::exportedFunction[] = {
  2016. {L"onDock", 1, (void*)Layout::script_vcpu_onDock },
  2017. {L"onUndock", 0, (void*)Layout::script_vcpu_onUndock },
  2018. {L"getScale", 0, (void*)Layout::script_vcpu_getScale },
  2019. {L"setScale", 1, (void*)Layout::script_vcpu_setScale },
  2020. {L"onScale", 1, (void*)Layout::script_vcpu_onScale },
  2021. {L"setDesktopAlpha", 1, (void*)Layout::script_vcpu_setDesktopAlpha },
  2022. {L"getDesktopAlpha", 0, (void*)Layout::script_vcpu_getDesktopAlpha },
  2023. {L"isTransparencySafe", 0, (void*)Layout::script_vcpu_isTransparencySafe},
  2024. {L"isLayoutAnimationSafe", 0, (void*)Layout::script_vcpu_isLayoutAnimationSafe},
  2025. {L"getContainer", 0, (void*)Layout::script_vcpu_getContainer },
  2026. {L"center", 0, (void*)Layout::script_vcpu_center},
  2027. {L"onMove", 0, (void*)Layout::script_vcpu_onMove},
  2028. {L"onEndMove", 0, (void*)Layout::script_vcpu_onEndMove},
  2029. {L"snapAdjust", 4, (void*)Layout::script_vcpu_snapAdjust},
  2030. {L"getSnapAdjustTop", 0, (void*)Layout::script_vcpu_getSnapAdjustTop},
  2031. {L"getSnapAdjustLeft", 0, (void*)Layout::script_vcpu_getSnapAdjustLeft},
  2032. {L"getSnapAdjustRight", 0, (void*)Layout::script_vcpu_getSnapAdjustRight},
  2033. {L"getSnapAdjustBottom", 0, (void*)Layout::script_vcpu_getSnapAdjustBottom},
  2034. {L"onUserResize", 4, (void*)Layout::script_vcpu_onUserResize},
  2035. {L"setRedrawOnResize", 1, (void*)Layout::script_vcpu_setRedrawOnResize},
  2036. {L"beforeRedock", 0, (void*)Layout::script_vcpu_beforeRedock},
  2037. {L"redock", 0, (void*)Layout::script_vcpu_redock},
  2038. {L"onMouseEnterLayout", 0, (void*)Layout::script_vcpu_onMouseEnterLayout},
  2039. {L"onMouseLeaveLayout", 0, (void*)Layout::script_vcpu_onMouseLeaveLayout},
  2040. {L"onSnapAdjustChanged", 0, (void*)Layout::script_vcpu_onSnapAdjustChanged},
  2041. };
  2042. // --------------------------------------------------------
  2043. const wchar_t *LayoutScriptController::getClassName()
  2044. {
  2045. return L"Layout";
  2046. }
  2047. const wchar_t *LayoutScriptController::getAncestorClassName()
  2048. {
  2049. return L"Group";
  2050. }
  2051. int LayoutScriptController::getInstantiable()
  2052. {
  2053. return 1;
  2054. }
  2055. ScriptObject *LayoutScriptController::instantiate()
  2056. {
  2057. Layout *l = new Layout;
  2058. return l->getScriptObject();
  2059. }
  2060. void LayoutScriptController::destroy(ScriptObject *o)
  2061. {
  2062. Group *g = static_cast<Group *>(o->vcpu_getInterface(groupGuid));
  2063. if (g && GroupMgr::hasGroup(g))
  2064. {
  2065. GroupMgr::destroy(g);
  2066. return ;
  2067. }
  2068. ASSERTALWAYS("you cannot destroy a static layout");
  2069. }
  2070. void *LayoutScriptController::encapsulate(ScriptObject *o)
  2071. {
  2072. return NULL;
  2073. }
  2074. void LayoutScriptController::deencapsulate(void *o)
  2075. {}
  2076. int LayoutScriptController::getNumFunctions()
  2077. {
  2078. return sizeof(exportedFunction) / sizeof(function_descriptor_struct);
  2079. }
  2080. const function_descriptor_struct *LayoutScriptController::getExportedFunctions()
  2081. {
  2082. return exportedFunction;
  2083. }
  2084. GUID LayoutScriptController::getClassGuid()
  2085. {
  2086. return layoutGuid;
  2087. }
  2088. // -------------------------------------------------------------------------
  2089. scriptVar Layout::script_vcpu_onDock(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar side)
  2090. {
  2091. SCRIPT_FUNCTION_INIT;
  2092. PROCESS_HOOKS1(o, layoutController, side);
  2093. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2094. SCRIPT_EXEC_EVENT1(o, side);
  2095. }
  2096. scriptVar Layout::script_vcpu_onUndock(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2097. {
  2098. SCRIPT_FUNCTION_INIT;
  2099. PROCESS_HOOKS0(o, layoutController);
  2100. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2101. SCRIPT_EXEC_EVENT0(o);
  2102. }
  2103. scriptVar Layout::script_vcpu_getScale(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2104. {
  2105. SCRIPT_FUNCTION_INIT
  2106. double r = 0;
  2107. Layout *l = static_cast<Layout *>(o->vcpu_getInterface(layoutGuid));
  2108. if (l) r = l->getRenderRatio();
  2109. return MAKE_SCRIPT_DOUBLE(r);
  2110. }
  2111. scriptVar Layout::script_vcpu_setScale(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s)
  2112. {
  2113. SCRIPT_FUNCTION_INIT
  2114. double a = GET_SCRIPT_DOUBLE(s);
  2115. Layout *l = static_cast<Layout *>(o->vcpu_getInterface(layoutGuid));
  2116. if (l) l->setRenderRatio(a);
  2117. RETURN_SCRIPT_VOID;
  2118. }
  2119. scriptVar Layout::script_vcpu_onScale(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s)
  2120. {
  2121. SCRIPT_FUNCTION_INIT;
  2122. PROCESS_HOOKS1(o, layoutController, s);
  2123. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2124. SCRIPT_EXEC_EVENT1(o, s);
  2125. }
  2126. scriptVar Layout::script_vcpu_setDesktopAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s)
  2127. {
  2128. SCRIPT_FUNCTION_INIT
  2129. bool a = GET_SCRIPT_BOOLEAN(s);
  2130. Layout *l = static_cast<Layout *>(o->vcpu_getInterface(layoutGuid));
  2131. if (l) l->setWantDesktopAlpha(a);
  2132. RETURN_SCRIPT_VOID;
  2133. }
  2134. scriptVar Layout::script_vcpu_getDesktopAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2135. {
  2136. SCRIPT_FUNCTION_INIT
  2137. Layout *l = static_cast<Layout *>(o->vcpu_getInterface(layoutGuid));
  2138. if (l) return MAKE_SCRIPT_BOOLEAN(l->wantDesktopAlpha() && l->isDesktopAlphaSafe());
  2139. RETURN_SCRIPT_ZERO;
  2140. }
  2141. scriptVar Layout::script_vcpu_isTransparencySafe(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2142. {
  2143. SCRIPT_FUNCTION_INIT
  2144. Layout *l = static_cast<Layout *>(o->vcpu_getInterface(layoutGuid));
  2145. if (l) return MAKE_SCRIPT_BOOLEAN(l->isTransparencySafe());
  2146. RETURN_SCRIPT_ZERO;
  2147. }
  2148. scriptVar Layout::script_vcpu_isLayoutAnimationSafe(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2149. {
  2150. SCRIPT_FUNCTION_INIT
  2151. Layout *l = static_cast<Layout *>(o->vcpu_getInterface(layoutGuid));
  2152. if (l) return MAKE_SCRIPT_BOOLEAN(!l->forceTransparencyFlag() && (l->getAlphaMgr()->getAlpha(l) == 255));
  2153. RETURN_SCRIPT_ZERO;
  2154. }
  2155. scriptVar Layout::script_vcpu_getContainer(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2156. {
  2157. SCRIPT_FUNCTION_INIT
  2158. Layout *l = static_cast<Layout *>(o->vcpu_getInterface(layoutGuid));
  2159. if (l)
  2160. {
  2161. Container *c = l->getParentContainer();
  2162. return MAKE_SCRIPT_OBJECT(c ? c->getScriptObject() : NULL);
  2163. }
  2164. return MAKE_SCRIPT_OBJECT(NULL);
  2165. }
  2166. scriptVar Layout::script_vcpu_center(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2167. {
  2168. SCRIPT_FUNCTION_INIT
  2169. Layout *l = static_cast<Layout *>(o->vcpu_getInterface(layoutGuid));
  2170. if (l) l->center();
  2171. RETURN_SCRIPT_VOID;
  2172. }
  2173. scriptVar Layout::script_vcpu_setRedrawOnResize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v)
  2174. {
  2175. SCRIPT_FUNCTION_INIT
  2176. Layout *l = static_cast<Layout *>(o->vcpu_getInterface(layoutGuid));
  2177. if (l) l->setWantRedrawOnResize(GET_SCRIPT_INT(v));
  2178. RETURN_SCRIPT_VOID;
  2179. }
  2180. scriptVar Layout::script_vcpu_beforeRedock(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2181. {
  2182. SCRIPT_FUNCTION_INIT
  2183. Layout *l = static_cast<Layout *>(o->vcpu_getInterface(layoutGuid));
  2184. if (l) windowTracker->beforeRedock(l, &l->redock);
  2185. RETURN_SCRIPT_VOID;
  2186. }
  2187. scriptVar Layout::script_vcpu_redock(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2188. {
  2189. SCRIPT_FUNCTION_INIT
  2190. Layout *l = static_cast<Layout *>(o->vcpu_getInterface(layoutGuid));
  2191. if (l) windowTracker->afterRedock(l, &l->redock);
  2192. RETURN_SCRIPT_VOID;
  2193. }
  2194. scriptVar Layout::script_vcpu_onEndMove(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2195. {
  2196. SCRIPT_FUNCTION_INIT;
  2197. PROCESS_HOOKS0(o, layoutController);
  2198. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2199. SCRIPT_EXEC_EVENT0(o);
  2200. }
  2201. scriptVar Layout::script_vcpu_onMouseEnterLayout(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2202. {
  2203. SCRIPT_FUNCTION_INIT;
  2204. PROCESS_HOOKS0(o, layoutController);
  2205. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2206. SCRIPT_EXEC_EVENT0(o);
  2207. }
  2208. scriptVar Layout::script_vcpu_onMouseLeaveLayout(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2209. {
  2210. SCRIPT_FUNCTION_INIT;
  2211. PROCESS_HOOKS0(o, layoutController);
  2212. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2213. SCRIPT_EXEC_EVENT0(o);
  2214. }
  2215. scriptVar Layout::script_vcpu_onSnapAdjustChanged(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2216. {
  2217. SCRIPT_FUNCTION_INIT;
  2218. PROCESS_HOOKS0(o, layoutController);
  2219. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2220. SCRIPT_EXEC_EVENT0(o);
  2221. }
  2222. scriptVar Layout::script_vcpu_onUserResize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y, scriptVar w, scriptVar h)
  2223. {
  2224. SCRIPT_FUNCTION_INIT;
  2225. PROCESS_HOOKS4(o, layoutController, x, y, w, h);
  2226. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2227. SCRIPT_EXEC_EVENT4(o, x, y, w, h);
  2228. }
  2229. scriptVar Layout::script_vcpu_onMove(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2230. {
  2231. SCRIPT_FUNCTION_INIT;
  2232. PROCESS_HOOKS0(o, layoutController);
  2233. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2234. SCRIPT_EXEC_EVENT0(o);
  2235. }
  2236. scriptVar Layout::script_vcpu_snapAdjust(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar left, scriptVar top, scriptVar right, scriptVar bottom)
  2237. {
  2238. SCRIPT_FUNCTION_INIT
  2239. Layout *l = static_cast<Layout *>(o->vcpu_getInterface(layoutGuid));
  2240. if (l) l->snapAdjust(GET_SCRIPT_INT(left), GET_SCRIPT_INT(top), GET_SCRIPT_INT(right), GET_SCRIPT_INT(bottom));
  2241. RETURN_SCRIPT_VOID;
  2242. }
  2243. scriptVar Layout::script_vcpu_getSnapAdjustLeft(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2244. {
  2245. SCRIPT_FUNCTION_INIT
  2246. Layout *l = static_cast<Layout *>(o->vcpu_getInterface(layoutGuid));
  2247. if (l)
  2248. {
  2249. RECT r;
  2250. l->getSnapAdjust(&r);
  2251. return MAKE_SCRIPT_INT(r.left);
  2252. }
  2253. RETURN_SCRIPT_VOID;
  2254. }
  2255. scriptVar Layout::script_vcpu_getSnapAdjustTop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2256. {
  2257. SCRIPT_FUNCTION_INIT
  2258. Layout *l = static_cast<Layout *>(o->vcpu_getInterface(layoutGuid));
  2259. if (l)
  2260. {
  2261. RECT r;
  2262. l->getSnapAdjust(&r);
  2263. return MAKE_SCRIPT_INT(r.top);
  2264. }
  2265. RETURN_SCRIPT_VOID;
  2266. }
  2267. scriptVar Layout::script_vcpu_getSnapAdjustRight(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2268. {
  2269. SCRIPT_FUNCTION_INIT
  2270. Layout *l = static_cast<Layout *>(o->vcpu_getInterface(layoutGuid));
  2271. if (l)
  2272. {
  2273. RECT r;
  2274. l->getSnapAdjust(&r);
  2275. return MAKE_SCRIPT_INT(r.right);
  2276. }
  2277. RETURN_SCRIPT_VOID;
  2278. }
  2279. scriptVar Layout::script_vcpu_getSnapAdjustBottom(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2280. {
  2281. SCRIPT_FUNCTION_INIT
  2282. Layout *l = static_cast<Layout *>(o->vcpu_getInterface(layoutGuid));
  2283. if (l)
  2284. {
  2285. RECT r;
  2286. l->getSnapAdjust(&r);
  2287. return MAKE_SCRIPT_INT(r.bottom);
  2288. }
  2289. RETURN_SCRIPT_VOID;
  2290. }
  2291. int Layout::broadcasting = 0;
  2292. StringW Layout::MakePrefix()
  2293. {
  2294. return StringPrintfW(L"Skin:%s/Container:%s/Layout:%s", WASABI_API_SKIN->getSkinName(), getParentContainer()->getDescriptor(), getGuiObject()->guiobject_getId());
  2295. }