skinnedmenuthreadinfo.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef NULLOSFT_MEDIALIBRARY_SKINNED_MENU_THREAD_INFO_HEADER
  2. #define NULLOSFT_MEDIALIBRARY_SKINNED_MENU_THREAD_INFO_HEADER
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #include <wtypes.h>
  7. #include "./klib/khash.h"
  8. #ifdef _WIN64
  9. KHASH_MAP_INIT_INT64(intptr_map, HWND);
  10. #else
  11. KHASH_MAP_INIT_INT(intptr_map, HWND);
  12. #endif
  13. KHASH_SET_INIT_INT(int_set)
  14. class SkinnedMenu;
  15. class SkinnedMenuWnd;
  16. class SkinnedMenuThreadInfo
  17. {
  18. protected:
  19. SkinnedMenuThreadInfo();
  20. ~SkinnedMenuThreadInfo();
  21. public:
  22. static HRESULT GetInstance(BOOL allowCreate, SkinnedMenuThreadInfo **instance);
  23. public:
  24. size_t AddRef();
  25. size_t Release();
  26. BOOL SetAttachHook(SkinnedMenu *menu);
  27. BOOL RemoveAttachHook(SkinnedMenu *menu);
  28. BOOL IsAttachHookActive();
  29. BOOL SetValidationHook(SkinnedMenuWnd *window);
  30. BOOL RemoveValidationHook(SkinnedMenuWnd *window);
  31. BOOL IsValidationHookActive();
  32. BOOL RegisterMenu(HMENU menu, HWND window);
  33. BOOL UnregisterMenu(HMENU menu);
  34. HWND FindMenuWindow(HMENU menu);
  35. void ClaimId(unsigned int id);
  36. void ReleaseId(unsigned int id);
  37. unsigned int GetAvailableId();
  38. HMENU SetActiveMeasureMenu(HMENU menu);
  39. HMENU GetActiveMeasureMenu();
  40. protected:
  41. LRESULT AttachHook(int nCode, WPARAM wParam, LPARAM lParam);
  42. LRESULT ValidationHook(int nCode, WPARAM wParam, LPARAM lParam);
  43. protected:
  44. friend static LRESULT CALLBACK SkinnedMenuThreadInfo_AttachHookCb(int nCode, WPARAM wParam, LPARAM lParam);
  45. friend static LRESULT CALLBACK SkinnedMenuThreadInfo_ValidationHookCb(int nCode, WPARAM wParam, LPARAM lParam);
  46. protected:
  47. size_t ref;
  48. HHOOK attachHook;
  49. SkinnedMenu *attachMenu;
  50. HHOOK validationHook;
  51. SkinnedMenuWnd *validationWindow;
  52. khash_t(intptr_map) *windowMap;
  53. khash_t(int_set) *claimedIdSet;
  54. unsigned int lastAssignedId;
  55. HMENU activeMeasureMenu;
  56. };
  57. #endif //NULLOSFT_MEDIALIBRARY_SKINNED_MENU_THREAD_INFO_HEADER