diff options
author | George Hazan <ghazan@miranda.im> | 2017-03-21 18:23:08 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-03-21 18:23:08 +0300 |
commit | b3a736917686b19b55c684c1b15c1e83cd0261e5 (patch) | |
tree | 2b71bed0ce0058f33a389a46b2be7dc67accab0b /src/mir_app | |
parent | 03ba85dcd2d47cf31d6181b40620e278f7f30427 (diff) |
some common code moved into mir_app
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/src/colorchooser.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 7 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 7 | ||||
-rw-r--r-- | src/mir_app/src/srmm_base.cpp | 96 | ||||
-rw-r--r-- | src/mir_app/src/srmm_util.cpp | 17 |
5 files changed, 115 insertions, 14 deletions
diff --git a/src/mir_app/src/colorchooser.cpp b/src/mir_app/src/colorchooser.cpp index 731239b8c1..6422e4020a 100644 --- a/src/mir_app/src/colorchooser.cpp +++ b/src/mir_app/src/colorchooser.cpp @@ -267,6 +267,6 @@ public: void CSrmmBaseDialog::ShowColorChooser(int iCtrlId)
{
- CColorChooserDlg *pDialog = new CColorChooserDlg(m_si, iCtrlId == m_pColor->GetCtrlId(), m_hwnd, m_pEntry->GetHwnd(), GetDlgItem(m_hwnd, iCtrlId));
+ CColorChooserDlg *pDialog = new CColorChooserDlg(m_si, iCtrlId == IDC_SRMM_COLOR, m_hwnd, m_pEntry->GetHwnd(), GetDlgItem(m_hwnd, iCtrlId));
pDialog->Show();
}
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 1d15af6551..fb6970252c 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -400,9 +400,9 @@ ProtoGetAvatarFormatByMimeType @400 ProtoGetAvatarMimeType @401
?set_uin@DB_AUTH_BLOB@@QAEXK@Z @402 NONAME
??0CSrmmBaseDialog@@IAE@PAUHINSTANCE__@@HPAUSESSION_INFO@@@Z @403 NONAME
-??0CSrmmBaseDialog@@QAE@ABV0@@Z @404 NONAME
+??0CSrmmBaseDialog@@AAE@ABV0@@Z @404 NONAME
??1CSrmmBaseDialog@@UAE@XZ @405 NONAME
-??4CSrmmBaseDialog@@QAEAAV0@ABV0@@Z @406 NONAME
+??4CSrmmBaseDialog@@AAEAAV0@ABV0@@Z @406 NONAME
??_7CSrmmBaseDialog@@6B@ @407 NONAME
?DlgProc@CSrmmBaseDialog@@MAEHIIJ@Z @408 NONAME
??2CSrmmBaseDialog@@SAPAXI@Z @409 NONAME
@@ -426,3 +426,6 @@ _Srmm_ButtonSubclassProc@16 @423 NONAME ?ScrollToBottom@CSrmmBaseDialog@@UAEXXZ @427 NONAME
?UpdateNickList@CSrmmBaseDialog@@UAEXXZ @428 NONAME
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
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 0802a90a7f..7f8659dd96 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -400,9 +400,9 @@ ProtoGetAvatarFormatByMimeType @400 ProtoGetAvatarMimeType @401
?set_uin@DB_AUTH_BLOB@@QEAAXK@Z @402 NONAME
??0CSrmmBaseDialog@@IEAA@PEAUHINSTANCE__@@HPEAUSESSION_INFO@@@Z @403 NONAME
-??0CSrmmBaseDialog@@QEAA@AEBV0@@Z @404 NONAME
+??0CSrmmBaseDialog@@AEAA@AEBV0@@Z @404 NONAME
??1CSrmmBaseDialog@@UEAA@XZ @405 NONAME
-??4CSrmmBaseDialog@@QEAAAEAV0@AEBV0@@Z @406 NONAME
+??4CSrmmBaseDialog@@AEAAAEAV0@AEBV0@@Z @406 NONAME
??_7CSrmmBaseDialog@@6B@ @407 NONAME
?DlgProc@CSrmmBaseDialog@@MEAA_JI_K_J@Z @408 NONAME
??2CSrmmBaseDialog@@SAPEAX_K@Z @409 NONAME
@@ -426,3 +426,6 @@ Srmm_ButtonSubclassProc @423 NONAME ?ScrollToBottom@CSrmmBaseDialog@@UEAAXXZ @427 NONAME
?UpdateNickList@CSrmmBaseDialog@@UEAAXXZ @428 NONAME
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
diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp index 8df17b3fd7..d95ed32a65 100644 --- a/src/mir_app/src/srmm_base.cpp +++ b/src/mir_app/src/srmm_base.cpp @@ -29,18 +29,27 @@ extern HCURSOR g_hCurHyperlinkHand; CSrmmBaseDialog::CSrmmBaseDialog(HINSTANCE hInst, int idDialog, SESSION_INFO *si) : CDlgBase(hInst, idDialog), + m_btnFilter(this, IDC_SRMM_FILTER), + m_btnColor(this, IDC_SRMM_COLOR), + m_btnBkColor(this, IDC_SRMM_BKGCOLOR), + m_btnBold(this, IDC_SRMM_BOLD), + m_btnItalic(this, IDC_SRMM_ITALICS), + m_btnUnderline(this, IDC_SRMM_UNDERLINE), + m_si(si), m_pLog(nullptr), m_pEntry(nullptr), - m_pFilter(nullptr), - m_pColor(nullptr), - m_pBkColor(nullptr), - m_hContact(0) + m_hContact(0), + m_clrInputBG(GetSysColor(COLOR_WINDOW)) { m_bFilterEnabled = db_get_b(0, CHAT_MODULE, "FilterEnabled", 0) != 0; m_bNicklistEnabled = db_get_b(0, CHAT_MODULE, "ShowNicklist", 1) != 0; m_iLogFilterFlags = db_get_dw(0, CHAT_MODULE, "FilterFlags", 0x03E0); + m_btnColor.OnClick = Callback(this, &CSrmmBaseDialog::onClick_Color); + m_btnBkColor.OnClick = Callback(this, &CSrmmBaseDialog::onClick_BkColor); + m_btnBold.OnClick = m_btnItalic.OnClick = m_btnUnderline.OnClick = Callback(this, &CSrmmBaseDialog::onClick_BIU); + if (si) { m_hContact = si->hContact; @@ -58,6 +67,18 @@ CSrmmBaseDialog::CSrmmBaseDialog(HINSTANCE hInst, int idDialog, SESSION_INFO *si } } +CSrmmBaseDialog::CSrmmBaseDialog(const CSrmmBaseDialog&) : + CDlgBase(0, 0), + m_btnColor(0, 0), m_btnBkColor(0, 0), m_btnFilter(0, 0), + m_btnBold(0, 0), m_btnItalic(0, 0), m_btnUnderline(0, 0) +{ +} + +CSrmmBaseDialog& CSrmmBaseDialog::operator=(const CSrmmBaseDialog&) +{ + return *this; +} + INT_PTR CSrmmBaseDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { @@ -180,3 +201,70 @@ void CSrmmBaseDialog::RedrawLog2() if (m_si->pLog) StreamInEvents(m_si->pLogEnd, TRUE); } + +///////////////////////////////////////////////////////////////////////////////////////// + +void CSrmmBaseDialog::onClick_Color(CCtrlButton *pButton) +{ + if (!pButton->Enabled()) + return; + + CHARFORMAT2 cf; + cf.cbSize = sizeof(CHARFORMAT2); + cf.dwEffects = 0; + cf.dwMask = CFM_COLOR; + + if (IsDlgButtonChecked(m_hwnd, pButton->GetCtrlId())) { + if (db_get_b(0, CHAT_MODULE, "RightClickFilter", 0) == 0) { + ShowColorChooser(pButton->GetCtrlId()); + return; + } + if (m_bFGSet) + cf.crTextColor = chatApi.MM_FindModule(m_si->pszModule)->crColors[m_iFG]; + } + else cf.crTextColor = m_clrInputFG; + + m_pEntry->SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); +} + +void CSrmmBaseDialog::onClick_BkColor(CCtrlButton *pButton) +{ + if (!pButton->Enabled()) + return; + + CHARFORMAT2 cf; + cf.cbSize = sizeof(CHARFORMAT2); + cf.dwEffects = 0; + cf.dwMask = CFM_BACKCOLOR; + + if (IsDlgButtonChecked(m_hwnd, pButton->GetCtrlId())) { + if (!db_get_b(0, CHAT_MODULE, "RightClickFilter", 0)) { + ShowColorChooser(pButton->GetCtrlId()); + return; + } + if (m_bBGSet) + cf.crBackColor = chatApi.MM_FindModule(m_si->pszModule)->crColors[m_iBG]; + } + else cf.crBackColor = m_clrInputBG; + + m_pEntry->SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); +} + +void CSrmmBaseDialog::onClick_BIU(CCtrlButton *pButton) +{ + if (!pButton->Enabled()) + return; + + CHARFORMAT2 cf; + cf.cbSize = sizeof(CHARFORMAT2); + cf.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE; + cf.dwEffects = 0; + + if (IsDlgButtonChecked(m_hwnd, IDC_SRMM_BOLD)) + cf.dwEffects |= CFE_BOLD; + if (IsDlgButtonChecked(m_hwnd, IDC_SRMM_ITALICS)) + cf.dwEffects |= CFE_ITALIC; + if (IsDlgButtonChecked(m_hwnd, IDC_SRMM_UNDERLINE)) + cf.dwEffects |= CFE_UNDERLINE; + m_pEntry->SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); +} diff --git a/src/mir_app/src/srmm_util.cpp b/src/mir_app/src/srmm_util.cpp index e9aeffc33c..d1b8be54cd 100644 --- a/src/mir_app/src/srmm_util.cpp +++ b/src/mir_app/src/srmm_util.cpp @@ -82,12 +82,19 @@ EXTERN_C MIR_APP_DLL(LRESULT) CALLBACK Srmm_ButtonSubclassProc(HWND hwnd, UINT m if (pDlg == nullptr) break; - if (hwnd == pDlg->m_pFilter->GetHwnd()) + switch (GetDlgCtrlID(hwnd)) { + case IDC_SRMM_FILTER: pDlg->ShowFilterMenu(); - else if (hwnd == pDlg->m_pColor->GetHwnd()) - pDlg->ShowColorChooser(pDlg->m_pColor->GetCtrlId()); - else if (hwnd == pDlg->m_pBkColor->GetHwnd()) - pDlg->ShowColorChooser(pDlg->m_pBkColor->GetCtrlId()); + break; + + case IDC_SRMM_COLOR: + pDlg->ShowColorChooser(IDC_SRMM_COLOR); + break; + + case IDC_SRMM_BKGCOLOR: + pDlg->ShowColorChooser(IDC_SRMM_BKGCOLOR); + break; + } } break; } |