123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880 |
- #include <precomp.h>
- #include <bfc/wasabi_std.h>
- #include <api/wnd/notifmsg.h>
- #include <api/script/scriptmgr.h>
- #include <api/script/script.h>
- #include <api/script/objects/guiobj.h>
- #include <api/script/vcpu.h>
- #include <api/skin/widgets/group.h>
- //#include <api/wac/main.h>
- #include <math.h>
- #include <api/skin/skinparse.h>
- #include <api/wndmgr/layout.h>
- #include <api/script/objecttable.h>
- #include <api/wnd/cwndtrack.h>
- #include <api/wnd/popup.h>
- #include <bfc/parse/paramparser.h>
- #include <api/wnd/cursor.h>
- #include <api/wnd/wndtrack.h>
- #include <bfc/string/stringdict.h>
- #include <api/config/items/cfgitem.h>
- #include <api/config/items/attrbool.h>
- #ifndef PI
- #define PI 3.1415926536F
- #endif
- #include <api/script/objects/guiobject.h>
- const wchar_t guiobjectXuiStr[] = L"GuiObject"; // This is the xml tag
- char guiobjectXuiSvcName[] = "GuiObject xui object"; // this is the name of the xuiservice
- #ifdef USEAPPBAR
- extern _bool cfg_options_appbarondrag;
- #endif
- static wchar_t txt[4096];
- GuiObjectI::GuiObjectI(ScriptObject *o) {
- translate = 1;
- my_script_object = o;
- my_root_wnd = NULL;
- redock.l = NULL;
- MEMSET(&redock.original_rect, 0, sizeof(RECT));
- targetstatus = TARGET_FROZEN;
- targetspeed = 4;
- start_time = 0;
- reversetarget = 0;
- dodragcheck = 0;
- gui_rx = 0;
- gui_ry = 0;
- gui_rw = 0;
- gui_rh = 0;
- gui_x = 0;
- gui_y = 0;
- gui_w = AUTOWH;
- gui_h = AUTOWH;
- p_group = NULL;
- targetx = AUTOWH;
- targety = AUTOWH;
- targetw = AUTOWH;
- targeth = AUTOWH;
- targeta = AUTOWH;
- in_area = 0;
- clickthrough = 0;
- autosysmetricsx = 0;
- autosysmetricsy = 0;
- autosysmetricsw = 0;
- autosysmetricsh = 0;
- xuisvc = NULL;
- xuifac = NULL;
- mover = 0;
- moving = 0;
- droptarget = 0;
- #ifdef WASABI_COMPILE_CONFIG
- cfgitem = NULL;
- #endif
- timer.setGuiObjectI(this);
- wantfocus = 0;
- anchorage = ANCHOR_NONE;
- anchor_x1 = anchor_x2 = anchor_y1 = anchor_y2 = 0;
- anchorage_invalidated = 0;
- anchorage = ANCHOR_LEFT|ANCHOR_TOP;
- cursor = NULL;
- #ifdef USEAPPBAR
- m_dock_side = APPBAR_NOTDOCKED;
- #endif
- m_lastnondocked_x = -0xFFFF;
- m_lastnondocked_y = -0xFFFF;
- }
- GuiObjectI::~GuiObjectI() {
- notifylist.deleteAll();
- delete cursor;
- if (guiobject_getParentGroup())
- guiobject_getParentGroup()->removeObject(this);
- if (targetstatus == TARGET_RUNNING)
- stopTargetTimer();
- #ifdef WASABI_COMPILE_CONFIG
- if (cfgitem) viewer_delViewItem(cfgitem);
- #endif
- }
- ScriptObject *GuiObjectI::guiobject_getScriptObject()
- {
- return my_script_object;
- }
- // Used by us when parsing xml to assign the object's ID, shouldn't be used elsewhere
- void GuiObjectI::guiobject_setId(const wchar_t *id)
- {
- guiobject_id = id;
- }
- const wchar_t *GuiObjectI::guiobject_getId()
- {
- if (guiobject_id.isempty()) return L"";
- return guiobject_id; //FG> avoid returning NULL
- }
- int GuiObjectI::guiobject_setXmlParam(const wchar_t *paramname, const wchar_t *strvalue)
- {
- int r = 0;
- //ifc_window *w = guiobject_getRootWnd();
- XmlObject *xo = static_cast<XmlObject *>(guiobject_getScriptObject()->vcpu_getInterface(xmlObjectGuid));
- if (xo != NULL) {
- r = xo->setXmlParam(paramname, strvalue);
- }
- return r;
- }
- const wchar_t *GuiObjectI::guiobject_getXmlParam(const wchar_t *paramname) {
- const wchar_t *rt = NULL;
- //ifc_window *w = guiobject_getRootWnd();
- XmlObject *xo = static_cast<XmlObject *>(guiobject_getScriptObject()->vcpu_getInterface(xmlObjectGuid));
- if (xo != NULL) {
- int r = xo->getXmlParam(paramname);
- rt = xo->getXmlParamValue(r);
- }
- return rt;
- }
- int GuiObjectI::guiobject_setXmlParamById(int id, const wchar_t *strvalue)
- {
- int a;
- switch (id) {
- case GuiObjectWnd::GUIOBJECT_ID:
- guiobject_setId(strvalue);
- break;
- case GuiObjectWnd::GUIOBJECT_ALPHA:
- if (wcschr(strvalue, ',')) // erroneous value, this is probably a color, or something
- guiobject_setAlpha(255);
- else
- guiobject_setAlpha(WTOI(strvalue));
- break;
- case GuiObjectWnd::GUIOBJECT_ACTIVEALPHA:
- if (wcschr(strvalue, ',')) // erroneous value, this is probably a color, or something
- guiobject_setActiveAlpha(255);
- else
- guiobject_setActiveAlpha(WTOI(strvalue));
- break;
- case GuiObjectWnd::GUIOBJECT_INACTIVEALPHA:
- if (wcschr(strvalue, ',')) // erroneous value, this is probably a color, or something
- guiobject_setInactiveAlpha(255);
- else
- guiobject_setInactiveAlpha(WTOI(strvalue));
- break;
- case GuiObjectWnd::GUIOBJECT_SYSREGION:
- guiobject_setRegionOp(WASABI_API_SKIN->parse(strvalue, L"regionop"));
- break;
- case GuiObjectWnd::GUIOBJECT_RECTRGN:
- guiobject_setRectRgn(WTOI(strvalue));
- break;
- case GuiObjectWnd::GUIOBJECT_TOOLTIP:
- guiobject_getRootWnd()->setTip(strvalue);
- break;
- case GuiObjectWnd::GUIOBJECT_SYSMETRICSX:
- guiobject_setAutoSysMetricsX(WTOI(strvalue));
- break;
- case GuiObjectWnd::GUIOBJECT_SYSMETRICSY:
- guiobject_setAutoSysMetricsY(WTOI(strvalue));
- break;
- case GuiObjectWnd::GUIOBJECT_SYSMETRICSW:
- guiobject_setAutoSysMetricsW(WTOI(strvalue));
- break;
- case GuiObjectWnd::GUIOBJECT_SYSMETRICSH:
- guiobject_setAutoSysMetricsH(WTOI(strvalue));
- break;
- case GuiObjectWnd::GUIOBJECT_MOVE:
- guiobject_setMover(WTOI(strvalue));
- break;
- case GuiObjectWnd::GUIOBJECT_RENDERBASETEXTURE:
- guiobject_getRootWnd()->setRenderBaseTexture(WTOI(strvalue));
- break;
- #ifdef WASABI_COMPILE_CONFIG
- case GuiObjectWnd::GUIOBJECT_CFGATTR:
- setCfgAttr(strvalue);
- break;
- #endif
- case GuiObjectWnd::GUIOBJECT_TABORDER:
- guiobject_setTabOrder(WTOI(strvalue));
- break;
- case GuiObjectWnd::GUIOBJECT_X: {
- a = WTOI(strvalue);
- guiobject_setGuiPosition(&a, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
- Group *g = guiobject_getParentGroup();
- if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
- g->updatePos(this);
- break; }
- case GuiObjectWnd::GUIOBJECT_Y: {
- a = WTOI(strvalue);
- guiobject_setGuiPosition(NULL, &a, NULL, NULL, NULL, NULL, NULL, NULL);
- Group *g = guiobject_getParentGroup();
- if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
- g->updatePos(this);
- break; }
- case GuiObjectWnd::GUIOBJECT_W: {
- a = WTOI(strvalue);
- guiobject_setGuiPosition(NULL, NULL, &a, NULL, NULL, NULL, NULL, NULL);
- Group *g = guiobject_getParentGroup();
- if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
- g->updatePos(this);
- break; }
- case GuiObjectWnd::GUIOBJECT_H: {
- a = WTOI(strvalue);
- guiobject_setGuiPosition(NULL, NULL, NULL, &a, NULL, NULL, NULL, NULL);
- Group *g = guiobject_getParentGroup();
- if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
- g->updatePos(this);
- break; }
- case GuiObjectWnd::GUIOBJECT_FITTOPARENT: {
- int v = WTOI(strvalue);
- if (v) {
- int one = 1;
- int x = 0, y = 0, w = 0, h = 0;
- if (v < 0) {
- v = -v;
- x += v;
- y += v;
- w -= v * 2;
- h -= v * 2;
- }
- guiobject_setGuiPosition(&x, &y, &w, &h, NULL, NULL, &one, &one);
- Group *g = guiobject_getParentGroup();
- if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
- g->updatePos(this);
- }
- break; }
- case GuiObjectWnd::GUIOBJECT_WANTFOCUS:
- wantfocus = WTOI(strvalue);
- if (guiobject_getRootWnd()->isPostOnInit()) {
- if (wantfocus) {
- if (guiobject_getRootWnd()->getTabOrder() == -1)
- guiobject_getRootWnd()->setAutoTabOrder();
- } else {
- if (guiobject_getRootWnd()->getTabOrder() != -1)
- guiobject_getRootWnd()->setTabOrder(-1);
- }
- }
- break;
- case GuiObjectWnd::GUIOBJECT_VISIBLE: {
- a = WTOI(strvalue);
- ifc_window *w = guiobject_getRootWnd();
- if (w->isPostOnInit())
- w->setVisible(a);
- else
- w->setStartHidden(!a);
- break; }
- case GuiObjectWnd::GUIOBJECT_RELATX: {
- if (strvalue && *strvalue == '%')
- a = 2;
- else
- a = WTOI(strvalue);
- guiobject_setGuiPosition(NULL, NULL, NULL, NULL, &a, NULL, NULL, NULL);
- Group *g = guiobject_getParentGroup();
- if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
- g->updatePos(this);
- break; }
- case GuiObjectWnd::GUIOBJECT_RELATY: {
- if (strvalue && *strvalue == '%')
- a = 2;
- else
- a = WTOI(strvalue);
- guiobject_setGuiPosition(NULL, NULL, NULL, NULL, NULL, &a, NULL, NULL);
- Group *g = guiobject_getParentGroup();
- if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
- g->updatePos(this);
- break; }
- case GuiObjectWnd::GUIOBJECT_RELATW: {
- if (strvalue && *strvalue == '%')
- a = 2;
- else
- a = WTOI(strvalue);
- guiobject_setGuiPosition(NULL, NULL, NULL, NULL, NULL, NULL, &a, NULL);
- Group *g = guiobject_getParentGroup();
- if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
- g->updatePos(this);
- break; }
- case GuiObjectWnd::GUIOBJECT_RELATH: {
- if (strvalue && *strvalue == '%')
- a = 2;
- else
- a = WTOI(strvalue);
- guiobject_setGuiPosition(NULL, NULL, NULL, NULL, NULL, NULL, NULL, &a);
- Group *g = guiobject_getParentGroup();
- if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
- g->updatePos(this);
- break; }
- case GuiObjectWnd::GUIOBJECT_DROPTARGET:
- guiobject_setDropTarget(strvalue);
- break;
- case GuiObjectWnd::GUIOBJECT_GHOST:
- guiobject_setClickThrough(WTOI(strvalue));
- break;
- case GuiObjectWnd::GUIOBJECT_SETNODBLCLICK:
- guiobject_setNoDoubleClick(WTOI(strvalue));
- break;
- case GuiObjectWnd::GUIOBJECT_SETNOLEFTCLICK:
- guiobject_setNoLeftClick(WTOI(strvalue));
- break;
- case GuiObjectWnd::GUIOBJECT_SETNORIGHTCLICK:
- guiobject_setNoRightClick(WTOI(strvalue));
- break;
- case GuiObjectWnd::GUIOBJECT_SETNOMOUSEMOVE:
- guiobject_setNoMouseMove(WTOI(strvalue));
- break;
- case GuiObjectWnd::GUIOBJECT_SETNOCONTEXTMENU:
- guiobject_setNoContextMenu(WTOI(strvalue));
- break;
- case GuiObjectWnd::GUIOBJECT_SETX1: {
- a = WTOI(strvalue);
- guiobject_setAnchoragePosition(&a, NULL, NULL, NULL, NULL);
- Group *g = guiobject_getParentGroup();
- if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
- g->updatePos(this);
- break;
- }
- case GuiObjectWnd::GUIOBJECT_SETY1:{
- a = WTOI(strvalue);
- guiobject_setAnchoragePosition(NULL, &a, NULL, NULL, NULL);
- Group *g = guiobject_getParentGroup();
- if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
- g->updatePos(this);
- break;
- }
- case GuiObjectWnd::GUIOBJECT_SETX2:{
- a = WTOI(strvalue);
- guiobject_setAnchoragePosition(NULL, NULL, &a, NULL, NULL);
- Group *g = guiobject_getParentGroup();
- if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
- g->updatePos(this);
- break;
- }
- case GuiObjectWnd::GUIOBJECT_SETY2:{
- a = WTOI(strvalue);
- guiobject_setAnchoragePosition(NULL, NULL, NULL, &a, NULL);
- Group *g = guiobject_getParentGroup();
- if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
- g->updatePos(this);
- break;
- }
- case GuiObjectWnd::GUIOBJECT_SETANCHOR: {
- int anchorage=ANCHOR_NONE;
- ParamParser pp(strvalue, L"|");
- for (int m=0;m<pp.getNumItems();m++)
- {
- const wchar_t *s = pp.enumItem(m);
- if (!WCSICMP(s, L"left")) anchorage |= ANCHOR_LEFT;
- else if (!WCSICMP(s, L"top")) anchorage |= ANCHOR_TOP;
- else if (!WCSICMP(s, L"right")) anchorage |= ANCHOR_RIGHT;
- else if (!WCSICMP(s, L"bottom")) anchorage |= ANCHOR_BOTTOM;
- }
- guiobject_setAnchoragePosition(NULL, NULL, NULL, NULL, &anchorage);
- Group *g = guiobject_getParentGroup();
- if (g != NULL && guiobject_getRootWnd()->isPostOnInit())
- g->updatePos(this);
- }
- break;
- case GuiObjectWnd::GUIOBJECT_SETCURSOR:
- guiobject_setCursor(strvalue);
- break;
- case GuiObjectWnd::GUIOBJECT_NOTIFY:
- notifylist.addItem(new StringW(strvalue));
- break;
- case GuiObjectWnd::GUIOBJECT_USERDATA:
- // nothing to do, param goes in xmlobject
- break;
- #ifdef USEAPPBAR
- case GuiObjectWnd::GUIOBJECT_APPBAR:
- setAppBar(strvalue);
- break;
- #endif
- case GuiObjectWnd::GUIOBJECT_TRANSLATE:
- translate = WTOI(strvalue);
- break;
- default:
- return 0;
- }
- return 1;
- }
- void GuiObjectI::guiobject_getGuiPosition(int *x, int *y, int *w, int *h, int *rx, int *ry, int *rw, int *rh) {
- if (x) *x = gui_x;
- if (y) *y = gui_y;
- if (w) *w = gui_w;
- if (h) *h = gui_h;
- if (rx) *rx = gui_rx;
- if (ry) *ry = gui_ry;
- if (rw) *rw = gui_rw;
- if (rh) *rh = gui_rh;
- }
- void GuiObjectI::guiobject_setGuiPosition(int *x, int *y, int *w, int *h, int *rx, int *ry, int *rw, int *rh) {
- if (x && *x != NOCHANGE && *x != AUTOWH) gui_x = *x;
- if (y && *y != NOCHANGE && *y != AUTOWH) gui_y = *y;
- if (w && *w != NOCHANGE && *w != AUTOWH) gui_w = *w;
- if (h && *h != NOCHANGE && *h != AUTOWH) gui_h = *h;
- if (rx && *rx != NOCHANGE && *rx != AUTOWH) gui_rx = *rx;
- if (ry && *ry != NOCHANGE && *ry != AUTOWH) gui_ry = *ry;
- if (rw && *rw != NOCHANGE && *rw != AUTOWH) gui_rw = *rw;
- if (rh && *rh != NOCHANGE && *rh != AUTOWH) gui_rh = *rh;
- if (guiobject_getRootWnd()->isInited() && guiobject_getParentGroup())
- guiobject_getParentGroup()->updatePos(this);
- else {
- if (!guiobject_getRootWnd()->isVirtual())
- guiobject_getRootWnd()->resize(gui_x, gui_y, gui_w, gui_h);
- }
- }
- int GuiObjectI::guiobject_getAnchoragePosition(int *x1, int *y1, int *x2, int *y2, int *anchor) {
- if (x1) *x1 = anchor_x1;
- if (y1) *y1 = anchor_y1;
- if (x2) *x2 = anchor_x2;
- if (y2) *y2 = anchor_y2;
- if (anchor) *anchor = anchorage;
- return anchorage_invalidated;
- }
- void GuiObjectI::guiobject_setAnchoragePosition(int *x1, int *y1, int *x2, int *y2, int *anchor) {
- anchorage_invalidated = 1;
- if (x1) anchor_x1 = *x1;
- if (x2) anchor_x2 = *x2;
- if (y1) anchor_y1 = *y1;
- if (y2) anchor_y2 = *y2;
- if (anchor) anchorage = *anchor;
- if (guiobject_getRootWnd()->isInited() && guiobject_getParentGroup()) {
- guiobject_getParentGroup()->updatePos(this);
- }
- }
- void GuiObjectI::guiobject_validateAnchorage() {
- anchorage_invalidated = 0;
- }
- void GuiObjectI::guiobject_setClickThrough(int c) {
- guiobject_getRootWnd()->setClickThrough(c);
- }
- void GuiObjectI::guiobject_setRegionOp(int op) {
- guiobject_getRootWnd()->setRegionOp(op);
- }
- int GuiObjectI::guiobject_getRegionOp() {
- return guiobject_getRootWnd()->getRegionOp();
- }
- void GuiObjectI::guiobject_setRectRgn(int rrgn) {
- guiobject_getRootWnd()->setRectRgn(rrgn);
- }
- void GuiObjectI::guiobject_setMover(int n) {
- mover = n;
- }
- int GuiObjectI::guiobject_getMover() {
- return mover;
- }
- FOURCC GuiObjectI::guiobject_getDropTarget() {
- return droptarget;
- }
- void GuiObjectI::guiobject_setDropTarget(const wchar_t *strval)
- {
- if (strval == NULL)
- droptarget = 0;
- else
- {
- uint8_t *temp = (uint8_t *)&droptarget;
- temp[3]=(uint8_t)strval[0];
- temp[2]=(uint8_t)strval[1];
- temp[1]=(uint8_t)strval[2];
- temp[0]=(uint8_t)strval[3];
- }
- }
- int GuiObjectI::guiobject_isRectRgn() {
- return guiobject_getRootWnd()->isRectRgn();
- }
- int GuiObjectI::guiobject_isClickThrough() {
- return guiobject_getRootWnd()->isClickThrough();
- }
- void GuiObjectI::guiobject_setParentGroup(Group *l) {
- if (!l) { p_group = NULL; return; }
- p_group = l;
- }
- Group *GuiObjectI::guiobject_getParentGroup() {
- if (!p_group) return NULL;
- return p_group;
- }
- GuiObject *GuiObjectI::guiobject_getParent() {
- ifc_window *grw = guiobject_getRootWnd();
- if (!grw) return NULL;
- ifc_window *w = grw->getParent();
- if (!w) return NULL;
- return static_cast<GuiObject *>(w->getInterface(guiObjectGuid));
- }
- #ifdef WASABI_COMPILE_WNDMGR
- Layout *GuiObjectI::guiobject_getParentLayout() {
- Group *m = p_group;
- Layout *l = NULL;
- while (m) {
- if (m->isLayout()) {
- l = static_cast<Layout *>(m);
- break;
- }
- m = m->getGuiObject()->guiobject_getParentGroup();
- }
- if (!l) {
- ifc_window *w = guiobject_getRootWnd()->getDesktopParent();
- if (w)
- l = static_cast<Layout *>(w->getInterface(layoutGuid));
- }
- if (l && l->isDeleting()) return NULL;
- return l;
- }
- #endif
- GuiObject *GuiObjectI::guiobject_getTopParent() {
- ifc_window *m = guiobject_getRootWnd();
- GuiObject *top = this;
- while (m != NULL) {
- m = m->getParent();
- if (m != NULL) {
- GuiObject *g = m->getGuiObject();
- if (g != NULL)
- top = g;
- }
- }
- return top;
- }
- /*void GuiObjectI::parseNotify(const char *s) {
- scriptNotify(s, "", 0, 0);
- }*/
- void GuiObjectI::guiobject_bringToFront() {
- ifc_window *b = guiobject_getRootWnd();
- if (b) {
- if (b->getParent())
- b->getParent()->bringVirtualToFront(b);
- }
- }
- void GuiObjectI::guiobject_bringToBack() {
- ifc_window *b = guiobject_getRootWnd();
- if (b) {
- if (b->getParent())
- b->getParent()->bringVirtualToBack(b);
- }
- }
- void GuiObjectI::guiobject_bringAbove(GuiObject *o) {
- ASSERT(o != NULL);
- ifc_window *b = guiobject_getRootWnd();
- ifc_window *c = o->guiobject_getRootWnd();
- if (b && c) {
- if (b->getParent())
- b->getParent()->bringVirtualAbove(b, c);
- }
- }
- void GuiObjectI::guiobject_bringBelow(GuiObject *o) {
- ASSERT(o != NULL);
- ifc_window *b = guiobject_getRootWnd();
- ifc_window *c = o->guiobject_getRootWnd();
- if (b && c) {
- if (b->getParent())
- b->getParent()->bringVirtualBelow(b, c);
- }
- }
- void GuiObjectI::guiobject_setTargetSpeed(float s) { // s == n of seconds
- if (targetspeed == (int)(s * 4.0)) return;
- targetspeed = (int)(s * 4.0); // units of 250ms
- if (targetstatus == TARGET_RUNNING) {
- stopTargetTimer();
- startTargetTimer();
- }
- }
- void GuiObjectTimer::timerclient_timerCallback(int id) {
- if (id == TARGETTIMER_ID && obj)
- obj->onTargetTimer();
- }
- void GuiObjectI::guiobject_setTargetX(int x) {
- targetx = x;
- }
- void GuiObjectI::guiobject_setTargetY(int y) {
- targety = y;
- }
- void GuiObjectI::guiobject_setTargetW(int w) {
- targetw = w;
- }
- void GuiObjectI::guiobject_setTargetH(int h) {
- targeth = h;
- }
- void GuiObjectI::guiobject_setTargetA(int a) {
- targeta = a;
- }
- void GuiObjectI::guiobject_gotoTarget() {
- if (!guiobject_getRootWnd()) return;
- start_time=0;
- guiobject_getGuiPosition(&startx, &starty, &startw, &starth, NULL, NULL, NULL, NULL);
- starta = guiobject_getAlpha();
- if (targetx == AUTOWH || targetx == NOCHANGE)
- targetx = startx;
- if (targety == AUTOWH || targety == NOCHANGE)
- targety = starty;
- if (targetw == AUTOWH || targetw == NOCHANGE)
- targetw = startw;
- if (targeth == AUTOWH || targeth == NOCHANGE)
- targeth = starth;
- if (targeta == AUTOWH || targeta == NOCHANGE)
- targeta = starta;
- startTargetTimer();
- Layout *l = static_cast<Layout *>(guiobject_getScriptObject()->vcpu_getInterface(layoutGuid));
- if (targetx != startx ||
- targety != starty ||
- targetw != startw ||
- targeth != starth) {
- if (l) windowTracker->beforeRedock(l, &redock);
- }
- }
- void GuiObjectI::startTargetTimer() {
- timer.timerclient_setTimer(TARGETTIMER_ID, 20);
- targetstatus = TARGET_RUNNING;
- }
- void GuiObjectI::stopTargetTimer() {
- timer.timerclient_killTimer(TARGETTIMER_ID);
- targetstatus = TARGET_FROZEN;
- }
- void GuiObjectI::onTargetTimer() {
- if (targetstatus != TARGET_RUNNING) return;
- if (!guiobject_getRootWnd()) return;
- RECT r;
- guiobject_getRootWnd()->getClientRect(&r);
- RECT wr;
- guiobject_getRootWnd()->getWindowRect(&wr);
- int ttime=250*targetspeed;
- if (ttime < 0) ttime = 0;
- int n;
- if (!start_time)
- {
- n=0;
- start_time = Wasabi::Std::getTickCount();
- }
- else
- {
- n=MulDiv(Wasabi::Std::getTickCount()-start_time,256,ttime);
- }
- if (ttime == 0) n = 255;
- if (n >= 255) n=255;
- float sintrans = (float)(sin(((float)n/255)*PI-PI/2)/2+0.5); // used for smoothing transitions
- float nw = ((float)(targetw - startw) * sintrans) + startw;
- float nh = ((float)(targeth - starth) * sintrans) + starth;
- float na = ((float)(targeta - starta) * sintrans) + starta;
- Layout *l = static_cast<Layout *>(guiobject_getScriptObject()->vcpu_getInterface(layoutGuid));
- int islayout = l != NULL && static_cast<ifc_window*>(l) == guiobject_getRootWnd();
- float rat = 1.0f;
- if (islayout) rat = (float)l->getRenderRatio();
- float nx;
- float ny;
- if (!reversetarget) {
- nx = ((float)(targetx - startx) * sintrans) + startx;
- ny = ((float)(targety - starty) * sintrans) + starty;
- } else {
- nx = startx - ((float)(targetw - startw) * sintrans) * rat;
- ny = starty - ((float)(targeth - starth) * sintrans) * rat;
- }
- int zx=(int)nx;
- int zy=(int)ny;
- int zw=(int)nw;
- int zh=(int)nh;
- if (reversetarget) {
- while (zy + zh * rat < wr.bottom) zy++;
- while (zx + zw * rat < wr.right) zx++;
- }
- int oldredraw = -1;
- if (reversetarget && islayout) {
- oldredraw = l->wantRedrawOnResize();
- l->setWantRedrawOnResize(0);
- int paddtop = wr.top - (int)ny;
- int paddleft = wr.left - (int)nx;
- #ifdef _WIN32
- if (paddtop > 0 || paddleft > 0) {
- RegionI r;
- GetWindowRgn(l->gethWnd(), r.getOSHandle());
- r.offset(MAX(0, paddleft), MAX(0, paddtop));
- SetWindowRgn(l->gethWnd(), r.makeWindowRegion(), FALSE);
- }
- #else
- #warning port me
- #endif
- }
- guiobject_setGuiPosition(&zx, &zy, &zw, &zh, NULL, NULL, NULL, NULL);
- guiobject_getRootWnd()->cascadeRepaint(0);
- guiobject_setAlpha((int)na);
- if (n==255) {
- stopTargetTimer();
- guiobject_onTargetReached();
- }
- if (l != NULL) l->savePosition();
- if (oldredraw != -1 && l) {
- l->setWantRedrawOnResize(oldredraw);
- }
- }
- void GuiObjectI::guiobject_cancelTarget() {
- stopTargetTimer();
- Layout *l = static_cast<Layout *>(guiobject_getScriptObject()->vcpu_getInterface(layoutGuid));
- if (l && redock.l) windowTracker->afterRedock(l, &redock);
- }
- void GuiObjectI::guiobject_reverseTarget(int reverse) {
- reversetarget = reverse;
- }
- #ifdef WASABI_COMPILE_WNDMGR
- void GuiObjectI::guiobject_popParentLayout() {
- Layout *l = guiobject_getParentLayout();
- if (l && l->getParentContainer()) {
- SkinParser::showContainer(l->getParentContainer()->getId(), TRUE);
- #ifdef WIN32
- SetForegroundWindow(l->gethWnd());
- #else
- l->bringToFront();
- #endif
- }
- }
- #endif
- int GuiObjectI::guiobject_movingToTarget() {
- return targetstatus == TARGET_RUNNING;
- }
- void GuiObjectI::guiobject_onLeftButtonDown(int x, int y) {
- if (!VCPU::getComplete()) {
- scriptVar _x = SOM::makeVar(SCRIPT_INT);
- SOM::assign(&_x, x);
- scriptVar _y = SOM::makeVar(SCRIPT_INT);
- SOM::assign(&_y, y);
- GuiObject_ScriptMethods::onLeftButtonDown(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y);
- if (mover && !VCPU::getComplete()) {
- #ifdef WASABI_COMPILE_WNDMGR
- Layout *l = guiobject_getParentLayout();
- if (l) {
- // Martin> (9/9/8) added l->getGuiObject()->guiobject_getMover() so setting move="0" to layouts will disable moving it around
- if (!l->isLocked() && l->getGuiObject()->guiobject_getMover()) {
- #ifdef USEAPPBAR
- if (cfg_options_appbarondrag) {
- m_initial_dock_side = m_dock_side = l->appbar_getSide();
- if (m_dock_side != APPBAR_NOTDOCKED) {
- dodragcheck = 1;
- goto skipit;
- }
- }
- #endif
- l->maximize(0);
- skipit:
- l->beginMove();
- if (l->getParentContainer() && l->getParentContainer()->isMainContainer() || Std::keyModifier(STDKEY_ALT))
- WASABI_API_WNDMGR->wndTrackStartCooperative(l);
- moving = 1;
- anchor.x = (int)((float)x * guiobject_getRootWnd()->getRenderRatio());
- anchor.y = (int)((float)y * guiobject_getRootWnd()->getRenderRatio());
- }
- }
- #endif //WASABI_COMPILE_WNDMGR
- }
- }
- }
- void GuiObjectI::guiobject_onLeftButtonUp(int x, int y) {
- scriptVar _x = SOM::makeVar(SCRIPT_INT);
- SOM::assign(&_x, x);
- scriptVar _y = SOM::makeVar(SCRIPT_INT);
- SOM::assign(&_y, y);
- GuiObject_ScriptMethods::onLeftButtonUp(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y);
- if (moving) {
- int sendendmove = 0;
- #ifdef WASABI_COMPILE_WNDMGR
- Group *l = guiobject_getParentLayout();
- if (l) {
- if (WASABI_API_WNDMGR->wndTrackWasCooperative())
- WASABI_API_WNDMGR->wndTrackEndCooperative();
- moving = 0;
- sendendmove = 1;
- }
- #ifdef USEAPPBAR
- if (cfg_options_appbarondrag) {
- if (m_dock_side != m_initial_dock_side) {
- ifc_window *dw = guiobject_getRootWnd()->getDesktopParent();
- if (dw) {
- AppBar *ab = reinterpret_cast<AppBar *>(dw->getInterface(appBarGuid));
- if (ab) {
- if (m_dock_side == APPBAR_NOTDOCKED) ab->appbar_setNoRestore(1);
- ab->appbar_dock(m_dock_side);
- if (m_dock_side == APPBAR_NOTDOCKED) ab->appbar_setNoRestore(0);
- }
- }
- }
- if (m_dock_side == APPBAR_NOTDOCKED) {
- ifc_window *dp = guiobject_getRootWnd()->getDesktopParent();
- if (dp) dp->restore(0);
- }
- } else {
- ifc_window *dp = guiobject_getRootWnd()->getDesktopParent();
- if (dp) dp->restore(0);
- }
- #else
- ifc_window *dp = guiobject_getRootWnd()->getDesktopParent();
- if (dp) dp->restore(0);
- #endif // USEAPPBAR
- if (sendendmove && l) l->endMove();
- #endif //WASABI_COMPILE_WNDMGR
- }
- }
- void GuiObjectI::guiobject_onRightButtonDown(int x, int y) {
- scriptVar _x = SOM::makeVar(SCRIPT_INT);
- SOM::assign(&_x, x);
- scriptVar _y = SOM::makeVar(SCRIPT_INT);
- SOM::assign(&_y, y);
- GuiObject_ScriptMethods::onRightButtonDown(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y);
- }
- #ifdef WASABI_CUSTOM_CONTEXTMENUS
- extern void appContextMenu(ifc_window *wnd);
- extern void appControlMenu(ifc_window *wnd);
- #endif
- void GuiObjectI::guiobject_onRightButtonUp(int x, int y) {
- scriptVar _x = SOM::makeVar(SCRIPT_INT);
- SOM::assign(&_x, x);
- scriptVar _y = SOM::makeVar(SCRIPT_INT);
- SOM::assign(&_y, y);
- GuiObject_ScriptMethods::onRightButtonUp(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y);
- ifc_window *w = guiobject_getRootWnd();
- if (Std::keyModifier(STDKEY_CONTROL) &&
- Std::keyModifier(STDKEY_SHIFT)) {
- GuiObjectI::infoMenu(this, x, y);
- } else {
- if (w && w->wantAutoContextMenu() && !VCPU::getComplete() && WASABI_API_WNDMGR->getModalWnd() == NULL) {
- ifc_window *par = w->getParent();
- if (par && guiobject_getParentLayout()) {
- if (!Std::keyModifier(STDKEY_CONTROL)) {
- #if defined(WA3COMPATIBILITY)
- Main::appContextMenu(par, TRUE, guiobject_getParentLayout()->isTransparencySafe());
- #elif defined(WASABI_CUSTOM_CONTEXTMENUS)
- appContextMenu(par);
- #endif
- } else {
- Layout *l = guiobject_getParentLayout();
- if (l->getParent() == NULL) {
- #if defined(WA3COMPATIBILITY)
- l->controlMenu();
- #elif defined(WASABI_CUSTOM_CONTEXTMENUS)
- appControlMenu(l);
- #endif
- }
- }
- } else {
- Layout *l = static_cast<Layout *>(w->getInterface(layoutGuid));
- if (l != NULL) {
- if (!Std::keyModifier(STDKEY_CONTROL)) {
- #if defined(WA3COMPATIBILITY)
- Main::appContextMenu(w, TRUE, l->isTransparencySafe());
- #elif defined(WASABI_CUSTOM_CONTEXTMENUS)
- appContextMenu(w);
- #endif
- } else {
- #if defined(WA3COMPATIBILITY)
- l->controlMenu();
- #elif defined(WASABI_CUSTOM_CONTEXTMENUS)
- appControlMenu(l);
- #endif
- }
- }
- }
- }
- }
- }
- void GuiObjectI::guiobject_onRightButtonDblClk(int x, int y) {
- scriptVar _x = SOM::makeVar(SCRIPT_INT);
- SOM::assign(&_x, x);
- scriptVar _y = SOM::makeVar(SCRIPT_INT);
- SOM::assign(&_y, y);
- GuiObject_ScriptMethods::onRightButtonDblClk(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y);
- }
- void GuiObjectI::guiobject_onLeftButtonDblClk(int x, int y) {
- scriptVar _x = SOM::makeVar(SCRIPT_INT);
- SOM::assign(&_x, x/* - wr.left*/);
- scriptVar _y = SOM::makeVar(SCRIPT_INT);
- SOM::assign(&_y, y/* - wr.top*/);
- GuiObject_ScriptMethods::onLeftButtonDblClk(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y);
- }
- int GuiObjectI::guiobject_onMouseWheelUp(int clicked, int lines)
- {
- scriptVar retval;
- retval = GuiObject_ScriptMethods::onMouseWheelUp(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_INT(clicked), MAKE_SCRIPT_INT(lines) );
- int retv;
- if ((retval.type == SCRIPT_VOID) || (retval.type == SCRIPT_OBJECT) || (retval.type == SCRIPT_STRING))
- retv = 0;
- else
- retv = GET_SCRIPT_INT(retval);
- return retv;
- }
- int GuiObjectI::guiobject_onMouseWheelDown(int clicked, int lines)
- {
- scriptVar retval;
- retval = GuiObject_ScriptMethods::onMouseWheelDown(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_INT(clicked), MAKE_SCRIPT_INT(lines) );
- int retv;
- if ((retval.type == SCRIPT_VOID) || (retval.type == SCRIPT_OBJECT) || (retval.type == SCRIPT_STRING))
- retv = 0;
- else
- retv = GET_SCRIPT_INT(retval);
- return retv;
- }
- void GuiObjectI::guiobject_onMouseMove(int x, int y) {
- scriptVar _x = SOM::makeVar(SCRIPT_INT);
- SOM::assign(&_x, x);
- scriptVar _y = SOM::makeVar(SCRIPT_INT);
- SOM::assign(&_y, y);
- GuiObject_ScriptMethods::onMouseMove(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y);
- POINT pos={x,y};
- guiobject_getRootWnd()->clientToScreen((int *)&pos.x, (int *)&pos.y);
- #ifdef WASABI_COMPILE_WNDMGR
- if (moving) {
- #ifdef _WIN32
- if (!Std::keyDown(MK_LBUTTON)) {
- #else
- #warning port me
- if (0) {
- #endif
- moving = 0;
- } else {
- #ifdef WIN32
- int drag_x = GetSystemMetrics(SM_CXDRAG);
- int drag_y = GetSystemMetrics(SM_CYDRAG);
- #else
- #warning port me
- int drag_x = 5;
- int drag_y = 5;
- #endif
- POINT relatpos;
- relatpos.x = (int)((float)x*guiobject_getRootWnd()->getRenderRatio()) - anchor.x;
- relatpos.y = (int)((float)y*guiobject_getRootWnd()->getRenderRatio()) - anchor.y;
- if (!dodragcheck || (ABS(relatpos.x) >= drag_x || ABS(relatpos.y) >= drag_y)) {
- dodragcheck = 0;
- ifc_window *p = guiobject_getRootWnd()->getDesktopParent();
- if (p) {
- RECT r, cr;
- p->getWindowRect(&r);
- p->getClientRect(&cr);
- RECT nr=r;
- int w,h;
- #ifdef USEAPPBAR
- int side = APPBAR_NOTDOCKED;
- if (cfg_options_appbarondrag) {
- AppBar *ab = reinterpret_cast<AppBar *>(p->getInterface(appBarGuid));
- if (ab) {
- int _x=x, _y=y;
- p->clientToScreen(&_x, &_y);
- side = ab->appbar_testDock(_x, _y, &nr);
- if (ABS(p->getRenderRatio() - 1.0) > 0.01f) {
- int _w = nr.right-nr.left;
- int _h = nr.bottom-nr.top;
- double rr = p->getRenderRatio();
- _w = (int)((double)(_w) / rr + 0.5);
- _h = (int)((double)(_h) / rr + 0.5);
- nr.right = nr.left + _w;
- nr.bottom = nr.top + _h;
- }
- }
- }
- #endif
- w = cr.right-cr.left;
- h = cr.bottom-cr.top;
- int resize=0;
- #ifdef USEAPPBAR
- if (cfg_options_appbarondrag) {
- if (side != m_dock_side) {
- if (side != APPBAR_NOTDOCKED) {
- m_lastnondocked_x = r.left;
- m_lastnondocked_y = r.top;
- resize=1;
- } else {
- RECT rr;
- p->getRestoredRect(&rr);
- w = (rr.right-rr.left);
- h = (rr.bottom-rr.top);
- if (m_lastnondocked_x != -0xFFFF) {
- r.left = m_lastnondocked_x;
- r.top = m_lastnondocked_y;
- }
- r.right = r.left + w;
- r.bottom = r.top + h;
- snapAdjust(p, &r, -1);
- nr=r;
- resize=1;
- }
- }
- }
- #endif
- // use the scaling to adjust the overall size so docking will be correct
- double rr = p->getRenderRatio();
- r.left += relatpos.x;
- r.top += relatpos.y;
- r.right = r.left + (int)((double)w * rr);
- r.bottom = r.top + (int)((double)h * rr);
- #ifdef USEAPPBAR
- if (side == APPBAR_NOTDOCKED && m_dock_side == APPBAR_NOTDOCKED)
- WASABI_API_WNDMGR->wndTrackDock(p, &r, &nr, LEFT|TOP|RIGHT|BOTTOM|KEEPSIZE);
- if (side != APPBAR_NOTDOCKED || resize) {
- Layout *l = (Layout *)p->getInterface(layoutGuid);
- if (l) l->pushForceUnlink();
- {
- RECT adj = nr;
- snapAdjust(p, &adj, 1);
- int _w = adj.right-adj.left;
- int _h = adj.bottom-adj.top;
- if (ABS(p->getRenderRatio() - 1.0) > 0.01f) {
- double rr = p->getRenderRatio();
- if ((int)((double)(_w) * rr) == (int)((double)(w) * rr)) _w = w;
- if ((int)((double)(_h) * rr) == (int)((double)(h) * rr)) _h = h;
- }
- p->resize(adj.left, adj.top, _w, _h);
- }
- if (l) l->popForceUnlink();
- } else {
- p->move(r.left, r.top);
- }
- m_dock_side = side;
- guiobject_getParentLayout()->onMove();
- if (GetCapture() != guiobject_getRootWnd()->getRootParent()->gethWnd()) {
- DebugStringW(L"not mine anymore :(\n");
- }
- #endif
- }
- }
- }
- }
- #endif
- }
- // -----------------------------------------------------------------------
- void GuiObjectI::snapAdjust(ifc_window *rw, RECT *r, int way) {
- RECT s;
- Layout *l = static_cast<Layout*>(rw->getInterface(layoutGuid));
- if (!l) return;
- l->getSnapAdjust(&s);
- int h = r->bottom - r->top;
- int w = r->right - r->left;
- if (way == 1) {
- h += s.top + s.bottom;
- w += s.left + s.right;
- r->left -= s.left;
- r->top -= s.top;
- r->bottom = r->top + h;
- r->right = r->left + w;
- } else if (way == -1) {
- h -= s.top + s.bottom;
- w -= s.left + s.right;
- r->left += s.left;
- r->top += s.top;
- r->bottom = r->top + h;
- r->right = r->left + w;
- }
- }
- #ifdef USEAPPBAR
- int GuiObjectI::guiobject_getAppBar() {
- AppBar *ab = reinterpret_cast<AppBar *>(guiobject_getRootWnd()->getInterface(appBarGuid));
- if (ab) return ab->appbar_getEnabledSides();
- return 0;
- }
- BEGIN_STRINGDICTIONARY(_appbarvalues)
- SDI(L"top", APPBAR_TOP_ENABLED);
- SDI(L"left", APPBAR_LEFT_ENABLED);
- SDI(L"right", APPBAR_RIGHT_ENABLED);
- SDI(L"bottom", APPBAR_BOTTOM_ENABLED);
- END_STRINGDICTIONARY(_appbarvalues, appbarvalues)
- void GuiObjectI::guiobject_setAppBar(int en) {
- AppBar *ab = reinterpret_cast<AppBar *>(guiobject_getRootWnd()->getInterface(appBarGuid));
- if (ab) ab->appbar_setEnabledSides(en);
- }
- void GuiObjectI::setAppBar(const wchar_t *en)
- {
- AppBar *ab = reinterpret_cast<AppBar *>(guiobject_getRootWnd()->getInterface(appBarGuid));
- if (ab) {
- int e = 0;
- ParamParser pp(en, L"|;");
- for (int i=0;i<pp.getNumItems();i++)
- {
- const wchar_t *s = pp.enumItem(i);
- if (!_wcsicmp(s, L"left")) e |= APPBAR_LEFT_ENABLED;
- else if (!_wcsicmp(s, L"top")) e |= APPBAR_TOP_ENABLED;
- else if (!_wcsicmp(s, L"right")) e |= APPBAR_RIGHT_ENABLED;
- else if (!_wcsicmp(s, L"bottom")) e |= APPBAR_BOTTOM_ENABLED;
- }
- ab->appbar_setEnabledSides(e);
- }
- }
- #endif
- const wchar_t *GuiObjectI::guiobject_getName()
- {
- const wchar_t *ret = NULL;
- ifc_window *w = guiobject_getRootWnd();
- if (w != NULL)
- ret = w->getRootWndName();
- return ret;
- }
- void GuiObjectI::guiobject_onEnable(int en) {
- scriptVar _is = SOM::makeVar(SCRIPT_INT);
- SOM::assign(&_is, en);
- GuiObject_ScriptMethods::onEnable(SCRIPT_CALL, guiobject_getScriptObject(), _is);
- }
- void GuiObjectI::guiobject_onStartup() {
- GuiObject_ScriptMethods::onStartup(SCRIPT_CALL, guiobject_getScriptObject());
- if (guiobject_getRootObject()) {
- foreach (notifylist)
- guiobject_getRootObject()->rootobject_notify(notifylist.getfor()->getValue(), L"", 0, 0);
- endfor;
- }
- }
- void GuiObjectI::guiobject_onEnterArea() {
- if (in_area) return;
- GuiObject_ScriptMethods::onEnterArea(SCRIPT_CALL, guiobject_getScriptObject());
- in_area = 1;
- }
- void GuiObjectI::guiobject_onLeaveArea() {
- if (!in_area) return;
- GuiObject_ScriptMethods::onLeaveArea(SCRIPT_CALL, guiobject_getScriptObject());
- in_area = 0;
- }
- void GuiObjectI::guiobject_onCancelCapture() {
- moving = 0;
- }
- ifc_window *GuiObjectI::guiobject_getRootWnd(void) {
- return my_root_wnd;
- }
- void GuiObjectI::guiobject_setRootWnd(ifc_window *r) {
- my_root_wnd = r;
- }
- RootObject *GuiObjectI::guiobject_getRootObject() {
- ScriptObject *o = guiobject_getScriptObject();
- if (!o) return NULL;
- return static_cast<RootObject *>(o->vcpu_getInterface(rootObjectGuid));
- }
- void GuiObjectI::guiobject_onResize(int x, int y, int w, int h) {
- scriptVar _x = SOM::makeVar(SCRIPT_INT);
- SOM::assign(&_x, x);
- scriptVar _y = SOM::makeVar(SCRIPT_INT);
- SOM::assign(&_y, y);
- scriptVar _w = SOM::makeVar(SCRIPT_INT);
- SOM::assign(&_w, w);
- scriptVar _h = SOM::makeVar(SCRIPT_INT);
- SOM::assign(&_h, h);
- GuiObject_ScriptMethods::onResize(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y, _w, _h);
- }
- void GuiObjectI::guiobject_onSetVisible(int v) {
- #ifdef WASABI_COMPILE_WNDMGR
- if (guiobject_getParentLayout())
- guiobject_getParentLayout()->onGuiObjectSetVisible(this, v);
- #endif
- scriptVar _v = SOM::makeVar(SCRIPT_BOOLEAN);
- SOM::assign(&_v, v);
- GuiObject_ScriptMethods::onSetVisible(SCRIPT_CALL, guiobject_getScriptObject(), _v);
- #ifdef WASABI_COMPILE_WNDMGR
- if (moving) {
- if (WASABI_API_WNDMGR->wndTrackWasCooperative())
- WASABI_API_WNDMGR->wndTrackEndCooperative();
- moving = 0;
- ifc_window *dp = guiobject_getRootWnd()->getDesktopParent();
- if (dp) dp->restore(0);
- guiobject_getParentGroup()->endMove();
- }
- #endif //WASABI_COMPILE_WNDMGR
- }
- void GuiObjectI::guiobject_setAlpha(int a) {
- if (!my_root_wnd) return;
- Layout *l = static_cast<Layout*>(my_root_wnd->getInterface(layoutGuid));
- if (l) l->setAlpha(a);
- else my_root_wnd->setAlpha(a);
- }
- int GuiObjectI::guiobject_getAlpha() {
- if (!my_root_wnd) return 255;
- Layout *l = static_cast<Layout*>(my_root_wnd->getInterface(layoutGuid));
- if (l) return l->getAlpha();
- return my_root_wnd->getPaintingAlpha();
- }
- void GuiObjectI::guiobject_setActiveAlpha(int a) {
- if (my_root_wnd) {
- int i;
- my_root_wnd->getAlpha(NULL, &i);
- my_root_wnd->setAlpha(a, i);
- }
- }
- int GuiObjectI::guiobject_getActiveAlpha() {
- int a = 255;
- if (my_root_wnd) my_root_wnd->getAlpha(&a);
- return a;
- }
- void GuiObjectI::guiobject_setInactiveAlpha(int a) {
- if (my_root_wnd) {
- int _a;
- my_root_wnd->getAlpha(&_a);
- my_root_wnd->setAlpha(_a, a);
- }
- }
- int GuiObjectI::guiobject_getInactiveAlpha() {
- if (my_root_wnd) {
- int i;
- my_root_wnd->getAlpha(NULL, &i);
- return i;
- }
- return 255;
- }
- void GuiObjectI::guiobject_onTargetReached() {
- GuiObject_ScriptMethods::onTargetReached(SCRIPT_CALL, guiobject_getScriptObject());
- Layout *l = static_cast<Layout *>(guiobject_getScriptObject()->vcpu_getInterface(layoutGuid));
- if (l && redock.l) windowTracker->afterRedock(l, &redock);
- }
- void GuiObjectI::guiobject_setAutoSysMetricsX(int a) {
- if (a == autosysmetricsx) return;
- autosysmetricsx = a;
- if (guiobject_getRootWnd() && guiobject_getRootWnd()->isInited())
- if (guiobject_getParentGroup()) guiobject_getParentGroup()->updatePos(this);
- }
- void GuiObjectI::guiobject_setAutoSysMetricsY(int a) {
- if (a == autosysmetricsy) return;
- autosysmetricsy = a;
- if (guiobject_getRootWnd() && guiobject_getRootWnd()->isInited())
- if (guiobject_getParentGroup()) guiobject_getParentGroup()->updatePos(this);
- }
- void GuiObjectI::guiobject_setAutoSysMetricsW(int a) {
- if (a == autosysmetricsw) return;
- autosysmetricsw = a;
- if (guiobject_getRootWnd() && guiobject_getRootWnd()->isInited())
- if (guiobject_getParentGroup()) guiobject_getParentGroup()->updatePos(this);
- }
- void GuiObjectI::guiobject_setAutoSysMetricsH(int a) {
- if (a == autosysmetricsh) return;
- autosysmetricsh = a;
- if (guiobject_getRootWnd() && guiobject_getRootWnd()->isInited())
- if (guiobject_getParentGroup()) guiobject_getParentGroup()->updatePos(this);
- }
- int GuiObjectI::guiobject_getAutoSysMetricsX() {
- return autosysmetricsx;
- }
- int GuiObjectI::guiobject_getAutoSysMetricsY() {
- return autosysmetricsy;
- }
- int GuiObjectI::guiobject_getAutoSysMetricsW() {
- return autosysmetricsw;
- }
- int GuiObjectI::guiobject_getAutoSysMetricsH() {
- return autosysmetricsh;
- }
- int GuiObjectI::guiobject_getAutoWidth() {
- if (!guiobject_getRootWnd()) return AUTOWH;
- return guiobject_getRootWnd()->getPreferences(SUGGESTED_W);
- }
- int GuiObjectI::guiobject_getAutoHeight() {
- if (!guiobject_getRootWnd()) return AUTOWH;
- return guiobject_getRootWnd()->getPreferences(SUGGESTED_H);
- }
- #ifdef WASABI_COMPILE_WNDMGR
- int GuiObjectI::guiobject_runModal() {
- if (!guiobject_getRootWnd()) return 0;
- ifc_window *w = guiobject_getRootWnd()->getDesktopParent();
- #ifdef WASABI_MODAL_PUSH
- WASABI_MODAL_PUSH
- #endif
- int r = w->runModal();
- #ifdef WASABI_MODAL_POP
- WASABI_MODAL_POP
- #endif
- return r;
- }
- void GuiObjectI::guiobject_endModal(int retcode) {
- if (!guiobject_getRootWnd()) return;
- ifc_window *w = guiobject_getRootWnd()->getDesktopParent();
- w->endModal(retcode);
- }
- #endif
- int GuiObjectI::guiobject_isActive() {
- if (!guiobject_getRootWnd()) return 0;
- return guiobject_getRootWnd()->isActive();
- }
- svc_xuiObject *GuiObjectI::guiobject_getXuiService() {
- return xuisvc;
- }
- void GuiObjectI::guiobject_setXuiService(svc_xuiObject *svc) {
- xuisvc = svc;
- }
- waServiceFactory *GuiObjectI::guiobject_getXuiServiceFactory() {
- return xuifac;
- }
- void GuiObjectI::guiobject_setXuiServiceFactory(waServiceFactory *fac) {
- xuifac = fac;
- }
- #ifdef WASABI_COMPILE_WNDMGR
- void GuiObjectI::guiobject_setStatusText(const wchar_t *text, int overlay)
- {
- Layout *l = guiobject_getParentLayout();
- if (l)
- l->setStatusText(text, overlay);
- }
- void GuiObjectI::guiobject_registerStatusCB(GuiStatusCallback *cb) {
- Layout *l = guiobject_getParentLayout();
- if (l) l->registerStatusCallback(cb);
- }
- void GuiObjectI::guiobject_addAppCmds(AppCmds *commands){
- Layout *l = guiobject_getParentLayout();
- if (l) l->addAppCmds(commands);
- }
- void GuiObjectI::guiobject_removeAppCmds(AppCmds *commands){
- Layout *l = guiobject_getParentLayout();
- if (l) l->removeAppCmds(commands);
- }
- void GuiObjectI::guiobject_pushCompleted(int max) {
- Layout *l = guiobject_getParentLayout();
- if (l) l->pushCompleted(max);
- }
- void GuiObjectI::guiobject_incCompleted(int add) {
- Layout *l = guiobject_getParentLayout();
- if (l) l->incCompleted(add);
- }
- void GuiObjectI::guiobject_setCompleted(int pos) {
- Layout *l = guiobject_getParentLayout();
- if (l) l->setCompleted(pos);
- }
- void GuiObjectI::guiobject_popCompleted() {
- Layout *l = guiobject_getParentLayout();
- if (l) l->popCompleted();
- }
- #endif //WASABI_COMPILE_WNDMGR
- void GuiObjectI::infoMenu(GuiObject *o, int x, int y)
- {
- PopupMenu pop;
- pop.addCommand(StringPrintfW(L"Class : %s", o->guiobject_getScriptObject()->vcpu_getClassName()), 0, 0, 1);
- pop.addCommand(StringPrintfW(L"Id : %s", o->guiobject_getId()), 0, 0, 1);
- RECT r;
- guiobject_getRootWnd()->getNonClientRect(&r);
- 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);
- int _x, _y, _w, _h, _rx, _ry, _rw, _rh;
- guiobject_getGuiPosition(&_x, &_y, &_w, &_h, &_rx, &_ry, &_rw, &_rh);
- 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);
- if (guiobject_wantTranslation() == 2)
- {
- if (!_wcsicmp(o->guiobject_getScriptObject()->vcpu_getClassName(), L"Text"))
- {
- pop.addCommand(StringPrintfW(L"StringEntry : %s", guiobject_getXmlParam(L"text")), 0, 0, 1);
- }
- else if (!_wcsicmp(o->guiobject_getScriptObject()->vcpu_getClassName(), L"TitleBar"))
- {
- pop.addCommand(StringPrintfW(L"StringEntry : %s", guiobject_getXmlParam(L"title")), 0, 0, 1);
- }
- }
- guiobject_getRootWnd()->clientToScreen(&x, &y);
- pop.popAtXY(x, y, 1);
- }
- #ifdef WASABI_COMPILE_CONFIG
- void GuiObjectI::guiobject_setCfgAttrib(CfgItem *item, const wchar_t *name)
- {
- if (cfgitem) viewer_delViewItem(cfgitem);
- cfgitem = item;
- cfgattrname = name;
- if (cfgitem) {
- viewer_addViewItem(cfgitem);
- }
- ifc_window *mw = guiobject_getRootWnd();
- if (mw != NULL) {
- if (mw->isPostOnInit())
- dataChanged();
- }
- }
- int GuiObjectI::viewer_onEvent(CfgItem *item, int event, intptr_t param, void *ptr, size_t ptrlen) {
- if (item == cfgitem)
- dataChanged();
- return 1;
- }
- void GuiObjectI::dataChanged() {
- ifc_window *w = guiobject_getRootWnd();
- if (w != NULL) {
- w->onAction(L"reload_config", NULL, -1, -1, 0, 0, NULL, 0, w);
- }
- GuiObject_ScriptMethods::onCfgChanged(SCRIPT_CALL, guiobject_getScriptObject());
- }
- CfgItem *GuiObjectI::guiobject_getCfgItem() {
- return cfgitem;
- }
- const wchar_t *GuiObjectI::guiobject_getCfgAttrib()
- {
- return cfgattrname;
- }
- #endif //WASABI_COMPILE_CONFIG
- void GuiObjectI::guiobject_onChar(wchar_t c)
- {
- wchar_t _c[2]=L"X";
- _c[0]=c;
- GuiObject_ScriptMethods::onChar(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_STRING(_c));
- }
- void GuiObjectI::guiobject_onKeyDown(int vkcode) {
- GuiObject_ScriptMethods::onKeyDown(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_INT(vkcode));
- }
- void GuiObjectI::guiobject_onKeyUp(int vkcode) {
- GuiObject_ScriptMethods::onKeyUp(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_INT(vkcode));
- }
- void GuiObjectI::guiobject_setCursor(const wchar_t *c)
- {
- ifc_window *w = guiobject_getRootWnd();
- #ifdef _WIN32
- if (w != NULL) {
- delete cursor;
- cursor = new SkinCursor(c);
- w->setDefaultCursor(cursor);
- }
- #else
- #warning port me
- #endif
- }
- void GuiObjectI::guiobject_setEnabled(int en) {
- ifc_window *w = guiobject_getRootWnd();
- if (w != NULL) w->setEnabled(en);
- }
- int GuiObjectI::guiobject_wantTranslation()
- {
- return translate;
- }
- int GuiObjectI::guiobject_dragEnter(ifc_window *sourceWnd)
- {
- GuiObject_ScriptMethods::onDragEnter(SCRIPT_CALL, guiobject_getScriptObject());
- return 1;
- }
- int GuiObjectI::guiobject_dragOver(int x, int y, ifc_window *sourceWnd)
- {
- GuiObject_ScriptMethods::onDragOver(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_INT(x), MAKE_SCRIPT_INT(y) );
- return 1;
- }
- int GuiObjectI::guiobject_dragLeave(ifc_window *sourceWnd)
- {
- GuiObject_ScriptMethods::onDragLeave(SCRIPT_CALL, guiobject_getScriptObject());
- return 1;
- }
- GuiObjectScriptController _guiController;
- GuiObjectScriptController *guiController = &_guiController;
- // -- Functions table -------------------------------------
- function_descriptor_struct GuiObjectScriptController::exportedFunction[] = {
- {L"getId", 0, (void*)GuiObject_ScriptMethods::getId },
- {L"show", 0, (void*)GuiObject_ScriptMethods::show },
- {L"hide", 0, (void*)GuiObject_ScriptMethods::hide },
- {L"onSetVisible", 1, (void*)GuiObject_ScriptMethods::onSetVisible},
- {L"isVisible", 0, (void*)GuiObject_ScriptMethods::isvisible },
- {L"setAlpha", 1, (void*)GuiObject_ScriptMethods::setAlpha },
- {L"getAlpha", 0, (void*)GuiObject_ScriptMethods::getAlpha },
- {L"setActiveAlpha", 1, (void*)GuiObject_ScriptMethods::setActiveAlpha },
- {L"getActiveAlpha", 0, (void*)GuiObject_ScriptMethods::getActiveAlpha },
- {L"setInactiveAlpha", 1, (void*)GuiObject_ScriptMethods::setInactiveAlpha },
- {L"getInactiveAlpha", 0, (void*)GuiObject_ScriptMethods::getInactiveAlpha },
- {L"onLeftButtonDown", 2, (void*)GuiObject_ScriptMethods::onLeftButtonDown },
- {L"onLeftButtonUp", 2, (void*)GuiObject_ScriptMethods::onLeftButtonUp },
- {L"onRightButtonDown", 2, (void*)GuiObject_ScriptMethods::onRightButtonDown },
- {L"onRightButtonUp", 2, (void*)GuiObject_ScriptMethods::onRightButtonUp },
- {L"onRightButtonDblClk", 2, (void*)GuiObject_ScriptMethods::onRightButtonDblClk },
- {L"onLeftButtonDblClk", 2, (void*)GuiObject_ScriptMethods::onLeftButtonDblClk },
- {L"onMouseWheelUp", 2, (void*)GuiObject_ScriptMethods::onMouseWheelUp },
- {L"onMouseWheelDown", 2, (void*)GuiObject_ScriptMethods::onMouseWheelDown },
- {L"onMouseMove", 2, (void*)GuiObject_ScriptMethods::onMouseMove },
- {L"onEnterArea", 0, (void*)GuiObject_ScriptMethods::onEnterArea },
- {L"onLeaveArea", 0, (void*)GuiObject_ScriptMethods::onLeaveArea },
- {L"isMouseOverRect", 0, (void*)GuiObject_ScriptMethods::isMouseOverRect},
- {L"onStartup", 0, (void*)GuiObject_ScriptMethods::onStartup },
- {L"onChar", 1, (void*)GuiObject_ScriptMethods::onChar },
- {L"onKeyDown", 1, (void*)GuiObject_ScriptMethods::onKeyDown},
- {L"onKeyUp", 1, (void*)GuiObject_ScriptMethods::onKeyUp},
- {L"setEnabled", 1, (void*)GuiObject_ScriptMethods::setEnabled },
- {L"getEnabled", 0, (void*)GuiObject_ScriptMethods::getEnabled },
- {L"onEnable", 1, (void*)GuiObject_ScriptMethods::onEnable },
- {L"resize", 4, (void*)GuiObject_ScriptMethods::resize },
- {L"onResize", 4, (void*)GuiObject_ScriptMethods::onResize },
- {L"isMouseOver", 2, (void*)GuiObject_ScriptMethods::isMouseOver },
- {L"getLeft", 0, (void*)GuiObject_ScriptMethods::getLeft },
- {L"getTop", 0, (void*)GuiObject_ScriptMethods::getTop },
- {L"getWidth", 0, (void*)GuiObject_ScriptMethods::getWidth },
- {L"getHeight", 0, (void*)GuiObject_ScriptMethods::getHeight },
- {L"getGuiX", 0, (void*)GuiObject_ScriptMethods::getGuiX },
- {L"getGuiY", 0, (void*)GuiObject_ScriptMethods::getGuiY },
- {L"getGuiW", 0, (void*)GuiObject_ScriptMethods::getGuiW },
- {L"getGuiH", 0, (void*)GuiObject_ScriptMethods::getGuiH },
- {L"getGuiRelatX", 0, (void*)GuiObject_ScriptMethods::getGuiRelatX },
- {L"getGuiRelatY", 0, (void*)GuiObject_ScriptMethods::getGuiRelatX },
- {L"getGuiRelatW", 0, (void*)GuiObject_ScriptMethods::getGuiRelatX },
- {L"getGuiRelatH", 0, (void*)GuiObject_ScriptMethods::getGuiRelatX },
- {L"clientToScreenX", 1, (void*)GuiObject_ScriptMethods::clientToScreenX },
- {L"clientToScreenY", 1, (void*)GuiObject_ScriptMethods::clientToScreenY },
- {L"clientToScreenW", 1, (void*)GuiObject_ScriptMethods::clientToScreenW },
- {L"clientToScreenH", 1, (void*)GuiObject_ScriptMethods::clientToScreenH },
- {L"screenToClientX", 1, (void*)GuiObject_ScriptMethods::screenToClientX },
- {L"screenToClientY", 1, (void*)GuiObject_ScriptMethods::screenToClientY },
- {L"screenToClientW", 1, (void*)GuiObject_ScriptMethods::screenToClientW },
- {L"screenToClientH", 1, (void*)GuiObject_ScriptMethods::screenToClientH },
- {L"setTargetX", 1, (void*)GuiObject_ScriptMethods::setTargetX },
- {L"setTargetY", 1, (void*)GuiObject_ScriptMethods::setTargetY },
- {L"setTargetW", 1, (void*)GuiObject_ScriptMethods::setTargetW },
- {L"setTargetH", 1, (void*)GuiObject_ScriptMethods::setTargetH },
- {L"setTargetA", 1, (void*)GuiObject_ScriptMethods::setTargetA },
- {L"setTargetSpeed", 1, (void*)GuiObject_ScriptMethods::setTargetSpeed },
- {L"gotoTarget", 0, (void*)GuiObject_ScriptMethods::gotoTarget },
- {L"onTargetReached", 0, (void*)GuiObject_ScriptMethods::onTargetReached },
- {L"cancelTarget", 0, (void*)GuiObject_ScriptMethods::cancelTarget },
- {L"reverseTarget", 1, (void*)GuiObject_ScriptMethods::reverseTarget },
- {L"isGoingToTarget", 0, (void*)GuiObject_ScriptMethods::movingToTarget },
- {L"setXmlParam", 2, (void*)GuiObject_ScriptMethods::setXmlParam },
- {L"getXmlParam", 1, (void*)GuiObject_ScriptMethods::getXmlParam },
- {L"init", 1, (void*)GuiObject_ScriptMethods::init },
- {L"bringToFront", 0, (void*)GuiObject_ScriptMethods::bringToFront },
- {L"bringToBack", 0, (void*)GuiObject_ScriptMethods::bringToBack },
- {L"bringAbove", 1, (void*)GuiObject_ScriptMethods::bringAbove },
- {L"bringBelow", 1, (void*)GuiObject_ScriptMethods::bringBelow },
- {L"isActive", 0, (void*)GuiObject_ScriptMethods::isActive},
- {L"getParent", 0, (void*)GuiObject_ScriptMethods::getParent},
- {L"getTopParent", 0, (void*)GuiObject_ScriptMethods::getTopParent},
- {L"getInterface", 1, (void*)GuiObject_ScriptMethods::getInterface},
- {L"onAction", 7, (void*)GuiObject_ScriptMethods::onAction},
- #ifdef WASABI_COMPILE_WNDMGR
- {L"getParentLayout", 0, (void*)GuiObject_ScriptMethods::getParentLayout},
- {L"runModal", 0, (void*)GuiObject_ScriptMethods::runModal},
- {L"endModal", 1, (void*)GuiObject_ScriptMethods::endModal},
- {L"popParentLayout", 0, (void*)GuiObject_ScriptMethods::popParentLayout},
- {L"setStatusText", 2, (void*)GuiObject_ScriptMethods::setStatusText},
- #endif
- {L"findObject", 1, (void*)GuiObject_ScriptMethods::findObject},
- {L"findObjectXY", 2, (void*)GuiObject_ScriptMethods::findObjectXY},
- {L"getName", 0, (void*)GuiObject_ScriptMethods::getName},
- {L"getAutoWidth", 0, (void*)GuiObject_ScriptMethods::getAutoWidth },
- {L"getAutoHeight", 0, (void*)GuiObject_ScriptMethods::getAutoHeight },
- {L"setFocus", 0, (void*)GuiObject_ScriptMethods::setFocus},
- {L"onGetFocus", 0, (void*)GuiObject_ScriptMethods::onGetFocus},
- {L"onKillFocus", 0, (void*)GuiObject_ScriptMethods::onKillFocus},
- {L"sendAction", 6, (void*)GuiObject_ScriptMethods::sendAction},
- {L"onAccelerator", 1, (void*)GuiObject_ScriptMethods::onAccelerator},
- #ifdef WASABI_COMPILE_CONFIG
- {L"cfg_getInt", 0, (void*)GuiObject_ScriptMethods::cfgGetInt },
- {L"cfg_setInt", 1, (void*)GuiObject_ScriptMethods::cfgSetInt },
- {L"cfg_getFloat", 0, (void*)GuiObject_ScriptMethods::cfgGetFloat },
- {L"cfg_setFloat", 1, (void*)GuiObject_ScriptMethods::cfgSetFloat },
- {L"cfg_getString", 0, (void*)GuiObject_ScriptMethods::cfgGetString },
- {L"cfg_setString", 1, (void*)GuiObject_ScriptMethods::cfgSetString },
- {L"cfg_onDataChanged", 0, (void*)GuiObject_ScriptMethods::onCfgChanged },
- {L"cfg_getItemGuid", 0, (void*)GuiObject_ScriptMethods::cfgGetGuid},
- {L"cfg_getAttributeName", 0, (void*)GuiObject_ScriptMethods::cfgGetAttributeName},
- #endif
- {L"onDragEnter", 0, (void*)GuiObject_ScriptMethods::onDragEnter },
- {L"onDragOver", 2, (void*)GuiObject_ScriptMethods::onDragOver},
- {L"onDragLeave", 0, (void*)GuiObject_ScriptMethods::onDragLeave},
- };
- const wchar_t *GuiObjectScriptController::getClassName() {
- return L"GuiObject";
- }
- const wchar_t *GuiObjectScriptController::getAncestorClassName() {
- return L"Object";
- }
- ScriptObjectController *GuiObjectScriptController::getAncestorController() {
- return rootScriptObjectController;}
- int GuiObjectScriptController::getNumFunctions() {
- return sizeof(exportedFunction) / sizeof(function_descriptor_struct);
- }
- const function_descriptor_struct *GuiObjectScriptController::getExportedFunctions() {
- return exportedFunction;
- }
- GUID GuiObjectScriptController::getClassGuid() {
- return guiObjectGuid;
- }
- int GuiObjectScriptController::getInstantiable() {
- return 1;
- }
- ScriptObject *GuiObjectScriptController::instantiate() {
- GuiObjectWnd *w = new GuiObjectWnd;
- ASSERT(w != NULL);
- return w->getScriptObject();
- }
- void GuiObjectScriptController::destroy(ScriptObject *o) {
- GuiObjectWnd *w = static_cast<GuiObjectWnd *>(o->vcpu_getInterface(guiObjectWndGuid));
- ASSERT(w != NULL);
- delete w;
- }
- void *GuiObjectScriptController::encapsulate(ScriptObject *o) {
- return static_cast<void *>(new GuiObjectI(o));
- }
- void GuiObjectScriptController::deencapsulate(void *o) {
- delete static_cast<GuiObjectI *>(o);
- }
- // ----------------------------------------------------------------------------------------------------------------------------------
- // returns a new ScriptString object containing the xml id of this object
- scriptVar GuiObject_ScriptMethods::getId(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
-
- if (g)
- return MAKE_SCRIPT_STRING(g->guiobject_getId());
- return MAKE_SCRIPT_STRING(L"");
- }
- scriptVar GuiObject_ScriptMethods::hide(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) {
- ifc_window *w = g->guiobject_getRootWnd();
- if (w)
- w->setVisible(0);
- }
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::show(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) {
- ifc_window *w = g->guiobject_getRootWnd();
- if (w)
- w->setVisible(1);
- }
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::isvisible(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) {
- ifc_window *w = g->guiobject_getRootWnd();
- if (w) return MAKE_SCRIPT_BOOLEAN(w->isVisible());
- }
- RETURN_SCRIPT_ZERO;
- }
- scriptVar GuiObject_ScriptMethods::getAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) return MAKE_SCRIPT_INT(g->guiobject_getAlpha());
- return MAKE_SCRIPT_INT(255);
- }
- scriptVar GuiObject_ScriptMethods::setAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) g->guiobject_setAlpha(GET_SCRIPT_INT(a));
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::getActiveAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) return MAKE_SCRIPT_INT(g->guiobject_getActiveAlpha());
- return MAKE_SCRIPT_INT(255);
- }
- scriptVar GuiObject_ScriptMethods::setActiveAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) g->guiobject_setActiveAlpha(GET_SCRIPT_INT(a));
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::getInactiveAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) return MAKE_SCRIPT_INT(g->guiobject_getInactiveAlpha());
- return MAKE_SCRIPT_INT(255);
- }
- scriptVar GuiObject_ScriptMethods::setInactiveAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) g->guiobject_setInactiveAlpha(GET_SCRIPT_INT(a));
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::onMouseMove(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS2(o, guiController, x, y);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT2(o, x, y);
- }
- scriptVar GuiObject_ScriptMethods::onLeftButtonDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS2(o, guiController, x, y);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT2(o, x, y);
- }
- scriptVar GuiObject_ScriptMethods::onLeftButtonUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS2(o, guiController, x, y);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT2(o, x, y);
- }
- scriptVar GuiObject_ScriptMethods::onRightButtonDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS2(o, guiController, x, y);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT2(o, x, y);
- }
- scriptVar GuiObject_ScriptMethods::onRightButtonUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS2(o, guiController, x, y);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT2(o, x, y);
- }
- scriptVar GuiObject_ScriptMethods::onLeftButtonDblClk(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS2(o, guiController, x, y);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT2(o, x, y);
- }
- scriptVar GuiObject_ScriptMethods::onRightButtonDblClk(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS2(o, guiController, x, y);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT2(o, x, y);
- }
- scriptVar GuiObject_ScriptMethods::onMouseWheelUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar clicked, scriptVar lines) {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS2(o, guiController, clicked, lines);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT2(o, clicked, lines);
- }
- scriptVar GuiObject_ScriptMethods::onMouseWheelDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar clicked, scriptVar lines) {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS2(o, guiController, clicked, lines);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT2(o, clicked, lines);
- }
- scriptVar GuiObject_ScriptMethods::onEnterArea(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS0(o, guiController);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT0(o);
- }
- scriptVar GuiObject_ScriptMethods::onLeaveArea(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS0(o, guiController);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT0(o);
- }
- scriptVar GuiObject_ScriptMethods::setEnabled(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v) {
- SCRIPT_FUNCTION_INIT;
- ASSERT(SOM::isNumeric(&v));
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) {
- ifc_window *b = g->guiobject_getRootWnd();
- if (b) b->setEnabled(GET_SCRIPT_BOOLEAN(v));
- }
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::getEnabled(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) {
- ifc_window *b = g->guiobject_getRootWnd();
- if (b) return MAKE_SCRIPT_BOOLEAN(b->isEnabled());
- }
- RETURN_SCRIPT_ZERO;
- }
- scriptVar GuiObject_ScriptMethods::onEnable(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v) {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS1(o, guiController, v);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT1(o, v);
- }
- scriptVar GuiObject_ScriptMethods::onSetVisible(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v) {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS1(o, guiController, v);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT1(o, v);
- }
- scriptVar GuiObject_ScriptMethods::onResize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y, scriptVar w, scriptVar h) {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS4(o, guiController, x, y, w, h);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT4(o, x, y, w, h);
- }
- scriptVar GuiObject_ScriptMethods::resize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y, scriptVar w, scriptVar h) {
- SCRIPT_FUNCTION_INIT;
- ASSERT(SOM::isNumeric(&x));
- ASSERT(SOM::isNumeric(&y));
- ASSERT(SOM::isNumeric(&w));
- ASSERT(SOM::isNumeric(&h));
- GuiObject *go = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (go) {
- int _x = SOM::makeInt(&x);
- int _y = SOM::makeInt(&y);
- int _w = SOM::makeInt(&w);
- int _h = SOM::makeInt(&h);
- ifc_window *b = go->guiobject_getRootWnd();
- if (b) b->resize(_x, _y, _w, _h);
- go->guiobject_setGuiPosition(_x == NOCHANGE ? &_x : NULL, _y == NOCHANGE ? &_y : NULL, _w == NOCHANGE ? &_w : NULL, _h == NOCHANGE ? &_h : NULL, NULL, NULL, NULL, NULL);
- if (b && b->getInterface(layoutGuid)) {
- b->cascadeRepaint();
- ((Layout *)b->getInterface(layoutGuid))->savePosition();
- }
- }
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::isMouseOver(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) {
- SCRIPT_FUNCTION_INIT;
- ASSERT(SOM::isNumeric(&x));
- ASSERT(SOM::isNumeric(&y));
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) {
- ifc_window *b = g->guiobject_getRootWnd();
- POINT pt={GET_SCRIPT_INT(x), GET_SCRIPT_INT(y)};
- b->clientToScreen((int *)&pt.x, (int *)&pt.y);
- return MAKE_SCRIPT_BOOLEAN(WASABI_API_WND->rootWndFromPoint(&pt) == b);
- }
- RETURN_SCRIPT_ZERO;
- }
- scriptVar GuiObject_ScriptMethods::getLeft(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
- ifc_window *b = go->guiobject_getRootWnd();
- int r=0;
- if (b && b->isInited()) {
- POINT pt;
- b->getPosition(&pt);
- r = pt.x;
- } else if (b && !b->isInited()) {
- go->guiobject_getGuiPosition(&r, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
- }
- return MAKE_SCRIPT_INT(r);
- }
- scriptVar GuiObject_ScriptMethods::movingToTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) return MAKE_SCRIPT_BOOLEAN(g->guiobject_movingToTarget());
- RETURN_SCRIPT_ZERO;
- }
- scriptVar GuiObject_ScriptMethods::cancelTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g && g->guiobject_movingToTarget()) g->guiobject_cancelTarget();
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::reverseTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) g->guiobject_reverseTarget(GET_SCRIPT_INT(r));
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::getTop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
- ifc_window *b = go->guiobject_getRootWnd();
- int r=0;
- if (b && b->isInited()) {
- POINT pt;
- b->getPosition(&pt);
- r = pt.y;
- } else if (b && !b->isInited()) {
- go->guiobject_getGuiPosition(NULL, &r, NULL, NULL, NULL, NULL, NULL, NULL);
- }
- return MAKE_SCRIPT_INT(r);
- }
- scriptVar GuiObject_ScriptMethods::getWidth(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
- ifc_window *b = go->guiobject_getRootWnd();
- int r=0;
- if (b && b->isInited()) {
- RECT rc;
- b->getClientRect(&rc);
- r = rc.right-rc.left;
- } else if (b && !b->isInited()) {
- go->guiobject_getGuiPosition(NULL, NULL, &r, NULL, NULL, NULL, NULL, NULL);
- }
- return MAKE_SCRIPT_INT(r);
- }
- scriptVar GuiObject_ScriptMethods::getHeight(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
- ifc_window *b = go->guiobject_getRootWnd();
- int r=0;
- if (b && b->isInited()) {
- RECT rc;
- b->getClientRect(&rc);
- r = rc.bottom-rc.top;
- } else if (b && !b->isInited()) {
- go->guiobject_getGuiPosition(NULL, NULL, NULL, &r, NULL, NULL, NULL, NULL);
- }
- return MAKE_SCRIPT_INT(r);
- }
- scriptVar GuiObject_ScriptMethods::setTargetX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x) {
- SCRIPT_FUNCTION_INIT;
- ASSERT(SOM::isNumeric(&x));
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) g->guiobject_setTargetX(GET_SCRIPT_INT(x));
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::setTargetY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar y) {
- SCRIPT_FUNCTION_INIT;
- ASSERT(SOM::isNumeric(&y));
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) g->guiobject_setTargetY(GET_SCRIPT_INT(y));
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::setTargetW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar w) {
- SCRIPT_FUNCTION_INIT;
- ASSERT(SOM::isNumeric(&w));
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) g->guiobject_setTargetW(GET_SCRIPT_INT(w));
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::setTargetH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar h) {
- SCRIPT_FUNCTION_INIT;
- ASSERT(SOM::isNumeric(&h));
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) g->guiobject_setTargetH(GET_SCRIPT_INT(h));
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::setTargetA(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a) {
- SCRIPT_FUNCTION_INIT;
- ASSERT(SOM::isNumeric(&a));
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) g->guiobject_setTargetA(GET_SCRIPT_INT(a));
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::setTargetSpeed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s) {
- SCRIPT_FUNCTION_INIT;
- ASSERT(SOM::isNumeric(&s));
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) g->guiobject_setTargetSpeed(GET_SCRIPT_FLOAT(s));
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::gotoTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) g->guiobject_gotoTarget();
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::bringToFront(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) g->guiobject_bringToFront();
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::bringToBack(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) g->guiobject_bringToBack();
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::bringAbove(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj) {
- SCRIPT_FUNCTION_INIT;
- ASSERT(obj.data.odata != NULL);
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) g->guiobject_bringAbove((static_cast<GuiObject *>(GET_SCRIPT_OBJECT_AS(obj, guiObjectGuid))));
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::bringBelow(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj) {
- SCRIPT_FUNCTION_INIT;
- ASSERT(obj.data.odata != NULL);
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) g->guiobject_bringBelow((static_cast<GuiObject *>(GET_SCRIPT_OBJECT_AS(obj, guiObjectGuid))));
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::onTargetReached(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS0(o, guiController);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT0(o);
- }
- scriptVar GuiObject_ScriptMethods::setXmlParam(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar param, scriptVar value)
- {
- SCRIPT_FUNCTION_INIT;
- XmlObject *x = static_cast<XmlObject*>(o->vcpu_getInterface(xmlObjectGuid));
- if (x)
- x->setXmlParam(GET_SCRIPT_STRING(param), GET_SCRIPT_STRING(value));
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::getXmlParam(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar param) {
- SCRIPT_FUNCTION_INIT;
- const wchar_t *rt = NULL;
- XmlObject *x = static_cast<XmlObject*>(o->vcpu_getInterface(xmlObjectGuid));
- if (x) {
- int r = x->getXmlParam(GET_SCRIPT_STRING(param));
- if (r != -1)
- rt = x->getXmlParamValue(r);
- }
- if (rt == NULL)
- rt = L""; // returning null in a string is kinda bad, y'know?
-
- return MAKE_SCRIPT_STRING(rt);
- }
- scriptVar GuiObject_ScriptMethods::onStartup(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS0(o, guiController);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT0(o);
- }
- scriptVar GuiObject_ScriptMethods::getGuiX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- int v=0;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) g->guiobject_getGuiPosition(&v, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
- return MAKE_SCRIPT_INT(v);
- }
- scriptVar GuiObject_ScriptMethods::getGuiY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- int v=0;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) g->guiobject_getGuiPosition(NULL, &v, NULL, NULL, NULL, NULL, NULL, NULL);
- return MAKE_SCRIPT_INT(v);
- }
- scriptVar GuiObject_ScriptMethods::getGuiW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- int v=0;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) g->guiobject_getGuiPosition(NULL, NULL, &v, NULL, NULL, NULL, NULL, NULL);
- return MAKE_SCRIPT_INT(v);
- }
- scriptVar GuiObject_ScriptMethods::getGuiH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- int v=0;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) g->guiobject_getGuiPosition(NULL, NULL, NULL, &v, NULL, NULL, NULL, NULL);
- return MAKE_SCRIPT_INT(v);
- }
- scriptVar GuiObject_ScriptMethods::getGuiRelatX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- int v=0;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) g->guiobject_getGuiPosition(NULL, NULL, NULL, NULL, &v, NULL, NULL, NULL);
- return MAKE_SCRIPT_INT(v);
- }
- scriptVar GuiObject_ScriptMethods::getGuiRelatY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- int v=0;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) g->guiobject_getGuiPosition(NULL, NULL, NULL, NULL, NULL, &v, NULL, NULL);
- return MAKE_SCRIPT_INT(v);
- }
- scriptVar GuiObject_ScriptMethods::getGuiRelatW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- int v=0;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) g->guiobject_getGuiPosition(NULL, NULL, NULL, NULL, NULL, NULL, &v, NULL);
- return MAKE_SCRIPT_INT(v);
- }
- scriptVar GuiObject_ScriptMethods::getGuiRelatH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- int v=0;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) g->guiobject_getGuiPosition(NULL, NULL, NULL, NULL, NULL, NULL, NULL, &v);
- return MAKE_SCRIPT_INT(v);
- }
- scriptVar GuiObject_ScriptMethods::clientToScreenX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x) {
- SCRIPT_FUNCTION_INIT;
- int v=0;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) {
- ifc_window *w = g->guiobject_getRootWnd();
- if (w != NULL) {
- v = GET_SCRIPT_INT(x);
- w->clientToScreen(&v, NULL);
- }
- }
- return MAKE_SCRIPT_INT(v);
- }
- scriptVar GuiObject_ScriptMethods::clientToScreenY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar y) {
- SCRIPT_FUNCTION_INIT;
- int v=0;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) {
- ifc_window *w = g->guiobject_getRootWnd();
- if (w != NULL) {
- v = GET_SCRIPT_INT(y);
- w->clientToScreen(NULL, &v);
- }
- }
- return MAKE_SCRIPT_INT(v);
- }
- scriptVar GuiObject_ScriptMethods::clientToScreenW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar w) {
- SCRIPT_FUNCTION_INIT;
- int v=0;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) {
- ifc_window *wn = g->guiobject_getRootWnd();
- if (wn != NULL) {
- v = GET_SCRIPT_INT(w);
- double rr = wn->getRenderRatio();
- v = (int)((double)(v) * rr);
- }
- }
- return MAKE_SCRIPT_INT(v);
- }
- scriptVar GuiObject_ScriptMethods::clientToScreenH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar h) {
- SCRIPT_FUNCTION_INIT;
- int v=0;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) {
- ifc_window *w = g->guiobject_getRootWnd();
- if (w != NULL) {
- v = GET_SCRIPT_INT(h);
- double rr = w->getRenderRatio();
- v = (int)((double)(v) * rr);
- }
- }
- return MAKE_SCRIPT_INT(v);
- }
- scriptVar GuiObject_ScriptMethods::screenToClientX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x) {
- SCRIPT_FUNCTION_INIT;
- int v=0;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) {
- ifc_window *w = g->guiobject_getRootWnd();
- if (w != NULL) {
- v = GET_SCRIPT_INT(x);
- w->screenToClient(&v, NULL);
- }
- }
- return MAKE_SCRIPT_INT(v);
- }
- scriptVar GuiObject_ScriptMethods::screenToClientY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar y) {
- SCRIPT_FUNCTION_INIT;
- int v=0;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) {
- ifc_window *w = g->guiobject_getRootWnd();
- if (w != NULL) {
- v = GET_SCRIPT_INT(y);
- w->screenToClient(NULL, &v);
- }
- }
- return MAKE_SCRIPT_INT(v);
- }
- scriptVar GuiObject_ScriptMethods::screenToClientW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar w) {
- SCRIPT_FUNCTION_INIT;
- int v=0;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) {
- ifc_window *wn = g->guiobject_getRootWnd();
- if (wn != NULL) {
- v = GET_SCRIPT_INT(w);
- double rr = wn->getRenderRatio();
- v = (int)((double)(v) / rr);
- }
- }
- return MAKE_SCRIPT_INT(v);
- }
- scriptVar GuiObject_ScriptMethods::screenToClientH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar h) {
- SCRIPT_FUNCTION_INIT;
- int v=0;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) {
- ifc_window *w = g->guiobject_getRootWnd();
- if (w != NULL) {
- v = GET_SCRIPT_INT(h);
- double rr = w->getRenderRatio();
- v = (int)((double)(v) / rr);
- }
- }
- return MAKE_SCRIPT_INT(v);
- }
- scriptVar GuiObject_ScriptMethods::isActive(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) {
- ifc_window *w = (static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid)))->guiobject_getRootWnd();
- if (w) return MAKE_SCRIPT_INT(w->isActive());
- }
- RETURN_SCRIPT_ZERO;
- }
- scriptVar GuiObject_ScriptMethods::getParent(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *go = (static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid)));
- if (go) {
- GuiObject *g = go->guiobject_getParent();
- ScriptObject *so = NULL;
- if (g != NULL)
- so = g->guiobject_getScriptObject();
- return MAKE_SCRIPT_OBJECT(so);
- }
- RETURN_SCRIPT_VOID;
- }
- #ifdef WASABI_COMPILE_WNDMGR
- scriptVar GuiObject_ScriptMethods::getParentLayout(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *go = (static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid)));
- if (go) {
- Layout *l = go->guiobject_getParentLayout();
- return MAKE_SCRIPT_OBJECT(l ? l->getGuiObject()->guiobject_getScriptObject() : NULL);
- }
- RETURN_SCRIPT_VOID;
- }
- #endif
- scriptVar GuiObject_ScriptMethods::getTopParent(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *go = (static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid)));
- if (go) {
- GuiObject *l = go->guiobject_getTopParent();
- return MAKE_SCRIPT_OBJECT(l ? l->guiobject_getScriptObject() : NULL);
- }
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::getAutoWidth(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *go = (static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid)));
- int v = 0;
- if (go) { v = go->guiobject_getRootWnd()->getPreferences(SUGGESTED_W); if (v == AUTOWH) v = go->guiobject_getAutoWidth(); }
- return MAKE_SCRIPT_INT(v);
- }
- scriptVar GuiObject_ScriptMethods::getAutoHeight(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *go = (static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid)));
- int v = 0;
- if (go) { v = go->guiobject_getRootWnd()->getPreferences(SUGGESTED_H); if (v == AUTOWH) v = go->guiobject_getAutoHeight(); }
- return MAKE_SCRIPT_INT(v);
- }
- scriptVar GuiObject_ScriptMethods::init(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar parentGroup) {
- SCRIPT_FUNCTION_INIT;
- ASSERT(parentGroup.data.odata != NULL);
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) {
- Group *pg = static_cast<Group *>(GET_SCRIPT_OBJECT_AS(parentGroup, groupGuid));
- pg->addChild(g);
- if (!g->guiobject_getRootWnd()->isInited())
- g->guiobject_getRootWnd()->init(pg);
- }
- RETURN_SCRIPT_VOID;
- }
- #ifdef WASABI_COMPILE_WNDMGR
- scriptVar GuiObject_ScriptMethods::runModal(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- int r=0;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) r = g->guiobject_runModal();
- return MAKE_SCRIPT_INT(r);
- }
- scriptVar GuiObject_ScriptMethods::endModal(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar retcode) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) g->guiobject_endModal(GET_SCRIPT_INT(retcode));
- RETURN_SCRIPT_VOID;
- }
- #endif
- scriptVar GuiObject_ScriptMethods::setFocus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) {
- ifc_window *w = g->guiobject_getRootWnd();
- if (w != NULL) {
- w->setFocus();
- }
- }
- RETURN_SCRIPT_VOID;
- }
- #ifdef WASABI_COMPILE_WNDMGR
- scriptVar GuiObject_ScriptMethods::popParentLayout(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) g->guiobject_popParentLayout();
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::setStatusText(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar text, scriptVar overlay) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g)
- g->guiobject_setStatusText(GET_SCRIPT_STRING(text), GET_SCRIPT_INT(overlay));
- RETURN_SCRIPT_VOID;
- }
- #endif
- scriptVar GuiObject_ScriptMethods::findObject(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar id) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- ScriptObject *s = NULL;
- if (g) {
- GuiObject *o = g->guiobject_findObject(GET_SCRIPT_STRING(id));
- if (o != NULL) s = o->guiobject_getScriptObject();
- }
- return MAKE_SCRIPT_OBJECT(s);
- }
- scriptVar GuiObject_ScriptMethods::findObjectXY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- ScriptObject *s = NULL;
- if (g) {
- GuiObject *o = g->guiobject_findObjectXY(GET_SCRIPT_INT(x), GET_SCRIPT_INT(y));
- if (o != NULL) s = o->guiobject_getScriptObject();
- }
- return MAKE_SCRIPT_OBJECT(s);
- }
- scriptVar GuiObject_ScriptMethods::getName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
- {
- SCRIPT_FUNCTION_INIT;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g)
- return MAKE_SCRIPT_STRING(g->guiobject_getName());
- return MAKE_SCRIPT_STRING(L"");
- }
- scriptVar GuiObject_ScriptMethods::getMover(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- int r = 0;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) r = g->guiobject_getMover();
- return MAKE_SCRIPT_INT(r);
- }
- scriptVar GuiObject_ScriptMethods::setMover(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i) {
- SCRIPT_FUNCTION_INIT;
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- if (g) g->guiobject_setMover(GET_SCRIPT_INT(i));
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::setDropTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar targ) {
- GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid));
- const wchar_t *s = GET_SCRIPT_STRING(targ);
- if (g)
- g->guiobject_setDropTarget(s);
- RETURN_SCRIPT_VOID;
- }
- #ifdef WASABI_COMPILE_CONFIG
- scriptVar GuiObject_ScriptMethods::cfgGetInt(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT
- GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
- if (go) return MAKE_SCRIPT_INT(go->guiobject_getCfgInt());
- return MAKE_SCRIPT_INT(0);
- }
- scriptVar GuiObject_ScriptMethods::cfgSetInt(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v) {
- SCRIPT_FUNCTION_INIT
- ASSERT(SOM::isNumeric(&v));
- GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
- if (go) go->guiobject_setCfgInt(GET_SCRIPT_INT(v));
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::cfgGetString(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT
- GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
- if (go)
- return MAKE_SCRIPT_STRING(go->guiobject_getCfgString());
- return MAKE_SCRIPT_STRING(L"");
- }
- scriptVar GuiObject_ScriptMethods::cfgSetString(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v) {
- SCRIPT_FUNCTION_INIT
- GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
- if (go) go->guiobject_setCfgString(GET_SCRIPT_STRING(v));
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::cfgGetFloat(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT
- GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
- if (go) return MAKE_SCRIPT_FLOAT(go->guiobject_getCfgFloat());
- return MAKE_SCRIPT_FLOAT(0);
- }
- scriptVar GuiObject_ScriptMethods::cfgSetFloat(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v) {
- SCRIPT_FUNCTION_INIT
- GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
- if (go) go->guiobject_setCfgFloat(GET_SCRIPT_FLOAT(v));
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::cfgGetGuid(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT
- GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
- if (go) {
- CfgItem *i = go->guiobject_getCfgItem();
- if (i != NULL)
- {
- GUID guid = i->getGuid();
- nsGUID::toCharW(guid, txt);
- return MAKE_SCRIPT_STRING(txt);
- }
- }
- return MAKE_SCRIPT_STRING(L"");
- }
- scriptVar GuiObject_ScriptMethods::cfgGetAttributeName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT
- GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
- if (go)
- return MAKE_SCRIPT_STRING(go->guiobject_getCfgAttrib());
- return MAKE_SCRIPT_STRING(L"");
- }
- #endif
- scriptVar GuiObject_ScriptMethods::isMouseOverRect(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT
- GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
- int r = 0;
- if (go) {
- ifc_window *w = go->guiobject_getRootWnd();
- if (w != NULL) {
- RECT rc;
- int x, y;
- w->getWindowRect(&rc);
- Wasabi::Std::getMousePos(&x, &y);
- if (x >= rc.left && x <= rc.right && y >= rc.top && y <= rc.bottom) r = 1;
- }
- }
- return MAKE_SCRIPT_BOOLEAN(r);
- }
- #ifdef WASABI_COMPILE_CONFIG
- scriptVar GuiObject_ScriptMethods::onCfgChanged(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS0(o, guiController);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT0(o);
- }
- #endif
- scriptVar GuiObject_ScriptMethods::onChar(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar c) {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS1(o, guiController, c);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT1(o, c);
- }
- scriptVar GuiObject_ScriptMethods::onKeyDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar c) {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS1(o, guiController, c);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT1(o, c);
- }
- scriptVar GuiObject_ScriptMethods::onKeyUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar c) {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS1(o, guiController, c);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT1(o, c);
- }
- scriptVar GuiObject_ScriptMethods::onGetFocus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS0(o, guiController);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT0(o);
- }
- scriptVar GuiObject_ScriptMethods::onKillFocus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS0(o, guiController);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT0(o);
- }
- scriptVar GuiObject_ScriptMethods::sendAction(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar action, scriptVar param, scriptVar x, scriptVar y, scriptVar p1, scriptVar p2) {
- SCRIPT_FUNCTION_INIT
- GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid));
- int a = 0;
- if (go) {
- ifc_window *w = go->guiobject_getRootWnd();
- if (w!=NULL) {
- 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));
- }
- }
- return MAKE_SCRIPT_INT(a);
- }
- scriptVar GuiObject_ScriptMethods::onAccelerator(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar accel) {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS1(o, guiController, accel);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT1(o, accel);
- }
- scriptVar GuiObject_ScriptMethods::onAction(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar action, scriptVar param, scriptVar x, scriptVar y, scriptVar p1, scriptVar p2, scriptVar source) {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS7(o, guiController, action, param, x, y, p1, p2, source);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT7(o, action, param, x, y, p1, p2, source);
- }
- #ifdef WASABI_COMPILE_CONFIG
- int GuiObjectI::guiobject_getCfgInt()
- {
- if (!cfgitem)
- return 0;
- return
- cfgitem->getDataAsInt(cfgattrname);
- }
- void GuiObjectI::guiobject_setCfgInt(int i) {
- if (!cfgitem) return;
- cfgitem->setDataAsInt(cfgattrname, i);
- }
- float GuiObjectI::guiobject_getCfgFloat() {
- if (!cfgitem) return 0;
- return (float)cfgitem->getDataAsFloat(cfgattrname);
- }
- void GuiObjectI::guiobject_setCfgFloat(float f) {
- if (!cfgitem) return;
- cfgitem->setDataAsFloat(cfgattrname, f);
- }
- const wchar_t *GuiObjectI::guiobject_getCfgString()
- {
- static StringW blah;
- if (!cfgitem) return 0;
- cfgitem->getData(cfgattrname, txt, 4096);
- return txt;
- }
- void GuiObjectI::guiobject_setCfgString(const wchar_t *s)
- {
- if (!cfgitem)
- return;
- cfgitem->setData(cfgattrname, s);
- }
- void GuiObjectI::setCfgAttr(const wchar_t *strvalue)
- {
- ParamParser pp(strvalue);
- if (pp.getNumItems() < 2) return;
- GUID g = nsGUID::fromCharW(pp.enumItem(0));
- if (g == INVALID_GUID) return;
- CfgItem *i = WASABI_API_CONFIG->config_getCfgItemByGuid(g);
- if (i == NULL) return;
- cfgattrname = pp.enumItem(1);
- guiobject_setCfgAttrib(i, cfgattrname);
- }
- int GuiObjectI::guiobject_hasCfgAttrib() {
- return (guiobject_getCfgItem() && guiobject_getCfgAttrib());
- }
- #endif
- GuiObject *GuiObjectI::guiobject_findObject(const wchar_t *id)
- {
- ifc_window *me = guiobject_getRootWnd();
- ifc_window *w = me->findWindow(id);
- if (w != NULL) return w->getGuiObject();
- return NULL;
- }
- GuiObject *GuiObjectI::guiobject_findObjectXY(int x, int y) {
- ifc_window *me = guiobject_getRootWnd();
- POINT pt={x,y};
- me->clientToScreen((int *)&pt.x, (int *)&pt.y);
- ifc_window *w = WASABI_API_WND->rootWndFromPoint(&pt);
- if (w != NULL) return w->getGuiObject();
- return NULL;
- }
- GuiObject *GuiObjectI::guiobject_findObjectByInterface(GUID interface_guid) {
- ifc_window *me = guiobject_getRootWnd();
- ifc_window *w = me->findWindowByInterface(interface_guid);
- if (w != NULL) return w->getGuiObject();
- return NULL;
- }
- GuiObject *GuiObjectI::guiobject_findObjectByCallback(FindObjectCallback *cb) {
- ifc_window *me = guiobject_getRootWnd();
- ifc_window *w = me->findWindowByCallback(cb);
- if (w != NULL) return w->getGuiObject();
- return NULL;
- }
- void GuiObjectI::guiobject_onAccelerator(const wchar_t *accel)
- {
- GuiObject_ScriptMethods::onAccelerator(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_STRING(accel));
- }
- 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)
- {
- GuiObject *gsourceobj = (source == NULL) ? NULL : source->getGuiObject();
- ScriptObject *sourceobj = (gsourceobj == NULL) ? NULL : gsourceobj->guiobject_getScriptObject();
- 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));
- return 1;
- }
- void GuiObjectI::guiobject_setTabOrder(int a) {
- ifc_window *me = guiobject_getRootWnd();
- me->setTabOrder(a);
- }
- void GuiObjectI::guiobject_onInit() {
- // api_window *me = guiobject_getRootWnd();
- // nothing to do here anymore, for now
- return;
- }
- int GuiObjectI::guiobject_wantFocus() {
- return wantfocus;
- }
- void GuiObjectI::guiobject_setNoDoubleClick(int no) {
- ifc_window *w = guiobject_getRootWnd();
- if (w != NULL)
- w->setNoDoubleClicks(no);
- }
- void GuiObjectI::guiobject_setNoLeftClick(int no) {
- ifc_window *w = guiobject_getRootWnd();
- if (w != NULL)
- w->setNoLeftClicks(no);
- }
- void GuiObjectI::guiobject_setNoRightClick(int no) {
- ifc_window *w = guiobject_getRootWnd();
- if (w != NULL)
- w->setNoRightClicks(no);
- }
- void GuiObjectI::guiobject_setNoMouseMove(int no) {
- ifc_window *w = guiobject_getRootWnd();
- if (w != NULL)
- w->setNoMouseMoves(no);
- }
- void GuiObjectI::guiobject_setNoContextMenu(int no) {
- ifc_window *w = guiobject_getRootWnd();
- if (w != NULL)
- w->setNoContextMenus(no);
- }
- scriptVar GuiObject_ScriptMethods::getInterface(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar guid) {
- SCRIPT_FUNCTION_INIT;
- int type=-1;
- GUID _g = nsGUID::fromCharW(GET_SCRIPT_STRING(guid));
- void *i = o->vcpu_getInterface(_g, &type);
- if (i != NULL && type == INTERFACE_SCRIPTOBJECT) {
- return MAKE_SCRIPT_OBJECT(reinterpret_cast<ScriptObject*>(i));
- }
- RETURN_SCRIPT_VOID;
- }
- scriptVar GuiObject_ScriptMethods::onDragEnter(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
- {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS0(o, guiController);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT0(o);
- }
- scriptVar GuiObject_ScriptMethods::onDragOver(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y)
- {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS2(o, guiController, x, y);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT2(o, x, y);
- }
- scriptVar GuiObject_ScriptMethods::onDragLeave(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
- {
- SCRIPT_FUNCTION_INIT;
- PROCESS_HOOKS0(o, guiController);
- SCRIPT_FUNCTION_CHECKABORTEVENT;
- SCRIPT_EXEC_EVENT0(o);
- }
|