summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-01-28 16:46:52 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-01-28 16:46:52 +0000
commitba0fed41b69b73c2207f21b62879430930fe47ba (patch)
tree9b09bc638d90f38d3aa7aa4208b4ca985e8edcaf
parent8d0a7a7cda2eb520a7389bbc0d18fb3da051d66d (diff)
fix for the default font settings for StdClist
git-svn-id: http://svn.miranda-ng.org/main/trunk@7931 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--src/core/stdclist/src/clcfonts.cpp102
-rw-r--r--src/core/stdclist/src/clcopts.cpp3
-rw-r--r--src/modules/clist/clcutils.cpp19
3 files changed, 50 insertions, 74 deletions
diff --git a/src/core/stdclist/src/clcfonts.cpp b/src/core/stdclist/src/clcfonts.cpp
index d068cc37b8..fe4c9c1e9a 100644
--- a/src/core/stdclist/src/clcfonts.cpp
+++ b/src/core/stdclist/src/clcfonts.cpp
@@ -26,38 +26,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "m_fontservice.h"
-#define CLIST_FONTID_CONTACTS 0
-#define CLIST_FONTID_INVIS 1
-#define CLIST_FONTID_OFFLINE 2
-#define CLIST_FONTID_NOTONLIST 3
-#define CLIST_FONTID_GROUPS 4
-#define CLIST_FONTID_GROUPCOUNTS 5
-#define CLIST_FONTID_DIVIDERS 6
-#define CLIST_FONTID_OFFINVIS 7
-#define CLIST_FONTID_MAX 7
-
-static const TCHAR* szClistFontIdDescr[CLIST_FONTID_MAX + 1] =
+struct
{
- LPGENT( "Standard contacts"),
- LPGENT( "Online contacts to whom you have a different visibility"),
- LPGENT( "Offline contacts"),
- LPGENT( "Contacts which are 'not on list'"),
- LPGENT( "Groups"),
- LPGENT( "Group member counts"),
- LPGENT( "Dividers"),
- LPGENT( "Offline contacts to whom you have a different visibility" )
-};
-
-static int fontListOrder[CLIST_FONTID_MAX + 1] =
+ const TCHAR *tszName;
+ int iMask;
+}
+static clistFontDescr[] =
{
- CLIST_FONTID_CONTACTS,
- CLIST_FONTID_INVIS,
- CLIST_FONTID_OFFLINE,
- CLIST_FONTID_OFFINVIS,
- CLIST_FONTID_NOTONLIST,
- CLIST_FONTID_GROUPS,
- CLIST_FONTID_GROUPCOUNTS,
- CLIST_FONTID_DIVIDERS
+ { LPGENT("Standard contacts"), FIDF_CLASSGENERAL },
+ { LPGENT("Online contacts to whom you have a different visibility"), FIDF_CLASSGENERAL },
+ { LPGENT("Offline contacts"), FIDF_CLASSGENERAL },
+ { LPGENT("Contacts which are 'not on list'"), FIDF_CLASSGENERAL },
+ { LPGENT("Groups"), FIDF_CLASSHEADER },
+ { LPGENT("Group member counts"), FIDF_CLASSHEADER },
+ { LPGENT("Dividers"), FIDF_CLASSSMALL },
+ { LPGENT("Offline contacts to whom you have a different visibility"), FIDF_CLASSGENERAL }
};
static int FS_FontsChanged(WPARAM wParam, LPARAM lParam)
@@ -68,44 +51,37 @@ static int FS_FontsChanged(WPARAM wParam, LPARAM lParam)
void RegisterCListFonts()
{
- FontIDT fontid = {0};
- ColourIDT colourid = {0};
- char idstr[10];
- int i;
-
- fontid.cbSize = sizeof(FontIDT);
- fontid.flags = FIDF_ALLOWREREGISTER | FIDF_APPENDNAME | FIDF_NOAS | FIDF_SAVEPOINTSIZE | FIDF_ALLOWEFFECTS;
-
- for (i = 0; i <= CLIST_FONTID_MAX; i++) {
-
- switch (fontListOrder[i])
- {
- case FONTID_GROUPS:
- case FONTID_GROUPCOUNTS:
- fontid.flags &= ~FIDF_CLASSMASK;
- fontid.flags |= FIDF_CLASSHEADER;
- break;
- case FONTID_DIVIDERS:
- fontid.flags &= ~FIDF_CLASSMASK;
- fontid.flags |= FIDF_CLASSSMALL;
- break;
- default:
- fontid.flags &= ~FIDF_CLASSMASK;
- fontid.flags |= FIDF_CLASSGENERAL;
- break;
- }
-
- strncpy(fontid.dbSettingsGroup, "CLC", sizeof(fontid.dbSettingsGroup));
- _tcsncpy(fontid.group, LPGENT("Contact list"), SIZEOF(fontid.group));
- _tcsncpy(fontid.name, szClistFontIdDescr[fontListOrder[i]], SIZEOF(fontid.name));
- mir_snprintf(idstr, SIZEOF(idstr), "Font%d", fontListOrder[i]);
- strncpy(fontid.prefix, idstr, SIZEOF(fontid.prefix));
- fontid.order = fontListOrder[i];
+ FontIDT fontid = { sizeof(fontid) };
+ fontid.flags = FIDF_DEFAULTVALID | FIDF_ALLOWREREGISTER | FIDF_APPENDNAME | FIDF_NOAS | FIDF_SAVEPOINTSIZE | FIDF_ALLOWEFFECTS;
+ strncpy(fontid.dbSettingsGroup, "CLC", sizeof(fontid.dbSettingsGroup));
+ _tcsncpy(fontid.group, LPGENT("Contact list"), SIZEOF(fontid.group));
+
+ HDC hdc = GetDC(NULL);
+ for (int i = 0; i < SIZEOF(clistFontDescr); i++) {
+ LOGFONT lf;
+ pcli->pfnGetFontSetting(i, &lf, &fontid.deffontsettings.colour);
+ lf.lfHeight = -MulDiv(lf.lfHeight, GetDeviceCaps(hdc, LOGPIXELSY), 72);
+ _tcsncpy_s(fontid.deffontsettings.szFace, SIZEOF(fontid.deffontsettings.szFace), lf.lfFaceName, _TRUNCATE);
+ fontid.deffontsettings.charset = lf.lfCharSet;
+ fontid.deffontsettings.size = (char)lf.lfHeight;
+ fontid.deffontsettings.style = (lf.lfWeight >= FW_BOLD ? DBFONTF_BOLD : 0) | (lf.lfItalic ? DBFONTF_ITALIC : 0);
+
+ fontid.flags &= ~FIDF_CLASSMASK;
+ fontid.flags |= clistFontDescr[i].iMask;
+
+ _tcsncpy(fontid.name, clistFontDescr[i].tszName, SIZEOF(fontid.name));
+
+ char idstr[10];
+ mir_snprintf(idstr, SIZEOF(idstr), "Font%d", i);
+ strncpy(fontid.prefix, idstr, SIZEOF(fontid.prefix));
+ fontid.order = i;
FontRegisterT(&fontid);
}
+ ReleaseDC(NULL, hdc);
// and colours
+ ColourIDT colourid = { 0 };
colourid.cbSize = sizeof(ColourIDT);
colourid.order = 0;
strncpy(colourid.dbSettingsGroup, "CLC", sizeof(colourid.dbSettingsGroup));
diff --git a/src/core/stdclist/src/clcopts.cpp b/src/core/stdclist/src/clcopts.cpp
index f346fd29f3..ce74813a6c 100644
--- a/src/core/stdclist/src/clcopts.cpp
+++ b/src/core/stdclist/src/clcopts.cpp
@@ -117,10 +117,9 @@ static DWORD MakeCheckBoxTreeFlags(HWND hwndTree)
static LONG CalcMinRowHeight()
{
- int i;
LONG minHeight = 16;
HDC hdc = GetDC(NULL);
- for (i = 0; i < FONTID_LAST; i++) {
+ for (int i = 0; i < FONTID_LAST; i++) {
HFONT hFont;
LOGFONT lf;
COLORREF color;
diff --git a/src/modules/clist/clcutils.cpp b/src/modules/clist/clcutils.cpp
index e4258c8a11..b87fc9cfa5 100644
--- a/src/modules/clist/clcutils.cpp
+++ b/src/modules/clist/clcutils.cpp
@@ -685,27 +685,28 @@ void fnGetDefaultFontSetting(int i, LOGFONT* lf, COLORREF* colour)
void fnGetFontSetting(int i, LOGFONT* lf, COLORREF* colour)
{
- DBVARIANT dbv;
- char idstr[20];
- BYTE style;
-
cli.pfnGetDefaultFontSetting(i, lf, colour);
+
+ char idstr[20];
mir_snprintf(idstr, SIZEOF(idstr), "Font%dName", i);
- if (!db_get_ts(NULL, "CLC", idstr, &dbv)) {
- lstrcpy(lf->lfFaceName, dbv.ptszVal);
- mir_free(dbv.pszVal);
- }
+ ptrT tszFace(db_get_tsa(NULL, "CLC", idstr));
+ if (tszFace)
+ lstrcpy(lf->lfFaceName, tszFace);
+
mir_snprintf(idstr, SIZEOF(idstr), "Font%dCol", i);
*colour = db_get_dw(NULL, "CLC", idstr, *colour);
+
mir_snprintf(idstr, SIZEOF(idstr), "Font%dSize", i);
lf->lfHeight = (char) db_get_b(NULL, "CLC", idstr, lf->lfHeight);
+
mir_snprintf(idstr, SIZEOF(idstr), "Font%dSty", i);
- style = (BYTE) db_get_b(NULL, "CLC", idstr, (lf->lfWeight == FW_NORMAL ? 0 : DBFONTF_BOLD) | (lf->lfItalic ? DBFONTF_ITALIC : 0) | (lf->lfUnderline ? DBFONTF_UNDERLINE : 0));
+ BYTE style = (BYTE)db_get_b(NULL, "CLC", idstr, (lf->lfWeight == FW_NORMAL ? 0 : DBFONTF_BOLD) | (lf->lfItalic ? DBFONTF_ITALIC : 0) | (lf->lfUnderline ? DBFONTF_UNDERLINE : 0));
lf->lfWidth = lf->lfEscapement = lf->lfOrientation = 0;
lf->lfWeight = style & DBFONTF_BOLD ? FW_BOLD : FW_NORMAL;
lf->lfItalic = (style & DBFONTF_ITALIC) != 0;
lf->lfUnderline = (style & DBFONTF_UNDERLINE) != 0;
lf->lfStrikeOut = 0;
+
mir_snprintf(idstr, SIZEOF(idstr), "Font%dSet", i);
lf->lfCharSet = db_get_b(NULL, "CLC", idstr, lf->lfCharSet);
lf->lfOutPrecision = OUT_DEFAULT_PRECIS;