From c0658da7ca3d7edaedc92672788765504f3043e5 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 19 Mar 2014 15:40:40 +0000 Subject: - stdchat to use the message area input font from stdmsg; - message area color is also cached now git-svn-id: http://svn.miranda-ng.org/main/trunk@8662 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/core/stdchat/src/chat.h | 5 ++++- src/core/stdchat/src/main.cpp | 15 +++++++------ src/core/stdchat/src/tools.cpp | 45 ++++++++++++++++++++++++++++++++++---- src/core/stdchat/src/window.cpp | 22 +++++-------------- src/core/stdmsg/src/msgoptions.cpp | 16 ++++++-------- 5 files changed, 65 insertions(+), 38 deletions(-) (limited to 'src/core') diff --git a/src/core/stdchat/src/chat.h b/src/core/stdchat/src/chat.h index acd01aabfd..5bee654fae 100644 --- a/src/core/stdchat/src/chat.h +++ b/src/core/stdchat/src/chat.h @@ -98,7 +98,9 @@ struct GlobalLogSettings : public GlobalLogSettingsBase { int iX, iY; bool bTabsEnable, TabsAtBottom, TabCloseOnDblClick, TabRestore; - HFONT MessageBoxFont; + + HFONT MessageAreaFont; + COLORREF MessageAreaColor; }; extern GlobalLogSettings g_Settings; @@ -179,6 +181,7 @@ void CheckColorsInModule(const char* pszModule); int GetRichTextLength(HWND hwnd); UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, TCHAR* pszUID, TCHAR* pszWordText); void DestroyGCMenu(HMENU *hMenu, int iIndex); +bool LoadMessageFont(LOGFONT *lf, COLORREF *colour); // message.c char* Message_GetFromStream(HWND hwndDlg, SESSION_INFO *si); diff --git a/src/core/stdchat/src/main.cpp b/src/core/stdchat/src/main.cpp index 2e538b47c4..63fd05a2f4 100644 --- a/src/core/stdchat/src/main.cpp +++ b/src/core/stdchat/src/main.cpp @@ -267,11 +267,12 @@ static BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce) static void OnLoadSettings() { + if (g_Settings.MessageAreaFont) + DeleteObject(g_Settings.MessageAreaFont); + LOGFONT lf; - if (g_Settings.MessageBoxFont) - DeleteObject(g_Settings.MessageBoxFont); - pci->LoadMsgDlgFont(17, &lf, NULL); - g_Settings.MessageBoxFont = CreateFontIndirect(&lf); + LoadMessageFont(&lf, &g_Settings.MessageAreaColor); + g_Settings.MessageAreaFont = CreateFontIndirect(&lf); g_Settings.iX = db_get_dw(NULL, CHAT_MODULE, "roomx", -1); g_Settings.iY = db_get_dw(NULL, CHAT_MODULE, "roomy", -1); @@ -337,7 +338,7 @@ extern "C" __declspec(dllexport) int Load(void) AddIcons(); RegisterFonts(); - CHAT_MANAGER_INITDATA data = { &g_Settings, sizeof(MODULEINFO), sizeof(SESSION_INFO), LPGENT("Chat module"), FONTMODE_USE }; + CHAT_MANAGER_INITDATA data = { &g_Settings, sizeof(MODULEINFO), sizeof(SESSION_INFO), LPGENT("Chat module"), FONTMODE_SKIP }; mir_getCI(&data); saveCI = *pci; @@ -388,8 +389,8 @@ extern "C" __declspec(dllexport) int Unload(void) db_set_dw(NULL, CHAT_MODULE, "roomwidth", g_Settings.iWidth); db_set_dw(NULL, CHAT_MODULE, "roomheight", g_Settings.iHeight); - if (g_Settings.MessageBoxFont) - DeleteObject(g_Settings.MessageBoxFont); + if (g_Settings.MessageAreaFont) + DeleteObject(g_Settings.MessageAreaFont); DestroyMenu(g_hMenu); return 0; } diff --git a/src/core/stdchat/src/tools.cpp b/src/core/stdchat/src/tools.cpp index ab82184a58..173aaee7a7 100644 --- a/src/core/stdchat/src/tools.cpp +++ b/src/core/stdchat/src/tools.cpp @@ -22,6 +22,46 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "chat.h" +bool LoadMessageFont(LOGFONT *lf, COLORREF *colour) +{ + char str[32]; + int i = 8; // MSGFONTID_MESSAGEAREA + + if (colour) { + mir_snprintf(str, SIZEOF(str), "SRMFont%dCol", i); + *colour = db_get_dw(NULL, "SRMM", str, 0); + } + if (lf) { + mir_snprintf(str, SIZEOF(str), "SRMFont%dSize", i); + lf->lfHeight = (char)db_get_b(NULL, "SRMM", str, -12); + lf->lfWidth = 0; + lf->lfEscapement = 0; + lf->lfOrientation = 0; + mir_snprintf(str, SIZEOF(str), "SRMFont%dSty", i); + int style = db_get_b(NULL, "SRMM", str, 0); + lf->lfWeight = style & DBFONTF_BOLD ? FW_BOLD : FW_NORMAL; + lf->lfItalic = style & DBFONTF_ITALIC ? 1 : 0; + lf->lfUnderline = 0; + lf->lfStrikeOut = 0; + lf->lfOutPrecision = OUT_DEFAULT_PRECIS; + lf->lfClipPrecision = CLIP_DEFAULT_PRECIS; + lf->lfQuality = DEFAULT_QUALITY; + lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; + mir_snprintf(str, SIZEOF(str), "SRMFont%d", i); + + DBVARIANT dbv; + if (db_get_ts(NULL, "SRMM", str, &dbv)) + _tcscpy(lf->lfFaceName, _T("Arial")); + else { + lstrcpyn(lf->lfFaceName, dbv.ptszVal, SIZEOF(lf->lfFaceName)); + db_free(&dbv); + } + mir_snprintf(str, SIZEOF(str), "SRMFont%dSet", i); + lf->lfCharSet = db_get_b(NULL, "SRMM", str, DEFAULT_CHARSET); + } + return true; +} + int GetRichTextLength(HWND hwnd) { GETTEXTLENGTHEX gtl; @@ -56,14 +96,11 @@ void CheckColorsInModule(const char* pszModule) int i = 0; COLORREF crBG = (COLORREF)db_get_dw(NULL, CHAT_MODULE, "ColorMessageBG", GetSysColor(COLOR_WINDOW)); - COLORREF crFG; - pci->LoadMsgDlgFont(17, NULL, &crFG); - if (!pMod) return; for (i = 0; i < pMod->nColorCount; i++) { - if (pMod->crColors[i] == crFG || pMod->crColors[i] == crBG) { + if (pMod->crColors[i] == g_Settings.MessageAreaColor || pMod->crColors[i] == crBG) { if (pMod->crColors[i] == RGB(255, 255, 255)) pMod->crColors[i]--; else diff --git a/src/core/stdchat/src/window.cpp b/src/core/stdchat/src/window.cpp index cda6fa9ffe..321affafcd 100644 --- a/src/core/stdchat/src/window.cpp +++ b/src/core/stdchat/src/window.cpp @@ -522,9 +522,6 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, SendMessage(hwnd, WM_SETREDRAW, FALSE, 0); - LOGFONT lf; - pci->LoadMsgDlgFont(17, &lf, NULL); - if (lpPrevCmd) { SETTEXTEX ste; ste.flags = ST_DEFAULT; @@ -641,9 +638,6 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, case WM_RBUTTONUP: case WM_MBUTTONUP: { - COLORREF cr; - pci->LoadMsgDlgFont(17, NULL, &cr); - CHARFORMAT2 cf; cf.cbSize = sizeof(CHARFORMAT2); cf.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_BACKCOLOR | CFM_COLOR; @@ -659,9 +653,9 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, Parentsi->iFG = index; } - if (u == BST_UNCHECKED && cf.crTextColor != cr) + if (u == BST_UNCHECKED && cf.crTextColor != g_Settings.MessageAreaColor) CheckDlgButton(GetParent(hwnd), IDC_COLOR, BST_CHECKED); - else if (u == BST_CHECKED && cf.crTextColor == cr) + else if (u == BST_CHECKED && cf.crTextColor == g_Settings.MessageAreaColor) CheckDlgButton(GetParent(hwnd), IDC_COLOR, BST_UNCHECKED); } @@ -1230,18 +1224,14 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TAB), GWL_STYLE, (LONG_PTR)mask); } { - // messagebox - COLORREF crFore; - pci->LoadMsgDlgFont(17, NULL, &crFore); - CHARFORMAT2 cf; cf.cbSize = sizeof(CHARFORMAT2); cf.dwMask = CFM_COLOR|CFM_BOLD|CFM_UNDERLINE|CFM_BACKCOLOR; cf.dwEffects = 0; - cf.crTextColor = crFore; + cf.crTextColor = g_Settings.MessageAreaColor; cf.crBackColor = (COLORREF)db_get_dw(NULL, CHAT_MODULE, "ColorMessageBG", GetSysColor(COLOR_WINDOW)); SendMessage(GetDlgItem(hwndDlg, IDC_MESSAGE), EM_SETBKGNDCOLOR , 0, db_get_dw(NULL, CHAT_MODULE, "ColorMessageBG", GetSysColor(COLOR_WINDOW))); - SendDlgItemMessage(hwndDlg, IDC_MESSAGE, WM_SETFONT, (WPARAM) g_Settings.MessageBoxFont, MAKELPARAM(TRUE, 0)); + SendDlgItemMessage(hwndDlg, IDC_MESSAGE, WM_SETFONT, (WPARAM) g_Settings.MessageAreaFont, MAKELPARAM(TRUE, 0)); SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETCHARFORMAT, (WPARAM)SCF_ALL , (LPARAM)&cf); // nicklist @@ -2470,10 +2460,8 @@ LABEL_SHOWWINDOW: } } else { - COLORREF cr; - pci->LoadMsgDlgFont(17, NULL, &cr); cf.dwMask = CFM_COLOR; - cf.crTextColor = cr; + cf.crTextColor = g_Settings.MessageAreaColor; SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); } } diff --git a/src/core/stdmsg/src/msgoptions.cpp b/src/core/stdmsg/src/msgoptions.cpp index a2fdc868b8..c57d10abfd 100644 --- a/src/core/stdmsg/src/msgoptions.cpp +++ b/src/core/stdmsg/src/msgoptions.cpp @@ -24,8 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "m_fontservice.h" #include "m_modernopt.h" -#define FONTF_BOLD 1 -#define FONTF_ITALIC 2 struct FontOptionsList { const TCHAR* szDescr; @@ -38,11 +36,11 @@ static const fontOptionsList[] = { { LPGENT("Outgoing messages"), RGB(106, 106, 106), _T("Arial"), 0, -12}, { LPGENT("Incoming messages"), RGB(0, 0, 0), _T("Arial"), 0, -12}, - { LPGENT("Outgoing name"), RGB(89, 89, 89), _T("Arial"), FONTF_BOLD, -12}, - { LPGENT("Outgoing time"), RGB(0, 0, 0), _T("Terminal"), FONTF_BOLD, -9}, + { LPGENT("Outgoing name"), RGB(89, 89, 89), _T("Arial"), DBFONTF_BOLD, -12}, + { LPGENT("Outgoing time"), RGB(0, 0, 0), _T("Terminal"), DBFONTF_BOLD, -9}, { LPGENT("Outgoing colon"), RGB(89, 89, 89), _T("Arial"), 0, -11}, - { LPGENT("Incoming name"), RGB(215, 0, 0), _T("Arial"), FONTF_BOLD, -12}, - { LPGENT("Incoming time"), RGB(0, 0, 0), _T("Terminal"), FONTF_BOLD, -9}, + { LPGENT("Incoming name"), RGB(215, 0, 0), _T("Arial"), DBFONTF_BOLD, -12}, + { LPGENT("Incoming time"), RGB(0, 0, 0), _T("Terminal"), DBFONTF_BOLD, -9}, { LPGENT("Incoming colon"), RGB(215, 0, 0), _T("Arial"), 0, -11}, { LPGENT("Message area"), RGB(0, 0, 0), _T("Arial"), 0, -12}, { LPGENT("Notices"), RGB(90, 90, 160), _T("Arial"), 0, -12}, @@ -72,8 +70,8 @@ bool LoadMsgDlgFont(int i, LOGFONT* lf, COLORREF * colour) lf->lfOrientation = 0; mir_snprintf(str, SIZEOF(str), "SRMFont%dSty", i); int style = db_get_b(NULL, SRMMMOD, str, fontOptionsList[i].defStyle); - lf->lfWeight = style & FONTF_BOLD ? FW_BOLD : FW_NORMAL; - lf->lfItalic = style & FONTF_ITALIC ? 1 : 0; + lf->lfWeight = style & DBFONTF_BOLD ? FW_BOLD : FW_NORMAL; + lf->lfItalic = style & DBFONTF_ITALIC ? 1 : 0; lf->lfUnderline = 0; lf->lfStrikeOut = 0; lf->lfOutPrecision = OUT_DEFAULT_PRECIS; @@ -110,7 +108,7 @@ void RegisterSRMMFonts( void ) fontid.order = i; fontid.flags &= ~FIDF_CLASSMASK; - fontid.flags |= (fontOptionsList[i].defStyle == FONTF_BOLD) ? FIDF_CLASSHEADER : FIDF_CLASSGENERAL; + fontid.flags |= (fontOptionsList[i].defStyle == DBFONTF_BOLD) ? FIDF_CLASSHEADER : FIDF_CLASSGENERAL; fontid.deffontsettings.colour = fontOptionsList[i].defColour; fontid.deffontsettings.size = fontOptionsList[i].defSize; -- cgit v1.2.3