1
0

wndholder.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. #ifndef __WINDOWHOLDER_H
  2. #define __WINDOWHOLDER_H
  3. #include <api/wnd/wndclass/guiobjwnd.h>
  4. #include <bfc/ptrlist.h>
  5. #include <api/syscb/callbacks/wndcb.h>
  6. #include <api/timer/timerclient.h>
  7. class svc_windowCreate;
  8. #define WINDOWHOLDER_PARENT GuiObjectWnd
  9. /**
  10. Class
  11. @short
  12. @author Nullsoft
  13. @ver 1.0
  14. @see
  15. */
  16. class WindowHolder : public Dispatchable
  17. {
  18. public:
  19. ifc_window *onInsertWindow(GUID g, const wchar_t *groupid);
  20. void onRemoveWindow(int deferred=0);
  21. int wantGuid(GUID g);
  22. int wantGroup(const wchar_t *groupid);
  23. GUID getCurGuid();
  24. const wchar_t *getCurGroupId();
  25. ifc_window *getCurRootWnd();
  26. const wchar_t *getCurId();
  27. ifc_window *getRootWndPtr();
  28. int acceptsGenericGuid();
  29. int acceptsGenericGroup();
  30. int wndholder_getPreferences(int what);
  31. void wndholder_onNeedReloadGroup(const wchar_t *id);
  32. void cancelDeferredRemove();
  33. int wndholder_wantAutoFocus();
  34. int wndholder_isAutoAvailable();
  35. enum {
  36. WNDHOLDER_ONINSERTWINDOW=50,
  37. WNDHOLDER_ONREMOVEWINDOW=100,
  38. WNDHOLDER_WANTGUID=150,
  39. WNDHOLDER_WANTGROUP=200,
  40. WNDHOLDER_GETROOTWNDPTR=250,
  41. WNDHOLDER_GETCURGUID=300,
  42. WNDHOLDER_GETCURGROUPID=350,
  43. WNDHOLDER_GETCURROOTWND=400,
  44. WNDHOLDER_GETCURID=450,
  45. WNDHOLDER_ISGENERICGUID=500,
  46. WNDHOLDER_ISGENERICGROUP=550,
  47. WNDHOLDER_GETPREFERENCES=600,
  48. WNDHOLDER_ONNEEDRELOADGRP=650,
  49. WNDHOLDER_CANCELDEFERREDREMOVE=660,
  50. WNDHOLDER_WANTAUTOFOCUS=670,
  51. WNDHOLDER_ISAUTOAVAILABLE=680,
  52. };
  53. };
  54. inline ifc_window *WindowHolder::onInsertWindow(GUID g, const wchar_t *groupid) {
  55. return _call(WNDHOLDER_ONINSERTWINDOW, (ifc_window *)NULL, g, groupid);
  56. }
  57. inline void WindowHolder::onRemoveWindow(int def) {
  58. _voidcall(WNDHOLDER_ONREMOVEWINDOW, def);
  59. }
  60. inline int WindowHolder::wantGuid(GUID g) {
  61. return _call(WNDHOLDER_WANTGUID, 0, g);
  62. }
  63. inline int WindowHolder::wantGroup(const wchar_t *groupid) {
  64. return _call(WNDHOLDER_WANTGROUP, 0, groupid);
  65. }
  66. inline ifc_window *WindowHolder::getRootWndPtr() {
  67. return _call(WNDHOLDER_GETROOTWNDPTR, (ifc_window *)NULL);
  68. }
  69. inline GUID WindowHolder::getCurGuid() {
  70. return _call(WNDHOLDER_GETCURGUID, INVALID_GUID);
  71. }
  72. inline const wchar_t *WindowHolder::getCurGroupId() {
  73. return _call(WNDHOLDER_GETCURGROUPID, (const wchar_t *)NULL);
  74. }
  75. inline ifc_window *WindowHolder::getCurRootWnd() {
  76. return _call(WNDHOLDER_GETCURROOTWND, (ifc_window *)NULL);
  77. }
  78. inline const wchar_t *WindowHolder::getCurId() {
  79. return _call(WNDHOLDER_GETCURID, (const wchar_t *)NULL);
  80. }
  81. inline int WindowHolder::acceptsGenericGuid() {
  82. return _call(WNDHOLDER_ISGENERICGUID, 0);
  83. }
  84. inline int WindowHolder::acceptsGenericGroup() {
  85. return _call(WNDHOLDER_ISGENERICGROUP, 0);
  86. }
  87. inline int WindowHolder::wndholder_getPreferences(int what) {
  88. return _call(WNDHOLDER_GETPREFERENCES, 0, what);
  89. }
  90. inline void WindowHolder::wndholder_onNeedReloadGroup(const wchar_t *id) {
  91. _voidcall(WNDHOLDER_ONNEEDRELOADGRP, id);
  92. }
  93. inline void WindowHolder::cancelDeferredRemove() {
  94. _voidcall(WNDHOLDER_CANCELDEFERREDREMOVE);
  95. }
  96. inline int WindowHolder::wndholder_wantAutoFocus() {
  97. return _call(WNDHOLDER_WANTAUTOFOCUS, 1);
  98. }
  99. inline int WindowHolder::wndholder_isAutoAvailable() {
  100. return _call(WNDHOLDER_ISAUTOAVAILABLE, 1);
  101. }
  102. class DeferredRemove;
  103. /**
  104. Class
  105. @short
  106. @author Nullsoft
  107. @ver 1.0
  108. @see
  109. */
  110. class WindowHolderI : public WindowHolder {
  111. public:
  112. WindowHolderI();
  113. virtual ~WindowHolderI();
  114. virtual ifc_window *onInsertWindow(GUID g, const wchar_t *groupid);
  115. virtual void onRemoveWindow(int deferred);
  116. void addAcceptGuid(GUID g);
  117. void addAcceptGroup(const wchar_t *groupid);
  118. void setAcceptAllGuids(int tf);
  119. void setAcceptAllGroups(int tf);
  120. virtual int acceptsGenericGroup() { return generic_group; }
  121. virtual int acceptsGenericGuid() { return generic_guid; }
  122. virtual int wantGuid(GUID g);
  123. virtual int wantGroup(const wchar_t *groupid);
  124. virtual void onInsert(ifc_window *w, const wchar_t *id) {};
  125. virtual void onRemove(ifc_window *w, const wchar_t *id) {};
  126. virtual ifc_window *getRootWndPtr()=0;
  127. virtual GUID getCurGuid() { return cur_guid; }
  128. virtual const wchar_t *getCurGroupId() { return cur_groupid; }
  129. virtual ifc_window *getCurRootWnd() { return wnd; }
  130. virtual GUID *getFirstAcceptedGuid();
  131. virtual const wchar_t *getFirstAcceptedGroup();
  132. virtual const wchar_t *getCurId() { return cur_id; }
  133. virtual void cancelDeferredRemove();
  134. virtual int wndholder_isAutoAvailable() { return 1; }
  135. GUID getDeferedGuid() { return defered_guid; }
  136. virtual int wndholder_getPreferences(int what)=0;
  137. virtual void wndholder_onNeedReloadGroup(const wchar_t *id);
  138. private:
  139. ifc_window *createWindow(const GUID *g, const wchar_t *groupid);
  140. virtual int wndholder_wantAutoFocus();
  141. void destroyWindow();
  142. ifc_window *wnd;
  143. GUID cur_guid;
  144. StringW cur_groupid;
  145. StringW cur_id;
  146. PtrList<GUID> accepted_guids;
  147. PtrList<StringW> accepted_groups;
  148. int generic_guid;
  149. int generic_group;
  150. svc_windowCreate *wc_svc;
  151. GUID defered_guid;
  152. DeferredRemove *dr;
  153. protected:
  154. RECVS_DISPATCH;
  155. };
  156. /**
  157. Class
  158. @short
  159. @author Nullsoft
  160. @ver 1.0
  161. @see
  162. */
  163. class WindowHolderWnd : public WINDOWHOLDER_PARENT, public WindowHolderI
  164. {
  165. public:
  166. WindowHolderWnd();
  167. virtual ~WindowHolderWnd();
  168. virtual int onInit();
  169. virtual ifc_window *getRootWndPtr() { return this; }
  170. virtual void onInsert(ifc_window *w, const wchar_t *id);
  171. virtual void onRemove(ifc_window *w, const wchar_t *id);
  172. virtual int onResize();
  173. virtual int handleRatio();
  174. virtual int handleDesktopAlpha();
  175. virtual int handleTransparency();
  176. virtual int wndholder_getPreferences(int what) { return getPreferences(what); }
  177. virtual int getPreferences(int what);
  178. void setAutoOpen(int tf) { autoopen = tf; }
  179. void setAutoClose(int tf) { autoclose = tf; }
  180. void setNoCmdBar(int tf) { nocmdbar = tf; if (isInited()) invalidate(); }
  181. void setNoAnim(int tf) { noanim = tf; }
  182. virtual int onGroupChange(const wchar_t *grpid);
  183. virtual int wndholder_wantAutoFocus();
  184. void setAutoFocus(int autof) { autofocus = autof; }
  185. void setAutoAvailable(int autoa) { autoavail = autoa; }
  186. virtual int wndholder_isAutoAvailable() { return autoavail; }
  187. private:
  188. void notifyOnRemove(); // no virtual please
  189. void notifyOnInsert(); // no virtual please
  190. virtual void onSetVisible(int show);
  191. virtual int onDeferredCallback(intptr_t p1, intptr_t p2);
  192. int autoopen;
  193. int autoclose;
  194. int nocmdbar;
  195. int noanim;
  196. int has_wnd;
  197. int autofocus;
  198. int autoavail;
  199. };
  200. class DeferredRemove : public TimerClientDI
  201. {
  202. public:
  203. DeferredRemove(WindowHolderI *parent) : whi(parent) {}
  204. virtual ~DeferredRemove() {}
  205. void post() {
  206. timerclient_postDeferredCallback(1, 0);
  207. }
  208. virtual int timerclient_onDeferredCallback(intptr_t p1, intptr_t p2) {
  209. if (p1 == 1 && whi != NULL) whi->onRemoveWindow(0);
  210. else return TimerClientDI::timerclient_onDeferredCallback(p1, p2);
  211. return 0;
  212. }
  213. private:
  214. WindowHolderI *whi;
  215. };
  216. #endif