1
0

guiobjwnd.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. #ifndef __GUIOBJWND_H
  2. #define __GUIOBJWND_H
  3. #if defined(WIN32) || defined(WIN64)
  4. #define USEAPPBAR
  5. #endif
  6. #ifdef USEAPPBAR
  7. #include <api/wnd/wndclass/appbarwnd.h>
  8. #define GUIOBJECTWND_PARENT AppBarWnd
  9. #else
  10. #include <api/wnd/wndclass/clickwnd.h>
  11. #define GUIOBJECTWND_PARENT ClickWnd
  12. #endif
  13. #include <api/script/scriptobj.h>
  14. #include <api/script/objects/guiobject.h>
  15. #include <api/script/objects/rootobj.h>
  16. #include <api/skin/xmlobject.h>
  17. #include <api/service/svcs/svc_xuiobject.h>
  18. // {E5760861-5489-4ffc-BE02-061D9DA6CD1B}
  19. const GUID guiObjectWndGuid =
  20. { 0xe5760861, 0x5489, 0x4ffc, { 0xbe, 0x2, 0x6, 0x1d, 0x9d, 0xa6, 0xcd, 0x1b } };
  21. #define XUI_ATTRIBUTE_IMPLIED XML_ATTRIBUTE_IMPLIED
  22. #define XUI_ATTRIBUTE_REQUIRED XML_ATTRIBUTE_REQUIRED
  23. class GuiObjectWnd : public GUIOBJECTWND_PARENT, public RootObjectInstance, public XmlObjectI
  24. {
  25. public:
  26. GuiObjectWnd();
  27. virtual ~GuiObjectWnd();
  28. #ifdef WASABI_COMPILE_CONFIG
  29. virtual int onReloadConfig() { return 1; }
  30. #endif
  31. // XmlObject
  32. virtual int setXmlParamById(int xmlhandle, int attrid, const wchar_t *name, const wchar_t *value);
  33. virtual int onUnknownXmlParam(const wchar_t *param, const wchar_t *value);
  34. virtual int newXuiHandle() { return newXmlHandle(); }
  35. // ClickWnd
  36. virtual int onRightButtonDown(int x, int y);
  37. virtual int onRightButtonUp(int x, int y);
  38. virtual int onLeftButtonDown(int x, int y);
  39. virtual int onLeftButtonUp(int x, int y);
  40. virtual int onMouseMove(int x, int y);
  41. virtual int onLeftButtonDblClk(int x, int y);
  42. virtual int onRightButtonDblClk(int x, int y);
  43. virtual int onMouseWheelUp(int click, int lines);
  44. virtual int onMouseWheelDown(int click, int lines);
  45. virtual int onResize();
  46. virtual int onActivate();
  47. virtual int onDeactivate();
  48. virtual void onEnterArea();
  49. virtual void onLeaveArea();
  50. virtual void onSetVisible(int show);
  51. virtual int onEnable(int en);
  52. virtual void onCancelCapture();
  53. virtual int dragDrop(ifc_window *sourceWnd, int x, int y);
  54. virtual int acceptExternalDrops() { return 1; }
  55. virtual int dragEnter(ifc_window *sourceWnd);
  56. virtual int dragOver(int x, int y, ifc_window *sourceWnd);
  57. virtual int dragLeave(ifc_window *sourceWnd);
  58. virtual void *getInterface(GUID g);
  59. virtual int onAction(const wchar_t *action, const wchar_t *param, int x, int y, intptr_t p1, intptr_t p2, void *data, size_t datalen, ifc_window *source);
  60. virtual const wchar_t *getId();
  61. virtual int onAcceleratorEvent(const wchar_t *name);
  62. virtual void setContent(const wchar_t *groupid_orguid, int autoresizefromcontent = 0);
  63. virtual void setContentBySkinItem(SkinItem *item, int autoresizefromcontent = 0);
  64. virtual void onNewContent() {}
  65. // AbstractWndHolder
  66. virtual void abstract_onNewContent();
  67. virtual int onUnknownXuiParam(const wchar_t *param, const wchar_t *value) { return 0; }
  68. virtual GuiObject *findObject(const wchar_t *object_id);
  69. #ifdef WASABI_COMPILE_SCRIPT
  70. virtual ScriptObject *findScriptObject(const wchar_t *object_id);
  71. #endif
  72. #ifdef WASABI_COMPILE_SKIN
  73. virtual GuiObject *getContent() { return abstract_getContent(); }
  74. virtual ScriptObject *getContentScriptObject() { return abstract_getContentScriptObject(); }
  75. virtual ifc_window *getContentRootWnd() { return abstract_getContentRootWnd(); }
  76. #endif
  77. // BaseWnd
  78. virtual int onInit();
  79. virtual int onPostOnInit();
  80. virtual int onChar(unsigned int c);
  81. virtual int onKeyDown(int vkcode);
  82. virtual int onKeyUp(int vkcode);
  83. virtual int onGetFocus();
  84. virtual int onKillFocus();
  85. virtual int wantFocus();
  86. const wchar_t *getTip();
  87. // GuiObjectWnd
  88. int wantTranslation();
  89. GuiObject *getGuiObject();
  90. RootObject *getRootObject();
  91. int cfg_reentry;
  92. // XuiObject
  93. virtual int setXuiParam(int _xuihandle, int attrid, const wchar_t *name, const wchar_t *value);
  94. protected:
  95. /*static */void CreateXMLParameters(int master_handle);
  96. private:
  97. GuiObject *my_gui_object;
  98. int xuihandle;
  99. static XMLParamPair params[];
  100. public:
  101. enum {
  102. GUIOBJECT_ID = 0,
  103. GUIOBJECT_ALPHA,
  104. GUIOBJECT_ACTIVEALPHA,
  105. GUIOBJECT_INACTIVEALPHA,
  106. GUIOBJECT_SYSREGION,
  107. GUIOBJECT_RECTRGN,
  108. GUIOBJECT_TOOLTIP,
  109. GUIOBJECT_SYSMETRICSX,
  110. GUIOBJECT_SYSMETRICSY,
  111. GUIOBJECT_SYSMETRICSW,
  112. GUIOBJECT_SYSMETRICSH,
  113. GUIOBJECT_MOVE,
  114. GUIOBJECT_RENDERBASETEXTURE,
  115. GUIOBJECT_CFGATTR,
  116. GUIOBJECT_X,
  117. GUIOBJECT_Y,
  118. GUIOBJECT_W,
  119. GUIOBJECT_H,
  120. GUIOBJECT_VISIBLE,
  121. GUIOBJECT_ENABLED,
  122. GUIOBJECT_RELATX,
  123. GUIOBJECT_RELATY,
  124. GUIOBJECT_RELATW,
  125. GUIOBJECT_RELATH,
  126. GUIOBJECT_DROPTARGET,
  127. GUIOBJECT_GHOST,
  128. GUIOBJECT_NOTIFY,
  129. GUIOBJECT_FOCUSONCLICK,
  130. GUIOBJECT_TABORDER,
  131. GUIOBJECT_WANTFOCUS,
  132. GUIOBJECT_SETNODBLCLICK,
  133. GUIOBJECT_SETNOLEFTCLICK,
  134. GUIOBJECT_SETNORIGHTCLICK,
  135. GUIOBJECT_SETNOMOUSEMOVE,
  136. GUIOBJECT_SETNOCONTEXTMENU,
  137. GUIOBJECT_SETX1,
  138. GUIOBJECT_SETY1,
  139. GUIOBJECT_SETX2,
  140. GUIOBJECT_SETY2,
  141. GUIOBJECT_SETANCHOR,
  142. GUIOBJECT_SETCURSOR,
  143. GUIOBJECT_FITTOPARENT,
  144. GUIOBJECT_USERDATA,
  145. #ifdef USEAPPBAR
  146. GUIOBJECT_APPBAR,
  147. #endif
  148. GUIOBJECT_TRANSLATE,
  149. GUIOBJECT_NUMPARAMS
  150. };
  151. };
  152. template <class T, const wchar_t XMLTAG[], char SVCNAME[]>
  153. class XuiObjectSvc : public svc_xuiObjectI
  154. {
  155. public:
  156. static const wchar_t *xuisvc_getXmlTag() { return XMLTAG; }
  157. int testTag(const wchar_t *xmltag)
  158. {
  159. if (!WCSICMP(xmltag, XMLTAG)) return 1;
  160. return 0;
  161. }
  162. GuiObject *instantiate(const wchar_t *xmltag, ifc_xmlreaderparams *params = NULL)
  163. {
  164. if (testTag(xmltag))
  165. {
  166. T * obj = new T;
  167. ASSERT(obj != NULL);
  168. return obj->getGuiObject();
  169. }
  170. return NULL;
  171. }
  172. void destroy(GuiObject *g)
  173. {
  174. T *obj = static_cast<T *>(g->guiobject_getRootWnd());
  175. delete obj;
  176. }
  177. static const char *getServiceName() { return SVCNAME; }
  178. };
  179. template <class T>
  180. class XuiObjectSvc2 : public svc_xuiObjectI
  181. {
  182. public:
  183. static const wchar_t *xuisvc_getXmlTag() { return T::xuiobject_getXmlTag(); }
  184. int testTag(const wchar_t *xmltag)
  185. {
  186. if (!WCSICMP(xmltag, T::xuiobject_getXmlTag())) return 1;
  187. return 0;
  188. }
  189. GuiObject *instantiate(const wchar_t *xmltag, ifc_xmlreaderparams *params = NULL)
  190. {
  191. if (testTag(xmltag))
  192. {
  193. T * obj = new T;
  194. ASSERT(obj != NULL);
  195. return obj->getGuiObject();
  196. }
  197. return NULL;
  198. }
  199. void destroy(GuiObject *g)
  200. {
  201. T *obj = static_cast<T *>(g->guiobject_getRootWnd());
  202. delete obj;
  203. }
  204. static const char *getServiceName() { return T::xuiobject_getServiceName(); }
  205. };
  206. #endif