aboutsummaryrefslogtreecommitdiff
path: root/Src/Plugins/Library/ml_devices/widgetStyle.h
blob: bb2a010a8f144f059aa5e4f3be843400d1a85345 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#ifndef _NULLSOFT_WINAMP_ML_DEVICES_WIDGETSTYLE_HEADER
#define _NULLSOFT_WINAMP_ML_DEVICES_WIDGETSTYLE_HEADER

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif

#include <wtypes.h>

typedef struct WidgetStyle WidgetStyle;
typedef enum WidgetStyleFlags WidgetStyleFlags;
typedef enum WidgetStyleAssignFlags WidgetStyleAssignFlags;

enum WidgetStyleFlags
{
	WIDGETSTYLE_OWN_TEXT_FONT = (1 << 0),
	WIDGETSTYLE_OWN_TITLE_FONT = (1 << 1),
	WIDGETSTYLE_OWN_CATEGORY_FONT = (1 << 2),
	WIDGETSTYLE_OWN_BACK_BRUSH = (1 << 3),
	WIDGETSTYLE_OWN_CATEGORY_BRUSH = (1 << 4),
};
DEFINE_ENUM_FLAG_OPERATORS(WidgetStyleFlags);

enum WidgetStyleAssignFlags
{
	WIDGETSTYLE_LINK_OBJECT = 0,
	WIDGETSTYLE_COPY_OBJECT = (1 << 0),
	WIDGETSTYLE_OWN_OBJECT = (1 << 1),
};
DEFINE_ENUM_FLAG_OPERATORS(WidgetStyleAssignFlags);


struct WidgetStyle
{
	WidgetStyleFlags flags;
	HFONT textFont;
	HFONT titleFont;
	HFONT categoryFont;
	HBRUSH backBrush;
	HBRUSH categoryBrush;
	COLORREF titleColor;
	COLORREF textColor;
	COLORREF backColor;
	COLORREF borderColor;
	COLORREF imageBackColor;
	COLORREF imageFrontColor;
	COLORREF selectBackColor;
	COLORREF selectFrontColor;
	COLORREF inactiveSelectBackColor;
	COLORREF inactiveSelectFrontColor;
	COLORREF categoryTextColor;
	COLORREF categoryLineColor;
	COLORREF categoryBackColor;
	COLORREF categoryEmptyTextColor;
	COLORREF textEditorBorderColor;
	SIZE unitSize;
};

#define DLU_TO_PX_VALIDATE_MIN(_value, _dlu, _min)\
	{if (0 != (_dlu) && ((_value) < (_min))) (_value) = (_min);}

#define WIDGETSTYLE_DLU_TO_HORZ_PX(_style, _dlu) MulDiv((_dlu), ((WidgetStyle*)(_style))->unitSize.cx, 4)
#define WIDGETSTYLE_DLU_TO_VERT_PX(_style, _dlu) MulDiv((_dlu), ((WidgetStyle*)(_style))->unitSize.cy, 8)

#define WIDGETSTYLE_DLU_TO_HORZ_PX_MIN(_value, _style, _dlu, _min)\
	{_value = WIDGETSTYLE_DLU_TO_HORZ_PX(_style, _dlu); DLU_TO_PX_VALIDATE_MIN(_value, _dlu, _min);}

#define WIDGETSTYLE_DLU_TO_VERT_PX_MIN(_value, _style, _dlu, _min)\
	{_value = WIDGETSTYLE_DLU_TO_VERT_PX(_style, _dlu); DLU_TO_PX_VALIDATE_MIN(_value, _dlu, _min);}

#define WIDGETSTYLE_TITLE_FONT(_style) (((WidgetStyle*)(_style))->titleFont)
#define WIDGETSTYLE_TEXT_FONT(_style) (((WidgetStyle*)(_style))->textFont)
#define WIDGETSTYLE_CATEGORY_FONT(_style) (((WidgetStyle*)(_style))->categoryFont)
#define WIDGETSTYLE_BACK_BRUSH(_style) (((WidgetStyle*)(_style))->backBrush)
#define WIDGETSTYLE_CATEGORY_BRUSH(_style) (((WidgetStyle*)(_style))->categoryBrush)
#define WIDGETSTYLE_TITLE_COLOR(_style) (((WidgetStyle*)(_style))->titleColor)
#define WIDGETSTYLE_TEXT_COLOR(_style) (((WidgetStyle*)(_style))->textColor)
#define WIDGETSTYLE_BACK_COLOR(_style) (((WidgetStyle*)(_style))->backColor)
#define WIDGETSTYLE_BORDER_COLOR(_style) (((WidgetStyle*)(_style))->borderColor)
#define WIDGETSTYLE_IMAGE_BACK_COLOR(_style) (((WidgetStyle*)(_style))->imageBackColor)
#define WIDGETSTYLE_IMAGE_FRONT_COLOR(_style) (((WidgetStyle*)(_style))->imageFrontColor)
#define WIDGETSTYLE_SELECT_BACK_COLOR(_style) (((WidgetStyle*)(_style))->selectBackColor)
#define WIDGETSTYLE_SELECT_FRONT_COLOR(_style) (((WidgetStyle*)(_style))->selectFrontColor)
#define WIDGETSTYLE_INACTIVE_SELECT_BACK_COLOR(_style) (((WidgetStyle*)(_style))->inactiveSelectBackColor)
#define WIDGETSTYLE_INACTIVE_SELECT_FRONT_COLOR(_style) (((WidgetStyle*)(_style))->inactiveSelectFrontColor)
#define WIDGETSTYLE_CATEGORY_TEXT_COLOR(_style) (((WidgetStyle*)(_style))->categoryTextColor)
#define WIDGETSTYLE_CATEGORY_BACK_COLOR(_style) (((WidgetStyle*)(_style))->categoryBackColor)
#define WIDGETSTYLE_CATEGORY_LINE_COLOR(_style) (((WidgetStyle*)(_style))->categoryLineColor)
#define WIDGETSTYLE_CATEGORY_EMPTY_TEXT_COLOR(_style) (((WidgetStyle*)(_style))->categoryEmptyTextColor)
#define WIDGETSTYLE_TEXT_EDITOR_BORDER_COLOR(_style) (((WidgetStyle*)(_style))->textEditorBorderColor)
#define WIDGETSTYLE_SET_UNIT_SIZE(_style, _width, _height)\
	{(((WidgetStyle*)(_style))->unitSize).cx = _width;\
	 (((WidgetStyle*)(_style))->unitSize).cy = _height;}

