summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/m_chat_int.h2
-rw-r--r--libs/win32/mir_app.libbin112886 -> 113562 bytes
-rw-r--r--libs/win64/mir_app.libbin108382 -> 109068 bytes
-rw-r--r--plugins/Scriver/src/chat_window.cpp122
-rw-r--r--plugins/TabSRMM/src/chat_window.cpp133
-rw-r--r--src/core/stdmsg/src/chat_manager.cpp2
-rw-r--r--src/core/stdmsg/src/chat_util.cpp45
-rw-r--r--src/core/stdmsg/src/chat_window.cpp166
-rw-r--r--src/core/stdmsg/src/msgoptions.cpp13
-rw-r--r--src/core/stdmsg/src/stdafx.h5
-rw-r--r--src/mir_app/src/mir_app.def2
-rw-r--r--src/mir_app/src/mir_app64.def2
-rw-r--r--src/mir_app/src/srmm_base.cpp131
13 files changed, 163 insertions, 460 deletions
diff --git a/include/m_chat_int.h b/include/m_chat_int.h
index ce3324e47e..e787173971 100644
--- a/include/m_chat_int.h
+++ b/include/m_chat_int.h
@@ -402,6 +402,8 @@ protected:
virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
void DoEventHook(int iType, const USERINFO *pUser, const wchar_t *pszText, INT_PTR dwItem);
+ bool ProcessHotkeys(int key);
+ void RefreshButtonStatus(void);
protected:
CCtrlEdit *m_pLog, *m_pEntry;
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib
index c5acb671dd..41af1a5183 100644
--- a/libs/win32/mir_app.lib
+++ b/libs/win32/mir_app.lib
Binary files differ
diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib
index f78980d5f4..fa88f295f8 100644
--- a/libs/win64/mir_app.lib
+++ b/libs/win64/mir_app.lib
Binary files differ
diff --git a/plugins/Scriver/src/chat_window.cpp b/plugins/Scriver/src/chat_window.cpp
index 7d76fc1a76..a57895fc2b 100644
--- a/plugins/Scriver/src/chat_window.cpp
+++ b/plugins/Scriver/src/chat_window.cpp
@@ -193,55 +193,9 @@ LRESULT CALLBACK CChatRoomDlg::MessageSubclassProc(HWND hwnd, UINT msg, WPARAM w
mir_free(dat->szSearchResult);
dat->szSearchResult = nullptr;
}
- if (wParam == 0x49 && isCtrl && !isAlt) { // ctrl-i (italics)
- CheckDlgButton(GetParent(hwnd), IDC_SRMM_ITALICS, IsDlgButtonChecked(GetParent(hwnd), IDC_SRMM_ITALICS) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_SRMM_ITALICS, 0), 0);
- return TRUE;
- }
-
- if (wParam == 0x42 && isCtrl && !isAlt) { // ctrl-b (bold)
- CheckDlgButton(GetParent(hwnd), IDC_SRMM_BOLD, IsDlgButtonChecked(GetParent(hwnd), IDC_SRMM_BOLD) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_SRMM_BOLD, 0), 0);
- return TRUE;
- }
- if (wParam == 0x55 && isCtrl && !isAlt) { // ctrl-u (paste clean text)
- CheckDlgButton(GetParent(hwnd), IDC_SRMM_UNDERLINE, IsDlgButtonChecked(GetParent(hwnd), IDC_SRMM_UNDERLINE) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_SRMM_UNDERLINE, 0), 0);
+ if (pDlg->ProcessHotkeys(wParam))
return TRUE;
- }
-
- if (wParam == 0x4b && isCtrl && !isAlt) { // ctrl-k (paste clean text)
- CheckDlgButton(GetParent(hwnd), IDC_SRMM_COLOR, IsDlgButtonChecked(GetParent(hwnd), IDC_SRMM_COLOR) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_SRMM_COLOR, 0), 0);
- return TRUE;
- }
-
- if (wParam == VK_SPACE && isCtrl && !isAlt) { // ctrl-space (paste clean text)
- CheckDlgButton(GetParent(hwnd), IDC_SRMM_BKGCOLOR, BST_UNCHECKED);
- CheckDlgButton(GetParent(hwnd), IDC_SRMM_COLOR, BST_UNCHECKED);
- CheckDlgButton(GetParent(hwnd), IDC_SRMM_BOLD, BST_UNCHECKED);
- CheckDlgButton(GetParent(hwnd), IDC_SRMM_UNDERLINE, BST_UNCHECKED);
- CheckDlgButton(GetParent(hwnd), IDC_SRMM_ITALICS, BST_UNCHECKED);
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_SRMM_BKGCOLOR, 0), 0);
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_SRMM_COLOR, 0), 0);
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_SRMM_BOLD, 0), 0);
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_SRMM_UNDERLINE, 0), 0);
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_SRMM_ITALICS, 0), 0);
- return TRUE;
- }
-
- if (wParam == 0x4c && isCtrl && !isAlt) { // ctrl-l (paste clean text)
- CheckDlgButton(GetParent(hwnd), IDC_SRMM_BKGCOLOR, IsDlgButtonChecked(GetParent(hwnd), IDC_SRMM_BKGCOLOR) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_SRMM_BKGCOLOR, 0), 0);
- return TRUE;
- }
-
- if (wParam == 0x46 && isCtrl && !isAlt) { // ctrl-f (paste clean text)
- if (IsWindowEnabled(GetDlgItem(GetParent(hwnd), IDC_SRMM_FILTER)))
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_SRMM_FILTER, 0), 0);
- return TRUE;
- }
if (wParam == 0x4e && isCtrl && !isAlt) { // ctrl-n (nicklist)
if (IsWindowEnabled(GetDlgItem(GetParent(hwnd), IDC_SHOWNICKLIST)))
@@ -286,79 +240,7 @@ LRESULT CALLBACK CChatRoomDlg::MessageSubclassProc(HWND hwnd, UINT msg, WPARAM w
case WM_LBUTTONUP:
case WM_RBUTTONUP:
case WM_MBUTTONUP:
- {
- UINT u = 0;
- UINT u2 = 0;
- COLORREF cr;
- SESSION_INFO *si = pDlg->m_si;
-
- LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, nullptr, &cr);
-
- CHARFORMAT2 cf;
- cf.cbSize = sizeof(CHARFORMAT2);
- cf.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_BACKCOLOR | CFM_COLOR;
- SendMessage(hwnd, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
-
- if (pci->MM_FindModule(si->pszModule) && pci->MM_FindModule(si->pszModule)->bColor) {
- int index = pci->GetColorIndex(si->pszModule, cf.crTextColor);
- u = IsDlgButtonChecked(GetParent(hwnd), IDC_SRMM_COLOR);
-
- if (index >= 0) {
- pDlg->m_bFGSet = true;
- pDlg->m_iFG = index;
- }
-
- if (u == BST_UNCHECKED && cf.crTextColor != cr)
- CheckDlgButton(GetParent(hwnd), IDC_SRMM_COLOR, BST_CHECKED);
- else if (u == BST_CHECKED && cf.crTextColor == cr)
- CheckDlgButton(GetParent(hwnd), IDC_SRMM_COLOR, BST_UNCHECKED);
- }
-
- if (pci->MM_FindModule(si->pszModule) && pci->MM_FindModule(si->pszModule)->bBkgColor) {
- int index = pci->GetColorIndex(si->pszModule, cf.crBackColor);
- COLORREF crB = db_get_dw(0, SRMM_MODULE, SRMSGSET_INPUTBKGCOLOUR, SRMSGDEFSET_INPUTBKGCOLOUR);
- u = IsDlgButtonChecked(GetParent(hwnd), IDC_SRMM_BKGCOLOR);
-
- if (index >= 0) {
- pDlg->m_bBGSet = TRUE;
- pDlg->m_iBG = index;
- }
- if (u == BST_UNCHECKED && cf.crBackColor != crB)
- CheckDlgButton(GetParent(hwnd), IDC_SRMM_BKGCOLOR, BST_CHECKED);
- else if (u == BST_CHECKED && cf.crBackColor == crB)
- CheckDlgButton(GetParent(hwnd), IDC_SRMM_BKGCOLOR, BST_UNCHECKED);
- }
-
- if (pci->MM_FindModule(si->pszModule) && pci->MM_FindModule(si->pszModule)->bBold) {
- u = IsDlgButtonChecked(GetParent(hwnd), IDC_SRMM_BOLD);
- u2 = cf.dwEffects;
- u2 &= CFE_BOLD;
- if (u == BST_UNCHECKED && u2)
- CheckDlgButton(GetParent(hwnd), IDC_SRMM_BOLD, BST_CHECKED);
- else if (u == BST_CHECKED && u2 == 0)
- CheckDlgButton(GetParent(hwnd), IDC_SRMM_BOLD, BST_UNCHECKED);
- }
-
- if (pci->MM_FindModule(si->pszModule) && pci->MM_FindModule(si->pszModule)->bItalics) {
- u = IsDlgButtonChecked(GetParent(hwnd), IDC_SRMM_ITALICS);
- u2 = cf.dwEffects;
- u2 &= CFE_ITALIC;
- if (u == BST_UNCHECKED && u2)
- CheckDlgButton(GetParent(hwnd), IDC_SRMM_ITALICS, BST_CHECKED);
- else if (u == BST_CHECKED && u2 == 0)
- CheckDlgButton(GetParent(hwnd), IDC_SRMM_ITALICS, BST_UNCHECKED);
- }
-
- if (pci->MM_FindModule(si->pszModule) && pci->MM_FindModule(si->pszModule)->bUnderline) {
- u = IsDlgButtonChecked(GetParent(hwnd), IDC_SRMM_UNDERLINE);
- u2 = cf.dwEffects;
- u2 &= CFE_UNDERLINE;
- if (u == BST_UNCHECKED && u2)
- CheckDlgButton(GetParent(hwnd), IDC_SRMM_UNDERLINE, BST_CHECKED);
- else if (u == BST_CHECKED && u2 == 0)
- CheckDlgButton(GetParent(hwnd), IDC_SRMM_UNDERLINE, BST_UNCHECKED);
- }
- }
+ pDlg->RefreshButtonStatus();
break;
case WM_DESTROY:
diff --git a/plugins/TabSRMM/src/chat_window.cpp b/plugins/TabSRMM/src/chat_window.cpp
index e2efde0ab3..38603f90b9 100644
--- a/plugins/TabSRMM/src/chat_window.cpp
+++ b/plugins/TabSRMM/src/chat_window.cpp
@@ -600,61 +600,8 @@ LRESULT CALLBACK CChatRoomDlg::MessageSubclassProc(HWND hwnd, UINT msg, WPARAM w
if (PluginConfig.m_bSoundOnTyping && !isAlt && !isCtrl && !(pDlg->m_pContainer->dwFlags & CNT_NOSOUND) && wParam != VK_ESCAPE && !(wParam == VK_TAB && PluginConfig.m_bAllowTab))
SkinPlaySound("SoundOnTyping");
- if (isCtrl && !isAlt && !isShift) {
- MODULEINFO *mi = pci->MM_FindModule(pDlg->m_si->pszModule);
- if (mi == nullptr)
- return 0;
-
- switch (wParam) {
- case 0x09: // ctrl-i (italics)
- if (mi->bItalics) {
- CheckDlgButton(hwndParent, IDC_SRMM_ITALICS, IsDlgButtonChecked(hwndParent, IDC_SRMM_ITALICS) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
- SendMessage(hwndParent, WM_COMMAND, MAKEWPARAM(IDC_SRMM_ITALICS, 0), 0);
- }
- return 0;
- case 0x02: // ctrl-b (bold)
- if (mi->bBold) {
- CheckDlgButton(hwndParent, IDC_SRMM_BOLD, IsDlgButtonChecked(hwndParent, IDC_SRMM_BOLD) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
- SendMessage(hwndParent, WM_COMMAND, MAKEWPARAM(IDC_SRMM_BOLD, 0), 0);
- }
- return 0;
- case 0x20: // ctrl-space clear formatting
- if (mi->bBold && mi->bItalics && mi->bUnderline) {
- CheckDlgButton(hwndParent, IDC_SRMM_BKGCOLOR, BST_UNCHECKED);
- CheckDlgButton(hwndParent, IDC_SRMM_COLOR, BST_UNCHECKED);
- CheckDlgButton(hwndParent, IDC_SRMM_BOLD, BST_UNCHECKED);
- CheckDlgButton(hwndParent, IDC_SRMM_UNDERLINE, BST_UNCHECKED);
- CheckDlgButton(hwndParent, IDC_SRMM_ITALICS, BST_UNCHECKED);
- SendMessage(hwndParent, WM_COMMAND, MAKEWPARAM(IDC_SRMM_BKGCOLOR, 0), 0);
- SendMessage(hwndParent, WM_COMMAND, MAKEWPARAM(IDC_SRMM_COLOR, 0), 0);
- SendMessage(hwndParent, WM_COMMAND, MAKEWPARAM(IDC_SRMM_BOLD, 0), 0);
- SendMessage(hwndParent, WM_COMMAND, MAKEWPARAM(IDC_SRMM_UNDERLINE, 0), 0);
- SendMessage(hwndParent, WM_COMMAND, MAKEWPARAM(IDC_SRMM_ITALICS, 0), 0);
- }
- return 0;
- case 0x0c: // ctrl-l background color
- if (mi->bBkgColor) {
- CheckDlgButton(hwndParent, IDC_SRMM_BKGCOLOR, IsDlgButtonChecked(hwndParent, IDC_SRMM_BKGCOLOR) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
- SendMessage(hwndParent, WM_COMMAND, MAKEWPARAM(IDC_SRMM_BKGCOLOR, 0), 0);
- }
- return 0;
- case 0x15: // ctrl-u underlined
- if (mi->bUnderline) {
- CheckDlgButton(hwndParent, IDC_SRMM_UNDERLINE, IsDlgButtonChecked(hwndParent, IDC_SRMM_UNDERLINE) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
- SendMessage(hwndParent, WM_COMMAND, MAKEWPARAM(IDC_SRMM_UNDERLINE, 0), 0);
- }
- return 0; // ctrl-k color
- case 0x0b:
- if (mi->bColor) {
- CheckDlgButton(hwndParent, IDC_SRMM_COLOR, IsDlgButtonChecked(hwndParent, IDC_SRMM_COLOR) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
- SendMessage(hwndParent, WM_COMMAND, MAKEWPARAM(IDC_SRMM_COLOR, 0), 0);
- }
- return 0;
- case 0x17:
- PostMessage(hwndParent, WM_CLOSE, 0, 1);
- return 0;
- }
- }
+ if (pDlg->ProcessHotkeys(wParam))
+ return true;
break;
case WM_KEYDOWN:
@@ -853,81 +800,7 @@ LRESULT CALLBACK CChatRoomDlg::MessageSubclassProc(HWND hwnd, UINT msg, WPARAM w
case WM_LBUTTONUP:
case WM_RBUTTONUP:
case WM_MBUTTONUP:
- COLORREF cr;
- LoadLogfont(FONTSECTION_IM, MSGFONTID_MESSAGEAREA, nullptr, &cr, FONTMODULE);
-
- CHARFORMAT2 cf;
- cf.cbSize = sizeof(CHARFORMAT2);
- cf.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_BACKCOLOR | CFM_COLOR | CFM_UNDERLINETYPE;
- cf.dwEffects = 0;
- SendMessage(hwnd, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
- {
- MODULEINFO *mi = pci->MM_FindModule(pDlg->m_si->pszModule);
- if (mi == nullptr)
- break;
-
- if (mi->bColor) {
- int index = Chat_GetColorIndex(pDlg->m_si->pszModule, cf.crTextColor);
- UINT u = IsDlgButtonChecked(GetParent(hwnd), IDC_SRMM_COLOR);
-
- if (index >= 0) {
- pDlg->m_bFGSet = true;
- pDlg->m_iFG = index;
- }
-
- if (u == BST_UNCHECKED && cf.crTextColor != cr)
- CheckDlgButton(hwndParent, IDC_SRMM_COLOR, BST_CHECKED);
- else if (u == BST_CHECKED && cf.crTextColor == cr)
- CheckDlgButton(hwndParent, IDC_SRMM_COLOR, BST_UNCHECKED);
- }
-
- if (mi->bBkgColor) {
- int index = Chat_GetColorIndex(pDlg->m_si->pszModule, cf.crBackColor);
- UINT u = IsDlgButtonChecked(hwndParent, IDC_SRMM_BKGCOLOR);
-
- if (index >= 0) {
- pDlg->m_bBGSet = true;
- pDlg->m_iBG = index;
- }
-
- if (u == BST_UNCHECKED && cf.crBackColor != pDlg->m_clrInputBG)
- CheckDlgButton(hwndParent, IDC_SRMM_BKGCOLOR, BST_CHECKED);
- else if (u == BST_CHECKED && cf.crBackColor == pDlg->m_clrInputBG)
- CheckDlgButton(hwndParent, IDC_SRMM_BKGCOLOR, BST_UNCHECKED);
- }
-
- if (mi->bBold) {
- UINT u = IsDlgButtonChecked(hwndParent, IDC_SRMM_BOLD);
- UINT u2 = cf.dwEffects;
- u2 &= CFE_BOLD;
- if (u == BST_UNCHECKED && u2)
- CheckDlgButton(hwndParent, IDC_SRMM_BOLD, BST_CHECKED);
- else if (u == BST_CHECKED && u2 == 0)
- CheckDlgButton(hwndParent, IDC_SRMM_BOLD, BST_UNCHECKED);
- }
-
- if (mi->bItalics) {
- UINT u = IsDlgButtonChecked(hwndParent, IDC_SRMM_ITALICS);
- UINT u2 = cf.dwEffects;
- u2 &= CFE_ITALIC;
- if (u == BST_UNCHECKED && u2)
- CheckDlgButton(hwndParent, IDC_SRMM_ITALICS, BST_CHECKED);
- else if (u == BST_CHECKED && u2 == 0)
- CheckDlgButton(hwndParent, IDC_SRMM_ITALICS, BST_UNCHECKED);
- }
-
- if (mi->bUnderline) {
- UINT u = IsDlgButtonChecked(hwndParent, IDC_SRMM_UNDERLINE);
- if (cf.dwEffects & CFE_UNDERLINE && (cf.bUnderlineType & CFU_UNDERLINE || cf.bUnderlineType & CFU_UNDERLINEWORD)) {
- if (u == BST_UNCHECKED)
- CheckDlgButton(hwndParent, IDC_SRMM_UNDERLINE, BST_CHECKED);
- }
- else {
- if (u == BST_CHECKED)
- CheckDlgButton(hwndParent, IDC_SRMM_UNDERLINE, BST_UNCHECKED);
- }
- }
- }
+ pDlg->RefreshButtonStatus();
break;
case WM_INPUTLANGCHANGE:
diff --git a/src/core/stdmsg/src/chat_manager.cpp b/src/core/stdmsg/src/chat_manager.cpp
index bd9d3cacb8..dded4667bc 100644
--- a/src/core/stdmsg/src/chat_manager.cpp
+++ b/src/core/stdmsg/src/chat_manager.cpp
@@ -133,7 +133,7 @@ static void OnLoadSettings()
DeleteObject(g_Settings.MessageAreaFont);
LOGFONT lf;
- LoadMessageFont(&lf, &g_Settings.MessageAreaColor);
+ LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, &lf, &g_Settings.MessageAreaColor);
g_Settings.MessageAreaFont = CreateFontIndirect(&lf);
g_Settings.iX = db_get_dw(NULL, CHAT_MODULE, "roomx", -1);
diff --git a/src/core/stdmsg/src/chat_util.cpp b/src/core/stdmsg/src/chat_util.cpp
index d163e2e83a..e1ee1b2f96 100644
--- a/src/core/stdmsg/src/chat_util.cpp
+++ b/src/core/stdmsg/src/chat_util.cpp
@@ -142,45 +142,6 @@ char* Message_GetFromStream(HWND hwndDlg, SESSION_INFO *si)
/////////////////////////////////////////////////////////////////////////////////////////
-bool LoadMessageFont(LOGFONT *lf, COLORREF *colour)
-{
- char str[32];
- int i = 8; // MSGFONTID_MESSAGEAREA
-
- if (colour) {
- mir_snprintf(str, "SRMFont%dCol", i);
- *colour = db_get_dw(NULL, "SRMM", str, 0);
- }
- if (lf) {
- mir_snprintf(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, "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, "SRMFont%d", i);
-
- ptrW wszFontFace(db_get_wsa(NULL, "SRMM", str));
- if (wszFontFace == nullptr)
- mir_wstrcpy(lf->lfFaceName, L"Arial");
- else
- mir_wstrncpy(lf->lfFaceName, wszFontFace, _countof(lf->lfFaceName));
-
- mir_snprintf(str, "SRMFont%dSet", i);
- lf->lfCharSet = db_get_b(NULL, "SRMM", str, DEFAULT_CHARSET);
- }
- return true;
-}
-
int GetRichTextLength(HWND hwnd)
{
GETTEXTLENGTHEX gtl;
@@ -212,13 +173,11 @@ int GetColorIndex(const char* pszModule, COLORREF cr)
void CheckColorsInModule(const char* pszModule)
{
MODULEINFO *pMod = pci->MM_FindModule(pszModule);
- int i = 0;
- COLORREF crBG = (COLORREF)db_get_dw(NULL, CHAT_MODULE, "ColorMessageBG", GetSysColor(COLOR_WINDOW));
-
if (!pMod)
return;
- for (i = 0; i < pMod->nColorCount; i++) {
+ COLORREF crBG = (COLORREF)db_get_dw(NULL, CHAT_MODULE, "ColorMessageBG", GetSysColor(COLOR_WINDOW));
+ for (int i = 0; i < pMod->nColorCount; i++) {
if (pMod->crColors[i] == g_Settings.MessageAreaColor || pMod->crColors[i] == crBG) {
if (pMod->crColors[i] == RGB(255, 255, 255))
pMod->crColors[i]--;
diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp
index 73816dc2ac..5fdab6eb00 100644
--- a/src/core/stdmsg/src/chat_window.cpp
+++ b/src/core/stdmsg/src/chat_window.cpp
@@ -91,7 +91,7 @@ LBL_CalcBottom:
return RD_ANCHORX_LEFT | RD_ANCHORY_TOP;
}
-static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+LRESULT CALLBACK CChatRoomDlg::MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
MESSAGESUBDATA *dat = (MESSAGESUBDATA*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
HWND hwndDlg = GetParent(hwnd);
@@ -207,7 +207,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
if (g_Settings.bTabsEnable)
SendMessage(hwndDlg, GC_SWITCHTAB, 0, (int)wParam - (int)VK_NUMPAD1);
- if (wParam == VK_TAB && !isCtrl && !isShift) { //tab-autocomplete
+ if (wParam == VK_TAB && !isCtrl && !isShift) { // tab-autocomplete
wchar_t *pszText = nullptr;
LRESULT lResult = (LRESULT)SendMessage(hwnd, EM_GETSEL, 0, 0);
@@ -269,80 +269,26 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
dat->szTabSave[0] = '\0';
}
- if (wParam == VK_F4 && isCtrl && !isAlt) { // ctrl-F4 (close tab)
- pDlg->CloseTab();
- return TRUE;
- }
-
- if (wParam == VK_ESCAPE && !isCtrl && !isAlt) { // Esc (close tab)
- pDlg->CloseTab();
- return TRUE;
- }
-
- if (wParam == 0x49 && isCtrl && !isAlt) { // ctrl-i (italics)
- CheckDlgButton(hwndDlg, IDC_SRMM_ITALICS, IsDlgButtonChecked(hwndDlg, IDC_SRMM_ITALICS) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
- SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_SRMM_ITALICS, 0), 0);
+ if (pDlg->ProcessHotkeys(wParam))
return TRUE;
- }
-
- if (wParam == 0x42 && isCtrl && !isAlt) { // ctrl-b (bold)
- CheckDlgButton(hwndDlg, IDC_SRMM_BOLD, IsDlgButtonChecked(hwndDlg, IDC_SRMM_BOLD) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
- SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_SRMM_BOLD, 0), 0);
- return TRUE;
- }
-
- if (wParam == 0x55 && isCtrl && !isAlt) { // ctrl-u (paste clean text)
- CheckDlgButton(hwndDlg, IDC_SRMM_UNDERLINE, IsDlgButtonChecked(hwndDlg, IDC_SRMM_UNDERLINE) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
- SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_SRMM_UNDERLINE, 0), 0);
- return TRUE;
- }
-
- if (wParam == 0x4b && isCtrl && !isAlt) { // ctrl-k (paste clean text)
- CheckDlgButton(hwndDlg, IDC_SRMM_COLOR, IsDlgButtonChecked(hwndDlg, IDC_SRMM_COLOR) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
- SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_SRMM_COLOR, 0), 0);
- return TRUE;
- }
-
- if (wParam == VK_SPACE && isCtrl && !isAlt) { // ctrl-space (paste clean text)
- CheckDlgButton(hwndDlg, IDC_SRMM_BKGCOLOR, BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_SRMM_COLOR, BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_SRMM_BOLD, BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_SRMM_UNDERLINE, BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_SRMM_ITALICS, BST_UNCHECKED);
- SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_SRMM_BKGCOLOR, 0), 0);
- SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_SRMM_COLOR, 0), 0);
- SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_SRMM_BOLD, 0), 0);
- SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_SRMM_UNDERLINE, 0), 0);
- SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_SRMM_ITALICS, 0), 0);
- return TRUE;
- }
-
- if (wParam == 0x4c && isCtrl && !isAlt) { // ctrl-l (paste clean text)
- CheckDlgButton(hwndDlg, IDC_SRMM_BKGCOLOR, IsDlgButtonChecked(hwndDlg, IDC_SRMM_BKGCOLOR) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
- SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_SRMM_BKGCOLOR, 0), 0);
- return TRUE;
- }
if (wParam == 0x46 && isCtrl && !isAlt) { // ctrl-f (paste clean text)
- if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_SRMM_FILTER)))
- SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_SRMM_FILTER, 0), 0);
+ pDlg->onClick_Filter(&pDlg->m_btnFilter);
return TRUE;
}
if (wParam == 0x4e && isCtrl && !isAlt) { // ctrl-n (nicklist)
- if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_SHOWNICKLIST)))
- SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_SHOWNICKLIST, 0), 0);
+ pDlg->onClick_NickList(&pDlg->m_btnNickList);
return TRUE;
}
if (wParam == 0x48 && isCtrl && !isAlt) { // ctrl-h (history)
- SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_HISTORY, 0), 0);
+ pDlg->onClick_History(&pDlg->m_btnHistory);
return TRUE;
}
if (wParam == 0x4f && isCtrl && !isAlt) { // ctrl-o (options)
- if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHANMGR)))
- SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_CHANMGR, 0), 0);
+ pDlg->onClick_Options(&pDlg->m_btnChannelMgr);
return TRUE;
}
@@ -480,76 +426,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
case WM_LBUTTONUP:
case WM_RBUTTONUP:
case WM_MBUTTONUP:
- {
- CHARFORMAT2 cf;
- cf.cbSize = sizeof(CHARFORMAT2);
- cf.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_BACKCOLOR | CFM_COLOR;
- SendMessage(hwnd, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
-
- MODULEINFO *pmi = pci->MM_FindModule(dat->si->pszModule);
- if (pmi == nullptr)
- break;
-
- if (pmi->bColor) {
- int index = GetColorIndex(dat->si->pszModule, cf.crTextColor);
- UINT u = IsDlgButtonChecked(hwndDlg, IDC_SRMM_COLOR);
-
- if (index >= 0) {
- pDlg->m_bFGSet = true;
- pDlg->m_iFG = index;
- }
-
- if (u == BST_UNCHECKED && cf.crTextColor != g_Settings.MessageAreaColor)
- CheckDlgButton(hwndDlg, IDC_SRMM_COLOR, BST_CHECKED);
- else if (u == BST_CHECKED && cf.crTextColor == g_Settings.MessageAreaColor)
- CheckDlgButton(hwndDlg, IDC_SRMM_COLOR, BST_UNCHECKED);
- }
-
- if (pmi->bBkgColor) {
- int index = GetColorIndex(dat->si->pszModule, cf.crBackColor);
- COLORREF crB = (COLORREF)db_get_dw(0, CHAT_MODULE, "ColorMessageBG", GetSysColor(COLOR_WINDOW));
- UINT u = IsDlgButtonChecked(hwndDlg, IDC_SRMM_BKGCOLOR);
-
- if (index >= 0) {
- pDlg->m_bBGSet = TRUE;
- pDlg->m_iBG = index;
- }
- if (u == BST_UNCHECKED && cf.crBackColor != crB)
- CheckDlgButton(hwndDlg, IDC_SRMM_BKGCOLOR, BST_CHECKED);
- else if (u == BST_CHECKED && cf.crBackColor == crB)
- CheckDlgButton(hwndDlg, IDC_SRMM_BKGCOLOR, BST_UNCHECKED);
- }
-
- if (pmi->bBold) {
- UINT u = IsDlgButtonChecked(hwndDlg, IDC_SRMM_BOLD);
- UINT u2 = cf.dwEffects;
- u2 &= CFE_BOLD;
- if (u == BST_UNCHECKED && u2)
- CheckDlgButton(hwndDlg, IDC_SRMM_BOLD, BST_CHECKED);
- else if (u == BST_CHECKED && u2 == 0)
- CheckDlgButton(hwndDlg, IDC_SRMM_BOLD, BST_UNCHECKED);
- }
-
- if (pmi->bItalics) {
- UINT u = IsDlgButtonChecked(hwndDlg, IDC_SRMM_ITALICS);
- UINT u2 = cf.dwEffects;
- u2 &= CFE_ITALIC;
- if (u == BST_UNCHECKED && u2)
- CheckDlgButton(hwndDlg, IDC_SRMM_ITALICS, BST_CHECKED);
- else if (u == BST_CHECKED && u2 == 0)
- CheckDlgButton(hwndDlg, IDC_SRMM_ITALICS, BST_UNCHECKED);
- }
-
- if (pmi->bUnderline) {
- UINT u = IsDlgButtonChecked(hwndDlg, IDC_SRMM_UNDERLINE);
- UINT u2 = cf.dwEffects;
- u2 &= CFE_UNDERLINE;
- if (u == BST_UNCHECKED && u2)
- CheckDlgButton(hwndDlg, IDC_SRMM_UNDERLINE, BST_CHECKED);
- else if (u == BST_CHECKED && u2 == 0)
- CheckDlgButton(hwndDlg, IDC_SRMM_UNDERLINE, BST_UNCHECKED);
- }
- }
+ pDlg->RefreshButtonStatus();
break;
case WM_DESTROY:
@@ -832,10 +709,6 @@ CChatRoomDlg::CChatRoomDlg(SESSION_INFO *si) :
m_autoClose = 0;
m_forceResizable = true;
- m_btnBold.OnClick = Callback(this, &CChatRoomDlg::onClick_Bold);
- m_btnItalic.OnClick = Callback(this, &CChatRoomDlg::onClick_Bold);
- m_btnUnderline.OnClick = Callback(this, &CChatRoomDlg::onClick_Bold);
-
m_btnOk.OnClick = Callback(this, &CChatRoomDlg::onClick_Ok);
m_btnFilter.OnClick = Callback(this, &CChatRoomDlg::onClick_Filter);
@@ -926,23 +799,6 @@ void CChatRoomDlg::OnDestroy()
NotifyLocalWinEvent(m_hContact, m_hwnd, MSG_WINDOW_EVT_CLOSE);
}
-void CChatRoomDlg::onClick_Bold(CCtrlButton *pButton)
-{
- if (!pButton->Enabled())
- return;
-
- CHARFORMAT2 cf;
- cf.cbSize = sizeof(CHARFORMAT2);
- cf.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE;
- cf.dwEffects = 0;
- switch (pButton->GetCtrlId()) {
- case IDC_SRMM_BOLD: cf.dwEffects |= CFE_BOLD; break;
- case IDC_SRMM_ITALICS: cf.dwEffects |= CFE_ITALIC; break;
- case IDC_SRMM_UNDERLINE: cf.dwEffects |= CFE_UNDERLINE; break;
- }
- m_message.SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
-}
-
void CChatRoomDlg::onClick_Filter(CCtrlButton *pButton)
{
if (!pButton->Enabled())
@@ -1144,7 +1000,7 @@ void CChatRoomDlg::CloseTab()
void CChatRoomDlg::LoadSettings()
{
m_clrInputBG = db_get_dw(0, CHAT_MODULE, "ColorMessageBG", GetSysColor(COLOR_WINDOW));
- LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, nullptr, &m_clrInputFG);
+ m_clrInputFG = g_Settings.MessageAreaColor;
}
void CChatRoomDlg::RedrawLog()
@@ -1243,9 +1099,9 @@ void CChatRoomDlg::UpdateOptions()
cf.dwMask = CFM_COLOR | CFM_BOLD | CFM_UNDERLINE | CFM_BACKCOLOR;
cf.dwEffects = 0;
cf.crTextColor = g_Settings.MessageAreaColor;
- cf.crBackColor = db_get_dw(0, CHAT_MODULE, "ColorMessageBG", GetSysColor(COLOR_WINDOW));
+ cf.crBackColor = m_clrInputBG;
- m_message.SendMsg(EM_SETBKGNDCOLOR, 0, db_get_dw(0, CHAT_MODULE, "ColorMessageBG", GetSysColor(COLOR_WINDOW)));
+ m_message.SendMsg(EM_SETBKGNDCOLOR, 0, m_clrInputBG);
m_message.SendMsg(WM_SETFONT, (WPARAM)g_Settings.MessageAreaFont, MAKELPARAM(TRUE, 0));
m_message.SendMsg(EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
diff --git a/src/core/stdmsg/src/msgoptions.cpp b/src/core/stdmsg/src/msgoptions.cpp
index ad7f93fa7c..75467c6d18 100644
--- a/src/core/stdmsg/src/msgoptions.cpp
+++ b/src/core/stdmsg/src/msgoptions.cpp
@@ -82,13 +82,12 @@ bool LoadMsgDlgFont(int i, LOGFONT* lf, COLORREF * colour)
lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
mir_snprintf(str, "SRMFont%d", i);
- DBVARIANT dbv;
- if (db_get_ws(NULL, SRMMMOD, str, &dbv))
- wcsncpy(lf->lfFaceName, fontOptionsList[i].szDefFace, _countof(lf->lfFaceName)-1);
- else {
- mir_wstrncpy(lf->lfFaceName, dbv.ptszVal, _countof(lf->lfFaceName));
- db_free(&dbv);
- }
+ ptrW wszFontFace(db_get_wsa(NULL, SRMMMOD, str));
+ if (wszFontFace == nullptr)
+ wcsncpy_s(lf->lfFaceName, fontOptionsList[i].szDefFace, _TRUNCATE);
+ else
+ mir_wstrncpy(lf->lfFaceName, wszFontFace, _countof(lf->lfFaceName));
+
mir_snprintf(str, "SRMFont%dSet", i);
lf->lfCharSet = db_get_b(NULL, SRMMMOD, str, MsgDlgGetFontDefaultCharset(lf->lfFaceName));
}
diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h
index ec0d18a764..c665cbb2b8 100644
--- a/src/core/stdmsg/src/stdafx.h
+++ b/src/core/stdmsg/src/stdafx.h
@@ -127,7 +127,6 @@ void Unload_ChatModule(void);
void Load_ChatModule(void);
// log.cpp
-void Log_StreamInEvent(HWND hwndDlg, LOGINFO *lin, SESSION_INFO *si, BOOL bRedraw);
void ValidateFilename(wchar_t *filename);
char* Log_CreateRtfHeader(MODULEINFO *mi);
@@ -151,7 +150,6 @@ void CheckColorsInModule(const char* pszModule);
int GetRichTextLength(HWND hwnd);
UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, wchar_t* pszUID, wchar_t* pszWordText);
void DestroyGCMenu(HMENU *hMenu, int iIndex);
-bool LoadMessageFont(LOGFONT *lf, COLORREF *colour);
void SetButtonsPos(HWND hwndDlg, bool bIsChat);
int RestoreWindowPosition(HWND hwnd, MCONTACT hContact, bool bHide);
@@ -212,6 +210,7 @@ class CChatRoomDlg : public CSrmmBaseDialog
friend struct CTabbedWindow;
static INT_PTR CALLBACK FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
HWND m_hwndStatus;
@@ -251,8 +250,6 @@ public:
virtual void UpdateStatusBar() override;
virtual void UpdateTitle() override;
- void onClick_Bold(CCtrlButton*);
-
void onClick_Ok(CCtrlButton*);
void onClick_Filter(CCtrlButton*);
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 327dab2f19..da3ee660ea 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -429,3 +429,5 @@ Clist_ClearSearch @429 NONAME
?onClick_BIU@CSrmmBaseDialog@@IAEXPAVCCtrlButton@@@Z @430 NONAME
?onClick_BkColor@CSrmmBaseDialog@@IAEXPAVCCtrlButton@@@Z @431 NONAME
?onClick_Color@CSrmmBaseDialog@@IAEXPAVCCtrlButton@@@Z @432 NONAME
+?ProcessHotkeys@CSrmmBaseDialog@@IAE_NH@Z @433 NONAME
+?RefreshButtonStatus@CSrmmBaseDialog@@IAEXXZ @434 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 9a6bf47022..cd572cd7e2 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -429,3 +429,5 @@ Clist_ClearSearch @429 NONAME
?onClick_BIU@CSrmmBaseDialog@@IEAAXPEAVCCtrlButton@@@Z @430 NONAME
?onClick_BkColor@CSrmmBaseDialog@@IEAAXPEAVCCtrlButton@@@Z @431 NONAME
?onClick_Color@CSrmmBaseDialog@@IEAAXPEAVCCtrlButton@@@Z @432 NONAME
+?ProcessHotkeys@CSrmmBaseDialog@@IEAA_NH@Z @433 NONAME
+?RefreshButtonStatus@CSrmmBaseDialog@@IEAAXXZ @434 NONAME
diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp
index 9410e76142..81c4af1b38 100644
--- a/src/mir_app/src/srmm_base.cpp
+++ b/src/mir_app/src/srmm_base.cpp
@@ -115,6 +115,8 @@ void CSrmmBaseDialog::OnInitDialog()
mir_subclassWindow(m_btnFilter.GetHwnd(), Srmm_ButtonSubclassProc);
mir_subclassWindow(m_btnColor.GetHwnd(), Srmm_ButtonSubclassProc);
mir_subclassWindow(m_btnBkColor.GetHwnd(), Srmm_ButtonSubclassProc);
+
+ LoadSettings();
}
INT_PTR CSrmmBaseDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
@@ -306,3 +308,132 @@ void CSrmmBaseDialog::onClick_BIU(CCtrlButton *pButton)
cf.dwEffects |= CFE_UNDERLINE;
m_pEntry->SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+bool CSrmmBaseDialog::ProcessHotkeys(int key)
+{
+ BOOL isCtrl = GetKeyState(VK_CONTROL) & 0x8000;
+ BOOL isAlt = GetKeyState(VK_MENU) & 0x8000;
+
+ if (key == VK_F4 && isCtrl && !isAlt) { // ctrl-F4 (close tab)
+ CloseTab();
+ return true;
+ }
+
+ if (key == VK_ESCAPE && !isCtrl && !isAlt) { // Esc (close tab)
+ CloseTab();
+ return true;
+ }
+
+ if (key == 0x42 && isCtrl && !isAlt) { // ctrl-b (bold)
+ m_btnBold.Push(!m_btnBold.IsPushed());
+ onClick_BIU(&m_btnBold);
+ return true;
+ }
+
+ if (key == 0x49 && isCtrl && !isAlt) { // ctrl-i (italics)
+ m_btnItalic.Push(!m_btnItalic.IsPushed());
+ onClick_BIU(&m_btnItalic);
+ return true;
+ }
+
+ if (key == 0x55 && isCtrl && !isAlt) { // ctrl-u (paste clean text)
+ m_btnUnderline.Push(!m_btnUnderline.IsPushed());
+ onClick_BIU(&m_btnUnderline);
+ return true;
+ }
+
+ if (key == 0x4b && isCtrl && !isAlt) { // ctrl-k (paste clean text)
+ m_btnColor.Push(!m_btnColor.IsPushed());
+ onClick_Color(&m_btnColor);
+ return true;
+ }
+
+ if (key == 0x4c && isCtrl && !isAlt) { // ctrl-l (paste clean text)
+ m_btnBkColor.Push(!m_btnBkColor.IsPushed());
+ onClick_BkColor(&m_btnBkColor);
+ return true;
+ }
+
+ if (key == VK_SPACE && isCtrl && !isAlt) { // ctrl-space (paste clean text)
+ m_btnBold.Push(false); onClick_BIU(&m_btnBold);
+ m_btnItalic.Push(false); onClick_BIU(&m_btnItalic);
+ m_btnUnderline.Push(false); onClick_BIU(&m_btnUnderline);
+
+ m_btnColor.Push(false); onClick_Color(&m_btnColor);
+ m_btnBkColor.Push(false); onClick_BkColor(&m_btnBkColor);
+ return true;
+ }
+
+ return false;
+}
+
+void CSrmmBaseDialog::RefreshButtonStatus(void)
+{
+ CHARFORMAT2 cf;
+ cf.cbSize = sizeof(CHARFORMAT2);
+ cf.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_BACKCOLOR | CFM_COLOR;
+ SendMessage(m_pEntry->GetHwnd(), EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
+
+ MODULEINFO *mi = chatApi.MM_FindModule(m_si->pszModule);
+ if (mi == nullptr)
+ return;
+
+ if (mi->bColor) {
+ int index = GetColorIndex(m_si->pszModule, cf.crTextColor);
+ bool bState = m_btnColor.IsPushed();
+
+ if (index >= 0) {
+ m_bFGSet = true;
+ m_iFG = index;
+ }
+
+ if (!bState && cf.crTextColor != m_clrInputFG)
+ m_btnColor.Push(true);
+ else if (bState && cf.crTextColor == m_clrInputFG)
+ m_btnColor.Push(false);
+ }
+
+ if (mi->bBkgColor) {
+ int index = GetColorIndex(m_si->pszModule, cf.crBackColor);
+ bool bState = m_btnBkColor.IsPushed();
+
+ if (index >= 0) {
+ m_bBGSet = true;
+ m_iBG = index;
+ }
+
+ if (!bState && cf.crBackColor != m_clrInputBG)
+ m_btnBkColor.Push(true);
+ else if (bState && cf.crBackColor == m_clrInputBG)
+ m_btnBkColor.Push(false);
+ }
+
+ if (mi->bBold) {
+ bool bState = m_btnBold.IsPushed();
+ UINT u2 = cf.dwEffects & CFE_BOLD;
+ if (!bState && u2 != 0)
+ m_btnBold.Push(true);
+ else if (bState && u2 == 0)
+ m_btnBold.Push(false);
+ }
+
+ if (mi->bItalics) {
+ bool bState = m_btnItalic.IsPushed();
+ UINT u2 = cf.dwEffects & CFE_ITALIC;
+ if (!bState && u2 != 0)
+ m_btnItalic.Push(true);
+ else if (bState && u2 == 0)
+ m_btnItalic.Push(false);
+ }
+
+ if (mi->bUnderline) {
+ bool bState = m_btnUnderline.IsPushed();
+ UINT u2 = cf.dwEffects & CFE_UNDERLINE;
+ if (!bState && u2 != 0)
+ m_btnUnderline.Push(true);
+ else if (bState && u2 == 0)
+ m_btnUnderline.Push(false);
+ }
+}