1
0

group.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. #include "widgets/group.h"
  2. #if 0 // not in use
  3. #ifndef __GROUP_H
  4. #define __GROUP_H
  5. #ifndef _NOSTUDIO
  6. class Group;
  7. class Container;
  8. class Layout;
  9. class CfgItem;
  10. class CfgGroup;
  11. class SRegion;
  12. #include <bfc/tlist.h>
  13. #include <bfc/depview.h>
  14. #include <api/wnd/wndclass/embeddedxui.h>
  15. #include <api/wnd/wndclass/clickwnd.h>
  16. #include <api/wnd/wndclass/buttwnd.h>
  17. #include <tataki/bitmap/bitmap.h>
  18. #include <tataki/region/region.h>
  19. #ifdef WASABI_COMPILE_CONFIG
  20. #include <api/config/items/cfgitem.h>
  21. #endif // wasabi_compile_config
  22. #include <api/wndmgr/container.h>
  23. #endif // _nostudio
  24. #include <api/script/script.h>
  25. #include <api/script/scriptobj.h>
  26. #ifdef WASABI_WIDGETS_GUIOBJECT
  27. #include <api/script/objects/guiobj.h>
  28. #endif
  29. // {80F0F8BD-1BA5-42a6-A093-3236A00C8D4A}
  30. static const GUID cfgGroupGuid =
  31. { 0x80f0f8bd, 0x1ba5, 0x42a6, { 0xa0, 0x93, 0x32, 0x36, 0xa0, 0xc, 0x8d, 0x4a } };
  32. #define RESIZE_MINW 96
  33. #define RESIZE_MINH 24
  34. class XmlObject;
  35. class GroupScriptController : public GuiObjectScriptController {
  36. public:
  37. virtual const wchar_t *getClassName();
  38. virtual const wchar_t *getAncestorClassName();
  39. virtual ScriptObjectController *getAncestorController() { return guiController; }
  40. virtual int getNumFunctions();
  41. virtual const function_descriptor_struct *getExportedFunctions();
  42. virtual GUID getClassGuid();
  43. virtual ScriptObject *instantiate();
  44. virtual void destroy(ScriptObject *o);
  45. virtual void *encapsulate(ScriptObject *o);
  46. virtual void deencapsulate(void *o);
  47. virtual int getInstantiable();
  48. virtual ScriptObject *cast(ScriptObject *, GUID g);
  49. private:
  50. static function_descriptor_struct exportedFunction[];
  51. };
  52. extern GroupScriptController *groupController;
  53. class XuiParam {
  54. public:
  55. XuiParam(const wchar_t *_param, const wchar_t *_value) : param(_param), value(_value) {}
  56. virtual ~XuiParam() {}
  57. StringW param;
  58. StringW value;
  59. };
  60. #define GROUP_PARENT EmbeddedXuiObject
  61. class Group : public GROUP_PARENT {
  62. public:
  63. Group();
  64. virtual ~Group();
  65. int onPaint(Canvas *canvas);
  66. virtual int onResize();
  67. virtual int onPostedMove();
  68. virtual int onInit();
  69. virtual Container *getParentContainer();
  70. virtual int childNotify(ifc_window *child, int msg, intptr_t p1, intptr_t p2);
  71. virtual void setBaseTexture(const wchar_t *b, int regis=1);
  72. virtual SkinBitmap *getBaseTexture();
  73. virtual ifc_window *getBaseTextureWindow();
  74. virtual int setXmlParam(const wchar_t *paramname, const wchar_t *strvalue);
  75. virtual int setXuiParam(int _xuihandle, int xuiid, const wchar_t *paramname, const wchar_t *strvalue);
  76. virtual api_region *getRegion();
  77. virtual void setRegion(api_region *r);
  78. void reloadDefaults();
  79. virtual int onGroupChange(const wchar_t *id);
  80. virtual void autoResize();
  81. virtual void startScripts();
  82. void onCreateObject(GuiObject *o);
  83. GuiObject *getObject(const wchar_t *id);
  84. void sendNotifyToAllChildren(int notifymsg, int param1, int param2);
  85. int isDeleting() { return deleting; }
  86. void updatePos(GuiObject *o, RECT *r=NULL);
  87. AutoSkinBitmap *background;
  88. int x, y;
  89. LPARAM wndHolder_getParentParam(int i=0);
  90. virtual void setDesignWidth(int w);
  91. virtual void setDesignHeight(int h);
  92. virtual int getDesignWidth();
  93. virtual int getDesignHeight();
  94. virtual void invalidateWindowRegion();
  95. virtual void setRegionOp(int o);
  96. virtual void setGroupContent(const wchar_t *id, SkinItem *specific_item, int scripts_enabled);
  97. virtual const wchar_t *getGroupContentId();
  98. virtual SkinItem *getGroupContentSkinItem();
  99. virtual void setAutoWidthSource(const wchar_t *obj);
  100. virtual void setAutoHeightSource(const wchar_t *obj);
  101. virtual void cancelCapture() {};
  102. virtual int getPreferences(int what);
  103. virtual const wchar_t *vcpu_getClassName();
  104. virtual ScriptObjectController *vcpu_getController() { return groupController; }
  105. int getNumObjects();
  106. ifc_window *enumObjects(int i);
  107. void addChild(GuiObject *g);
  108. void removeChild(GuiObject *g);
  109. #ifdef WASABI_COMPILE_WNDMGR
  110. virtual void mouseResize(int x, int y, int resizeway);// screen coords!
  111. virtual void beginMove();
  112. virtual void beginScale();
  113. virtual void beginResize();
  114. virtual void endMove();
  115. virtual void endScale();
  116. virtual void endResize();
  117. #endif
  118. virtual int getAutoWidth(void);
  119. virtual int getAutoHeight(void);
  120. virtual int isLayout();
  121. void setDrawBackground(int t);
  122. int getDrawBackground(void);
  123. #ifdef WASABI_COMPILE_CONFIG
  124. static int isCfgGroup(Group *ptr);
  125. #endif
  126. void addScript(int scriptid);
  127. void deleteScripts();
  128. int enumScript(int n);
  129. int getNumScripts();
  130. virtual int isDesktopAlphaSafe();
  131. virtual int isTransparencySafe(int excludeme=0);
  132. static int isGroup(Group *o);
  133. const wchar_t *getBackgroundStr();
  134. int getWidthBasedOn(GuiObject *o=NULL);
  135. int getHeightBasedOn(GuiObject *o=NULL);
  136. void fixPosition();
  137. const wchar_t *embeddedxui_getEmbeddedObjectId() { return xui_embedded_id; }
  138. virtual void onFillGroup();
  139. virtual int onUnknownXuiParam(const wchar_t *xmlattributename, const wchar_t *value);
  140. virtual ScriptObject *script_cast(GUID g);
  141. virtual void onMinMaxEnforcerChanged();
  142. virtual int isTransparencyForcedOff() { return 0; }
  143. protected:
  144. static PtrList<CfgGroup> cfggrouplist;
  145. private:
  146. StringW basetextureStr;
  147. StringW xui_embedded_id;
  148. void invalidateScaledReg();
  149. void ensureScaledRegValid();
  150. int resizing;
  151. int size_w,size_h;
  152. int cX,cY;
  153. int captured;
  154. POINT mousepos;
  155. int propagatesize;
  156. PtrList<XuiParam> xuiparams;
  157. int moving;
  158. int mover;
  159. int drawbackground;
  160. RECT oldRect;
  161. int groupmaxheight;
  162. int groupmaxwidth;
  163. int groupminheight;
  164. int groupminwidth;
  165. int lockminmax;
  166. // int regionop;
  167. TList<int> scripts;
  168. RegionI *subtractedreg;
  169. static PtrList<Group> groups;
  170. StringW backgroundstr;
  171. StringW instanceid;
  172. RegionI *reg;
  173. RegionI *scaledreg;
  174. int scaledregionvalid;
  175. int autoregionop;
  176. StringW content_id;
  177. SkinItem *content_item;
  178. int no_init_on_addchild;
  179. StringW autoheightsource;
  180. StringW autowidthsource;
  181. GuiObject *lastheightsource;
  182. GuiObject *lastwidthsource;
  183. int lastgetwidthbasedon, lastgetheightbasedon;
  184. int default_w, default_h;
  185. int design_w, design_h;
  186. int scripts_enabled;
  187. int xuihandle;
  188. static XMLParamPair groupParams[];
  189. protected:
  190. enum {
  191. XUIGROUP_INSTANCEID=0,
  192. XUIGROUP_BACKGROUND,
  193. XUIGROUP_DRAWBACKGROUND,
  194. XUIGROUP_DEFAULT_W,
  195. XUIGROUP_DEFAULT_H,
  196. XUIGROUP_MAXIMUM_H,
  197. XUIGROUP_MAXIMUM_W,
  198. XUIGROUP_MINIMUM_H,
  199. XUIGROUP_MINIMUM_W,
  200. XUIGROUP_PROPAGATESIZE,
  201. XUIGROUP_LOCKMINMAX,
  202. XUIGROUP_NAME,
  203. XUIGROUP_AUTOWIDTHSOURCE,
  204. XUIGROUP_AUTOHEIGHTSOURCE,
  205. XUIGROUP_EMBED_XUI,
  206. XUIGROUP_XUITAG,
  207. XUIGROUP_INHERIT_GROUP,
  208. XUIGROUP_INHERIT_CONTENT,
  209. XUIGROUP_DESIGN_W,
  210. XUIGROUP_DESIGN_H,
  211. XUIGROUP_NUMPARAMS,
  212. };
  213. // FG>
  214. // -- SCRIPT -----------------------------------------------------
  215. private:
  216. PtrList<ScriptObject> script_objects;
  217. PtrList<GuiObject> gui_objects;
  218. int deleting;
  219. int skinpart;
  220. int alpha;
  221. int disable_update_pos;
  222. public:
  223. void addObject(GuiObject *o);
  224. void removeObject(GuiObject *o);
  225. void setSkinPartId(int i) { skinpart = i; }
  226. int getSkinPartId() { return skinpart; }
  227. static scriptVar script_vcpu_getObject(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj);
  228. static scriptVar script_vcpu_getNumObjects(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  229. static scriptVar script_vcpu_enumObject(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i);
  230. static scriptVar script_vcpu_onCreateObject(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar ob);
  231. static scriptVar script_vcpu_getMousePosX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  232. static scriptVar script_vcpu_getMousePosY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  233. static scriptVar script_vcpu_subtractRegion(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar reg);
  234. static scriptVar script_vcpu_isLayout(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  235. static scriptVar script_vcpu_autoResize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  236. static void instantiate(Layout *l);
  237. };
  238. extern const wchar_t groupXuiObjectStr[];
  239. extern char groupXuiSvcName[];
  240. class GroupXuiSvc : public XuiObjectSvc<Group, groupXuiObjectStr, groupXuiSvcName> {};
  241. #ifdef WASABI_COMPILE_CONFIG
  242. class CfgGroupScriptController : public GroupScriptController {
  243. public:
  244. virtual const wchar_t *getClassName();
  245. virtual const wchar_t *getAncestorClassName();
  246. virtual ScriptObjectController *getAncestorController() { return groupController; }
  247. virtual int getNumFunctions();
  248. virtual const function_descriptor_struct *getExportedFunctions();
  249. virtual GUID getClassGuid();
  250. virtual ScriptObject *instantiate();
  251. virtual int getInstantiable();
  252. private:
  253. static function_descriptor_struct exportedFunction[];
  254. };
  255. extern CfgGroupScriptController *cfgGroupController;
  256. class CfgGroup : public Group, public DependentViewerTPtr<CfgItem> {
  257. public:
  258. CfgGroup();
  259. virtual ~CfgGroup();
  260. void setAttr(CfgItem *item, const wchar_t *name);
  261. const wchar_t *vcpu_getClassName();
  262. virtual ScriptObjectController *vcpu_getController() { return cfgGroupController; }
  263. virtual int viewer_onEvent(CfgItem *item, int event, intptr_t param, void *ptr, size_t ptrlen);
  264. virtual void dataChanged();
  265. CfgItem *getCfgItem();
  266. const wchar_t *getAttributeName();
  267. const wchar_t *getCfgGuid() { return cfgguid; }
  268. virtual int onInit();
  269. static scriptVar script_vcpu_cfgGetInt(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  270. static scriptVar script_vcpu_cfgSetInt(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v);
  271. static scriptVar script_vcpu_cfgGetFloat(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  272. static scriptVar script_vcpu_cfgSetFloat(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v);
  273. static scriptVar script_vcpu_cfgGetString(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  274. static scriptVar script_vcpu_cfgSetString(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v);
  275. static scriptVar script_vcpu_cfgGetName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  276. static scriptVar script_vcpu_cfgGetGuid(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  277. static scriptVar script_vcpu_onCfgChanged(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  278. private:
  279. CfgItem *cfgitem;
  280. StringW attrname;
  281. StringW cfgguid;
  282. static wchar_t txt[512];
  283. };
  284. extern const wchar_t cfgGroupXuiObjectStr[];
  285. extern char cfgGroupXuiSvcName[];
  286. class CfgGroupXuiSvc : public XuiObjectSvc<CfgGroup, cfgGroupXuiObjectStr, cfgGroupXuiSvcName> {};
  287. #endif // wasabi_compile_config
  288. #endif // group.h
  289. #endif