container.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. #ifdef WASABI_COMPILE_WNDMGR
  2. #ifndef __CONTAINER_H
  3. #define __CONTAINER_H
  4. class Container;
  5. class Layout;
  6. #include <bfc/ptrlist.h>
  7. #include <api/skin/xmlobject.h>
  8. #ifdef WASABI_WIDGETS_GUIOBJECT
  9. #include <api/script/objects/guiobj.h>
  10. #endif
  11. #include <api/script/script.h>
  12. #include <api/script/scriptobj.h>
  13. #include <api/script/objcontroller.h>
  14. #include <api/script/objects/rootobj.h>
  15. #define CONTAINER_UNDEFINED_NAME L"undefined container name"
  16. enum {
  17. CONTAINERPARAM_NAME = 0,
  18. CONTAINERPARAM_ID,
  19. CONTAINERPARAM_DYNAMIC,
  20. CONTAINERPARAM_DEFAULTX,
  21. CONTAINERPARAM_DEFAULTY,
  22. CONTAINERPARAM_DEFAULTVISIBLE,
  23. CONTAINERPARAM_CANCLOSE,
  24. CONTAINERPARAM_NOMENU,
  25. CONTAINERPARAM_NOFOCUSAPPONCLOSE,
  26. CONTAINERPARAM_CONTENT,
  27. };
  28. class ContainerScriptController: public ScriptObjectControllerI
  29. {
  30. public:
  31. virtual const wchar_t *getClassName();
  32. virtual const wchar_t *getAncestorClassName();
  33. virtual ScriptObjectController *getAncestorController();
  34. virtual int getNumFunctions();
  35. virtual const function_descriptor_struct *getExportedFunctions();
  36. virtual GUID getClassGuid();
  37. virtual ScriptObject *instantiate();
  38. virtual void destroy(ScriptObject *o);
  39. virtual void *encapsulate(ScriptObject *o);
  40. virtual void deencapsulate(void *o);
  41. virtual int getInstantiable();
  42. private:
  43. static function_descriptor_struct exportedFunction[];
  44. };
  45. class ContentEntry
  46. {
  47. public:
  48. ContentEntry(const wchar_t *gid, GUID g, ifc_window *w) : groupid(gid), guid(g), wnd(w) { }
  49. GUID guid;
  50. StringW groupid;
  51. ifc_window *wnd;
  52. };
  53. extern ContainerScriptController *containerController;
  54. #define CONTAINER_SCRIPTPARENT RootObjectInstance
  55. class Container : public CONTAINER_SCRIPTPARENT, public XmlObjectI, public DependentI
  56. {
  57. public:
  58. Container(int scriptid = -1);
  59. virtual ~Container();
  60. virtual void setName(const wchar_t *name);
  61. virtual void setId(const wchar_t *id);
  62. virtual const wchar_t *getName();
  63. virtual const wchar_t *getId();
  64. virtual int setXmlParam(const wchar_t *p, const wchar_t *v);
  65. virtual void onInit(int noshow = 0);
  66. virtual void addLayout(Layout *layout);
  67. virtual void resetLayouts();
  68. virtual void setVisible(int sh);
  69. virtual int isVisible();
  70. virtual void switchToLayout(const wchar_t *name, int moveit = 1);
  71. virtual void toggle();
  72. virtual void close();
  73. virtual void sysMenu();
  74. virtual int getNumLayouts();
  75. virtual Layout *enumLayout(int n);
  76. virtual Layout *getLayout(const wchar_t *name, int *pos = NULL);
  77. virtual int getScriptId();
  78. virtual void savePositions();
  79. void setDefaultLayout(const wchar_t *name);
  80. void loadFromDefaults(int noshow = 0);
  81. int isTranscient() { return transcient; }
  82. void setTranscient(int is) { transcient = is; }
  83. // player callbacks to notify that container/component
  84. // has been set visible/invisible
  85. virtual void otherContainerToggled(const wchar_t *id, int visible);
  86. virtual void componentToggled(GUID *g, int visible);
  87. virtual int isMainContainer();
  88. virtual int isDynamic();
  89. virtual void onSwitchToLayout(Layout *l);
  90. virtual void onBeforeSwitchToLayout(Layout *oldl, Layout *newl);
  91. virtual void onHideLayout(Layout *l);
  92. virtual void onShowLayout(Layout *l);
  93. virtual Layout *getCurrentLayout();
  94. virtual int getDefaultPositionX(void);
  95. virtual int getDefaultPositionY(void);
  96. virtual void onChildSetLayoutVisible(Layout *l, int v);
  97. virtual void notifyAddContent(ifc_window *w, const wchar_t *groupid, GUID guid = INVALID_GUID);
  98. virtual void notifyRemoveContent(ifc_window *w);
  99. virtual int hasContent(GUID g);
  100. virtual GUID getDefaultContent();
  101. const wchar_t *getDescriptor(void);
  102. virtual void getWindowRect(RECT *r);
  103. virtual void sendNotifyToAllLayouts(int notifymsg, int param1, int param2);
  104. void setDynamic(int i);
  105. void updateDefaultVisible();
  106. void setDeleting() { deleting = 1; }
  107. int isDeleting() { return deleting; }
  108. int isInited() { return inited; }
  109. int canClose() { return canclose; }
  110. void setCanClose(int c) { canclose = c; }
  111. GUID getGUID() { return myGUID; }
  112. int getNoMenu() { return nomenu; }
  113. void setPreventSaveVisibility(int p) { prevent_save_visibility = p; }
  114. int wantRefocusApp() { return refocusapponclose; }
  115. void setWantRefocusApp(int rf) { refocusapponclose = rf; }
  116. public:
  117. // ifc_dependent stuff
  118. static const GUID *depend_getClassGuid() {
  119. // {C439D9F4-34F5-453c-B947-448ED20203FC}
  120. static const GUID ret =
  121. { 0xc439d9f4, 0x34f5, 0x453c, { 0xb9, 0x47, 0x44, 0x8e, 0xd2, 0x2, 0x3, 0xfc } };
  122. return &ret;
  123. }
  124. enum
  125. {
  126. Event_NAMECHANGE = 0,
  127. };
  128. private:
  129. void containerCallback(int msg);
  130. StringW containerName;
  131. StringW containerId;
  132. PtrList<Layout> layouts;
  133. int currentLayout;
  134. StringW last_layout;
  135. int canclose;
  136. int lastLayout;
  137. int default_visible, loaded_default_visible;
  138. int ismain;
  139. int dynamic;
  140. int default_x = -1;
  141. int default_y = -1;
  142. int default_w = -1;
  143. int default_h = -1;
  144. int scriptid;
  145. int inited;
  146. int deleting;
  147. int transcient;
  148. PtrList<ContentEntry> contents;
  149. int switching_layout;
  150. int nomenu;
  151. int prevent_save_visibility;
  152. int refocusapponclose;
  153. GUID contentGuid;
  154. bool hasContentGuid;
  155. private:
  156. GUID myGUID;
  157. void showDefaultLayout(int noshow = 0);
  158. public:
  159. static scriptVar script_vcpu_getId(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  160. static scriptVar script_onSwitchToLayout(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar l);
  161. static scriptVar script_onBeforeSwitchToLayout(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar oldl, scriptVar newl);
  162. static scriptVar script_onHideLayout(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar l);
  163. static scriptVar script_onShowLayout(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar l);
  164. static scriptVar script_getLayout(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj);
  165. static scriptVar script_switchToLayout(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s);
  166. static scriptVar script_getCurrentLayout(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  167. static scriptVar script_show(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  168. static scriptVar script_hide(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  169. static scriptVar script_close(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  170. static scriptVar script_toggle(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  171. static scriptVar script_getNumLayouts(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  172. static scriptVar script_enumLayout(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar n);
  173. static scriptVar script_isDynamic(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  174. static scriptVar script_setName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar name);
  175. static scriptVar script_getName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  176. static scriptVar script_getGuid(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  177. static scriptVar script_setXmlParam(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar p, scriptVar v);
  178. static scriptVar script_onAddContent(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar window, scriptVar id, scriptVar g);
  179. };
  180. enum {
  181. CONT_CB_NONE,
  182. CONT_CB_VISIBLE,
  183. CONT_CB_HIDDEN
  184. };
  185. #endif
  186. #endif