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
|
/*
Copyright (c) 2005 Victor Pavlychko (nullbyte@sotline.net.ua)
Copyright (C) 2012-24 Miranda NG team (https://miranda-ng.org)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation version 2
of the License.
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 for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stdafx.h"
MyColourID g_colorTable[COLOR_COUNT] =
{
{ LPGEN("Incoming name"), "ColorNickIn", RGB(0x00, 0x00, 0x00) },
{ LPGEN("Outgoing name"), "ColorNickOut", RGB(0x00, 0x00, 0x00) },
{ LPGEN("Incoming messages"), "ColorMsgIn", RGB(0xd6, 0xf5, 0xc0) },
{ LPGEN("Outgoing messages"), "ColorMsgOut", RGB(0xf5, 0xe7, 0xd8) },
{ LPGEN("Incoming files"), "ColorFileIn", RGB(0xe3, 0xee, 0x9b) },
{ LPGEN("Outgoing files"), "ColorFileOut", RGB(0xe3, 0xee, 0x9b) },
{ LPGEN("Status changes"), "ColorStatus", RGB(0xf0, 0xf0, 0xf0) },
{ LPGEN("Other incoming events"), "ColorIn", RGB(0xff, 0xff, 0xff) },
{ LPGEN("Other outgoing events"), "ColorOut", RGB(0xff, 0xff, 0xff) },
{ LPGEN("Selected item's text"), "ColorSelTxt", RGB(0xff, 0xff, 0xff) },
{ LPGEN("Selected item's background"), "ColorSel", RGB(0xcd, 0xcd, 0xfc) },
{ LPGEN("Selected item's frame"), "ColorSelFrm", GetSysColor(COLOR_HIGHLIGHTTEXT) },
{ LPGEN("Highlighted messages"), "ColorHighlight", RGB(0xf0, 0xf0, 0xf0) },
{ LPGEN("Grid background"), "Background", RGB(0xff, 0xff, 0xff) },
{ LPGEN("Quoting"), "Quote", RGB(0x80, 0x80, 0xff) },
{ LPGEN("Separator"), "Separator", RGB(0x60, 0x60, 0x60) },
{ LPGEN("Progress indicator"), "Progress", RGB(0xff, 0x00, 0x00) },
{ LPGEN("Links"), "Links", RGB(0x24, 0x7E, 0xCA) },
};
MyFontID g_fontTable[FONT_COUNT] =
{
{ LPGEN("Incoming messages"), "FontMsgIn" },
{ LPGEN("Outgoing messages"), "FontMsgOut" },
{ LPGEN("Incoming files"), "FontFileIn" },
{ LPGEN("Outgoing files"), "FontFileOut" },
{ LPGEN("Status changes"), "FontStatus" },
{ LPGEN("Highlighted messages"), "FontHighlight", DBFONTF_BOLD, RGB(0x7f, 0, 0) },
{ LPGEN("Other incoming events"), "FontIn" },
{ LPGEN("Other outgoing events"), "FontOut" },
};
int evtFontsChanged(WPARAM, LPARAM)
{
for (auto &it : g_colorTable)
it.cl = Colour_Get(MODULENAME, it.szName);
DeleteObject(g_plugin.hBackBrush);
g_plugin.hBackBrush = CreateSolidBrush(g_colorTable[COLOR_SELBACK].cl);
for (auto &it : g_fontTable) {
it.cl = (COLORREF)Font_Get(MODULENAME, it.szName, &it.lf);
DeleteObject(it.hfnt);
it.hfnt = CreateFontIndirectA(&it.lf);
}
WindowList_Broadcast(g_hNewstoryLogs, UM_REDRAW_LIST, 0, 0);
return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
void InitFonts()
{
HookEvent(ME_FONT_RELOAD, evtFontsChanged);
HookEvent(ME_COLOUR_RELOAD, evtFontsChanged);
ColourID cid = {};
strncpy_s(cid.group, MODULENAME, _TRUNCATE);
strncpy_s(cid.dbSettingsGroup, MODULENAME, _TRUNCATE);
for (auto &it : g_colorTable) {
cid.order = int(&it - g_colorTable);
strncpy_s(cid.name, it.szName, _TRUNCATE);
strncpy_s(cid.setting, it.szSetting, _TRUNCATE);
cid.defcolour = it.defaultValue;
g_plugin.addColor(&cid);
it.cl = Colour_Get(cid.group, cid.name);
}
g_plugin.hBackBrush = CreateSolidBrush(g_colorTable[COLOR_SELBACK].cl);
LOGFONT lfDefault;
SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(lfDefault), &lfDefault, FALSE);
FontID fontid = {};
fontid.flags = FIDF_DEFAULTVALID;
strncpy_s(fontid.group, MODULENAME, _TRUNCATE);
strncpy_s(fontid.dbSettingsGroup, MODULENAME, _TRUNCATE);
strncpy_s(fontid.deffontsettings.szFace, _T2A(lfDefault.lfFaceName), _TRUNCATE);
fontid.deffontsettings.size = -12;
for (auto &it : g_fontTable) {
fontid.order = int(&it - g_fontTable);
strncpy_s(fontid.name, it.szName, _TRUNCATE);
strncpy_s(fontid.setting, it.szSetting, _TRUNCATE);
fontid.deffontsettings.style = it.style;
fontid.deffontsettings.colour = it.defaultValue;
g_plugin.addFont(&fontid);
it.cl = Font_Get(MODULENAME, it.szName, &it.lf);
it.hfnt = CreateFontIndirectA(&it.lf);
}
}
void DestroyFonts()
{
DeleteObject(g_plugin.hBackBrush);
for (auto &it : g_fontTable)
DeleteObject(it.hfnt);
}
|