summaryrefslogtreecommitdiff
path: root/plugins/NewStory/src/fonts.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-11-25 15:46:39 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-11-25 15:46:39 +0300
commitf0c30e09912360c393c53431a61df2eb42d61f53 (patch)
tree8f4a5bb57e417edcc92b253d46f56a4ad1f17f77 /plugins/NewStory/src/fonts.cpp
parentf5e4db1c78db17956920f88cea5e6914ec668e24 (diff)
NewStory:
- fix for fonts & colors' registration - fix for 64-bit WINAPI;
Diffstat (limited to 'plugins/NewStory/src/fonts.cpp')
-rw-r--r--plugins/NewStory/src/fonts.cpp158
1 files changed, 67 insertions, 91 deletions
diff --git a/plugins/NewStory/src/fonts.cpp b/plugins/NewStory/src/fonts.cpp
index 0db756187b..515665fa57 100644
--- a/plugins/NewStory/src/fonts.cpp
+++ b/plugins/NewStory/src/fonts.cpp
@@ -1,119 +1,95 @@
#include "stdafx.h"
-MyColourID colors[] =
+MyColourID colors[] =
{
- {0, {MODULETITLE, "Incoming Messages", MODULENAME, "ColorMsgIn", 0, RGB(0xff, 0xff, 0xff), 0}},
- {0, {MODULETITLE, "Outgoing Messages", MODULENAME, "ColorMsgOut", 0, RGB(0xff, 0xff, 0xff), 1}},
-
- {0, {MODULETITLE, "Incoming Files", MODULENAME, "ColorFileIn", 0, RGB(0xff, 0xff, 0xff), 2}},
- {0, {MODULETITLE, "Outgoing Files", MODULENAME, "ColorFileOut", 0, RGB(0xff, 0xff, 0xff), 3}},
-
- {0, {MODULETITLE, "Incoming URLs", MODULENAME, "ColorURLIn", 0, RGB(0xff, 0xff, 0xff), 4}},
- {0, {MODULETITLE, "Outgoing URLs", MODULENAME, "ColorURLOut", 0, RGB(0xff, 0xff, 0xff), 5}},
-
- {0, {MODULETITLE, "Status changes", MODULENAME, "ColorStatus", 0, RGB(0xff, 0xff, 0xff), 6}},
-
- {0, {MODULETITLE, "Other Outgoing Events", MODULENAME, "ColorOut", 0, RGB(0xff, 0xff, 0xff), 7}},
- {0, {MODULETITLE, "Other Incoming Events", MODULENAME, "ColorIn", 0, RGB(0xff, 0xff, 0xff), 8}},
-
- {0, {MODULETITLE, "Selected Items", MODULENAME, "ColorSel", 0, RGB(0x60, 0x60, 0x60), 9}},
- {0, {MODULETITLE, "Selected Items (Text)", MODULENAME, "ColorSelTxt", 0, RGB(0xff, 0xff, 0xff), 10}}
+ { "Incoming Messages", "ColorMsgIn", RGB(0xff, 0xff, 0xff) },
+ { "Outgoing Messages", "ColorMsgOut", RGB(0xff, 0xff, 0xff) },
+
+ { "Incoming Files", "ColorFileIn", RGB(0xff, 0xff, 0xff) },
+ { "Outgoing Files", "ColorFileOut", RGB(0xff, 0xff, 0xff) },
+
+ { "Incoming URLs", "ColorURLIn", RGB(0xff, 0xff, 0xff) },
+ { "Outgoing URLs", "ColorURLOut", RGB(0xff, 0xff, 0xff) },
+
+ { "Status changes", "ColorStatus", RGB(0xff, 0xff, 0xff) },
+
+ { "Other Outgoing Events", "ColorOut", RGB(0xff, 0xff, 0xff) },
+ { "Other Incoming Events", "ColorIn", RGB(0xff, 0xff, 0xff) },
+
+ { "Selected Items", "ColorSel", RGB(0x60, 0x60, 0x60) },
+ { "Selected Items (Text)", "ColorSelTxt", RGB(0xff, 0xff, 0xff) }
};
-MyFontID fonts[] =
+MyFontID fonts[] =
{
- {0, 0, 0, {MODULETITLE, "Incoming Messages", MODULENAME, "FontMsgIn", 0, {0}, 0}},
- {0, 0, 0, {MODULETITLE, "Outgoing Messages", MODULENAME, "FontMsgOut", 0, {0}, 1}},
-
- {0, 0, 0, {MODULETITLE, "Incoming Files", MODULENAME, "FontFileIn", 0, {0}, 2}},
- {0, 0, 0, {MODULETITLE, "Outgoing Files", MODULENAME, "FontFileOut", 0, {0}, 3}},
+ { "Incoming Messages", "FontMsgIn" },
+ { "Outgoing Messages", "FontMsgOut" },
- {0, 0, 0, {MODULETITLE, "Incoming URLs", MODULENAME, "FontURLIn", 0, {0}, 4}},
- {0, 0, 0, {MODULETITLE, "Outgoing URLs", MODULENAME, "FontURLOut", 0, {0}, 5}},
+ { "Incoming Files", "FontFileIn" },
+ { "Outgoing Files", "FontFileOut" },
- {0, 0, 0, {MODULETITLE, "Status changes", MODULENAME, "FontStatus", 0, {0}, 6}},
+ { "Incoming URLs", "FontURLIn" },
+ { "Outgoing URLs", "FontURLOut" },
- {0, 0, 0, {MODULETITLE, "Other Outgoing Events", MODULENAME, "FontOut", 0, {0}, 7}},
- {0, 0, 0, {MODULETITLE, "Other Incoming Events", MODULENAME, "FontIn", 0, {0}, 8}}
+ { "Status changes", "FontStatus" },
-// {sizeof(FontID), MODULETITLE, "Default Text", MODULENAME, "FontDef", FIDF_SAVEPOINTSIZE, {0}, 0},
-// {sizeof(FontID), MODULETITLE, "Selected Item", MODULENAME, "FontSel", FIDF_SAVEPOINTSIZE, {0}, 1}
+ { "Other Outgoing Events", "FontOut" },
+ { "Other Incoming Events", "FontIn" }
};
int evtFontsChanged(WPARAM, LPARAM)
{
- int i;
- for (i = 0; i < COLOR_COUNT; i++)
- colors[i].cl = Colour_Get(colors[i].info.group, colors[i].info.name);
-
- for (i = 0; i < FONT_COUNT; i++) {
- fonts[i].cl = (COLORREF)Font_Get(fonts[i].info, fonts[i].lf);
- DeleteObject(fonts[i].hfnt);
- fonts[i].hfnt = CreateFontIndirectA(fonts[i].lf);
+ for (auto &it : colors)
+ it.cl = Colour_Get(MODULENAME, it.szName);
+
+ for (auto &it : fonts) {
+ it.cl = (COLORREF)Font_Get(MODULENAME, it.szName, &it.lf);
+
+ DeleteObject(it.hfnt);
+ it.hfnt = CreateFontIndirectA(&it.lf);
}
-// WindowList_Broadcast(hNewstoryWindows, UM_REDRAWLISTH, 0, 0);
+
+ // WindowList_Broadcast(hNewstoryWindows, UM_REDRAWLISTH, 0, 0);
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
void InitFonts()
{
- bool isFSInstalled = /*ServiceExists(MS_FONT_GET) ? */true/* : false*/;
-
- int i; // damn msvc can't handle for(int i...) correctly! =(
-
HookEvent(ME_FONT_RELOAD, evtFontsChanged);
HookEvent(ME_COLOUR_RELOAD, evtFontsChanged);
- if (isFSInstalled)
- {
- for (i = 0; i < COLOR_COUNT; i++)
- {
- g_plugin.addColor(&colors[i].info);
- colors[i].cl = Colour_Get(colors[i].info.group, colors[i].info.name);
- }
- for (i = 0; i < FONT_COUNT; i++)
- {
- //CallService(MS_FONT_REGISTER, (WPARAM)&fonts[i].info, 0);
- g_plugin.addFont(&fonts[i].info);
- fonts[i].lf = (LOGFONTA *)malloc(sizeof(LOGFONTA));
- fonts[i].cl = (COLORREF)Font_Get(fonts[i].info, fonts[i].lf);
- fonts[i].hfnt = CreateFontIndirectA(fonts[i].lf);
- //MessageBox(0, fonts[i].lf->lfFaceName, _T(""), MB_OK);
- }
- } else
- {
- LOGFONTA lfText = {0};
- lfText.lfHeight = -11;
- lfText.lfWidth = lfText.lfEscapement = lfText.lfOrientation = 0;
- lfText.lfItalic = lfText.lfUnderline = lfText.lfStrikeOut = FALSE;
- lfText.lfCharSet = DEFAULT_CHARSET;
- lfText.lfOutPrecision = OUT_DEFAULT_PRECIS;
- lfText.lfClipPrecision = CLIP_DEFAULT_PRECIS;
- lfText.lfQuality = DEFAULT_QUALITY;
- lfText.lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
- lstrcpyA(lfText.lfFaceName, "MS Shell Dlg");
- lfText.lfWeight = FW_REGULAR;
-
- for (i = 0; i < COLOR_COUNT; i++)
- {
- colors[i].cl = colors[i].info.defcolour;
- }
- for (i = 0; i < FONT_COUNT; i++)
- {
- fonts[i].lf = (LOGFONTA *)malloc(sizeof(LOGFONTA));
- *fonts[i].lf = lfText;
- fonts[i].cl = RGB(0,0,0);
- fonts[i].hfnt = CreateFontIndirectA(fonts[i].lf);
- }
+ ColourID cid = {};
+ strncpy_s(cid.group, MODULENAME, _TRUNCATE);
+ strncpy_s(cid.dbSettingsGroup, MODULENAME, _TRUNCATE);
+
+ for (auto &it : colors) {
+ cid.order = int(&it - colors);
+ 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);
+ }
+
+ FontID fontid = {};
+ strncpy_s(fontid.group, MODULENAME, _TRUNCATE);
+ strncpy_s(fontid.dbSettingsGroup, MODULENAME, _TRUNCATE);
+
+ for (auto &it : fonts) {
+ fontid.order = int(&it - fonts);
+ strncpy_s(fontid.name, it.szName, _TRUNCATE);
+ strncpy_s(fontid.setting, it.szSetting, _TRUNCATE);
+ g_plugin.addFont(&fontid);
+
+ it.cl = Font_Get(MODULENAME, it.szName, &it.lf);
+ it.hfnt = CreateFontIndirectA(&it.lf);
}
}
void DestroyFonts()
{
- int i;
- for (i = 0; i < FONT_COUNT; i++)
- {
- DeleteObject(fonts[i].hfnt);
- free(fonts[i].lf);
- }
-} \ No newline at end of file
+ for (auto &it : fonts)
+ DeleteObject(it.hfnt);
+}