diff options
author | George Hazan <ghazan@miranda.im> | 2017-03-21 21:22:34 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-03-21 21:22:34 +0300 |
commit | 216654c005d6b363c91ee3dfbff2203bab4e06c1 (patch) | |
tree | cd38e82811875d56c38415479a77b71dcd418e27 /src/mir_app | |
parent | 7104a25fa975b8b70fcab6e499efe91bc1a9313c (diff) |
common chat hotkeys processing code moved to mir_app
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/src/mir_app.def | 2 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 2 | ||||
-rw-r--r-- | src/mir_app/src/srmm_base.cpp | 131 |
3 files changed, 135 insertions, 0 deletions
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); + } +} |