1
0

group.h 10 KB

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