- Notifications
You must be signed in to change notification settings - Fork 337
/
Copy pathdrawing_win.cpp
174 lines (153 loc) · 5.79 KB
/
drawing_win.cpp
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0,
* as published by the Free Software Foundation.
*
* This program is designed to work with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms, as
* designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an additional
* permission to link the program and your derivative works with the
* separately licensed software that they have either included with
* the program or referenced in the documentation.
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include"base/drawing.h"
#include"base/string_utilities.h"
usingnamespacebase;
//----------------------------------------------------------------------------------------------------------------------
staticbool inTesting = false;
Color Color::getSystemColor(SystemColor colorType) {
DWORD sysColor = 0;
switch (colorType) {
case ControlShadowColor:
sysColor = GetSysColor(COLOR_3DSHADOW);
break;
case ControlDarkShadowColor:
sysColor = GetSysColor(COLOR_3DDKSHADOW);
break;
case ControlColor:
sysColor = GetSysColor(COLOR_BTNFACE);
break;
case ControlHighlightColor:
sysColor = GetSysColor(COLOR_BTNHIGHLIGHT);
break;
case ControlLightHighlightColor:
sysColor = GetSysColor(COLOR_BTNHIGHLIGHT);
break;
case ControlTextColor:
sysColor = GetSysColor(COLOR_BTNTEXT);
break;
case ControlBackgroundColor:
sysColor = GetSysColor(COLOR_WINDOW);
break;
case SelectedControlColor:
sysColor = GetSysColor(COLOR_BTNFACE);
break;
case SecondarySelectedControlColor:
sysColor = GetSysColor(COLOR_BTNFACE);
break;
case SelectedControlTextColor:
sysColor = GetSysColor(COLOR_BTNTEXT);
break;
case DisabledControlTextColor:
sysColor = GetSysColor(COLOR_GRAYTEXT);
break;
case TextColor:
sysColor = GetSysColor(COLOR_WINDOWTEXT);
break;
case TextBackgroundColor:
sysColor = GetSysColor(COLOR_WINDOW);
break;
case LabelColor:
case SecondaryLabelColor:
case TertiaryLabelColor:
case QuaternaryLabelColor:
sysColor = GetSysColor(COLOR_WINDOWTEXT);
break;
case SelectedTextColor:
sysColor = GetSysColor(COLOR_HIGHLIGHTTEXT);
break;
case SelectedTextBackgroundColor:
sysColor = GetSysColor(COLOR_HIGHLIGHT);
break;
case GridColor:
sysColor = GetSysColor(0x909090);
break;
case WindowBackgroundColor:
sysColor = GetSysColor(COLOR_WINDOW);
break;
case WindowFrameColor:
sysColor = GetSysColor(COLOR_WINDOWFRAME);
break;
case WindowFrameTextColor:
sysColor = GetSysColor(COLOR_CAPTIONTEXT);
break;
case SecondaryBackgroundColor:
sysColor = GetSysColor(COLOR_WINDOW);
break;
case SelectedMenuItemColor:
sysColor = GetSysColor(COLOR_MENUHILIGHT);
break;
case SelectedMenuItemTextColor:
sysColor = GetSysColor(COLOR_MENUTEXT);
break;
case HighlightColor:
sysColor = GetSysColor(COLOR_HIGHLIGHT);
break;
case HeaderColor:
sysColor = GetSysColor(COLOR_BTNFACE);
break;
case HeaderTextColor:
sysColor = GetSysColor(COLOR_BTNTEXT);
break;
case AlternateSelectedControlColor:
sysColor = GetSysColor(COLOR_BTNFACE);
break;
case AlternateSelectedControlTextColor:
sysColor = GetSysColor(COLOR_BTNTEXT);
break;
}
returnColor(GetRValue(sysColor) / 255.0, GetGValue(sysColor) / 255.0, GetBValue(sysColor) / 255.0);
}
//----------------------------------------------------------------------------------------------------------------------
std::string OSConstants::defaultFontName() {
NONCLIENTMETRICS metrics;
metrics.cbSize = sizeof(metrics);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(metrics), &metrics, 0);
returnbase::wstring_to_string(metrics.lfCaptionFont.lfFaceName);
}
//----------------------------------------------------------------------------------------------------------------------
floatOSConstants::systemFontSize() {
NONCLIENTMETRICS metrics;
metrics.cbSize = sizeof(metrics);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(metrics), &metrics, 0);
return (float)-metrics.lfCaptionFont.lfHeight;
}
//----------------------------------------------------------------------------------------------------------------------
floatOSConstants::smallSystemFontSize() {
NONCLIENTMETRICS metrics;
metrics.cbSize = sizeof(metrics);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(metrics), &metrics, 0);
return (float)-metrics.lfCaptionFont.lfHeight - 2;
}
//----------------------------------------------------------------------------------------------------------------------
floatOSConstants::labelFontSize() {
NONCLIENTMETRICS metrics;
metrics.cbSize = sizeof(metrics);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(metrics), &metrics, 0);
return (float)-metrics.lfCaptionFont.lfHeight;
}
//----------------------------------------------------------------------------------------------------------------------
voidColor::prepareForTesting() {
inTesting = true;
}