widget.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #ifndef _NULLSOFT_WINAMP_ML_DEVICES_WIDGET_HEADER
  2. #define _NULLSOFT_WINAMP_ML_DEVICES_WIDGET_HEADER
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #include <wtypes.h>
  7. #include "./widgetStyle.h"
  8. #define WIDGET_WINDOW_CLASS L"NullsoftDevicesWidget"
  9. typedef BOOL (*WidgetInitCallback)(HWND /*hwnd*/, void** /*self_out*/, void* /*param*/);
  10. typedef void (*WidgetDestroyCallback)(void* /*self*/, HWND /*hwnd*/);
  11. typedef void (*WidgetLayoutCallback)(void* /*self*/, HWND /*hwnd*/, WidgetStyle* /*style*/, const RECT* /*clientRect*/, SIZE* /*viewSize*/, BOOL /*redraw*/);
  12. typedef BOOL (*WidgetPaintCallback)(void* /*self*/, HWND /*hwnd*/, WidgetStyle* /*style*/, HDC /*hdc*/, const RECT* /*paintRect*/, BOOL /*erase*/);
  13. typedef BOOL (*WidgetMessageCallback)(void* /*self*/, HWND /*hwnd*/, unsigned int /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, LRESULT* /*result*/);
  14. typedef void (*WidgetStyleCallback)(void* /*self*/, HWND /*hwnd*/, WidgetStyle* /*style*/);
  15. typedef BOOL (*WidgetMouseCallback)(void* /*self*/, HWND /*hwnd*/, unsigned int /*vKeys*/, const POINT* /*cursor*/);
  16. typedef INT (*WidgetInputCallback)(void* /*self*/, HWND /*hwnd*/, unsigned int /*vKey*/, MSG* /*message*/);
  17. typedef BOOL (*WidgetKeyCallback)(void* /*self*/, HWND /*hwnd*/, unsigned int /*vKey*/, unsigned int /*flags*/);
  18. typedef void (*WidgetFocusCallback)(void* /*self*/, HWND /*hwnd*/, HWND /*focusHwnd*/, BOOL /*focusReceived*/);
  19. typedef BOOL (*WidgetMenuCallback)(void* /*self*/, HWND /*hwnd*/, HWND /*targetWindow*/, const POINT* /*cursor*/);
  20. typedef void (*WidgetZoomCallback)(void* /*self*/, HWND /*hwnd*/, NMTRBTHUMBPOSCHANGING* /*sliderInfo*/);
  21. typedef void (*WidgetScrollCallback)(void* /*self*/, HWND /*hwnd*/, int* /*dx*/, int* /*dy*/);
  22. typedef BOOL (*WidgetNotifyCallback)(void* /*self*/, HWND /*hwnd*/, NMHDR* /*notification*/, LRESULT* /*result*/);
  23. typedef BOOL (*WidgetHelpCallback)(void* /*self*/, HWND /*hwnd*/, wchar_t* /*buffer*/, size_t /*bufferMax*/);
  24. typedef struct WidgetInterface
  25. {
  26. WidgetInitCallback init;
  27. WidgetDestroyCallback destroy;
  28. WidgetLayoutCallback layout;
  29. WidgetPaintCallback paint;
  30. WidgetStyleCallback styleColorChanged;
  31. WidgetStyleCallback styleFontChanged;
  32. WidgetMouseCallback mouseMove;
  33. WidgetMouseCallback leftButtonDown;
  34. WidgetMouseCallback leftButtonUp;
  35. WidgetMouseCallback leftButtonDblClk;
  36. WidgetMouseCallback rightButtonDown;
  37. WidgetMouseCallback rightButtonUp;
  38. WidgetKeyCallback keyDown;
  39. WidgetKeyCallback keyUp;
  40. WidgetKeyCallback character;
  41. WidgetInputCallback inputRequest;
  42. WidgetFocusCallback focusChanged;
  43. WidgetMenuCallback contextMenu;
  44. WidgetZoomCallback zoomChanging;
  45. WidgetScrollCallback scrollBefore;
  46. WidgetScrollCallback scroll;
  47. WidgetNotifyCallback notify;
  48. WidgetHelpCallback help;
  49. WidgetMessageCallback messageProc;
  50. } WidgetInterface;
  51. HWND
  52. Widget_CreateWindow(unsigned int type,
  53. const WidgetInterface *callbacks,
  54. const wchar_t *text,
  55. unsigned long windowExStyle,
  56. unsigned long windowStyle,
  57. int x,
  58. int y,
  59. int width,
  60. int height,
  61. HWND parentWindow,
  62. unsigned int controlId,
  63. void *param);
  64. #define WIDGET_WM_FIRST (WM_USER + 10)
  65. #define WIDGET_WM_GET_TYPE (WIDGET_WM_FIRST + 0)
  66. #define WIDGET_GET_TYPE(/*HWND*/ _hwnd)\
  67. ((unsigned int)SendMessageW((_hwnd), WIDGET_WM_GET_TYPE, 0, 0L))
  68. #define WIDGET_WM_GET_SELF (WIDGET_WM_FIRST + 1)
  69. #define WIDGET_GET_SELF(/*HWND*/ _hwnd, _type)\
  70. ((_type*)SendMessageW((_hwnd), WIDGET_WM_GET_SELF, 0, 0L))
  71. #define WIDGET_WM_SET_STYLE (WIDGET_WM_FIRST + 2)
  72. #define WIDGET_SET_STYLE(/*HWND*/ _hwnd, /*WidgetStyle* */ _style)\
  73. ((BOOL)SendMessageW((_hwnd), WIDGET_WM_SET_STYLE, 0, (LPARAM)(_style)))
  74. #define WIDGET_WM_GET_STYLE (WIDGET_WM_FIRST + 3)
  75. #define WIDGET_GET_STYLE(/*HWND*/ _hwnd)\
  76. ((WidgetStyle*)SendMessageW((_hwnd), WIDGET_WM_GET_STYLE, 0, 0L))
  77. #define WIDGET_WM_STYLE_COLOR_CHANGED (WIDGET_WM_FIRST + 4)
  78. #define WIDGET_STYLE_COLOR_CHANGED(/*HWND*/ _hwnd)\
  79. (SendMessageW((_hwnd), WIDGET_WM_STYLE_COLOR_CHANGED, 0, 0L))
  80. #define WIDGET_WM_STYLE_FONT_CHANGED (WIDGET_WM_FIRST + 5)
  81. #define WIDGET_STYLE_FONT_CHANGED(/*HWND*/ _hwnd)\
  82. (SendMessageW((_hwnd), WIDGET_WM_STYLE_FONT_CHANGED, 0, 0L))
  83. #define WIDGET_WM_FREEZE (WIDGET_WM_FIRST + 6)
  84. #define WIDGET_FREEZE(/*HWND*/ _hwnd)\
  85. (SendMessageW((_hwnd), WIDGET_WM_FREEZE, TRUE, 0L))
  86. #define WIDGET_THAW(/*HWND*/ _hwnd)\
  87. (SendMessageW((_hwnd), WIDGET_WM_FREEZE, FALSE, 0L))
  88. #define WIDGET_WM_SET_SCROLL_POS (WIDGET_WM_FIRST + 7) // just offsets scroll positions wihtout scrolling view. result = (LRESULT)MAKELPARAM(actualDx,actualDy).
  89. #define WIDGET_SET_SCROLL_POS(/*HWND*/ _hwnd, /*int*/ _dx, /*int*/ _dy, /*BOOL*/ _redraw)\
  90. (SendMessageW((_hwnd), WIDGET_WM_SET_SCROLL_POS, (WPARAM)(_redraw), MAKELPARAM((_dx), (_dy))))
  91. #define WIDGET_WM_SCROLL (WIDGET_WM_FIRST + 8)
  92. #define WIDGET_SCROLL(/*HWND*/ _hwnd, /*int*/ _dx, /*int*/ _dy, /*BOOL*/ _redraw)\
  93. ((BOOL)SendMessageW((_hwnd), WIDGET_WM_SCROLL, (WPARAM)(_redraw), MAKELPARAM((_dx), (_dy))))
  94. #define WIDGET_WM_ZOOM_SLIDER_POS_CHANGING (WIDGET_WM_FIRST + 9)
  95. #define WIDGET_ZOOM_SLIDER_POS_CHANGING(/*HWND*/ _hwnd, /*NMTRBTHUMBPOSCHANGING* */ _sliderInfo)\
  96. ((BOOL)SendMessageW((_hwnd), WIDGET_WM_ZOOM_SLIDER_POS_CHANGING, 0, (LPARAM)(_sliderInfo)))
  97. #define WIDGET_WM_ENABLE_CHILDREN_SCROLL (WIDGET_WM_FIRST + 10)
  98. #define WIDGET_ENABLE_CHILDREN_SCROLL(/*HWND*/ _hwnd, /*BOOL*/ _enable)\
  99. ((BOOL)SendMessageW((_hwnd), WIDGET_WM_ENABLE_CHILDREN_SCROLL, 0, (LPARAM)(_enable)))
  100. #define WIDGET_WM_GET_CHILDREN_SCROLL_ENABLED (WIDGET_WM_FIRST + 11)
  101. #define WIDGET_GET_CHILDREN_SCROLL_ENABLED(/*HWND*/ _hwnd)\
  102. ((BOOL)SendMessageW((_hwnd), WIDGET_WM_GET_CHILDREN_SCROLL_ENABLED, 0, 0L))
  103. #define WIDGET_WM_GET_HELP_URL (WIDGET_WM_FIRST + 12)
  104. #define WIDGET_GET_HELP_URL(/*HWND*/ _hwnd, /* wchar_t* */ _buffer, /*size_t*/ _bufferMax)\
  105. ((BOOL)SendMessageW((_hwnd), WIDGET_WM_GET_HELP_URL, (WPARAM)(_bufferMax), (LPARAM)(_buffer)))
  106. #endif //_NULLSOFT_WINAMP_ML_DEVICES_WIDGET_HEADER