1
0

guiobj.cpp 93 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880
  1. #include <precomp.h>
  2. #include <bfc/wasabi_std.h>
  3. #include <api/wnd/notifmsg.h>
  4. #include <api/script/scriptmgr.h>
  5. #include <api/script/script.h>
  6. #include <api/script/objects/guiobj.h>
  7. #include <api/script/vcpu.h>
  8. #include <api/skin/widgets/group.h>
  9. //#include <api/wac/main.h>
  10. #include <math.h>
  11. #include <api/skin/skinparse.h>
  12. #include <api/wndmgr/layout.h>
  13. #include <api/script/objecttable.h>
  14. #include <api/wnd/cwndtrack.h>
  15. #include <api/wnd/popup.h>
  16. #include <bfc/parse/paramparser.h>
  17. #include <api/wnd/cursor.h>
  18. #include <api/wnd/wndtrack.h>
  19. #include <bfc/string/stringdict.h>
  20. #include <api/config/items/cfgitem.h>
  21. #include <api/config/items/attrbool.h>
  22. #ifndef PI
  23. #define PI 3.1415926536F
  24. #endif
  25. #include <api/script/objects/guiobject.h>
  26. const wchar_t guiobjectXuiStr[] = L"GuiObject"; // This is the xml tag
  27. char guiobjectXuiSvcName[] = "GuiObject xui object"; // this is the name of the xuiservice
  28. #ifdef USEAPPBAR
  29. extern _bool cfg_options_appbarondrag;
  30. #endif
  31. static wchar_t txt[4096];
  32. GuiObjectI::GuiObjectI(ScriptObject *o) {
  33. translate = 1;
  34. my_script_object = o;
  35. my_root_wnd = NULL;
  36. redock.l = NULL;
  37. MEMSET(&redock.original_rect, 0, sizeof(RECT));
  38. targetstatus = TARGET_FROZEN;
  39. targetspeed = 4;
  40. start_time = 0;
  41. reversetarget = 0;
  42. dodragcheck = 0;
  43. gui_rx = 0;
  44. gui_ry = 0;
  45. gui_rw = 0;
  46. gui_rh = 0;
  47. gui_x = 0;
  48. gui_y = 0;
  49. gui_w = AUTOWH;
  50. gui_h = AUTOWH;
  51. p_group = NULL;
  52. targetx = AUTOWH;
  53. targety = AUTOWH;
  54. targetw = AUTOWH;
  55. targeth = AUTOWH;
  56. targeta = AUTOWH;
  57. in_area = 0;
  58. clickthrough = 0;
  59. autosysmetricsx = 0;
  60. autosysmetricsy = 0;
  61. autosysmetricsw = 0;
  62. autosysmetricsh = 0;
  63. xuisvc = NULL;
  64. xuifac = NULL;
  65. mover = 0;
  66. moving = 0;
  67. droptarget = 0;
  68. #ifdef WASABI_COMPILE_CONFIG
  69. cfgitem = NULL;
  70. #endif
  71. timer.setGuiObjectI(this);
  72. wantfocus = 0;
  73. anchorage = ANCHOR_NONE;
  74. anchor_x1 = anchor_x2 = anchor_y1 = anchor_y2 = 0;
  75. anchorage_invalidated = 0;
  76. anchorage = ANCHOR_LEFT|ANCHOR_TOP;
  77. cursor = NULL;
  78. #ifdef USEAPPBAR
  79. m_dock_side = APPBAR_NOTDOCKED;
  80. #endif
  81. m_lastnondocked_x = -0xFFFF;
  82. m_lastnondocked_y = -0xFFFF;
  83. }
  84. GuiObjectI::~GuiObjectI() {
  85. notifylist.deleteAll();
  86. delete cursor;
  87. if (guiobject_getParentGroup())
  88. guiobject_getParentGroup()->removeObject(this);
  89. if (targetstatus == TARGET_RUNNING)
  90. stopTargetTimer();
  91. #ifdef WASABI_COMPILE_CONFIG
  92. if (cfgitem) viewer_delViewItem(cfgitem);
  93. #endif
  94. }
  95. ScriptObject *GuiObjectI::guiobject_getScriptObject()
  96. {
  97. return my_script_object;
  98. }
  99. // Used by us when parsing xml to assign the object's ID, shouldn't be used elsewhere
  100. void GuiObjectI::guiobject_setId(const wchar_t *id)
  101. {
  102. guiobject_id = id;
  103. }
  104. const wchar_t *GuiObjectI::guiobject_getId()
  105. {
  106. if (guiobject_id.isempty()) return L"";
  107. return guiobject_id; //FG> avoid returning NULL
  108. }
  109. int GuiObjectI::guiobject_setXmlParam(const wchar_t *paramname, const wchar_t *strvalue)
  110. {
  111. int r = 0;
  112. //ifc_window *w = guiobject_getRootWnd();
  113. XmlObject *xo = static_cast<XmlObject *>(guiobject_getScriptObject()->vcpu_getInterface(xmlObjectGuid));
  114. if (xo != NULL) {
  115. r = xo->setXmlParam(paramname, strvalue);
  116. }
  117. return r;
  118. }
  119. const wchar_t *GuiObjectI::guiobject_getXmlParam(const wchar_t *paramname) {
  120. const wchar_t *rt = NULL;
  121. //ifc_window *w = guiobject_getRootWnd();
  122. XmlObject *xo = static_cast<XmlObject *>(guiobject_getScriptObject()->vcpu_getInterface(xmlObjectGuid));
  123. if (xo != NULL) {
  124. int r = xo->getXmlParam(paramname);
  125. rt = xo->getXmlParamValue(r);
  126. }
  127. return rt;
  128. }
  129. int GuiObjectI::guiobject_setXmlParamById(int id, const wchar_t *strvalue)
  130. {
  131. int a;
  132. switch (id) {
  133. case GuiObjectWnd::GUIOBJECT_ID:
  134. guiobject_setId(strvalue);
  135. break;
  136. case GuiObjectWnd::GUIOBJECT_ALPHA:
  137. if (wcschr(strvalue, ',')) // erroneous value, this is probably a color, or something
  138. guiobject_setAlpha(255);
  139. else
  140. guiobject_setAlpha(WTOI(strvalue));
  141. break;
  142. case GuiObjectWnd::GUIOBJECT_ACTIVEALPHA:
  143. if (wcschr(strvalue, ',')) // erroneous value, this is probably a color, or something
  144. guiobject_setActiveAlpha(255);
  145. else
  146. guiobject_setActiveAlpha(WTOI(strvalue));
  147. break;
  148. case GuiObjectWnd::GUIOBJECT_INACTIVEALPHA:
  149. if (wcschr(strvalue, ',')) // erroneous value, this is probably a color, or something
  150. guiobject_setInactiveAlpha(255);
  151. else
  152. guiobject_setInactiveAlpha(WTOI(strvalue));
  153. break;
  154. case GuiObjectWnd::GUIOBJECT_SYSREGION:
  155. guiobject_setRegionOp(WASABI_API_SKIN->parse(strvalue, L"regionop"));
  156. break;
  157. case GuiObjectWnd::GUIOBJECT_RECTRGN:
  158. guiobject_setRectRgn(WTOI(strvalue));
  159. break;
  160. case GuiObjectWnd::GUIOBJECT_TOOLTIP:
  161. guiobject_getRootWnd()->setTip(strvalue);
  162. break;
  163. case GuiObjectWnd::GUIOBJECT_SYSMETRICSX:
  164. guiobject_setAutoSysMetricsX(WTOI(strvalue));
  165. break;
  166. case GuiObjectWnd::GUIOBJECT_SYSMETRICSY:
  167. guiobject_setAutoSysMetricsY(WTOI(strvalue));
  168. break;
  169. case GuiObjectWnd::GUIOBJECT_SYSMETRICSW:
  170. guiobject_setAutoSysMetricsW(WTOI(strvalue));
  171. break;
  172. case GuiObjectWnd::GUIOBJECT_SYSMETRICSH:
  173. guiobject_setAutoSysMetricsH(WTOI(strvalue));
  174. break;
  175. case GuiObjectWnd::GUIOBJECT_MOVE:
  176. guiobject_setMover(WTOI(strvalue));
  177. break;
  178. case GuiObjectWnd::GUIOBJECT_RENDERBASETEXTURE:
  179. guiobject_getRootWnd()->setRenderBaseTexture(WTOI(strvalue));
  180. break;
  181. #ifdef WASABI_COMPILE_CONFIG
  182. case GuiObjectWnd::GUIOBJECT_CFGATTR:
  183. setCfgAttr(strvalue);
  184. break;
  185. #endif
  186. case GuiObjectWnd::GUIOBJECT_TABORDER:
  187. guiobject_setTabOrder(WTOI(strvalue));
  188. break;
  189. case GuiObjectWnd::GUIOBJECT_X: {
  190. a = WTOI(strvalue);
  191. guiobject_setGuiPosition(&a, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
  192. Group *g = guiobject_getParentGroup();
  193. if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
  194. g->updatePos(this);
  195. break; }
  196. case GuiObjectWnd::GUIOBJECT_Y: {
  197. a = WTOI(strvalue);
  198. guiobject_setGuiPosition(NULL, &a, NULL, NULL, NULL, NULL, NULL, NULL);
  199. Group *g = guiobject_getParentGroup();
  200. if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
  201. g->updatePos(this);
  202. break; }
  203. case GuiObjectWnd::GUIOBJECT_W: {
  204. a = WTOI(strvalue);
  205. guiobject_setGuiPosition(NULL, NULL, &a, NULL, NULL, NULL, NULL, NULL);
  206. Group *g = guiobject_getParentGroup();
  207. if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
  208. g->updatePos(this);
  209. break; }
  210. case GuiObjectWnd::GUIOBJECT_H: {
  211. a = WTOI(strvalue);
  212. guiobject_setGuiPosition(NULL, NULL, NULL, &a, NULL, NULL, NULL, NULL);
  213. Group *g = guiobject_getParentGroup();
  214. if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
  215. g->updatePos(this);
  216. break; }
  217. case GuiObjectWnd::GUIOBJECT_FITTOPARENT: {
  218. int v = WTOI(strvalue);
  219. if (v) {
  220. int one = 1;
  221. int x = 0, y = 0, w = 0, h = 0;
  222. if (v < 0) {
  223. v = -v;
  224. x += v;
  225. y += v;
  226. w -= v * 2;
  227. h -= v * 2;
  228. }
  229. guiobject_setGuiPosition(&x, &y, &w, &h, NULL, NULL, &one, &one);
  230. Group *g = guiobject_getParentGroup();
  231. if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
  232. g->updatePos(this);
  233. }
  234. break; }
  235. case GuiObjectWnd::GUIOBJECT_WANTFOCUS:
  236. wantfocus = WTOI(strvalue);
  237. if (guiobject_getRootWnd()->isPostOnInit()) {
  238. if (wantfocus) {
  239. if (guiobject_getRootWnd()->getTabOrder() == -1)
  240. guiobject_getRootWnd()->setAutoTabOrder();
  241. } else {
  242. if (guiobject_getRootWnd()->getTabOrder() != -1)
  243. guiobject_getRootWnd()->setTabOrder(-1);
  244. }
  245. }
  246. break;
  247. case GuiObjectWnd::GUIOBJECT_VISIBLE: {
  248. a = WTOI(strvalue);
  249. ifc_window *w = guiobject_getRootWnd();
  250. if (w->isPostOnInit())
  251. w->setVisible(a);
  252. else
  253. w->setStartHidden(!a);
  254. break; }
  255. case GuiObjectWnd::GUIOBJECT_RELATX: {
  256. if (strvalue && *strvalue == '%')
  257. a = 2;
  258. else
  259. a = WTOI(strvalue);
  260. guiobject_setGuiPosition(NULL, NULL, NULL, NULL, &a, NULL, NULL, NULL);
  261. Group *g = guiobject_getParentGroup();
  262. if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
  263. g->updatePos(this);
  264. break; }
  265. case GuiObjectWnd::GUIOBJECT_RELATY: {
  266. if (strvalue && *strvalue == '%')
  267. a = 2;
  268. else
  269. a = WTOI(strvalue);
  270. guiobject_setGuiPosition(NULL, NULL, NULL, NULL, NULL, &a, NULL, NULL);
  271. Group *g = guiobject_getParentGroup();
  272. if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
  273. g->updatePos(this);
  274. break; }
  275. case GuiObjectWnd::GUIOBJECT_RELATW: {
  276. if (strvalue && *strvalue == '%')
  277. a = 2;
  278. else
  279. a = WTOI(strvalue);
  280. guiobject_setGuiPosition(NULL, NULL, NULL, NULL, NULL, NULL, &a, NULL);
  281. Group *g = guiobject_getParentGroup();
  282. if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
  283. g->updatePos(this);
  284. break; }
  285. case GuiObjectWnd::GUIOBJECT_RELATH: {
  286. if (strvalue && *strvalue == '%')
  287. a = 2;
  288. else
  289. a = WTOI(strvalue);
  290. guiobject_setGuiPosition(NULL, NULL, NULL, NULL, NULL, NULL, NULL, &a);
  291. Group *g = guiobject_getParentGroup();
  292. if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
  293. g->updatePos(this);
  294. break; }
  295. case GuiObjectWnd::GUIOBJECT_DROPTARGET:
  296. guiobject_setDropTarget(strvalue);
  297. break;
  298. case GuiObjectWnd::GUIOBJECT_GHOST:
  299. guiobject_setClickThrough(WTOI(strvalue));
  300. break;
  301. case GuiObjectWnd::GUIOBJECT_SETNODBLCLICK:
  302. guiobject_setNoDoubleClick(WTOI(strvalue));
  303. break;
  304. case GuiObjectWnd::GUIOBJECT_SETNOLEFTCLICK:
  305. guiobject_setNoLeftClick(WTOI(strvalue));
  306. break;
  307. case GuiObjectWnd::GUIOBJECT_SETNORIGHTCLICK:
  308. guiobject_setNoRightClick(WTOI(strvalue));
  309. break;
  310. case GuiObjectWnd::GUIOBJECT_SETNOMOUSEMOVE:
  311. guiobject_setNoMouseMove(WTOI(strvalue));
  312. break;
  313. case GuiObjectWnd::GUIOBJECT_SETNOCONTEXTMENU:
  314. guiobject_setNoContextMenu(WTOI(strvalue));
  315. break;
  316. case GuiObjectWnd::GUIOBJECT_SETX1: {
  317. a = WTOI(strvalue);
  318. guiobject_setAnchoragePosition(&a, NULL, NULL, NULL, NULL);
  319. Group *g = guiobject_getParentGroup();
  320. if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
  321. g->updatePos(this);
  322. break;
  323. }
  324. case GuiObjectWnd::GUIOBJECT_SETY1:{
  325. a = WTOI(strvalue);
  326. guiobject_setAnchoragePosition(NULL, &a, NULL, NULL, NULL);
  327. Group *g = guiobject_getParentGroup();
  328. if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
  329. g->updatePos(this);
  330. break;
  331. }
  332. case GuiObjectWnd::GUIOBJECT_SETX2:{
  333. a = WTOI(strvalue);
  334. guiobject_setAnchoragePosition(NULL, NULL, &a, NULL, NULL);
  335. Group *g = guiobject_getParentGroup();
  336. if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
  337. g->updatePos(this);
  338. break;
  339. }
  340. case GuiObjectWnd::GUIOBJECT_SETY2:{
  341. a = WTOI(strvalue);
  342. guiobject_setAnchoragePosition(NULL, NULL, NULL, &a, NULL);
  343. Group *g = guiobject_getParentGroup();
  344. if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
  345. g->updatePos(this);
  346. break;
  347. }
  348. case GuiObjectWnd::GUIOBJECT_SETANCHOR: {
  349. int anchorage=ANCHOR_NONE;
  350. ParamParser pp(strvalue, L"|");
  351. for (int m=0;m<pp.getNumItems();m++)
  352. {
  353. const wchar_t *s = pp.enumItem(m);
  354. if (!WCSICMP(s, L"left")) anchorage |= ANCHOR_LEFT;
  355. else if (!WCSICMP(s, L"top")) anchorage |= ANCHOR_TOP;
  356. else if (!WCSICMP(s, L"right")) anchorage |= ANCHOR_RIGHT;
  357. else if (!WCSICMP(s, L"bottom")) anchorage |= ANCHOR_BOTTOM;
  358. }
  359. guiobject_setAnchoragePosition(NULL, NULL, NULL, NULL, &anchorage);
  360. Group *g = guiobject_getParentGroup();
  361. if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
  362. g->updatePos(this);
  363. }
  364. break;
  365. case GuiObjectWnd::GUIOBJECT_SETCURSOR:
  366. guiobject_setCursor(strvalue);
  367. break;
  368. case GuiObjectWnd::GUIOBJECT_NOTIFY:
  369. notifylist.addItem(new StringW(strvalue));
  370. break;
  371. case GuiObjectWnd::GUIOBJECT_USERDATA:
  372. // nothing to do, param goes in xmlobject
  373. break;
  374. #ifdef USEAPPBAR
  375. case GuiObjectWnd::GUIOBJECT_APPBAR:
  376. setAppBar(strvalue);
  377. break;
  378. #endif
  379. case GuiObjectWnd::GUIOBJECT_TRANSLATE:
  380. translate = WTOI(strvalue);
  381. break;
  382. default:
  383. return 0;
  384. }
  385. return 1;
  386. }
  387. void GuiObjectI::guiobject_getGuiPosition(int *x, int *y, int *w, int *h, int *rx, int *ry, int *rw, int *rh) {
  388. if (x) *x = gui_x;
  389. if (y) *y = gui_y;
  390. if (w) *w = gui_w;
  391. if (h) *h = gui_h;
  392. if (rx) *rx = gui_rx;
  393. if (ry) *ry = gui_ry;
  394. if (rw) *rw = gui_rw;
  395. if (rh) *rh = gui_rh;
  396. }
  397. void GuiObjectI::guiobject_setGuiPosition(int *x, int *y, int *w, int *h, int *rx, int *ry, int *rw, int *rh) {
  398. if (x && *x != NOCHANGE && *x != AUTOWH) gui_x = *x;
  399. if (y && *y != NOCHANGE && *y != AUTOWH) gui_y = *y;
  400. if (w && *w != NOCHANGE && *w != AUTOWH) gui_w = *w;
  401. if (h && *h != NOCHANGE && *h != AUTOWH) gui_h = *h;
  402. if (rx && *rx != NOCHANGE && *rx != AUTOWH) gui_rx = *rx;
  403. if (ry && *ry != NOCHANGE && *ry != AUTOWH) gui_ry = *ry;
  404. if (rw && *rw != NOCHANGE && *rw != AUTOWH) gui_rw = *rw;
  405. if (rh && *rh != NOCHANGE && *rh != AUTOWH) gui_rh = *rh;
  406. if (guiobject_getRootWnd()->isInited() && guiobject_getParentGroup())
  407. guiobject_getParentGroup()->updatePos(this);
  408. else {
  409. if (!guiobject_getRootWnd()->isVirtual())
  410. guiobject_getRootWnd()->resize(gui_x, gui_y, gui_w, gui_h);
  411. }
  412. }
  413. int GuiObjectI::guiobject_getAnchoragePosition(int *x1, int *y1, int *x2, int *y2, int *anchor) {
  414. if (x1) *x1 = anchor_x1;
  415. if (y1) *y1 = anchor_y1;
  416. if (x2) *x2 = anchor_x2;
  417. if (y2) *y2 = anchor_y2;
  418. if (anchor) *anchor = anchorage;
  419. return anchorage_invalidated;
  420. }
  421. void GuiObjectI::guiobject_setAnchoragePosition(int *x1, int *y1, int *x2, int *y2, int *anchor) {
  422. anchorage_invalidated = 1;
  423. if (x1) anchor_x1 = *x1;
  424. if (x2) anchor_x2 = *x2;
  425. if (y1) anchor_y1 = *y1;
  426. if (y2) anchor_y2 = *y2;
  427. if (anchor) anchorage = *anchor;
  428. if (guiobject_getRootWnd()->isInited() && guiobject_getParentGroup()) {
  429. guiobject_getParentGroup()->updatePos(this);
  430. }
  431. }
  432. void GuiObjectI::guiobject_validateAnchorage() {
  433. anchorage_invalidated = 0;
  434. }
  435. void GuiObjectI::guiobject_setClickThrough(int c) {
  436. guiobject_getRootWnd()->setClickThrough(c);
  437. }
  438. void GuiObjectI::guiobject_setRegionOp(int op) {
  439. guiobject_getRootWnd()->setRegionOp(op);
  440. }
  441. int GuiObjectI::guiobject_getRegionOp() {
  442. return guiobject_getRootWnd()->getRegionOp();
  443. }
  444. void GuiObjectI::guiobject_setRectRgn(int rrgn) {
  445. guiobject_getRootWnd()->setRectRgn(rrgn);
  446. }
  447. void GuiObjectI::guiobject_setMover(int n) {
  448. mover = n;
  449. }
  450. int GuiObjectI::guiobject_getMover() {
  451. return mover;
  452. }
  453. FOURCC GuiObjectI::guiobject_getDropTarget() {
  454. return droptarget;
  455. }
  456. void GuiObjectI::guiobject_setDropTarget(const wchar_t *strval)
  457. {
  458. if (strval == NULL)
  459. droptarget = 0;
  460. else
  461. {
  462. uint8_t *temp = (uint8_t *)&droptarget;
  463. temp[3]=(uint8_t)strval[0];
  464. temp[2]=(uint8_t)strval[1];
  465. temp[1]=(uint8_t)strval[2];
  466. temp[0]=(uint8_t)strval[3];
  467. }
  468. }
  469. int GuiObjectI::guiobject_isRectRgn() {
  470. return guiobject_getRootWnd()->isRectRgn();
  471. }
  472. int GuiObjectI::guiobject_isClickThrough() {
  473. return guiobject_getRootWnd()->isClickThrough();
  474. }
  475. void GuiObjectI::guiobject_setParentGroup(Group *l) {
  476. if (!l) { p_group = NULL; return; }
  477. p_group = l;
  478. }
  479. Group *GuiObjectI::guiobject_getParentGroup() {
  480. if (!p_group) return NULL;
  481. return p_group;
  482. }
  483. GuiObject *GuiObjectI::guiobject_getParent() {
  484. ifc_window *grw = guiobject_getRootWnd();
  485. if (!grw) return NULL;
  486. ifc_window *w = grw->getParent();
  487. if (!w) return NULL;
  488. return static_cast<GuiObject *>(w->getInterface(guiObjectGuid));
  489. }
  490. #ifdef WASABI_COMPILE_WNDMGR
  491. Layout *GuiObjectI::guiobject_getParentLayout() {
  492. Group *m = p_group;
  493. Layout *l = NULL;
  494. while (m) {
  495. if (m->isLayout()) {
  496. l = static_cast<Layout *>(m);
  497. break;
  498. }
  499. m = m->getGuiObject()->guiobject_getParentGroup();
  500. }
  501. if (!l) {
  502. ifc_window *w = guiobject_getRootWnd()->getDesktopParent();
  503. if (w)
  504. l = static_cast<Layout *>(w->getInterface(layoutGuid));
  505. }
  506. if (l && l->isDeleting()) return NULL;
  507. return l;
  508. }
  509. #endif
  510. GuiObject *GuiObjectI::guiobject_getTopParent() {
  511. ifc_window *m = guiobject_getRootWnd();
  512. GuiObject *top = this;
  513. while (m != NULL) {
  514. m = m->getParent();
  515. if (m != NULL) {
  516. GuiObject *g = m->getGuiObject();
  517. if (g != NULL)
  518. top = g;
  519. }
  520. }
  521. return top;
  522. }
  523. /*void GuiObjectI::parseNotify(const char *s) {
  524. scriptNotify(s, "", 0, 0);
  525. }*/
  526. void GuiObjectI::guiobject_bringToFront() {
  527. ifc_window *b = guiobject_getRootWnd();
  528. if (b) {
  529. if (b->getParent())
  530. b->getParent()->bringVirtualToFront(b);
  531. }
  532. }
  533. void GuiObjectI::guiobject_bringToBack() {
  534. ifc_window *b = guiobject_getRootWnd();
  535. if (b) {
  536. if (b->getParent())
  537. b->getParent()->bringVirtualToBack(b);
  538. }
  539. }
  540. void GuiObjectI::guiobject_bringAbove(GuiObject *o) {
  541. ASSERT(o != NULL);
  542. ifc_window *b = guiobject_getRootWnd();
  543. ifc_window *c = o->guiobject_getRootWnd();
  544. if (b && c) {
  545. if (b->getParent())
  546. b->getParent()->bringVirtualAbove(b, c);
  547. }
  548. }
  549. void GuiObjectI::guiobject_bringBelow(GuiObject *o) {
  550. ASSERT(o != NULL);
  551. ifc_window *b = guiobject_getRootWnd();
  552. ifc_window *c = o->guiobject_getRootWnd();
  553. if (b && c) {
  554. if (b->getParent())
  555. b->getParent()->bringVirtualBelow(b, c);
  556. }
  557. }
  558. void GuiObjectI::guiobject_setTargetSpeed(float s) { // s == n of seconds
  559. if (targetspeed == (int)(s * 4.0)) return;
  560. targetspeed = (int)(s * 4.0); // units of 250ms
  561. if (targetstatus == TARGET_RUNNING) {
  562. stopTargetTimer();
  563. startTargetTimer();
  564. }
  565. }
  566. void GuiObjectTimer::timerclient_timerCallback(int id) {
  567. if (id == TARGETTIMER_ID && obj)
  568. obj->onTargetTimer();
  569. }
  570. void GuiObjectI::guiobject_setTargetX(int x) {
  571. targetx = x;
  572. }
  573. void GuiObjectI::guiobject_setTargetY(int y) {
  574. targety = y;
  575. }
  576. void GuiObjectI::guiobject_setTargetW(int w) {
  577. targetw = w;
  578. }
  579. void GuiObjectI::guiobject_setTargetH(int h) {
  580. targeth = h;
  581. }
  582. void GuiObjectI::guiobject_setTargetA(int a) {
  583. targeta = a;
  584. }
  585. void GuiObjectI::guiobject_gotoTarget() {
  586. if (!guiobject_getRootWnd()) return;
  587. start_time=0;
  588. guiobject_getGuiPosition(&startx, &starty, &startw, &starth, NULL, NULL, NULL, NULL);
  589. starta = guiobject_getAlpha();
  590. if (targetx == AUTOWH || targetx == NOCHANGE)
  591. targetx = startx;
  592. if (targety == AUTOWH || targety == NOCHANGE)
  593. targety = starty;
  594. if (targetw == AUTOWH || targetw == NOCHANGE)
  595. targetw = startw;
  596. if (targeth == AUTOWH || targeth == NOCHANGE)
  597. targeth = starth;
  598. if (targeta == AUTOWH || targeta == NOCHANGE)
  599. targeta = starta;
  600. startTargetTimer();
  601. Layout *l = static_cast<Layout *>(guiobject_getScriptObject()->vcpu_getInterface(layoutGuid));
  602. if (targetx != startx ||
  603. targety != starty ||
  604. targetw != startw ||
  605. targeth != starth) {
  606. if (l) windowTracker->beforeRedock(l, &redock);
  607. }
  608. }
  609. void GuiObjectI::startTargetTimer() {
  610. timer.timerclient_setTimer(TARGETTIMER_ID, 20);
  611. targetstatus = TARGET_RUNNING;
  612. }
  613. void GuiObjectI::stopTargetTimer() {
  614. timer.timerclient_killTimer(TARGETTIMER_ID);
  615. targetstatus = TARGET_FROZEN;
  616. }
  617. void GuiObjectI::onTargetTimer() {
  618. if (targetstatus != TARGET_RUNNING) return;
  619. if (!guiobject_getRootWnd()) return;
  620. RECT r;
  621. guiobject_getRootWnd()->getClientRect(&r);
  622. RECT wr;
  623. guiobject_getRootWnd()->getWindowRect(&wr);
  624. int ttime=250*targetspeed;
  625. if (ttime < 0) ttime = 0;
  626. int n;
  627. if (!start_time)
  628. {
  629. n=0;
  630. start_time = Wasabi::Std::getTickCount();
  631. }
  632. else
  633. {
  634. n=MulDiv(Wasabi::Std::getTickCount()-start_time,256,ttime);
  635. }
  636. if (ttime == 0) n = 255;
  637. if (n >= 255) n=255;
  638. float sintrans = (float)(sin(((float)n/255)*PI-PI/2)/2+0.5); // used for smoothing transitions
  639. float nw = ((float)(targetw - startw) * sintrans) + startw;
  640. float nh = ((float)(targeth - starth) * sintrans) + starth;
  641. float na = ((float)(targeta - starta) * sintrans) + starta;
  642. Layout *l = static_cast<Layout *>(guiobject_getScriptObject()->vcpu_getInterface(layoutGuid));
  643. int islayout = l != NULL && static_cast<ifc_window*>(l) == guiobject_getRootWnd();
  644. float rat = 1.0f;
  645. if (islayout) rat = (float)l->getRenderRatio();
  646. float nx;
  647. float ny;
  648. if (!reversetarget) {
  649. nx = ((float)(targetx - startx) * sintrans) + startx;
  650. ny = ((float)(targety - starty) * sintrans) + starty;
  651. } else {
  652. nx = startx - ((float)(targetw - startw) * sintrans) * rat;
  653. ny = starty - ((float)(targeth - starth) * sintrans) * rat;
  654. }
  655. int zx=(int)nx;
  656. int zy=(int)ny;
  657. int zw=(int)nw;
  658. int zh=(int)nh;
  659. if (reversetarget) {
  660. while (zy + zh * rat < wr.bottom) zy++;
  661. while (zx + zw * rat < wr.right) zx++;
  662. }
  663. int oldredraw = -1;
  664. if (reversetarget && islayout) {
  665. oldredraw = l->wantRedrawOnResize();
  666. l->setWantRedrawOnResize(0);
  667. int paddtop = wr.top - (int)ny;
  668. int paddleft = wr.left - (int)nx;
  669. #ifdef _WIN32
  670. if (paddtop > 0 || paddleft > 0) {
  671. RegionI r;
  672. GetWindowRgn(l->gethWnd(), r.getOSHandle());
  673. r.offset(MAX(0, paddleft), MAX(0, paddtop));
  674. SetWindowRgn(l->gethWnd(), r.makeWindowRegion(), FALSE);
  675. }
  676. #else
  677. #warning port me
  678. #endif
  679. }
  680. guiobject_setGuiPosition(&zx, &zy, &zw, &zh, NULL, NULL, NULL, NULL);
  681. guiobject_getRootWnd()->cascadeRepaint(0);
  682. guiobject_setAlpha((int)na);
  683. if (n==255) {
  684. stopTargetTimer();
  685. guiobject_onTargetReached();
  686. }
  687. if (l != NULL) l->savePosition();
  688. if (oldredraw != -1 && l) {
  689. l->setWantRedrawOnResize(oldredraw);
  690. }
  691. }
  692. void GuiObjectI::guiobject_cancelTarget() {
  693. stopTargetTimer();
  694. Layout *l = static_cast<Layout *>(guiobject_getScriptObject()->vcpu_getInterface(layoutGuid));
  695. if (l && redock.l) windowTracker->afterRedock(l, &redock);
  696. }
  697. void GuiObjectI::guiobject_reverseTarget(int reverse) {
  698. reversetarget = reverse;
  699. }
  700. #ifdef WASABI_COMPILE_WNDMGR
  701. void GuiObjectI::guiobject_popParentLayout() {
  702. Layout *l = guiobject_getParentLayout();
  703. if (l && l->getParentContainer()) {
  704. SkinParser::showContainer(l->getParentContainer()->getId(), TRUE);
  705. #ifdef WIN32
  706. SetForegroundWindow(l->gethWnd());
  707. #else
  708. l->bringToFront();
  709. #endif
  710. }
  711. }
  712. #endif
  713. int GuiObjectI::guiobject_movingToTarget() {
  714. return targetstatus == TARGET_RUNNING;
  715. }
  716. void GuiObjectI::guiobject_onLeftButtonDown(int x, int y) {
  717. if (!VCPU::getComplete()) {
  718. scriptVar _x = SOM::makeVar(SCRIPT_INT);
  719. SOM::assign(&_x, x);
  720. scriptVar _y = SOM::makeVar(SCRIPT_INT);
  721. SOM::assign(&_y, y);
  722. GuiObject_ScriptMethods::onLeftButtonDown(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y);
  723. if (mover && !VCPU::getComplete()) {
  724. #ifdef WASABI_COMPILE_WNDMGR
  725. Layout *l = guiobject_getParentLayout();
  726. if (l) {
  727. // Martin> (9/9/8) added l->getGuiObject()->guiobject_getMover() so setting move="0" to layouts will disable moving it around
  728. if (!l->isLocked() && l->getGuiObject()->guiobject_getMover()) {
  729. #ifdef USEAPPBAR
  730. if (cfg_options_appbarondrag) {
  731. m_initial_dock_side = m_dock_side = l->appbar_getSide();
  732. if (m_dock_side != APPBAR_NOTDOCKED) {
  733. dodragcheck = 1;
  734. goto skipit;
  735. }
  736. }
  737. #endif
  738. l->maximize(0);
  739. skipit:
  740. l->beginMove();
  741. if (l->getParentContainer() && l->getParentContainer()->isMainContainer() || Std::keyModifier(STDKEY_ALT))
  742. WASABI_API_WNDMGR->wndTrackStartCooperative(l);
  743. moving = 1;
  744. anchor.x = (int)((float)x * guiobject_getRootWnd()->getRenderRatio());
  745. anchor.y = (int)((float)y * guiobject_getRootWnd()->getRenderRatio());
  746. }
  747. }
  748. #endif //WASABI_COMPILE_WNDMGR
  749. }
  750. }
  751. }
  752. void GuiObjectI::guiobject_onLeftButtonUp(int x, int y) {
  753. scriptVar _x = SOM::makeVar(SCRIPT_INT);
  754. SOM::assign(&_x, x);
  755. scriptVar _y = SOM::makeVar(SCRIPT_INT);
  756. SOM::assign(&_y, y);
  757. GuiObject_ScriptMethods::onLeftButtonUp(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y);
  758. if (moving) {
  759. int sendendmove = 0;
  760. #ifdef WASABI_COMPILE_WNDMGR
  761. Group *l = guiobject_getParentLayout();
  762. if (l) {
  763. if (WASABI_API_WNDMGR->wndTrackWasCooperative())
  764. WASABI_API_WNDMGR->wndTrackEndCooperative();
  765. moving = 0;
  766. sendendmove = 1;
  767. }
  768. #ifdef USEAPPBAR
  769. if (cfg_options_appbarondrag) {
  770. if (m_dock_side != m_initial_dock_side) {
  771. ifc_window *dw = guiobject_getRootWnd()->getDesktopParent();
  772. if (dw) {
  773. AppBar *ab = reinterpret_cast<AppBar *>(dw->getInterface(appBarGuid));
  774. if (ab) {
  775. if (m_dock_side == APPBAR_NOTDOCKED) ab->appbar_setNoRestore(1);
  776. ab->appbar_dock(m_dock_side);
  777. if (m_dock_side == APPBAR_NOTDOCKED) ab->appbar_setNoRestore(0);
  778. }
  779. }
  780. }
  781. if (m_dock_side == APPBAR_NOTDOCKED) {
  782. ifc_window *dp = guiobject_getRootWnd()->getDesktopParent();
  783. if (dp) dp->restore(0);
  784. }
  785. } else {
  786. ifc_window *dp = guiobject_getRootWnd()->getDesktopParent();
  787. if (dp) dp->restore(0);
  788. }
  789. #else
  790. ifc_window *dp = guiobject_getRootWnd()->getDesktopParent();
  791. if (dp) dp->restore(0);
  792. #endif // USEAPPBAR
  793. if (sendendmove && l) l->endMove();
  794. #endif //WASABI_COMPILE_WNDMGR
  795. }
  796. }
  797. void GuiObjectI::guiobject_onRightButtonDown(int x, int y) {
  798. scriptVar _x = SOM::makeVar(SCRIPT_INT);
  799. SOM::assign(&_x, x);
  800. scriptVar _y = SOM::makeVar(SCRIPT_INT);
  801. SOM::assign(&_y, y);
  802. GuiObject_ScriptMethods::onRightButtonDown(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y);
  803. }
  804. #ifdef WASABI_CUSTOM_CONTEXTMENUS
  805. extern void appContextMenu(ifc_window *wnd);
  806. extern void appControlMenu(ifc_window *wnd);
  807. #endif
  808. void GuiObjectI::guiobject_onRightButtonUp(int x, int y) {
  809. scriptVar _x = SOM::makeVar(SCRIPT_INT);
  810. SOM::assign(&_x, x);
  811. scriptVar _y = SOM::makeVar(SCRIPT_INT);
  812. SOM::assign(&_y, y);
  813. GuiObject_ScriptMethods::onRightButtonUp(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y);
  814. ifc_window *w = guiobject_getRootWnd();
  815. if (Std::keyModifier(STDKEY_CONTROL) &&
  816. Std::keyModifier(STDKEY_SHIFT)) {
  817. GuiObjectI::infoMenu(this, x, y);
  818. } else {
  819. if (w && w->wantAutoContextMenu() && !VCPU::getComplete() && WASABI_API_WNDMGR->getModalWnd() == NULL) {
  820. ifc_window *par = w->getParent();
  821. if (par && guiobject_getParentLayout()) {
  822. if (!Std::keyModifier(STDKEY_CONTROL)) {
  823. #if defined(WA3COMPATIBILITY)
  824. Main::appContextMenu(par, TRUE, guiobject_getParentLayout()->isTransparencySafe());
  825. #elif defined(WASABI_CUSTOM_CONTEXTMENUS)
  826. appContextMenu(par);
  827. #endif
  828. } else {
  829. Layout *l = guiobject_getParentLayout();
  830. if (l->getParent() == NULL) {
  831. #if defined(WA3COMPATIBILITY)
  832. l->controlMenu();
  833. #elif defined(WASABI_CUSTOM_CONTEXTMENUS)
  834. appControlMenu(l);
  835. #endif
  836. }
  837. }
  838. } else {
  839. Layout *l = static_cast<Layout *>(w->getInterface(layoutGuid));
  840. if (l != NULL) {
  841. if (!Std::keyModifier(STDKEY_CONTROL)) {
  842. #if defined(WA3COMPATIBILITY)
  843. Main::appContextMenu(w, TRUE, l->isTransparencySafe());
  844. #elif defined(WASABI_CUSTOM_CONTEXTMENUS)
  845. appContextMenu(w);
  846. #endif
  847. } else {
  848. #if defined(WA3COMPATIBILITY)
  849. l->controlMenu();
  850. #elif defined(WASABI_CUSTOM_CONTEXTMENUS)
  851. appControlMenu(l);
  852. #endif
  853. }
  854. }
  855. }
  856. }
  857. }
  858. }
  859. void GuiObjectI::guiobject_onRightButtonDblClk(int x, int y) {
  860. scriptVar _x = SOM::makeVar(SCRIPT_INT);
  861. SOM::assign(&_x, x);
  862. scriptVar _y = SOM::makeVar(SCRIPT_INT);
  863. SOM::assign(&_y, y);
  864. GuiObject_ScriptMethods::onRightButtonDblClk(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y);
  865. }
  866. void GuiObjectI::guiobject_onLeftButtonDblClk(int x, int y) {
  867. scriptVar _x = SOM::makeVar(SCRIPT_INT);
  868. SOM::assign(&_x, x/* - wr.left*/);
  869. scriptVar _y = SOM::makeVar(SCRIPT_INT);
  870. SOM::assign(&_y, y/* - wr.top*/);
  871. GuiObject_ScriptMethods::onLeftButtonDblClk(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y);
  872. }
  873. int GuiObjectI::guiobject_onMouseWheelUp(int clicked, int lines)
  874. {
  875. scriptVar retval;
  876. retval = GuiObject_ScriptMethods::onMouseWheelUp(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_INT(clicked), MAKE_SCRIPT_INT(lines) );
  877. int retv;
  878. if ((retval.type == SCRIPT_VOID) || (retval.type == SCRIPT_OBJECT) || (retval.type == SCRIPT_STRING))
  879. retv = 0;
  880. else
  881. retv = GET_SCRIPT_INT(retval);
  882. return retv;
  883. }
  884. int GuiObjectI::guiobject_onMouseWheelDown(int clicked, int lines)
  885. {
  886. scriptVar retval;
  887. retval = GuiObject_ScriptMethods::onMouseWheelDown(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_INT(clicked), MAKE_SCRIPT_INT(lines) );
  888. int retv;
  889. if ((retval.type == SCRIPT_VOID) || (retval.type == SCRIPT_OBJECT) || (retval.type == SCRIPT_STRING))
  890. retv = 0;
  891. else
  892. retv = GET_SCRIPT_INT(retval);
  893. return retv;
  894. }
  895. void GuiObjectI::guiobject_onMouseMove(int x, int y) {
  896. scriptVar _x = SOM::makeVar(SCRIPT_INT);
  897. SOM::assign(&_x, x);
  898. scriptVar _y = SOM::makeVar(SCRIPT_INT);
  899. SOM::assign(&_y, y);
  900. GuiObject_ScriptMethods::onMouseMove(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y);
  901. POINT pos={x,y};
  902. guiobject_getRootWnd()->clientToScreen((int *)&pos.x, (int *)&pos.y);
  903. #ifdef WASABI_COMPILE_WNDMGR
  904. if (moving) {
  905. #ifdef _WIN32
  906. if (!Std::keyDown(MK_LBUTTON)) {
  907. #else
  908. #warning port me
  909. if (0) {
  910. #endif
  911. moving = 0;
  912. } else {
  913. #ifdef WIN32
  914. int drag_x = GetSystemMetrics(SM_CXDRAG);
  915. int drag_y = GetSystemMetrics(SM_CYDRAG);
  916. #else
  917. #warning port me
  918. int drag_x = 5;
  919. int drag_y = 5;
  920. #endif
  921. POINT relatpos;
  922. relatpos.x = (int)((float)x*guiobject_getRootWnd()->getRenderRatio()) - anchor.x;
  923. relatpos.y = (int)((float)y*guiobject_getRootWnd()->getRenderRatio()) - anchor.y;
  924. if (!dodragcheck || (ABS(relatpos.x) >= drag_x || ABS(relatpos.y) >= drag_y)) {
  925. dodragcheck = 0;
  926. ifc_window *p = guiobject_getRootWnd()->getDesktopParent();
  927. if (p) {
  928. RECT r, cr;
  929. p->getWindowRect(&r);
  930. p->getClientRect(&cr);
  931. RECT nr=r;
  932. int w,h;
  933. #ifdef USEAPPBAR
  934. int side = APPBAR_NOTDOCKED;
  935. if (cfg_options_appbarondrag) {
  936. AppBar *ab = reinterpret_cast<AppBar *>(p->getInterface(appBarGuid));
  937. if (ab) {
  938. int _x=x, _y=y;
  939. p->clientToScreen(&_x, &_y);
  940. side = ab->appbar_testDock(_x, _y, &nr);
  941. if (ABS(p->getRenderRatio() - 1.0) > 0.01f) {
  942. int _w = nr.right-nr.left;
  943. int _h = nr.bottom-nr.top;
  944. double rr = p->getRenderRatio();
  945. _w = (int)((double)(_w) / rr + 0.5);
  946. _h = (int)((double)(_h) / rr + 0.5);
  947. nr.right = nr.left + _w;
  948. nr.bottom = nr.top + _h;
  949. }
  950. }
  951. }
  952. #endif
  953. w = cr.right-cr.left;
  954. h = cr.bottom-cr.top;
  955. int resize=0;
  956. #ifdef USEAPPBAR
  957. if (cfg_options_appbarondrag) {
  958. if (side != m_dock_side) {
  959. if (side != APPBAR_NOTDOCKED) {
  960. m_lastnondocked_x = r.left;
  961. m_lastnondocked_y = r.top;
  962. resize=1;
  963. } else {
  964. RECT rr;
  965. p->getRestoredRect(&rr);
  966. w = (rr.right-rr.left);
  967. h = (rr.bottom-rr.top);
  968. if (m_lastnondocked_x != -0xFFFF) {
  969. r.left = m_lastnondocked_x;
  970. r.top = m_lastnondocked_y;
  971. }
  972. r.right = r.left + w;
  973. r.bottom = r.top + h;
  974. snapAdjust(p, &r, -1);
  975. nr=r;
  976. resize=1;
  977. }
  978. }
  979. }
  980. #endif
  981. // use the scaling to adjust the overall size so docking will be correct
  982. double rr = p->getRenderRatio();
  983. r.left += relatpos.x;
  984. r.top += relatpos.y;
  985. r.right = r.left + (int)((double)w * rr);
  986. r.bottom = r.top + (int)((double)h * rr);
  987. #ifdef USEAPPBAR
  988. if (side == APPBAR_NOTDOCKED && m_dock_side == APPBAR_NOTDOCKED)
  989. WASABI_API_WNDMGR->wndTrackDock(p, &r, &nr, LEFT|TOP|RIGHT|BOTTOM|KEEPSIZE);
  990. if (side != APPBAR_NOTDOCKED || resize) {
  991. Layout *l = (Layout *)p->getInterface(layoutGuid);
  992. if (l) l->pushForceUnlink();
  993. {
  994. RECT adj = nr;
  995. snapAdjust(p, &adj, 1);
  996. int _w = adj.right-adj.left;
  997. int _h = adj.bottom-adj.top;
  998. if (ABS(p->getRenderRatio() - 1.0) > 0.01f) {
  999. double rr = p->getRenderRatio();
  1000. if ((int)((double)(_w) * rr) == (int)((double)(w) * rr)) _w = w;
  1001. if ((int)((double)(_h) * rr) == (int)((double)(h) * rr)) _h = h;
  1002. }
  1003. p->resize(adj.left, adj.top, _w, _h);
  1004. }
  1005. if (l) l->popForceUnlink();
  1006. } else {
  1007. p->move(r.left, r.top);
  1008. }
  1009. m_dock_side = side;
  1010. guiobject_getParentLayout()->onMove();
  1011. if (GetCapture() != guiobject_getRootWnd()->getRootParent()->gethWnd()) {
  1012. DebugStringW(L"not mine anymore :(\n");
  1013. }
  1014. #endif
  1015. }
  1016. }
  1017. }
  1018. }
  1019. #endif
  1020. }
  1021. // -----------------------------------------------------------------------
  1022. void GuiObjectI::snapAdjust(ifc_window *rw, RECT *r, int way) {
  1023. RECT s;
  1024. Layout *l = static_cast<Layout*>(rw->getInterface(layoutGuid));
  1025. if (!l) return;
  1026. l->getSnapAdjust(&s);
  1027. int h = r->bottom - r->top;
  1028. int w = r->right - r->left;
  1029. if (way == 1) {
  1030. h += s.top + s.bottom;
  1031. w += s.left + s.right;
  1032. r->left -= s.left;
  1033. r->top -= s.top;
  1034. r->bottom = r->top + h;
  1035. r->right = r->left + w;
  1036. } else if (way == -1) {
  1037. h -= s.top + s.bottom;
  1038. w -= s.left + s.right;
  1039. r->left += s.left;
  1040. r->top += s.top;
  1041. r->bottom = r->top + h;
  1042. r->right = r->left + w;
  1043. }
  1044. }
  1045. #ifdef USEAPPBAR
  1046. int GuiObjectI::guiobject_getAppBar() {
  1047. AppBar *ab = reinterpret_cast<AppBar *>(guiobject_getRootWnd()->getInterface(appBarGuid));
  1048. if (ab) return ab->appbar_getEnabledSides();
  1049. return 0;
  1050. }
  1051. BEGIN_STRINGDICTIONARY(_appbarvalues)
  1052. SDI(L"top", APPBAR_TOP_ENABLED);
  1053. SDI(L"left", APPBAR_LEFT_ENABLED);
  1054. SDI(L"right", APPBAR_RIGHT_ENABLED);
  1055. SDI(L"bottom", APPBAR_BOTTOM_ENABLED);
  1056. END_STRINGDICTIONARY(_appbarvalues, appbarvalues)
  1057. void GuiObjectI::guiobject_setAppBar(int en) {
  1058. AppBar *ab = reinterpret_cast<AppBar *>(guiobject_getRootWnd()->getInterface(appBarGuid));
  1059. if (ab) ab->appbar_setEnabledSides(en);
  1060. }
  1061. void GuiObjectI::setAppBar(const wchar_t *en)
  1062. {
  1063. AppBar *ab = reinterpret_cast<AppBar *>(guiobject_getRootWnd()->getInterface(appBarGuid));
  1064. if (ab) {
  1065. int e = 0;
  1066. ParamParser pp(en, L"|;");
  1067. for (int i=0;i<pp.getNumItems();i++)
  1068. {
  1069. const wchar_t *s = pp.enumItem(i);
  1070. if (!_wcsicmp(s, L"left")) e |= APPBAR_LEFT_ENABLED;
  1071. else if (!_wcsicmp(s, L"top")) e |= APPBAR_TOP_ENABLED;
  1072. else if (!_wcsicmp(s, L"right")) e |= APPBAR_RIGHT_ENABLED;
  1073. else if (!_wcsicmp(s, L"bottom")) e |= APPBAR_BOTTOM_ENABLED;
  1074. }
  1075. ab->appbar_setEnabledSides(e);
  1076. }
  1077. }
  1078. #endif
  1079. const wchar_t *GuiObjectI::guiobject_getName()
  1080. {
  1081. const wchar_t *ret = NULL;
  1082. ifc_window *w = guiobject_getRootWnd();
  1083. if (w != NULL)
  1084. ret = w->getRootWndName();
  1085. return ret;
  1086. }
  1087. void GuiObjectI::guiobject_onEnable(int en) {
  1088. scriptVar _is = SOM::makeVar(SCRIPT_INT);
  1089. SOM::assign(&_is, en);
  1090. GuiObject_ScriptMethods::onEnable(SCRIPT_CALL, guiobject_getScriptObject(), _is);
  1091. }
  1092. void GuiObjectI::guiobject_onStartup() {
  1093. GuiObject_ScriptMethods::onStartup(SCRIPT_CALL, guiobject_getScriptObject());
  1094. if (guiobject_getRootObject()) {
  1095. foreach (notifylist)
  1096. guiobject_getRootObject()->rootobject_notify(notifylist.getfor()->getValue(), L"", 0, 0);
  1097. endfor;
  1098. }
  1099. }
  1100. void GuiObjectI::guiobject_onEnterArea() {
  1101. if (in_area) return;
  1102. GuiObject_ScriptMethods::onEnterArea(SCRIPT_CALL, guiobject_getScriptObject());
  1103. in_area = 1;
  1104. }
  1105. void GuiObjectI::guiobject_onLeaveArea() {
  1106. if (!in_area) return;
  1107. GuiObject_ScriptMethods::onLeaveArea(SCRIPT_CALL, guiobject_getScriptObject());
  1108. in_area = 0;
  1109. }
  1110. void GuiObjectI::guiobject_onCancelCapture() {
  1111. moving = 0;
  1112. }
  1113. ifc_window *GuiObjectI::guiobject_getRootWnd(void) {
  1114. return my_root_wnd;
  1115. }
  1116. void GuiObjectI::guiobject_setRootWnd(ifc_window *r) {
  1117. my_root_wnd = r;
  1118. }
  1119. RootObject *GuiObjectI::guiobject_getRootObject() {
  1120. ScriptObject *o = guiobject_getScriptObject();
  1121. if (!o) return NULL;
  1122. return static_cast<RootObject *>(o->vcpu_getInterface(rootObjectGuid));
  1123. }
  1124. void GuiObjectI::guiobject_onResize(int x, int y, int w, int h) {
  1125. scriptVar _x = SOM::makeVar(SCRIPT_INT);
  1126. SOM::assign(&_x, x);
  1127. scriptVar _y = SOM::makeVar(SCRIPT_INT);
  1128. SOM::assign(&_y, y);
  1129. scriptVar _w = SOM::makeVar(SCRIPT_INT);
  1130. SOM::assign(&_w, w);
  1131. scriptVar _h = SOM::makeVar(SCRIPT_INT);
  1132. SOM::assign(&_h, h);
  1133. GuiObject_ScriptMethods::onResize(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y, _w, _h);
  1134. }
  1135. void GuiObjectI::guiobject_onSetVisible(int v) {
  1136. #ifdef WASABI_COMPILE_WNDMGR
  1137. if (guiobject_getParentLayout())
  1138. guiobject_getParentLayout()->onGuiObjectSetVisible(this, v);
  1139. #endif
  1140. scriptVar _v = SOM::makeVar(SCRIPT_BOOLEAN);
  1141. SOM::assign(&_v, v);
  1142. GuiObject_ScriptMethods::onSetVisible(SCRIPT_CALL, guiobject_getScriptObject(), _v);
  1143. #ifdef WASABI_COMPILE_WNDMGR
  1144. if (moving) {
  1145. if (WASABI_API_WNDMGR->wndTrackWasCooperative())
  1146. WASABI_API_WNDMGR->wndTrackEndCooperative();
  1147. moving = 0;
  1148. ifc_window *dp = guiobject_getRootWnd()->getDesktopParent();
  1149. if (dp) dp->restore(0);
  1150. guiobject_getParentGroup()->endMove();
  1151. }
  1152. #endif //WASABI_COMPILE_WNDMGR
  1153. }
  1154. void GuiObjectI::guiobject_setAlpha(int a) {
  1155. if (!my_root_wnd) return;
  1156. Layout *l = static_cast<Layout*>(my_root_wnd->getInterface(layoutGuid));
  1157. if (l) l->setAlpha(a);
  1158. else my_root_wnd->setAlpha(a);
  1159. }
  1160. int GuiObjectI::guiobject_getAlpha() {
  1161. if (!my_root_wnd) return 255;
  1162. Layout *l = static_cast<Layout*>(my_root_wnd->getInterface(layoutGuid));
  1163. if (l) return l->getAlpha();
  1164. return my_root_wnd->getPaintingAlpha();
  1165. }
  1166. void GuiObjectI::guiobject_setActiveAlpha(int a) {
  1167. if (my_root_wnd) {
  1168. int i;
  1169. my_root_wnd->getAlpha(NULL, &i);
  1170. my_root_wnd->setAlpha(a, i);
  1171. }
  1172. }
  1173. int GuiObjectI::guiobject_getActiveAlpha() {
  1174. int a = 255;
  1175. if (my_root_wnd) my_root_wnd->getAlpha(&a);
  1176. return a;
  1177. }
  1178. void GuiObjectI::guiobject_setInactiveAlpha(int a) {
  1179. if (my_root_wnd) {
  1180. int _a;
  1181. my_root_wnd->getAlpha(&_a);
  1182. my_root_wnd->setAlpha(_a, a);
  1183. }
  1184. }
  1185. int GuiObjectI::guiobject_getInactiveAlpha() {
  1186. if (my_root_wnd) {
  1187. int i;
  1188. my_root_wnd->getAlpha(NULL, &i);
  1189. return i;
  1190. }
  1191. return 255;
  1192. }
  1193. void GuiObjectI::guiobject_onTargetReached() {
  1194. GuiObject_ScriptMethods::onTargetReached(SCRIPT_CALL, guiobject_getScriptObject());
  1195. Layout *l = static_cast<Layout *>(guiobject_getScriptObject()->vcpu_getInterface(layoutGuid));
  1196. if (l && redock.l) windowTracker->afterRedock(l, &redock);
  1197. }
  1198. void GuiObjectI::guiobject_setAutoSysMetricsX(int a) {
  1199. if (a == autosysmetricsx) return;
  1200. autosysmetricsx = a;
  1201. if (guiobject_getRootWnd() && guiobject_getRootWnd()->isInited())
  1202. if (guiobject_getParentGroup()) guiobject_getParentGroup()->updatePos(this);
  1203. }
  1204. void GuiObjectI::guiobject_setAutoSysMetricsY(int a) {
  1205. if (a == autosysmetricsy) return;
  1206. autosysmetricsy = a;
  1207. if (guiobject_getRootWnd() && guiobject_getRootWnd()->isInited())
  1208. if (guiobject_getParentGroup()) guiobject_getParentGroup()->updatePos(this);
  1209. }
  1210. void GuiObjectI::guiobject_setAutoSysMetricsW(int a) {
  1211. if (a == autosysmetricsw) return;
  1212. autosysmetricsw = a;
  1213. if (guiobject_getRootWnd() && guiobject_getRootWnd()->isInited())
  1214. if (guiobject_getParentGroup()) guiobject_getParentGroup()->updatePos(this);
  1215. }
  1216. void GuiObjectI::guiobject_setAutoSysMetricsH(int a) {
  1217. if (a == autosysmetricsh) return;
  1218. autosysmetricsh = a;
  1219. if (guiobject_getRootWnd() && guiobject_getRootWnd()->isInited())
  1220. if (guiobject_getParentGroup()) guiobject_getParentGroup()->updatePos(this);
  1221. }
  1222. int GuiObjectI::guiobject_getAutoSysMetricsX() {
  1223. return autosysmetricsx;
  1224. }
  1225. int GuiObjectI::guiobject_getAutoSysMetricsY() {
  1226. return autosysmetricsy;
  1227. }
  1228. int GuiObjectI::guiobject_getAutoSysMetricsW() {
  1229. return autosysmetricsw;
  1230. }
  1231. int GuiObjectI::guiobject_getAutoSysMetricsH() {
  1232. return autosysmetricsh;
  1233. }
  1234. int GuiObjectI::guiobject_getAutoWidth() {
  1235. if (!guiobject_getRootWnd()) return AUTOWH;
  1236. return guiobject_getRootWnd()->getPreferences(SUGGESTED_W);
  1237. }
  1238. int GuiObjectI::guiobject_getAutoHeight() {
  1239. if (!guiobject_getRootWnd()) return AUTOWH;
  1240. return guiobject_getRootWnd()->getPreferences(SUGGESTED_H);
  1241. }
  1242. #ifdef WASABI_COMPILE_WNDMGR
  1243. int GuiObjectI::guiobject_runModal() {
  1244. if (!guiobject_getRootWnd()) return 0;
  1245. ifc_window *w = guiobject_getRootWnd()->getDesktopParent();
  1246. #ifdef WASABI_MODAL_PUSH
  1247. WASABI_MODAL_PUSH
  1248. #endif
  1249. int r = w->runModal();
  1250. #ifdef WASABI_MODAL_POP
  1251. WASABI_MODAL_POP
  1252. #endif
  1253. return r;
  1254. }
  1255. void GuiObjectI::guiobject_endModal(int retcode) {
  1256. if (!guiobject_getRootWnd()) return;
  1257. ifc_window *w = guiobject_getRootWnd()->getDesktopParent();
  1258. w->endModal(retcode);
  1259. }
  1260. #endif
  1261. int GuiObjectI::guiobject_isActive() {
  1262. if (!guiobject_getRootWnd()) return 0;
  1263. return guiobject_getRootWnd()->isActive();
  1264. }
  1265. svc_xuiObject *GuiObjectI::guiobject_getXuiService() {
  1266. return xuisvc;
  1267. }
  1268. void GuiObjectI::guiobject_setXuiService(svc_xuiObject *svc) {
  1269. xuisvc = svc;
  1270. }
  1271. waServiceFactory *GuiObjectI::guiobject_getXuiServiceFactory() {
  1272. return xuifac;
  1273. }
  1274. void GuiObjectI::guiobject_setXuiServiceFactory(waServiceFactory *fac) {
  1275. xuifac = fac;
  1276. }
  1277. #ifdef WASABI_COMPILE_WNDMGR
  1278. void GuiObjectI::guiobject_setStatusText(const wchar_t *text, int overlay)
  1279. {
  1280. Layout *l = guiobject_getParentLayout();
  1281. if (l)
  1282. l->setStatusText(text, overlay);
  1283. }
  1284. void GuiObjectI::guiobject_registerStatusCB(GuiStatusCallback *cb) {
  1285. Layout *l = guiobject_getParentLayout();
  1286. if (l) l->registerStatusCallback(cb);
  1287. }
  1288. void GuiObjectI::guiobject_addAppCmds(AppCmds *commands){
  1289. Layout *l = guiobject_getParentLayout();
  1290. if (l) l->addAppCmds(commands);
  1291. }
  1292. void GuiObjectI::guiobject_removeAppCmds(AppCmds *commands){
  1293. Layout *l = guiobject_getParentLayout();
  1294. if (l) l->removeAppCmds(commands);
  1295. }
  1296. void GuiObjectI::guiobject_pushCompleted(int max) {
  1297. Layout *l = guiobject_getParentLayout();
  1298. if (l) l->pushCompleted(max);
  1299. }
  1300. void GuiObjectI::guiobject_incCompleted(int add) {
  1301. Layout *l = guiobject_getParentLayout();
  1302. if (l) l->incCompleted(add);
  1303. }
  1304. void GuiObjectI::guiobject_setCompleted(int pos) {
  1305. Layout *l = guiobject_getParentLayout();
  1306. if (l) l->setCompleted(pos);
  1307. }
  1308. void GuiObjectI::guiobject_popCompleted() {
  1309. Layout *l = guiobject_getParentLayout();
  1310. if (l) l->popCompleted();
  1311. }
  1312. #endif //WASABI_COMPILE_WNDMGR
  1313. void GuiObjectI::infoMenu(GuiObject *o, int x, int y)
  1314. {
  1315. PopupMenu pop;
  1316. pop.addCommand(StringPrintfW(L"Class : %s", o->guiobject_getScriptObject()->vcpu_getClassName()), 0, 0, 1);
  1317. pop.addCommand(StringPrintfW(L"Id : %s", o->guiobject_getId()), 0, 0, 1);
  1318. RECT r;
  1319. guiobject_getRootWnd()->getNonClientRect(&r);
  1320. pop.addCommand(StringPrintfW(L"Coordinates : %d,%d (%d x %d)", r.left, r.top, r.right-r.left, r.bottom-r.top), 0, 0, 1);
  1321. int _x, _y, _w, _h, _rx, _ry, _rw, _rh;
  1322. guiobject_getGuiPosition(&_x, &_y, &_w, &_h, &_rx, &_ry, &_rw, &_rh);
  1323. pop.addCommand(StringPrintfW(L"GuiPos : x=%d relatx=%d, y=%d relaty=%d, w=%d relatw=%d, h=%d relath=%d", _x, _rx, _y, _ry, _w, _rw, _h, _rh), 0, 0, 1);
  1324. if (guiobject_wantTranslation() == 2)
  1325. {
  1326. if (!_wcsicmp(o->guiobject_getScriptObject()->vcpu_getClassName(), L"Text"))
  1327. {
  1328. pop.addCommand(StringPrintfW(L"StringEntry : %s", guiobject_getXmlParam(L"text")), 0, 0, 1);
  1329. }
  1330. else if (!_wcsicmp(o->guiobject_getScriptObject()->vcpu_getClassName(), L"TitleBar"))
  1331. {
  1332. pop.addCommand(StringPrintfW(L"StringEntry : %s", guiobject_getXmlParam(L"title")), 0, 0, 1);
  1333. }
  1334. }
  1335. guiobject_getRootWnd()->clientToScreen(&x, &y);
  1336. pop.popAtXY(x, y, 1);
  1337. }
  1338. #ifdef WASABI_COMPILE_CONFIG
  1339. void GuiObjectI::guiobject_setCfgAttrib(CfgItem *item, const wchar_t *name)
  1340. {
  1341. if (cfgitem) viewer_delViewItem(cfgitem);
  1342. cfgitem = item;
  1343. cfgattrname = name;
  1344. if (cfgitem) {
  1345. viewer_addViewItem(cfgitem);
  1346. }
  1347. ifc_window *mw = guiobject_getRootWnd();
  1348. if (mw != NULL) {
  1349. if (mw->isPostOnInit())
  1350. dataChanged();
  1351. }
  1352. }
  1353. int GuiObjectI::viewer_onEvent(CfgItem *item, int event, intptr_t param, void *ptr, size_t ptrlen) {
  1354. if (item == cfgitem)
  1355. dataChanged();
  1356. return 1;
  1357. }
  1358. void GuiObjectI::dataChanged() {
  1359. ifc_window *w = guiobject_getRootWnd();
  1360. if (w != NULL) {
  1361. w->onAction(L"reload_config", NULL, -1, -1, 0, 0, NULL, 0, w);
  1362. }
  1363. GuiObject_ScriptMethods::onCfgChanged(SCRIPT_CALL, guiobject_getScriptObject());
  1364. }
  1365. CfgItem *GuiObjectI::guiobject_getCfgItem() {
  1366. return cfgitem;
  1367. }
  1368. const wchar_t *GuiObjectI::guiobject_getCfgAttrib()
  1369. {
  1370. return cfgattrname;
  1371. }
  1372. #endif //WASABI_COMPILE_CONFIG
  1373. void GuiObjectI::guiobject_onChar(wchar_t c)
  1374. {
  1375. wchar_t _c[2]=L"X";
  1376. _c[0]=c;
  1377. GuiObject_ScriptMethods::onChar(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_STRING(_c));
  1378. }
  1379. void GuiObjectI::guiobject_onKeyDown(int vkcode) {
  1380. GuiObject_ScriptMethods::onKeyDown(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_INT(vkcode));
  1381. }
  1382. void GuiObjectI::guiobject_onKeyUp(int vkcode) {
  1383. GuiObject_ScriptMethods::onKeyUp(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_INT(vkcode));
  1384. }
  1385. void GuiObjectI::guiobject_setCursor(const wchar_t *c)
  1386. {
  1387. ifc_window *w = guiobject_getRootWnd();
  1388. #ifdef _WIN32
  1389. if (w != NULL) {
  1390. delete cursor;
  1391. cursor = new SkinCursor(c);
  1392. w->setDefaultCursor(cursor);
  1393. }
  1394. #else
  1395. #warning port me
  1396. #endif
  1397. }
  1398. void GuiObjectI::guiobject_setEnabled(int en) {
  1399. ifc_window *w = guiobject_getRootWnd();
  1400. if (w != NULL) w->setEnabled(en);
  1401. }
  1402. int GuiObjectI::guiobject_wantTranslation()
  1403. {
  1404. return translate;
  1405. }
  1406. int GuiObjectI::guiobject_dragEnter(ifc_window *sourceWnd)
  1407. {
  1408. GuiObject_ScriptMethods::onDragEnter(SCRIPT_CALL, guiobject_getScriptObject());
  1409. return 1;
  1410. }
  1411. int GuiObjectI::guiobject_dragOver(int x, int y, ifc_window *sourceWnd)
  1412. {
  1413. GuiObject_ScriptMethods::onDragOver(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_INT(x), MAKE_SCRIPT_INT(y) );
  1414. return 1;
  1415. }
  1416. int GuiObjectI::guiobject_dragLeave(ifc_window *sourceWnd)
  1417. {
  1418. GuiObject_ScriptMethods::onDragLeave(SCRIPT_CALL, guiobject_getScriptObject());
  1419. return 1;
  1420. }
  1421. GuiObjectScriptController _guiController;
  1422. GuiObjectScriptController *guiController = &_guiController;
  1423. // -- Functions table -------------------------------------
  1424. function_descriptor_struct GuiObjectScriptController::exportedFunction[] = {
  1425. {L"getId", 0, (void*)GuiObject_ScriptMethods::getId },
  1426. {L"show", 0, (void*)GuiObject_ScriptMethods::show },
  1427. {L"hide", 0, (void*)GuiObject_ScriptMethods::hide },
  1428. {L"onSetVisible", 1, (void*)GuiObject_ScriptMethods::onSetVisible},
  1429. {L"isVisible", 0, (void*)GuiObject_ScriptMethods::isvisible },
  1430. {L"setAlpha", 1, (void*)GuiObject_ScriptMethods::setAlpha },
  1431. {L"getAlpha", 0, (void*)GuiObject_ScriptMethods::getAlpha },
  1432. {L"setActiveAlpha", 1, (void*)GuiObject_ScriptMethods::setActiveAlpha },
  1433. {L"getActiveAlpha", 0, (void*)GuiObject_ScriptMethods::getActiveAlpha },
  1434. {L"setInactiveAlpha", 1, (void*)GuiObject_ScriptMethods::setInactiveAlpha },
  1435. {L"getInactiveAlpha", 0, (void*)GuiObject_ScriptMethods::getInactiveAlpha },
  1436. {L"onLeftButtonDown", 2, (void*)GuiObject_ScriptMethods::onLeftButtonDown },
  1437. {L"onLeftButtonUp", 2, (void*)GuiObject_ScriptMethods::onLeftButtonUp },
  1438. {L"onRightButtonDown", 2, (void*)GuiObject_ScriptMethods::onRightButtonDown },
  1439. {L"onRightButtonUp", 2, (void*)GuiObject_ScriptMethods::onRightButtonUp },
  1440. {L"onRightButtonDblClk", 2, (void*)GuiObject_ScriptMethods::onRightButtonDblClk },
  1441. {L"onLeftButtonDblClk", 2, (void*)GuiObject_ScriptMethods::onLeftButtonDblClk },
  1442. {L"onMouseWheelUp", 2, (void*)GuiObject_ScriptMethods::onMouseWheelUp },
  1443. {L"onMouseWheelDown", 2, (void*)GuiObject_ScriptMethods::onMouseWheelDown },
  1444. {L"onMouseMove", 2, (void*)GuiObject_ScriptMethods::onMouseMove },
  1445. {L"onEnterArea", 0, (void*)GuiObject_ScriptMethods::onEnterArea },
  1446. {L"onLeaveArea", 0, (void*)GuiObject_ScriptMethods::onLeaveArea },
  1447. {L"isMouseOverRect", 0, (void*)GuiObject_ScriptMethods::isMouseOverRect},
  1448. {L"onStartup", 0, (void*)GuiObject_ScriptMethods::onStartup },
  1449. {L"onChar", 1, (void*)GuiObject_ScriptMethods::onChar },
  1450. {L"onKeyDown", 1, (void*)GuiObject_ScriptMethods::onKeyDown},
  1451. {L"onKeyUp", 1, (void*)GuiObject_ScriptMethods::onKeyUp},
  1452. {L"setEnabled", 1, (void*)GuiObject_ScriptMethods::setEnabled },
  1453. {L"getEnabled", 0, (void*)GuiObject_ScriptMethods::getEnabled },
  1454. {L"onEnable", 1, (void*)GuiObject_ScriptMethods::onEnable },
  1455. {L"resize", 4, (void*)GuiObject_ScriptMethods::resize },
  1456. {L"onResize", 4, (void*)GuiObject_ScriptMethods::onResize },
  1457. {L"isMouseOver", 2, (void*)GuiObject_ScriptMethods::isMouseOver },
  1458. {L"getLeft", 0, (void*)GuiObject_ScriptMethods::getLeft },
  1459. {L"getTop", 0, (void*)GuiObject_ScriptMethods::getTop },
  1460. {L"getWidth", 0, (void*)GuiObject_ScriptMethods::getWidth },
  1461. {L"getHeight", 0, (void*)GuiObject_ScriptMethods::getHeight },
  1462. {L"getGuiX", 0, (void*)GuiObject_ScriptMethods::getGuiX },
  1463. {L"getGuiY", 0, (void*)GuiObject_ScriptMethods::getGuiY },
  1464. {L"getGuiW", 0, (void*)GuiObject_ScriptMethods::getGuiW },
  1465. {L"getGuiH", 0, (void*)GuiObject_ScriptMethods::getGuiH },
  1466. {L"getGuiRelatX", 0, (void*)GuiObject_ScriptMethods::getGuiRelatX },
  1467. {L"getGuiRelatY", 0, (void*)GuiObject_ScriptMethods::getGuiRelatX },
  1468. {L"getGuiRelatW", 0, (void*)GuiObject_ScriptMethods::getGuiRelatX },
  1469. {L"getGuiRelatH", 0, (void*)GuiObject_ScriptMethods::getGuiRelatX },
  1470. {L"clientToScreenX", 1, (void*)GuiObject_ScriptMethods::clientToScreenX },
  1471. {L"clientToScreenY", 1, (void*)GuiObject_ScriptMethods::clientToScreenY },
  1472. {L"clientToScreenW", 1, (void*)GuiObject_ScriptMethods::clientToScreenW },
  1473. {L"clientToScreenH", 1, (void*)GuiObject_ScriptMethods::clientToScreenH },
  1474. {L"screenToClientX", 1, (void*)GuiObject_ScriptMethods::screenToClientX },
  1475. {L"screenToClientY", 1, (void*)GuiObject_ScriptMethods::screenToClientY },
  1476. {L"screenToClientW", 1, (void*)GuiObject_ScriptMethods::screenToClientW },
  1477. {L"screenToClientH", 1, (void*)GuiObject_ScriptMethods::screenToClientH },
  1478. {L"setTargetX", 1, (void*)GuiObject_ScriptMethods::setTargetX },
  1479. {L"setTargetY", 1, (void*)GuiObject_ScriptMethods::setTargetY },
  1480. {L"setTargetW", 1, (void*)GuiObject_ScriptMethods::setTargetW },
  1481. {L"setTargetH", 1, (void*)GuiObject_ScriptMethods::setTargetH },
  1482. {L"setTargetA", 1, (void*)GuiObject_ScriptMethods::setTargetA },
  1483. {L"setTargetSpeed", 1, (void*)GuiObject_ScriptMethods::setTargetSpeed },
  1484. {L"gotoTarget", 0, (void*)GuiObject_ScriptMethods::gotoTarget },
  1485. {L"onTargetReached", 0, (void*)GuiObject_ScriptMethods::onTargetReached },
  1486. {L"cancelTarget", 0, (void*)GuiObject_ScriptMethods::cancelTarget },
  1487. {L"reverseTarget", 1, (void*)GuiObject_ScriptMethods::reverseTarget },
  1488. {L"isGoingToTarget", 0, (void*)GuiObject_ScriptMethods::movingToTarget },
  1489. {L"setXmlParam", 2, (void*)GuiObject_ScriptMethods::setXmlParam },
  1490. {L"getXmlParam", 1, (void*)GuiObject_ScriptMethods::getXmlParam },
  1491. {L"init", 1, (void*)GuiObject_ScriptMethods::init },
  1492. {L"bringToFront", 0, (void*)GuiObject_ScriptMethods::bringToFront },
  1493. {L"bringToBack", 0, (void*)GuiObject_ScriptMethods::bringToBack },
  1494. {L"bringAbove", 1, (void*)GuiObject_ScriptMethods::bringAbove },
  1495. {L"bringBelow", 1, (void*)GuiObject_ScriptMethods::bringBelow },
  1496. {L"isActive", 0, (void*)GuiObject_ScriptMethods::isActive},
  1497. {L"getParent", 0, (void*)GuiObject_ScriptMethods::getParent},
  1498. {L"getTopParent", 0, (void*)GuiObject_ScriptMethods::getTopParent},
  1499. {L"getInterface", 1, (void*)GuiObject_ScriptMethods::getInterface},
  1500. {L"onAction", 7, (void*)GuiObject_ScriptMethods::onAction},
  1501. #ifdef WASABI_COMPILE_WNDMGR
  1502. {L"getParentLayout", 0, (void*)GuiObject_ScriptMethods::getParentLayout},
  1503. {L"runModal", 0, (void*)GuiObject_ScriptMethods::runModal},
  1504. {L"endModal", 1, (void*)GuiObject_ScriptMethods::endModal},
  1505. {L"popParentLayout", 0, (void*)GuiObject_ScriptMethods::popParentLayout},
  1506. {L"setStatusText", 2, (void*)GuiObject_ScriptMethods::setStatusText},
  1507. #endif
  1508. {L"findObject", 1, (void*)GuiObject_ScriptMethods::findObject},
  1509. {L"findObjectXY", 2, (void*)GuiObject_ScriptMethods::findObjectXY},
  1510. {L"getName", 0, (void*)GuiObject_ScriptMethods::getName},
  1511. {L"getAutoWidth", 0, (void*)GuiObject_ScriptMethods::getAutoWidth },
  1512. {L"getAutoHeight", 0, (void*)GuiObject_ScriptMethods::getAutoHeight },
  1513. {L"setFocus", 0, (void*)GuiObject_ScriptMethods::setFocus},
  1514. {L"onGetFocus", 0, (void*)GuiObject_ScriptMethods::onGetFocus},
  1515. {L"onKillFocus", 0, (void*)GuiObject_ScriptMethods::onKillFocus},
  1516. {L"sendAction", 6, (void*)GuiObject_ScriptMethods::sendAction},
  1517. {L"onAccelerator", 1, (void*)GuiObject_ScriptMethods::onAccelerator},
  1518. #ifdef WASABI_COMPILE_CONFIG
  1519. {L"cfg_getInt", 0, (void*)GuiObject_ScriptMethods::cfgGetInt },
  1520. {L"cfg_setInt", 1, (void*)GuiObject_ScriptMethods::cfgSetInt },
  1521. {L"cfg_getFloat", 0, (void*)GuiObject_ScriptMethods::cfgGetFloat },
  1522. {L"cfg_setFloat", 1, (void*)GuiObject_ScriptMethods::cfgSetFloat },
  1523. {L"cfg_getString", 0, (void*)GuiObject_ScriptMethods::cfgGetString },
  1524. {L"cfg_setString", 1, (void*)GuiObject_ScriptMethods::cfgSetString },
  1525. {L"cfg_onDataChanged", 0, (void*)GuiObject_ScriptMethods::onCfgChanged },
  1526. {L"cfg_getItemGuid", 0, (void*)GuiObject_ScriptMethods::cfgGetGuid},
  1527. {L"cfg_getAttributeName", 0, (void*)GuiObject_ScriptMethods::cfgGetAttributeName},
  1528. #endif
  1529. {L"onDragEnter", 0, (void*)GuiObject_ScriptMethods::onDragEnter },
  1530. {L"onDragOver", 2, (void*)GuiObject_ScriptMethods::onDragOver},
  1531. {L"onDragLeave", 0, (void*)GuiObject_ScriptMethods::onDragLeave},
  1532. };
  1533. const wchar_t *GuiObjectScriptController::getClassName() {
  1534. return L"GuiObject";
  1535. }
  1536. const wchar_t *GuiObjectScriptController::getAncestorClassName() {
  1537. return L"Object";
  1538. }
  1539. ScriptObjectController *GuiObjectScriptController::getAncestorController() {
  1540. return rootScriptObjectController;}
  1541. int GuiObjectScriptController::getNumFunctions() {
  1542. return sizeof(exportedFunction) / sizeof(function_descriptor_struct);
  1543. }
  1544. const function_descriptor_struct *GuiObjectScriptController::getExportedFunctions() {
  1545. return exportedFunction;
  1546. }
  1547. GUID GuiObjectScriptController::getClassGuid() {
  1548. return guiObjectGuid;
  1549. }
  1550. int GuiObjectScriptController::getInstantiable() {
  1551. return 1;
  1552. }
  1553. ScriptObject *GuiObjectScriptController::instantiate() {
  1554. GuiObjectWnd *w = new GuiObjectWnd;
  1555. ASSERT(w != NULL);
  1556. return w->getScriptObject();
  1557. }
  1558. void GuiObjectScriptController::destroy(ScriptObject *o) {
  1559. GuiObjectWnd *w = static_cast<GuiObjectWnd *>(o->vcpu_getInterface(guiObjectWndGuid));
  1560. ASSERT(w != NULL);
  1561. delete w;
  1562. }
  1563. void *GuiObjectScriptController::encapsulate(ScriptObject *o) {
  1564. return static_cast<void *>(new GuiObjectI(o));
  1565. }
  1566. void GuiObjectScriptController::deencapsulate(void *o) {
  1567. delete static_cast<GuiObjectI *>(o);
  1568. }
  1569. // ----------------------------------------------------------------------------------------------------------------------------------
  1570. // returns a new ScriptString object containing the xml id of this object
  1571. scriptVar GuiObject_ScriptMethods::getId(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  1572. SCRIPT_FUNCTION_INIT;
  1573. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1574. if (g)
  1575. return MAKE_SCRIPT_STRING(g->guiobject_getId());
  1576. return MAKE_SCRIPT_STRING(L"");
  1577. }
  1578. scriptVar GuiObject_ScriptMethods::hide(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  1579. SCRIPT_FUNCTION_INIT;
  1580. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1581. if (g) {
  1582. ifc_window *w = g->guiobject_getRootWnd();
  1583. if (w)
  1584. w->setVisible(0);
  1585. }
  1586. RETURN_SCRIPT_VOID;
  1587. }
  1588. scriptVar GuiObject_ScriptMethods::show(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  1589. SCRIPT_FUNCTION_INIT;
  1590. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1591. if (g) {
  1592. ifc_window *w = g->guiobject_getRootWnd();
  1593. if (w)
  1594. w->setVisible(1);
  1595. }
  1596. RETURN_SCRIPT_VOID;
  1597. }
  1598. scriptVar GuiObject_ScriptMethods::isvisible(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  1599. SCRIPT_FUNCTION_INIT;
  1600. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1601. if (g) {
  1602. ifc_window *w = g->guiobject_getRootWnd();
  1603. if (w) return MAKE_SCRIPT_BOOLEAN(w->isVisible());
  1604. }
  1605. RETURN_SCRIPT_ZERO;
  1606. }
  1607. scriptVar GuiObject_ScriptMethods::getAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  1608. SCRIPT_FUNCTION_INIT;
  1609. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1610. if (g) return MAKE_SCRIPT_INT(g->guiobject_getAlpha());
  1611. return MAKE_SCRIPT_INT(255);
  1612. }
  1613. scriptVar GuiObject_ScriptMethods::setAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a) {
  1614. SCRIPT_FUNCTION_INIT;
  1615. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1616. if (g) g->guiobject_setAlpha(GET_SCRIPT_INT(a));
  1617. RETURN_SCRIPT_VOID;
  1618. }
  1619. scriptVar GuiObject_ScriptMethods::getActiveAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  1620. SCRIPT_FUNCTION_INIT;
  1621. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1622. if (g) return MAKE_SCRIPT_INT(g->guiobject_getActiveAlpha());
  1623. return MAKE_SCRIPT_INT(255);
  1624. }
  1625. scriptVar GuiObject_ScriptMethods::setActiveAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a) {
  1626. SCRIPT_FUNCTION_INIT;
  1627. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1628. if (g) g->guiobject_setActiveAlpha(GET_SCRIPT_INT(a));
  1629. RETURN_SCRIPT_VOID;
  1630. }
  1631. scriptVar GuiObject_ScriptMethods::getInactiveAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  1632. SCRIPT_FUNCTION_INIT;
  1633. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1634. if (g) return MAKE_SCRIPT_INT(g->guiobject_getInactiveAlpha());
  1635. return MAKE_SCRIPT_INT(255);
  1636. }
  1637. scriptVar GuiObject_ScriptMethods::setInactiveAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a) {
  1638. SCRIPT_FUNCTION_INIT;
  1639. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1640. if (g) g->guiobject_setInactiveAlpha(GET_SCRIPT_INT(a));
  1641. RETURN_SCRIPT_VOID;
  1642. }
  1643. scriptVar GuiObject_ScriptMethods::onMouseMove(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) {
  1644. SCRIPT_FUNCTION_INIT;
  1645. PROCESS_HOOKS2(o, guiController, x, y);
  1646. SCRIPT_FUNCTION_CHECKABORTEVENT;
  1647. SCRIPT_EXEC_EVENT2(o, x, y);
  1648. }
  1649. scriptVar GuiObject_ScriptMethods::onLeftButtonDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) {
  1650. SCRIPT_FUNCTION_INIT;
  1651. PROCESS_HOOKS2(o, guiController, x, y);
  1652. SCRIPT_FUNCTION_CHECKABORTEVENT;
  1653. SCRIPT_EXEC_EVENT2(o, x, y);
  1654. }
  1655. scriptVar GuiObject_ScriptMethods::onLeftButtonUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) {
  1656. SCRIPT_FUNCTION_INIT;
  1657. PROCESS_HOOKS2(o, guiController, x, y);
  1658. SCRIPT_FUNCTION_CHECKABORTEVENT;
  1659. SCRIPT_EXEC_EVENT2(o, x, y);
  1660. }
  1661. scriptVar GuiObject_ScriptMethods::onRightButtonDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) {
  1662. SCRIPT_FUNCTION_INIT;
  1663. PROCESS_HOOKS2(o, guiController, x, y);
  1664. SCRIPT_FUNCTION_CHECKABORTEVENT;
  1665. SCRIPT_EXEC_EVENT2(o, x, y);
  1666. }
  1667. scriptVar GuiObject_ScriptMethods::onRightButtonUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) {
  1668. SCRIPT_FUNCTION_INIT;
  1669. PROCESS_HOOKS2(o, guiController, x, y);
  1670. SCRIPT_FUNCTION_CHECKABORTEVENT;
  1671. SCRIPT_EXEC_EVENT2(o, x, y);
  1672. }
  1673. scriptVar GuiObject_ScriptMethods::onLeftButtonDblClk(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) {
  1674. SCRIPT_FUNCTION_INIT;
  1675. PROCESS_HOOKS2(o, guiController, x, y);
  1676. SCRIPT_FUNCTION_CHECKABORTEVENT;
  1677. SCRIPT_EXEC_EVENT2(o, x, y);
  1678. }
  1679. scriptVar GuiObject_ScriptMethods::onRightButtonDblClk(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) {
  1680. SCRIPT_FUNCTION_INIT;
  1681. PROCESS_HOOKS2(o, guiController, x, y);
  1682. SCRIPT_FUNCTION_CHECKABORTEVENT;
  1683. SCRIPT_EXEC_EVENT2(o, x, y);
  1684. }
  1685. scriptVar GuiObject_ScriptMethods::onMouseWheelUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar clicked, scriptVar lines) {
  1686. SCRIPT_FUNCTION_INIT;
  1687. PROCESS_HOOKS2(o, guiController, clicked, lines);
  1688. SCRIPT_FUNCTION_CHECKABORTEVENT;
  1689. SCRIPT_EXEC_EVENT2(o, clicked, lines);
  1690. }
  1691. scriptVar GuiObject_ScriptMethods::onMouseWheelDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar clicked, scriptVar lines) {
  1692. SCRIPT_FUNCTION_INIT;
  1693. PROCESS_HOOKS2(o, guiController, clicked, lines);
  1694. SCRIPT_FUNCTION_CHECKABORTEVENT;
  1695. SCRIPT_EXEC_EVENT2(o, clicked, lines);
  1696. }
  1697. scriptVar GuiObject_ScriptMethods::onEnterArea(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  1698. SCRIPT_FUNCTION_INIT;
  1699. PROCESS_HOOKS0(o, guiController);
  1700. SCRIPT_FUNCTION_CHECKABORTEVENT;
  1701. SCRIPT_EXEC_EVENT0(o);
  1702. }
  1703. scriptVar GuiObject_ScriptMethods::onLeaveArea(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  1704. SCRIPT_FUNCTION_INIT;
  1705. PROCESS_HOOKS0(o, guiController);
  1706. SCRIPT_FUNCTION_CHECKABORTEVENT;
  1707. SCRIPT_EXEC_EVENT0(o);
  1708. }
  1709. scriptVar GuiObject_ScriptMethods::setEnabled(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v) {
  1710. SCRIPT_FUNCTION_INIT;
  1711. ASSERT(SOM::isNumeric(&v));
  1712. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1713. if (g) {
  1714. ifc_window *b = g->guiobject_getRootWnd();
  1715. if (b) b->setEnabled(GET_SCRIPT_BOOLEAN(v));
  1716. }
  1717. RETURN_SCRIPT_VOID;
  1718. }
  1719. scriptVar GuiObject_ScriptMethods::getEnabled(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  1720. SCRIPT_FUNCTION_INIT;
  1721. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1722. if (g) {
  1723. ifc_window *b = g->guiobject_getRootWnd();
  1724. if (b) return MAKE_SCRIPT_BOOLEAN(b->isEnabled());
  1725. }
  1726. RETURN_SCRIPT_ZERO;
  1727. }
  1728. scriptVar GuiObject_ScriptMethods::onEnable(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v) {
  1729. SCRIPT_FUNCTION_INIT;
  1730. PROCESS_HOOKS1(o, guiController, v);
  1731. SCRIPT_FUNCTION_CHECKABORTEVENT;
  1732. SCRIPT_EXEC_EVENT1(o, v);
  1733. }
  1734. scriptVar GuiObject_ScriptMethods::onSetVisible(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v) {
  1735. SCRIPT_FUNCTION_INIT;
  1736. PROCESS_HOOKS1(o, guiController, v);
  1737. SCRIPT_FUNCTION_CHECKABORTEVENT;
  1738. SCRIPT_EXEC_EVENT1(o, v);
  1739. }
  1740. scriptVar GuiObject_ScriptMethods::onResize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y, scriptVar w, scriptVar h) {
  1741. SCRIPT_FUNCTION_INIT;
  1742. PROCESS_HOOKS4(o, guiController, x, y, w, h);
  1743. SCRIPT_FUNCTION_CHECKABORTEVENT;
  1744. SCRIPT_EXEC_EVENT4(o, x, y, w, h);
  1745. }
  1746. scriptVar GuiObject_ScriptMethods::resize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y, scriptVar w, scriptVar h) {
  1747. SCRIPT_FUNCTION_INIT;
  1748. ASSERT(SOM::isNumeric(&x));
  1749. ASSERT(SOM::isNumeric(&y));
  1750. ASSERT(SOM::isNumeric(&w));
  1751. ASSERT(SOM::isNumeric(&h));
  1752. GuiObject *go = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1753. if (go) {
  1754. int _x = SOM::makeInt(&x);
  1755. int _y = SOM::makeInt(&y);
  1756. int _w = SOM::makeInt(&w);
  1757. int _h = SOM::makeInt(&h);
  1758. ifc_window *b = go->guiobject_getRootWnd();
  1759. if (b) b->resize(_x, _y, _w, _h);
  1760. go->guiobject_setGuiPosition(_x == NOCHANGE ? &_x : NULL, _y == NOCHANGE ? &_y : NULL, _w == NOCHANGE ? &_w : NULL, _h == NOCHANGE ? &_h : NULL, NULL, NULL, NULL, NULL);
  1761. if (b && b->getInterface(layoutGuid)) {
  1762. b->cascadeRepaint();
  1763. ((Layout *)b->getInterface(layoutGuid))->savePosition();
  1764. }
  1765. }
  1766. RETURN_SCRIPT_VOID;
  1767. }
  1768. scriptVar GuiObject_ScriptMethods::isMouseOver(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) {
  1769. SCRIPT_FUNCTION_INIT;
  1770. ASSERT(SOM::isNumeric(&x));
  1771. ASSERT(SOM::isNumeric(&y));
  1772. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1773. if (g) {
  1774. ifc_window *b = g->guiobject_getRootWnd();
  1775. POINT pt={GET_SCRIPT_INT(x), GET_SCRIPT_INT(y)};
  1776. b->clientToScreen((int *)&pt.x, (int *)&pt.y);
  1777. return MAKE_SCRIPT_BOOLEAN(WASABI_API_WND->rootWndFromPoint(&pt) == b);
  1778. }
  1779. RETURN_SCRIPT_ZERO;
  1780. }
  1781. scriptVar GuiObject_ScriptMethods::getLeft(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  1782. SCRIPT_FUNCTION_INIT;
  1783. GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
  1784. ifc_window *b = go->guiobject_getRootWnd();
  1785. int r=0;
  1786. if (b && b->isInited()) {
  1787. POINT pt;
  1788. b->getPosition(&pt);
  1789. r = pt.x;
  1790. } else if (b && !b->isInited()) {
  1791. go->guiobject_getGuiPosition(&r, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
  1792. }
  1793. return MAKE_SCRIPT_INT(r);
  1794. }
  1795. scriptVar GuiObject_ScriptMethods::movingToTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  1796. SCRIPT_FUNCTION_INIT;
  1797. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1798. if (g) return MAKE_SCRIPT_BOOLEAN(g->guiobject_movingToTarget());
  1799. RETURN_SCRIPT_ZERO;
  1800. }
  1801. scriptVar GuiObject_ScriptMethods::cancelTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  1802. SCRIPT_FUNCTION_INIT;
  1803. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1804. if (g && g->guiobject_movingToTarget()) g->guiobject_cancelTarget();
  1805. RETURN_SCRIPT_VOID;
  1806. }
  1807. scriptVar GuiObject_ScriptMethods::reverseTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r) {
  1808. SCRIPT_FUNCTION_INIT;
  1809. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1810. if (g) g->guiobject_reverseTarget(GET_SCRIPT_INT(r));
  1811. RETURN_SCRIPT_VOID;
  1812. }
  1813. scriptVar GuiObject_ScriptMethods::getTop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  1814. SCRIPT_FUNCTION_INIT;
  1815. GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
  1816. ifc_window *b = go->guiobject_getRootWnd();
  1817. int r=0;
  1818. if (b && b->isInited()) {
  1819. POINT pt;
  1820. b->getPosition(&pt);
  1821. r = pt.y;
  1822. } else if (b && !b->isInited()) {
  1823. go->guiobject_getGuiPosition(NULL, &r, NULL, NULL, NULL, NULL, NULL, NULL);
  1824. }
  1825. return MAKE_SCRIPT_INT(r);
  1826. }
  1827. scriptVar GuiObject_ScriptMethods::getWidth(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  1828. SCRIPT_FUNCTION_INIT;
  1829. GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
  1830. ifc_window *b = go->guiobject_getRootWnd();
  1831. int r=0;
  1832. if (b && b->isInited()) {
  1833. RECT rc;
  1834. b->getClientRect(&rc);
  1835. r = rc.right-rc.left;
  1836. } else if (b && !b->isInited()) {
  1837. go->guiobject_getGuiPosition(NULL, NULL, &r, NULL, NULL, NULL, NULL, NULL);
  1838. }
  1839. return MAKE_SCRIPT_INT(r);
  1840. }
  1841. scriptVar GuiObject_ScriptMethods::getHeight(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  1842. SCRIPT_FUNCTION_INIT;
  1843. GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
  1844. ifc_window *b = go->guiobject_getRootWnd();
  1845. int r=0;
  1846. if (b && b->isInited()) {
  1847. RECT rc;
  1848. b->getClientRect(&rc);
  1849. r = rc.bottom-rc.top;
  1850. } else if (b && !b->isInited()) {
  1851. go->guiobject_getGuiPosition(NULL, NULL, NULL, &r, NULL, NULL, NULL, NULL);
  1852. }
  1853. return MAKE_SCRIPT_INT(r);
  1854. }
  1855. scriptVar GuiObject_ScriptMethods::setTargetX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x) {
  1856. SCRIPT_FUNCTION_INIT;
  1857. ASSERT(SOM::isNumeric(&x));
  1858. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1859. if (g) g->guiobject_setTargetX(GET_SCRIPT_INT(x));
  1860. RETURN_SCRIPT_VOID;
  1861. }
  1862. scriptVar GuiObject_ScriptMethods::setTargetY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar y) {
  1863. SCRIPT_FUNCTION_INIT;
  1864. ASSERT(SOM::isNumeric(&y));
  1865. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1866. if (g) g->guiobject_setTargetY(GET_SCRIPT_INT(y));
  1867. RETURN_SCRIPT_VOID;
  1868. }
  1869. scriptVar GuiObject_ScriptMethods::setTargetW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar w) {
  1870. SCRIPT_FUNCTION_INIT;
  1871. ASSERT(SOM::isNumeric(&w));
  1872. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1873. if (g) g->guiobject_setTargetW(GET_SCRIPT_INT(w));
  1874. RETURN_SCRIPT_VOID;
  1875. }
  1876. scriptVar GuiObject_ScriptMethods::setTargetH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar h) {
  1877. SCRIPT_FUNCTION_INIT;
  1878. ASSERT(SOM::isNumeric(&h));
  1879. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1880. if (g) g->guiobject_setTargetH(GET_SCRIPT_INT(h));
  1881. RETURN_SCRIPT_VOID;
  1882. }
  1883. scriptVar GuiObject_ScriptMethods::setTargetA(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a) {
  1884. SCRIPT_FUNCTION_INIT;
  1885. ASSERT(SOM::isNumeric(&a));
  1886. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1887. if (g) g->guiobject_setTargetA(GET_SCRIPT_INT(a));
  1888. RETURN_SCRIPT_VOID;
  1889. }
  1890. scriptVar GuiObject_ScriptMethods::setTargetSpeed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s) {
  1891. SCRIPT_FUNCTION_INIT;
  1892. ASSERT(SOM::isNumeric(&s));
  1893. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1894. if (g) g->guiobject_setTargetSpeed(GET_SCRIPT_FLOAT(s));
  1895. RETURN_SCRIPT_VOID;
  1896. }
  1897. scriptVar GuiObject_ScriptMethods::gotoTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  1898. SCRIPT_FUNCTION_INIT;
  1899. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1900. if (g) g->guiobject_gotoTarget();
  1901. RETURN_SCRIPT_VOID;
  1902. }
  1903. scriptVar GuiObject_ScriptMethods::bringToFront(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  1904. SCRIPT_FUNCTION_INIT;
  1905. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1906. if (g) g->guiobject_bringToFront();
  1907. RETURN_SCRIPT_VOID;
  1908. }
  1909. scriptVar GuiObject_ScriptMethods::bringToBack(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  1910. SCRIPT_FUNCTION_INIT;
  1911. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1912. if (g) g->guiobject_bringToBack();
  1913. RETURN_SCRIPT_VOID;
  1914. }
  1915. scriptVar GuiObject_ScriptMethods::bringAbove(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj) {
  1916. SCRIPT_FUNCTION_INIT;
  1917. ASSERT(obj.data.odata != NULL);
  1918. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1919. if (g) g->guiobject_bringAbove((static_cast<GuiObject *>(GET_SCRIPT_OBJECT_AS(obj, guiObjectGuid))));
  1920. RETURN_SCRIPT_VOID;
  1921. }
  1922. scriptVar GuiObject_ScriptMethods::bringBelow(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj) {
  1923. SCRIPT_FUNCTION_INIT;
  1924. ASSERT(obj.data.odata != NULL);
  1925. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1926. if (g) g->guiobject_bringBelow((static_cast<GuiObject *>(GET_SCRIPT_OBJECT_AS(obj, guiObjectGuid))));
  1927. RETURN_SCRIPT_VOID;
  1928. }
  1929. scriptVar GuiObject_ScriptMethods::onTargetReached(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  1930. SCRIPT_FUNCTION_INIT;
  1931. PROCESS_HOOKS0(o, guiController);
  1932. SCRIPT_FUNCTION_CHECKABORTEVENT;
  1933. SCRIPT_EXEC_EVENT0(o);
  1934. }
  1935. scriptVar GuiObject_ScriptMethods::setXmlParam(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar param, scriptVar value)
  1936. {
  1937. SCRIPT_FUNCTION_INIT;
  1938. XmlObject *x = static_cast<XmlObject*>(o->vcpu_getInterface(xmlObjectGuid));
  1939. if (x)
  1940. x->setXmlParam(GET_SCRIPT_STRING(param), GET_SCRIPT_STRING(value));
  1941. RETURN_SCRIPT_VOID;
  1942. }
  1943. scriptVar GuiObject_ScriptMethods::getXmlParam(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar param) {
  1944. SCRIPT_FUNCTION_INIT;
  1945. const wchar_t *rt = NULL;
  1946. XmlObject *x = static_cast<XmlObject*>(o->vcpu_getInterface(xmlObjectGuid));
  1947. if (x) {
  1948. int r = x->getXmlParam(GET_SCRIPT_STRING(param));
  1949. if (r != -1)
  1950. rt = x->getXmlParamValue(r);
  1951. }
  1952. if (rt == NULL)
  1953. rt = L""; // returning null in a string is kinda bad, y'know?
  1954. return MAKE_SCRIPT_STRING(rt);
  1955. }
  1956. scriptVar GuiObject_ScriptMethods::onStartup(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  1957. SCRIPT_FUNCTION_INIT;
  1958. PROCESS_HOOKS0(o, guiController);
  1959. SCRIPT_FUNCTION_CHECKABORTEVENT;
  1960. SCRIPT_EXEC_EVENT0(o);
  1961. }
  1962. scriptVar GuiObject_ScriptMethods::getGuiX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  1963. SCRIPT_FUNCTION_INIT;
  1964. int v=0;
  1965. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1966. if (g) g->guiobject_getGuiPosition(&v, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
  1967. return MAKE_SCRIPT_INT(v);
  1968. }
  1969. scriptVar GuiObject_ScriptMethods::getGuiY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  1970. SCRIPT_FUNCTION_INIT;
  1971. int v=0;
  1972. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1973. if (g) g->guiobject_getGuiPosition(NULL, &v, NULL, NULL, NULL, NULL, NULL, NULL);
  1974. return MAKE_SCRIPT_INT(v);
  1975. }
  1976. scriptVar GuiObject_ScriptMethods::getGuiW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  1977. SCRIPT_FUNCTION_INIT;
  1978. int v=0;
  1979. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1980. if (g) g->guiobject_getGuiPosition(NULL, NULL, &v, NULL, NULL, NULL, NULL, NULL);
  1981. return MAKE_SCRIPT_INT(v);
  1982. }
  1983. scriptVar GuiObject_ScriptMethods::getGuiH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  1984. SCRIPT_FUNCTION_INIT;
  1985. int v=0;
  1986. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1987. if (g) g->guiobject_getGuiPosition(NULL, NULL, NULL, &v, NULL, NULL, NULL, NULL);
  1988. return MAKE_SCRIPT_INT(v);
  1989. }
  1990. scriptVar GuiObject_ScriptMethods::getGuiRelatX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  1991. SCRIPT_FUNCTION_INIT;
  1992. int v=0;
  1993. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  1994. if (g) g->guiobject_getGuiPosition(NULL, NULL, NULL, NULL, &v, NULL, NULL, NULL);
  1995. return MAKE_SCRIPT_INT(v);
  1996. }
  1997. scriptVar GuiObject_ScriptMethods::getGuiRelatY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  1998. SCRIPT_FUNCTION_INIT;
  1999. int v=0;
  2000. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  2001. if (g) g->guiobject_getGuiPosition(NULL, NULL, NULL, NULL, NULL, &v, NULL, NULL);
  2002. return MAKE_SCRIPT_INT(v);
  2003. }
  2004. scriptVar GuiObject_ScriptMethods::getGuiRelatW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  2005. SCRIPT_FUNCTION_INIT;
  2006. int v=0;
  2007. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  2008. if (g) g->guiobject_getGuiPosition(NULL, NULL, NULL, NULL, NULL, NULL, &v, NULL);
  2009. return MAKE_SCRIPT_INT(v);
  2010. }
  2011. scriptVar GuiObject_ScriptMethods::getGuiRelatH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  2012. SCRIPT_FUNCTION_INIT;
  2013. int v=0;
  2014. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  2015. if (g) g->guiobject_getGuiPosition(NULL, NULL, NULL, NULL, NULL, NULL, NULL, &v);
  2016. return MAKE_SCRIPT_INT(v);
  2017. }
  2018. scriptVar GuiObject_ScriptMethods::clientToScreenX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x) {
  2019. SCRIPT_FUNCTION_INIT;
  2020. int v=0;
  2021. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  2022. if (g) {
  2023. ifc_window *w = g->guiobject_getRootWnd();
  2024. if (w != NULL) {
  2025. v = GET_SCRIPT_INT(x);
  2026. w->clientToScreen(&v, NULL);
  2027. }
  2028. }
  2029. return MAKE_SCRIPT_INT(v);
  2030. }
  2031. scriptVar GuiObject_ScriptMethods::clientToScreenY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar y) {
  2032. SCRIPT_FUNCTION_INIT;
  2033. int v=0;
  2034. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  2035. if (g) {
  2036. ifc_window *w = g->guiobject_getRootWnd();
  2037. if (w != NULL) {
  2038. v = GET_SCRIPT_INT(y);
  2039. w->clientToScreen(NULL, &v);
  2040. }
  2041. }
  2042. return MAKE_SCRIPT_INT(v);
  2043. }
  2044. scriptVar GuiObject_ScriptMethods::clientToScreenW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar w) {
  2045. SCRIPT_FUNCTION_INIT;
  2046. int v=0;
  2047. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  2048. if (g) {
  2049. ifc_window *wn = g->guiobject_getRootWnd();
  2050. if (wn != NULL) {
  2051. v = GET_SCRIPT_INT(w);
  2052. double rr = wn->getRenderRatio();
  2053. v = (int)((double)(v) * rr);
  2054. }
  2055. }
  2056. return MAKE_SCRIPT_INT(v);
  2057. }
  2058. scriptVar GuiObject_ScriptMethods::clientToScreenH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar h) {
  2059. SCRIPT_FUNCTION_INIT;
  2060. int v=0;
  2061. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  2062. if (g) {
  2063. ifc_window *w = g->guiobject_getRootWnd();
  2064. if (w != NULL) {
  2065. v = GET_SCRIPT_INT(h);
  2066. double rr = w->getRenderRatio();
  2067. v = (int)((double)(v) * rr);
  2068. }
  2069. }
  2070. return MAKE_SCRIPT_INT(v);
  2071. }
  2072. scriptVar GuiObject_ScriptMethods::screenToClientX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x) {
  2073. SCRIPT_FUNCTION_INIT;
  2074. int v=0;
  2075. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  2076. if (g) {
  2077. ifc_window *w = g->guiobject_getRootWnd();
  2078. if (w != NULL) {
  2079. v = GET_SCRIPT_INT(x);
  2080. w->screenToClient(&v, NULL);
  2081. }
  2082. }
  2083. return MAKE_SCRIPT_INT(v);
  2084. }
  2085. scriptVar GuiObject_ScriptMethods::screenToClientY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar y) {
  2086. SCRIPT_FUNCTION_INIT;
  2087. int v=0;
  2088. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  2089. if (g) {
  2090. ifc_window *w = g->guiobject_getRootWnd();
  2091. if (w != NULL) {
  2092. v = GET_SCRIPT_INT(y);
  2093. w->screenToClient(NULL, &v);
  2094. }
  2095. }
  2096. return MAKE_SCRIPT_INT(v);
  2097. }
  2098. scriptVar GuiObject_ScriptMethods::screenToClientW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar w) {
  2099. SCRIPT_FUNCTION_INIT;
  2100. int v=0;
  2101. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  2102. if (g) {
  2103. ifc_window *wn = g->guiobject_getRootWnd();
  2104. if (wn != NULL) {
  2105. v = GET_SCRIPT_INT(w);
  2106. double rr = wn->getRenderRatio();
  2107. v = (int)((double)(v) / rr);
  2108. }
  2109. }
  2110. return MAKE_SCRIPT_INT(v);
  2111. }
  2112. scriptVar GuiObject_ScriptMethods::screenToClientH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar h) {
  2113. SCRIPT_FUNCTION_INIT;
  2114. int v=0;
  2115. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  2116. if (g) {
  2117. ifc_window *w = g->guiobject_getRootWnd();
  2118. if (w != NULL) {
  2119. v = GET_SCRIPT_INT(h);
  2120. double rr = w->getRenderRatio();
  2121. v = (int)((double)(v) / rr);
  2122. }
  2123. }
  2124. return MAKE_SCRIPT_INT(v);
  2125. }
  2126. scriptVar GuiObject_ScriptMethods::isActive(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  2127. SCRIPT_FUNCTION_INIT;
  2128. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  2129. if (g) {
  2130. ifc_window *w = (static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid)))->guiobject_getRootWnd();
  2131. if (w) return MAKE_SCRIPT_INT(w->isActive());
  2132. }
  2133. RETURN_SCRIPT_ZERO;
  2134. }
  2135. scriptVar GuiObject_ScriptMethods::getParent(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  2136. SCRIPT_FUNCTION_INIT;
  2137. GuiObject *go = (static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid)));
  2138. if (go) {
  2139. GuiObject *g = go->guiobject_getParent();
  2140. ScriptObject *so = NULL;
  2141. if (g != NULL)
  2142. so = g->guiobject_getScriptObject();
  2143. return MAKE_SCRIPT_OBJECT(so);
  2144. }
  2145. RETURN_SCRIPT_VOID;
  2146. }
  2147. #ifdef WASABI_COMPILE_WNDMGR
  2148. scriptVar GuiObject_ScriptMethods::getParentLayout(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  2149. SCRIPT_FUNCTION_INIT;
  2150. GuiObject *go = (static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid)));
  2151. if (go) {
  2152. Layout *l = go->guiobject_getParentLayout();
  2153. return MAKE_SCRIPT_OBJECT(l ? l->getGuiObject()->guiobject_getScriptObject() : NULL);
  2154. }
  2155. RETURN_SCRIPT_VOID;
  2156. }
  2157. #endif
  2158. scriptVar GuiObject_ScriptMethods::getTopParent(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  2159. SCRIPT_FUNCTION_INIT;
  2160. GuiObject *go = (static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid)));
  2161. if (go) {
  2162. GuiObject *l = go->guiobject_getTopParent();
  2163. return MAKE_SCRIPT_OBJECT(l ? l->guiobject_getScriptObject() : NULL);
  2164. }
  2165. RETURN_SCRIPT_VOID;
  2166. }
  2167. scriptVar GuiObject_ScriptMethods::getAutoWidth(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  2168. SCRIPT_FUNCTION_INIT;
  2169. GuiObject *go = (static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid)));
  2170. int v = 0;
  2171. if (go) { v = go->guiobject_getRootWnd()->getPreferences(SUGGESTED_W); if (v == AUTOWH) v = go->guiobject_getAutoWidth(); }
  2172. return MAKE_SCRIPT_INT(v);
  2173. }
  2174. scriptVar GuiObject_ScriptMethods::getAutoHeight(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  2175. SCRIPT_FUNCTION_INIT;
  2176. GuiObject *go = (static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid)));
  2177. int v = 0;
  2178. if (go) { v = go->guiobject_getRootWnd()->getPreferences(SUGGESTED_H); if (v == AUTOWH) v = go->guiobject_getAutoHeight(); }
  2179. return MAKE_SCRIPT_INT(v);
  2180. }
  2181. scriptVar GuiObject_ScriptMethods::init(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar parentGroup) {
  2182. SCRIPT_FUNCTION_INIT;
  2183. ASSERT(parentGroup.data.odata != NULL);
  2184. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  2185. if (g) {
  2186. Group *pg = static_cast<Group *>(GET_SCRIPT_OBJECT_AS(parentGroup, groupGuid));
  2187. pg->addChild(g);
  2188. if (!g->guiobject_getRootWnd()->isInited())
  2189. g->guiobject_getRootWnd()->init(pg);
  2190. }
  2191. RETURN_SCRIPT_VOID;
  2192. }
  2193. #ifdef WASABI_COMPILE_WNDMGR
  2194. scriptVar GuiObject_ScriptMethods::runModal(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  2195. SCRIPT_FUNCTION_INIT;
  2196. int r=0;
  2197. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  2198. if (g) r = g->guiobject_runModal();
  2199. return MAKE_SCRIPT_INT(r);
  2200. }
  2201. scriptVar GuiObject_ScriptMethods::endModal(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar retcode) {
  2202. SCRIPT_FUNCTION_INIT;
  2203. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  2204. if (g) g->guiobject_endModal(GET_SCRIPT_INT(retcode));
  2205. RETURN_SCRIPT_VOID;
  2206. }
  2207. #endif
  2208. scriptVar GuiObject_ScriptMethods::setFocus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  2209. SCRIPT_FUNCTION_INIT;
  2210. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  2211. if (g) {
  2212. ifc_window *w = g->guiobject_getRootWnd();
  2213. if (w != NULL) {
  2214. w->setFocus();
  2215. }
  2216. }
  2217. RETURN_SCRIPT_VOID;
  2218. }
  2219. #ifdef WASABI_COMPILE_WNDMGR
  2220. scriptVar GuiObject_ScriptMethods::popParentLayout(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  2221. SCRIPT_FUNCTION_INIT;
  2222. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  2223. if (g) g->guiobject_popParentLayout();
  2224. RETURN_SCRIPT_VOID;
  2225. }
  2226. scriptVar GuiObject_ScriptMethods::setStatusText(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar text, scriptVar overlay) {
  2227. SCRIPT_FUNCTION_INIT;
  2228. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  2229. if (g)
  2230. g->guiobject_setStatusText(GET_SCRIPT_STRING(text), GET_SCRIPT_INT(overlay));
  2231. RETURN_SCRIPT_VOID;
  2232. }
  2233. #endif
  2234. scriptVar GuiObject_ScriptMethods::findObject(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar id) {
  2235. SCRIPT_FUNCTION_INIT;
  2236. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  2237. ScriptObject *s = NULL;
  2238. if (g) {
  2239. GuiObject *o = g->guiobject_findObject(GET_SCRIPT_STRING(id));
  2240. if (o != NULL) s = o->guiobject_getScriptObject();
  2241. }
  2242. return MAKE_SCRIPT_OBJECT(s);
  2243. }
  2244. scriptVar GuiObject_ScriptMethods::findObjectXY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) {
  2245. SCRIPT_FUNCTION_INIT;
  2246. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  2247. ScriptObject *s = NULL;
  2248. if (g) {
  2249. GuiObject *o = g->guiobject_findObjectXY(GET_SCRIPT_INT(x), GET_SCRIPT_INT(y));
  2250. if (o != NULL) s = o->guiobject_getScriptObject();
  2251. }
  2252. return MAKE_SCRIPT_OBJECT(s);
  2253. }
  2254. scriptVar GuiObject_ScriptMethods::getName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2255. {
  2256. SCRIPT_FUNCTION_INIT;
  2257. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  2258. if (g)
  2259. return MAKE_SCRIPT_STRING(g->guiobject_getName());
  2260. return MAKE_SCRIPT_STRING(L"");
  2261. }
  2262. scriptVar GuiObject_ScriptMethods::getMover(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  2263. SCRIPT_FUNCTION_INIT;
  2264. int r = 0;
  2265. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  2266. if (g) r = g->guiobject_getMover();
  2267. return MAKE_SCRIPT_INT(r);
  2268. }
  2269. scriptVar GuiObject_ScriptMethods::setMover(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i) {
  2270. SCRIPT_FUNCTION_INIT;
  2271. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  2272. if (g) g->guiobject_setMover(GET_SCRIPT_INT(i));
  2273. RETURN_SCRIPT_VOID;
  2274. }
  2275. scriptVar GuiObject_ScriptMethods::setDropTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar targ) {
  2276. GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
  2277. const wchar_t *s = GET_SCRIPT_STRING(targ);
  2278. if (g)
  2279. g->guiobject_setDropTarget(s);
  2280. RETURN_SCRIPT_VOID;
  2281. }
  2282. #ifdef WASABI_COMPILE_CONFIG
  2283. scriptVar GuiObject_ScriptMethods::cfgGetInt(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  2284. SCRIPT_FUNCTION_INIT
  2285. GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
  2286. if (go) return MAKE_SCRIPT_INT(go->guiobject_getCfgInt());
  2287. return MAKE_SCRIPT_INT(0);
  2288. }
  2289. scriptVar GuiObject_ScriptMethods::cfgSetInt(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v) {
  2290. SCRIPT_FUNCTION_INIT
  2291. ASSERT(SOM::isNumeric(&v));
  2292. GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
  2293. if (go) go->guiobject_setCfgInt(GET_SCRIPT_INT(v));
  2294. RETURN_SCRIPT_VOID;
  2295. }
  2296. scriptVar GuiObject_ScriptMethods::cfgGetString(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  2297. SCRIPT_FUNCTION_INIT
  2298. GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
  2299. if (go)
  2300. return MAKE_SCRIPT_STRING(go->guiobject_getCfgString());
  2301. return MAKE_SCRIPT_STRING(L"");
  2302. }
  2303. scriptVar GuiObject_ScriptMethods::cfgSetString(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v) {
  2304. SCRIPT_FUNCTION_INIT
  2305. GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
  2306. if (go) go->guiobject_setCfgString(GET_SCRIPT_STRING(v));
  2307. RETURN_SCRIPT_VOID;
  2308. }
  2309. scriptVar GuiObject_ScriptMethods::cfgGetFloat(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  2310. SCRIPT_FUNCTION_INIT
  2311. GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
  2312. if (go) return MAKE_SCRIPT_FLOAT(go->guiobject_getCfgFloat());
  2313. return MAKE_SCRIPT_FLOAT(0);
  2314. }
  2315. scriptVar GuiObject_ScriptMethods::cfgSetFloat(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v) {
  2316. SCRIPT_FUNCTION_INIT
  2317. GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
  2318. if (go) go->guiobject_setCfgFloat(GET_SCRIPT_FLOAT(v));
  2319. RETURN_SCRIPT_VOID;
  2320. }
  2321. scriptVar GuiObject_ScriptMethods::cfgGetGuid(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  2322. SCRIPT_FUNCTION_INIT
  2323. GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
  2324. if (go) {
  2325. CfgItem *i = go->guiobject_getCfgItem();
  2326. if (i != NULL)
  2327. {
  2328. GUID guid = i->getGuid();
  2329. nsGUID::toCharW(guid, txt);
  2330. return MAKE_SCRIPT_STRING(txt);
  2331. }
  2332. }
  2333. return MAKE_SCRIPT_STRING(L"");
  2334. }
  2335. scriptVar GuiObject_ScriptMethods::cfgGetAttributeName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  2336. SCRIPT_FUNCTION_INIT
  2337. GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
  2338. if (go)
  2339. return MAKE_SCRIPT_STRING(go->guiobject_getCfgAttrib());
  2340. return MAKE_SCRIPT_STRING(L"");
  2341. }
  2342. #endif
  2343. scriptVar GuiObject_ScriptMethods::isMouseOverRect(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  2344. SCRIPT_FUNCTION_INIT
  2345. GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
  2346. int r = 0;
  2347. if (go) {
  2348. ifc_window *w = go->guiobject_getRootWnd();
  2349. if (w != NULL) {
  2350. RECT rc;
  2351. int x, y;
  2352. w->getWindowRect(&rc);
  2353. Wasabi::Std::getMousePos(&x, &y);
  2354. if (x >= rc.left && x <= rc.right && y >= rc.top && y <= rc.bottom) r = 1;
  2355. }
  2356. }
  2357. return MAKE_SCRIPT_BOOLEAN(r);
  2358. }
  2359. #ifdef WASABI_COMPILE_CONFIG
  2360. scriptVar GuiObject_ScriptMethods::onCfgChanged(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  2361. SCRIPT_FUNCTION_INIT;
  2362. PROCESS_HOOKS0(o, guiController);
  2363. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2364. SCRIPT_EXEC_EVENT0(o);
  2365. }
  2366. #endif
  2367. scriptVar GuiObject_ScriptMethods::onChar(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar c) {
  2368. SCRIPT_FUNCTION_INIT;
  2369. PROCESS_HOOKS1(o, guiController, c);
  2370. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2371. SCRIPT_EXEC_EVENT1(o, c);
  2372. }
  2373. scriptVar GuiObject_ScriptMethods::onKeyDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar c) {
  2374. SCRIPT_FUNCTION_INIT;
  2375. PROCESS_HOOKS1(o, guiController, c);
  2376. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2377. SCRIPT_EXEC_EVENT1(o, c);
  2378. }
  2379. scriptVar GuiObject_ScriptMethods::onKeyUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar c) {
  2380. SCRIPT_FUNCTION_INIT;
  2381. PROCESS_HOOKS1(o, guiController, c);
  2382. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2383. SCRIPT_EXEC_EVENT1(o, c);
  2384. }
  2385. scriptVar GuiObject_ScriptMethods::onGetFocus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  2386. SCRIPT_FUNCTION_INIT;
  2387. PROCESS_HOOKS0(o, guiController);
  2388. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2389. SCRIPT_EXEC_EVENT0(o);
  2390. }
  2391. scriptVar GuiObject_ScriptMethods::onKillFocus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  2392. SCRIPT_FUNCTION_INIT;
  2393. PROCESS_HOOKS0(o, guiController);
  2394. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2395. SCRIPT_EXEC_EVENT0(o);
  2396. }
  2397. scriptVar GuiObject_ScriptMethods::sendAction(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar action, scriptVar param, scriptVar x, scriptVar y, scriptVar p1, scriptVar p2) {
  2398. SCRIPT_FUNCTION_INIT
  2399. GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
  2400. int a = 0;
  2401. if (go) {
  2402. ifc_window *w = go->guiobject_getRootWnd();
  2403. if (w!=NULL) {
  2404. a = w->onAction(GET_SCRIPT_STRING(action), GET_SCRIPT_STRING(param), GET_SCRIPT_INT(x), GET_SCRIPT_INT(y), GET_SCRIPT_INT(p1), GET_SCRIPT_INT(p2));
  2405. }
  2406. }
  2407. return MAKE_SCRIPT_INT(a);
  2408. }
  2409. scriptVar GuiObject_ScriptMethods::onAccelerator(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar accel) {
  2410. SCRIPT_FUNCTION_INIT;
  2411. PROCESS_HOOKS1(o, guiController, accel);
  2412. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2413. SCRIPT_EXEC_EVENT1(o, accel);
  2414. }
  2415. scriptVar GuiObject_ScriptMethods::onAction(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar action, scriptVar param, scriptVar x, scriptVar y, scriptVar p1, scriptVar p2, scriptVar source) {
  2416. SCRIPT_FUNCTION_INIT;
  2417. PROCESS_HOOKS7(o, guiController, action, param, x, y, p1, p2, source);
  2418. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2419. SCRIPT_EXEC_EVENT7(o, action, param, x, y, p1, p2, source);
  2420. }
  2421. #ifdef WASABI_COMPILE_CONFIG
  2422. int GuiObjectI::guiobject_getCfgInt()
  2423. {
  2424. if (!cfgitem)
  2425. return 0;
  2426. return
  2427. cfgitem->getDataAsInt(cfgattrname);
  2428. }
  2429. void GuiObjectI::guiobject_setCfgInt(int i) {
  2430. if (!cfgitem) return;
  2431. cfgitem->setDataAsInt(cfgattrname, i);
  2432. }
  2433. float GuiObjectI::guiobject_getCfgFloat() {
  2434. if (!cfgitem) return 0;
  2435. return (float)cfgitem->getDataAsFloat(cfgattrname);
  2436. }
  2437. void GuiObjectI::guiobject_setCfgFloat(float f) {
  2438. if (!cfgitem) return;
  2439. cfgitem->setDataAsFloat(cfgattrname, f);
  2440. }
  2441. const wchar_t *GuiObjectI::guiobject_getCfgString()
  2442. {
  2443. static StringW blah;
  2444. if (!cfgitem) return 0;
  2445. cfgitem->getData(cfgattrname, txt, 4096);
  2446. return txt;
  2447. }
  2448. void GuiObjectI::guiobject_setCfgString(const wchar_t *s)
  2449. {
  2450. if (!cfgitem)
  2451. return;
  2452. cfgitem->setData(cfgattrname, s);
  2453. }
  2454. void GuiObjectI::setCfgAttr(const wchar_t *strvalue)
  2455. {
  2456. ParamParser pp(strvalue);
  2457. if (pp.getNumItems() < 2) return;
  2458. GUID g = nsGUID::fromCharW(pp.enumItem(0));
  2459. if (g == INVALID_GUID) return;
  2460. CfgItem *i = WASABI_API_CONFIG->config_getCfgItemByGuid(g);
  2461. if (i == NULL) return;
  2462. cfgattrname = pp.enumItem(1);
  2463. guiobject_setCfgAttrib(i, cfgattrname);
  2464. }
  2465. int GuiObjectI::guiobject_hasCfgAttrib() {
  2466. return (guiobject_getCfgItem() && guiobject_getCfgAttrib());
  2467. }
  2468. #endif
  2469. GuiObject *GuiObjectI::guiobject_findObject(const wchar_t *id)
  2470. {
  2471. ifc_window *me = guiobject_getRootWnd();
  2472. ifc_window *w = me->findWindow(id);
  2473. if (w != NULL) return w->getGuiObject();
  2474. return NULL;
  2475. }
  2476. GuiObject *GuiObjectI::guiobject_findObjectXY(int x, int y) {
  2477. ifc_window *me = guiobject_getRootWnd();
  2478. POINT pt={x,y};
  2479. me->clientToScreen((int *)&pt.x, (int *)&pt.y);
  2480. ifc_window *w = WASABI_API_WND->rootWndFromPoint(&pt);
  2481. if (w != NULL) return w->getGuiObject();
  2482. return NULL;
  2483. }
  2484. GuiObject *GuiObjectI::guiobject_findObjectByInterface(GUID interface_guid) {
  2485. ifc_window *me = guiobject_getRootWnd();
  2486. ifc_window *w = me->findWindowByInterface(interface_guid);
  2487. if (w != NULL) return w->getGuiObject();
  2488. return NULL;
  2489. }
  2490. GuiObject *GuiObjectI::guiobject_findObjectByCallback(FindObjectCallback *cb) {
  2491. ifc_window *me = guiobject_getRootWnd();
  2492. ifc_window *w = me->findWindowByCallback(cb);
  2493. if (w != NULL) return w->getGuiObject();
  2494. return NULL;
  2495. }
  2496. void GuiObjectI::guiobject_onAccelerator(const wchar_t *accel)
  2497. {
  2498. GuiObject_ScriptMethods::onAccelerator(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_STRING(accel));
  2499. }
  2500. int GuiObjectI::guiobject_onAction(const wchar_t *action, const wchar_t *param, int x, int y, intptr_t p1, intptr_t p2, void *data, size_t datalen, ifc_window *source)
  2501. {
  2502. GuiObject *gsourceobj = (source == NULL) ? NULL : source->getGuiObject();
  2503. ScriptObject *sourceobj = (gsourceobj == NULL) ? NULL : gsourceobj->guiobject_getScriptObject();
  2504. GuiObject_ScriptMethods::onAction(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_STRING(action), MAKE_SCRIPT_STRING(param), MAKE_SCRIPT_INT(x), MAKE_SCRIPT_INT(y), MAKE_SCRIPT_INT(p1), MAKE_SCRIPT_INT(p2), MAKE_SCRIPT_OBJECT(sourceobj));
  2505. return 1;
  2506. }
  2507. void GuiObjectI::guiobject_setTabOrder(int a) {
  2508. ifc_window *me = guiobject_getRootWnd();
  2509. me->setTabOrder(a);
  2510. }
  2511. void GuiObjectI::guiobject_onInit() {
  2512. // api_window *me = guiobject_getRootWnd();
  2513. // nothing to do here anymore, for now
  2514. return;
  2515. }
  2516. int GuiObjectI::guiobject_wantFocus() {
  2517. return wantfocus;
  2518. }
  2519. void GuiObjectI::guiobject_setNoDoubleClick(int no) {
  2520. ifc_window *w = guiobject_getRootWnd();
  2521. if (w != NULL)
  2522. w->setNoDoubleClicks(no);
  2523. }
  2524. void GuiObjectI::guiobject_setNoLeftClick(int no) {
  2525. ifc_window *w = guiobject_getRootWnd();
  2526. if (w != NULL)
  2527. w->setNoLeftClicks(no);
  2528. }
  2529. void GuiObjectI::guiobject_setNoRightClick(int no) {
  2530. ifc_window *w = guiobject_getRootWnd();
  2531. if (w != NULL)
  2532. w->setNoRightClicks(no);
  2533. }
  2534. void GuiObjectI::guiobject_setNoMouseMove(int no) {
  2535. ifc_window *w = guiobject_getRootWnd();
  2536. if (w != NULL)
  2537. w->setNoMouseMoves(no);
  2538. }
  2539. void GuiObjectI::guiobject_setNoContextMenu(int no) {
  2540. ifc_window *w = guiobject_getRootWnd();
  2541. if (w != NULL)
  2542. w->setNoContextMenus(no);
  2543. }
  2544. scriptVar GuiObject_ScriptMethods::getInterface(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar guid) {
  2545. SCRIPT_FUNCTION_INIT;
  2546. int type=-1;
  2547. GUID _g = nsGUID::fromCharW(GET_SCRIPT_STRING(guid));
  2548. void *i = o->vcpu_getInterface(_g, &type);
  2549. if (i != NULL && type == INTERFACE_SCRIPTOBJECT) {
  2550. return MAKE_SCRIPT_OBJECT(reinterpret_cast<ScriptObject*>(i));
  2551. }
  2552. RETURN_SCRIPT_VOID;
  2553. }
  2554. scriptVar GuiObject_ScriptMethods::onDragEnter(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2555. {
  2556. SCRIPT_FUNCTION_INIT;
  2557. PROCESS_HOOKS0(o, guiController);
  2558. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2559. SCRIPT_EXEC_EVENT0(o);
  2560. }
  2561. scriptVar GuiObject_ScriptMethods::onDragOver(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y)
  2562. {
  2563. SCRIPT_FUNCTION_INIT;
  2564. PROCESS_HOOKS2(o, guiController, x, y);
  2565. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2566. SCRIPT_EXEC_EVENT2(o, x, y);
  2567. }
  2568. scriptVar GuiObject_ScriptMethods::onDragLeave(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2569. {
  2570. SCRIPT_FUNCTION_INIT;
  2571. PROCESS_HOOKS0(o, guiController);
  2572. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2573. SCRIPT_EXEC_EVENT0(o);
  2574. }