abstractwndhold.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. #ifndef __ABSTRACTWNDHOLD_H
  2. #define __ABSTRACTWNDHOLD_H
  3. #include <api/wnd/wndclass/svcwndhold.h>
  4. #include <api/syscb/callbacks/wndcb.h>
  5. class GuiObject;
  6. class ScriptObject;
  7. class SkinItem;
  8. #define ABSTRACTWNDHOLDER_PARENT ServiceWndHolder
  9. /**
  10. The AbstractWndHolder enables you to display deferred content. This means
  11. the content does not actually need to exist at creation. It will be automatically
  12. loaded when it is found.
  13. This class is meant to be derived from. You shouldn't create an AbstractWndHolder
  14. directly to implement this kind of functionality. Please use GuiObjectWnd along
  15. with the setContent() method.
  16. @short An abstracted window holder with deferred content loading.
  17. @author Nullsoft
  18. @ver 1.0
  19. @see GuiObjectWnd
  20. */
  21. class AbstractWndHolder : public ABSTRACTWNDHOLDER_PARENT, public WndCallbackI {
  22. protected:
  23. // don't create me directly, create a GuiObjectWnd and setContent("group.id") on it
  24. // these are for inheriting and have a deferred content (so if you _were_ using that,
  25. // your findObjects would fail right after init and before abstract_onNewContent)
  26. /**
  27. Sets the group id of the content and the auto resize flag.
  28. Setting the auto resize flag to 1 will enable the automatic resize of
  29. the window according to the size of the content attempting to be
  30. displayed.
  31. @param groupid The content group.
  32. @param _autoresizefromcontent 0, disable auto resize; 1, enable auto resize;
  33. */
  34. AbstractWndHolder(const wchar_t *groupid=NULL, int _autoresizefromcontent=0);
  35. AbstractWndHolder(SkinItem *groupitem, int _autoresizefromcontent=0);
  36. /**
  37. Finds the group with the matching GUID and uses that group as the content.
  38. This insures you get the exact group and not a replacement.
  39. Setting the auto resize flag to 1 will enable the automatic resize of
  40. the window according to the size of the content attempting to be
  41. displayed.
  42. @param _guid The GUID the content group.
  43. @param _autoresizefromcontent 0, disable auto resize; 1, enable auto resize;
  44. */
  45. AbstractWndHolder(GUID _guid, int _autoresizefromcontent=0);
  46. public:
  47. /**
  48. Destroys the instance of the group used for content automatically.
  49. */
  50. virtual ~AbstractWndHolder();
  51. /**
  52. Sets the content group using the group id.
  53. @param groupid The content group id.
  54. @param _autoresizefromcontent -1, no change; 0, disable auto resize; 1, enable auto resize;
  55. */
  56. virtual void abstract_setContent(const wchar_t *groupid, int _autoresizefromcontent=-1); // -1 = no change, 0 = false, 1 = true
  57. /**
  58. Sets the content group using the group's GUID.
  59. This insures you get the exact group and not a replacement.
  60. @param g The content group's GUID.
  61. @param _autoresizefromcontent -1, no change; 0, disable auto resize; 1, enable auto resize;
  62. */
  63. virtual void abstract_setContent(GUID g, int _autoresizefromcontent=-1); // -1 = no change, 0 = false, 1 = true
  64. virtual void abstract_setContentBySkinItem(SkinItem *groupitem, int _autoresizefromcontent=-1); // -1 = no change, 0 = false, 1 = true
  65. /**
  66. This event is triggered when the content is loaded or the content changes.
  67. Override it to implement your own handling of this event.
  68. */
  69. virtual void abstract_onNewContent();
  70. /**
  71. This event is triggered when the content group is changed.
  72. Override it to implement your own handling of this event.
  73. @see abstract_setContant()
  74. @ret 1, if you handle the event;
  75. @param grpid The new group that was set.
  76. */
  77. virtual int onGroupChange(const wchar_t *grpid);
  78. /**
  79. This event is triggered when the visibility of the window changes.
  80. Override it to implement your own handling of this event.
  81. @see onGroupChange()
  82. @param show 0, hide window; 1, show window;
  83. */
  84. virtual void onSetVisible(int show);
  85. /**
  86. This event is triggered when the window is being initialized.
  87. Override it to implement your own handling of this event.
  88. @ret 1, if you handle the event;
  89. */
  90. virtual int onInit();
  91. /**
  92. This event is triggered when the window is resized.
  93. Override it to implement your own handling of this event.
  94. @ret 1, if you handle the event;
  95. */
  96. virtual int onResize();
  97. /**
  98. Get the api_window.
  99. @ret
  100. */
  101. ifc_window *rootwndholder_getRootWnd();
  102. /**
  103. Find an object in the content group. This is done via
  104. the object's text id.
  105. @see abstract_findScriptObject()
  106. @ret !NULL, The requested object pointer; NULL, Failed to find object.
  107. @param The id of the object to find.
  108. */
  109. virtual GuiObject *abstract_findObject(const wchar_t *object_id);
  110. /**
  111. Find a script object in the content group. This is done via the
  112. script object's text id.
  113. @see abstract_findObject()
  114. @ret !NULL, The requested script object pointer; NULL, Failed to find the object.
  115. @param The id of the script object to find.
  116. // TODO: benski> currently unused. cut?
  117. */
  118. virtual ScriptObject *abstract_findScriptObject(const wchar_t *object_id);
  119. /**
  120. Get the content group.
  121. @see abstract_getContentScriptObject()
  122. @ret A pointer to the content group GuiObject.
  123. */
  124. virtual GuiObject *abstract_getContent();
  125. /**
  126. Get the content script object.
  127. @see abstract_getContent()
  128. @ret A pointer to the content ScriptObject.
  129. */
  130. virtual ScriptObject *abstract_getContentScriptObject();
  131. /**
  132. Get the ifc_window that is holding the content group.
  133. @see rootwndholder_getRootWnd()
  134. @ret A pointer to the ifc_window holding the content group.
  135. */
  136. virtual ifc_window *abstract_getContentRootWnd() { return group; }
  137. /**
  138. Read the auto-resize from content flag.
  139. @see abstract_setAutoResizeFromContent()
  140. @ret 0, disable auto resize; 1, enable auto resize;
  141. @param
  142. */
  143. virtual int abstract_wantAutoResizeFromContent() { return autoresizefromcontent; }
  144. /**
  145. Set the auto-resize from content flag.
  146. @see abstract_wantAutoResizeFromContent()
  147. @param i 0, disable auto resize; 1, enable auto resize;
  148. */
  149. virtual void abstract_setAutoResizeFromContent(int i) { autoresizefromcontent = i; }
  150. /**
  151. Set the allow deferred content flag. Allowing deferred content enables content to be
  152. loaded after the window is shown.
  153. @param allow 0, Do not allow; 1, Allow
  154. */
  155. virtual void abstract_setAllowDeferredContent(int allow) { allow_deferred_content = allow; }
  156. /**
  157. The deferred callback.
  158. @ret 1, If you handle the event.
  159. @param p1
  160. @param p2
  161. */
  162. virtual int onDeferredCallback(intptr_t p1, intptr_t p2);
  163. virtual void setContentSkinItem(SkinItem *groupitem, int autoresize=-1);
  164. virtual void abstract_setScriptsEnabled(int en);
  165. virtual int abstact_getScriptsEnabled();
  166. private:
  167. /**
  168. Creates the child content window when required.
  169. */
  170. void createChild();
  171. /**
  172. Set Both Content.
  173. @param guid
  174. @param g
  175. @param _autoresizefromcontent
  176. */
  177. void setBothContent(const wchar_t *guid, GUID g, int _autoresizefromcontent);
  178. /**
  179. Loads the content from the previously specified group.
  180. @see abstract_setContent()
  181. */
  182. void doLoadContent();
  183. /**
  184. Destroys the instantiated copy of the content group.
  185. */
  186. void destroyContent();
  187. StringW groupid;
  188. GUID guid;
  189. ifc_window *group;
  190. int cbreg;
  191. int inselfresize;
  192. int autoresizefromcontent;
  193. int allow_deferred_content;
  194. int need_deferred_load;
  195. SkinItem *group_item;
  196. int scripts_enabled = 0;
  197. };
  198. #endif