xuimenu.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #ifndef _XUIMENU_H
  2. #define _XUIMENU_H
  3. #include <api/wnd/wndclass/guiobjwnd.h>
  4. /*<?<autoheader/>*/
  5. #include "xuimenuso.h"
  6. /*?>*/
  7. #define XUIMENU_PARENT XuiMenuScriptObject
  8. // {A0211C57-DCED-45ae-AEA6-56014B5898E8}
  9. static const GUID xuiMenuGuid =
  10. { 0xa0211c57, 0xdced, 0x45ae, { 0xae, 0xa6, 0x56, 0x1, 0x4b, 0x58, 0x98, 0xe8 } };
  11. /*<?<classdecl name="XuiMenu" factory="ScriptObject" />*/
  12. class XuiMenu : public XuiMenuScriptObject
  13. {
  14. /*?>*/
  15. public:
  16. friend LRESULT CALLBACK xuimenu_KeyboardProc(int code, WPARAM wParam, LPARAM lParam);
  17. friend LRESULT CALLBACK xuimenu_msgProc(int code, WPARAM wParam, LPARAM lParam);
  18. XuiMenu();
  19. virtual ~XuiMenu();
  20. virtual int onInit();
  21. virtual int onLeftButtonDown(int x, int y);
  22. int setXuiParam(int _xuihandle, int xmlattrid, const wchar_t *name, const wchar_t *value);
  23. virtual void timerCallback(int c);
  24. virtual int onDeferredCallback(intptr_t p1, intptr_t p2);
  25. SCRIPT void setMenuGroup(const wchar_t *mg);
  26. SCRIPT const wchar_t *getMenuGroup() { return menugroup; }
  27. SCRIPT void setMenu(const wchar_t *m);
  28. SCRIPT const wchar_t *getMenu() { return menuid; }
  29. SCRIPT void spawnMenu(int monitor = 1);
  30. SCRIPT void cancelMenu();
  31. SCRIPT void setNormalId(const wchar_t *id);
  32. SCRIPT void setDownId(const wchar_t *id);
  33. SCRIPT void setHoverId(const wchar_t *id);
  34. SCRIPT EVENT virtual void onOpenMenu();
  35. SCRIPT EVENT virtual void onCloseMenu();
  36. virtual void onEnterArea();
  37. virtual void onLeaveArea();
  38. 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);
  39. SCRIPT void nextMenu();
  40. SCRIPT void previousMenu();
  41. enum {
  42. MENU_MENU = 0,
  43. MENU_MENUGROUP,
  44. MENU_NORMALID,
  45. MENU_DOWNID,
  46. MENU_HOVERID,
  47. MENU_NEXT,
  48. MENU_PREV,
  49. };
  50. protected:
  51. /*static */void CreateXMLParameters(int master_handle);
  52. private:
  53. static XMLParamPair params[];
  54. void onMenuSelect(HWND hwnd, HMENU menu, int menuitem, int flags);
  55. void startKbdHook();
  56. void stopKbdHook();
  57. void updateObjects();
  58. void timerCheck();
  59. void switchToMenu(XuiMenu *menu);
  60. void _nextMenu();
  61. void _previousMenu();
  62. void openAction();
  63. void onTrappedLeft();
  64. void onTrappedRight();
  65. StringW menugroup;
  66. StringW menuid;
  67. int xuihandle;
  68. XuiMenu *nextinchain;
  69. int timerset;
  70. int disablespawn;
  71. GuiObject *normal;
  72. GuiObject *down;
  73. GuiObject *hover;
  74. StringW next, prev;
  75. int isspawned;
  76. StringW normalid, downid, hoverid;
  77. int inarea;
  78. int kbdhook;
  79. int orig_x, orig_y;
  80. int kbdlocktimer;
  81. int submenu_isselected;
  82. int submenu_selectedbymouse;
  83. HMENU submenu_selected;
  84. HWND menu_parent;
  85. HMENU first_hmenu;
  86. HMENU cur_hmenu;
  87. };
  88. // -----------------------------------------------------------------------
  89. extern const wchar_t MenuXuiObjectStr[];
  90. extern char MenuXuiSvcName[];
  91. class MenuXuiSvc : public XuiObjectSvc<XuiMenu, MenuXuiObjectStr, MenuXuiSvcName> {};
  92. #endif