summaryrefslogtreecommitdiff
path: root/utils/mir_fonts.cpp
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2015-10-22 13:05:29 +0000
committerRobert Pösel <robyer@seznam.cz>2015-10-22 13:05:29 +0000
commit5e2886ded2b2214b9e09ee0d08676ed31a32911e (patch)
tree3b89017f0cd3ac9e8b046592a4ef5bb22ae5af41 /utils/mir_fonts.cpp
parent2cbd98009118a9ea15b446820495b54c44fd069d (diff)
Move utils files from "plugins/utils" to "/utils" so it can be used from protocols too
git-svn-id: http://svn.miranda-ng.org/main/trunk@15592 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'utils/mir_fonts.cpp')
-rw-r--r--utils/mir_fonts.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/utils/mir_fonts.cpp b/utils/mir_fonts.cpp
new file mode 100644
index 0000000000..0ef14e3c6d
--- /dev/null
+++ b/utils/mir_fonts.cpp
@@ -0,0 +1,67 @@
+#include <windows.h>
+
+#include <m_system.h>
+#include <m_fontservice.h>
+#include <win2k.h>
+
+#include "mir_fonts.h"
+
+int FontService_RegisterFont(const char *pszDbModule, const char *pszDbName, const TCHAR *pszSection, const TCHAR *pszDescription, const TCHAR *pszBackgroundGroup, const TCHAR *pszBackgroundName, int position, BOOL bAllowEffects, LOGFONT *plfDefault, COLORREF clrDefault)
+{
+ FontIDT fid = { 0 };
+ fid.cbSize = sizeof(fid);
+ mir_strncpy(fid.dbSettingsGroup, pszDbModule, sizeof(fid.dbSettingsGroup)); /* buffer safe */
+ mir_strncpy(fid.prefix, pszDbName, sizeof(fid.prefix)); /* buffer safe */
+ mir_tstrncpy(fid.group, pszSection, _countof(fid.group)); /* buffer safe */
+ mir_tstrncpy(fid.name, pszDescription, _countof(fid.name)); /* buffer safe */
+ mir_tstrncpy(fid.backgroundGroup, pszBackgroundGroup, _countof(fid.backgroundGroup)); /* buffer safe */
+ mir_tstrncpy(fid.backgroundName, pszBackgroundName, _countof(fid.backgroundName)); /* buffer safe */
+ fid.flags = FIDF_ALLOWREREGISTER;
+ if (bAllowEffects) fid.flags |= FIDF_ALLOWEFFECTS;
+ fid.order = position;
+ if (plfDefault != NULL) {
+ fid.flags |= FIDF_DEFAULTVALID;
+ fid.deffontsettings.colour = clrDefault;
+ fid.deffontsettings.size = (char)plfDefault->lfHeight;
+ if (plfDefault->lfItalic) fid.deffontsettings.style |= DBFONTF_ITALIC;
+ if (plfDefault->lfWeight != FW_NORMAL) fid.deffontsettings.style |= DBFONTF_BOLD;
+ if (plfDefault->lfUnderline) fid.deffontsettings.style |= DBFONTF_UNDERLINE;
+ if (plfDefault->lfStrikeOut) fid.deffontsettings.style |= DBFONTF_STRIKEOUT;
+ fid.deffontsettings.charset = plfDefault->lfCharSet;
+ mir_tstrncpy(fid.deffontsettings.szFace, plfDefault->lfFaceName, _countof(fid.deffontsettings.szFace)); /* buffer safe */
+ }
+ FontRegisterT(&fid);
+ return 0;
+}
+
+int FontService_GetFont(const TCHAR *pszSection, const TCHAR *pszDescription, COLORREF *pclr, LOGFONT *plf)
+{
+ FontIDT fid = { 0 };
+ mir_tstrncpy(fid.group, pszSection, _countof(fid.group)); /* buffer sfae */
+ mir_tstrncpy(fid.name, pszDescription, _countof(fid.name)); /* buffer safe */
+ *pclr = (COLORREF)CallService(MS_FONT_GETT, (WPARAM)&fid, (LPARAM)plf); /* uses fallback font on error */
+ return (int)*pclr == -1;
+}
+
+int FontService_RegisterColor(const char *pszDbModule, const char *pszDbName, const TCHAR *pszSection, const TCHAR *pszDescription, COLORREF clrDefault)
+{
+ ColourIDT cid = { 0 };
+ cid.cbSize = sizeof(cid);
+ cid.defcolour = clrDefault;
+ mir_strncpy(cid.dbSettingsGroup, pszDbModule, sizeof(cid.dbSettingsGroup)); /* buffer safe */
+ mir_strncpy(cid.setting, pszDbName, sizeof(cid.setting)); /* buffer safe */
+ mir_tstrncpy(cid.group, pszSection, _countof(cid.group)); /* buffer safe */
+ mir_tstrncpy(cid.name, pszDescription, _countof(cid.name)); /* buffer safe */
+ ColourRegisterT(&cid);
+ return 0;
+}
+
+int FontService_GetColor(const TCHAR *pszSection, const TCHAR *pszDescription, COLORREF *pclr)
+{
+ ColourIDT cid = { 0 };
+ cid.cbSize = sizeof(cid);
+ _tcsncpy_s(cid.group, pszSection, _TRUNCATE);
+ _tcsncpy_s(cid.name, pszDescription, _TRUNCATE);
+ *pclr = (COLORREF)CallService(MS_COLOUR_GETT, (WPARAM)&cid, 0);
+ return (int)*pclr == -1;
+}