xuilist.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. #ifndef __XUILIST_H
  2. #define __XUILIST_H
  3. #include <api/wnd/wndclass/listwnd.h>
  4. #include <api/script/objcontroller.h>
  5. #include <bfc/depend.h>
  6. class svc_textFeed;
  7. #define SCRIPTLIST_PARENT ListWnd
  8. // -----------------------------------------------------------------------
  9. class ScriptList : public SCRIPTLIST_PARENT, public DependentViewerI {
  10. public:
  11. ScriptList();
  12. virtual ~ScriptList();
  13. virtual int onInit();
  14. //virtual void onDoubleClick(int itemnum); // moved to the script-handling callback.
  15. //void onItemSelection(int itemnum, int selected);
  16. int setXuiParam(int xuihandle, int xmlattributeid, const wchar_t *xmlattributename, const wchar_t *value);
  17. #ifdef WASABI_COMPILE_CONFIG
  18. int onReloadConfig();
  19. #endif
  20. virtual int viewer_onEvent(api_dependent *item, const GUID *classguid, int event, intptr_t param, void *ptr, size_t ptrlen);
  21. virtual void onSetVisible(int i);
  22. virtual int 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);
  23. // Callback methods that send hooks into the Script system
  24. virtual void onSelectAll();
  25. virtual void onDelete();
  26. virtual void onDoubleClick(int itemnum);
  27. virtual void onLeftClick(int itemnum);
  28. virtual void onSecondLeftClick(int itemnum);
  29. virtual int onRightClick(int itemnum);
  30. virtual int onColumnDblClick(int col, int x, int y);
  31. virtual int onColumnLabelClick(int col, int x, int y);
  32. virtual void onItemSelection(int itemnum, int selected);
  33. virtual int onIconLeftClick(int itemnum, int x, int y);
  34. enum {
  35. SCRIPTLIST_SETITEMS = 0,
  36. SCRIPTLIST_SETMULTISELECT,
  37. SCRIPTLIST_SETAUTODESELECT,
  38. SCRIPTLIST_SELECT,
  39. SCRIPTLIST_FEED,
  40. SCRIPTLIST_HOVERSELECT,
  41. SCRIPTLIST_SORT,
  42. SCRIPTLIST_SELECTONUPDOWN,
  43. SCRIPTLIST_NUMCOLUMNS,
  44. SCRIPTLIST_COLUMNWIDTHS,
  45. SCRIPTLIST_COLUMNLABELS,
  46. };
  47. protected:
  48. /*static */void CreateXMLParameters(int master_handle);
  49. private:
  50. static XMLParamPair params[];
  51. #ifdef WASABI_COMPILE_CONFIG
  52. void saveToConfig();
  53. void selectFromConfig();
  54. #endif
  55. void fillFromParams();
  56. int selectEntry(const wchar_t *e, int cb=1);
  57. void selectEntries(const wchar_t *multientry, int cb=1);
  58. void setNumColumns();
  59. void setColumnWidths();
  60. void setColumnLabels();
  61. void openFeed(const wchar_t *feedid);
  62. void closeFeed();
  63. //virtual int getColumnsHeight() { return 0; }
  64. virtual int wantHScroll() { return 0; }
  65. StringW items;
  66. StringW columnwidths;
  67. StringW columnlabels;
  68. int xmlnumcolumns;
  69. int last_numcolumns;
  70. int multiselect;
  71. int myxuihandle;
  72. int autosave;
  73. #ifdef WASABI_COMPILE_CONFIG
  74. int config_reentry;
  75. #endif
  76. svc_textFeed *feed;
  77. StringW last_feed;
  78. };
  79. // -----------------------------------------------------------------------------------------------------
  80. class GuiListScriptController : public ScriptObjectControllerI {
  81. public:
  82. virtual const wchar_t *getClassName() { return L"GuiList"; }
  83. virtual const wchar_t *getAncestorClassName() { return L"GuiObject"; }
  84. virtual ScriptObjectController *getAncestorController() { return WASABI_API_MAKI->maki_getController(guiObjectGuid); }
  85. virtual int getNumFunctions();
  86. virtual const function_descriptor_struct *getExportedFunctions();
  87. virtual GUID getClassGuid() { return guilistGuid; }
  88. virtual ScriptObject *instantiate();
  89. virtual void destroy(ScriptObject *o);
  90. virtual void *encapsulate(ScriptObject *o);
  91. virtual void deencapsulate(void *o);
  92. public:
  93. static scriptVar guilist_getNumItems(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  94. static /*int*/ scriptVar guilist_getWantAutoDeselect(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  95. static /*void*/ scriptVar guilist_setWantAutoDeselect(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar want);
  96. static /*void*/ scriptVar guilist_onSetVisible(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar show);
  97. static /*void*/ scriptVar guilist_setAutoSort(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar dosort);
  98. static /*void*/ scriptVar guilist_next(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  99. static /*void*/ scriptVar guilist_selectCurrent(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  100. static /*void*/ scriptVar guilist_selectFirstEntry(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  101. static /*void*/ scriptVar guilist_previous(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  102. static /*void*/ scriptVar guilist_pagedown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  103. static /*void*/ scriptVar guilist_pageup(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  104. static /*void*/ scriptVar guilist_home(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  105. static /*void*/ scriptVar guilist_end(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  106. static /*void*/ scriptVar guilist_reset(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  107. static /*int*/ scriptVar guilist_addColumn(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*String*/ scriptVar name, /*int*/ scriptVar width, /*int*/ scriptVar numeric);
  108. static /*int*/ scriptVar guilist_getNumColumns(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  109. static /*int*/ scriptVar guilist_getColumnWidth(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar column);
  110. static /*void*/ scriptVar guilist_setColumnWidth(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar column, /*int*/ scriptVar newwidth);
  111. static /*String*/ scriptVar guilist_getColumnLabel(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar column);
  112. static /*void*/ scriptVar guilist_setColumnLabel(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar column, /*String*/ scriptVar newlabel);
  113. static /*int*/ scriptVar guilist_getColumnNumeric(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar column);
  114. static /*void*/ scriptVar guilist_setColumnDynamic(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar column, /*int*/ scriptVar isdynamic);
  115. static /*int*/ scriptVar guilist_isColumnDynamic(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar column);
  116. static /*void*/ scriptVar guilist_setMinimumSize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar size);
  117. static /*int*/ scriptVar guilist_addItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*String*/ scriptVar label);
  118. static /*int*/ scriptVar guilist_insertItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar pos, /*String*/ scriptVar label);
  119. static /*int*/ scriptVar guilist_getLastAddedItemPos(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  120. static /*void*/ scriptVar guilist_setSubItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar pos, /*int*/ scriptVar subpos, /*String*/ scriptVar txt);
  121. static /*void*/ scriptVar guilist_deleteAllItems(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  122. static /*int*/ scriptVar guilist_deleteByPos(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar pos);
  123. static /*String*/ scriptVar guilist_getItemLabel(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar pos, /*int*/ scriptVar subpos);
  124. static /*void*/ scriptVar guilist_setItemLabel(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar pos, /*String*/ scriptVar text);
  125. static /*void*/ scriptVar guilist_setItemIcon(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar pos, /*String*/ scriptVar bitmapId);
  126. static /*string*/ scriptVar guilist_getItemIcon(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar pos);
  127. static /*void*/ scriptVar guilist_setShowIcons(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar onoff);
  128. static /*int*/ scriptVar guilist_getShowIcons(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  129. static /*int*/ scriptVar guilist_getIconWidth(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  130. static /*void*/ scriptVar guilist_setIconWidth(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val);
  131. static /*int*/ scriptVar guilist_getIconHeight(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  132. static /*void*/ scriptVar guilist_setIconHeight(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val);
  133. static /*int*/ scriptVar guilist_onIconLeftClick(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar pos, scriptVar x, scriptVar y);
  134. static /*int*/ scriptVar guilist_getItemSelected(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar pos);
  135. static /*int*/ scriptVar guilist_isItemFocused(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar pos);
  136. static /*int*/ scriptVar guilist_getItemFocused(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  137. static /*void*/ scriptVar guilist_setItemFocused(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar pos);
  138. static /*void*/ scriptVar guilist_ensureItemVisible(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar pos);
  139. static /*void*/ scriptVar guilist_invalidateColumns(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  140. static /*int*/ scriptVar guilist_scrollAbsolute(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar x);
  141. static /*int*/ scriptVar guilist_scrollRelative(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar x);
  142. static /*void*/ scriptVar guilist_scrollLeft(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar lines);
  143. static /*void*/ scriptVar guilist_scrollRight(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar lines);
  144. static /*void*/ scriptVar guilist_scrollUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar lines);
  145. static /*void*/ scriptVar guilist_scrollDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar lines);
  146. static /*String*/ scriptVar guilist_getSubitemText(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar pos, /*int*/ scriptVar subpos);
  147. static /*int*/ scriptVar guilist_getFirstItemSelected(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  148. static /*int*/ scriptVar guilist_getNextItemSelected(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar lastpos);
  149. static /*int*/ scriptVar guilist_selectAll(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  150. static /*int*/ scriptVar guilist_deselectAll(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  151. static /*int*/ scriptVar guilist_invertSelection(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  152. static /*int*/ scriptVar guilist_invalidateItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar pos);
  153. static /*int*/ scriptVar guilist_getFirstItemVisible(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  154. static /*int*/ scriptVar guilist_getLastItemVisible(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  155. static /*int*/ scriptVar guilist_setFontSize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar size);
  156. static /*int*/ scriptVar guilist_getFontSize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  157. static /*void*/ scriptVar guilist_jumpToNext(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*char*/ scriptVar c);
  158. static /*void*/ scriptVar guilist_scrollToItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar pos);
  159. static /*void*/ scriptVar guilist_resort(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  160. static /*int*/ scriptVar guilist_getSortDirection(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  161. static /*int*/ scriptVar guilist_getSortColumn(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  162. static /*void*/ scriptVar guilist_setSortColumn(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar col);
  163. static /*void*/ scriptVar guilist_setSortDirection(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar dir);
  164. static /*int*/ scriptVar guilist_getItemCount(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  165. static /*void*/ scriptVar guilist_setSelectionStart(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar pos);
  166. static /*void*/ scriptVar guilist_setSelectionEnd(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar pos);
  167. static /*void*/ scriptVar guilist_setSelected(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar pos, /*int*/ scriptVar selected);
  168. static /*void*/ scriptVar guilist_toggleSelection(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar pos, /*int*/ scriptVar setfocus);
  169. static /*int*/ scriptVar guilist_getHeaderHeight(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  170. static /*int*/ scriptVar guilist_getPreventMultipleSelection(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  171. static /*int*/ scriptVar guilist_setPreventMultipleSelection(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar val);
  172. static /*void*/ scriptVar guilist_moveItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar from, /*int*/ scriptVar to);
  173. static /*void*/ scriptVar guilist_onSelectAll(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  174. static /*void*/ scriptVar guilist_onDelete(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  175. static /*void*/ scriptVar guilist_onDoubleClick(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar itemnum);
  176. static /*void*/ scriptVar guilist_onLeftClick(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar itemnum);
  177. static /*void*/ scriptVar guilist_onSecondLeftClick(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar itemnum);
  178. static /*int*/ scriptVar guilist_onRightClick(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar itemnum);
  179. static /*int*/ scriptVar guilist_onColumnDblClick(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar col, /*int*/ scriptVar x, /*int*/ scriptVar y);
  180. static /*int*/ scriptVar guilist_onColumnLabelClick(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar col, /*int*/ scriptVar x, /*int*/ scriptVar y);
  181. static /*void*/ scriptVar guilist_onItemSelection(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, /*int*/ scriptVar itemnum, /*int*/ scriptVar selected);
  182. private:
  183. static function_descriptor_struct exportedFunction[];
  184. static StringW staticStr;
  185. };
  186. extern GuiListScriptController *guiListController;
  187. // -----------------------------------------------------------------------
  188. extern const wchar_t ScriptListXuiObjectStr[];
  189. extern char ScriptListXuiSvcName[];
  190. class ScriptListXuiSvc : public XuiObjectSvc<ScriptList, ScriptListXuiObjectStr, ScriptListXuiSvcName> {};
  191. #endif