1
0

widgetStyle.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. #ifndef _NULLSOFT_WINAMP_ML_DEVICES_WIDGETSTYLE_HEADER
  2. #define _NULLSOFT_WINAMP_ML_DEVICES_WIDGETSTYLE_HEADER
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #include <wtypes.h>
  7. typedef struct WidgetStyle WidgetStyle;
  8. typedef enum WidgetStyleFlags WidgetStyleFlags;
  9. typedef enum WidgetStyleAssignFlags WidgetStyleAssignFlags;
  10. enum WidgetStyleFlags
  11. {
  12. WIDGETSTYLE_OWN_TEXT_FONT = (1 << 0),
  13. WIDGETSTYLE_OWN_TITLE_FONT = (1 << 1),
  14. WIDGETSTYLE_OWN_CATEGORY_FONT = (1 << 2),
  15. WIDGETSTYLE_OWN_BACK_BRUSH = (1 << 3),
  16. WIDGETSTYLE_OWN_CATEGORY_BRUSH = (1 << 4),
  17. };
  18. DEFINE_ENUM_FLAG_OPERATORS(WidgetStyleFlags);
  19. enum WidgetStyleAssignFlags
  20. {
  21. WIDGETSTYLE_LINK_OBJECT = 0,
  22. WIDGETSTYLE_COPY_OBJECT = (1 << 0),
  23. WIDGETSTYLE_OWN_OBJECT = (1 << 1),
  24. };
  25. DEFINE_ENUM_FLAG_OPERATORS(WidgetStyleAssignFlags);
  26. struct WidgetStyle
  27. {
  28. WidgetStyleFlags flags;
  29. HFONT textFont;
  30. HFONT titleFont;
  31. HFONT categoryFont;
  32. HBRUSH backBrush;
  33. HBRUSH categoryBrush;
  34. COLORREF titleColor;
  35. COLORREF textColor;
  36. COLORREF backColor;
  37. COLORREF borderColor;
  38. COLORREF imageBackColor;
  39. COLORREF imageFrontColor;
  40. COLORREF selectBackColor;
  41. COLORREF selectFrontColor;
  42. COLORREF inactiveSelectBackColor;
  43. COLORREF inactiveSelectFrontColor;
  44. COLORREF categoryTextColor;
  45. COLORREF categoryLineColor;
  46. COLORREF categoryBackColor;
  47. COLORREF categoryEmptyTextColor;
  48. COLORREF textEditorBorderColor;
  49. SIZE unitSize;
  50. };
  51. #define DLU_TO_PX_VALIDATE_MIN(_value, _dlu, _min)\
  52. {if (0 != (_dlu) && ((_value) < (_min))) (_value) = (_min);}
  53. #define WIDGETSTYLE_DLU_TO_HORZ_PX(_style, _dlu) MulDiv((_dlu), ((WidgetStyle*)(_style))->unitSize.cx, 4)
  54. #define WIDGETSTYLE_DLU_TO_VERT_PX(_style, _dlu) MulDiv((_dlu), ((WidgetStyle*)(_style))->unitSize.cy, 8)
  55. #define WIDGETSTYLE_DLU_TO_HORZ_PX_MIN(_value, _style, _dlu, _min)\
  56. {_value = WIDGETSTYLE_DLU_TO_HORZ_PX(_style, _dlu); DLU_TO_PX_VALIDATE_MIN(_value, _dlu, _min);}
  57. #define WIDGETSTYLE_DLU_TO_VERT_PX_MIN(_value, _style, _dlu, _min)\
  58. {_value = WIDGETSTYLE_DLU_TO_VERT_PX(_style, _dlu); DLU_TO_PX_VALIDATE_MIN(_value, _dlu, _min);}
  59. #define WIDGETSTYLE_TITLE_FONT(_style) (((WidgetStyle*)(_style))->titleFont)
  60. #define WIDGETSTYLE_TEXT_FONT(_style) (((WidgetStyle*)(_style))->textFont)
  61. #define WIDGETSTYLE_CATEGORY_FONT(_style) (((WidgetStyle*)(_style))->categoryFont)
  62. #define WIDGETSTYLE_BACK_BRUSH(_style) (((WidgetStyle*)(_style))->backBrush)
  63. #define WIDGETSTYLE_CATEGORY_BRUSH(_style) (((WidgetStyle*)(_style))->categoryBrush)
  64. #define WIDGETSTYLE_TITLE_COLOR(_style) (((WidgetStyle*)(_style))->titleColor)
  65. #define WIDGETSTYLE_TEXT_COLOR(_style) (((WidgetStyle*)(_style))->textColor)
  66. #define WIDGETSTYLE_BACK_COLOR(_style) (((WidgetStyle*)(_style))->backColor)
  67. #define WIDGETSTYLE_BORDER_COLOR(_style) (((WidgetStyle*)(_style))->borderColor)
  68. #define WIDGETSTYLE_IMAGE_BACK_COLOR(_style) (((WidgetStyle*)(_style))->imageBackColor)
  69. #define WIDGETSTYLE_IMAGE_FRONT_COLOR(_style) (((WidgetStyle*)(_style))->imageFrontColor)
  70. #define WIDGETSTYLE_SELECT_BACK_COLOR(_style) (((WidgetStyle*)(_style))->selectBackColor)
  71. #define WIDGETSTYLE_SELECT_FRONT_COLOR(_style) (((WidgetStyle*)(_style))->selectFrontColor)
  72. #define WIDGETSTYLE_INACTIVE_SELECT_BACK_COLOR(_style) (((WidgetStyle*)(_style))->inactiveSelectBackColor)
  73. #define WIDGETSTYLE_INACTIVE_SELECT_FRONT_COLOR(_style) (((WidgetStyle*)(_style))->inactiveSelectFrontColor)
  74. #define WIDGETSTYLE_CATEGORY_TEXT_COLOR(_style) (((WidgetStyle*)(_style))->categoryTextColor)
  75. #define WIDGETSTYLE_CATEGORY_BACK_COLOR(_style) (((WidgetStyle*)(_style))->categoryBackColor)
  76. #define WIDGETSTYLE_CATEGORY_LINE_COLOR(_style) (((WidgetStyle*)(_style))->categoryLineColor)
  77. #define WIDGETSTYLE_CATEGORY_EMPTY_TEXT_COLOR(_style) (((WidgetStyle*)(_style))->categoryEmptyTextColor)
  78. #define WIDGETSTYLE_TEXT_EDITOR_BORDER_COLOR(_style) (((WidgetStyle*)(_style))->textEditorBorderColor)
  79. #define WIDGETSTYLE_SET_UNIT_SIZE(_style, _width, _height)\
  80. {(((WidgetStyle*)(_style))->unitSize).cx = _width;\
  81. (((WidgetStyle*)(_style))->unitSize).cy = _height;}
  82. #define WIDGETSTYLE_SET_TITLE_FONT(_style, _font, _flags)\
  83. WidgetStyle_SetTitleFont(((WidgetStyle*)(_style)), (_font), (_flags))
  84. #define WIDGETSTYLE_SET_TEXT_FONT(_style, _font, _flags)\
  85. WidgetStyle_SetTextFont(((WidgetStyle*)(_style)), (_font), (_flags))
  86. #define WIDGETSTYLE_SET_CATEGORY_FONT(_style, _font, _flags)\
  87. WidgetStyle_SetCategoryFont(((WidgetStyle*)(_style)), (_font), (_flags))
  88. #define WIDGETSTYLE_SET_BACK_BRUSH(_style, _brush, _flags)\
  89. WidgetStyle_SetBackBrush(((WidgetStyle*)(_style)), (_brush), (_flags))
  90. #define WIDGETSTYLE_SET_CATEGORY_BRUSH(_style, _brush, _flags)\
  91. WidgetStyle_SetCategoryBrush(((WidgetStyle*)(_style)), (_brush), (_flags))
  92. #define WIDGETSTYLE_SET_TITLE_COLOR(_style, _color) (((WidgetStyle*)(_style))->titleColor = (_color))
  93. #define WIDGETSTYLE_SET_TEXT_COLOR(_style, _color) (((WidgetStyle*)(_style))->textColor = (_color))
  94. #define WIDGETSTYLE_SET_BACK_COLOR(_style, _color) (((WidgetStyle*)(_style))->backColor = (_color))
  95. #define WIDGETSTYLE_SET_BORDER_COLOR(_style, _color) (((WidgetStyle*)(_style))->borderColor = (_color))
  96. #define WIDGETSTYLE_SET_IMAGE_BACK_COLOR(_style, _color) (((WidgetStyle*)(_style))->imageBackColor = (_color))
  97. #define WIDGETSTYLE_SET_IMAGE_FRONT_COLOR(_style, _color) (((WidgetStyle*)(_style))->imageFrontColor = (_color))
  98. #define WIDGETSTYLE_SET_SELECT_BACK_COLOR(_style, _color) (((WidgetStyle*)(_style))->selectBackColor = (_color))
  99. #define WIDGETSTYLE_SET_SELECT_FRONT_COLOR(_style, _color) (((WidgetStyle*)(_style))->selectFrontColor = (_color))
  100. #define WIDGETSTYLE_SET_INACTIVE_SELECT_BACK_COLOR(_style, _color) (((WidgetStyle*)(_style))->inactiveSelectBackColor = (_color))
  101. #define WIDGETSTYLE_SET_INACTIVE_SELECT_FRONT_COLOR(_style, _color) (((WidgetStyle*)(_style))->inactiveSelectFrontColor = (_color))
  102. #define WIDGETSTYLE_SET_CATEGORY_TEXT_COLOR(_style, _color) (((WidgetStyle*)(_style))->categoryTextColor = (_color))
  103. #define WIDGETSTYLE_SET_CATEGORY_BACK_COLOR(_style, _color) (((WidgetStyle*)(_style))->categoryBackColor = (_color))
  104. #define WIDGETSTYLE_SET_CATEGORY_LINE_COLOR(_style, _color) (((WidgetStyle*)(_style))->categoryLineColor = (_color))
  105. #define WIDGETSTYLE_SET_CATEGORY_EMPTY_TEXT_COLOR(_style, _color) (((WidgetStyle*)(_style))->categoryEmptyTextColor = (_color))
  106. #define WIDGETSTYLE_SET_TEXT_EDITOR_BORDER_COLOR(_style, _color) (((WidgetStyle*)(_style))->textEditorBorderColor = (_color))
  107. void
  108. WidgetStyle_Free(WidgetStyle *self);
  109. BOOL
  110. WidgetStyle_SetBackBrush(WidgetStyle *self,
  111. HBRUSH brush,
  112. WidgetStyleAssignFlags flags);
  113. BOOL
  114. WidgetStyle_SetCategoryBrush(WidgetStyle *self,
  115. HBRUSH brush,
  116. WidgetStyleAssignFlags flags);
  117. BOOL
  118. WidgetStyle_SetTextFont(WidgetStyle *self,
  119. HFONT font,
  120. WidgetStyleAssignFlags flags);
  121. BOOL
  122. WidgetStyle_SetTitleFont(WidgetStyle *self,
  123. HFONT font,
  124. WidgetStyleAssignFlags flags);
  125. BOOL
  126. WidgetStyle_SetCategoryFont(WidgetStyle *self,
  127. HFONT font,
  128. WidgetStyleAssignFlags flags);
  129. BOOL
  130. WidgetStyle_UpdateDefaultColors(WidgetStyle *style);
  131. BOOL
  132. WidgetStyle_UpdateDefaultFonts(WidgetStyle *style,
  133. HFONT baseFont,
  134. long unitWidth,
  135. long unitHeight);
  136. #endif //_NULLSOFT_WINAMP_ML_DEVICES_WIDGETSTYLE_HEADER