1
0

xuitree.cpp 77 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644
  1. #include <precomp.h>
  2. #include "xuitree.h"
  3. #include <api/service/svc_enum.h>
  4. #include <bfc/parse/hierarchyparser.h>
  5. #include <api/script/scriptguid.h>
  6. #include <api/skin/feeds/TextFeedEnum.h>
  7. // The temporary memory buffer to hold our string returns.
  8. StringW GuiTreeScriptController::staticStr;
  9. class ScriptTreeItem;
  10. // -----------------------------------------------------------------------
  11. // class TreeItemScript -- This is the tree item type inserted into
  12. // the tree if a script or XML piece is inserting items into the tree.
  13. class TreeItemScript : public TreeItem
  14. {
  15. public:
  16. TreeItemScript(const wchar_t *label = NULL, ScriptTreeItem *_scriptitem = NULL) : scriptitem(_scriptitem), TreeItem(label)
  17. {}
  18. virtual ~TreeItemScript()
  19. {}
  20. virtual void onTreeAdd()
  21. {
  22. if (scriptitem) TreeItemScriptController::treeitem_onTreeAdd(SCRIPT_CALL, scriptitem->getScriptObject());
  23. }
  24. virtual void onTreeRemove()
  25. {
  26. if (scriptitem) TreeItemScriptController::treeitem_onTreeRemove(SCRIPT_CALL, scriptitem->getScriptObject());
  27. }
  28. virtual void onSelect()
  29. {
  30. if (scriptitem) TreeItemScriptController::treeitem_onSelect(SCRIPT_CALL, scriptitem->getScriptObject());
  31. }
  32. virtual void onDeselect()
  33. {
  34. if (scriptitem) TreeItemScriptController::treeitem_onDeselect(SCRIPT_CALL, scriptitem->getScriptObject());
  35. }
  36. virtual int onLeftDoubleClick()
  37. {
  38. scriptVar retval;
  39. if (scriptitem)
  40. retval = TreeItemScriptController::treeitem_onLeftDoubleClick(SCRIPT_CALL, scriptitem->getScriptObject());
  41. if ((retval.type == SCRIPT_VOID)
  42. || (retval.type == SCRIPT_OBJECT)
  43. || (retval.type == SCRIPT_STRING))
  44. return 0;
  45. return GET_SCRIPT_INT(retval);
  46. }
  47. virtual int onRightDoubleClick()
  48. {
  49. scriptVar retval;
  50. if (scriptitem) retval = TreeItemScriptController::treeitem_onRightDoubleClick(SCRIPT_CALL, scriptitem->getScriptObject());
  51. if ((retval.type == SCRIPT_VOID) || (retval.type == SCRIPT_OBJECT) || (retval.type == SCRIPT_STRING)) return 0;
  52. return GET_SCRIPT_INT(retval);
  53. }
  54. // return 1 if you eat the key
  55. virtual int onChar(UINT key)
  56. {
  57. scriptVar retval;
  58. if (scriptitem) retval = TreeItemScriptController::treeitem_onChar(SCRIPT_CALL, scriptitem->getScriptObject(), MAKE_SCRIPT_INT(key));
  59. if ((retval.type == SCRIPT_VOID) || (retval.type == SCRIPT_OBJECT) || (retval.type == SCRIPT_STRING)) return 0;
  60. return GET_SCRIPT_INT(retval);
  61. }
  62. // these are called after the expand/collapse happens
  63. virtual void onExpand()
  64. {
  65. if (scriptitem) TreeItemScriptController::treeitem_onExpand(SCRIPT_CALL, scriptitem->getScriptObject());
  66. }
  67. virtual void onCollapse()
  68. {
  69. if (scriptitem) TreeItemScriptController::treeitem_onCollapse(SCRIPT_CALL, scriptitem->getScriptObject());
  70. }
  71. virtual int onBeginLabelEdit()
  72. {
  73. scriptVar retval;
  74. if (scriptitem) retval = TreeItemScriptController::treeitem_onBeginLabelEdit(SCRIPT_CALL, scriptitem->getScriptObject());
  75. int retv = 0;
  76. if ((retval.type == SCRIPT_VOID) || (retval.type == SCRIPT_OBJECT) || (retval.type == SCRIPT_STRING))
  77. {
  78. retv = -1;
  79. }
  80. if (!retv)
  81. {
  82. retv = GET_SCRIPT_INT(retval);
  83. }
  84. if (retv < 1)
  85. {
  86. retv = TreeItem::onBeginLabelEdit();
  87. }
  88. return retv;
  89. }
  90. virtual int onEndLabelEdit(const wchar_t *newlabel)
  91. {
  92. scriptVar retval;
  93. if (scriptitem)
  94. retval = TreeItemScriptController::treeitem_onEndLabelEdit(SCRIPT_CALL, scriptitem->getScriptObject(), MAKE_SCRIPT_STRING(newlabel));
  95. int retv = 0;
  96. if ((retval.type == SCRIPT_VOID) || (retval.type == SCRIPT_OBJECT) || (retval.type == SCRIPT_STRING))
  97. {
  98. retv = -1;
  99. }
  100. if (!retv)
  101. {
  102. retv = GET_SCRIPT_INT(retval);
  103. }
  104. if (retv < 1)
  105. {
  106. retv = TreeItem::onEndLabelEdit(newlabel);
  107. }
  108. return retv;
  109. }
  110. virtual int onContextMenu(int x, int y)
  111. {
  112. scriptVar retval;
  113. if (scriptitem) retval = TreeItemScriptController::treeitem_onContextMenu(SCRIPT_CALL, scriptitem->getScriptObject(), MAKE_SCRIPT_INT(x), MAKE_SCRIPT_INT(y) );
  114. int retv = 0;
  115. if ((retval.type == SCRIPT_VOID) || (retval.type == SCRIPT_OBJECT) || (retval.type == SCRIPT_STRING))
  116. {
  117. retv = -1;
  118. }
  119. if (!retv)
  120. {
  121. retv = GET_SCRIPT_INT(retval);
  122. }
  123. if (retv < 1)
  124. {
  125. retv = TreeItem::onContextMenu(x, y);
  126. }
  127. return retv;
  128. }
  129. protected:
  130. ScriptTreeItem *scriptitem;
  131. };
  132. // -----------------------------------------------------------------------
  133. const wchar_t ScriptTreeXuiObjectStr[] = L"Tree"; // This is the xml tag
  134. char ScriptTreeXuiSvcName[] = "Tree xui object";
  135. XMLParamPair ScriptTree::params[] = {
  136. {SCRIPTTREE_CHILDTABS, L"CHILDTABS"},
  137. {SCRIPTTREE_EXPANDROOT, L"EXPANDROOT"},
  138. {SCRIPTTREE_FEED, L"FEED"},
  139. {SCRIPTTREE_SETITEMS, L"ITEMS"},
  140. {SCRIPTTREE_SORTED, L"SORTED"},
  141. };
  142. // -----------------------------------------------------------------------
  143. ScriptTree::ScriptTree()
  144. {
  145. getScriptObject()->vcpu_setInterface(guitreeGuid, (void *)static_cast<ScriptTree *>(this));
  146. getScriptObject()->vcpu_setClassName(L"GuiTree"); // this is the script class name
  147. getScriptObject()->vcpu_setController(guiTreeController);
  148. myxuihandle = newXuiHandle();
  149. CreateXMLParameters(myxuihandle);
  150. feed = NULL;
  151. childtabs = 1;
  152. expandroot = 1;
  153. }
  154. void ScriptTree::CreateXMLParameters(int master_handle)
  155. {
  156. //SCRIPTTREE_PARENT::CreateXMLParameters(master_handle);
  157. int numParams = sizeof(params) / sizeof(params[0]);
  158. hintNumberOfParams(myxuihandle, numParams);
  159. for (int i = 0;i < numParams;i++)
  160. addParam(myxuihandle, params[i], XUI_ATTRIBUTE_IMPLIED);
  161. }
  162. // -----------------------------------------------------------------------
  163. ScriptTree::~ScriptTree()
  164. {
  165. closeFeed();
  166. // Clean up the ScriptTreeItems owned by this guy.
  167. TreeItem *item = enumRootItem(0);
  168. while (item != NULL)
  169. {
  170. // Delete this item.
  171. ScriptTreeItem *dead = NULL;
  172. //if (TISC::g_scriptitems.getItem(item, &dead) && (dead != NULL))
  173. //{ // true if it found something.
  174. // TISC::g_scriptitems.delItem(item);
  175. // delete dead;
  176. // // DebugString(" === deleting tree item (%08X, %08X, %08X)\n", item, dead, this);
  177. // continue;
  178. //}
  179. auto it = TISC::g_scriptitems.find(item);
  180. if (TISC::g_scriptitems.end() != it)
  181. {
  182. dead = it->second;
  183. delete dead;
  184. TISC::g_scriptitems.erase(it);
  185. continue;
  186. }
  187. else
  188. {
  189. // DebugString(" !!! ORPHAN TREE ITEM (%08X, %08X, %08X)\n", item, 0, this);
  190. }
  191. // Figure out who the next item to process should be.
  192. // 1) Children first.
  193. TreeItem *child = item->getChild();
  194. if (child != NULL)
  195. {
  196. item = child;
  197. }
  198. else
  199. {
  200. // 2) Siblings next.
  201. TreeItem *sibling = item->getSibling();
  202. if (sibling != NULL)
  203. {
  204. item = sibling;
  205. }
  206. else
  207. {
  208. // 3) Zip up parent chain last.
  209. TreeItem *item_parent, *parent_sibling;
  210. item_parent = item->getParent();
  211. item = NULL; // at this point if we do not assign, we are NULL.
  212. while (item_parent != NULL)
  213. {
  214. parent_sibling = item_parent->getSibling();
  215. if (parent_sibling != NULL)
  216. {
  217. item = parent_sibling;
  218. break;
  219. }
  220. item_parent = item_parent->getParent();
  221. }
  222. // 4) Uhhh.... you're null. All done. Go home.
  223. }
  224. }
  225. }
  226. /*
  227. // delete all of our script items from g_scriptitems
  228. int i = 0;
  229. TreeItem *next = enumRootItem(0);
  230. while (next) { // go through all of our items
  231. ScriptTreeItem *dead = NULL;
  232. if (TISC::g_scriptitems.getItem(next, &dead) && (dead != NULL)) { // true if it found something.
  233. TISC::g_scriptitems.delItem(next);
  234. delete dead;
  235. // DebugString(" === deleting tree item (%08X, %08X)\n", next, dead);
  236. } else {
  237. // DebugString(" !!! ORPHAN TREE ITEM (%08X, %08X)\n", next, i);
  238. }
  239. TreeItem *next = enumAllItems(i++);
  240. }
  241. */
  242. // some items will wind up leaked into g_scriptitems, most likely.
  243. }
  244. // -----------------------------------------------------------------------
  245. int ScriptTree::setXuiParam(int xuihandle, int xmlattributeid, const wchar_t *xmlattributename, const wchar_t *value)
  246. {
  247. if (xuihandle != myxuihandle)
  248. return SCRIPTTREE_PARENT::setXuiParam(xuihandle, xmlattributeid, xmlattributename, value);
  249. switch (xmlattributeid)
  250. {
  251. case SCRIPTTREE_SETITEMS:
  252. items = value;
  253. fillFromParams();
  254. #ifdef WASABI_COMPILE_CONFIG
  255. if (getGuiObject()->guiobject_hasCfgAttrib())
  256. selectFromConfig();
  257. #endif
  258. break;
  259. case SCRIPTTREE_FEED:
  260. {
  261. closeFeed();
  262. openFeed(value);
  263. break;
  264. }
  265. case SCRIPTTREE_SORTED:
  266. {
  267. setSorted(WTOB(value));
  268. break;
  269. }
  270. case SCRIPTTREE_CHILDTABS:
  271. {
  272. childtabs = WTOI(value);
  273. break;
  274. }
  275. case SCRIPTTREE_EXPANDROOT:
  276. {
  277. expandRoot(WTOI(value));
  278. break;
  279. }
  280. default:
  281. return 0;
  282. }
  283. return 1;
  284. }
  285. // -----------------------------------------------------------------------
  286. int ScriptTree::onInit()
  287. {
  288. SCRIPTTREE_PARENT::onInit();
  289. fillFromParams();
  290. return 1;
  291. }
  292. // -----------------------------------------------------------------------
  293. int ScriptTree::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)
  294. {
  295. SCRIPTTREE_PARENT::onAction(action, param, x, y, p1, p2, data, datalen, source);
  296. if (!WCSICMP(action, L"get_selection"))
  297. {
  298. if (source != NULL)
  299. {
  300. StringW res(L"");
  301. // Hmmmmm..... multiselection trees?
  302. sendAction(source, L"set_selection", res);
  303. }
  304. }
  305. return 1;
  306. }
  307. // -----------------------------------------------------------------------
  308. ScriptTreeItem *ScriptTree::bindScriptTreeItem(TreeItem *item)
  309. {
  310. ASSERT(item != NULL);
  311. // find this tree item in our map of tree items.
  312. ScriptTreeItem *si = NULL;
  313. //TISC::g_scriptitems.getItem(item, &si);
  314. auto it = TISC::g_scriptitems.find(item);
  315. if (TISC::g_scriptitems.end() == it)
  316. {
  317. // if there was no scriptobject in our map already, make one
  318. // for this tree item and place it in our map.
  319. si = new ScriptTreeItem(item, this);
  320. TISC::g_scriptitems.insert({ item, si });
  321. }
  322. else
  323. {
  324. si = it->second;
  325. }
  326. return si;
  327. }
  328. // -----------------------------------------------------------------------
  329. int ScriptTree::destroyScriptTreeItem(ScriptTreeItem *item)
  330. {
  331. ASSERT(item != NULL);
  332. // find this tree item in our map of tree items.
  333. TreeItem *ti = item->getItem();
  334. if (ti)
  335. {
  336. ScriptTreeItem *check = NULL;
  337. //TISC::g_scriptitems.getItem(ti, &check); // this is a doublecheck on who owns who.
  338. auto it = TISC::g_scriptitems.find(ti);
  339. if (TISC::g_scriptitems.end() != it)
  340. {
  341. // remove the treeitem from the tree
  342. this->removeTreeItem(ti); // (removes without deleting)
  343. // remove the scripttreeitem from the map
  344. TISC::g_scriptitems.erase(it);
  345. // and delete.(phew! bomb disposal!)
  346. delete ti;
  347. delete item;
  348. return 1; // yes, we deleted it.
  349. }
  350. }
  351. return 0; // Not ours, don't wanna delete it. Someone else can Deal With It.
  352. }
  353. // -----------------------------------------------------------------------
  354. void ScriptTree::onSetVisible(int i)
  355. {
  356. SCRIPTTREE_PARENT::onSetVisible(i);
  357. }
  358. #ifdef WASABI_COMPILE_CONFIG
  359. // -----------------------------------------------------------------------
  360. int ScriptTree::onReloadConfig()
  361. {
  362. SCRIPTTREE_PARENT::onReloadConfig();
  363. selectFromConfig();
  364. return 1;
  365. }
  366. // -----------------------------------------------------------------------
  367. void ScriptTree::saveToConfig()
  368. {}
  369. // -----------------------------------------------------------------------
  370. void ScriptTree::selectFromConfig()
  371. {}
  372. #endif
  373. // -----------------------------------------------------------------------
  374. int ScriptTree::selectEntry(const wchar_t *e, int cb)
  375. {
  376. return -1;
  377. }
  378. // -----------------------------------------------------------------------
  379. void ScriptTree::expandRoot(int val)
  380. {
  381. if (val)
  382. {
  383. expandroot = 1;
  384. int count;
  385. TreeItem *rootitem;
  386. for (count = 0, rootitem = enumRootItem(count); rootitem; rootitem = enumRootItem(++count))
  387. {
  388. rootitem->expand();
  389. }
  390. }
  391. else
  392. {
  393. expandroot = 0;
  394. }
  395. }
  396. // -----------------------------------------------------------------------
  397. void ScriptTree::fillFromHPNode(HPNode *node, TreeItem *parent)
  398. {
  399. // Go through the given node's children and add items for them
  400. // to the corresponding parent item.
  401. int i, n = node->getNumChildren();
  402. for (i = 0; i < n; i++)
  403. {
  404. // Here's a child node
  405. HPNode *child_node = static_cast<HPNode *>(node->enumChild(i));
  406. // Make a script-aware tree item and script item to correspond to it, labelled with the child_node's name
  407. ScriptTreeItem *si = new ScriptTreeItem;
  408. TreeItem *child_item = new TreeItemScript((*child_node)(), si);
  409. si->setItem(child_item);
  410. si->setScriptTree(this);
  411. // Add the script and tree items to the scriptitems map
  412. TISC::g_scriptitems.insert({ child_item, si });
  413. // DebugString(StringPrintf(" === NEW NODE ITEM (%08X, %08X, %08X)\n", child_item, si, this);
  414. // Add the child item to either ourselves or the given parent.
  415. addTreeItem(child_item, parent, getSorted(), childtabs);
  416. // And then continue to fill from that node.
  417. fillFromHPNode(child_node, child_item);
  418. }
  419. }
  420. // -----------------------------------------------------------------------
  421. void ScriptTree::fillFromParams()
  422. {
  423. deleteAllItems();
  424. if (!items.isempty())
  425. {
  426. HierarchyParser hierarchy(items);
  427. fillFromHPNode(hierarchy.rootNode());
  428. }
  429. // If we want our roots opened, do so now.
  430. expandRoot(expandroot);
  431. }
  432. // -----------------------------------------------------------------------
  433. void ScriptTree::selectEntries(const wchar_t *entries, int cb)
  434. {}
  435. // -----------------------------------------------------------------------
  436. void ScriptTree::openFeed(const wchar_t *feedid)
  437. {
  438. if (!_wcsicmp(feedid, last_feed)) return ;
  439. feed = TextFeedEnum(feedid).getFirst();
  440. if (feed != NULL)
  441. {
  442. viewer_addViewItem(feed->getDependencyPtr());
  443. setXuiParam(myxuihandle, SCRIPTTREE_SETITEMS, L"items", feed->getFeedText(feedid));
  444. }
  445. last_feed = feedid;
  446. }
  447. // -----------------------------------------------------------------------
  448. void ScriptTree::closeFeed()
  449. {
  450. if (feed)
  451. {
  452. viewer_delViewItem(feed->getDependencyPtr());
  453. SvcEnum::release(feed);
  454. }
  455. feed = NULL;
  456. last_feed = L"";
  457. }
  458. // -----------------------------------------------------------------------
  459. int ScriptTree::viewer_onEvent(api_dependent *item, const GUID *classguid, int event, intptr_t param, void *ptr, size_t ptrlen)
  460. {
  461. if (feed == dynamic_guid_cast<svc_textFeed>(item, classguid))
  462. {
  463. if (event == svc_textFeed::Event_TEXTCHANGE)
  464. {
  465. setXuiParam(myxuihandle, SCRIPTTREE_SETITEMS, L"items", (const wchar_t *)ptr);
  466. return 1;
  467. }
  468. }
  469. return 0;
  470. }
  471. // -----------------------------------------------------------------------
  472. // Callback methods that send hooks into the Script system
  473. int ScriptTree::onLeftButtonDown(int x, int y)
  474. {
  475. scriptVar retval;
  476. retval = GuiTreeScriptController::guitree_onLeftButtonDown(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(x), MAKE_SCRIPT_INT(y) );
  477. int retv = 0;
  478. if ((retval.type == SCRIPT_VOID) || (retval.type == SCRIPT_OBJECT) || (retval.type == SCRIPT_STRING))
  479. {
  480. retv = -1;
  481. }
  482. if (!retv)
  483. {
  484. retv = GET_SCRIPT_INT(retval);
  485. }
  486. if (retv < 1)
  487. {
  488. retv = SCRIPTTREE_PARENT::onLeftButtonDown(x, y);
  489. }
  490. return retv;
  491. }
  492. int ScriptTree::onLeftButtonUp(int x, int y)
  493. {
  494. scriptVar retval;
  495. retval = GuiTreeScriptController::guitree_onLeftButtonUp(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(x), MAKE_SCRIPT_INT(y) );
  496. int retv = 0;
  497. if ((retval.type == SCRIPT_VOID) || (retval.type == SCRIPT_OBJECT) || (retval.type == SCRIPT_STRING))
  498. {
  499. retv = -1;
  500. }
  501. if (!retv)
  502. {
  503. retv = GET_SCRIPT_INT(retval);
  504. }
  505. if (retv < 1)
  506. {
  507. retv = SCRIPTTREE_PARENT::onLeftButtonUp(x, y);
  508. }
  509. return retv;
  510. }
  511. int ScriptTree::onRightButtonUp(int x, int y)
  512. {
  513. scriptVar retval;
  514. retval = GuiTreeScriptController::guitree_onRightButtonUp(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(x), MAKE_SCRIPT_INT(y) );
  515. int retv = 0;
  516. if ((retval.type == SCRIPT_VOID) || (retval.type == SCRIPT_OBJECT) || (retval.type == SCRIPT_STRING))
  517. {
  518. retv = -1;
  519. }
  520. if (!retv)
  521. {
  522. retv = GET_SCRIPT_INT(retval);
  523. }
  524. if (retv < 1)
  525. {
  526. retv = SCRIPTTREE_PARENT::onRightButtonUp(x, y);
  527. }
  528. return retv;
  529. }
  530. int ScriptTree::onMouseMove(int x, int y)
  531. {
  532. scriptVar retval;
  533. retval = GuiTreeScriptController::guitree_onMouseMove(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(x), MAKE_SCRIPT_INT(y) );
  534. int retv = 0;
  535. if ((retval.type == SCRIPT_VOID) || (retval.type == SCRIPT_OBJECT) || (retval.type == SCRIPT_STRING))
  536. {
  537. retv = -1;
  538. }
  539. if (!retv)
  540. {
  541. retv = GET_SCRIPT_INT(retval);
  542. }
  543. if (retv < 1)
  544. {
  545. retv = SCRIPTTREE_PARENT::onMouseMove(x, y);
  546. }
  547. return retv;
  548. }
  549. int ScriptTree::wantAutoContextMenu()
  550. {
  551. scriptVar retval;
  552. retval = GuiTreeScriptController::guitree_wantAutoContextMenu(SCRIPT_CALL, getScriptObject() );
  553. int retv = 0;
  554. if ((retval.type == SCRIPT_VOID) || (retval.type == SCRIPT_OBJECT) || (retval.type == SCRIPT_STRING))
  555. {
  556. retv = -1;
  557. }
  558. if (!retv)
  559. {
  560. retv = GET_SCRIPT_INT(retval);
  561. }
  562. if (retv < 1)
  563. {
  564. retv = SCRIPTTREE_PARENT::wantAutoContextMenu();
  565. }
  566. return retv;
  567. }
  568. int ScriptTree::onLeftButtonDblClk(int x, int y)
  569. {
  570. scriptVar retval;
  571. retval = GuiTreeScriptController::guitree_onLeftButtonDblClk(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(x), MAKE_SCRIPT_INT(y) );
  572. int retv = 0;
  573. if ((retval.type == SCRIPT_VOID) || (retval.type == SCRIPT_OBJECT) || (retval.type == SCRIPT_STRING))
  574. {
  575. retv = -1;
  576. }
  577. if (!retv)
  578. {
  579. retv = GET_SCRIPT_INT(retval);
  580. }
  581. if (retv < 1)
  582. {
  583. retv = SCRIPTTREE_PARENT::onLeftButtonDblClk(x, y);
  584. }
  585. return retv;
  586. }
  587. int ScriptTree::onRightButtonDblClk(int x, int y)
  588. {
  589. scriptVar retval;
  590. retval = GuiTreeScriptController::guitree_onRightButtonDblClk(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(x), MAKE_SCRIPT_INT(y) );
  591. int retv = 0;
  592. if ((retval.type == SCRIPT_VOID) || (retval.type == SCRIPT_OBJECT) || (retval.type == SCRIPT_STRING))
  593. {
  594. retv = -1;
  595. }
  596. if (!retv)
  597. {
  598. retv = GET_SCRIPT_INT(retval);
  599. }
  600. if (retv < 1)
  601. {
  602. retv = SCRIPTTREE_PARENT::onRightButtonDblClk(x, y);
  603. }
  604. return retv;
  605. }
  606. int ScriptTree::onMouseWheelUp(int clicked, int lines)
  607. {
  608. scriptVar retval;
  609. retval = GuiTreeScriptController::guitree_onMouseWheelUp(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(clicked), MAKE_SCRIPT_INT(lines) );
  610. int retv = 0;
  611. if ((retval.type == SCRIPT_VOID) || (retval.type == SCRIPT_OBJECT) || (retval.type == SCRIPT_STRING))
  612. {
  613. retv = -1;
  614. }
  615. if (!retv)
  616. {
  617. retv = GET_SCRIPT_INT(retval);
  618. }
  619. if (retv < 1)
  620. {
  621. retv = SCRIPTTREE_PARENT::onMouseWheelUp(clicked, lines);
  622. }
  623. return retv;
  624. }
  625. int ScriptTree::onMouseWheelDown(int clicked, int lines)
  626. {
  627. scriptVar retval;
  628. retval = GuiTreeScriptController::guitree_onMouseWheelDown(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(clicked), MAKE_SCRIPT_INT(lines) );
  629. int retv = 0;
  630. if ((retval.type == SCRIPT_VOID) || (retval.type == SCRIPT_OBJECT) || (retval.type == SCRIPT_STRING))
  631. {
  632. retv = -1;
  633. }
  634. if (!retv)
  635. {
  636. retv = GET_SCRIPT_INT(retval);
  637. }
  638. if (retv < 1)
  639. {
  640. retv = SCRIPTTREE_PARENT::onMouseWheelDown(clicked, lines);
  641. }
  642. return retv;
  643. }
  644. int ScriptTree::onContextMenu(int x, int y)
  645. {
  646. scriptVar retval;
  647. retval = GuiTreeScriptController::guitree_onContextMenu(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(x), MAKE_SCRIPT_INT(y) );
  648. int retv = 0;
  649. if ((retval.type == SCRIPT_VOID) || (retval.type == SCRIPT_OBJECT) || (retval.type == SCRIPT_STRING))
  650. {
  651. retv = -1;
  652. }
  653. if (!retv)
  654. {
  655. retv = GET_SCRIPT_INT(retval);
  656. }
  657. if (retv < 1)
  658. {
  659. retv = SCRIPTTREE_PARENT::onContextMenu(x, y);
  660. }
  661. return retv;
  662. }
  663. int ScriptTree::onChar(wchar_t c)
  664. {
  665. scriptVar retval;
  666. retval = GuiTreeScriptController::guitree_onChar(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(c));
  667. int retv = 0;
  668. if ((retval.type == SCRIPT_VOID) || (retval.type == SCRIPT_OBJECT) || (retval.type == SCRIPT_STRING))
  669. {
  670. retv = -1;
  671. }
  672. if (!retv)
  673. {
  674. retv = GET_SCRIPT_INT(retval);
  675. }
  676. if (retv < 1)
  677. {
  678. retv = SCRIPTTREE_PARENT::onChar(c);
  679. }
  680. return retv;
  681. }
  682. int ScriptTree::onKeyDown(int keycode)
  683. {
  684. scriptVar retval;
  685. retval = GuiTreeScriptController::guitree_onKeyDown(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(keycode) );
  686. int retv = 0;
  687. if ((retval.type == SCRIPT_VOID) || (retval.type == SCRIPT_OBJECT) || (retval.type == SCRIPT_STRING))
  688. {
  689. retv = -1;
  690. }
  691. if (!retv)
  692. {
  693. retv = GET_SCRIPT_INT(retval);
  694. }
  695. if (retv < 1)
  696. {
  697. retv = SCRIPTTREE_PARENT::onKeyDown(keycode);
  698. }
  699. return retv;
  700. }
  701. void ScriptTree::onItemRecvDrop(TreeItem *item)
  702. {
  703. ScriptTreeItem *sti_item = bindScriptTreeItem(item);
  704. GuiTreeScriptController::guitree_onItemRecvDrop(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_OBJECT(sti_item->getScriptObject()) );
  705. }
  706. void ScriptTree::onLabelChange(TreeItem *item)
  707. {
  708. ScriptTreeItem *sti_item = bindScriptTreeItem(item);
  709. GuiTreeScriptController::guitree_onLabelChange(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_OBJECT(sti_item->getScriptObject()) );
  710. }
  711. void ScriptTree::onItemSelected(TreeItem *item)
  712. {
  713. ScriptTreeItem *sti_item = bindScriptTreeItem(item);
  714. GuiTreeScriptController::guitree_onItemSelected(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_OBJECT(sti_item->getScriptObject()) );
  715. }
  716. void ScriptTree::onItemDeselected(TreeItem *item)
  717. {
  718. ScriptTreeItem *sti_item = bindScriptTreeItem(item);
  719. GuiTreeScriptController::guitree_onItemDeselected(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_OBJECT(sti_item->getScriptObject()) );
  720. }
  721. int ScriptTree::onKillFocus()
  722. {
  723. scriptVar retval;
  724. retval = GuiTreeScriptController::guitree_onKillFocus(SCRIPT_CALL, getScriptObject() );
  725. int retv = 0;
  726. if ((retval.type == SCRIPT_VOID) || (retval.type == SCRIPT_OBJECT) || (retval.type == SCRIPT_STRING))
  727. {
  728. retv = -1;
  729. }
  730. if (!retv)
  731. {
  732. retv = GET_SCRIPT_INT(retval);
  733. }
  734. if (retv < 1)
  735. {
  736. retv = SCRIPTTREE_PARENT::onKillFocus();
  737. }
  738. return retv;
  739. }
  740. // -----------------------------------------------------------------------
  741. // Script Object
  742. GuiTreeScriptController _guiTreeController;
  743. GuiTreeScriptController *guiTreeController = &_guiTreeController;
  744. // -- Functions table -------------------------------------
  745. function_descriptor_struct GuiTreeScriptController::exportedFunction[] = {
  746. {L"getNumRootItems", 0, (void*)GuiTreeScriptController::guitree_getNumRootItems },
  747. {L"enumRootItem", 1, (void*)GuiTreeScriptController::guitree_enumRootItem },
  748. {L"onLeftButtonDown", 2, (void*)GuiTreeScriptController::guitree_onLeftButtonDown }, // , /*Int*/ scriptVar x, /*Int*/ scriptVar y);
  749. {L"onLeftButtonUp", 2, (void*)GuiTreeScriptController::guitree_onLeftButtonUp }, // , /*Int*/ scriptVar x, /*Int*/ scriptVar y);
  750. {L"onRightButtonUp", 2, (void*)GuiTreeScriptController::guitree_onRightButtonUp }, // , /*Int*/ scriptVar x, /*Int*/ scriptVar y);
  751. {L"onMouseMove", 2, (void*)GuiTreeScriptController::guitree_onMouseMove }, // , /*Int*/ scriptVar x, /*Int*/ scriptVar y);
  752. {L"onWantAutoContextMenu", 0, (void*)GuiTreeScriptController::guitree_wantAutoContextMenu }, // );
  753. {L"onLeftButtonDblClk", 2, (void*)GuiTreeScriptController::guitree_onLeftButtonDblClk }, // , /*Int*/ scriptVar x, /*Int*/ scriptVar y);
  754. {L"onRightButtonDblClk", 2, (void*)GuiTreeScriptController::guitree_onRightButtonDblClk }, // , /*Int*/ scriptVar x, /*Int*/ scriptVar y);
  755. {L"onMouseWheelUp", 2, (void*)GuiTreeScriptController::guitree_onMouseWheelUp }, // , /*Int*/ scriptVar clicked, /*Int*/ scriptVar lines);
  756. {L"onMouseWheelDown", 2, (void*)GuiTreeScriptController::guitree_onMouseWheelDown }, // , /*Int*/ scriptVar clicked, /*Int*/ scriptVar lines);
  757. {L"onContextMenu", 2, (void*)GuiTreeScriptController::guitree_onContextMenu }, // , /*Int*/ scriptVar x, /*Int*/ scriptVar y);
  758. {L"onChar", 1, (void*)GuiTreeScriptController::guitree_onChar }, // , /*Int*/ scriptVar c);
  759. {L"onKeyDown", 1, (void*)GuiTreeScriptController::guitree_onKeyDown }, // , /*Int*/ scriptVar keycode);
  760. {L"onItemRecvDrop", 1, (void*)GuiTreeScriptController::guitree_onItemRecvDrop }, // , /*TreeItem*/ scriptVar item);
  761. {L"onLabelChange", 1, (void*)GuiTreeScriptController::guitree_onLabelChange }, // , /*TreeItem*/ scriptVar item);
  762. {L"onItemSelected", 1, (void*)GuiTreeScriptController::guitree_onItemSelected }, // , /*TreeItem*/ scriptVar item);
  763. {L"onItemDeselected", 1, (void*)GuiTreeScriptController::guitree_onItemDeselected }, // , /*TreeItem*/ scriptVar item);
  764. {L"onKillFocus", 0, (void*)GuiTreeScriptController::guitree_onKillFocus }, // );
  765. {L"jumpToNext", 1, (void*)GuiTreeScriptController::guitree_jumpToNext }, // , /*Int*/ scriptVar c);
  766. {L"ensureItemVisible", 1, (void*)GuiTreeScriptController::guitree_ensureItemVisible }, // , /*TreeItem*/ scriptVar item);
  767. {L"getContentsWidth", 0, (void*)GuiTreeScriptController::guitree_getContentsWidth }, // );
  768. {L"getContentsHeight", 0, (void*)GuiTreeScriptController::guitree_getContentsHeight }, // );
  769. {L"addTreeItem", 4, (void*)GuiTreeScriptController::guitree_addTreeItem }, // , /*TreeItem*/ scriptVar item, /*TreeItem*/ scriptVar par, /*Int*/ scriptVar sorted, /*Int*/ scriptVar haschildtab);
  770. {L"removeTreeItem", 1, (void*)GuiTreeScriptController::guitree_removeTreeItem }, // , /*TreeItem*/ scriptVar item);
  771. {L"moveTreeItem", 2, (void*)GuiTreeScriptController::guitree_moveTreeItem }, // , /*TreeItem*/ scriptVar item, /*TreeItem*/ scriptVar newparent);
  772. {L"deleteAllItems", 0, (void*)GuiTreeScriptController::guitree_deleteAllItems }, // );
  773. {L"expandItem", 1, (void*)GuiTreeScriptController::guitree_expandItem }, // , /*TreeItem*/ scriptVar item);
  774. {L"expandItemDeferred", 1, (void*)GuiTreeScriptController::guitree_expandItemDeferred }, // , /*TreeItem*/ scriptVar item);
  775. {L"collapseItem", 1, (void*)GuiTreeScriptController::guitree_collapseItem }, // , /*TreeItem*/ scriptVar item);
  776. {L"collapseItemDeferred", 1, (void*)GuiTreeScriptController::guitree_collapseItemDeferred }, // , /*TreeItem*/ scriptVar item);
  777. {L"selectItem", 1, (void*)GuiTreeScriptController::guitree_selectItem }, // , /*TreeItem*/ scriptVar item);
  778. {L"selectItemDeferred", 1, (void*)GuiTreeScriptController::guitree_selectItemDeferred }, // , /*TreeItem*/ scriptVar item);
  779. {L"delItemDeferred", 1, (void*)GuiTreeScriptController::guitree_delItemDeferred }, // , /*TreeItem*/ scriptVar item);
  780. {L"hiliteItem", 1, (void*)GuiTreeScriptController::guitree_hiliteItem }, // , /*TreeItem*/ scriptVar item);
  781. {L"unhiliteItem", 1, (void*)GuiTreeScriptController::guitree_unhiliteItem }, // , /*TreeItem*/ scriptVar item);
  782. {L"getCurItem", 0, (void*)GuiTreeScriptController::guitree_getCurItem }, // );
  783. {L"hitTest", 2, (void*)GuiTreeScriptController::guitree_hitTest }, // , /*Int*/ scriptVar x, /*Int*/ scriptVar y);
  784. {L"editItemLabel", 1, (void*)GuiTreeScriptController::guitree_editItemLabel }, // , /*TreeItem*/ scriptVar item);
  785. {L"cancelEditLabel", 1, (void*)GuiTreeScriptController::guitree_cancelEditLabel }, // , /*Int*/ scriptVar destroyit);
  786. {L"setAutoEdit", 1, (void*)GuiTreeScriptController::guitree_setAutoEdit }, // , /*Int*/ scriptVar ae);
  787. {L"getAutoEdit", 0, (void*)GuiTreeScriptController::guitree_getAutoEdit }, // );
  788. {L"getByLabel", 2, (void*)GuiTreeScriptController::guitree_getByLabel }, // , /*TreeItem*/ scriptVar item, /*String*/ scriptVar name);
  789. {L"setSorted", 1, (void*)GuiTreeScriptController::guitree_setSorted }, // , /*Int*/ scriptVar dosort);
  790. {L"getSorted", 0, (void*)GuiTreeScriptController::guitree_getSorted }, // );
  791. {L"sortTreeItems", 0, (void*)GuiTreeScriptController::guitree_sortTreeItems }, // );
  792. {L"getSibling", 1, (void*)GuiTreeScriptController::guitree_getSibling }, // , /*TreeItem*/ scriptVar item);
  793. {L"setAutoCollapse", 1, (void*)GuiTreeScriptController::guitree_setAutoCollapse }, // , /*Int*/ scriptVar doautocollapse);
  794. {L"setFontSize", 1, (void*)GuiTreeScriptController::guitree_setFontSize }, // , /*Int*/ scriptVar newsize);
  795. {L"getFontSize", 0, (void*)GuiTreeScriptController::guitree_getFontSize }, // );
  796. {L"getNumVisibleChildItems", 1, (void*)GuiTreeScriptController::guitree_getNumVisibleChildItems }, // , /*TreeItem*/ scriptVar c);
  797. {L"getNumVisibleItems", 0, (void*)GuiTreeScriptController::guitree_getNumVisibleItems }, // );
  798. {L"enumVisibleItems", 1, (void*)GuiTreeScriptController::guitree_enumVisibleItems }, // , /*Int*/ scriptVar n);
  799. {L"enumVisibleChildItems", 2, (void*)GuiTreeScriptController::guitree_enumVisibleChildItems }, // , /*TreeItem*/ scriptVar c, /*Int*/ scriptVar n);
  800. {L"enumAllItems", 1, (void*)GuiTreeScriptController::guitree_enumAllItems }, // , /*Int*/ scriptVar n);
  801. {L"getItemRectX", 1, (void*)GuiTreeScriptController::guitree_getItemRectX }, // , /*TreeItem*/ scriptVar item);
  802. {L"getItemRectY", 1, (void*)GuiTreeScriptController::guitree_getItemRectY }, // , /*TreeItem*/ scriptVar item);
  803. {L"getItemRectW", 1, (void*)GuiTreeScriptController::guitree_getItemRectW }, // , /*TreeItem*/ scriptVar item);
  804. {L"getItemRectH", 1, (void*)GuiTreeScriptController::guitree_getItemRectH }, // , /*TreeItem*/ scriptVar item);
  805. // {L"getItemFromPoint", 2, (void*)GuiTreeScriptController::guitree_getItemFromPoint }, // , /*Int*/ scriptVar x, /*Int*/ scriptVar y);
  806. };
  807. ScriptObject *GuiTreeScriptController::instantiate()
  808. {
  809. ScriptTree *sp = new ScriptTree;
  810. ASSERT(sp != NULL);
  811. return sp->getScriptObject();
  812. }
  813. void GuiTreeScriptController::destroy(ScriptObject *o)
  814. {
  815. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  816. ASSERT(sp != NULL);
  817. delete sp;
  818. }
  819. void *GuiTreeScriptController::encapsulate(ScriptObject *o)
  820. {
  821. return NULL; // no encapsulation for guitrees yet
  822. }
  823. void GuiTreeScriptController::deencapsulate(void *o)
  824. {}
  825. int GuiTreeScriptController::getNumFunctions()
  826. {
  827. return sizeof(exportedFunction) / sizeof(function_descriptor_struct);
  828. }
  829. const function_descriptor_struct *GuiTreeScriptController::getExportedFunctions()
  830. {
  831. return exportedFunction;
  832. }
  833. /*int*/ scriptVar GuiTreeScriptController::guitree_getNumRootItems(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  834. {
  835. SCRIPT_FUNCTION_INIT
  836. ScriptTree *sp = static_cast<ScriptTree*>(o->vcpu_getInterface(guitreeGuid));
  837. int a = 0;
  838. if (sp != NULL)
  839. {
  840. a = sp->getNumRootItems();
  841. }
  842. return MAKE_SCRIPT_INT(a);
  843. }
  844. /*TreeItem*/ scriptVar GuiTreeScriptController::guitree_enumRootItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar which)
  845. {
  846. SCRIPT_FUNCTION_INIT
  847. ScriptTree *sp = static_cast<ScriptTree*>(o->vcpu_getInterface(guitreeGuid));
  848. scriptVar retval = MAKE_SCRIPT_OBJECT(NULL);
  849. if (sp != NULL)
  850. {
  851. TreeItem *a = NULL;
  852. int _which = GET_SCRIPT_INT(which);
  853. a = sp->enumRootItem(_which);
  854. if (a != NULL)
  855. {
  856. ScriptTreeItem *item = sp->bindScriptTreeItem(a);
  857. if (item != NULL)
  858. {
  859. retval = MAKE_SCRIPT_OBJECT(item->getScriptObject());
  860. }
  861. }
  862. }
  863. return retval;
  864. }
  865. /*Int*/ scriptVar GuiTreeScriptController::guitree_onLeftButtonDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*Int*/ scriptVar x, /*Int*/ scriptVar y)
  866. {
  867. SCRIPT_FUNCTION_INIT
  868. PROCESS_HOOKS2(o, guiTreeController, x, y);
  869. SCRIPT_FUNCTION_CHECKABORTEVENT;
  870. SCRIPT_EXEC_EVENT2(o, x, y);
  871. }
  872. /*Int*/ scriptVar GuiTreeScriptController::guitree_onLeftButtonUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*Int*/ scriptVar x, /*Int*/ scriptVar y)
  873. {
  874. SCRIPT_FUNCTION_INIT
  875. PROCESS_HOOKS2(o, guiTreeController, x, y);
  876. SCRIPT_FUNCTION_CHECKABORTEVENT;
  877. SCRIPT_EXEC_EVENT2(o, x, y);
  878. }
  879. /*Int*/ scriptVar GuiTreeScriptController::guitree_onRightButtonUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*Int*/ scriptVar x, /*Int*/ scriptVar y)
  880. {
  881. SCRIPT_FUNCTION_INIT
  882. PROCESS_HOOKS2(o, guiTreeController, x, y);
  883. SCRIPT_FUNCTION_CHECKABORTEVENT;
  884. SCRIPT_EXEC_EVENT2(o, x, y);
  885. }
  886. /*Int*/ scriptVar GuiTreeScriptController::guitree_onMouseMove(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*Int*/ scriptVar x, /*Int*/ scriptVar y)
  887. {
  888. SCRIPT_FUNCTION_INIT
  889. PROCESS_HOOKS2(o, guiTreeController, x, y);
  890. SCRIPT_FUNCTION_CHECKABORTEVENT;
  891. SCRIPT_EXEC_EVENT2(o, x, y);
  892. }
  893. /*Int*/ scriptVar GuiTreeScriptController::guitree_wantAutoContextMenu(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  894. {
  895. SCRIPT_FUNCTION_INIT
  896. PROCESS_HOOKS0(o, guiTreeController);
  897. SCRIPT_FUNCTION_CHECKABORTEVENT;
  898. SCRIPT_EXEC_EVENT0(o);
  899. }
  900. /*Int*/ scriptVar GuiTreeScriptController::guitree_onLeftButtonDblClk(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*Int*/ scriptVar x, /*Int*/ scriptVar y)
  901. {
  902. SCRIPT_FUNCTION_INIT
  903. PROCESS_HOOKS2(o, guiTreeController, x, y);
  904. SCRIPT_FUNCTION_CHECKABORTEVENT;
  905. SCRIPT_EXEC_EVENT2(o, x, y);
  906. }
  907. /*Int*/ scriptVar GuiTreeScriptController::guitree_onRightButtonDblClk(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*Int*/ scriptVar x, /*Int*/ scriptVar y)
  908. {
  909. SCRIPT_FUNCTION_INIT
  910. PROCESS_HOOKS2(o, guiTreeController, x, y);
  911. SCRIPT_FUNCTION_CHECKABORTEVENT;
  912. SCRIPT_EXEC_EVENT2(o, x, y);
  913. }
  914. /*Int*/ scriptVar GuiTreeScriptController::guitree_onMouseWheelUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*Int*/ scriptVar clicked, /*Int*/ scriptVar lines)
  915. {
  916. SCRIPT_FUNCTION_INIT
  917. PROCESS_HOOKS2(o, guiTreeController, clicked, lines);
  918. SCRIPT_FUNCTION_CHECKABORTEVENT;
  919. SCRIPT_EXEC_EVENT2(o, clicked, lines);
  920. }
  921. /*Int*/ scriptVar GuiTreeScriptController::guitree_onMouseWheelDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*Int*/ scriptVar clicked, /*Int*/ scriptVar lines)
  922. {
  923. SCRIPT_FUNCTION_INIT
  924. PROCESS_HOOKS2(o, guiTreeController, clicked, lines);
  925. SCRIPT_FUNCTION_CHECKABORTEVENT;
  926. SCRIPT_EXEC_EVENT2(o, clicked, lines);
  927. }
  928. /*Int*/ scriptVar GuiTreeScriptController::guitree_onContextMenu(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*Int*/ scriptVar x, /*Int*/ scriptVar y)
  929. {
  930. SCRIPT_FUNCTION_INIT
  931. PROCESS_HOOKS2(o, guiTreeController, x, y);
  932. SCRIPT_FUNCTION_CHECKABORTEVENT;
  933. SCRIPT_EXEC_EVENT2(o, x, y);
  934. }
  935. /*Int*/ scriptVar GuiTreeScriptController::guitree_onChar(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*Int*/ scriptVar c)
  936. {
  937. SCRIPT_FUNCTION_INIT
  938. PROCESS_HOOKS1(o, guiTreeController, c);
  939. SCRIPT_FUNCTION_CHECKABORTEVENT;
  940. SCRIPT_EXEC_EVENT1(o, c);
  941. }
  942. /*Int*/ scriptVar GuiTreeScriptController::guitree_onKeyDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*Int*/ scriptVar keycode)
  943. {
  944. SCRIPT_FUNCTION_INIT
  945. PROCESS_HOOKS1(o, guiTreeController, keycode);
  946. SCRIPT_FUNCTION_CHECKABORTEVENT;
  947. SCRIPT_EXEC_EVENT1(o, keycode);
  948. }
  949. /*Void*/ scriptVar GuiTreeScriptController::guitree_onItemRecvDrop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*TreeItem*/ scriptVar item)
  950. {
  951. SCRIPT_FUNCTION_INIT
  952. PROCESS_HOOKS1(o, guiTreeController, item);
  953. SCRIPT_FUNCTION_CHECKABORTEVENT;
  954. SCRIPT_EXEC_EVENT1(o, item);
  955. }
  956. /*Void*/ scriptVar GuiTreeScriptController::guitree_onLabelChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*TreeItem*/ scriptVar item)
  957. {
  958. SCRIPT_FUNCTION_INIT
  959. PROCESS_HOOKS1(o, guiTreeController, item);
  960. SCRIPT_FUNCTION_CHECKABORTEVENT;
  961. SCRIPT_EXEC_EVENT1(o, item);
  962. }
  963. /*Void*/ scriptVar GuiTreeScriptController::guitree_onItemSelected(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*TreeItem*/ scriptVar item)
  964. {
  965. SCRIPT_FUNCTION_INIT
  966. PROCESS_HOOKS1(o, guiTreeController, item);
  967. SCRIPT_FUNCTION_CHECKABORTEVENT;
  968. SCRIPT_EXEC_EVENT1(o, item);
  969. }
  970. /*Void*/ scriptVar GuiTreeScriptController::guitree_onItemDeselected(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*TreeItem*/ scriptVar item)
  971. {
  972. SCRIPT_FUNCTION_INIT
  973. PROCESS_HOOKS1(o, guiTreeController, item);
  974. SCRIPT_FUNCTION_CHECKABORTEVENT;
  975. SCRIPT_EXEC_EVENT1(o, item);
  976. }
  977. /*Int*/ scriptVar GuiTreeScriptController::guitree_onKillFocus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  978. {
  979. SCRIPT_FUNCTION_INIT
  980. PROCESS_HOOKS0(o, guiTreeController);
  981. SCRIPT_FUNCTION_CHECKABORTEVENT;
  982. SCRIPT_EXEC_EVENT0(o);
  983. }
  984. // -------------------------------------------------------------------------
  985. /*Void*/ scriptVar GuiTreeScriptController::guitree_jumpToNext(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar c)
  986. {
  987. SCRIPT_FUNCTION_INIT
  988. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  989. int _c = GET_SCRIPT_INT(c);
  990. if (sp != NULL)
  991. {
  992. sp->jumpToNext(_c);
  993. }
  994. RETURN_SCRIPT_VOID;
  995. }
  996. /*Void*/ scriptVar GuiTreeScriptController::guitree_ensureItemVisible(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar item)
  997. {
  998. SCRIPT_FUNCTION_INIT
  999. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1000. TreeItem *_item = NULL;
  1001. ScriptObject *so_item = GET_SCRIPT_OBJECT(item);
  1002. if (so_item)
  1003. {
  1004. ScriptTreeItem *sti_item = static_cast<ScriptTreeItem *>(so_item->vcpu_getInterface(treeitemGuid));
  1005. if (sti_item)
  1006. {
  1007. _item = sti_item->getItem();
  1008. }
  1009. }
  1010. if (sp != NULL)
  1011. {
  1012. sp->ensureItemVisible(_item);
  1013. }
  1014. RETURN_SCRIPT_VOID;
  1015. }
  1016. /*Int*/ scriptVar GuiTreeScriptController::guitree_getContentsWidth(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  1017. {
  1018. SCRIPT_FUNCTION_INIT
  1019. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1020. scriptVar retval = MAKE_SCRIPT_INT(0);
  1021. if (sp != NULL)
  1022. {
  1023. int a = 0;
  1024. a = sp->getContentsWidth();
  1025. retval = MAKE_SCRIPT_INT(a);
  1026. }
  1027. return retval;
  1028. }
  1029. /*Int*/ scriptVar GuiTreeScriptController::guitree_getContentsHeight(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  1030. {
  1031. SCRIPT_FUNCTION_INIT
  1032. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1033. scriptVar retval = MAKE_SCRIPT_INT(0);
  1034. if (sp != NULL)
  1035. {
  1036. int a = 0;
  1037. a = sp->getContentsHeight();
  1038. retval = MAKE_SCRIPT_INT(a);
  1039. }
  1040. return retval;
  1041. }
  1042. /*TreeItem*/ scriptVar GuiTreeScriptController::guitree_addTreeItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar item, scriptVar par, scriptVar sorted, scriptVar haschildtab)
  1043. {
  1044. SCRIPT_FUNCTION_INIT
  1045. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1046. TreeItem *_par = NULL;
  1047. ScriptObject *so_par = GET_SCRIPT_OBJECT(par);
  1048. if (so_par)
  1049. {
  1050. ScriptTreeItem *sti_par = static_cast<ScriptTreeItem *>(so_par->vcpu_getInterface(treeitemGuid));
  1051. if (sti_par)
  1052. {
  1053. _par = sti_par->getItem();
  1054. }
  1055. }
  1056. TreeItem *_item = NULL;
  1057. ScriptObject *so_item = GET_SCRIPT_OBJECT(item);
  1058. if (so_item)
  1059. {
  1060. ScriptTreeItem *sti_item = static_cast<ScriptTreeItem *>(so_item->vcpu_getInterface(treeitemGuid));
  1061. if (sti_item)
  1062. {
  1063. _item = sti_item->getItem();
  1064. }
  1065. }
  1066. int _haschildtab = GET_SCRIPT_INT(haschildtab);
  1067. int _sorted = GET_SCRIPT_INT(sorted);
  1068. scriptVar retval = MAKE_SCRIPT_OBJECT(NULL);
  1069. if (sp != NULL)
  1070. {
  1071. TreeItem *a = NULL;
  1072. a = sp->addTreeItem(_item, _par, _sorted, _haschildtab);
  1073. if (a != NULL)
  1074. {
  1075. ScriptTreeItem *item = sp->bindScriptTreeItem(a);
  1076. if (item != NULL)
  1077. {
  1078. retval = MAKE_SCRIPT_OBJECT(item->getScriptObject());
  1079. }
  1080. }
  1081. }
  1082. return retval;
  1083. }
  1084. /*Int*/ scriptVar GuiTreeScriptController::guitree_removeTreeItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar item)
  1085. {
  1086. SCRIPT_FUNCTION_INIT
  1087. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1088. TreeItem *_item = NULL;
  1089. ScriptObject *so_item = GET_SCRIPT_OBJECT(item);
  1090. if (so_item)
  1091. {
  1092. ScriptTreeItem *sti_item = static_cast<ScriptTreeItem *>(so_item->vcpu_getInterface(treeitemGuid));
  1093. if (sti_item)
  1094. {
  1095. _item = sti_item->getItem();
  1096. }
  1097. }
  1098. scriptVar retval = MAKE_SCRIPT_INT(0);
  1099. if (sp != NULL)
  1100. {
  1101. int a = 0;
  1102. a = sp->removeTreeItem(_item);
  1103. retval = MAKE_SCRIPT_INT(a);
  1104. }
  1105. return retval;
  1106. }
  1107. /*Void*/ scriptVar GuiTreeScriptController::guitree_moveTreeItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar item, scriptVar newparent)
  1108. {
  1109. SCRIPT_FUNCTION_INIT
  1110. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1111. TreeItem *_newparent = NULL;
  1112. ScriptObject *so_newparent = GET_SCRIPT_OBJECT(newparent);
  1113. if (so_newparent)
  1114. {
  1115. ScriptTreeItem *sti_newparent = static_cast<ScriptTreeItem *>(so_newparent->vcpu_getInterface(treeitemGuid));
  1116. if (sti_newparent)
  1117. {
  1118. _newparent = sti_newparent->getItem();
  1119. }
  1120. }
  1121. TreeItem *_item = NULL;
  1122. ScriptObject *so_item = GET_SCRIPT_OBJECT(item);
  1123. if (so_item)
  1124. {
  1125. ScriptTreeItem *sti_item = static_cast<ScriptTreeItem *>(so_item->vcpu_getInterface(treeitemGuid));
  1126. if (sti_item)
  1127. {
  1128. _item = sti_item->getItem();
  1129. }
  1130. }
  1131. if (sp != NULL)
  1132. {
  1133. sp->moveTreeItem(_item, _newparent);
  1134. }
  1135. RETURN_SCRIPT_VOID;
  1136. }
  1137. /*Void*/ scriptVar GuiTreeScriptController::guitree_deleteAllItems(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  1138. {
  1139. SCRIPT_FUNCTION_INIT
  1140. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1141. if (sp != NULL)
  1142. {
  1143. sp->deleteAllItems();
  1144. }
  1145. RETURN_SCRIPT_VOID;
  1146. }
  1147. /*Int*/ scriptVar GuiTreeScriptController::guitree_expandItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar item)
  1148. {
  1149. SCRIPT_FUNCTION_INIT
  1150. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1151. TreeItem *_item = NULL;
  1152. ScriptObject *so_item = GET_SCRIPT_OBJECT(item);
  1153. if (so_item)
  1154. {
  1155. ScriptTreeItem *sti_item = static_cast<ScriptTreeItem *>(so_item->vcpu_getInterface(treeitemGuid));
  1156. if (sti_item)
  1157. {
  1158. _item = sti_item->getItem();
  1159. }
  1160. }
  1161. scriptVar retval = MAKE_SCRIPT_INT(0);
  1162. if (sp != NULL)
  1163. {
  1164. int a = 0;
  1165. a = sp->expandItem(_item);
  1166. retval = MAKE_SCRIPT_INT(a);
  1167. }
  1168. return retval;
  1169. }
  1170. /*Void*/ scriptVar GuiTreeScriptController::guitree_expandItemDeferred(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar item)
  1171. {
  1172. SCRIPT_FUNCTION_INIT
  1173. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1174. TreeItem *_item = NULL;
  1175. ScriptObject *so_item = GET_SCRIPT_OBJECT(item);
  1176. if (so_item)
  1177. {
  1178. ScriptTreeItem *sti_item = static_cast<ScriptTreeItem *>(so_item->vcpu_getInterface(treeitemGuid));
  1179. if (sti_item)
  1180. {
  1181. _item = sti_item->getItem();
  1182. }
  1183. }
  1184. if (sp != NULL)
  1185. {
  1186. sp->expandItemDeferred(_item);
  1187. }
  1188. RETURN_SCRIPT_VOID;
  1189. }
  1190. /*Int*/ scriptVar GuiTreeScriptController::guitree_collapseItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar item)
  1191. {
  1192. SCRIPT_FUNCTION_INIT
  1193. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1194. TreeItem *_item = NULL;
  1195. ScriptObject *so_item = GET_SCRIPT_OBJECT(item);
  1196. if (so_item)
  1197. {
  1198. ScriptTreeItem *sti_item = static_cast<ScriptTreeItem *>(so_item->vcpu_getInterface(treeitemGuid));
  1199. if (sti_item)
  1200. {
  1201. _item = sti_item->getItem();
  1202. }
  1203. }
  1204. scriptVar retval = MAKE_SCRIPT_INT(0);
  1205. if (sp != NULL)
  1206. {
  1207. int a = 0;
  1208. a = sp->collapseItem(_item);
  1209. retval = MAKE_SCRIPT_INT(a);
  1210. }
  1211. return retval;
  1212. }
  1213. /*Void*/ scriptVar GuiTreeScriptController::guitree_collapseItemDeferred(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar item)
  1214. {
  1215. SCRIPT_FUNCTION_INIT
  1216. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1217. TreeItem *_item = NULL;
  1218. ScriptObject *so_item = GET_SCRIPT_OBJECT(item);
  1219. if (so_item)
  1220. {
  1221. ScriptTreeItem *sti_item = static_cast<ScriptTreeItem *>(so_item->vcpu_getInterface(treeitemGuid));
  1222. if (sti_item)
  1223. {
  1224. _item = sti_item->getItem();
  1225. }
  1226. }
  1227. if (sp != NULL)
  1228. {
  1229. sp->collapseItemDeferred(_item);
  1230. }
  1231. RETURN_SCRIPT_VOID;
  1232. }
  1233. /*Void*/ scriptVar GuiTreeScriptController::guitree_selectItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar item)
  1234. {
  1235. SCRIPT_FUNCTION_INIT
  1236. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1237. TreeItem *_item = NULL;
  1238. ScriptObject *so_item = GET_SCRIPT_OBJECT(item);
  1239. if (so_item)
  1240. {
  1241. ScriptTreeItem *sti_item = static_cast<ScriptTreeItem *>(so_item->vcpu_getInterface(treeitemGuid));
  1242. if (sti_item)
  1243. {
  1244. _item = sti_item->getItem();
  1245. }
  1246. }
  1247. if (sp != NULL)
  1248. {
  1249. sp->selectItem(_item);
  1250. }
  1251. RETURN_SCRIPT_VOID;
  1252. }
  1253. /*Void*/ scriptVar GuiTreeScriptController::guitree_selectItemDeferred(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar item)
  1254. {
  1255. SCRIPT_FUNCTION_INIT
  1256. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1257. TreeItem *_item = NULL;
  1258. ScriptObject *so_item = GET_SCRIPT_OBJECT(item);
  1259. if (so_item)
  1260. {
  1261. ScriptTreeItem *sti_item = static_cast<ScriptTreeItem *>(so_item->vcpu_getInterface(treeitemGuid));
  1262. if (sti_item)
  1263. {
  1264. _item = sti_item->getItem();
  1265. }
  1266. }
  1267. if (sp != NULL)
  1268. {
  1269. sp->selectItemDeferred(_item);
  1270. }
  1271. RETURN_SCRIPT_VOID;
  1272. }
  1273. /*Void*/ scriptVar GuiTreeScriptController::guitree_delItemDeferred(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar item)
  1274. {
  1275. SCRIPT_FUNCTION_INIT
  1276. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1277. TreeItem *_item = NULL;
  1278. ScriptObject *so_item = GET_SCRIPT_OBJECT(item);
  1279. if (so_item)
  1280. {
  1281. ScriptTreeItem *sti_item = static_cast<ScriptTreeItem *>(so_item->vcpu_getInterface(treeitemGuid));
  1282. if (sti_item)
  1283. {
  1284. _item = sti_item->getItem();
  1285. }
  1286. }
  1287. if (sp != NULL)
  1288. {
  1289. sp->delItemDeferred(_item);
  1290. }
  1291. RETURN_SCRIPT_VOID;
  1292. }
  1293. /*Void*/ scriptVar GuiTreeScriptController::guitree_hiliteItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar item)
  1294. {
  1295. SCRIPT_FUNCTION_INIT
  1296. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1297. TreeItem *_item = NULL;
  1298. ScriptObject *so_item = GET_SCRIPT_OBJECT(item);
  1299. if (so_item)
  1300. {
  1301. ScriptTreeItem *sti_item = static_cast<ScriptTreeItem *>(so_item->vcpu_getInterface(treeitemGuid));
  1302. if (sti_item)
  1303. {
  1304. _item = sti_item->getItem();
  1305. }
  1306. }
  1307. if (sp != NULL)
  1308. {
  1309. sp->hiliteItem(_item);
  1310. }
  1311. RETURN_SCRIPT_VOID;
  1312. }
  1313. /*Void*/ scriptVar GuiTreeScriptController::guitree_unhiliteItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar item)
  1314. {
  1315. SCRIPT_FUNCTION_INIT
  1316. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1317. TreeItem *_item = NULL;
  1318. ScriptObject *so_item = GET_SCRIPT_OBJECT(item);
  1319. if (so_item)
  1320. {
  1321. ScriptTreeItem *sti_item = static_cast<ScriptTreeItem *>(so_item->vcpu_getInterface(treeitemGuid));
  1322. if (sti_item)
  1323. {
  1324. _item = sti_item->getItem();
  1325. }
  1326. }
  1327. if (sp != NULL)
  1328. {
  1329. sp->unhiliteItem(_item);
  1330. }
  1331. RETURN_SCRIPT_VOID;
  1332. }
  1333. /*TreeItem*/ scriptVar GuiTreeScriptController::guitree_getCurItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  1334. {
  1335. SCRIPT_FUNCTION_INIT
  1336. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1337. scriptVar retval = MAKE_SCRIPT_OBJECT(NULL);
  1338. if (sp != NULL)
  1339. {
  1340. TreeItem *a = NULL;
  1341. a = sp->getCurItem();
  1342. if (a != NULL)
  1343. {
  1344. ScriptTreeItem *item = sp->bindScriptTreeItem(a);
  1345. if (item != NULL)
  1346. {
  1347. retval = MAKE_SCRIPT_OBJECT(item->getScriptObject());
  1348. }
  1349. }
  1350. }
  1351. return retval;
  1352. }
  1353. /*TreeItem*/ scriptVar GuiTreeScriptController::guitree_hitTest(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y)
  1354. {
  1355. SCRIPT_FUNCTION_INIT
  1356. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1357. int _y = GET_SCRIPT_INT(y);
  1358. int _x = GET_SCRIPT_INT(x);
  1359. scriptVar retval = MAKE_SCRIPT_OBJECT(NULL);
  1360. if (sp != NULL)
  1361. {
  1362. TreeItem *a = NULL;
  1363. a = sp->hitTest(_x, _y);
  1364. if (a != NULL)
  1365. {
  1366. ScriptTreeItem *item = sp->bindScriptTreeItem(a);
  1367. if (item != NULL)
  1368. {
  1369. retval = MAKE_SCRIPT_OBJECT(item->getScriptObject());
  1370. }
  1371. }
  1372. }
  1373. return retval;
  1374. }
  1375. /*Void*/ scriptVar GuiTreeScriptController::guitree_editItemLabel(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar item)
  1376. {
  1377. SCRIPT_FUNCTION_INIT
  1378. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1379. TreeItem *_item = NULL;
  1380. ScriptObject *so_item = GET_SCRIPT_OBJECT(item);
  1381. if (so_item)
  1382. {
  1383. ScriptTreeItem *sti_item = static_cast<ScriptTreeItem *>(so_item->vcpu_getInterface(treeitemGuid));
  1384. if (sti_item)
  1385. {
  1386. _item = sti_item->getItem();
  1387. }
  1388. }
  1389. if (sp != NULL)
  1390. {
  1391. sp->editItemLabel(_item);
  1392. }
  1393. RETURN_SCRIPT_VOID;
  1394. }
  1395. /*Void*/ scriptVar GuiTreeScriptController::guitree_cancelEditLabel(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar destroyit)
  1396. {
  1397. SCRIPT_FUNCTION_INIT
  1398. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1399. int _destroyit = GET_SCRIPT_INT(destroyit);
  1400. if (sp != NULL)
  1401. {
  1402. sp->cancelEditLabel(_destroyit);
  1403. }
  1404. RETURN_SCRIPT_VOID;
  1405. }
  1406. /*Void*/ scriptVar GuiTreeScriptController::guitree_setAutoEdit(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar ae)
  1407. {
  1408. SCRIPT_FUNCTION_INIT
  1409. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1410. int _ae = GET_SCRIPT_INT(ae);
  1411. if (sp != NULL)
  1412. {
  1413. sp->setAutoEdit(_ae);
  1414. }
  1415. RETURN_SCRIPT_VOID;
  1416. }
  1417. /*Int*/ scriptVar GuiTreeScriptController::guitree_getAutoEdit(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  1418. {
  1419. SCRIPT_FUNCTION_INIT
  1420. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1421. scriptVar retval = MAKE_SCRIPT_INT(0);
  1422. if (sp != NULL)
  1423. {
  1424. int a = 0;
  1425. a = sp->getAutoEdit();
  1426. retval = MAKE_SCRIPT_INT(a);
  1427. }
  1428. return retval;
  1429. }
  1430. /*TreeItem*/ scriptVar GuiTreeScriptController::guitree_getByLabel(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar item, /*String*/ scriptVar name)
  1431. {
  1432. SCRIPT_FUNCTION_INIT
  1433. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1434. TreeItem *_item = NULL;
  1435. ScriptObject *so_item = GET_SCRIPT_OBJECT(item);
  1436. if (so_item)
  1437. {
  1438. ScriptTreeItem *sti_item = static_cast<ScriptTreeItem *>(so_item->vcpu_getInterface(treeitemGuid));
  1439. if (sti_item)
  1440. {
  1441. _item = sti_item->getItem();
  1442. }
  1443. }
  1444. StringW _name = GET_SCRIPT_STRING(name);
  1445. scriptVar retval = MAKE_SCRIPT_OBJECT(NULL);
  1446. if (sp != NULL)
  1447. {
  1448. TreeItem *a = NULL;
  1449. a = sp->getByLabel(_item, _name);
  1450. if (a != NULL)
  1451. {
  1452. ScriptTreeItem *item = sp->bindScriptTreeItem(a);
  1453. if (item != NULL)
  1454. {
  1455. retval = MAKE_SCRIPT_OBJECT(item->getScriptObject());
  1456. }
  1457. }
  1458. }
  1459. return retval;
  1460. }
  1461. /*Void*/ scriptVar GuiTreeScriptController::guitree_setSorted(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar dosort)
  1462. {
  1463. SCRIPT_FUNCTION_INIT
  1464. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1465. int _dosort = GET_SCRIPT_INT(dosort);
  1466. if (sp != NULL)
  1467. {
  1468. sp->setSorted(!!_dosort);
  1469. }
  1470. RETURN_SCRIPT_VOID;
  1471. }
  1472. /*Int*/ scriptVar GuiTreeScriptController::guitree_getSorted(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  1473. {
  1474. SCRIPT_FUNCTION_INIT
  1475. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1476. scriptVar retval = MAKE_SCRIPT_OBJECT(NULL);
  1477. if (sp != NULL)
  1478. {
  1479. int a = NULL;
  1480. a = sp->getSorted();
  1481. retval = MAKE_SCRIPT_INT(a);
  1482. }
  1483. return retval;
  1484. }
  1485. /*Void*/ scriptVar GuiTreeScriptController::guitree_sortTreeItems(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  1486. {
  1487. SCRIPT_FUNCTION_INIT
  1488. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1489. if (sp != NULL)
  1490. {
  1491. sp->sortTreeItems();
  1492. }
  1493. RETURN_SCRIPT_VOID;
  1494. }
  1495. /*TreeItem*/ scriptVar GuiTreeScriptController::guitree_getSibling(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar item)
  1496. {
  1497. SCRIPT_FUNCTION_INIT
  1498. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1499. TreeItem *_item = NULL;
  1500. ScriptObject *so_item = GET_SCRIPT_OBJECT(item);
  1501. if (so_item)
  1502. {
  1503. ScriptTreeItem *sti_item = static_cast<ScriptTreeItem *>(so_item->vcpu_getInterface(treeitemGuid));
  1504. if (sti_item)
  1505. {
  1506. _item = sti_item->getItem();
  1507. }
  1508. }
  1509. scriptVar retval = MAKE_SCRIPT_OBJECT(NULL);
  1510. if (sp != NULL)
  1511. {
  1512. TreeItem *a = NULL;
  1513. a = sp->getSibling(_item);
  1514. if (a != NULL)
  1515. {
  1516. ScriptTreeItem *item = sp->bindScriptTreeItem(a);
  1517. if (item != NULL)
  1518. {
  1519. retval = MAKE_SCRIPT_OBJECT(item->getScriptObject());
  1520. }
  1521. }
  1522. }
  1523. return retval;
  1524. }
  1525. /*Void*/ scriptVar GuiTreeScriptController::guitree_setAutoCollapse(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar doautocollapse)
  1526. {
  1527. SCRIPT_FUNCTION_INIT
  1528. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1529. int _doautocollapse = GET_SCRIPT_INT(doautocollapse);
  1530. if (sp != NULL)
  1531. {
  1532. sp->setAutoCollapse(!!_doautocollapse);
  1533. }
  1534. RETURN_SCRIPT_VOID;
  1535. }
  1536. /*Int*/ scriptVar GuiTreeScriptController::guitree_setFontSize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar newsize)
  1537. {
  1538. SCRIPT_FUNCTION_INIT
  1539. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1540. int _newsize = GET_SCRIPT_INT(newsize);
  1541. scriptVar retval = MAKE_SCRIPT_INT(0);
  1542. if (sp != NULL)
  1543. {
  1544. int a = 0;
  1545. a = sp->setFontSize(_newsize);
  1546. retval = MAKE_SCRIPT_INT(a);
  1547. }
  1548. return retval;
  1549. }
  1550. /*Int*/ scriptVar GuiTreeScriptController::guitree_getFontSize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  1551. {
  1552. SCRIPT_FUNCTION_INIT
  1553. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1554. scriptVar retval = MAKE_SCRIPT_INT(0);
  1555. if (sp != NULL)
  1556. {
  1557. int a = 0;
  1558. a = sp->getFontSize();
  1559. retval = MAKE_SCRIPT_INT(a);
  1560. }
  1561. return retval;
  1562. }
  1563. /*Int*/ scriptVar GuiTreeScriptController::guitree_getNumVisibleChildItems(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar c)
  1564. {
  1565. SCRIPT_FUNCTION_INIT
  1566. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1567. TreeItem *_c = NULL;
  1568. ScriptObject *so_c = GET_SCRIPT_OBJECT(c);
  1569. if (so_c)
  1570. {
  1571. ScriptTreeItem *sti_c = static_cast<ScriptTreeItem *>(so_c->vcpu_getInterface(treeitemGuid));
  1572. if (sti_c)
  1573. {
  1574. _c = sti_c->getItem();
  1575. }
  1576. }
  1577. scriptVar retval = MAKE_SCRIPT_INT(0);
  1578. if (sp != NULL)
  1579. {
  1580. int a = 0;
  1581. a = sp->getNumVisibleChildItems(_c);
  1582. retval = MAKE_SCRIPT_INT(a);
  1583. }
  1584. return retval;
  1585. }
  1586. /*Int*/ scriptVar GuiTreeScriptController::guitree_getNumVisibleItems(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  1587. {
  1588. SCRIPT_FUNCTION_INIT
  1589. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1590. scriptVar retval = MAKE_SCRIPT_INT(0);
  1591. if (sp != NULL)
  1592. {
  1593. int a = 0;
  1594. a = sp->getNumVisibleItems();
  1595. retval = MAKE_SCRIPT_INT(a);
  1596. }
  1597. return retval;
  1598. }
  1599. /*TreeItem*/ scriptVar GuiTreeScriptController::guitree_enumVisibleItems(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar n)
  1600. {
  1601. SCRIPT_FUNCTION_INIT
  1602. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1603. int _n = GET_SCRIPT_INT(n);
  1604. scriptVar retval = MAKE_SCRIPT_OBJECT(NULL);
  1605. if (sp != NULL)
  1606. {
  1607. TreeItem *a = NULL;
  1608. a = sp->enumVisibleItems(_n);
  1609. if (a != NULL)
  1610. {
  1611. ScriptTreeItem *item = sp->bindScriptTreeItem(a);
  1612. if (item != NULL)
  1613. {
  1614. retval = MAKE_SCRIPT_OBJECT(item->getScriptObject());
  1615. }
  1616. }
  1617. }
  1618. return retval;
  1619. }
  1620. /*TreeItem*/ scriptVar GuiTreeScriptController::guitree_enumVisibleChildItems(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar c, scriptVar n)
  1621. {
  1622. SCRIPT_FUNCTION_INIT
  1623. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1624. TreeItem *_c = NULL;
  1625. ScriptObject *so_c = GET_SCRIPT_OBJECT(c);
  1626. if (so_c)
  1627. {
  1628. ScriptTreeItem *sti_c = static_cast<ScriptTreeItem *>(so_c->vcpu_getInterface(treeitemGuid));
  1629. if (sti_c)
  1630. {
  1631. _c = sti_c->getItem();
  1632. }
  1633. }
  1634. int _n = GET_SCRIPT_INT(n);
  1635. scriptVar retval = MAKE_SCRIPT_OBJECT(NULL);
  1636. if (sp != NULL)
  1637. {
  1638. TreeItem *a = NULL;
  1639. a = sp->enumVisibleChildItems(_c, _n);
  1640. if (a != NULL)
  1641. {
  1642. ScriptTreeItem *item = sp->bindScriptTreeItem(a);
  1643. if (item != NULL)
  1644. {
  1645. retval = MAKE_SCRIPT_OBJECT(item->getScriptObject());
  1646. }
  1647. }
  1648. }
  1649. return retval;
  1650. }
  1651. /*TreeItem*/ scriptVar GuiTreeScriptController::guitree_enumAllItems(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar n)
  1652. {
  1653. SCRIPT_FUNCTION_INIT
  1654. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1655. int _n = GET_SCRIPT_INT(n);
  1656. scriptVar retval = MAKE_SCRIPT_OBJECT(NULL);
  1657. if (sp != NULL)
  1658. {
  1659. TreeItem *a = NULL;
  1660. a = sp->enumAllItems(_n);
  1661. if (a != NULL)
  1662. {
  1663. ScriptTreeItem *item = sp->bindScriptTreeItem(a);
  1664. if (item != NULL)
  1665. {
  1666. retval = MAKE_SCRIPT_OBJECT(item->getScriptObject());
  1667. }
  1668. }
  1669. }
  1670. return retval;
  1671. }
  1672. /*Int*/ scriptVar GuiTreeScriptController::guitree_getItemRectX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar item)
  1673. {
  1674. SCRIPT_FUNCTION_INIT
  1675. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1676. TreeItem *_item = NULL;
  1677. ScriptObject *so_item = GET_SCRIPT_OBJECT(item);
  1678. if (so_item)
  1679. {
  1680. ScriptTreeItem *sti_item = static_cast<ScriptTreeItem *>(so_item->vcpu_getInterface(treeitemGuid));
  1681. if (sti_item)
  1682. {
  1683. _item = sti_item->getItem();
  1684. }
  1685. }
  1686. scriptVar retval = MAKE_SCRIPT_INT(0);
  1687. if (sp != NULL)
  1688. {
  1689. int a = 0;
  1690. RECT r;
  1691. sp->getItemRect(_item, &r);
  1692. a = r.left;
  1693. retval = MAKE_SCRIPT_INT(a);
  1694. }
  1695. return retval;
  1696. }
  1697. /*Int*/ scriptVar GuiTreeScriptController::guitree_getItemRectY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar item)
  1698. {
  1699. SCRIPT_FUNCTION_INIT
  1700. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1701. TreeItem *_item = NULL;
  1702. ScriptObject *so_item = GET_SCRIPT_OBJECT(item);
  1703. if (so_item)
  1704. {
  1705. ScriptTreeItem *sti_item = static_cast<ScriptTreeItem *>(so_item->vcpu_getInterface(treeitemGuid));
  1706. if (sti_item)
  1707. {
  1708. _item = sti_item->getItem();
  1709. }
  1710. }
  1711. scriptVar retval = MAKE_SCRIPT_INT(0);
  1712. if (sp != NULL)
  1713. {
  1714. int a = 0;
  1715. RECT r;
  1716. sp->getItemRect(_item, &r);
  1717. a = r.top;
  1718. retval = MAKE_SCRIPT_INT(a);
  1719. }
  1720. return retval;
  1721. }
  1722. /*Int*/ scriptVar GuiTreeScriptController::guitree_getItemRectW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar item)
  1723. {
  1724. SCRIPT_FUNCTION_INIT
  1725. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1726. TreeItem *_item = NULL;
  1727. ScriptObject *so_item = GET_SCRIPT_OBJECT(item);
  1728. if (so_item)
  1729. {
  1730. ScriptTreeItem *sti_item = static_cast<ScriptTreeItem *>(so_item->vcpu_getInterface(treeitemGuid));
  1731. if (sti_item)
  1732. {
  1733. _item = sti_item->getItem();
  1734. }
  1735. }
  1736. scriptVar retval = MAKE_SCRIPT_INT(0);
  1737. if (sp != NULL)
  1738. {
  1739. int a = 0;
  1740. RECT r;
  1741. sp->getItemRect(_item, &r);
  1742. a = r.left - r.right;
  1743. retval = MAKE_SCRIPT_INT(a);
  1744. }
  1745. return retval;
  1746. }
  1747. /*Int*/ scriptVar GuiTreeScriptController::guitree_getItemRectH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar item)
  1748. {
  1749. SCRIPT_FUNCTION_INIT
  1750. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1751. TreeItem *_item = NULL;
  1752. ScriptObject *so_item = GET_SCRIPT_OBJECT(item);
  1753. if (so_item)
  1754. {
  1755. ScriptTreeItem *sti_item = static_cast<ScriptTreeItem *>(so_item->vcpu_getInterface(treeitemGuid));
  1756. if (sti_item)
  1757. {
  1758. _item = sti_item->getItem();
  1759. }
  1760. }
  1761. scriptVar retval = MAKE_SCRIPT_INT(0);
  1762. if (sp != NULL)
  1763. {
  1764. int a = 0;
  1765. RECT r;
  1766. sp->getItemRect(_item, &r);
  1767. a = r.bottom - r.top;
  1768. retval = MAKE_SCRIPT_INT(a);
  1769. }
  1770. return retval;
  1771. }
  1772. #if 0 // Not implemented in TreeWnd, dammit.
  1773. /*TreeItem*/ scriptVar GuiTreeScriptController::guitree_getItemFromPoint(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y)
  1774. {
  1775. SCRIPT_FUNCTION_INIT
  1776. ScriptTree *sp = static_cast<ScriptTree *>(o->vcpu_getInterface(guitreeGuid));
  1777. int _y = GET_SCRIPT_INT(y);
  1778. int _x = GET_SCRIPT_INT(x);
  1779. scriptVar retval = MAKE_SCRIPT_OBJECT(NULL);
  1780. if (sp != NULL)
  1781. {
  1782. TreeItem *a = NULL;
  1783. POINT p = {_x, _y};
  1784. a = sp->getItemFromPoint(&p);
  1785. if (a != NULL)
  1786. {
  1787. ScriptTreeItem *item = sp->bindScriptTreeItem(a);
  1788. if (item != NULL)
  1789. {
  1790. retval = MAKE_SCRIPT_OBJECT(item->getScriptObject());
  1791. }
  1792. }
  1793. }
  1794. return retval;
  1795. }
  1796. #endif
  1797. // -----------------------------------------------------------------------
  1798. // Script Object For The Tree Item
  1799. ScriptTreeItem::ScriptTreeItem(TreeItem *_item, ScriptTree *_tree) : item(_item), tree(_tree), SCRIPTTREEITEM_SCRIPTPARENT()
  1800. {
  1801. getScriptObject()->vcpu_setInterface(treeitemGuid, (void *)static_cast<ScriptTreeItem *>(this));
  1802. getScriptObject()->vcpu_setClassName(L"TreeItem");
  1803. getScriptObject()->vcpu_setController(treeItemController);
  1804. }
  1805. ScriptTreeItem::~ScriptTreeItem()
  1806. {}
  1807. int ScriptTreeItem::getNumChildren()
  1808. {
  1809. ASSERT(item);
  1810. return item->getNumChildren();
  1811. }
  1812. void ScriptTreeItem::setLabel(const wchar_t *label)
  1813. {
  1814. ASSERT(item);
  1815. item->setLabel(label);
  1816. }
  1817. const wchar_t *ScriptTreeItem::getLabel()
  1818. {
  1819. ASSERT(item);
  1820. return item->getLabel();
  1821. }
  1822. void ScriptTreeItem::ensureVisible()
  1823. {
  1824. ASSERT(item);
  1825. item->ensureVisible();
  1826. }
  1827. TreeItem *ScriptTreeItem::getNthChild(int nth)
  1828. {
  1829. ASSERT(item);
  1830. return item->getNthChild(nth);
  1831. }
  1832. TreeItem *ScriptTreeItem::getChild()
  1833. {
  1834. ASSERT(item);
  1835. return item->getChild();
  1836. }
  1837. TreeItem *ScriptTreeItem::getChildSibling(TreeItem *_item)
  1838. {
  1839. ASSERT(item);
  1840. return item->getChildSibling(_item);
  1841. }
  1842. TreeItem *ScriptTreeItem::getSibling()
  1843. {
  1844. ASSERT(item);
  1845. return item->getSibling();
  1846. }
  1847. TreeItem *ScriptTreeItem::getParent()
  1848. {
  1849. ASSERT(item);
  1850. return item->getParent();
  1851. }
  1852. void ScriptTreeItem::editLabel()
  1853. {
  1854. ASSERT(item);
  1855. item->editLabel();
  1856. }
  1857. bool ScriptTreeItem::hasSubItems()
  1858. {
  1859. ASSERT(item);
  1860. return item->hasSubItems();
  1861. }
  1862. void ScriptTreeItem::setSorted(int issorted)
  1863. {
  1864. ASSERT(item);
  1865. item->setSorted(issorted);
  1866. }
  1867. void ScriptTreeItem::setChildTab(int haschildtab)
  1868. {
  1869. ASSERT(item);
  1870. item->setChildTab(haschildtab);
  1871. }
  1872. bool ScriptTreeItem::isSorted()
  1873. {
  1874. ASSERT(item);
  1875. return item->isSorted();
  1876. }
  1877. bool ScriptTreeItem::isCollapsed()
  1878. {
  1879. ASSERT(item);
  1880. return item->isCollapsed();
  1881. }
  1882. bool ScriptTreeItem::isExpanded()
  1883. {
  1884. ASSERT(item);
  1885. return item->isExpanded();
  1886. }
  1887. void ScriptTreeItem::invalidate()
  1888. {
  1889. ASSERT(item);
  1890. item->invalidate();
  1891. }
  1892. bool ScriptTreeItem::isSelected()
  1893. {
  1894. ASSERT(item);
  1895. return item->isSelected();
  1896. }
  1897. bool ScriptTreeItem::isHilited()
  1898. {
  1899. ASSERT(item);
  1900. return item->isHilited();
  1901. }
  1902. void ScriptTreeItem::setHilited(bool ishilited)
  1903. {
  1904. ASSERT(item);
  1905. item->setHilited(ishilited);
  1906. }
  1907. int ScriptTreeItem::collapse()
  1908. {
  1909. ASSERT(item);
  1910. return item->collapse();
  1911. }
  1912. int ScriptTreeItem::expand()
  1913. {
  1914. ASSERT(item);
  1915. return item->expand();
  1916. }
  1917. #if 0
  1918. // This was never implemented!
  1919. void ScriptTreeItem::setCurrent(bool tf)
  1920. {
  1921. ASSERT(item);
  1922. item->setCurrent(tf);
  1923. }
  1924. #endif
  1925. TreeWnd *ScriptTreeItem::getTree()
  1926. {
  1927. ASSERT(item);
  1928. return item->getTree();
  1929. }
  1930. // -----------------------------------------------------------------------
  1931. // Script Controller For The Tree Item
  1932. TreeItemScriptController _treeItemController;
  1933. TreeItemScriptController *treeItemController = &_treeItemController;
  1934. // -- Functions table -------------------------------------
  1935. function_descriptor_struct TreeItemScriptController::exportedFunction[] = {
  1936. {L"getNumChildren", 0, (void*)TreeItemScriptController::treeitem_getNumChildren },
  1937. {L"setLabel", 1, (void*)TreeItemScriptController::treeitem_setLabel },
  1938. {L"getLabel", 0, (void*)TreeItemScriptController::treeitem_getLabel },
  1939. {L"ensureVisible", 0, (void*)TreeItemScriptController::treeitem_ensureVisible },
  1940. {L"getNthChild", 1, (void*)TreeItemScriptController::treeitem_getNthChild },
  1941. {L"getChild", 0, (void*)TreeItemScriptController::treeitem_getChild },
  1942. {L"getChildSibling", 1, (void*)TreeItemScriptController::treeitem_getChildSibling },
  1943. {L"getSibling", 0, (void*)TreeItemScriptController::treeitem_getSibling },
  1944. {L"getParent", 0, (void*)TreeItemScriptController::treeitem_getParent },
  1945. {L"editLabel", 0, (void*)TreeItemScriptController::treeitem_editLabel },
  1946. {L"hasSubItems", 0, (void*)TreeItemScriptController::treeitem_hasSubItems },
  1947. {L"setSorted", 1, (void*)TreeItemScriptController::treeitem_setSorted },
  1948. {L"setChildTab", 1, (void*)TreeItemScriptController::treeitem_setChildTab },
  1949. {L"isSorted", 0, (void*)TreeItemScriptController::treeitem_isSorted },
  1950. {L"isCollapsed", 0, (void*)TreeItemScriptController::treeitem_isCollapsed },
  1951. {L"isExpanded", 0, (void*)TreeItemScriptController::treeitem_isExpanded },
  1952. {L"invalidate", 0, (void*)TreeItemScriptController::treeitem_invalidate },
  1953. {L"isSelected", 0, (void*)TreeItemScriptController::treeitem_isSelected },
  1954. {L"isHilited", 0, (void*)TreeItemScriptController::treeitem_isHilited },
  1955. {L"setHilited", 1, (void*)TreeItemScriptController::treeitem_setHilited },
  1956. {L"collapse", 0, (void*)TreeItemScriptController::treeitem_collapse },
  1957. {L"expand", 0, (void*)TreeItemScriptController::treeitem_expand },
  1958. {L"getTree", 0, (void*)TreeItemScriptController::treeitem_getTree },
  1959. {L"onTreeAdd", 0, (void*)TreeItemScriptController::treeitem_onTreeAdd },
  1960. {L"onTreeRemove", 0, (void*)TreeItemScriptController::treeitem_onTreeRemove },
  1961. {L"onSelect", 0, (void*)TreeItemScriptController::treeitem_onSelect },
  1962. {L"onDeselect", 0, (void*)TreeItemScriptController::treeitem_onDeselect },
  1963. {L"onLeftDoubleClick", 0, (void*)TreeItemScriptController::treeitem_onLeftDoubleClick },
  1964. {L"onRightDoubleClick", 0, (void*)TreeItemScriptController::treeitem_onRightDoubleClick },
  1965. {L"onChar", 1, (void*)TreeItemScriptController::treeitem_onChar },
  1966. {L"onExpand", 0, (void*)TreeItemScriptController::treeitem_onExpand },
  1967. {L"onCollapse", 0, (void*)TreeItemScriptController::treeitem_onCollapse },
  1968. {L"onBeginLabelEdit", 0, (void*)TreeItemScriptController::treeitem_onBeginLabelEdit },
  1969. {L"onEndLabelEdit", 1, (void*)TreeItemScriptController::treeitem_onEndLabelEdit },
  1970. {L"onContextMenu", 2, (void*)TreeItemScriptController::treeitem_onContextMenu },
  1971. };
  1972. StringW TreeItemScriptController::staticStr;
  1973. ScriptTreeMap TreeItemScriptController::g_scriptitems;
  1974. ScriptObject *TreeItemScriptController::instantiate()
  1975. {
  1976. ScriptTreeItem *sp = new ScriptTreeItem;
  1977. ASSERT(sp != NULL);
  1978. TreeItem *child_item = new TreeItemScript(L"", sp);
  1979. ASSERT(child_item != NULL);
  1980. sp->setItem(child_item);
  1981. TISC::g_scriptitems.insert({ child_item, sp });
  1982. // We're not attached to a tree. that's okay!
  1983. return sp->getScriptObject();
  1984. }
  1985. // If the script asks to delete the item, delete the internal item as well.
  1986. // We tell the owning ScriptTree to remove this object.
  1987. void TreeItemScriptController::destroy(ScriptObject *o)
  1988. {
  1989. ScriptTreeItem *sp = static_cast<ScriptTreeItem *>(o->vcpu_getInterface(treeitemGuid));
  1990. ASSERT(sp != NULL);
  1991. if (!sp->destroyScriptTreeItem())
  1992. {
  1993. auto item = sp->getItem();
  1994. // Ask the owner tree to do it for us, but if not owned, we do it ourselves.
  1995. if (item)
  1996. {
  1997. //TISC::g_scriptitems.delItem(sp->getItem());
  1998. auto it = TISC::g_scriptitems.find(item);
  1999. if (TISC::g_scriptitems.end() != it)
  2000. {
  2001. TISC::g_scriptitems.erase(it);
  2002. }
  2003. }
  2004. // AND we delete our item, since we're not a part of a tree that will do it for us.
  2005. delete item;
  2006. delete sp;
  2007. }
  2008. }
  2009. void *TreeItemScriptController::encapsulate(ScriptObject *o)
  2010. {
  2011. return NULL; // no encapsulation for guitrees yet
  2012. }
  2013. void TreeItemScriptController::deencapsulate(void *o)
  2014. {}
  2015. int TreeItemScriptController::getNumFunctions()
  2016. {
  2017. return sizeof(exportedFunction) / sizeof(function_descriptor_struct);
  2018. }
  2019. const function_descriptor_struct *TreeItemScriptController::getExportedFunctions()
  2020. {
  2021. return exportedFunction;
  2022. }
  2023. /*int*/ scriptVar TreeItemScriptController::treeitem_getNumChildren(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2024. {
  2025. SCRIPT_FUNCTION_INIT
  2026. ScriptTreeItem *sp = static_cast<ScriptTreeItem *>(o->vcpu_getInterface(treeitemGuid));
  2027. int a = 0;
  2028. if (sp != NULL)
  2029. {
  2030. a = sp->getNumChildren();
  2031. }
  2032. return MAKE_SCRIPT_INT(a);
  2033. }
  2034. /*void*/ scriptVar TreeItemScriptController::treeitem_setLabel(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*String*/ scriptVar label)
  2035. {
  2036. SCRIPT_FUNCTION_INIT
  2037. ScriptTreeItem *sp = static_cast<ScriptTreeItem *>(o->vcpu_getInterface(treeitemGuid));
  2038. StringW _label = GET_SCRIPT_STRING(label);
  2039. if (sp != NULL)
  2040. {
  2041. sp->setLabel(_label);
  2042. }
  2043. RETURN_SCRIPT_VOID;
  2044. }
  2045. /*String*/ scriptVar TreeItemScriptController::treeitem_getLabel(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2046. {
  2047. SCRIPT_FUNCTION_INIT
  2048. ScriptTreeItem *sp = static_cast<ScriptTreeItem *>(o->vcpu_getInterface(treeitemGuid));
  2049. if (sp != NULL)
  2050. {
  2051. staticStr = sp->getLabel();
  2052. }
  2053. return MAKE_SCRIPT_STRING(staticStr);
  2054. }
  2055. /*void*/ scriptVar TreeItemScriptController::treeitem_ensureVisible(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2056. {
  2057. SCRIPT_FUNCTION_INIT
  2058. ScriptTreeItem *sp = static_cast<ScriptTreeItem *>(o->vcpu_getInterface(treeitemGuid));
  2059. if (sp != NULL)
  2060. {
  2061. sp->ensureVisible();
  2062. }
  2063. RETURN_SCRIPT_VOID;
  2064. }
  2065. /*TreeItem*/ scriptVar TreeItemScriptController::treeitem_getNthChild(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar nth)
  2066. {
  2067. SCRIPT_FUNCTION_INIT
  2068. ScriptTreeItem *sp = static_cast<ScriptTreeItem *>(o->vcpu_getInterface(treeitemGuid));
  2069. int _nth = GET_SCRIPT_INT(nth);
  2070. TreeItem *a = NULL;
  2071. if (sp != NULL)
  2072. {
  2073. a = sp->getNthChild(_nth);
  2074. }
  2075. ScriptTree *tree = sp->getScriptTree();
  2076. ScriptTreeItem *retval = NULL;
  2077. if (tree && a)
  2078. {
  2079. retval = tree->bindScriptTreeItem(a);
  2080. }
  2081. if (retval)
  2082. {
  2083. return MAKE_SCRIPT_OBJECT(retval->getScriptObject());
  2084. }
  2085. return MAKE_SCRIPT_OBJECT(NULL); // Return NULL
  2086. }
  2087. /*TreeItem*/ scriptVar TreeItemScriptController::treeitem_getChild(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2088. {
  2089. SCRIPT_FUNCTION_INIT
  2090. ScriptTreeItem *sp = static_cast<ScriptTreeItem *>(o->vcpu_getInterface(treeitemGuid));
  2091. TreeItem *a = NULL;
  2092. if (sp != NULL)
  2093. {
  2094. a = sp->getChild();
  2095. }
  2096. ScriptTree *tree = sp->getScriptTree();
  2097. ScriptTreeItem *retval = NULL;
  2098. if (tree && a)
  2099. {
  2100. retval = tree->bindScriptTreeItem(a);
  2101. }
  2102. if (retval)
  2103. {
  2104. return MAKE_SCRIPT_OBJECT(retval->getScriptObject());
  2105. }
  2106. return MAKE_SCRIPT_OBJECT(NULL); // Return NULL
  2107. }
  2108. /*TreeItem*/ scriptVar TreeItemScriptController::treeitem_getChildSibling(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*TreeItem*/ scriptVar _item)
  2109. {
  2110. SCRIPT_FUNCTION_INIT
  2111. ScriptTreeItem *sp = static_cast<ScriptTreeItem *>(o->vcpu_getInterface(treeitemGuid));
  2112. TreeItem *__item = NULL;
  2113. ScriptObject *io = GET_SCRIPT_OBJECT(_item);
  2114. if (io)
  2115. {
  2116. ScriptTreeItem *sio = static_cast<ScriptTreeItem *>(io->vcpu_getInterface(treeitemGuid));
  2117. if (sio)
  2118. {
  2119. __item = sio->getItem();
  2120. }
  2121. }
  2122. TreeItem *a = NULL;
  2123. if (sp != NULL)
  2124. {
  2125. a = sp->getChildSibling(__item);
  2126. }
  2127. ScriptTree *tree = sp->getScriptTree();
  2128. ScriptTreeItem *retval = NULL;
  2129. if (tree && a)
  2130. {
  2131. retval = tree->bindScriptTreeItem(a);
  2132. }
  2133. if (retval)
  2134. {
  2135. return MAKE_SCRIPT_OBJECT(retval->getScriptObject());
  2136. }
  2137. return MAKE_SCRIPT_OBJECT(NULL); // Return NULL
  2138. }
  2139. /*TreeItem*/ scriptVar TreeItemScriptController::treeitem_getSibling(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2140. {
  2141. SCRIPT_FUNCTION_INIT
  2142. ScriptTreeItem *sp = static_cast<ScriptTreeItem *>(o->vcpu_getInterface(treeitemGuid));
  2143. TreeItem *a = NULL;
  2144. if (sp != NULL)
  2145. {
  2146. a = sp->getSibling();
  2147. }
  2148. ScriptTree *tree = sp->getScriptTree();
  2149. ScriptTreeItem *retval = NULL;
  2150. if (tree && a)
  2151. {
  2152. retval = tree->bindScriptTreeItem(a);
  2153. }
  2154. if (retval)
  2155. {
  2156. return MAKE_SCRIPT_OBJECT(retval->getScriptObject());
  2157. }
  2158. return MAKE_SCRIPT_OBJECT(NULL); // Return NULL
  2159. }
  2160. /*TreeItem*/ scriptVar TreeItemScriptController::treeitem_getParent(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2161. {
  2162. SCRIPT_FUNCTION_INIT
  2163. ScriptTreeItem *sp = static_cast<ScriptTreeItem *>(o->vcpu_getInterface(treeitemGuid));
  2164. TreeItem *a = NULL;
  2165. if (sp != NULL)
  2166. {
  2167. a = sp->getParent();
  2168. }
  2169. ScriptTree *tree = sp->getScriptTree();
  2170. ScriptTreeItem *retval = NULL;
  2171. if (tree && a)
  2172. {
  2173. retval = tree->bindScriptTreeItem(a);
  2174. }
  2175. if (retval)
  2176. {
  2177. return MAKE_SCRIPT_OBJECT(retval->getScriptObject());
  2178. }
  2179. return MAKE_SCRIPT_OBJECT(NULL); // Return NULL
  2180. }
  2181. /*void*/ scriptVar TreeItemScriptController::treeitem_editLabel(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2182. {
  2183. SCRIPT_FUNCTION_INIT
  2184. ScriptTreeItem *sp = static_cast<ScriptTreeItem *>(o->vcpu_getInterface(treeitemGuid));
  2185. if (sp != NULL)
  2186. {
  2187. sp->editLabel();
  2188. }
  2189. RETURN_SCRIPT_VOID;
  2190. }
  2191. /*int*/ scriptVar TreeItemScriptController::treeitem_hasSubItems(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2192. {
  2193. SCRIPT_FUNCTION_INIT
  2194. ScriptTreeItem *sp = static_cast<ScriptTreeItem *>(o->vcpu_getInterface(treeitemGuid));
  2195. int a = 0;
  2196. if (sp != NULL)
  2197. {
  2198. a = sp->hasSubItems();
  2199. }
  2200. return MAKE_SCRIPT_INT(a);
  2201. }
  2202. /*void*/ scriptVar TreeItemScriptController::treeitem_setSorted(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar issorted)
  2203. {
  2204. SCRIPT_FUNCTION_INIT
  2205. ScriptTreeItem *sp = static_cast<ScriptTreeItem *>(o->vcpu_getInterface(treeitemGuid));
  2206. int _issorted = GET_SCRIPT_INT(issorted);
  2207. if (sp != NULL)
  2208. {
  2209. sp->setSorted(_issorted);
  2210. }
  2211. RETURN_SCRIPT_VOID;
  2212. }
  2213. /*void*/ scriptVar TreeItemScriptController::treeitem_setChildTab(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar haschildtab)
  2214. {
  2215. SCRIPT_FUNCTION_INIT
  2216. ScriptTreeItem *sp = static_cast<ScriptTreeItem *>(o->vcpu_getInterface(treeitemGuid));
  2217. int _haschildtab = GET_SCRIPT_INT(haschildtab);
  2218. if (sp != NULL)
  2219. {
  2220. sp->setChildTab(_haschildtab);
  2221. }
  2222. RETURN_SCRIPT_VOID;
  2223. }
  2224. /*int*/ scriptVar TreeItemScriptController::treeitem_isSorted(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2225. {
  2226. SCRIPT_FUNCTION_INIT
  2227. ScriptTreeItem *sp = static_cast<ScriptTreeItem *>(o->vcpu_getInterface(treeitemGuid));
  2228. int a = 0;
  2229. if (sp != NULL)
  2230. {
  2231. a = sp->isSorted();
  2232. }
  2233. return MAKE_SCRIPT_INT(a);
  2234. }
  2235. /*int*/ scriptVar TreeItemScriptController::treeitem_isCollapsed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2236. {
  2237. SCRIPT_FUNCTION_INIT
  2238. ScriptTreeItem *sp = static_cast<ScriptTreeItem *>(o->vcpu_getInterface(treeitemGuid));
  2239. int a = 0;
  2240. if (sp != NULL)
  2241. {
  2242. a = sp->isCollapsed();
  2243. }
  2244. return MAKE_SCRIPT_INT(a);
  2245. }
  2246. /*int*/ scriptVar TreeItemScriptController::treeitem_isExpanded(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2247. {
  2248. SCRIPT_FUNCTION_INIT
  2249. ScriptTreeItem *sp = static_cast<ScriptTreeItem *>(o->vcpu_getInterface(treeitemGuid));
  2250. int a = 0;
  2251. if (sp != NULL)
  2252. {
  2253. a = sp->isExpanded();
  2254. }
  2255. return MAKE_SCRIPT_INT(a);
  2256. }
  2257. /*void*/ scriptVar TreeItemScriptController::treeitem_invalidate(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2258. {
  2259. SCRIPT_FUNCTION_INIT
  2260. ScriptTreeItem *sp = static_cast<ScriptTreeItem *>(o->vcpu_getInterface(treeitemGuid));
  2261. if (sp != NULL)
  2262. {
  2263. sp->invalidate();
  2264. }
  2265. RETURN_SCRIPT_VOID;
  2266. }
  2267. /*int*/ scriptVar TreeItemScriptController::treeitem_isSelected(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2268. {
  2269. SCRIPT_FUNCTION_INIT
  2270. ScriptTreeItem *sp = static_cast<ScriptTreeItem *>(o->vcpu_getInterface(treeitemGuid));
  2271. int a = 0;
  2272. if (sp != NULL)
  2273. {
  2274. a = sp->isSelected();
  2275. }
  2276. return MAKE_SCRIPT_INT(a);
  2277. }
  2278. /*int*/ scriptVar TreeItemScriptController::treeitem_isHilited(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2279. {
  2280. SCRIPT_FUNCTION_INIT
  2281. ScriptTreeItem *sp = static_cast<ScriptTreeItem *>(o->vcpu_getInterface(treeitemGuid));
  2282. int a = 0;
  2283. if (sp != NULL)
  2284. {
  2285. a = sp->isHilited();
  2286. }
  2287. return MAKE_SCRIPT_INT(a);
  2288. }
  2289. /*void*/ scriptVar TreeItemScriptController::treeitem_setHilited(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar ishilited)
  2290. {
  2291. SCRIPT_FUNCTION_INIT
  2292. ScriptTreeItem *sp = static_cast<ScriptTreeItem *>(o->vcpu_getInterface(treeitemGuid));
  2293. int _ishilited = GET_SCRIPT_INT(ishilited);
  2294. if (sp != NULL)
  2295. {
  2296. sp->setHilited(!!_ishilited);
  2297. }
  2298. RETURN_SCRIPT_VOID;
  2299. }
  2300. /*int*/ scriptVar TreeItemScriptController::treeitem_collapse(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2301. {
  2302. SCRIPT_FUNCTION_INIT
  2303. ScriptTreeItem *sp = static_cast<ScriptTreeItem *>(o->vcpu_getInterface(treeitemGuid));
  2304. int a = 0;
  2305. if (sp != NULL)
  2306. {
  2307. a = sp->collapse();
  2308. }
  2309. return MAKE_SCRIPT_INT(a);
  2310. }
  2311. /*int*/ scriptVar TreeItemScriptController::treeitem_expand(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2312. {
  2313. SCRIPT_FUNCTION_INIT
  2314. ScriptTreeItem *sp = static_cast<ScriptTreeItem *>(o->vcpu_getInterface(treeitemGuid));
  2315. int a = 0;
  2316. if (sp != NULL)
  2317. {
  2318. a = sp->expand();
  2319. }
  2320. return MAKE_SCRIPT_INT(a);
  2321. }
  2322. #if 0
  2323. // This was never implemented!
  2324. /*void*/ scriptVar TreeItemScriptController::treeitem_setCurrent(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar tf)
  2325. {
  2326. SCRIPT_FUNCTION_INIT
  2327. ScriptTreeItem *sp = static_cast<ScriptTreeItem *>(o->vcpu_getInterface(treeitemGuid));
  2328. int _tf = GET_SCRIPT_INT(tf);
  2329. if (sp != NULL)
  2330. {
  2331. sp->setCurrent(_tf);
  2332. }
  2333. RETURN_SCRIPT_VOID;
  2334. }
  2335. #endif
  2336. /*GuiTree*/ scriptVar TreeItemScriptController::treeitem_getTree(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2337. {
  2338. SCRIPT_FUNCTION_INIT
  2339. ScriptTreeItem *sp = static_cast<ScriptTreeItem *>(o->vcpu_getInterface(treeitemGuid));
  2340. ScriptTree *a = NULL;
  2341. ScriptObject *retval = NULL;
  2342. if (sp != NULL)
  2343. {
  2344. a = sp->getScriptTree();
  2345. }
  2346. if (a)
  2347. {
  2348. retval = a->getScriptObject();
  2349. }
  2350. return MAKE_SCRIPT_OBJECT(retval);
  2351. }
  2352. /*void*/ scriptVar TreeItemScriptController::treeitem_onTreeAdd(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2353. {
  2354. SCRIPT_FUNCTION_INIT
  2355. PROCESS_HOOKS0(o, guiTreeController);
  2356. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2357. SCRIPT_EXEC_EVENT0(o);
  2358. }
  2359. /*void*/ scriptVar TreeItemScriptController::treeitem_onTreeRemove(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2360. {
  2361. SCRIPT_FUNCTION_INIT
  2362. PROCESS_HOOKS0(o, guiTreeController);
  2363. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2364. SCRIPT_EXEC_EVENT0(o);
  2365. }
  2366. /*void*/ scriptVar TreeItemScriptController::treeitem_onSelect(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2367. {
  2368. SCRIPT_FUNCTION_INIT
  2369. PROCESS_HOOKS0(o, guiTreeController);
  2370. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2371. SCRIPT_EXEC_EVENT0(o);
  2372. }
  2373. /*void*/ scriptVar TreeItemScriptController::treeitem_onDeselect(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2374. {
  2375. SCRIPT_FUNCTION_INIT
  2376. PROCESS_HOOKS0(o, guiTreeController);
  2377. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2378. SCRIPT_EXEC_EVENT0(o);
  2379. }
  2380. /*int*/ scriptVar TreeItemScriptController::treeitem_onLeftDoubleClick(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2381. {
  2382. SCRIPT_FUNCTION_INIT
  2383. PROCESS_HOOKS0(o, guiTreeController);
  2384. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2385. SCRIPT_EXEC_EVENT0(o);
  2386. }
  2387. /*int*/ scriptVar TreeItemScriptController::treeitem_onRightDoubleClick(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2388. {
  2389. SCRIPT_FUNCTION_INIT
  2390. PROCESS_HOOKS0(o, guiTreeController);
  2391. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2392. SCRIPT_EXEC_EVENT0(o);
  2393. }
  2394. /*int*/ scriptVar TreeItemScriptController::treeitem_onChar(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar _key)
  2395. {
  2396. SCRIPT_FUNCTION_INIT
  2397. PROCESS_HOOKS1(o, guiTreeController, _key);
  2398. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2399. SCRIPT_EXEC_EVENT1(o, _key);
  2400. }
  2401. /*void*/ scriptVar TreeItemScriptController::treeitem_onExpand(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2402. {
  2403. SCRIPT_FUNCTION_INIT
  2404. PROCESS_HOOKS0(o, guiTreeController);
  2405. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2406. SCRIPT_EXEC_EVENT0(o);
  2407. }
  2408. /*void*/ scriptVar TreeItemScriptController::treeitem_onCollapse(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2409. {
  2410. SCRIPT_FUNCTION_INIT
  2411. PROCESS_HOOKS0(o, guiTreeController);
  2412. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2413. SCRIPT_EXEC_EVENT0(o);
  2414. }
  2415. /*int*/ scriptVar TreeItemScriptController::treeitem_onBeginLabelEdit(SCRIPT_FUNCTION_PARAMS, ScriptObject *o)
  2416. {
  2417. SCRIPT_FUNCTION_INIT
  2418. PROCESS_HOOKS0(o, guiTreeController);
  2419. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2420. SCRIPT_EXEC_EVENT0(o);
  2421. }
  2422. /*int*/ scriptVar TreeItemScriptController::treeitem_onEndLabelEdit(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*String*/ scriptVar _newlabel)
  2423. {
  2424. SCRIPT_FUNCTION_INIT
  2425. PROCESS_HOOKS1(o, guiTreeController, _newlabel);
  2426. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2427. SCRIPT_EXEC_EVENT1(o, _newlabel);
  2428. }
  2429. /*int*/ scriptVar TreeItemScriptController::treeitem_onContextMenu(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar _x, /*int*/ scriptVar _y)
  2430. {
  2431. SCRIPT_FUNCTION_INIT
  2432. PROCESS_HOOKS2(o, guiTreeController, _x, _y);
  2433. SCRIPT_FUNCTION_CHECKABORTEVENT;
  2434. SCRIPT_EXEC_EVENT2(o, _x, _y);
  2435. }