summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-03-21 21:22:34 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-03-21 21:22:34 +0300
commit216654c005d6b363c91ee3dfbff2203bab4e06c1 (patch)
treecd38e82811875d56c38415479a77b71dcd418e27 /plugins
parent7104a25fa975b8b70fcab6e499efe91bc1a9313c (diff)
common chat hotkeys processing code moved to mir_app
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Scriver/src/chat_window.cpp122
-rw-r--r--plugins/TabSRMM/src/chat_window.cpp133
2 files changed, 5 insertions, 250 deletions
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: