summaryrefslogtreecommitdiff
path: root/src/core/stdchat
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-03-19 15:40:40 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-03-19 15:40:40 +0000
commitc0658da7ca3d7edaedc92672788765504f3043e5 (patch)
treef7cc7ca237f9557c98e691e48d22811435057656 /src/core/stdchat
parente89159151599a72d4423f0de47e1a413873e4d49 (diff)
- 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
Diffstat (limited to 'src/core/stdchat')
-rw-r--r--src/core/stdchat/src/chat.h5
-rw-r--r--src/core/stdchat/src/main.cpp15
-rw-r--r--src/core/stdchat/src/tools.cpp45
-rw-r--r--src/core/stdchat/src/window.cpp22
4 files changed, 58 insertions, 29 deletions
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);
}
}