diff options
author | George Hazan <ghazan@miranda.im> | 2017-03-06 22:14:21 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-03-06 22:14:21 +0300 |
commit | aac6c1622c64cad51f9226ddeba7abfb5addaed3 (patch) | |
tree | 3eff3b3a7445d87d65ec7aa351da52c349bf5cfb | |
parent | 60f8115a8f4f9a771096dd6f669131a18876d1f2 (diff) |
Scriver:
- no more WM_COMMAND handlers in windows procedures;
- full complect of UI buttons;
- merged header files
-rw-r--r-- | plugins/Scriver/src/chat/window.cpp | 655 | ||||
-rw-r--r-- | plugins/Scriver/src/input.cpp | 34 | ||||
-rw-r--r-- | plugins/Scriver/src/msgdialog.cpp | 345 | ||||
-rw-r--r-- | plugins/Scriver/src/msgs.cpp | 41 | ||||
-rw-r--r-- | plugins/Scriver/src/msgs.h | 59 | ||||
-rw-r--r-- | plugins/Scriver/src/resource.h | 17 | ||||
-rw-r--r-- | plugins/Scriver/src/version.h | 2 |
7 files changed, 606 insertions, 547 deletions
diff --git a/plugins/Scriver/src/chat/window.cpp b/plugins/Scriver/src/chat/window.cpp index 6536ecf89b..2949d4151b 100644 --- a/plugins/Scriver/src/chat/window.cpp +++ b/plugins/Scriver/src/chat/window.cpp @@ -29,23 +29,6 @@ struct MESSAGESUBDATA SESSION_INFO *lastSession;
};
-static void InitButtons(HWND hwndDlg, SESSION_INFO *si)
-{
- SendDlgItemMessage(hwndDlg, IDC_CHAT_SHOWNICKLIST, BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetCachedIcon(si->bNicklistEnabled ? "chat_nicklist" : "chat_nicklist2"));
- SendDlgItemMessage(hwndDlg, IDC_CHAT_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetCachedIcon(si->bFilterEnabled ? "chat_filter" : "chat_filter2"));
-
- MODULEINFO *pInfo = pci->MM_FindModule(si->pszModule);
- if (pInfo) {
- EnableWindow(GetDlgItem(hwndDlg, IDC_CHAT_BOLD), pInfo->bBold);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CHAT_ITALICS), pInfo->bItalics);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CHAT_UNDERLINE), pInfo->bUnderline);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CHAT_COLOR), pInfo->bColor);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CHAT_BKGCOLOR), pInfo->bBkgColor);
- if (si->iType == GCW_CHATROOM)
- EnableWindow(GetDlgItem(hwndDlg, IDC_CHAT_CHANMGR), pInfo->bChanMgr);
- }
-}
-
static void TabAutoComplete(HWND hwnd, MESSAGESUBDATA *dat, SESSION_INFO *si)
{
LRESULT lResult = (LRESULT)SendMessage(hwnd, EM_GETSEL, 0, 0);
@@ -211,58 +194,58 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, dat->szSearchResult = NULL;
}
if (wParam == 0x49 && isCtrl && !isAlt) { // ctrl-i (italics)
- CheckDlgButton(GetParent(hwnd), IDC_CHAT_ITALICS, IsDlgButtonChecked(GetParent(hwnd), IDC_CHAT_ITALICS) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_CHAT_ITALICS, 0), 0);
+ CheckDlgButton(GetParent(hwnd), IDC_ITALICS, IsDlgButtonChecked(GetParent(hwnd), IDC_ITALICS) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
+ SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_ITALICS, 0), 0);
return TRUE;
}
if (wParam == 0x42 && isCtrl && !isAlt) { // ctrl-b (bold)
- CheckDlgButton(GetParent(hwnd), IDC_CHAT_BOLD, IsDlgButtonChecked(GetParent(hwnd), IDC_CHAT_BOLD) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_CHAT_BOLD, 0), 0);
+ CheckDlgButton(GetParent(hwnd), IDC_BOLD, IsDlgButtonChecked(GetParent(hwnd), IDC_BOLD) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
+ SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_BOLD, 0), 0);
return TRUE;
}
if (wParam == 0x55 && isCtrl && !isAlt) { // ctrl-u (paste clean text)
- CheckDlgButton(GetParent(hwnd), IDC_CHAT_UNDERLINE, IsDlgButtonChecked(GetParent(hwnd), IDC_CHAT_UNDERLINE) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_CHAT_UNDERLINE, 0), 0);
+ CheckDlgButton(GetParent(hwnd), IDC_UNDERLINE, IsDlgButtonChecked(GetParent(hwnd), IDC_UNDERLINE) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
+ SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_UNDERLINE, 0), 0);
return TRUE;
}
if (wParam == 0x4b && isCtrl && !isAlt) { // ctrl-k (paste clean text)
- CheckDlgButton(GetParent(hwnd), IDC_CHAT_COLOR, IsDlgButtonChecked(GetParent(hwnd), IDC_CHAT_COLOR) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_CHAT_COLOR, 0), 0);
+ CheckDlgButton(GetParent(hwnd), IDC_COLOR, IsDlgButtonChecked(GetParent(hwnd), IDC_COLOR) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
+ SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_COLOR, 0), 0);
return TRUE;
}
if (wParam == VK_SPACE && isCtrl && !isAlt) { // ctrl-space (paste clean text)
- CheckDlgButton(GetParent(hwnd), IDC_CHAT_BKGCOLOR, BST_UNCHECKED);
- CheckDlgButton(GetParent(hwnd), IDC_CHAT_COLOR, BST_UNCHECKED);
- CheckDlgButton(GetParent(hwnd), IDC_CHAT_BOLD, BST_UNCHECKED);
- CheckDlgButton(GetParent(hwnd), IDC_CHAT_UNDERLINE, BST_UNCHECKED);
- CheckDlgButton(GetParent(hwnd), IDC_CHAT_ITALICS, BST_UNCHECKED);
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_CHAT_BKGCOLOR, 0), 0);
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_CHAT_COLOR, 0), 0);
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_CHAT_BOLD, 0), 0);
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_CHAT_UNDERLINE, 0), 0);
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_CHAT_ITALICS, 0), 0);
+ CheckDlgButton(GetParent(hwnd), IDC_BKGCOLOR, BST_UNCHECKED);
+ CheckDlgButton(GetParent(hwnd), IDC_COLOR, BST_UNCHECKED);
+ CheckDlgButton(GetParent(hwnd), IDC_BOLD, BST_UNCHECKED);
+ CheckDlgButton(GetParent(hwnd), IDC_UNDERLINE, BST_UNCHECKED);
+ CheckDlgButton(GetParent(hwnd), IDC_ITALICS, BST_UNCHECKED);
+ SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_BKGCOLOR, 0), 0);
+ SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_COLOR, 0), 0);
+ SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_BOLD, 0), 0);
+ SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_UNDERLINE, 0), 0);
+ SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_ITALICS, 0), 0);
return TRUE;
}
if (wParam == 0x4c && isCtrl && !isAlt) { // ctrl-l (paste clean text)
- CheckDlgButton(GetParent(hwnd), IDC_CHAT_BKGCOLOR, IsDlgButtonChecked(GetParent(hwnd), IDC_CHAT_BKGCOLOR) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_CHAT_BKGCOLOR, 0), 0);
+ CheckDlgButton(GetParent(hwnd), IDC_BKGCOLOR, IsDlgButtonChecked(GetParent(hwnd), IDC_BKGCOLOR) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
+ SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_BKGCOLOR, 0), 0);
return TRUE;
}
if (wParam == 0x46 && isCtrl && !isAlt) { // ctrl-f (paste clean text)
- if (IsWindowEnabled(GetDlgItem(GetParent(hwnd), IDC_CHAT_FILTER)))
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_CHAT_FILTER, 0), 0);
+ if (IsWindowEnabled(GetDlgItem(GetParent(hwnd), IDC_FILTER)))
+ SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_FILTER, 0), 0);
return TRUE;
}
if (wParam == 0x4e && isCtrl && !isAlt) { // ctrl-n (nicklist)
- if (IsWindowEnabled(GetDlgItem(GetParent(hwnd), IDC_CHAT_SHOWNICKLIST)))
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_CHAT_SHOWNICKLIST, 0), 0);
+ if (IsWindowEnabled(GetDlgItem(GetParent(hwnd), IDC_SHOWNICKLIST)))
+ SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_SHOWNICKLIST, 0), 0);
return TRUE;
}
@@ -272,8 +255,8 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, }
if (wParam == 0x4f && isCtrl && !isAlt) { // ctrl-o (options)
- if (IsWindowEnabled(GetDlgItem(GetParent(hwnd), IDC_CHAT_CHANMGR)))
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_CHAT_CHANMGR, 0), 0);
+ if (IsWindowEnabled(GetDlgItem(GetParent(hwnd), IDC_CHANMGR)))
+ SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_CHANMGR, 0), 0);
return TRUE;
}
@@ -307,6 +290,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, UINT u = 0;
UINT u2 = 0;
COLORREF cr;
+ SESSION_INFO *si = pDlg->m_si;
LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, NULL, &cr);
@@ -315,64 +299,64 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, cf.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_BACKCOLOR | CFM_COLOR;
SendMessage(hwnd, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
- if (pci->MM_FindModule(pDlg->m_si->pszModule) && pci->MM_FindModule(pDlg->m_si->pszModule)->bColor) {
- int index = pci->GetColorIndex(pDlg->m_si->pszModule, cf.crTextColor);
- u = IsDlgButtonChecked(GetParent(hwnd), IDC_CHAT_COLOR);
+ 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_COLOR);
if (index >= 0) {
- pDlg->m_si->bFGSet = TRUE;
- pDlg->m_si->iFG = index;
+ si->bFGSet = TRUE;
+ si->iFG = index;
}
if (u == BST_UNCHECKED && cf.crTextColor != cr)
- CheckDlgButton(GetParent(hwnd), IDC_CHAT_COLOR, BST_CHECKED);
+ CheckDlgButton(GetParent(hwnd), IDC_COLOR, BST_CHECKED);
else if (u == BST_CHECKED && cf.crTextColor == cr)
- CheckDlgButton(GetParent(hwnd), IDC_CHAT_COLOR, BST_UNCHECKED);
+ CheckDlgButton(GetParent(hwnd), IDC_COLOR, BST_UNCHECKED);
}
- if (pci->MM_FindModule(pDlg->m_si->pszModule) && pci->MM_FindModule(pDlg->m_si->pszModule)->bBkgColor) {
- int index = pci->GetColorIndex(pDlg->m_si->pszModule, cf.crBackColor);
+ 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(NULL, SRMMMOD, SRMSGSET_INPUTBKGCOLOUR, SRMSGDEFSET_INPUTBKGCOLOUR);
- u = IsDlgButtonChecked(GetParent(hwnd), IDC_CHAT_BKGCOLOR);
+ u = IsDlgButtonChecked(GetParent(hwnd), IDC_BKGCOLOR);
if (index >= 0) {
- pDlg->m_si->bBGSet = TRUE;
- pDlg->m_si->iBG = index;
+ si->bBGSet = TRUE;
+ si->iBG = index;
}
if (u == BST_UNCHECKED && cf.crBackColor != crB)
- CheckDlgButton(GetParent(hwnd), IDC_CHAT_BKGCOLOR, BST_CHECKED);
+ CheckDlgButton(GetParent(hwnd), IDC_BKGCOLOR, BST_CHECKED);
else if (u == BST_CHECKED && cf.crBackColor == crB)
- CheckDlgButton(GetParent(hwnd), IDC_CHAT_BKGCOLOR, BST_UNCHECKED);
+ CheckDlgButton(GetParent(hwnd), IDC_BKGCOLOR, BST_UNCHECKED);
}
- if (pci->MM_FindModule(pDlg->m_si->pszModule) && pci->MM_FindModule(pDlg->m_si->pszModule)->bBold) {
- u = IsDlgButtonChecked(GetParent(hwnd), IDC_CHAT_BOLD);
+ if (pci->MM_FindModule(si->pszModule) && pci->MM_FindModule(si->pszModule)->bBold) {
+ u = IsDlgButtonChecked(GetParent(hwnd), IDC_BOLD);
u2 = cf.dwEffects;
u2 &= CFE_BOLD;
if (u == BST_UNCHECKED && u2)
- CheckDlgButton(GetParent(hwnd), IDC_CHAT_BOLD, BST_CHECKED);
+ CheckDlgButton(GetParent(hwnd), IDC_BOLD, BST_CHECKED);
else if (u == BST_CHECKED && u2 == 0)
- CheckDlgButton(GetParent(hwnd), IDC_CHAT_BOLD, BST_UNCHECKED);
+ CheckDlgButton(GetParent(hwnd), IDC_BOLD, BST_UNCHECKED);
}
- if (pci->MM_FindModule(pDlg->m_si->pszModule) && pci->MM_FindModule(pDlg->m_si->pszModule)->bItalics) {
- u = IsDlgButtonChecked(GetParent(hwnd), IDC_CHAT_ITALICS);
+ if (pci->MM_FindModule(si->pszModule) && pci->MM_FindModule(si->pszModule)->bItalics) {
+ u = IsDlgButtonChecked(GetParent(hwnd), IDC_ITALICS);
u2 = cf.dwEffects;
u2 &= CFE_ITALIC;
if (u == BST_UNCHECKED && u2)
- CheckDlgButton(GetParent(hwnd), IDC_CHAT_ITALICS, BST_CHECKED);
+ CheckDlgButton(GetParent(hwnd), IDC_ITALICS, BST_CHECKED);
else if (u == BST_CHECKED && u2 == 0)
- CheckDlgButton(GetParent(hwnd), IDC_CHAT_ITALICS, BST_UNCHECKED);
+ CheckDlgButton(GetParent(hwnd), IDC_ITALICS, BST_UNCHECKED);
}
- if (pci->MM_FindModule(pDlg->m_si->pszModule) && pci->MM_FindModule(pDlg->m_si->pszModule)->bUnderline) {
- u = IsDlgButtonChecked(GetParent(hwnd), IDC_CHAT_UNDERLINE);
+ if (pci->MM_FindModule(si->pszModule) && pci->MM_FindModule(si->pszModule)->bUnderline) {
+ u = IsDlgButtonChecked(GetParent(hwnd), IDC_UNDERLINE);
u2 = cf.dwEffects;
u2 &= CFE_UNDERLINE;
if (u == BST_UNCHECKED && u2)
- CheckDlgButton(GetParent(hwnd), IDC_CHAT_UNDERLINE, BST_CHECKED);
+ CheckDlgButton(GetParent(hwnd), IDC_UNDERLINE, BST_CHECKED);
else if (u == BST_CHECKED && u2 == 0)
- CheckDlgButton(GetParent(hwnd), IDC_CHAT_UNDERLINE, BST_UNCHECKED);
+ CheckDlgButton(GetParent(hwnd), IDC_UNDERLINE, BST_UNCHECKED);
}
}
break;
@@ -462,12 +446,12 @@ static LRESULT CALLBACK ButtonSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, L switch (msg) {
case WM_RBUTTONUP:
if (db_get_b(NULL, CHAT_MODULE, "RightClickFilter", 0) != 0) {
- if (GetDlgItem(GetParent(hwnd), IDC_CHAT_FILTER) == hwnd)
+ if (GetDlgItem(GetParent(hwnd), IDC_FILTER) == hwnd)
SendMessage(GetParent(hwnd), GC_SHOWFILTERMENU, 0, 0);
- if (GetDlgItem(GetParent(hwnd), IDC_CHAT_COLOR) == hwnd)
- SendMessage(GetParent(hwnd), GC_SHOWCOLORCHOOSER, 0, IDC_CHAT_COLOR);
- if (GetDlgItem(GetParent(hwnd), IDC_CHAT_BKGCOLOR) == hwnd)
- SendMessage(GetParent(hwnd), GC_SHOWCOLORCHOOSER, 0, IDC_CHAT_BKGCOLOR);
+ if (GetDlgItem(GetParent(hwnd), IDC_COLOR) == hwnd)
+ SendMessage(GetParent(hwnd), GC_SHOWCOLORCHOOSER, 0, IDC_COLOR);
+ if (GetDlgItem(GetParent(hwnd), IDC_BKGCOLOR) == hwnd)
+ SendMessage(GetParent(hwnd), GC_SHOWCOLORCHOOSER, 0, IDC_BKGCOLOR);
}
break;
}
@@ -540,9 +524,10 @@ static LRESULT CALLBACK LogSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR ptrW pszWord(GetRichTextWord(hwnd, &ptl));
inMenu = TRUE;
+ SESSION_INFO *si = pDlg->m_si;
CHARRANGE all = { 0, -1 };
HMENU hMenu = NULL;
- UINT uID = CreateGCMenu(hwnd, &hMenu, 1, pt, pDlg->m_si, NULL, pszWord);
+ UINT uID = CreateGCMenu(hwnd, &hMenu, 1, pt, si, NULL, pszWord);
inMenu = FALSE;
switch (uID) {
case 0:
@@ -558,11 +543,11 @@ static LRESULT CALLBACK LogSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR break;
case IDM_CLEAR:
- if (pDlg->m_si) {
+ if (si) {
SetWindowText(hwnd, L"");
- pci->LM_RemoveAll(&pDlg->m_si->pLog, &pDlg->m_si->pLogEnd);
- pDlg->m_si->iEventCount = 0;
- pDlg->m_si->LastTime = 0;
+ pci->LM_RemoveAll(&si->pLog, &si->pLogEnd);
+ si->iEventCount = 0;
+ si->LastTime = 0;
PostMessage(GetParent(hwnd), WM_MOUSEACTIVATE, 0, 0);
}
break;
@@ -581,7 +566,7 @@ static LRESULT CALLBACK LogSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR default:
PostMessage(GetParent(hwnd), WM_MOUSEACTIVATE, 0, 0);
- pci->DoEventHookAsync(GetParent(hwnd), pDlg->m_si->ptszID, pDlg->m_si->pszModule, GC_USER_LOGMENU, NULL, NULL, uID);
+ pci->DoEventHookAsync(GetParent(hwnd), si->ptszID, si->pszModule, GC_USER_LOGMENU, NULL, NULL, uID);
break;
}
DestroyGCMenu(&hMenu, 5);
@@ -834,15 +819,15 @@ void CChatRoomDlg::MessageDialogResize(int w, int h) ShowWindow(m_nickList.GetHwnd(), SW_HIDE);
if (m_si->iType == GCW_SERVER) {
- EnableWindow(GetDlgItem(m_hwnd, IDC_CHAT_SHOWNICKLIST), FALSE);
- EnableWindow(GetDlgItem(m_hwnd, IDC_CHAT_FILTER), FALSE);
- EnableWindow(GetDlgItem(m_hwnd, IDC_CHAT_CHANMGR), FALSE);
+ m_btnShowList.Enable(false);
+ m_btnFilter.Enable(false);
+ m_btnChanMgr.Enable(false);
}
else {
- EnableWindow(GetDlgItem(m_hwnd, IDC_CHAT_SHOWNICKLIST), TRUE);
- EnableWindow(GetDlgItem(m_hwnd, IDC_CHAT_FILTER), TRUE);
+ m_btnShowList.Enable(true);
+ m_btnFilter.Enable(true);
if (m_si->iType == GCW_CHATROOM)
- EnableWindow(GetDlgItem(m_hwnd, IDC_CHAT_CHANMGR), pci->MM_FindModule(m_si->pszModule)->bChanMgr);
+ m_btnChanMgr.Enable(pci->MM_FindModule(m_si->pszModule)->bChanMgr);
}
HDWP hdwp = BeginDeferWindowPos(5);
@@ -879,17 +864,45 @@ void CChatRoomDlg::MessageDialogResize(int w, int h) CChatRoomDlg::CChatRoomDlg(SESSION_INFO *si)
: CScriverWindow(IDD_CHANNEL),
m_si(si),
+
m_log(this, IDC_LOG),
m_message(this, IDC_MESSAGE),
m_nickList(this, IDC_CHAT_LIST),
+
m_splitterX(this, IDC_SPLITTERX),
- m_splitterY(this, IDC_SPLITTERY)
+ m_splitterY(this, IDC_SPLITTERY),
+
+ m_btnOk(this, IDOK),
+ m_btnBold(this, IDC_BOLD),
+ m_btnColor(this, IDC_COLOR),
+ m_btnFilter(this, IDC_FILTER),
+ m_btnItalic(this, IDC_ITALICS),
+ m_btnHistory(this, IDC_HISTORY),
+ m_btnChanMgr(this, IDC_CHANMGR),
+ m_btnBkColor(this, IDC_BKGCOLOR),
+ m_btnShowList(this, IDC_SHOWNICKLIST),
+ m_btnUnderline(this, IDC_UNDERLINE)
{
m_pLog = &m_log;
m_pEntry = &m_message;
- m_autoClose = 0;
m_hContact = si->hContact;
+ m_btnOk.OnClick = Callback(this, &CChatRoomDlg::onClick_Ok);
+ m_btnFilter.OnClick = Callback(this, &CChatRoomDlg::onClick_Filter);
+ m_btnHistory.OnClick = Callback(this, &CChatRoomDlg::onClick_History);
+ m_btnChanMgr.OnClick = Callback(this, &CChatRoomDlg::onClick_ChanMgr);
+ m_btnShowList.OnClick = Callback(this, &CChatRoomDlg::onClick_ShowList);
+
+ m_btnBold.OnClick = Callback(this, &CChatRoomDlg::onClick_BIU);
+ m_btnItalic.OnClick = Callback(this, &CChatRoomDlg::onClick_BIU);
+ m_btnUnderline.OnClick = Callback(this, &CChatRoomDlg::onClick_BIU);
+
+ m_btnColor.OnClick = Callback(this, &CChatRoomDlg::onClick_Color);
+ m_btnBkColor.OnClick = Callback(this, &CChatRoomDlg::onClick_BkColor);
+
+ m_nickList.OnDblClick = Callback(this, &CChatRoomDlg::onDblClick_List);
+
+ m_message.OnChange = Callback(this, &CChatRoomDlg::onChange_Message);
m_splitterX.OnChange = Callback(this, &CChatRoomDlg::OnSplitterX);
m_splitterY.OnChange = Callback(this, &CChatRoomDlg::OnSplitterY);
}
@@ -906,9 +919,9 @@ void CChatRoomDlg::OnInitDialog() mir_subclassWindow(m_nickList.GetHwnd(), NicklistSubclassProc);
mir_subclassWindow(m_log.GetHwnd(), LogSubclassProc);
- mir_subclassWindow(GetDlgItem(m_hwnd, IDC_CHAT_FILTER), ButtonSubclassProc);
- mir_subclassWindow(GetDlgItem(m_hwnd, IDC_CHAT_COLOR), ButtonSubclassProc);
- mir_subclassWindow(GetDlgItem(m_hwnd, IDC_CHAT_BKGCOLOR), ButtonSubclassProc);
+ mir_subclassWindow(m_btnFilter.GetHwnd(), ButtonSubclassProc);
+ mir_subclassWindow(m_btnColor.GetHwnd(), ButtonSubclassProc);
+ mir_subclassWindow(m_btnBkColor.GetHwnd(), ButtonSubclassProc);
mir_subclassWindow(m_message.GetHwnd(), MessageSubclassProc);
Srmm_CreateToolbarIcons(m_hwnd, BBBF_ISCHATBUTTON);
@@ -998,6 +1011,207 @@ void CChatRoomDlg::OnSplitterY(CSplitter *pSplitter) g_Settings.iSplitterY = m_si->iSplitterY;
}
+void CChatRoomDlg::onDblClick_List(CCtrlListBox*)
+{
+ TVHITTESTINFO hti;
+ hti.pt.x = (short)LOWORD(GetMessagePos());
+ hti.pt.y = (short)HIWORD(GetMessagePos());
+ ScreenToClient(m_nickList.GetHwnd(), &hti.pt);
+
+ int item = LOWORD(m_nickList.SendMsg(LB_ITEMFROMPOINT, 0, MAKELPARAM(hti.pt.x, hti.pt.y)));
+ USERINFO *ui = pci->SM_GetUserFromIndex(m_si->ptszID, m_si->pszModule, item);
+ if (ui) {
+ if (GetKeyState(VK_SHIFT) & 0x8000) {
+ LRESULT lResult = (LRESULT)m_message.SendMsg(EM_GETSEL, 0, 0);
+ int start = LOWORD(lResult);
+ size_t dwNameLenMax = (mir_wstrlen(ui->pszUID) + 4);
+ wchar_t* pszName = (wchar_t*)alloca(sizeof(wchar_t) * dwNameLenMax);
+ if (start == 0)
+ mir_snwprintf(pszName, dwNameLenMax, L"%s: ", ui->pszUID);
+ else
+ mir_snwprintf(pszName, dwNameLenMax, L"%s ", ui->pszUID);
+
+ m_message.SendMsg(EM_REPLACESEL, FALSE, (LPARAM)pszName);
+ PostMessage(m_hwnd, WM_MOUSEACTIVATE, 0, 0);
+ }
+ else pci->DoEventHookAsync(m_hwnd, m_si->ptszID, m_si->pszModule, GC_USER_PRIVMESS, ui, nullptr, 0);
+ }
+}
+
+void CChatRoomDlg::onClick_Ok(CCtrlButton *pButton)
+{
+ if (!pButton->Enabled())
+ return;
+
+ char *pszRtf = GetRichTextRTF(m_message.GetHwnd());
+ if (pszRtf == NULL)
+ return;
+
+ MODULEINFO *mi = pci->MM_FindModule(m_si->pszModule);
+ if (mi == NULL)
+ return;
+
+ TCmdList *cmdListNew = tcmdlist_last(cmdList);
+ while (cmdListNew != NULL && cmdListNew->temporary) {
+ cmdList = tcmdlist_remove(cmdList, cmdListNew);
+ cmdListNew = tcmdlist_last(cmdList);
+ }
+
+ // takes pszRtf to a queue, no leak here
+ cmdList = tcmdlist_append(cmdList, pszRtf, 20, FALSE);
+
+ CMStringW ptszText(ptrW(mir_utf8decodeW(pszRtf)));
+ pci->DoRtfToTags(ptszText, mi->nColorCount, mi->crColors);
+ ptszText.Trim();
+ ptszText.Replace(L"%", L"%%");
+
+ if (mi->bAckMsg) {
+ EnableWindow(m_message.GetHwnd(), FALSE);
+ m_message.SendMsg(EM_SETREADONLY, TRUE, 0);
+ }
+ else SetDlgItemText(m_hwnd, IDC_MESSAGE, L"");
+
+ EnableWindow(m_btnOk.GetHwnd(), FALSE);
+
+ pci->DoEventHookAsync(m_hwnd, m_si->ptszID, m_si->pszModule, GC_USER_MESSAGE, NULL, ptszText, 0);
+ SetFocus(m_message.GetHwnd());
+}
+
+void CChatRoomDlg::onClick_History(CCtrlButton *pButton)
+{
+ if (!pButton->Enabled())
+ return;
+
+ MODULEINFO *pInfo = pci->MM_FindModule(m_si->pszModule);
+ if (pInfo)
+ ShellExecute(m_hwnd, NULL, pci->GetChatLogsFilename(m_si, 0), NULL, NULL, SW_SHOW);
+}
+
+void CChatRoomDlg::onClick_ChanMgr(CCtrlButton *pButton)
+{
+ if (pButton->Enabled())
+ pci->DoEventHookAsync(m_hwnd, m_si->ptszID, m_si->pszModule, GC_USER_CHANMGR, NULL, NULL, 0);
+}
+
+void CChatRoomDlg::onClick_ShowList(CCtrlButton *pButton)
+{
+ if (!pButton->Enabled() || m_si->iType == GCW_SERVER)
+ return;
+
+ m_si->bNicklistEnabled = !m_si->bNicklistEnabled;
+ pButton->SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetCachedIcon(m_si->bNicklistEnabled ? "chat_nicklist" : "chat_nicklist2"));
+ SendMessage(m_hwnd, GC_SCROLLTOBOTTOM, 0, 0);
+ SendMessage(m_hwnd, WM_SIZE, 0, 0);
+}
+
+void CChatRoomDlg::onClick_Filter(CCtrlButton *pButton)
+{
+ if (!pButton->Enabled())
+ return;
+
+ m_si->bFilterEnabled = !m_si->bFilterEnabled;
+ pButton->SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetCachedIcon(m_si->bFilterEnabled ? "chat_filter" : "chat_filter2"));
+ if (m_si->bFilterEnabled && db_get_b(NULL, CHAT_MODULE, "RightClickFilter", 0) == 0)
+ SendMessage(m_hwnd, GC_SHOWFILTERMENU, 0, 0);
+ else
+ SendMessage(m_hwnd, GC_REDRAWLOG, 0, 0);
+}
+
+void CChatRoomDlg::onClick_BIU(CCtrlButton *pButton)
+{
+ if (!pButton->Enabled())
+ return;
+
+ MODULEINFO *pInfo = pci->MM_FindModule(m_si->pszModule);
+ CHARFORMAT2 cf;
+ cf.cbSize = sizeof(CHARFORMAT2);
+ cf.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE;
+ cf.dwEffects = 0;
+
+ if (IsDlgButtonChecked(m_hwnd, IDC_BOLD))
+ cf.dwEffects |= CFE_BOLD;
+ if (IsDlgButtonChecked(m_hwnd, IDC_ITALICS))
+ cf.dwEffects |= CFE_ITALIC;
+ if (IsDlgButtonChecked(m_hwnd, IDC_UNDERLINE))
+ cf.dwEffects |= CFE_UNDERLINE;
+ if (pInfo->bSingleFormat)
+ m_message.SendMsg(EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
+ else
+ m_message.SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
+}
+
+void CChatRoomDlg::onClick_Color(CCtrlButton *pButton)
+{
+ if (!pButton->Enabled())
+ return;
+
+ MODULEINFO *pInfo = pci->MM_FindModule(m_si->pszModule);
+ CHARFORMAT2 cf;
+ cf.cbSize = sizeof(CHARFORMAT2);
+ cf.dwEffects = 0;
+
+ if (IsDlgButtonChecked(m_hwnd, IDC_COLOR)) {
+ if (db_get_b(NULL, CHAT_MODULE, "RightClickFilter", 0) == 0)
+ SendMessage(m_hwnd, GC_SHOWCOLORCHOOSER, 0, IDC_COLOR);
+ else if (m_si->bFGSet) {
+ cf.dwMask = CFM_COLOR;
+ cf.crTextColor = pInfo->crColors[m_si->iFG];
+ if (pInfo->bSingleFormat)
+ m_message.SendMsg(EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
+ else
+ m_message.SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
+ }
+ }
+ else {
+ COLORREF cr;
+ LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, NULL, &cr);
+ cf.dwMask = CFM_COLOR;
+ cf.crTextColor = cr;
+ if (pInfo->bSingleFormat)
+ m_message.SendMsg(EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
+ else
+ m_message.SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
+ }
+}
+
+void CChatRoomDlg::onClick_BkColor(CCtrlButton *pButton)
+{
+ if (!pButton->Enabled())
+ return;
+
+ MODULEINFO *pInfo = pci->MM_FindModule(m_si->pszModule);
+ CHARFORMAT2 cf;
+ cf.cbSize = sizeof(CHARFORMAT2);
+ cf.dwEffects = 0;
+
+ if (IsDlgButtonChecked(m_hwnd, IDC_BKGCOLOR)) {
+ if (db_get_b(NULL, CHAT_MODULE, "RightClickFilter", 0) == 0)
+ SendMessage(m_hwnd, GC_SHOWCOLORCHOOSER, 0, IDC_BKGCOLOR);
+ else if (m_si->bBGSet) {
+ cf.dwMask = CFM_BACKCOLOR;
+ cf.crBackColor = pInfo->crColors[m_si->iBG];
+ if (pInfo->bSingleFormat)
+ m_message.SendMsg(EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
+ else
+ m_message.SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
+ }
+ }
+ else {
+ cf.dwMask = CFM_BACKCOLOR;
+ cf.crBackColor = (COLORREF)db_get_dw(NULL, SRMMMOD, SRMSGSET_INPUTBKGCOLOUR, SRMSGDEFSET_INPUTBKGCOLOUR);
+ if (pInfo->bSingleFormat)
+ m_message.SendMsg(EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
+ else
+ m_message.SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
+ }
+}
+
+void CChatRoomDlg::onChange_Message(CCtrlEdit *pEdit)
+{
+ cmdListCurrent = NULL;
+ m_btnOk.Enable(GetRichTextLength(pEdit->GetHwnd(), 1200, FALSE) != 0);
+}
+
INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static HMENU hToolbarMenu;
@@ -1010,8 +1224,20 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) switch (uMsg) {
case GC_SETWNDPROPS:
- // LoadGlobalSettings();
- InitButtons(m_hwnd, m_si);
+ m_btnShowList.SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetCachedIcon(m_si->bNicklistEnabled ? "chat_nicklist" : "chat_nicklist2"));
+ m_btnFilter.SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetCachedIcon(m_si->bFilterEnabled ? "chat_filter" : "chat_filter2"));
+ {
+ MODULEINFO *pInfo = pci->MM_FindModule(m_si->pszModule);
+ if (pInfo) {
+ m_btnBold.Enable(pInfo->bBold);
+ m_btnItalic.Enable(pInfo->bItalics);
+ m_btnUnderline.Enable(pInfo->bUnderline);
+ m_btnColor.Enable(pInfo->bColor);
+ m_btnBkColor.Enable(pInfo->bBkgColor);
+ if (m_si->iType == GCW_CHATROOM)
+ m_btnChanMgr.Enable(pInfo->bChanMgr);
+ }
+ }
SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0);
SendMessage(m_hwnd, DM_UPDATETITLEBAR, 0, 0);
@@ -1185,17 +1411,17 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) case GC_SETMESSAGEHIGHLIGHT:
m_si->wState |= GC_EVENT_HIGHLIGHT;
- SendMessage(m_si->hWnd, GC_FIXTABICONS, 0, 0);
+ SendMessage(m_hwnd, GC_FIXTABICONS, 0, 0);
SendMessage(m_hwnd, DM_UPDATETITLEBAR, 0, 0);
if (g_Settings.bFlashWindowHighlight && GetActiveWindow() != m_hwnd && GetForegroundWindow() != m_hwndParent)
- SendMessage(GetParent(m_si->hWnd), CM_STARTFLASHING, 0, 0);
+ SendMessage(m_hwndParent, CM_STARTFLASHING, 0, 0);
break;
case GC_SETTABHIGHLIGHT:
- SendMessage(m_si->hWnd, GC_FIXTABICONS, 0, 0);
+ SendMessage(m_hwnd, GC_FIXTABICONS, 0, 0);
SendMessage(m_hwnd, DM_UPDATETITLEBAR, 0, 0);
if (g_Settings.bFlashWindow && GetActiveWindow() != m_hwndParent && GetForegroundWindow() != m_hwndParent)
- SendMessage(GetParent(m_si->hWnd), CM_STARTFLASHING, 0, 0);
+ SendMessage(m_hwndParent, CM_STARTFLASHING, 0, 0);
break;
case DM_ACTIVATE:
@@ -1314,7 +1540,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) switch (wParam) {
case SESSION_OFFLINE:
SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0);
- SendMessage(m_si->hWnd, GC_UPDATENICKLIST, 0, 0);
+ SendMessage(m_hwnd, GC_UPDATENICKLIST, 0, 0);
return TRUE;
case SESSION_ONLINE:
@@ -1388,13 +1614,13 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) {
HWND hwnd = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_FILTER), m_hwnd, FilterWndProc, (LPARAM)m_si);
TranslateDialogDefault(hwnd);
- GetWindowRect(GetDlgItem(m_hwnd, IDC_CHAT_FILTER), &rc);
- SetWindowPos(hwnd, HWND_TOP, rc.left - 85, (IsWindowVisible(GetDlgItem(m_hwnd, IDC_CHAT_FILTER)) || IsWindowVisible(GetDlgItem(m_hwnd, IDC_CHAT_BOLD))) ? rc.top - 206 : rc.top - 186, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
+ GetWindowRect(m_btnFilter.GetHwnd(), &rc);
+ SetWindowPos(hwnd, HWND_TOP, rc.left - 85, (IsWindowVisible(m_btnFilter.GetHwnd()) || IsWindowVisible(m_btnBold.GetHwnd())) ? rc.top - 206 : rc.top - 186, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
}
break;
case GC_SHOWCOLORCHOOSER:
- pci->ColorChooser(m_si, lParam == IDC_CHAT_COLOR, m_hwnd, m_message.GetHwnd(), GetDlgItem(m_hwnd, lParam));
+ pci->ColorChooser(m_si, lParam == IDC_COLOR, m_hwnd, m_message.GetHwnd(), GetDlgItem(m_hwnd, lParam));
break;
case GC_SCROLLTOBOTTOM:
@@ -1467,231 +1693,6 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) }
break;
- case WM_COMMAND:
- if (!lParam && Clist_MenuProcessCommand(LOWORD(wParam), MPCF_CONTACTMENU, m_hContact))
- break;
-
- if (HIWORD(wParam) == BN_CLICKED)
- if (LOWORD(wParam) >= MIN_CBUTTONID && LOWORD(wParam) <= MAX_CBUTTONID) {
- Srmm_ClickToolbarIcon(m_hContact, LOWORD(wParam), GetDlgItem(m_hwnd, LOWORD(wParam)), 0);
- break;
- }
-
- switch (LOWORD(wParam)) {
- case IDC_CHAT_LIST:
- if (HIWORD(wParam) == LBN_DBLCLK) {
- TVHITTESTINFO hti;
- hti.pt.x = (short)LOWORD(GetMessagePos());
- hti.pt.y = (short)HIWORD(GetMessagePos());
- ScreenToClient(m_nickList.GetHwnd(), &hti.pt);
-
- int item = LOWORD(m_nickList.SendMsg(LB_ITEMFROMPOINT, 0, MAKELPARAM(hti.pt.x, hti.pt.y)));
- USERINFO *ui = pci->SM_GetUserFromIndex(m_si->ptszID, m_si->pszModule, item);
- if (ui) {
- if (GetKeyState(VK_SHIFT) & 0x8000) {
- LRESULT lResult = (LRESULT)m_message.SendMsg(EM_GETSEL, 0, 0);
- int start = LOWORD(lResult);
- size_t dwNameLenMax = (mir_wstrlen(ui->pszUID) + 4);
- wchar_t* pszName = (wchar_t*)alloca(sizeof(wchar_t) * dwNameLenMax);
- if (start == 0)
- mir_snwprintf(pszName, dwNameLenMax, L"%s: ", ui->pszUID);
- else
- mir_snwprintf(pszName, dwNameLenMax, L"%s ", ui->pszUID);
-
- m_message.SendMsg(EM_REPLACESEL, FALSE, (LPARAM)pszName);
- PostMessage(m_hwnd, WM_MOUSEACTIVATE, 0, 0);
- }
- else pci->DoEventHookAsync(m_hwnd, m_si->ptszID, m_si->pszModule, GC_USER_PRIVMESS, ui, nullptr, 0);
- }
-
- return TRUE;
- }
-
- if (HIWORD(wParam) == LBN_KILLFOCUS)
- RedrawWindow(m_nickList.GetHwnd(), NULL, NULL, RDW_INVALIDATE);
- break;
-
- case IDOK:
- if (IsWindowEnabled(GetDlgItem(m_hwnd, IDOK))) {
- char *pszRtf = GetRichTextRTF(m_message.GetHwnd());
- if (pszRtf == NULL)
- break;
-
- MODULEINFO *mi = pci->MM_FindModule(m_si->pszModule);
- if (mi == NULL)
- break;
-
- TCmdList *cmdListNew = tcmdlist_last(cmdList);
- while (cmdListNew != NULL && cmdListNew->temporary) {
- cmdList = tcmdlist_remove(cmdList, cmdListNew);
- cmdListNew = tcmdlist_last(cmdList);
- }
-
- // takes pszRtf to a queue, no leak here
- cmdList = tcmdlist_append(cmdList, pszRtf, 20, FALSE);
-
- CMStringW ptszText(ptrW(mir_utf8decodeW(pszRtf)));
- pci->DoRtfToTags(ptszText, mi->nColorCount, mi->crColors);
- ptszText.Trim();
- ptszText.Replace(L"%", L"%%");
-
- if (mi->bAckMsg) {
- EnableWindow(m_message.GetHwnd(), FALSE);
- m_message.SendMsg(EM_SETREADONLY, TRUE, 0);
- }
- else SetDlgItemText(m_hwnd, IDC_MESSAGE, L"");
-
- EnableWindow(GetDlgItem(m_hwnd, IDOK), FALSE);
-
- pci->DoEventHookAsync(m_hwnd, m_si->ptszID, m_si->pszModule, GC_USER_MESSAGE, NULL, ptszText, 0);
- SetFocus(m_message.GetHwnd());
- }
- break;
-
- case IDC_CHAT_SHOWNICKLIST:
- if (!IsWindowEnabled(GetDlgItem(m_hwnd, IDC_CHAT_SHOWNICKLIST)))
- break;
- if (m_si->iType == GCW_SERVER)
- break;
-
- m_si->bNicklistEnabled = !m_si->bNicklistEnabled;
-
- SendDlgItemMessage(m_hwnd, IDC_CHAT_SHOWNICKLIST, BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetCachedIcon(m_si->bNicklistEnabled ? "chat_nicklist" : "chat_nicklist2"));
- SendMessage(m_hwnd, GC_SCROLLTOBOTTOM, 0, 0);
- SendMessage(m_hwnd, WM_SIZE, 0, 0);
- break;
-
- case IDC_MESSAGE:
- if (HIWORD(wParam) == EN_CHANGE) {
- cmdListCurrent = NULL;
- EnableWindow(GetDlgItem(m_hwnd, IDOK), GetRichTextLength(m_message.GetHwnd(), 1200, FALSE) != 0);
- }
- break;
-
- case IDC_HISTORY:
- if (IsWindowEnabled(GetDlgItem(m_hwnd, IDC_HISTORY))) {
- MODULEINFO *pInfo = pci->MM_FindModule(m_si->pszModule);
- if (pInfo)
- ShellExecute(m_hwnd, NULL, pci->GetChatLogsFilename(m_si, 0), NULL, NULL, SW_SHOW);
- }
- break;
-
- case IDC_CHAT_CHANMGR:
- if (!IsWindowEnabled(GetDlgItem(m_hwnd, IDC_CHAT_CHANMGR)))
- break;
- pci->DoEventHookAsync(m_hwnd, m_si->ptszID, m_si->pszModule, GC_USER_CHANMGR, NULL, NULL, 0);
- break;
-
- case IDC_CHAT_FILTER:
- if (!IsWindowEnabled(GetDlgItem(m_hwnd, IDC_CHAT_FILTER)))
- break;
-
- m_si->bFilterEnabled = !m_si->bFilterEnabled;
- SendDlgItemMessage(m_hwnd, IDC_CHAT_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetCachedIcon(m_si->bFilterEnabled ? "chat_filter" : "chat_filter2"));
- if (m_si->bFilterEnabled && db_get_b(NULL, CHAT_MODULE, "RightClickFilter", 0) == 0) {
- SendMessage(m_hwnd, GC_SHOWFILTERMENU, 0, 0);
- break;
- }
- SendMessage(m_hwnd, GC_REDRAWLOG, 0, 0);
- break;
-
- case IDC_CHAT_BKGCOLOR:
- if (IsWindowEnabled(GetDlgItem(m_hwnd, IDC_CHAT_BKGCOLOR))) {
- MODULEINFO *pInfo = pci->MM_FindModule(m_si->pszModule);
- cf.cbSize = sizeof(CHARFORMAT2);
- cf.dwEffects = 0;
-
- if (IsDlgButtonChecked(m_hwnd, IDC_CHAT_BKGCOLOR)) {
- if (db_get_b(NULL, CHAT_MODULE, "RightClickFilter", 0) == 0)
- SendMessage(m_hwnd, GC_SHOWCOLORCHOOSER, 0, IDC_CHAT_BKGCOLOR);
- else if (m_si->bBGSet) {
- cf.dwMask = CFM_BACKCOLOR;
- cf.crBackColor = pInfo->crColors[m_si->iBG];
- if (pInfo->bSingleFormat)
- m_message.SendMsg(EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
- else
- m_message.SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
- }
- }
- else {
- cf.dwMask = CFM_BACKCOLOR;
- cf.crBackColor = (COLORREF)db_get_dw(NULL, SRMMMOD, SRMSGSET_INPUTBKGCOLOUR, SRMSGDEFSET_INPUTBKGCOLOUR);
- if (pInfo->bSingleFormat)
- m_message.SendMsg(EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
- else
- m_message.SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
- }
- }
- break;
-
- case IDC_CHAT_COLOR:
- {
- MODULEINFO *pInfo = pci->MM_FindModule(m_si->pszModule);
- cf.cbSize = sizeof(CHARFORMAT2);
- cf.dwEffects = 0;
-
- if (!IsWindowEnabled(GetDlgItem(m_hwnd, IDC_CHAT_COLOR)))
- break;
-
- if (IsDlgButtonChecked(m_hwnd, IDC_CHAT_COLOR)) {
- if (db_get_b(NULL, CHAT_MODULE, "RightClickFilter", 0) == 0)
- SendMessage(m_hwnd, GC_SHOWCOLORCHOOSER, 0, IDC_CHAT_COLOR);
- else if (m_si->bFGSet) {
- cf.dwMask = CFM_COLOR;
- cf.crTextColor = pInfo->crColors[m_si->iFG];
- if (pInfo->bSingleFormat)
- m_message.SendMsg(EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
- else
- m_message.SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
- }
- }
- else {
- COLORREF cr;
- LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, NULL, &cr);
- cf.dwMask = CFM_COLOR;
- cf.crTextColor = cr;
- if (pInfo->bSingleFormat)
- m_message.SendMsg(EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
- else
- m_message.SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
- }
- }
- break;
-
- case IDC_CHAT_BOLD:
- case IDC_CHAT_ITALICS:
- case IDC_CHAT_UNDERLINE:
- {
- MODULEINFO *pInfo = pci->MM_FindModule(m_si->pszModule);
- CHARFORMAT2 cf;
- cf.cbSize = sizeof(CHARFORMAT2);
- cf.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE;
- cf.dwEffects = 0;
-
- if (LOWORD(wParam) == IDC_CHAT_BOLD && !IsWindowEnabled(GetDlgItem(m_hwnd, IDC_CHAT_BOLD)))
- break;
- if (LOWORD(wParam) == IDC_CHAT_ITALICS && !IsWindowEnabled(GetDlgItem(m_hwnd, IDC_CHAT_ITALICS)))
- break;
- if (LOWORD(wParam) == IDC_CHAT_UNDERLINE && !IsWindowEnabled(GetDlgItem(m_hwnd, IDC_CHAT_UNDERLINE)))
- break;
- if (IsDlgButtonChecked(m_hwnd, IDC_CHAT_BOLD))
- cf.dwEffects |= CFE_BOLD;
- if (IsDlgButtonChecked(m_hwnd, IDC_CHAT_ITALICS))
- cf.dwEffects |= CFE_ITALIC;
- if (IsDlgButtonChecked(m_hwnd, IDC_CHAT_UNDERLINE))
- cf.dwEffects |= CFE_UNDERLINE;
- if (pInfo->bSingleFormat)
- m_message.SendMsg(EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
- else
- m_message.SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
- }
- break;
-
- case IDCANCEL:
- PostMessage(m_hwnd, WM_CLOSE, 0, 0);
- }
- break;
-
case WM_KEYDOWN:
SetFocus(m_message.GetHwnd());
break;
@@ -1735,7 +1736,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) Close();
break;
}
- return CSrmmBaseDialog::DlgProc(uMsg, wParam, lParam);
+ return CScriverWindow::DlgProc(uMsg, wParam, lParam);
}
void ShowRoom(SESSION_INFO *si)
diff --git a/plugins/Scriver/src/input.cpp b/plugins/Scriver/src/input.cpp index 9f5881fa6d..2d1c50f39a 100644 --- a/plugins/Scriver/src/input.cpp +++ b/plugins/Scriver/src/input.cpp @@ -130,31 +130,31 @@ int InputAreaShortcuts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, CScriv switch (action) {
case KB_PREV_TAB:
- SendMessage(GetParent(GetParent(hwnd)), CM_ACTIVATEPREV, 0, (LPARAM)GetParent(hwnd));
+ SendMessage(GetParent(windowData->GetHwnd()), CM_ACTIVATEPREV, 0, (LPARAM)windowData->GetHwnd());
return FALSE;
case KB_NEXT_TAB:
- SendMessage(GetParent(GetParent(hwnd)), CM_ACTIVATENEXT, 0, (LPARAM)GetParent(hwnd));
+ SendMessage(GetParent(windowData->GetHwnd()), CM_ACTIVATENEXT, 0, (LPARAM)windowData->GetHwnd());
return FALSE;
case KB_SWITCHSTATUSBAR:
- SendMessage(GetParent(GetParent(hwnd)), DM_SWITCHSTATUSBAR, 0, 0);
+ SendMessage(GetParent(windowData->GetHwnd()), DM_SWITCHSTATUSBAR, 0, 0);
return FALSE;
case KB_SWITCHTITLEBAR:
- SendMessage(GetParent(GetParent(hwnd)), DM_SWITCHTITLEBAR, 0, 0);
+ SendMessage(GetParent(windowData->GetHwnd()), DM_SWITCHTITLEBAR, 0, 0);
return FALSE;
case KB_SWITCHINFOBAR:
- SendMessage(GetParent(GetParent(hwnd)), DM_SWITCHINFOBAR, 0, 0);
+ SendMessage(GetParent(windowData->GetHwnd()), DM_SWITCHINFOBAR, 0, 0);
return FALSE;
case KB_SWITCHTOOLBAR:
- SendMessage(GetParent(GetParent(hwnd)), DM_SWITCHTOOLBAR, 0, 0);
+ SendMessage(GetParent(windowData->GetHwnd()), DM_SWITCHTOOLBAR, 0, 0);
return FALSE;
case KB_MINIMIZE:
- ShowWindow(GetParent(GetParent(hwnd)), SW_MINIMIZE);
+ ShowWindow(GetParent(windowData->GetHwnd()), SW_MINIMIZE);
return FALSE;
case KB_CLOSE:
- SendMessage(GetParent(hwnd), WM_CLOSE, 0, 0);
+ SendMessage(windowData->GetHwnd(), WM_CLOSE, 0, 0);
return FALSE;
case KB_CLEAR_LOG:
- SendMessage(GetParent(hwnd), DM_CLEARLOG, 0, 0);
+ SendMessage(windowData->GetHwnd(), DM_CLEARLOG, 0, 0);
return FALSE;
case KB_TAB1:
case KB_TAB2:
@@ -165,18 +165,18 @@ int InputAreaShortcuts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, CScriv case KB_TAB7:
case KB_TAB8:
case KB_TAB9:
- SendMessage(GetParent(GetParent(hwnd)), CM_ACTIVATEBYINDEX, 0, action - KB_TAB1);
+ SendMessage(GetParent(windowData->GetHwnd()), CM_ACTIVATEBYINDEX, 0, action - KB_TAB1);
return FALSE;
case KB_SEND_ALL:
- PostMessage(GetParent(hwnd), WM_COMMAND, IDC_SENDALL, 0);
+ PostMessage(windowData->GetHwnd(), WM_COMMAND, IDC_SENDALL, 0);
return FALSE;
case KB_QUOTE:
- PostMessage(GetParent(hwnd), WM_COMMAND, IDC_QUOTE, 0);
+ PostMessage(windowData->GetHwnd(), WM_COMMAND, IDC_QUOTE, 0);
return FALSE;
case KB_PASTESEND:
if (SendMessage(hwnd, EM_CANPASTE, 0, 0)) {
SendMessage(hwnd, EM_PASTESPECIAL, CF_UNICODETEXT, 0);
- PostMessage(GetParent(hwnd), WM_COMMAND, IDOK, 0);
+ PostMessage(windowData->GetHwnd(), WM_COMMAND, IDOK, 0);
}
return FALSE;
}
@@ -184,7 +184,7 @@ int InputAreaShortcuts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, CScriv switch (msg) {
case WM_KEYDOWN:
if (wParam >= '1' && wParam <= '9' && isCtrl) {
- SendMessage(GetParent(GetParent(hwnd)), CM_ACTIVATEBYINDEX, 0, wParam - '1');
+ SendMessage(GetParent(windowData->GetHwnd()), CM_ACTIVATEBYINDEX, 0, wParam - '1');
return 0;
}
@@ -195,7 +195,7 @@ int InputAreaShortcuts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, CScriv return FALSE;
if (wParam == 'R' && isCtrl && isShift) { // ctrl-shift-r
- SendMessage(GetParent(hwnd), DM_SWITCHRTL, 0, 0);
+ SendMessage(windowData->GetHwnd(), DM_SWITCHRTL, 0, 0);
return FALSE;
}
@@ -245,11 +245,11 @@ int InputAreaShortcuts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, CScriv case WM_SYSKEYDOWN:
if ((wParam == VK_LEFT) && isAlt) {
- SendMessage(GetParent(GetParent(hwnd)), CM_ACTIVATEPREV, 0, (LPARAM)GetParent(hwnd));
+ SendMessage(GetParent(windowData->GetHwnd()), CM_ACTIVATEPREV, 0, (LPARAM)windowData->GetHwnd());
return 0;
}
if ((wParam == VK_RIGHT) && isAlt) {
- SendMessage(GetParent(GetParent(hwnd)), CM_ACTIVATENEXT, 0, (LPARAM)GetParent(hwnd));
+ SendMessage(GetParent(windowData->GetHwnd()), CM_ACTIVATENEXT, 0, (LPARAM)windowData->GetHwnd());
return 0;
}
break;
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 4e066201e7..c740088dd6 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -623,10 +623,17 @@ static INT_PTR CALLBACK ConfirmSendAllDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa CSrmmWindow::CSrmmWindow(MCONTACT hContact, bool bIncoming, const char *szInitialText, bool bIsUnicode)
: CScriverWindow(IDD_MSG),
+ m_bIncoming(bIncoming),
m_log(this, IDC_LOG),
m_message(this, IDC_MESSAGE),
m_splitter(this, IDC_SPLITTERY),
- m_bIncoming(bIncoming)
+
+ m_btnOk(this, IDOK),
+ m_btnAdd(this, IDC_ADD),
+ m_btnQuote(this, IDC_QUOTE),
+ m_btnDetails(this, IDC_DETAILS),
+ m_btnHistory(this, IDC_HISTORY),
+ m_btnUserMenu(this, IDC_USERMENU)
{
m_pLog = &m_log;
m_pEntry = &m_message;
@@ -635,7 +642,15 @@ CSrmmWindow::CSrmmWindow(MCONTACT hContact, bool bIncoming, const char *szInitia m_hwndParent = GetParentWindow(hContact, FALSE);
m_wszInitialText = (bIsUnicode) ? mir_wstrdup((wchar_t*)szInitialText) : mir_a2u(szInitialText);
- m_splitter.OnChange = Callback(this, &CSrmmWindow::OnSplitterMoved);
+ m_btnOk.OnClick = Callback(this, &CSrmmWindow::onClick_Ok);
+ m_btnAdd.OnClick = Callback(this, &CSrmmWindow::onClick_Add);
+ m_btnQuote.OnClick = Callback(this, &CSrmmWindow::onClick_Quote);
+ m_btnDetails.OnClick = Callback(this, &CSrmmWindow::onClick_Details);
+ m_btnHistory.OnClick = Callback(this, &CSrmmWindow::onClick_History);
+ m_btnUserMenu.OnClick = Callback(this, &CSrmmWindow::onClick_UserMenu);
+
+ m_message.OnChange = Callback(this, &CSrmmWindow::onChange_Message);
+ m_splitter.OnChange = Callback(this, &CSrmmWindow::onChanged_Splitter);
}
void CSrmmWindow::OnInitDialog()
@@ -866,7 +881,7 @@ void CSrmmWindow::OnDestroy() WindowList_Remove(pci->hWindowList, m_hwnd);
HFONT hFont = (HFONT)m_message.SendMsg(WM_GETFONT, 0, 0);
- if (hFont != NULL && hFont != (HFONT)SendDlgItemMessage(m_hwnd, IDOK, WM_GETFONT, 0, 0))
+ if (hFont != NULL && hFont != (HFONT)m_btnOk.SendMsg(WM_GETFONT, 0, 0))
DeleteObject(hFont);
db_set_b(m_hContact, SRMMMOD, "UseRTL", m_bUseRtl);
@@ -885,7 +900,160 @@ void CSrmmWindow::OnDestroy() NotifyLocalWinEvent(m_hContact, m_hwnd, MSG_WINDOW_EVT_CLOSE);
}
-void CSrmmWindow::OnSplitterMoved(CSplitter *pSplitter)
+void CSrmmWindow::onClick_Ok(CCtrlButton *pButton)
+{
+ if (!m_btnOk.Enabled() || m_hContact == NULL)
+ return;
+
+ PARAFORMAT2 pf2;
+ memset(&pf2, 0, sizeof(pf2));
+ pf2.cbSize = sizeof(pf2);
+ pf2.dwMask = PFM_RTLPARA;
+ m_message.SendMsg(EM_GETPARAFORMAT, 0, (LPARAM)&pf2);
+
+ int bufSize = GetRichTextLength(m_message.GetHwnd(), 1200, TRUE) + 2;
+ ptrW ptszUnicode((wchar_t*)mir_alloc(bufSize * sizeof(wchar_t)));
+
+ MessageSendQueueItem msi = { 0 };
+ if (pf2.wEffects & PFE_RTLPARA)
+ msi.flags |= PREF_RTL;
+
+ GETTEXTEX gt = { 0 };
+ gt.flags = GT_USECRLF;
+ gt.cb = bufSize;
+ gt.codepage = 1200; // Unicode
+ m_message.SendMsg(EM_GETTEXTEX, (WPARAM)>, ptszUnicode);
+ if (RTL_Detect(ptszUnicode))
+ msi.flags |= PREF_RTL;
+
+ msi.sendBuffer = mir_utf8encodeW(ptszUnicode);
+ msi.sendBufferSize = (int)mir_strlen(msi.sendBuffer);
+ if (msi.sendBufferSize == 0)
+ return;
+
+ /* Store messaging history */
+ TCmdList *cmdListNew = tcmdlist_last(cmdList);
+ while (cmdListNew != NULL && cmdListNew->temporary) {
+ cmdList = tcmdlist_remove(cmdList, cmdListNew);
+ cmdListNew = tcmdlist_last(cmdList);
+ }
+ if (msi.sendBuffer != NULL)
+ cmdList = tcmdlist_append(cmdList, rtrim(msi.sendBuffer), 20, FALSE);
+
+ cmdListCurrent = NULL;
+
+ if (m_nTypeMode == PROTOTYPE_SELFTYPING_ON)
+ NotifyTyping(PROTOTYPE_SELFTYPING_OFF);
+
+ SetDlgItemText(m_hwnd, IDC_MESSAGE, L"");
+ EnableWindow(GetDlgItem(m_hwnd, IDOK), FALSE);
+ if (db_get_b(NULL, SRMMMOD, SRMSGSET_AUTOMIN, SRMSGDEFSET_AUTOMIN))
+ ShowWindow(m_hwndParent, SW_MINIMIZE);
+
+ if (pButton == nullptr)
+ SendMessage(m_hwndParent, DM_SENDMESSAGE, 0, (LPARAM)&msi);
+ else
+ SendMessage(m_hwnd, DM_SENDMESSAGE, 0, (LPARAM)&msi);
+}
+
+void CSrmmWindow::onClick_UserMenu(CCtrlButton *pButton)
+{
+ if (GetKeyState(VK_SHIFT) & 0x8000) // copy user name
+ SendMessage(m_hwnd, DM_USERNAMETOCLIP, 0, 0);
+ else {
+ RECT rc;
+ HMENU hMenu = Menu_BuildContactMenu(m_hContact);
+ GetWindowRect(pButton->GetHwnd(), &rc);
+ TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, m_hwnd, nullptr);
+ DestroyMenu(hMenu);
+ }
+}
+
+void CSrmmWindow::onClick_Quote(CCtrlButton*)
+{
+ if (m_hDbEventLast == 0)
+ return;
+
+ SETTEXTEX st;
+ st.flags = ST_SELECTION;
+ st.codepage = 1200;
+
+ wchar_t *buffer = NULL;
+ if (m_hwndIeview != NULL) {
+ IEVIEWEVENT evt = { sizeof(evt) };
+ evt.hwnd = m_hwndIeview;
+ evt.hContact = m_hContact;
+ evt.iType = IEE_GET_SELECTION;
+ buffer = mir_wstrdup((wchar_t*)CallService(MS_IEVIEW_EVENT, 0, (LPARAM)&evt));
+ }
+ else buffer = GetRichEditSelection(m_log.GetHwnd());
+
+ if (buffer != NULL) {
+ wchar_t *quotedBuffer = GetQuotedTextW(buffer);
+ m_message.SendMsg(EM_SETTEXTEX, (WPARAM)&st, (LPARAM)quotedBuffer);
+ mir_free(quotedBuffer);
+ mir_free(buffer);
+ }
+ else {
+ DBEVENTINFO dbei = {};
+ dbei.cbBlob = db_event_getBlobSize(m_hDbEventLast);
+ if (dbei.cbBlob == 0xFFFFFFFF)
+ return;
+ dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob);
+ db_event_get(m_hDbEventLast, &dbei);
+ if (DbEventIsMessageOrCustom(&dbei)) {
+ buffer = DbEvent_GetTextW(&dbei, CP_ACP);
+ if (buffer != NULL) {
+ wchar_t *quotedBuffer = GetQuotedTextW(buffer);
+ m_message.SendMsg(EM_SETTEXTEX, (WPARAM)&st, (LPARAM)quotedBuffer);
+ mir_free(quotedBuffer);
+ mir_free(buffer);
+ }
+ }
+ mir_free(dbei.pBlob);
+ }
+ SetFocus(m_message.GetHwnd());
+}
+
+void CSrmmWindow::onClick_Add(CCtrlButton*)
+{
+ ADDCONTACTSTRUCT acs = {};
+ acs.hContact = m_hContact;
+ acs.handleType = HANDLE_CONTACT;
+ CallService(MS_ADDCONTACT_SHOW, (WPARAM)m_hwnd, (LPARAM)&acs);
+
+ if (!db_get_b(m_hContact, "CList", "NotOnList", 0))
+ ShowWindow(GetDlgItem(m_hwnd, IDC_ADD), SW_HIDE);
+}
+
+void CSrmmWindow::onClick_Details(CCtrlButton*)
+{
+ CallService(MS_USERINFO_SHOWDIALOG, m_hContact, 0);
+}
+
+void CSrmmWindow::onClick_History(CCtrlButton*)
+{
+ CallService(MS_HISTORY_SHOWCONTACTHISTORY, m_hContact, 0);
+}
+
+void CSrmmWindow::onChange_Message(CCtrlEdit*)
+{
+ int len = GetRichTextLength(m_message.GetHwnd(), 1200, FALSE);
+ cmdListCurrent = NULL;
+ UpdateReadChars();
+ EnableWindow(GetDlgItem(m_hwnd, IDOK), len != 0);
+ if (!(GetKeyState(VK_CONTROL) & 0x8000) && !(GetKeyState(VK_SHIFT) & 0x8000)) {
+ m_nLastTyping = GetTickCount();
+ if (len != 0) {
+ if (m_nTypeMode == PROTOTYPE_SELFTYPING_OFF)
+ NotifyTyping(PROTOTYPE_SELFTYPING_ON);
+ }
+ else if (m_nTypeMode == PROTOTYPE_SELFTYPING_ON)
+ NotifyTyping(PROTOTYPE_SELFTYPING_OFF);
+ }
+}
+
+void CSrmmWindow::onChanged_Splitter(CSplitter *pSplitter)
{
RECT rc;
GetClientRect(m_hwnd, &rc);
@@ -1502,18 +1670,9 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) return TRUE;
}
}
- return Menu_MeasureItem(lParam);
+ return Menu_DrawItem(lParam);
case WM_COMMAND:
- if (!lParam && Clist_MenuProcessCommand(LOWORD(wParam), MPCF_CONTACTMENU, m_hContact))
- break;
-
- if (HIWORD(wParam) == BN_CLICKED)
- if (LOWORD(wParam) >= MIN_CBUTTONID && LOWORD(wParam) <= MAX_CBUTTONID) {
- Srmm_ClickToolbarIcon(m_hContact, LOWORD(wParam), GetDlgItem(m_hwnd, LOWORD(wParam)), 0);
- break;
- }
-
switch (LOWORD(wParam)) {
case IDC_SENDALL:
int result;
@@ -1524,160 +1683,8 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) }
else result = m_iSendAllConfirm;
- if (LOWORD(result) != IDYES)
- break;
-
- case IDOK:
- // this is a 'send' button
- if (!IsWindowEnabled(GetDlgItem(m_hwnd, IDOK)))
- break;
-
- if (m_hContact != NULL) {
- memset(&pf2, 0, sizeof(pf2));
- pf2.cbSize = sizeof(pf2);
- pf2.dwMask = PFM_RTLPARA;
- m_message.SendMsg(EM_GETPARAFORMAT, 0, (LPARAM)&pf2);
-
- int bufSize = GetRichTextLength(m_message.GetHwnd(), 1200, TRUE) + 2;
- ptrW ptszUnicode((wchar_t*)mir_alloc(bufSize * sizeof(wchar_t)));
-
- MessageSendQueueItem msi = { 0 };
- if (pf2.wEffects & PFE_RTLPARA)
- msi.flags |= PREF_RTL;
-
- GETTEXTEX gt = { 0 };
- gt.flags = GT_USECRLF;
- gt.cb = bufSize;
- gt.codepage = 1200; // Unicode
- m_message.SendMsg(EM_GETTEXTEX, (WPARAM)>, ptszUnicode);
- if (RTL_Detect(ptszUnicode))
- msi.flags |= PREF_RTL;
-
- msi.sendBuffer = mir_utf8encodeW(ptszUnicode);
- msi.sendBufferSize = (int)mir_strlen(msi.sendBuffer);
- if (msi.sendBufferSize == 0)
- break;
-
- /* Store messaging history */
- TCmdList *cmdListNew = tcmdlist_last(cmdList);
- while (cmdListNew != NULL && cmdListNew->temporary) {
- cmdList = tcmdlist_remove(cmdList, cmdListNew);
- cmdListNew = tcmdlist_last(cmdList);
- }
- if (msi.sendBuffer != NULL)
- cmdList = tcmdlist_append(cmdList, rtrim(msi.sendBuffer), 20, FALSE);
-
- cmdListCurrent = NULL;
-
- if (m_nTypeMode == PROTOTYPE_SELFTYPING_ON)
- NotifyTyping(PROTOTYPE_SELFTYPING_OFF);
-
- SetDlgItemText(m_hwnd, IDC_MESSAGE, L"");
- EnableWindow(GetDlgItem(m_hwnd, IDOK), FALSE);
- if (db_get_b(NULL, SRMMMOD, SRMSGSET_AUTOMIN, SRMSGDEFSET_AUTOMIN))
- ShowWindow(m_hwndParent, SW_MINIMIZE);
- if (LOWORD(wParam) == IDC_SENDALL)
- SendMessage(m_hwndParent, DM_SENDMESSAGE, 0, (LPARAM)&msi);
- else
- SendMessage(m_hwnd, DM_SENDMESSAGE, 0, (LPARAM)&msi);
- }
- return TRUE;
-
- case IDCANCEL:
- DestroyWindow(m_hwnd);
- return TRUE;
-
- case IDC_USERMENU:
- if (GetKeyState(VK_SHIFT) & 0x8000) // copy user name
- SendMessage(m_hwnd, DM_USERNAMETOCLIP, 0, 0);
- else {
- RECT rc;
- HMENU hMenu = Menu_BuildContactMenu(m_hContact);
- GetWindowRect(GetDlgItem(m_hwnd, LOWORD(wParam)), &rc);
- TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, m_hwnd, NULL);
- DestroyMenu(hMenu);
- }
- break;
-
- case IDC_HISTORY:
- CallService(MS_HISTORY_SHOWCONTACTHISTORY, m_hContact, 0);
- break;
-
- case IDC_DETAILS:
- CallService(MS_USERINFO_SHOWDIALOG, m_hContact, 0);
- break;
-
- case IDC_QUOTE:
- if (m_hDbEventLast != NULL) {
- SETTEXTEX st;
- st.flags = ST_SELECTION;
- st.codepage = 1200;
-
- wchar_t *buffer = NULL;
- if (m_hwndIeview != NULL) {
- IEVIEWEVENT evt = { sizeof(evt) };
- evt.hwnd = m_hwndIeview;
- evt.hContact = m_hContact;
- evt.iType = IEE_GET_SELECTION;
- buffer = mir_wstrdup((wchar_t*)CallService(MS_IEVIEW_EVENT, 0, (LPARAM)&evt));
- }
- else buffer = GetRichEditSelection(m_log.GetHwnd());
-
- if (buffer != NULL) {
- wchar_t *quotedBuffer = GetQuotedTextW(buffer);
- m_message.SendMsg(EM_SETTEXTEX, (WPARAM)&st, (LPARAM)quotedBuffer);
- mir_free(quotedBuffer);
- mir_free(buffer);
- }
- else {
- DBEVENTINFO dbei = {};
- dbei.cbBlob = db_event_getBlobSize(m_hDbEventLast);
- if (dbei.cbBlob == 0xFFFFFFFF)
- break;
- dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob);
- db_event_get(m_hDbEventLast, &dbei);
- if (DbEventIsMessageOrCustom(&dbei)) {
- buffer = DbEvent_GetTextW(&dbei, CP_ACP);
- if (buffer != NULL) {
- wchar_t *quotedBuffer = GetQuotedTextW(buffer);
- m_message.SendMsg(EM_SETTEXTEX, (WPARAM)&st, (LPARAM)quotedBuffer);
- mir_free(quotedBuffer);
- mir_free(buffer);
- }
- }
- mir_free(dbei.pBlob);
- }
- SetFocus(m_message.GetHwnd());
- }
- break;
-
- case IDC_ADD:
- {
- ADDCONTACTSTRUCT acs = { 0 };
- acs.hContact = m_hContact;
- acs.handleType = HANDLE_CONTACT;
- acs.szProto = 0;
- CallService(MS_ADDCONTACT_SHOW, (WPARAM)m_hwnd, (LPARAM)&acs);
- }
- if (!db_get_b(m_hContact, "CList", "NotOnList", 0))
- ShowWindow(GetDlgItem(m_hwnd, IDC_ADD), SW_HIDE);
-
- case IDC_MESSAGE:
- if (HIWORD(wParam) == EN_CHANGE) {
- int len = GetRichTextLength(m_message.GetHwnd(), 1200, FALSE);
- cmdListCurrent = NULL;
- UpdateReadChars();
- EnableWindow(GetDlgItem(m_hwnd, IDOK), len != 0);
- if (!(GetKeyState(VK_CONTROL) & 0x8000) && !(GetKeyState(VK_SHIFT) & 0x8000)) {
- m_nLastTyping = GetTickCount();
- if (len != 0) {
- if (m_nTypeMode == PROTOTYPE_SELFTYPING_OFF)
- NotifyTyping(PROTOTYPE_SELFTYPING_ON);
- }
- else if (m_nTypeMode == PROTOTYPE_SELFTYPING_ON)
- NotifyTyping(PROTOTYPE_SELFTYPING_OFF);
- }
- }
+ if (LOWORD(result) == IDYES)
+ onClick_Ok(nullptr);
break;
}
break;
@@ -1717,5 +1724,5 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) break;
}
- return CSrmmBaseDialog::DlgProc(msg, wParam, lParam);
+ return CScriverWindow::DlgProc(msg, wParam, lParam);
}
diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index 4bfc584182..e9717d97c1 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -358,6 +358,31 @@ static int AvatarChanged(WPARAM wParam, LPARAM lParam) }
/////////////////////////////////////////////////////////////////////////////////////////
+// CScriverWindow
+
+CScriverWindow::CScriverWindow(int iDialog)
+ : CSrmmBaseDialog(g_hInst, iDialog)
+{
+ m_autoClose = CLOSE_ON_CANCEL;
+}
+
+INT_PTR CScriverWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ if (uMsg == WM_COMMAND) {
+ if (!lParam && Clist_MenuProcessCommand(LOWORD(wParam), MPCF_CONTACTMENU, m_hContact))
+ return 0;
+
+ if (HIWORD(wParam) == BN_CLICKED)
+ if (LOWORD(wParam) >= MIN_CBUTTONID && LOWORD(wParam) <= MAX_CBUTTONID) {
+ Srmm_ClickToolbarIcon(m_hContact, LOWORD(wParam), GetDlgItem(m_hwnd, LOWORD(wParam)), 0);
+ return 0;
+ }
+ }
+
+ return CSrmmBaseDialog::DlgProc(uMsg, wParam, lParam);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
// status icons processing
static void RegisterStatusIcons()
@@ -452,35 +477,35 @@ int RegisterToolbarIcons(WPARAM, LPARAM) // chat buttons
bbd.bbbFlags = BBBF_ISPUSHBUTTON | BBBF_ISCHATBUTTON | BBBF_CREATEBYID;
- bbd.dwButtonID = IDC_CHAT_BOLD;
+ bbd.dwButtonID = IDC_BOLD;
bbd.dwDefPos = 10;
bbd.hIcon = IcoLib_GetIconHandle("chat_bold");
bbd.pwszText = LPGENW("&Bold");
bbd.pwszTooltip = LPGENW("Make the text bold (CTRL+B)");
Srmm_AddButton(&bbd);
- bbd.dwButtonID = IDC_CHAT_ITALICS;
+ bbd.dwButtonID = IDC_ITALICS;
bbd.dwDefPos = 15;
bbd.hIcon = IcoLib_GetIconHandle("chat_italics");
bbd.pwszText = LPGENW("&Italic");
bbd.pwszTooltip = LPGENW("Make the text italicized (CTRL+I)");
Srmm_AddButton(&bbd);
- bbd.dwButtonID = IDC_CHAT_UNDERLINE;
+ bbd.dwButtonID = IDC_UNDERLINE;
bbd.dwDefPos = 20;
bbd.hIcon = IcoLib_GetIconHandle("chat_underline");
bbd.pwszText = LPGENW("&Underline");
bbd.pwszTooltip = LPGENW("Make the text underlined (CTRL+U)");
Srmm_AddButton(&bbd);
- bbd.dwButtonID = IDC_CHAT_COLOR;
+ bbd.dwButtonID = IDC_COLOR;
bbd.dwDefPos = 25;
bbd.hIcon = IcoLib_GetIconHandle("chat_fgcol");
bbd.pwszText = LPGENW("&Color");
bbd.pwszTooltip = LPGENW("Select a foreground color for the text (CTRL+K)");
Srmm_AddButton(&bbd);
- bbd.dwButtonID = IDC_CHAT_BKGCOLOR;
+ bbd.dwButtonID = IDC_BKGCOLOR;
bbd.dwDefPos = 30;
bbd.hIcon = IcoLib_GetIconHandle("chat_bkgcol");
bbd.pwszText = LPGENW("&Background color");
@@ -488,21 +513,21 @@ int RegisterToolbarIcons(WPARAM, LPARAM) Srmm_AddButton(&bbd);
bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID;
- bbd.dwButtonID = IDC_CHAT_CHANMGR;
+ bbd.dwButtonID = IDC_CHANMGR;
bbd.dwDefPos = 30;
bbd.hIcon = IcoLib_GetIconHandle("chat_settings");
bbd.pwszText = LPGENW("&Room settings");
bbd.pwszTooltip = LPGENW("Control this room (CTRL+O)");
Srmm_AddButton(&bbd);
- bbd.dwButtonID = IDC_CHAT_SHOWNICKLIST;
+ bbd.dwButtonID = IDC_SHOWNICKLIST;
bbd.dwDefPos = 20;
bbd.hIcon = IcoLib_GetIconHandle("chat_nicklist");
bbd.pwszText = LPGENW("&Show/hide nick list");
bbd.pwszTooltip = LPGENW("Show/hide the nick list (CTRL+N)");
Srmm_AddButton(&bbd);
- bbd.dwButtonID = IDC_CHAT_FILTER;
+ bbd.dwButtonID = IDC_FILTER;
bbd.dwDefPos = 10;
bbd.hIcon = IcoLib_GetIconHandle("chat_filter");
bbd.pwszText = LPGENW("&Filter");
diff --git a/plugins/Scriver/src/msgs.h b/plugins/Scriver/src/msgs.h index 64f4d6b05d..d2090e6049 100644 --- a/plugins/Scriver/src/msgs.h +++ b/plugins/Scriver/src/msgs.h @@ -97,9 +97,9 @@ struct MessageWindowTabData class CScriverWindow : public CSrmmBaseDialog
{
protected:
- CScriverWindow(int iDialog) :
- CSrmmBaseDialog(g_hInst, iDialog)
- {}
+ CScriverWindow(int iDialog);
+
+ virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
public:
ParentWindowData *m_pParent;
@@ -111,6 +111,7 @@ public: class CSrmmWindow : public CScriverWindow
{
CCtrlEdit m_log, m_message;
+ CCtrlButton m_btnOk, m_btnAdd, m_btnUserMenu, m_btnQuote, m_btnHistory, m_btnDetails;
CSplitter m_splitter;
wchar_t *m_wszInitialText;
@@ -129,19 +130,19 @@ class CSrmmWindow : public CScriverWindow InfobarWindowData *m_pInfobarData;
- void GetContactUniqueId(char *buf, int maxlen);
- HICON GetTabIcon();
- void GetTitlebarIcon(struct TitleBarData *tbd);
- void MessageDialogResize(int w, int h);
- void ShowAvatar();
- void SetDialogToType();
- void SetStatusIcon();
- void StreamInEvents(MEVENT hDbEventFirst, int count, int fAppend);
- void UpdateReadChars();
+ void GetContactUniqueId(char *buf, int maxlen);
+ HICON GetTabIcon();
+ void GetTitlebarIcon(struct TitleBarData *tbd);
+ void MessageDialogResize(int w, int h);
+ void ShowAvatar();
+ void SetDialogToType();
+ void SetStatusIcon();
+ void StreamInEvents(MEVENT hDbEventFirst, int count, int fAppend);
+ void UpdateReadChars();
- bool IsTypingNotificationEnabled();
- bool IsTypingNotificationSupported();
- void NotifyTyping(int mode);
+ bool IsTypingNotificationEnabled();
+ bool IsTypingNotificationSupported();
+ void NotifyTyping(int mode);
public:
char *m_szProto;
@@ -161,12 +162,23 @@ public: virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
- void OnSplitterMoved(CSplitter *pSplitter);
+ void onClick_Ok(CCtrlButton*);
+ void onClick_Add(CCtrlButton*);
+ void onClick_Quote(CCtrlButton*);
+ void onClick_Details(CCtrlButton*);
+ void onClick_History(CCtrlButton*);
+ void onClick_UserMenu(CCtrlButton*);
+
+ void onChange_Message(CCtrlEdit*);
+
+ void onChanged_Splitter(CSplitter *pSplitter);
};
class CChatRoomDlg : public CScriverWindow
{
CCtrlEdit m_message, m_log;
+ CCtrlButton m_btnOk, m_btnHistory, m_btnShowList, m_btnFilter, m_btnChanMgr;
+ CCtrlButton m_btnColor, m_btnBkColor, m_btnBold, m_btnItalic, m_btnUnderline;
CCtrlListBox m_nickList;
CSplitter m_splitterX, m_splitterY;
@@ -184,9 +196,22 @@ public: virtual INT_PTR DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) override;
+ void onChange_Message(CCtrlEdit*);
+
+ void onClick_Ok(CCtrlButton*);
+ void onClick_Filter(CCtrlButton*);
+ void onClick_History(CCtrlButton*);
+ void onClick_ChanMgr(CCtrlButton*);
+ void onClick_ShowList(CCtrlButton*);
+
+ void onClick_BIU(CCtrlButton*);
+ void onClick_Color(CCtrlButton*);
+ void onClick_BkColor(CCtrlButton*);
+
+ void onDblClick_List(CCtrlListBox*);
+
void OnSplitterX(CSplitter *pSplitter);
void OnSplitterY(CSplitter *pSplitter);
-
};
#define HM_DBEVENTADDED (WM_USER+10)
diff --git a/plugins/Scriver/src/resource.h b/plugins/Scriver/src/resource.h index 6ce2fac1b0..b93c734738 100644 --- a/plugins/Scriver/src/resource.h +++ b/plugins/Scriver/src/resource.h @@ -88,13 +88,21 @@ #define IDC_LIMITCHATSTABS 1013
#define IDC_LIMITCHATSTABSNUM 1014
#define IDC_LIMITCHATSTABSNUMSPIN 1015
+#define IDC_SMILEY 1016
+#define IDC_UNDERLINE 1017
+#define IDC_COLOR 1018
+#define IDC_BKGCOLOR 1019
#define IDC_SHOWNAMES 1020
+#define IDC_BOLD 1021
#define IDC_USETABS 1022
#define IDC_SHOWSECONDS 1023
#define IDC_USELONGDATE 1024
#define IDC_USERELATIVEDATE 1025
#define IDC_USEIEVIEW 1026
#define IDC_FONTSCOLORS 1027
+#define IDC_ITALICS 1028
+#define IDC_FILTER 1029
+#define IDC_CHANMGR 1030
#define IDC_SHOWLOGICONS 1032
#define IDC_SHOWTIMES 1033
#define IDC_SHOWDATES 1034
@@ -171,14 +179,7 @@ #define IDC_INPUTLINESSPIN 1648
#define IDC_SPLITTERX 5006
#define IDC_SPLITTERY 5008
-#define IDC_CHAT_BOLD 5010
-#define IDC_CHAT_ITALICS 5011
-#define IDC_CHAT_UNDERLINE 5012
-#define IDC_CHAT_FILTER 5013
-#define IDC_CHAT_CHANMGR 5014
-#define IDC_CHAT_SHOWNICKLIST 5016
-#define IDC_CHAT_COLOR 5017
-#define IDC_CHAT_BKGCOLOR 5019
+#define IDC_SHOWNICKLIST 5016
#define IDC_CHAT_CHECKBOXES 5021
#define IDC_CHAT_NICKROW 5024
#define IDC_CHAT_LOGLIMIT 5024
diff --git a/plugins/Scriver/src/version.h b/plugins/Scriver/src/version.h index e65689c9c6..da34edf9da 100644 --- a/plugins/Scriver/src/version.h +++ b/plugins/Scriver/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 3 #define __MINOR_VERSION 0 #define __RELEASE_NUM 1 -#define __BUILD_NUM 3 +#define __BUILD_NUM 4 #include <stdver.h> |