#define WIDGETSTYLE_SET_TITLE_FONT(_style, _font, _flags)\
	WidgetStyle_SetTitleFont(((WidgetStyle*)(_style)), (_font), (_flags))
#define WIDGETSTYLE_SET_TEXT_FONT(_style, _font, _flags)\
	WidgetStyle_SetTextFont(((WidgetStyle*)(_style)), (_font), (_flags))
#define WIDGETSTYLE_SET_CATEGORY_FONT(_style, _font, _flags)\
	WidgetStyle_SetCategoryFont(((WidgetStyle*)(_style)), (_font), (_flags))
#define WIDGETSTYLE_SET_BACK_BRUSH(_style, _brush, _flags)\
	WidgetStyle_SetBackBrush(((WidgetStyle*)(_style)), (_brush), (_flags))
#define WIDGETSTYLE_SET_CATEGORY_BRUSH(_style, _brush, _flags)\
	WidgetStyle_SetCategoryBrush(((WidgetStyle*)(_style)), (_brush), (_flags))

#define WIDGETSTYLE_SET_TITLE_COLOR(_style, _color) (((WidgetStyle*)(_style))->titleColor = (_color))
#define WIDGETSTYLE_SET_TEXT_COLOR(_style, _color) (((WidgetStyle*)(_style))->textColor = (_color))
#define WIDGETSTYLE_SET_BACK_COLOR(_style, _color) (((WidgetStyle*)(_style))->backColor = (_color))
#define WIDGETSTYLE_SET_BORDER_COLOR(_style, _color) (((WidgetStyle*)(_style))->borderColor = (_color))
#define WIDGETSTYLE_SET_IMAGE_BACK_COLOR(_style, _color) (((WidgetStyle*)(_style))->imageBackColor = (_color))
#define WIDGETSTYLE_SET_IMAGE_FRONT_COLOR(_style, _color) (((WidgetStyle*)(_style))->imageFrontColor = (_color))
#define WIDGETSTYLE_SET_SELECT_BACK_COLOR(_style, _color) (((WidgetStyle*)(_style))->selectBackColor = (_color))
#define WIDGETSTYLE_SET_SELECT_FRONT_COLOR(_style, _color) (((WidgetStyle*)(_style))->selectFrontColor = (_color))
#define WIDGETSTYLE_SET_INACTIVE_SELECT_BACK_COLOR(_style, _color) (((WidgetStyle*)(_style))->inactiveSelectBackColor = (_color))
#define WIDGETSTYLE_SET_INACTIVE_SELECT_FRONT_COLOR(_style, _color) (((WidgetStyle*)(_style))->inactiveSelectFrontColor = (_color))
#define WIDGETSTYLE_SET_CATEGORY_TEXT_COLOR(_style, _color) (((WidgetStyle*)(_style))->categoryTextColor = (_color))
#define WIDGETSTYLE_SET_CATEGORY_BACK_COLOR(_style, _color) (((WidgetStyle*)(_style))->categoryBackColor = (_color))
#define WIDGETSTYLE_SET_CATEGORY_LINE_COLOR(_style, _color) (((WidgetStyle*)(_style))->categoryLineColor = (_color))
#define WIDGETSTYLE_SET_CATEGORY_EMPTY_TEXT_COLOR(_style, _color) (((WidgetStyle*)(_style))->categoryEmptyTextColor = (_color))
#define WIDGETSTYLE_SET_TEXT_EDITOR_BORDER_COLOR(_style, _color) (((WidgetStyle*)(_style))->textEditorBorderColor = (_color))
void
WidgetStyle_Free(WidgetStyle *self);

BOOL
WidgetStyle_SetBackBrush(WidgetStyle *self, 
						 HBRUSH brush, 
						 WidgetStyleAssignFlags flags);

BOOL
WidgetStyle_SetCategoryBrush(WidgetStyle *self, 
						 HBRUSH brush, 
						 WidgetStyleAssignFlags flags);

BOOL
WidgetStyle_SetTextFont(WidgetStyle *self, 
						HFONT font, 
						WidgetStyleAssignFlags flags);

BOOL
WidgetStyle_SetTitleFont(WidgetStyle *self, 
						 HFONT font, 
						 WidgetStyleAssignFlags flags);

BOOL
WidgetStyle_SetCategoryFont(WidgetStyle *self, 
						 HFONT font, 
						 WidgetStyleAssignFlags flags);

BOOL
WidgetStyle_UpdateDefaultColors(WidgetStyle *style);

BOOL
WidgetStyle_UpdateDefaultFonts(WidgetStyle *style, 
							  HFONT baseFont, 
							  long unitWidth, 
							  long unitHeight);


#endif //_NULLSOFT_WINAMP_ML_DEVICES_WIDGETSTYLE_HEADER