From 941ff9f0edad23f8f81523b35b022d8bd5d5033a Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 8 Sep 2019 21:28:48 +0300 Subject: . --- plugins/Scriver/src/chat_window.cpp | 637 ------------------------- plugins/Scriver/src/infobar.cpp | 28 +- plugins/Scriver/src/input.cpp | 4 +- plugins/Scriver/src/msgdialog.cpp | 904 +++++++++++++++++++++++++++--------- plugins/Scriver/src/msglog.cpp | 130 ++---- plugins/Scriver/src/msgs.cpp | 80 +--- plugins/Scriver/src/msgs.h | 193 ++++---- plugins/Scriver/src/resource.h | 1 - plugins/Scriver/src/tabs.cpp | 50 +- plugins/Scriver/src/tabs.h | 4 - plugins/Scriver/src/utils.cpp | 2 +- 11 files changed, 854 insertions(+), 1179 deletions(-) (limited to 'plugins/Scriver/src') diff --git a/plugins/Scriver/src/chat_window.cpp b/plugins/Scriver/src/chat_window.cpp index 1e61766683..b36284b504 100644 --- a/plugins/Scriver/src/chat_window.cpp +++ b/plugins/Scriver/src/chat_window.cpp @@ -130,218 +130,6 @@ void CMsgDialog::FixTabIcons() ///////////////////////////////////////////////////////////////////////////////////////// -void CMsgDialog::MessageDialogResize(int w, int h) -{ - bool bNick = m_si->iType != GCW_SERVER && m_bNicklistEnabled; - bool bToolbar = SendMessage(m_hwndParent, CM_GETTOOLBARSTATUS, 0, 0) != 0; - int hSplitterMinTop = TOOLBAR_HEIGHT + m_minLogBoxHeight, hSplitterMinBottom = m_minEditBoxHeight; - int toolbarHeight = bToolbar ? TOOLBAR_HEIGHT : 0; - - if (h - m_pParent->iSplitterY < hSplitterMinTop) - m_pParent->iSplitterY = h - hSplitterMinTop; - if (m_pParent->iSplitterY < hSplitterMinBottom) - m_pParent->iSplitterY = hSplitterMinBottom; - - m_splitterX.Show(bNick); - if (m_si->iType != GCW_SERVER) - m_nickList.Show(m_bNicklistEnabled); - else - m_nickList.Hide(); - - if (m_si->iType == GCW_SERVER) { - m_btnNickList.Enable(false); - m_btnFilter.Enable(false); - m_btnChannelMgr.Enable(false); - } - else { - m_btnNickList.Enable(true); - m_btnFilter.Enable(true); - if (m_si->iType == GCW_CHATROOM) - m_btnChannelMgr.Enable(m_si->pMI->bChanMgr); - } - - int toolbarTopY = bToolbar ? h - m_pParent->iSplitterY - toolbarHeight : h - m_pParent->iSplitterY; - int logBottom = (m_hwndIeview != nullptr) ? toolbarTopY / 2 : toolbarTopY; - - HDWP hdwp = BeginDeferWindowPos(5); - hdwp = DeferWindowPos(hdwp, m_log.GetHwnd(), nullptr, 1, 0, bNick ? w - m_pParent->iSplitterX - 1 : w - 2, logBottom, SWP_NOZORDER); - hdwp = DeferWindowPos(hdwp, m_nickList.GetHwnd(), nullptr, w - m_pParent->iSplitterX + 2, 0, m_pParent->iSplitterX - 3, toolbarTopY, SWP_NOZORDER); - hdwp = DeferWindowPos(hdwp, m_splitterX.GetHwnd(), nullptr, w - m_pParent->iSplitterX, 1, 2, toolbarTopY - 1, SWP_NOZORDER); - hdwp = DeferWindowPos(hdwp, m_splitterY.GetHwnd(), nullptr, 0, h - m_pParent->iSplitterY, w, SPLITTER_HEIGHT, SWP_NOZORDER); - hdwp = DeferWindowPos(hdwp, m_message.GetHwnd(), nullptr, 1, h - m_pParent->iSplitterY + SPLITTER_HEIGHT, w - 2, m_pParent->iSplitterY - SPLITTER_HEIGHT - 1, SWP_NOZORDER); - EndDeferWindowPos(hdwp); - - SetButtonsPos(m_hwnd, m_hContact, bToolbar); - - if (m_hwndIeview != nullptr) { - IEVIEWWINDOW ieWindow; - ieWindow.cbSize = sizeof(IEVIEWWINDOW); - ieWindow.iType = IEW_SETPOS; - ieWindow.parent = m_hwnd; - ieWindow.hwnd = m_hwndIeview; - ieWindow.x = 0; - ieWindow.y = logBottom + 1; - ieWindow.cx = bNick ? w - m_pParent->iSplitterX : w; - ieWindow.cy = logBottom; - CallService(MS_IEVIEW_WINDOW, 0, (LPARAM)&ieWindow); - } - else RedrawWindow(m_log.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE); - - RedrawWindow(m_nickList.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE); - RedrawWindow(m_message.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE); -} - -CMsgDialog::CMsgDialog(SESSION_INFO *si) - : CScriverWindow(IDD_CHANNEL, si), - m_splitterX(this, IDC_SPLITTERX), - m_splitterY(this, IDC_SPLITTERY), - m_btnOk(this, IDOK) -{ - m_btnOk.OnClick = Callback(this, &CMsgDialog::onClick_Ok); - m_btnFilter.OnClick = Callback(this, &CMsgDialog::onClick_Filter); - m_btnNickList.OnClick = Callback(this, &CMsgDialog::onClick_ShowList); - - m_message.OnChange = Callback(this, &CMsgDialog::onChange_Message); - - m_splitterX.OnChange = Callback(this, &CMsgDialog::OnSplitterX); - m_splitterY.OnChange = Callback(this, &CMsgDialog::OnSplitterY); -} - -bool CMsgDialog::OnInitDialog() -{ - CSuper::OnInitDialog(); - m_si->pDlg = this; - - NotifyEvent(MSG_WINDOW_EVT_OPENING); - - m_pParent = (ParentWindowData *)GetWindowLongPtr(m_hwndParent, GWLP_USERDATA); - - RECT rc; - GetWindowRect(m_message.GetHwnd(), &rc); - m_minLogBoxHeight = m_minEditBoxHeight = rc.bottom - rc.top; - if (m_pParent->iSplitterY == -1) - m_pParent->iSplitterY = m_minEditBoxHeight; - - if (m_pParent->iSplitterX == -1) { - GetWindowRect(m_nickList.GetHwnd(), &rc); - m_pParent->iSplitterX = rc.right - rc.left; - } - - SetMinSize(350, m_minLogBoxHeight + TOOLBAR_HEIGHT + m_minEditBoxHeight + 5); - - m_message.SendMsg(EM_SUBCLASSED, 0, 0); - m_message.SendMsg(EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS | ENM_KEYEVENTS | ENM_CHANGE | ENM_REQUESTRESIZE); - - int mask = (int)m_log.SendMsg(EM_GETEVENTMASK, 0, 0); - m_log.SendMsg(EM_SETEVENTMASK, 0, mask | ENM_LINK | ENM_MOUSEEVENTS); - m_log.SendMsg(EM_LIMITTEXT, sizeof(wchar_t) * 0x7FFFFFFF, 0); - m_log.SendMsg(EM_AUTOURLDETECT, 1, 0); - - if (db_get_b(0, CHAT_MODULE, "UseIEView", 0)) { - IEVIEWWINDOW ieWindow = { sizeof(ieWindow) }; - ieWindow.iType = IEW_CREATE; - ieWindow.dwMode = IEWM_CHAT; - ieWindow.parent = m_hwnd; - ieWindow.cx = 200; - ieWindow.cy = 300; - CallService(MS_IEVIEW_WINDOW, 0, (LPARAM)&ieWindow); - - m_hwndIeview = ieWindow.hwnd; - - IEVIEWEVENT iee = { sizeof(iee) }; - iee.iType = IEE_CLEAR_LOG; - iee.hwnd = m_hwndIeview; - iee.hContact = m_hContact; - iee.pszProto = m_si->pszModule; - CallService(MS_IEVIEW_EVENT, 0, (LPARAM)&iee); - } - - m_log.SendMsg(EM_HIDESELECTION, TRUE, 0); - - UpdateOptions(); - UpdateStatusBar(); - UpdateTitle(); - - SendMessage(m_hwndParent, CM_ADDCHILD, (WPARAM)this, 0); - UpdateNickList(); - NotifyEvent(MSG_WINDOW_EVT_OPEN); - return true; -} - -void CMsgDialog::OnDestroy() -{ - NotifyEvent(MSG_WINDOW_EVT_CLOSING); - - m_si->pDlg = nullptr; - - SendMessage(m_hwndParent, CM_REMOVECHILD, 0, (LPARAM)m_hwnd); - if (m_hwndIeview != nullptr) { - IEVIEWWINDOW ieWindow; - ieWindow.cbSize = sizeof(IEVIEWWINDOW); - ieWindow.iType = IEW_DESTROY; - ieWindow.hwnd = m_hwndIeview; - CallService(MS_IEVIEW_WINDOW, 0, (LPARAM)&ieWindow); - } - - NotifyEvent(MSG_WINDOW_EVT_CLOSE); - - CSuper::OnDestroy(); -} - -void CMsgDialog::OnSplitterX(CSplitter *pSplitter) -{ - RECT rc; - GetClientRect(m_hwnd, &rc); - - m_pParent->iSplitterX = rc.right - pSplitter->GetPos() + 1; - if (m_pParent->iSplitterX < 35) - m_pParent->iSplitterX = 35; - if (m_pParent->iSplitterX > rc.right - rc.left - 35) - m_pParent->iSplitterX = rc.right - rc.left - 35; -} - -void CMsgDialog::OnSplitterY(CSplitter *pSplitter) -{ - RECT rc; - GetClientRect(m_hwnd, &rc); - m_pParent->iSplitterY = rc.bottom - pSplitter->GetPos(); -} - -void CMsgDialog::onClick_Ok(CCtrlButton *pButton) -{ - if (!pButton->Enabled()) - return; - - char *pszRtf = m_message.GetRichTextRtf(); - if (pszRtf == nullptr) - return; - - TCmdList *cmdListNew = tcmdlist_last(cmdList); - while (cmdListNew != nullptr && 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))); - g_chatApi.DoRtfToTags(ptszText, 0, nullptr); - ptszText.Trim(); - ptszText.Replace(L"%", L"%%"); - - if (m_si->pMI->bAckMsg) { - EnableWindow(m_message.GetHwnd(), FALSE); - m_message.SendMsg(EM_SETREADONLY, TRUE, 0); - } - else m_message.SetText(L""); - - EnableWindow(m_btnOk.GetHwnd(), FALSE); - - Chat_DoEventHook(m_si, GC_USER_MESSAGE, nullptr, ptszText, 0); - SetFocus(m_message.GetHwnd()); -} - void CMsgDialog::onClick_ShowList(CCtrlButton *pButton) { if (!pButton->Enabled() || m_si->iType == GCW_SERVER) @@ -366,12 +154,6 @@ void CMsgDialog::onClick_Filter(CCtrlButton *pButton) RedrawLog(); } -void CMsgDialog::onChange_Message(CCtrlEdit*) -{ - cmdListCurrent = nullptr; - m_btnOk.Enable(m_message.GetRichTextLength() != 0); -} - ///////////////////////////////////////////////////////////////////////////////////////// static void __cdecl phase2(SESSION_INFO *si) @@ -406,21 +188,6 @@ void CMsgDialog::RedrawLog() else ClearLog(); } -void CMsgDialog::ScrollToBottom() -{ - if (GetWindowLongPtr(m_log.GetHwnd(), GWL_STYLE) & WS_VSCROLL) { - SCROLLINFO si = { sizeof(si) }; - si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS; - if (GetScrollInfo(m_log.GetHwnd(), SB_VERT, &si)) { - si.fMask = SIF_POS; - si.nPos = si.nMax - si.nPage + 1; - SetScrollInfo(m_log.GetHwnd(), SB_VERT, &si, TRUE); - - PostMessage(m_log.GetHwnd(), WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0); - } - } -} - void CMsgDialog::ShowFilterMenu() { HWND hwnd = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_FILTER), m_hwnd, FilterWndProc, (LPARAM)this); @@ -500,57 +267,6 @@ void CMsgDialog::UpdateOptions() RedrawLog2(); } -void CMsgDialog::UpdateStatusBar() -{ - wchar_t szTemp[512]; - mir_snwprintf(szTemp, L"%s : %s", m_si->pMI->ptszModDispName, m_si->ptszStatusbarText ? m_si->ptszStatusbarText : L""); - - StatusBarData sbd; - sbd.iItem = 0; - sbd.iFlags = SBDF_TEXT | SBDF_ICON; - sbd.hIcon = m_si->wStatus == ID_STATUS_ONLINE ? m_si->pMI->hOnlineIcon : m_si->pMI->hOfflineIcon; - sbd.pszText = szTemp; - SendMessage(m_hwndParent, CM_UPDATESTATUSBAR, (WPARAM)&sbd, (LPARAM)m_hwnd); - - sbd.iItem = 1; - sbd.hIcon = nullptr; - sbd.pszText = L""; - SendMessage(m_hwndParent, CM_UPDATESTATUSBAR, (WPARAM)&sbd, (LPARAM)m_hwnd); - - Srmm_SetIconFlags(m_hContact, SRMM_MODULE, 0, 0); -} - -void CMsgDialog::UpdateTitle() -{ - TitleBarData tbd = {}; - tbd.hIcon = (m_si->wStatus == ID_STATUS_ONLINE) ? m_si->pMI->hOnlineIcon : m_si->pMI->hOfflineIcon; - tbd.hIconBig = (m_si->wStatus == ID_STATUS_ONLINE) ? m_si->pMI->hOnlineIconBig : m_si->pMI->hOfflineIconBig; - tbd.hIconNot = (m_si->wState & (GC_EVENT_HIGHLIGHT | STATE_TALK)) ? g_plugin.getIcon(IDI_OVERLAY) : nullptr; - - int nUsers = m_si->getUserList().getCount(); - wchar_t szTemp[512]; - switch (m_si->iType) { - case GCW_CHATROOM: - mir_snwprintf(szTemp, - (nUsers == 1) ? TranslateT("%s: chat room (%u user)") : TranslateT("%s: chat room (%u users)"), - m_si->ptszName, nUsers); - break; - case GCW_PRIVMESS: - mir_snwprintf(szTemp, - (nUsers == 1) ? TranslateT("%s: message session") : TranslateT("%s: message session (%u users)"), - m_si->ptszName, nUsers); - break; - case GCW_SERVER: - mir_snwprintf(szTemp, L"%s: Server", m_si->ptszName); - break; - } - tbd.iFlags = TBDF_TEXT | TBDF_ICON; - tbd.pszText = szTemp; - SendMessage(m_hwndParent, CM_UPDATETITLEBAR, (WPARAM)&tbd, (LPARAM)m_hwnd); - - SendMessage(m_hwnd, DM_UPDATETABCONTROL, 0, 0); -} - ///////////////////////////////////////////////////////////////////////////////////////// INT_PTR CALLBACK CMsgDialog::FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) @@ -625,149 +341,6 @@ INT_PTR CALLBACK CMsgDialog::FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wPara ///////////////////////////////////////////////////////////////////////////////////////// -LRESULT CMsgDialog::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) -{ - bool isShift = (GetKeyState(VK_SHIFT) & 0x8000) != 0; - bool isCtrl = (GetKeyState(VK_CONTROL) & 0x8000) != 0; - bool isAlt = (GetKeyState(VK_MENU) & 0x8000) != 0; - - int result = InputAreaShortcuts(m_message.GetHwnd(), msg, wParam, lParam); - if (result != -1) - return result; - - switch (msg) { - case WM_MOUSEWHEEL: - if ((GetWindowLongPtr(m_message.GetHwnd(), GWL_STYLE) & WS_VSCROLL) == 0) - m_log.SendMsg(WM_MOUSEWHEEL, wParam, lParam); - - m_iLastEnterTime = 0; - return TRUE; - - case EM_REPLACESEL: - PostMessage(m_message.GetHwnd(), EM_ACTIVATE, 0, 0); - break; - - case EM_ACTIVATE: - SetActiveWindow(m_hwnd); - break; - - case WM_KEYDOWN: - if (wParam == VK_RETURN) { - if (CheckSend()) - return 0; - } - else m_iLastEnterTime = 0; - - if (wParam == VK_TAB && isShift && !isCtrl) { // SHIFT-TAB (go to nick list) - SetFocus(m_nickList.GetHwnd()); - return TRUE; - } - - if (wParam == VK_TAB && !isCtrl && !isShift) { //tab-autocomplete - m_message.SendMsg(WM_SETREDRAW, FALSE, 0); - TabAutoComplete(); - m_message.SendMsg(WM_SETREDRAW, TRUE, 0); - RedrawWindow(m_nickList.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE); - return 0; - } - if (wParam != VK_RIGHT && wParam != VK_LEFT) { - mir_free(m_wszSearchQuery); - m_wszSearchQuery = nullptr; - mir_free(m_wszSearchResult); - m_wszSearchResult = nullptr; - } - - if (ProcessHotkeys(wParam, isShift, isCtrl, isAlt)) - return TRUE; - - if (wParam == 0x4e && isCtrl && !isAlt) { // ctrl-n (nicklist) - if (m_btnNickList.Enabled()) - m_btnNickList.Click(); - return TRUE; - } - - if (wParam == 0x48 && isCtrl && !isAlt) { // ctrl-h (history) - m_btnHistory.Click(); - return TRUE; - } - - if (wParam == 0x4f && isCtrl && !isAlt) { // ctrl-o (options) - if (m_btnChannelMgr.Enabled()) - m_btnChannelMgr.Click(); - return TRUE; - } - - if (((wParam == VK_INSERT && isShift) || (wParam == 'V' && isCtrl)) && !isAlt) { // ctrl-v (paste clean text) - m_message.SendMsg(EM_PASTESPECIAL, CF_UNICODETEXT, 0); - return TRUE; - } - - if (wParam == VK_NEXT || wParam == VK_PRIOR) { - m_log.SendMsg(msg, wParam, lParam); - return TRUE; - } - break; - - case WM_LBUTTONDOWN: - case WM_MBUTTONDOWN: - case WM_KILLFOCUS: - m_iLastEnterTime = 0; - break; - - case WM_CONTEXTMENU: - InputAreaContextMenu(m_message.GetHwnd(), wParam, lParam, m_hContact); - return TRUE; - - case WM_KEYUP: - case WM_LBUTTONUP: - case WM_RBUTTONUP: - case WM_MBUTTONUP: - RefreshButtonStatus(); - break; - - case WM_DESTROY: - mir_free(m_wszSearchQuery); - mir_free(m_wszSearchResult); - return 0; - } - - return CSuper::WndProc_Message(msg, wParam, lParam); -} - -///////////////////////////////////////////////////////////////////////////////////////// - -LRESULT CMsgDialog::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam) -{ - int result = InputAreaShortcuts(m_log.GetHwnd(), msg, wParam, lParam); - if (result != -1) - return result; - - CHARRANGE sel; - - switch (msg) { - case WM_MEASUREITEM: - MeasureMenuItem(wParam, lParam); - return TRUE; - - case WM_DRAWITEM: - return DrawMenuItem(wParam, lParam); - - case WM_LBUTTONUP: - SendMessage(m_log.GetHwnd(), EM_EXGETSEL, 0, (LPARAM)&sel); - if (sel.cpMin != sel.cpMax) { - SendMessage(m_log.GetHwnd(), WM_COPY, 0, 0); - sel.cpMin = sel.cpMax; - SendMessage(m_log.GetHwnd(), EM_EXSETSEL, 0, (LPARAM)&sel); - } - SetFocus(m_message.GetHwnd()); - break; - } - - return CSuper::WndProc_Log(msg, wParam, lParam); -} - -///////////////////////////////////////////////////////////////////////////////////////// - LRESULT CMsgDialog::WndProc_Nicklist(UINT msg, WPARAM wParam, LPARAM lParam) { int result = InputAreaShortcuts(m_nickList.GetHwnd(), msg, wParam, lParam); @@ -854,212 +427,6 @@ LRESULT CMsgDialog::WndProc_Nicklist(UINT msg, WPARAM wParam, LPARAM lParam) ///////////////////////////////////////////////////////////////////////////////////////// -INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - RECT rc; - POINT pt; - HICON hIcon; - TabControlData tcd; - - switch (uMsg) { - case DM_SWITCHINFOBAR: - case DM_SWITCHTOOLBAR: - Resize(); - break; - - case WM_SIZE: - if (wParam == SIZE_MAXIMIZED) - ScrollToBottom(); - - if (IsIconic(m_hwnd)) break; - - if (wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED) { - GetClientRect(m_hwnd, &rc); - if (rc.right && rc.bottom) - MessageDialogResize(rc.right, rc.bottom); - } - break; - - case DM_UPDATETABCONTROL: - tcd.iFlags = TCDF_TEXT; - tcd.pszText = m_si->ptszName; - SendMessage(m_hwndParent, CM_UPDATETABCONTROL, (WPARAM)&tcd, (LPARAM)m_hwnd); - __fallthrough; - - case DM_ACTIVATE: - if (m_si->wState & STATE_TALK) { - m_si->wState &= ~STATE_TALK; - db_set_w(m_hContact, m_si->pszModule, "ApparentMode", 0); - } - - if (m_si->wState & GC_EVENT_HIGHLIGHT) { - m_si->wState &= ~GC_EVENT_HIGHLIGHT; - - if (g_clistApi.pfnGetEvent(m_hContact, 0)) - g_clistApi.pfnRemoveEvent(m_hContact, GC_FAKE_EVENT); - } - - FixTabIcons(); - if (!m_si->pDlg) { - ShowRoom(m_si); - SendMessage(m_hwnd, WM_MOUSEACTIVATE, 0, 0); - } - break; - - case WM_CTLCOLORLISTBOX: - SetBkColor((HDC)wParam, g_Settings.crUserListBGColor); - return (INT_PTR)g_chatApi.hListBkgBrush; - - case WM_MEASUREITEM: - if (!MeasureMenuItem(wParam, lParam)) { - MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *)lParam; - if (mis->CtlType == ODT_MENU) - return Menu_MeasureItem(lParam); - - int ih = Chat_GetTextPixelSize(L"AQGgl'", g_Settings.UserListFont, false); - int ih2 = Chat_GetTextPixelSize(L"AQGg'", g_Settings.UserListHeadingsFont, false); - int font = ih > ih2 ? ih : ih2; - int height = db_get_b(0, CHAT_MODULE, "NicklistRowDist", 12); - // make sure we have space for icon! - if (db_get_b(0, CHAT_MODULE, "ShowContactStatus", 0)) - font = font > 16 ? font : 16; - mis->itemHeight = height > font ? height : font; - } - return TRUE; - - case WM_DRAWITEM: - if (!DrawMenuItem(wParam, lParam)) { - DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)lParam; - if (dis->CtlType == ODT_MENU) - return Menu_DrawItem(lParam); - - if (dis->CtlID == IDC_SRMM_NICKLIST) { - int index = dis->itemID; - USERINFO *ui = g_chatApi.SM_GetUserFromIndex(m_si->ptszID, m_si->pszModule, index); - if (ui) { - int x_offset = 2; - - int height = dis->rcItem.bottom - dis->rcItem.top; - if (height & 1) - height++; - - int offset = (height == 10) ? 0 : height / 2 - 5; - HFONT hFont = (ui->iStatusEx == 0) ? g_Settings.UserListFont : g_Settings.UserListHeadingsFont; - HFONT hOldFont = (HFONT)SelectObject(dis->hDC, hFont); - SetBkMode(dis->hDC, TRANSPARENT); - - if (dis->itemAction == ODA_FOCUS && dis->itemState & ODS_SELECTED) - FillRect(dis->hDC, &dis->rcItem, g_chatApi.hListSelectedBkgBrush); - else //if (dis->itemState & ODS_INACTIVE) - FillRect(dis->hDC, &dis->rcItem, g_chatApi.hListBkgBrush); - - if (g_Settings.bShowContactStatus && g_Settings.bContactStatusFirst && ui->ContactStatus) { - hIcon = Skin_LoadProtoIcon(m_si->pszModule, ui->ContactStatus); - DrawIconEx(dis->hDC, x_offset, dis->rcItem.top + offset - 3, hIcon, 16, 16, 0, nullptr, DI_NORMAL); - IcoLib_ReleaseIcon(hIcon); - x_offset += 18; - } - DrawIconEx(dis->hDC, x_offset, dis->rcItem.top + offset, g_chatApi.SM_GetStatusIcon(m_si, ui), 10, 10, 0, nullptr, DI_NORMAL); - x_offset += 12; - if (g_Settings.bShowContactStatus && !g_Settings.bContactStatusFirst && ui->ContactStatus) { - hIcon = Skin_LoadProtoIcon(m_si->pszModule, ui->ContactStatus); - DrawIconEx(dis->hDC, x_offset, dis->rcItem.top + offset - 3, hIcon, 16, 16, 0, nullptr, DI_NORMAL); - IcoLib_ReleaseIcon(hIcon); - x_offset += 18; - } - - SetTextColor(dis->hDC, ui->iStatusEx == 0 ? g_Settings.crUserListColor : g_Settings.crUserListHeadingsColor); - TextOut(dis->hDC, dis->rcItem.left + x_offset, dis->rcItem.top, ui->pszNick, (int)mir_wstrlen(ui->pszNick)); - SelectObject(dis->hDC, hOldFont); - } - return TRUE; - } - } - break; - - case WM_ACTIVATE: - if (LOWORD(wParam) != WA_ACTIVE) - break; - - __fallthrough; - case WM_MOUSEACTIVATE: - if (uMsg != WM_ACTIVATE) - SetFocus(m_message.GetHwnd()); - - g_chatApi.SetActiveSession(m_si); - - if (db_get_w(m_hContact, m_si->pszModule, "ApparentMode", 0) != 0) - db_set_w(m_hContact, m_si->pszModule, "ApparentMode", 0); - if (g_clistApi.pfnGetEvent(m_hContact, 0)) - g_clistApi.pfnRemoveEvent(m_hContact, GC_FAKE_EVENT); - break; - - case WM_NOTIFY: - { - LPNMHDR pNmhdr = (LPNMHDR)lParam; - switch (pNmhdr->code) { - case EN_MSGFILTER: - if (pNmhdr->idFrom == IDC_SRMM_LOG && ((MSGFILTER *)lParam)->msg == WM_RBUTTONUP) { - SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, TRUE); - return TRUE; - } - break; - - case TTN_NEEDTEXT: - if (pNmhdr->idFrom == (UINT_PTR)m_nickList.GetHwnd()) { - LPNMTTDISPINFO lpttd = (LPNMTTDISPINFO)lParam; - SESSION_INFO* parentdat = (SESSION_INFO*)GetWindowLongPtr(m_hwnd, GWLP_USERDATA); - - POINT p; - GetCursorPos(&p); - ScreenToClient(m_nickList.GetHwnd(), &p); - int item = LOWORD(m_nickList.SendMsg(LB_ITEMFROMPOINT, 0, MAKELPARAM(p.x, p.y))); - USERINFO *ui = g_chatApi.SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, item); - if (ui != nullptr) { - static wchar_t ptszBuf[1024]; - mir_snwprintf(ptszBuf, L"%s: %s\r\n%s: %s\r\n%s: %s", - TranslateT("Nickname"), ui->pszNick, - TranslateT("Unique ID"), ui->pszUID, - TranslateT("Status"), g_chatApi.TM_WordToString(parentdat->pStatuses, ui->Status)); - lpttd->lpszText = ptszBuf; - } - } - break; - } - } - break; - - case WM_KEYDOWN: - SetFocus(m_message.GetHwnd()); - break; - - case WM_LBUTTONDBLCLK: - if (LOWORD(lParam) < 30) - ScrollToBottom(); - else - SendMessage(m_hwndParent, WM_SYSCOMMAND, SC_MINIMIZE, 0); - break; - - case WM_LBUTTONDOWN: - SendMessage(m_hwndParent, WM_LBUTTONDOWN, wParam, lParam); - return TRUE; - - case DM_GETCONTEXTMENU: - SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, (LPARAM)Menu_BuildContactMenu(m_hContact)); - return TRUE; - - case WM_CONTEXTMENU: - if (m_hwndParent == (HWND)wParam) { - HMENU hMenu = Menu_BuildContactMenu(m_hContact); - GetCursorPos(&pt); - TrackPopupMenu(hMenu, 0, pt.x, pt.y, 0, m_hwnd, nullptr); - DestroyMenu(hMenu); - } - break; - } - return CSuper::DlgProc(uMsg, wParam, lParam); -} - void ShowRoom(SESSION_INFO *si) { if (si == nullptr) @@ -1068,13 +435,9 @@ void ShowRoom(SESSION_INFO *si) // Do we need to create a window? CMsgDialog *pDlg; if (si->pDlg == nullptr) { - HWND hParent = GetParentWindow(si->hContact, true); - pDlg = new CMsgDialog(si); - pDlg->SetParent(hParent); pDlg->Show(); - pDlg->m_pParent = (ParentWindowData*)GetWindowLongPtr(hParent, GWLP_USERDATA); si->pDlg = pDlg; } else pDlg = si->pDlg; diff --git a/plugins/Scriver/src/infobar.cpp b/plugins/Scriver/src/infobar.cpp index 52ebca192d..2fb79a8d5c 100644 --- a/plugins/Scriver/src/infobar.cpp +++ b/plugins/Scriver/src/infobar.cpp @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" -void CSrmmWindow::SetupInfobar() +void CMsgDialog::SetupInfobar() { DWORD colour = g_plugin.getDword(SRMSGSET_INFOBARBKGCOLOUR, SRMSGDEFSET_INFOBARBKGCOLOUR); @@ -65,21 +65,17 @@ void CSrmmWindow::SetupInfobar() RefreshInfobar(); } -static HICON GetExtraStatusIcon(CSrmmWindow *pDlg) -{ - BYTE bXStatus = db_get_b(pDlg->m_hContact, pDlg->m_szProto, "XStatusId", 0); - if (bXStatus > 0) - return (HICON)CallProtoService(pDlg->m_szProto, PS_GETCUSTOMSTATUSICON, bXStatus, 0); - - return nullptr; -} - -void CSrmmWindow::RefreshInfobar() +void CMsgDialog::RefreshInfobar() { ptrW szContactStatusMsg(db_get_wsa(m_hContact, "CList", "StatusMsg")); ptrW szXStatusName(db_get_wsa(m_hContact, m_szProto, "XStatusName")); ptrW szXStatusMsg(db_get_wsa(m_hContact, m_szProto, "XStatusMsg")); - HICON hIcon = GetExtraStatusIcon(this); + + HICON hIcon = nullptr; + BYTE bXStatus = db_get_b(m_hContact, m_szProto, "XStatusId", 0); + if (bXStatus > 0) + hIcon = (HICON)CallProtoService(m_szProto, PS_GETCUSTOMSTATUSICON, bXStatus, 0); + wchar_t szText[2048]; SETTEXTEX st; if (szXStatusMsg && *szXStatusMsg) @@ -102,17 +98,17 @@ void CSrmmWindow::RefreshInfobar() RedrawWindow(GetDlgItem(m_hwndInfo, IDC_AVATAR), nullptr, nullptr, RDW_INVALIDATE); } -static INT_PTR CALLBACK InfobarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK InfobarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { static BOOL bWasCopy; - CSrmmWindow *idat = (CSrmmWindow*)GetWindowLongPtr(hwnd, GWLP_USERDATA); + CMsgDialog *idat = (CMsgDialog*)GetWindowLongPtr(hwnd, GWLP_USERDATA); if (!idat && msg != WM_INITDIALOG) return FALSE; switch (msg) { case WM_INITDIALOG: bWasCopy = FALSE; - idat = (CSrmmWindow *)lParam; + idat = (CMsgDialog *)lParam; idat->m_hwndInfo = hwnd; { RECT rect = { 0 }; @@ -265,7 +261,7 @@ static INT_PTR CALLBACK InfobarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA return FALSE; } -void CSrmmWindow::CreateInfobar() +void CMsgDialog::CreateInfobar() { m_hwndInfo = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_INFOBAR), m_hwnd, InfobarWndProc, (LPARAM)this); SetWindowPos(m_hwndInfo, HWND_TOP, 0, 0, 0, 0, SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOREPOSITION); diff --git a/plugins/Scriver/src/input.cpp b/plugins/Scriver/src/input.cpp index 81cedf22ca..825a97ce55 100644 --- a/plugins/Scriver/src/input.cpp +++ b/plugins/Scriver/src/input.cpp @@ -112,7 +112,7 @@ void InputAreaContextMenu(HWND hwnd, WPARAM, LPARAM lParam, MCONTACT hContact) DestroyMenu(hMenu); } -bool CScriverWindow::CheckSend() +bool CMsgDialog::CheckSend() { BOOL isShift = GetKeyState(VK_SHIFT) & 0x8000; BOOL isCtrl = GetKeyState(VK_CONTROL) & 0x8000; @@ -144,7 +144,7 @@ bool CScriverWindow::CheckSend() return false; } -int CScriverWindow::InputAreaShortcuts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +int CMsgDialog::InputAreaShortcuts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { BOOL isShift = GetKeyState(VK_SHIFT) & 0x8000; BOOL isAlt = GetKeyState(VK_MENU) & 0x8000; diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index ac82f3cdcc..60cf4659b9 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -147,10 +147,11 @@ static INT_PTR CALLBACK ConfirmSendAllDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa ///////////////////////////////////////////////////////////////////////////////////////// -CSrmmWindow::CSrmmWindow(MCONTACT hContact, bool bIncoming) - : CScriverWindow(IDD_MSG), +CMsgDialog::CMsgDialog(MCONTACT hContact, bool bIncoming) : + CSuper(g_plugin, IDD_MSG), m_bIncoming(bIncoming), - m_splitter(this, IDC_SPLITTERY), + m_splitterX(this, IDC_SPLITTERX), + m_splitterY(this, IDC_SPLITTERY), m_btnOk(this, IDOK), m_btnAdd(this, IDC_ADD), @@ -160,27 +161,55 @@ CSrmmWindow::CSrmmWindow(MCONTACT hContact, bool bIncoming) { m_hContact = hContact; - m_hwndParent = GetParentWindow(hContact, false); - - 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_btnUserMenu.OnClick = Callback(this, &CSrmmWindow::onClick_UserMenu); + m_btnAdd.OnClick = Callback(this, &CMsgDialog::onClick_Add); + m_btnQuote.OnClick = Callback(this, &CMsgDialog::onClick_Quote); + m_btnDetails.OnClick = Callback(this, &CMsgDialog::onClick_Details); + m_btnUserMenu.OnClick = Callback(this, &CMsgDialog::onClick_UserMenu); - m_message.OnChange = Callback(this, &CSrmmWindow::onChange_Message); + Init(); +} + +CMsgDialog::CMsgDialog(SESSION_INFO *si) : + CSuper(g_plugin, IDD_MSG, si), + m_splitterX(this, IDC_SPLITTERX), + m_splitterY(this, IDC_SPLITTERY), + + m_btnOk(this, IDOK), + m_btnAdd(this, IDC_ADD), + m_btnQuote(this, IDC_QUOTE), + m_btnDetails(this, IDC_DETAILS), + m_btnUserMenu(this, IDC_USERMENU) +{ + m_btnFilter.OnClick = Callback(this, &CMsgDialog::onClick_Filter); + m_btnNickList.OnClick = Callback(this, &CMsgDialog::onClick_ShowList); + + m_splitterX.OnChange = Callback(this, &CMsgDialog::onChange_SplitterX); + + Init(); +} + +void CMsgDialog::Init() +{ + m_autoClose = CLOSE_ON_CANCEL; + m_szProto = GetContactProto(m_hContact); - m_splitter.OnChange = Callback(this, &CSrmmWindow::onChanged_Splitter); + SetParent(GetParentWindow(m_hContact, isChat())); + m_pParent = (ParentWindowData *)GetWindowLongPtr(m_hwndParent, GWLP_USERDATA); + + m_btnOk.OnClick = Callback(this, &CMsgDialog::onClick_Ok); + + m_message.OnChange = Callback(this, &CMsgDialog::onChange_Message); + m_splitterY.OnChange = Callback(this, &CMsgDialog::onChange_SplitterY); } -bool CSrmmWindow::OnInitDialog() +bool CMsgDialog::OnInitDialog() { CSuper::OnInitDialog(); - NotifyEvent(MSG_WINDOW_EVT_OPENING); + if (m_si) + m_si->pDlg = this; - m_pParent = (ParentWindowData *)GetWindowLongPtr(m_hwndParent, GWLP_USERDATA); - m_szProto = GetContactProto(m_hContact); + NotifyEvent(MSG_WINDOW_EVT_OPENING); if (m_hContact && m_szProto != nullptr) m_wStatus = db_get_w(m_hContact, m_szProto, "Status", ID_STATUS_OFFLINE); @@ -234,6 +263,10 @@ bool CSrmmWindow::OnInitDialog() m_minEditBoxHeight = g_dat.minInputAreaHeight; if (m_pParent->iSplitterY == -1) m_pParent->iSplitterY = m_minEditBoxHeight; + if (m_pParent->iSplitterX == -1) { + GetWindowRect(m_nickList.GetHwnd(), &rc); + m_pParent->iSplitterX = rc.right - rc.left; + } SetMinSize(BOTTOM_RIGHT_AVATAR_HEIGHT, m_minLogBoxHeight + TOOLBAR_HEIGHT + m_minEditBoxHeight + max(INFO_BAR_HEIGHT, BOTTOM_RIGHT_AVATAR_HEIGHT - TOOLBAR_HEIGHT) + 5); @@ -255,11 +288,13 @@ bool CSrmmWindow::OnInitDialog() m_log.SendMsg(EM_SETEDITSTYLE, SES_EXTENDBACKCOLOR, SES_EXTENDBACKCOLOR); m_log.SendMsg(EM_SETLANGOPTIONS, 0, (LPARAM)m_log.SendMsg(EM_GETLANGOPTIONS, 0, 0) & ~(IMF_AUTOKEYBOARD | IMF_AUTOFONTSIZEADJUST)); m_log.SendMsg(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(0, 0)); + m_log.SendMsg(EM_LIMITTEXT, sizeof(wchar_t) * 0x7FFFFFFF, 0); + m_log.SendMsg(EM_HIDESELECTION, TRUE, 0); m_log.SendMsg(EM_AUTOURLDETECT, TRUE, 0); m_message.SetReadOnly(false); m_message.SendMsg(EM_SETLANGOPTIONS, 0, (LPARAM)m_message.SendMsg(EM_GETLANGOPTIONS, 0, 0) & ~IMF_AUTOKEYBOARD); - m_message.SendMsg(EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS | ENM_KEYEVENTS | ENM_CHANGE); + m_message.SendMsg(EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS | ENM_KEYEVENTS | ENM_CHANGE | ENM_REQUESTRESIZE); if (m_hContact && m_szProto) { int nMax = CallProtoService(m_szProto, PS_GETCAPS, PFLAG_MAXLENOFMESSAGE, m_hContact); if (nMax) @@ -284,95 +319,106 @@ bool CSrmmWindow::OnInitDialog() m_bUseIEView = false; } - bool notifyUnread = false; - if (m_hContact) { - int historyMode = g_plugin.iHistoryMode; - // This finds the first message to display, it works like shit - m_hDbEventFirst = db_event_firstUnread(m_hContact); - if (m_hDbEventFirst != 0) { + if (isChat()) { + UpdateOptions(); + UpdateStatusBar(); + UpdateTitle(); + UpdateNickList(); + } + else { + bool notifyUnread = false; + if (m_hContact) { + int historyMode = g_plugin.iHistoryMode; + // This finds the first message to display, it works like shit + m_hDbEventFirst = db_event_firstUnread(m_hContact); + if (m_hDbEventFirst != 0) { + DBEVENTINFO dbei = {}; + db_event_get(m_hDbEventFirst, &dbei); + if (DbEventIsMessageOrCustom(&dbei) && !(dbei.flags & DBEF_READ) && !(dbei.flags & DBEF_SENT)) + notifyUnread = true; + } + DBEVENTINFO dbei = {}; - db_event_get(m_hDbEventFirst, &dbei); - if (DbEventIsMessageOrCustom(&dbei) && !(dbei.flags & DBEF_READ) && !(dbei.flags & DBEF_SENT)) - notifyUnread = true; - } + MEVENT hPrevEvent; + switch (historyMode) { + case LOADHISTORY_COUNT: + for (int i = g_plugin.iLoadCount; i > 0; i--) { + if (m_hDbEventFirst == 0) + hPrevEvent = db_event_last(m_hContact); + else + hPrevEvent = db_event_prev(m_hContact, m_hDbEventFirst); + if (hPrevEvent == 0) + break; + dbei.cbBlob = 0; + m_hDbEventFirst = hPrevEvent; + db_event_get(m_hDbEventFirst, &dbei); + if (!DbEventIsShown(dbei)) + i++; + } + break; - DBEVENTINFO dbei = {}; - MEVENT hPrevEvent; - switch (historyMode) { - case LOADHISTORY_COUNT: - for (int i = g_plugin.iLoadCount; i > 0; i--) { - if (m_hDbEventFirst == 0) + case LOADHISTORY_TIME: + if (m_hDbEventFirst == 0) { + dbei.timestamp = time(0); hPrevEvent = db_event_last(m_hContact); - else + } + else { + db_event_get(m_hDbEventFirst, &dbei); hPrevEvent = db_event_prev(m_hContact, m_hDbEventFirst); - if (hPrevEvent == 0) - break; - dbei.cbBlob = 0; - m_hDbEventFirst = hPrevEvent; - db_event_get(m_hDbEventFirst, &dbei); - if (!DbEventIsShown(dbei)) - i++; - } - break; + } - case LOADHISTORY_TIME: - if (m_hDbEventFirst == 0) { - dbei.timestamp = time(0); - hPrevEvent = db_event_last(m_hContact); - } - else { - db_event_get(m_hDbEventFirst, &dbei); - hPrevEvent = db_event_prev(m_hContact, m_hDbEventFirst); + DWORD firstTime = dbei.timestamp - 60 * g_plugin.iLoadTime; + for (;;) { + if (hPrevEvent == 0) + break; + dbei.cbBlob = 0; + db_event_get(hPrevEvent, &dbei); + if (dbei.timestamp < firstTime) + break; + if (DbEventIsShown(dbei)) + m_hDbEventFirst = hPrevEvent; + hPrevEvent = db_event_prev(m_hContact, hPrevEvent); + } + break; } - - DWORD firstTime = dbei.timestamp - 60 * g_plugin.iLoadTime; - for (;;) { - if (hPrevEvent == 0) - break; - dbei.cbBlob = 0; - db_event_get(hPrevEvent, &dbei); - if (dbei.timestamp < firstTime) + } + + MEVENT hdbEvent = db_event_last(m_hContact); + if (hdbEvent) { + DBEVENTINFO dbei = {}; + do { + db_event_get(hdbEvent, &dbei); + if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT)) { + m_lastMessage = dbei.timestamp; break; - if (DbEventIsShown(dbei)) - m_hDbEventFirst = hPrevEvent; - hPrevEvent = db_event_prev(m_hContact, hPrevEvent); - } - break; + } + } while ((hdbEvent = db_event_prev(m_hContact, hdbEvent))); } - } - SendMessage(m_hwndParent, CM_ADDCHILD, (WPARAM)this, 0); - MEVENT hdbEvent = db_event_last(m_hContact); - if (hdbEvent) { - DBEVENTINFO dbei = {}; - do { - db_event_get(hdbEvent, &dbei); - if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT)) { - m_lastMessage = dbei.timestamp; - break; - } - } while ((hdbEvent = db_event_prev(m_hContact, hdbEvent))); - } + SendMessage(m_hwndParent, CM_POPUPWINDOW, m_bIncoming, (LPARAM)m_hwnd); + SendMessage(m_hwnd, DM_OPTIONSAPPLIED, 0, 0); - SendMessage(m_hwnd, DM_OPTIONSAPPLIED, 0, 0); - SendMessage(m_hwndParent, CM_POPUPWINDOW, m_bIncoming, (LPARAM)m_hwnd); - if (notifyUnread) { - if (GetForegroundWindow() != m_hwndParent || m_pParent->hwndActive != m_hwnd) { - m_iShowUnread = 1; - SendMessage(m_hwnd, DM_UPDATEICON, 0, 0); - SetTimer(m_hwnd, TIMERID_UNREAD, TIMEOUT_UNREAD, nullptr); + if (notifyUnread) { + if (GetForegroundWindow() != m_hwndParent || m_pParent->hwndActive != m_hwnd) { + m_iShowUnread = 1; + SendMessage(m_hwnd, DM_UPDATEICON, 0, 0); + SetTimer(m_hwnd, TIMERID_UNREAD, TIMEOUT_UNREAD, nullptr); + } + SendMessage(m_hwndParent, CM_STARTFLASHING, 0, 0); } - SendMessage(m_hwndParent, CM_STARTFLASHING, 0, 0); + + m_iMessagesInProgress = ReattachSendQueueItems(m_hwnd, m_hContact); + if (m_iMessagesInProgress > 0) + SendMessage(m_hwnd, DM_SHOWMESSAGESENDING, 0, 0); } - m_iMessagesInProgress = ReattachSendQueueItems(m_hwnd, m_hContact); - if (m_iMessagesInProgress > 0) - SendMessage(m_hwnd, DM_SHOWMESSAGESENDING, 0, 0); + + SendMessage(m_hwndParent, CM_ADDCHILD, (WPARAM)this, 0); NotifyEvent(MSG_WINDOW_EVT_OPEN); return true; } -void CSrmmWindow::OnDestroy() +void CMsgDialog::OnDestroy() { NotifyEvent(MSG_WINDOW_EVT_CLOSING); @@ -414,6 +460,9 @@ void CSrmmWindow::OnDestroy() db_delete_contact(m_hContact); } + if (m_si) + m_si->pDlg = nullptr; + SendMessage(m_hwndParent, CM_REMOVECHILD, 0, (LPARAM)m_hwnd); if (m_hwndIeview != nullptr) { IEVIEWWINDOW ieWindow = { sizeof(ieWindow) }; @@ -423,14 +472,17 @@ void CSrmmWindow::OnDestroy() } NotifyEvent(MSG_WINDOW_EVT_CLOSE); + mir_free(m_wszSearchQuery); + mir_free(m_wszSearchResult); + CSuper::OnDestroy(); } ///////////////////////////////////////////////////////////////////////////////////////// -void CSrmmWindow::onClick_Ok(CCtrlButton *pButton) +void CMsgDialog::onClick_Ok(CCtrlButton *pButton) { - if (!m_btnOk.Enabled() || m_hContact == 0) + if (!pButton->Enabled() || m_hContact == 0) return; PARAFORMAT2 pf2; @@ -451,7 +503,7 @@ void CSrmmWindow::onClick_Ok(CCtrlButton *pButton) if (Utils_IsRtl(ptrW(mir_utf8decodeW(msi.sendBuffer)))) msi.flags |= PREF_RTL; - /* Store messaging history */ + // Store messaging history TCmdList *cmdListNew = tcmdlist_last(cmdList); while (cmdListNew != nullptr && cmdListNew->temporary) { cmdList = tcmdlist_remove(cmdList, cmdListNew); @@ -466,17 +518,33 @@ void CSrmmWindow::onClick_Ok(CCtrlButton *pButton) NotifyTyping(PROTOTYPE_SELFTYPING_OFF); m_message.SetText(L""); - EnableWindow(GetDlgItem(m_hwnd, IDOK), FALSE); + m_btnOk.Disable(); if (g_plugin.bAutoMin) 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); + if (isChat()) { + CMStringW ptszText(ptrW(mir_utf8decodeW(msi.sendBuffer))); + g_chatApi.DoRtfToTags(ptszText, 0, nullptr); + ptszText.Trim(); + ptszText.Replace(L"%", L"%%"); + + if (m_si->pMI->bAckMsg) { + EnableWindow(m_message.GetHwnd(), FALSE); + m_message.SendMsg(EM_SETREADONLY, TRUE, 0); + } + else m_message.SetText(L""); + + Chat_DoEventHook(m_si, GC_USER_MESSAGE, nullptr, ptszText, 0); + } + else { + 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) +void CMsgDialog::onClick_UserMenu(CCtrlButton *pButton) { if (GetKeyState(VK_SHIFT) & 0x8000) // copy user name SendMessage(m_hwnd, DM_USERNAMETOCLIP, 0, 0); @@ -489,7 +557,7 @@ void CSrmmWindow::onClick_UserMenu(CCtrlButton *pButton) } } -void CSrmmWindow::onClick_Quote(CCtrlButton*) +void CMsgDialog::onClick_Quote(CCtrlButton*) { if (m_hDbEventLast == 0) return; @@ -535,7 +603,7 @@ void CSrmmWindow::onClick_Quote(CCtrlButton*) SetFocus(m_message.GetHwnd()); } -void CSrmmWindow::onClick_Add(CCtrlButton*) +void CMsgDialog::onClick_Add(CCtrlButton*) { Contact_Add(m_hContact, m_hwnd); @@ -543,22 +611,24 @@ void CSrmmWindow::onClick_Add(CCtrlButton*) ShowWindow(GetDlgItem(m_hwnd, IDC_ADD), SW_HIDE); } -void CSrmmWindow::onClick_Details(CCtrlButton*) +void CMsgDialog::onClick_Details(CCtrlButton*) { CallService(MS_USERINFO_SHOWDIALOG, m_hContact, 0); } -void CSrmmWindow::onClick_History(CCtrlButton*) +void CMsgDialog::onClick_History(CCtrlButton*) { CallService(MS_HISTORY_SHOWCONTACTHISTORY, m_hContact, 0); } -void CSrmmWindow::onChange_Message(CCtrlEdit*) +void CMsgDialog::onChange_Message(CCtrlEdit*) { - int len = m_message.GetRichTextLength(); cmdListCurrent = nullptr; + + int len = m_message.GetRichTextLength(); UpdateReadChars(); EnableWindow(GetDlgItem(m_hwnd, IDOK), len != 0); + if (!(GetKeyState(VK_CONTROL) & 0x8000) && !(GetKeyState(VK_SHIFT) & 0x8000)) { m_nLastTyping = GetTickCount(); if (len != 0) { @@ -570,7 +640,19 @@ void CSrmmWindow::onChange_Message(CCtrlEdit*) } } -void CSrmmWindow::onChanged_Splitter(CSplitter *pSplitter) +void CMsgDialog::onChange_SplitterX(CSplitter *pSplitter) +{ + RECT rc; + GetClientRect(m_hwnd, &rc); + + m_pParent->iSplitterX = rc.right - pSplitter->GetPos() + 1; + if (m_pParent->iSplitterX < 35) + m_pParent->iSplitterX = 35; + if (m_pParent->iSplitterX > rc.right - rc.left - 35) + m_pParent->iSplitterX = rc.right - rc.left - 35; +} + +void CMsgDialog::onChange_SplitterY(CSplitter *pSplitter) { RECT rc; GetClientRect(m_hwnd, &rc); @@ -579,7 +661,12 @@ void CSrmmWindow::onChanged_Splitter(CSplitter *pSplitter) ///////////////////////////////////////////////////////////////////////////////////////// -HICON CSrmmWindow::GetTabIcon() +void CMsgDialog::CloseTab() +{ + Close(); +} + +HICON CMsgDialog::GetTabIcon() { if (m_bShowTyping) return g_plugin.getIcon(IDI_TYPING); @@ -590,7 +677,7 @@ HICON CSrmmWindow::GetTabIcon() return m_hStatusIcon; } -void CSrmmWindow::GetTitlebarIcon(TitleBarData *tbd) +void CMsgDialog::GetTitlebarIcon(TitleBarData *tbd) { if (m_bShowTyping && g_dat.flags2.bShowTypingWin) tbd->hIconNot = tbd->hIcon = g_plugin.getIcon(IDI_TYPING); @@ -605,7 +692,7 @@ void CSrmmWindow::GetTitlebarIcon(TitleBarData *tbd) tbd->hIconBig = m_hStatusIconBig; } -bool CSrmmWindow::IsTypingNotificationSupported() +bool CMsgDialog::IsTypingNotificationSupported() { if (!m_hContact || !m_szProto) return false; @@ -616,7 +703,7 @@ bool CSrmmWindow::IsTypingNotificationSupported() return true; } -bool CSrmmWindow::IsTypingNotificationEnabled() +bool CMsgDialog::IsTypingNotificationEnabled() { if (!g_plugin.getByte(m_hContact, SRMSGSET_TYPING, g_plugin.bTypingNew)) return FALSE; @@ -637,13 +724,19 @@ bool CSrmmWindow::IsTypingNotificationEnabled() return TRUE; } +void CMsgDialog::LoadSettings() +{ + m_clrInputBG = g_plugin.getDword(SRMSGSET_INPUTBKGCOLOUR, SRMSGDEFSET_INPUTBKGCOLOUR); + LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, nullptr, &m_clrInputFG); +} + // Don't send to protocols who don't support typing // Don't send to users who are unchecked in the typing notification options // Don't send to protocols that are offline // Don't send to users who are not visible and // Don't send to users who are not on the visible list when you are in invisible mode. -void CSrmmWindow::NotifyTyping(int mode) +void CMsgDialog::NotifyTyping(int mode) { if (!IsTypingNotificationSupported()) return; @@ -656,7 +749,57 @@ void CSrmmWindow::NotifyTyping(int mode) CallService(MS_PROTO_SELFISTYPING, m_hContact, m_nTypeMode); } -void CSrmmWindow::ScrollToBottom() +void CMsgDialog::Reattach(HWND hwndContainer) +{ + MCONTACT hContact = m_hContact; + + POINT pt; + GetCursorPos(&pt); + HWND hParent = WindowFromPoint(pt); + while (GetParent(hParent) != nullptr) + hParent = GetParent(hParent); + + hParent = WindowList_Find(g_dat.hParentWindowList, (UINT_PTR)hParent); + if ((hParent != nullptr && hParent != hwndContainer) || (hParent == nullptr && m_pParent->childrenCount > 1 && (GetKeyState(VK_CONTROL) & 0x8000))) { + if (hParent == nullptr) { + hParent = GetParentWindow(hContact, false); + + RECT rc; + GetWindowRect(hParent, &rc); + + rc.right = (rc.right - rc.left); + rc.bottom = (rc.bottom - rc.top); + rc.left = pt.x - rc.right / 2; + rc.top = pt.y - rc.bottom / 2; + HMONITOR hMonitor = MonitorFromRect(&rc, MONITOR_DEFAULTTONEAREST); + + MONITORINFO mi; + mi.cbSize = sizeof(mi); + GetMonitorInfo(hMonitor, &mi); + + RECT rcDesktop = mi.rcWork; + if (rc.left < rcDesktop.left) + rc.left = rcDesktop.left; + if (rc.top < rcDesktop.top) + rc.top = rcDesktop.top; + MoveWindow(hParent, rc.left, rc.top, rc.right, rc.bottom, FALSE); + } + NotifyEvent(MSG_WINDOW_EVT_CLOSING); + NotifyEvent(MSG_WINDOW_EVT_CLOSE); + SetParent(hParent); + SendMessage(hwndContainer, CM_REMOVECHILD, 0, (LPARAM)m_hwnd); + SendMessage(m_hwnd, DM_SETPARENT, 0, (LPARAM)hParent); + SendMessage(hParent, CM_ADDCHILD, (WPARAM)this, 0); + SendMessage(m_hwnd, DM_UPDATETABCONTROL, 0, 0); + SendMessage(hParent, CM_ACTIVATECHILD, 0, (LPARAM)m_hwnd); + NotifyEvent(MSG_WINDOW_EVT_OPENING); + NotifyEvent(MSG_WINDOW_EVT_OPEN); + ShowWindow(hParent, SW_SHOWNA); + EnableWindow(hParent, TRUE); + } +} + +void CMsgDialog::ScrollToBottom() { if (m_hwndIeview != nullptr) { IEVIEWWINDOW ieWindow; @@ -679,33 +822,31 @@ void CSrmmWindow::ScrollToBottom() PostMessage(m_log.GetHwnd(), WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0); } } - RedrawWindow(m_log.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW); } } -void CSrmmWindow::SetDialogToType() +void CMsgDialog::SetDialogToType() { - BOOL showToolbar = SendMessage(m_hwndParent, CM_GETTOOLBARSTATUS, 0, 0); - if (m_hContact == 0) - showToolbar = false; + if (!isChat()) { + ParentWindowData *pdat = m_pParent; + if (pdat->flags2.bShowInfoBar) + ShowWindow(m_hwndInfo, SW_SHOW); + else + ShowWindow(m_hwndInfo, SW_HIDE); - ParentWindowData *pdat = m_pParent; - if (pdat->flags2.bShowInfoBar) - ShowWindow(m_hwndInfo, SW_SHOW); - else - ShowWindow(m_hwndInfo, SW_HIDE); + SendMessage(m_hwnd, DM_CLISTSETTINGSCHANGED, 0, 0); + UpdateReadChars(); + } m_message.Show(); m_log.Show(m_hwndIeview == nullptr); - m_splitter.Show(); - UpdateReadChars(); - EnableWindow(GetDlgItem(m_hwnd, IDOK), m_message.GetRichTextLength() != 0); - SendMessage(m_hwnd, DM_CLISTSETTINGSCHANGED, 0, 0); + m_splitterY.Show(); + m_btnOk.Enable(m_message.GetRichTextLength() != 0); Resize(); } -void CSrmmWindow::SetStatusIcon() +void CMsgDialog::SetStatusIcon() { if (m_szProto == nullptr) return; @@ -725,7 +866,7 @@ void CSrmmWindow::SetStatusIcon() m_hStatusIconOverlay = ImageList_GetIcon(g_dat.hHelperIconList, index, ILD_TRANSPARENT | INDEXTOOVERLAYMASK(1)); } -void CSrmmWindow::ShowAvatar() +void CMsgDialog::ShowAvatar() { INT_PTR res = CallService(MS_AV_GETAVATARBITMAP, m_hContact, 0); m_ace = res != CALLSERVICE_NOTFOUND ? (AVATARCACHEENTRY*)res : nullptr; @@ -737,9 +878,30 @@ void CSrmmWindow::ShowAvatar() RedrawWindow(GetDlgItem(m_hwnd, IDC_AVATAR), nullptr, nullptr, RDW_INVALIDATE); } -void CSrmmWindow::UpdateStatusBar() +void CMsgDialog::UpdateStatusBar() { - if (m_pParent->hwndActive == m_hwnd) { + if (m_pParent->hwndActive != m_hwnd) + return; + + if (isChat()) { + wchar_t szTemp[512]; + mir_snwprintf(szTemp, L"%s : %s", m_si->pMI->ptszModDispName, m_si->ptszStatusbarText ? m_si->ptszStatusbarText : L""); + + StatusBarData sbd; + sbd.iItem = 0; + sbd.iFlags = SBDF_TEXT | SBDF_ICON; + sbd.hIcon = m_si->wStatus == ID_STATUS_ONLINE ? m_si->pMI->hOnlineIcon : m_si->pMI->hOfflineIcon; + sbd.pszText = szTemp; + SendMessage(m_hwndParent, CM_UPDATESTATUSBAR, (WPARAM)& sbd, (LPARAM)m_hwnd); + + sbd.iItem = 1; + sbd.hIcon = nullptr; + sbd.pszText = L""; + SendMessage(m_hwndParent, CM_UPDATESTATUSBAR, (WPARAM)& sbd, (LPARAM)m_hwnd); + + Srmm_SetIconFlags(m_hContact, SRMM_MODULE, 0, 0); + } + else { wchar_t szText[256]; StatusBarData sbd = { 0 }; sbd.iFlags = SBDF_TEXT | SBDF_ICON; @@ -776,7 +938,7 @@ void CSrmmWindow::UpdateStatusBar() } } -void CSrmmWindow::UpdateReadChars() +void CMsgDialog::UpdateReadChars() { if (m_pParent->hwndActive == m_hwnd) { wchar_t szText[256]; @@ -796,108 +958,183 @@ void CSrmmWindow::UpdateReadChars() static const wchar_t *titleTokenNames[] = { L"%name%", L"%status%", L"%statusmsg%", L"%account%" }; -void CSrmmWindow::UpdateTitle() +void CMsgDialog::UpdateTitle() { + TitleBarData tbd = {}; + tbd.iFlags = TBDF_TEXT | TBDF_ICON; + CMStringW wszTitle; - if (g_dat.wszTitleFormat[0]) - wszTitle = g_dat.wszTitleFormat; - else - wszTitle = L"%name% - "; + if (isChat()) { + tbd.hIcon = (m_si->wStatus == ID_STATUS_ONLINE) ? m_si->pMI->hOnlineIcon : m_si->pMI->hOfflineIcon; + tbd.hIconBig = (m_si->wStatus == ID_STATUS_ONLINE) ? m_si->pMI->hOnlineIconBig : m_si->pMI->hOfflineIconBig; + tbd.hIconNot = (m_si->wState & (GC_EVENT_HIGHLIGHT | STATE_TALK)) ? g_plugin.getIcon(IDI_OVERLAY) : nullptr; + + int nUsers = m_si->getUserList().getCount(); + switch (m_si->iType) { + case GCW_CHATROOM: + wszTitle.Format((nUsers == 1) ? TranslateT("%s: chat room (%u user)") : TranslateT("%s: chat room (%u users)"), m_si->ptszName, nUsers); + break; + case GCW_PRIVMESS: + wszTitle.Format((nUsers == 1) ? TranslateT("%s: message session") : TranslateT("%s: message session (%u users)"), m_si->ptszName, nUsers); + break; + case GCW_SERVER: + wszTitle.Format(L"%s: Server", m_si->ptszName); + break; + } + } + else { + if (g_dat.wszTitleFormat[0]) + wszTitle = g_dat.wszTitleFormat; + else + wszTitle = L"%name% - "; - if (m_hContact && m_szProto) { - wszTitle.Replace(L"%name%", Clist_GetContactDisplayName(m_hContact)); - wszTitle.Replace(L"%status%", Clist_GetStatusModeDescription(db_get_w(m_hContact, m_szProto, "Status", ID_STATUS_OFFLINE), 0)); + if (m_hContact && m_szProto) { + wszTitle.Replace(L"%name%", Clist_GetContactDisplayName(m_hContact)); + wszTitle.Replace(L"%status%", Clist_GetStatusModeDescription(db_get_w(m_hContact, m_szProto, "Status", ID_STATUS_OFFLINE), 0)); - CMStringW tszStatus = ptrW(db_get_wsa(m_hContact, "CList", "StatusMsg")); - tszStatus.Replace(L"\r\n", L" "); - wszTitle.Replace(L"%statusmsg%", tszStatus); + CMStringW tszStatus = ptrW(db_get_wsa(m_hContact, "CList", "StatusMsg")); + tszStatus.Replace(L"\r\n", L" "); + wszTitle.Replace(L"%statusmsg%", tszStatus); - char *accModule = Proto_GetBaseAccountName(m_hContact); - if (accModule != nullptr) { - PROTOACCOUNT *proto = Proto_GetAccount(accModule); - if (proto != nullptr) - wszTitle.Replace(L"%account%", proto->tszAccountName); + char *accModule = Proto_GetBaseAccountName(m_hContact); + if (accModule != nullptr) { + PROTOACCOUNT *proto = Proto_GetAccount(accModule); + if (proto != nullptr) + wszTitle.Replace(L"%account%", proto->tszAccountName); + } } - } - if (g_dat.wszTitleFormat[0] == 0) - wszTitle.Append(TranslateT("Message session")); + if (g_dat.wszTitleFormat[0] == 0) + wszTitle.Append(TranslateT("Message session")); + + GetTitlebarIcon(&tbd); + } - TitleBarData tbd = {}; - tbd.iFlags = TBDF_TEXT | TBDF_ICON; - GetTitlebarIcon(&tbd); tbd.pszText = wszTitle.GetBuffer(); SendMessage(m_hwndParent, CM_UPDATETITLEBAR, (WPARAM)&tbd, (LPARAM)m_hwnd); + + if (isChat()) + SendMessage(m_hwnd, DM_UPDATETABCONTROL, 0, 0); } ///////////////////////////////////////////////////////////////////////////////////////// -void CSrmmWindow::MessageDialogResize(int w, int h) +void CMsgDialog::MessageDialogResize(int w, int h) { ParentWindowData *pdat = m_pParent; - bool bToolbar = (pdat->flags2.bShowToolBar) != 0; - int hSplitterPos = pdat->iSplitterY, toolbarHeight = (bToolbar) ? TOOLBAR_HEIGHT : 0; - int hSplitterMinTop = toolbarHeight + m_minLogBoxHeight, hSplitterMinBottom = m_minEditBoxHeight; - int infobarInnerHeight = INFO_BAR_INNER_HEIGHT; - int infobarHeight = INFO_BAR_HEIGHT; - int avatarWidth = 0, avatarHeight = 0; - int toolbarWidth = w; - int messageEditWidth = w - 2; - - if (hSplitterMinBottom < g_dat.minInputAreaHeight) - hSplitterMinBottom = g_dat.minInputAreaHeight; - - if (!pdat->flags2.bShowInfoBar) { - infobarHeight = 0; - infobarInnerHeight = 0; + bool bToolbar = pdat->flags2.bShowToolBar; + int logY, logH; + + if (isChat()) { + bool bNick = m_si->iType != GCW_SERVER && m_bNicklistEnabled; + int hSplitterMinTop = TOOLBAR_HEIGHT + m_minLogBoxHeight, hSplitterMinBottom = m_minEditBoxHeight; + int toolbarHeight = bToolbar ? TOOLBAR_HEIGHT : 0; + + if (h - pdat->iSplitterY < hSplitterMinTop) + pdat->iSplitterY = h - hSplitterMinTop; + if (pdat->iSplitterY < hSplitterMinBottom) + pdat->iSplitterY = hSplitterMinBottom; + + m_splitterX.Show(bNick); + if (m_si->iType != GCW_SERVER) + m_nickList.Show(m_bNicklistEnabled); + else + m_nickList.Hide(); + + if (m_si->iType == GCW_SERVER) { + m_btnNickList.Enable(false); + m_btnFilter.Enable(false); + m_btnChannelMgr.Enable(false); + } + else { + m_btnNickList.Enable(true); + m_btnFilter.Enable(true); + if (m_si->iType == GCW_CHATROOM) + m_btnChannelMgr.Enable(m_si->pMI->bChanMgr); + } + + logY = h - pdat->iSplitterY; + if (bToolbar) + logY -= toolbarHeight; + logH = logY; + + HDWP hdwp = BeginDeferWindowPos(5); + hdwp = DeferWindowPos(hdwp, m_log.GetHwnd(), nullptr, 1, 0, bNick ? w - pdat->iSplitterX - 1 : w - 2, logH, SWP_NOZORDER); + hdwp = DeferWindowPos(hdwp, m_nickList.GetHwnd(), nullptr, w - pdat->iSplitterX + 2, 0, pdat->iSplitterX - 3, logY, SWP_NOZORDER); + hdwp = DeferWindowPos(hdwp, m_splitterX.GetHwnd(), nullptr, w - pdat->iSplitterX, 1, 2, logY - 1, SWP_NOZORDER); + hdwp = DeferWindowPos(hdwp, m_splitterY.GetHwnd(), nullptr, 0, h - pdat->iSplitterY, w, SPLITTER_HEIGHT, SWP_NOZORDER); + hdwp = DeferWindowPos(hdwp, m_message.GetHwnd(), nullptr, 1, h - pdat->iSplitterY + SPLITTER_HEIGHT, w - 2, pdat->iSplitterY - SPLITTER_HEIGHT - 1, SWP_NOZORDER); + EndDeferWindowPos(hdwp); + + RedrawWindow(m_nickList.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE); } + else { + int hSplitterPos = pdat->iSplitterY, toolbarHeight = (bToolbar) ? TOOLBAR_HEIGHT : 0; + int hSplitterMinTop = toolbarHeight + m_minLogBoxHeight, hSplitterMinBottom = m_minEditBoxHeight; + int infobarInnerHeight = INFO_BAR_INNER_HEIGHT; + int infobarHeight = INFO_BAR_HEIGHT; + int avatarWidth = 0, avatarHeight = 0; + int toolbarWidth = w; + int messageEditWidth = w - 2; + + if (hSplitterMinBottom < g_dat.minInputAreaHeight) + hSplitterMinBottom = g_dat.minInputAreaHeight; + + if (!pdat->flags2.bShowInfoBar) { + infobarHeight = 0; + infobarInnerHeight = 0; + } - if (hSplitterPos > (h - toolbarHeight - infobarHeight + SPLITTER_HEIGHT + 1) / 2) - hSplitterPos = (h - toolbarHeight - infobarHeight + SPLITTER_HEIGHT + 1) / 2; + if (hSplitterPos > (h - toolbarHeight - infobarHeight + SPLITTER_HEIGHT + 1) / 2) + hSplitterPos = (h - toolbarHeight - infobarHeight + SPLITTER_HEIGHT + 1) / 2; - if (h - hSplitterPos - infobarHeight < hSplitterMinTop) - hSplitterPos = h - hSplitterMinTop - infobarHeight; + if (h - hSplitterPos - infobarHeight < hSplitterMinTop) + hSplitterPos = h - hSplitterMinTop - infobarHeight; - if (hSplitterPos < avatarHeight) - hSplitterPos = avatarHeight; + if (hSplitterPos < avatarHeight) + hSplitterPos = avatarHeight; - if (hSplitterPos < hSplitterMinBottom) - hSplitterPos = hSplitterMinBottom; + if (hSplitterPos < hSplitterMinBottom) + hSplitterPos = hSplitterMinBottom; - if (!pdat->flags2.bShowInfoBar) { - if (m_hbmpAvatarPic && g_dat.flags.bShowAvatar) { - avatarWidth = BOTTOM_RIGHT_AVATAR_HEIGHT; - avatarHeight = toolbarHeight + hSplitterPos - 2; - if (avatarHeight < BOTTOM_RIGHT_AVATAR_HEIGHT) { - avatarHeight = BOTTOM_RIGHT_AVATAR_HEIGHT; - hSplitterPos = avatarHeight - toolbarHeight + 2; - } - else avatarHeight = BOTTOM_RIGHT_AVATAR_HEIGHT; + if (!pdat->flags2.bShowInfoBar) { + if (m_hbmpAvatarPic && g_dat.flags.bShowAvatar) { + avatarWidth = BOTTOM_RIGHT_AVATAR_HEIGHT; + avatarHeight = toolbarHeight + hSplitterPos - 2; + if (avatarHeight < BOTTOM_RIGHT_AVATAR_HEIGHT) { + avatarHeight = BOTTOM_RIGHT_AVATAR_HEIGHT; + hSplitterPos = avatarHeight - toolbarHeight + 2; + } + else avatarHeight = BOTTOM_RIGHT_AVATAR_HEIGHT; - avatarWidth = avatarHeight; - if (avatarWidth > BOTTOM_RIGHT_AVATAR_HEIGHT && avatarWidth > w / 4) - avatarWidth = w / 4; + avatarWidth = avatarHeight; + if (avatarWidth > BOTTOM_RIGHT_AVATAR_HEIGHT && avatarWidth > w / 4) + avatarWidth = w / 4; - if ((toolbarWidth - avatarWidth - 2) < 0) - avatarWidth = toolbarWidth - 2; + if ((toolbarWidth - avatarWidth - 2) < 0) + avatarWidth = toolbarWidth - 2; - toolbarWidth -= avatarWidth + 2; - messageEditWidth -= avatarWidth + 1; + toolbarWidth -= avatarWidth + 2; + messageEditWidth -= avatarWidth + 1; + } } - } - pdat->iSplitterY = hSplitterPos; + pdat->iSplitterY = hSplitterPos; - int logY = infobarInnerHeight; - int logH = h - hSplitterPos - toolbarHeight - infobarInnerHeight - SPLITTER_HEIGHT; + logY = infobarInnerHeight; + logH = h - hSplitterPos - toolbarHeight - infobarInnerHeight - SPLITTER_HEIGHT; - HDWP hdwp = BeginDeferWindowPos(5); - hdwp = DeferWindowPos(hdwp, m_hwndInfo, nullptr, 1, 0, w - 2, infobarInnerHeight - 2, SWP_NOZORDER); - hdwp = DeferWindowPos(hdwp, m_log.GetHwnd(), nullptr, 1, logY, w - 2, logH, SWP_NOZORDER); - hdwp = DeferWindowPos(hdwp, m_message.GetHwnd(), nullptr, 1, h - hSplitterPos - 1, messageEditWidth, hSplitterPos, SWP_NOZORDER); - hdwp = DeferWindowPos(hdwp, GetDlgItem(m_hwnd, IDC_AVATAR), nullptr, w - avatarWidth - 1, h - (avatarHeight + avatarWidth) / 2 - 1, avatarWidth, avatarWidth, SWP_NOZORDER); - hdwp = DeferWindowPos(hdwp, m_splitter.GetHwnd(), nullptr, 0, h - hSplitterPos - SPLITTER_HEIGHT - 1, toolbarWidth, SPLITTER_HEIGHT, SWP_NOZORDER); - EndDeferWindowPos(hdwp); + HDWP hdwp = BeginDeferWindowPos(5); + hdwp = DeferWindowPos(hdwp, m_hwndInfo, nullptr, 1, 0, w - 2, infobarInnerHeight - 2, SWP_NOZORDER); + hdwp = DeferWindowPos(hdwp, m_log.GetHwnd(), nullptr, 1, logY, w - 2, logH, SWP_NOZORDER); + hdwp = DeferWindowPos(hdwp, m_message.GetHwnd(), nullptr, 1, h - hSplitterPos - 1, messageEditWidth, hSplitterPos, SWP_NOZORDER); + hdwp = DeferWindowPos(hdwp, GetDlgItem(m_hwnd, IDC_AVATAR), nullptr, w - avatarWidth - 1, h - (avatarHeight + avatarWidth) / 2 - 1, avatarWidth, avatarWidth, SWP_NOZORDER); + hdwp = DeferWindowPos(hdwp, m_splitterY.GetHwnd(), nullptr, 0, h - hSplitterPos - SPLITTER_HEIGHT - 1, toolbarWidth, SPLITTER_HEIGHT, SWP_NOZORDER); + EndDeferWindowPos(hdwp); + + RefreshInfobar(); + RedrawWindow(GetDlgItem(m_hwnd, IDC_AVATAR), nullptr, nullptr, RDW_INVALIDATE); + } SetButtonsPos(m_hwnd, m_hContact, bToolbar); @@ -910,21 +1147,21 @@ void CSrmmWindow::MessageDialogResize(int w, int h) ieWindow.y = logY; ieWindow.cx = w; ieWindow.cy = logH; - CallService(MS_IEVIEW_WINDOW, 0, (LPARAM)&ieWindow); + CallService(MS_IEVIEW_WINDOW, 0, (LPARAM)& ieWindow); } else RedrawWindow(m_log.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE); RedrawWindow(m_message.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE); - - RefreshInfobar(); - - RedrawWindow(GetDlgItem(m_hwnd, IDC_AVATAR), nullptr, nullptr, RDW_INVALIDATE); } ///////////////////////////////////////////////////////////////////////////////////////// -LRESULT CSrmmWindow::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam) +LRESULT CMsgDialog::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam) { + int result = InputAreaShortcuts(m_log.GetHwnd(), msg, wParam, lParam); + if (result != -1) + return result; + switch (msg) { case WM_MEASUREITEM: MeasureMenuItem(wParam, lParam); @@ -933,6 +1170,19 @@ LRESULT CSrmmWindow::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam) case WM_DRAWITEM: return DrawMenuItem(wParam, lParam); + case WM_LBUTTONUP: + if (isChat()) { + CHARRANGE sel; + SendMessage(m_log.GetHwnd(), EM_EXGETSEL, 0, (LPARAM)&sel); + if (sel.cpMin != sel.cpMax) { + SendMessage(m_log.GetHwnd(), WM_COPY, 0, 0); + sel.cpMin = sel.cpMax; + SendMessage(m_log.GetHwnd(), EM_EXSETSEL, 0, (LPARAM)&sel); + } + SetFocus(m_message.GetHwnd()); + } + break; + case WM_CONTEXTMENU: HMENU hMenu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_CONTEXT)); HMENU hSubMenu = GetSubMenu(hMenu, 0); @@ -1006,7 +1256,7 @@ LRESULT CSrmmWindow::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam) return CSuper::WndProc_Log(msg, wParam, lParam); } -LRESULT CSrmmWindow::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) +LRESULT CMsgDialog::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) { int result = InputAreaShortcuts(m_message.GetHwnd(), msg, wParam, lParam); if (result != -1) @@ -1019,11 +1269,70 @@ LRESULT CSrmmWindow::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) return 0; } else m_iLastEnterTime = 0; + + if (isChat()) { + bool isShift = (GetKeyState(VK_SHIFT) & 0x8000) != 0; + bool isCtrl = (GetKeyState(VK_CONTROL) & 0x8000) != 0; + bool isAlt = (GetKeyState(VK_MENU) & 0x8000) != 0; + + if (wParam == VK_TAB && isShift && !isCtrl) { // SHIFT-TAB (go to nick list) + SetFocus(m_nickList.GetHwnd()); + return TRUE; + } + + if (wParam == VK_TAB && !isCtrl && !isShift) { // tab-autocomplete + m_message.SendMsg(WM_SETREDRAW, FALSE, 0); + TabAutoComplete(); + m_message.SendMsg(WM_SETREDRAW, TRUE, 0); + RedrawWindow(m_nickList.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE); + return 0; + } + + if (wParam != VK_RIGHT && wParam != VK_LEFT) { + replaceStrW(m_wszSearchQuery, nullptr); + replaceStrW(m_wszSearchResult, nullptr); + } + + if (ProcessHotkeys(wParam, isShift, isCtrl, isAlt)) + return TRUE; + + if (wParam == 0x4e && isCtrl && !isAlt) { // ctrl-n (nicklist) + if (m_btnNickList.Enabled()) + m_btnNickList.Click(); + return TRUE; + } + + if (wParam == 0x48 && isCtrl && !isAlt) { // ctrl-h (history) + m_btnHistory.Click(); + return TRUE; + } + + if (wParam == 0x4f && isCtrl && !isAlt) { // ctrl-o (options) + if (m_btnChannelMgr.Enabled()) + m_btnChannelMgr.Click(); + return TRUE; + } + + if (((wParam == VK_INSERT && isShift) || (wParam == 'V' && isCtrl)) && !isAlt) { // ctrl-v (paste clean text) + m_message.SendMsg(EM_PASTESPECIAL, CF_UNICODETEXT, 0); + return TRUE; + } + + if (wParam == VK_NEXT || wParam == VK_PRIOR) { + m_log.SendMsg(msg, wParam, lParam); + return TRUE; + } + } + break; + + case EM_ACTIVATE: + SetActiveWindow(m_hwnd); break; case WM_MOUSEWHEEL: if ((GetWindowLongPtr(m_message.GetHwnd(), GWL_STYLE) & WS_VSCROLL) == 0) m_log.SendMsg(WM_MOUSEWHEEL, wParam, lParam); + m_iLastEnterTime = 0; break; case WM_LBUTTONDOWN: @@ -1033,6 +1342,13 @@ LRESULT CSrmmWindow::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) m_iLastEnterTime = 0; break; + case WM_KEYUP: + case WM_LBUTTONUP: + case WM_RBUTTONUP: + case WM_MBUTTONUP: + RefreshButtonStatus(); + break; + case WM_SYSCHAR: m_iLastEnterTime = 0; if ((wParam == 's' || wParam == 'S') && (GetKeyState(VK_MENU) & 0x8000)) { @@ -1067,7 +1383,7 @@ LRESULT CSrmmWindow::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) ///////////////////////////////////////////////////////////////////////////////////////// -INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) +INT_PTR CMsgDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) { PARAFORMAT2 pf2; LPNMHDR pNmhdr; @@ -1091,7 +1407,10 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) break; case WM_LBUTTONDBLCLK: - SendMessage(m_hwndParent, WM_SYSCOMMAND, SC_MINIMIZE, 0); + if (LOWORD(lParam) < 30) + ScrollToBottom(); + else + SendMessage(m_hwndParent, WM_SYSCOMMAND, SC_MINIMIZE, 0); break; case WM_DROPFILES: @@ -1140,6 +1459,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) tbd.iFlags = TBDF_ICON; GetTitlebarIcon(&tbd); SendMessage(m_hwndParent, CM_UPDATETITLEBAR, (WPARAM)&tbd, (LPARAM)m_hwnd); + TabControlData tcd; tcd.iFlags = TCDF_ICON; tcd.hIcon = GetTabIcon(); @@ -1261,7 +1581,10 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) case DM_SWITCHINFOBAR: case DM_SWITCHTOOLBAR: - SetDialogToType(); + if (isChat()) + Resize(); + else + SetDialogToType(); break; case DM_SWITCHTYPING: @@ -1292,30 +1615,68 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) break; case DM_ACTIVATE: + if (isChat()) { + if (m_si->wState & STATE_TALK) { + m_si->wState &= ~STATE_TALK; + db_set_w(m_hContact, m_si->pszModule, "ApparentMode", 0); + } + + if (m_si->wState & GC_EVENT_HIGHLIGHT) { + m_si->wState &= ~GC_EVENT_HIGHLIGHT; + + if (g_clistApi.pfnGetEvent(m_hContact, 0)) + g_clistApi.pfnRemoveEvent(m_hContact, GC_FAKE_EVENT); + } + + FixTabIcons(); + if (!m_si->pDlg) { + ShowRoom(m_si); + SendMessage(m_hwnd, WM_MOUSEACTIVATE, 0, 0); + } + break; + } + __fallthrough; + case WM_ACTIVATE: if (LOWORD(wParam) != WA_ACTIVE) break; __fallthrough; case WM_MOUSEACTIVATE: - if (m_hDbUnreadEventFirst != 0) { - MEVENT hDbEvent = m_hDbUnreadEventFirst; - m_hDbUnreadEventFirst = 0; - while (hDbEvent != 0) { - DBEVENTINFO dbei = {}; - db_event_get(hDbEvent, &dbei); - if (!(dbei.flags & DBEF_SENT) && DbEventIsMessageOrCustom(&dbei)) - g_clistApi.pfnRemoveEvent(m_hContact, hDbEvent); - hDbEvent = db_event_next(m_hContact, hDbEvent); - } + if (isChat()) { + SetFocus(m_message.GetHwnd()); + + g_chatApi.SetActiveSession(m_si); + + if (db_get_w(m_hContact, m_si->pszModule, "ApparentMode", 0) != 0) + db_set_w(m_hContact, m_si->pszModule, "ApparentMode", 0); + if (g_clistApi.pfnGetEvent(m_hContact, 0)) + g_clistApi.pfnRemoveEvent(m_hContact, GC_FAKE_EVENT); } - if (m_iShowUnread) { - m_iShowUnread = 0; - KillTimer(m_hwnd, TIMERID_UNREAD); - SendMessage(m_hwnd, DM_UPDATEICON, 0, 0); + else { + if (m_hDbUnreadEventFirst != 0) { + MEVENT hDbEvent = m_hDbUnreadEventFirst; + m_hDbUnreadEventFirst = 0; + while (hDbEvent != 0) { + DBEVENTINFO dbei = {}; + db_event_get(hDbEvent, &dbei); + if (!(dbei.flags & DBEF_SENT) && DbEventIsMessageOrCustom(&dbei)) + g_clistApi.pfnRemoveEvent(m_hContact, hDbEvent); + hDbEvent = db_event_next(m_hContact, hDbEvent); + } + } + if (m_iShowUnread) { + m_iShowUnread = 0; + KillTimer(m_hwnd, TIMERID_UNREAD); + SendMessage(m_hwnd, DM_UPDATEICON, 0, 0); + } } break; + case WM_CTLCOLORLISTBOX: + SetBkColor((HDC)wParam, g_Settings.crUserListBGColor); + return (INT_PTR)g_chatApi.hListBkgBrush; + case WM_LBUTTONDOWN: SendMessage(m_hwndParent, WM_LBUTTONDOWN, wParam, lParam); return TRUE; @@ -1339,6 +1700,10 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) SetFocus(m_message.GetHwnd()); return TRUE; + case WM_KEYDOWN: + SetFocus(m_message.GetHwnd()); + break; + case WM_SETFOCUS: SendMessage(m_hwndParent, CM_ACTIVATECHILD, 0, (LPARAM)m_hwnd); g_dat.hFocusWnd = m_hwnd; @@ -1351,6 +1716,9 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) return TRUE; case WM_SIZE: + if (wParam == SIZE_MAXIMIZED) + ScrollToBottom(); + if (wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED) { RECT rc; GetClientRect(m_hwnd, &rc); @@ -1518,13 +1886,28 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) break; case WM_MEASUREITEM: - if (!MeasureMenuItem(wParam, lParam)) - return Menu_MeasureItem(lParam); + if (!MeasureMenuItem(wParam, lParam)) { + MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *)lParam; + if (mis->CtlType == ODT_MENU) + return Menu_MeasureItem(lParam); + + int ih = Chat_GetTextPixelSize(L"AQGgl'", g_Settings.UserListFont, false); + int ih2 = Chat_GetTextPixelSize(L"AQGg'", g_Settings.UserListHeadingsFont, false); + int font = ih > ih2 ? ih : ih2; + int height = db_get_b(0, CHAT_MODULE, "NicklistRowDist", 12); + // make sure we have space for icon! + if (db_get_b(0, CHAT_MODULE, "ShowContactStatus", 0)) + font = font > 16 ? font : 16; + mis->itemHeight = height > font ? height : font; + } return TRUE; case WM_DRAWITEM: if (!DrawMenuItem(wParam, lParam)) { LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam; + if (dis->CtlType == ODT_MENU) + return Menu_DrawItem(lParam); + if (dis->hwndItem == GetDlgItem(m_hwnd, IDC_AVATAR)) { int avatarWidth = 0, avatarHeight = 0; int itemWidth = dis->rcItem.right - dis->rcItem.left + 1, itemHeight = dis->rcItem.bottom - dis->rcItem.top + 1; @@ -1566,6 +1949,48 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) DeleteDC(hdcMem); return TRUE; } + + if (dis->CtlID == IDC_SRMM_NICKLIST) { + int index = dis->itemID; + USERINFO *ui = g_chatApi.SM_GetUserFromIndex(m_si->ptszID, m_si->pszModule, index); + if (ui) { + int x_offset = 2; + + int height = dis->rcItem.bottom - dis->rcItem.top; + if (height & 1) + height++; + + int offset = (height == 10) ? 0 : height / 2 - 5; + HFONT hFont = (ui->iStatusEx == 0) ? g_Settings.UserListFont : g_Settings.UserListHeadingsFont; + HFONT hOldFont = (HFONT)SelectObject(dis->hDC, hFont); + SetBkMode(dis->hDC, TRANSPARENT); + + if (dis->itemAction == ODA_FOCUS && dis->itemState & ODS_SELECTED) + FillRect(dis->hDC, &dis->rcItem, g_chatApi.hListSelectedBkgBrush); + else //if (dis->itemState & ODS_INACTIVE) + FillRect(dis->hDC, &dis->rcItem, g_chatApi.hListBkgBrush); + + if (g_Settings.bShowContactStatus && g_Settings.bContactStatusFirst && ui->ContactStatus) { + HICON hIcon = Skin_LoadProtoIcon(m_si->pszModule, ui->ContactStatus); + DrawIconEx(dis->hDC, x_offset, dis->rcItem.top + offset - 3, hIcon, 16, 16, 0, nullptr, DI_NORMAL); + IcoLib_ReleaseIcon(hIcon); + x_offset += 18; + } + DrawIconEx(dis->hDC, x_offset, dis->rcItem.top + offset, g_chatApi.SM_GetStatusIcon(m_si, ui), 10, 10, 0, nullptr, DI_NORMAL); + x_offset += 12; + if (g_Settings.bShowContactStatus && !g_Settings.bContactStatusFirst && ui->ContactStatus) { + HICON hIcon = Skin_LoadProtoIcon(m_si->pszModule, ui->ContactStatus); + DrawIconEx(dis->hDC, x_offset, dis->rcItem.top + offset - 3, hIcon, 16, 16, 0, nullptr, DI_NORMAL); + IcoLib_ReleaseIcon(hIcon); + x_offset += 18; + } + + SetTextColor(dis->hDC, ui->iStatusEx == 0 ? g_Settings.crUserListColor : g_Settings.crUserListHeadingsColor); + TextOut(dis->hDC, dis->rcItem.left + x_offset, dis->rcItem.top, ui->pszNick, (int)mir_wstrlen(ui->pszNick)); + SelectObject(dis->hDC, hOldFont); + } + return TRUE; + } } return Menu_DrawItem(lParam); @@ -1615,6 +2040,27 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) return TRUE; } break; + + case IDC_SRMM_NICKLIST: + if (pNmhdr->code == TTN_NEEDTEXT) { + LPNMTTDISPINFO lpttd = (LPNMTTDISPINFO)lParam; + SESSION_INFO *parentdat = (SESSION_INFO *)GetWindowLongPtr(m_hwnd, GWLP_USERDATA); + + POINT p; + GetCursorPos(&p); + ScreenToClient(m_nickList.GetHwnd(), &p); + int item = LOWORD(m_nickList.SendMsg(LB_ITEMFROMPOINT, 0, MAKELPARAM(p.x, p.y))); + USERINFO *ui = g_chatApi.SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, item); + if (ui != nullptr) { + static wchar_t ptszBuf[1024]; + mir_snwprintf(ptszBuf, L"%s: %s\r\n%s: %s\r\n%s: %s", + TranslateT("Nickname"), ui->pszNick, + TranslateT("Unique ID"), ui->pszUID, + TranslateT("Status"), g_chatApi.TM_WordToString(parentdat->pStatuses, ui->Status)); + lpttd->lpszText = ptszBuf; + } + } + break; } break; diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp index 13722cbb7d..3d9c18238d 100644 --- a/plugins/Scriver/src/msglog.cpp +++ b/plugins/Scriver/src/msglog.cpp @@ -36,36 +36,6 @@ static HIMAGELIST g_hImageList; #define STREAMSTAGE_TAIL 2 #define STREAMSTAGE_STOP 3 -struct EventData -{ - int cbSize; - int iType; - DWORD dwFlags; - const char *fontName; - int fontSize; - int fontStyle; - COLORREF color; - union { - char *pszNick; // Nick, usage depends on type of event - wchar_t *pszNickT; - wchar_t *pszNickW; // Nick - Unicode - }; - union { - char *pszText; // Text, usage depends on type of event - wchar_t *pszTextT; - wchar_t *pszTextW; // Text - Unicode - }; - union { - char *pszText2; // Text, usage depends on type of event - wchar_t *pszText2T; - wchar_t *pszText2W; // Text - Unicode - }; - DWORD time; - DWORD eventType; - BOOL custom; - EventData *next; -}; - struct LogStreamData { int stage; @@ -75,7 +45,7 @@ struct LogStreamData size_t bufferOffset, bufferLen; int eventsToInsert; int isFirst; - CSrmmWindow *dlgDat; + CMsgDialog *dlgDat; GlobalMessageData *gdat; EventData *events; }; @@ -106,7 +76,7 @@ int DbEventIsShown(DBEVENTINFO &dbei) return DbEventIsCustomForMsgWindow(&dbei); } -EventData* getEventFromDB(CSrmmWindow *dat, MCONTACT hContact, MEVENT hDbEvent) +EventData* CMsgDialog::GetEventFromDB(MCONTACT hContact, MEVENT hDbEvent) { DBEVENTINFO dbei = {}; dbei.cbBlob = db_event_getBlobSize(hDbEvent); @@ -133,26 +103,26 @@ EventData* getEventFromDB(CSrmmWindow *dat, MCONTACT hContact, MEVENT hDbEvent) evt->dwFlags = (dbei.flags & DBEF_READ ? IEEDF_READ : 0) | (dbei.flags & DBEF_SENT ? IEEDF_SENT : 0) | (dbei.flags & DBEF_RTL ? IEEDF_RTL : 0); evt->dwFlags |= IEEDF_UNICODE_TEXT | IEEDF_UNICODE_NICK | IEEDF_UNICODE_TEXT2; - if (dat->m_bUseRtl) + if (m_bUseRtl) evt->dwFlags |= IEEDF_RTL; evt->time = dbei.timestamp; - evt->pszNick = nullptr; + evt->szNick.w = nullptr; if (evt->dwFlags & IEEDF_SENT) - evt->pszNickT = Contact_GetInfo(CNF_DISPLAY, 0, dat->m_szProto); + evt->szNick.w = Contact_GetInfo(CNF_DISPLAY, 0, m_szProto); else - evt->pszNickT = mir_wstrdup(Clist_GetContactDisplayName(hContact)); + evt->szNick.w = mir_wstrdup(Clist_GetContactDisplayName(hContact)); if (evt->eventType == EVENTTYPE_FILE) { char *filename = ((char*)dbei.pBlob) + sizeof(DWORD); char *descr = filename + mir_strlen(filename) + 1; - evt->pszTextT = DbEvent_GetString(&dbei, filename); + evt->szText.w = DbEvent_GetString(&dbei, filename); if (*descr != 0) - evt->pszText2T = DbEvent_GetString(&dbei, descr); + evt->szText2.w = DbEvent_GetString(&dbei, descr); } - else evt->pszTextT = DbEvent_GetTextW(&dbei, CP_UTF8); + else evt->szText.w = DbEvent_GetTextW(&dbei, CP_UTF8); - if (!dat->m_bUseRtl && Utils_IsRtl(evt->pszTextT)) + if (!m_bUseRtl && Utils_IsRtl(evt->szText.w)) evt->dwFlags |= IEEDF_RTL; mir_free(dbei.pBlob); @@ -173,24 +143,24 @@ static EventData* GetTestEvents() { EventData *evt, *firstEvent, *prevEvent; firstEvent = prevEvent = evt = GetTestEvent(IEEDF_SENT); - evt->pszNickT = mir_wstrdup(TranslateT("Me")); - evt->pszTextT = mir_wstrdup(TranslateT("O Lord, bless this Thy hand grenade that with it Thou mayest blow Thine enemies")); + evt->szNick.w = mir_wstrdup(TranslateT("Me")); + evt->szText.w = mir_wstrdup(TranslateT("O Lord, bless this Thy hand grenade that with it Thou mayest blow Thine enemies")); evt = GetTestEvent(IEEDF_SENT); - evt->pszNickT = mir_wstrdup(TranslateT("Me")); - evt->pszTextT = mir_wstrdup(TranslateT("to tiny bits, in Thy mercy")); + evt->szNick.w = mir_wstrdup(TranslateT("Me")); + evt->szText.w = mir_wstrdup(TranslateT("to tiny bits, in Thy mercy")); prevEvent->next = evt; prevEvent = evt; evt = GetTestEvent(0); - evt->pszNickT = mir_wstrdup(TranslateT("My contact")); - evt->pszTextT = mir_wstrdup(TranslateT("Lorem ipsum dolor sit amet,")); + evt->szNick.w = mir_wstrdup(TranslateT("My contact")); + evt->szText.w = mir_wstrdup(TranslateT("Lorem ipsum dolor sit amet,")); prevEvent->next = evt; prevEvent = evt; evt = GetTestEvent(0); - evt->pszNickT = mir_wstrdup(TranslateT("My contact")); - evt->pszTextT = mir_wstrdup(TranslateT("consectetur adipisicing elit")); + evt->szNick.w = mir_wstrdup(TranslateT("My contact")); + evt->szText.w = mir_wstrdup(TranslateT("consectetur adipisicing elit")); prevEvent->next = evt; prevEvent = evt; return firstEvent; @@ -198,9 +168,9 @@ static EventData* GetTestEvents() static void freeEvent(EventData *evt) { - mir_free(evt->pszNickT); - mir_free(evt->pszTextT); - mir_free(evt->pszText2T); + mir_free(evt->szNick.w); + mir_free(evt->szText.w); + mir_free(evt->szText2.w); mir_free(evt); } @@ -379,19 +349,19 @@ int isSameDate(time_t time1, time_t time2) static void AppendWithCustomLinks(EventData *evt, int style, CMStringA &buf) { - if (evt->pszText == nullptr) + if (evt->szText.w == nullptr) return; BOOL isAnsii = (evt->dwFlags & IEEDF_UNICODE_TEXT) == 0; WCHAR *wText; size_t len; if (isAnsii) { - len = mir_strlen(evt->pszText); - wText = mir_a2u(evt->pszText); + len = mir_strlen(evt->szText.a); + wText = mir_a2u(evt->szText.a); } else { - wText = evt->pszTextW; - len = (int)mir_wstrlen(evt->pszTextW); + wText = evt->szText.w; + len = (int)mir_wstrlen(evt->szText.w); } if (len > 0) { @@ -404,20 +374,20 @@ static void AppendWithCustomLinks(EventData *evt, int style, CMStringA &buf) } // mir_free() the return value -static char* CreateRTFFromEvent(CSrmmWindow *dat, EventData *evt, GlobalMessageData *gdat, LogStreamData *streamData) +char* CMsgDialog::CreateRTFFromEvent(EventData *evt, GlobalMessageData *gdat, LogStreamData *streamData) { int style, showColon = 0; int isGroupBreak = TRUE; int highlight = 0; - if ((gdat->flags.bGroupMessages) && evt->dwFlags == LOWORD(dat->m_lastEventType) && - evt->eventType == EVENTTYPE_MESSAGE && HIWORD(dat->m_lastEventType) == EVENTTYPE_MESSAGE && - (isSameDate(evt->time, dat->m_lastEventTime)) && ((((int)evt->time < dat->m_startTime) == (dat->m_lastEventTime < dat->m_startTime)) || !(evt->dwFlags & IEEDF_READ))) { + if ((gdat->flags.bGroupMessages) && evt->dwFlags == LOWORD(m_lastEventType) && + evt->eventType == EVENTTYPE_MESSAGE && HIWORD(m_lastEventType) == EVENTTYPE_MESSAGE && + (isSameDate(evt->time, m_lastEventTime)) && ((((int)evt->time < m_startTime) == (m_lastEventTime < m_startTime)) || !(evt->dwFlags & IEEDF_READ))) { isGroupBreak = FALSE; } CMStringA buf; - if (!streamData->isFirst && !dat->m_isMixed) { + if (!streamData->isFirst && !m_isMixed) { if (isGroupBreak || gdat->flags.bMarkFollowups) buf.Append("\\par"); else @@ -425,7 +395,7 @@ static char* CreateRTFFromEvent(CSrmmWindow *dat, EventData *evt, GlobalMessageD } if (evt->dwFlags & IEEDF_RTL) - dat->m_isMixed = 1; + m_isMixed = 1; if (!streamData->isFirst && isGroupBreak && (gdat->flags.bDrawLines)) buf.AppendFormat("\\sl-1\\slmult0\\highlight%d\\cf%d\\fs1 \\par\\sl0", fontOptionsListSize + 4, fontOptionsListSize + 4); @@ -438,14 +408,14 @@ static char* CreateRTFFromEvent(CSrmmWindow *dat, EventData *evt, GlobalMessageD highlight = fontOptionsListSize + 1; buf.AppendFormat("\\highlight%d\\cf%d", highlight, highlight); - if (!streamData->isFirst && dat->m_isMixed) { + if (!streamData->isFirst && m_isMixed) { if (isGroupBreak) buf.Append("\\sl-1 \\par\\sl0"); else buf.Append("\\sl-1 \\line\\sl0"); } streamData->isFirst = FALSE; - if (dat->m_isMixed) { + if (m_isMixed) { if (evt->dwFlags & IEEDF_RTL) buf.Append("\\ltrch\\rtlch"); else @@ -505,9 +475,9 @@ static char* CreateRTFFromEvent(CSrmmWindow *dat, EventData *evt, GlobalMessageD else buf.AppendFormat("%s ", SetToStyle(MSGFONTID_NOTICE)); if (evt->dwFlags & IEEDF_UNICODE_NICK) - AppendUnicodeToBuffer(buf, evt->pszNickW); + AppendUnicodeToBuffer(buf, evt->szNick.w); else - AppendAnsiToBuffer(buf, evt->pszNick); + AppendAnsiToBuffer(buf, evt->szNick.a); showColon = 1; if (evt->eventType == EVENTTYPE_MESSAGE && gdat->flags.bGroupMessages) { @@ -545,19 +515,19 @@ static char* CreateRTFFromEvent(CSrmmWindow *dat, EventData *evt, GlobalMessageD } AppendUnicodeToBuffer(buf, L" "); - if (evt->pszTextW != nullptr) { + if (evt->szText.w != nullptr) { if (evt->dwFlags & IEEDF_UNICODE_TEXT) - AppendUnicodeToBuffer(buf, evt->pszTextW); + AppendUnicodeToBuffer(buf, evt->szText.w); else - AppendAnsiToBuffer(buf, evt->pszText); + AppendAnsiToBuffer(buf, evt->szText.a); } - if (evt->pszText2W != nullptr) { + if (evt->szText2.w != nullptr) { AppendUnicodeToBuffer(buf, L" ("); if (evt->dwFlags & IEEDF_UNICODE_TEXT2) - AppendUnicodeToBuffer(buf, evt->pszText2W); + AppendUnicodeToBuffer(buf, evt->szText2.w); else - AppendAnsiToBuffer(buf, evt->pszText2); + AppendAnsiToBuffer(buf, evt->szText2.a); AppendUnicodeToBuffer(buf, L")"); } break; @@ -569,11 +539,11 @@ static char* CreateRTFFromEvent(CSrmmWindow *dat, EventData *evt, GlobalMessageD AppendWithCustomLinks(evt, style, buf); break; } - if (dat->m_isMixed) + if (m_isMixed) buf.Append("\\par"); - dat->m_lastEventTime = evt->time; - dat->m_lastEventType = MAKELONG(evt->dwFlags, evt->eventType); + m_lastEventTime = evt->time; + m_lastEventType = MAKELONG(evt->dwFlags, evt->eventType); return buf.Detach(); } @@ -592,16 +562,16 @@ static DWORD CALLBACK LogStreamInEvents(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG if (dat->events != nullptr) { EventData *evt = dat->events; dat->buffer = nullptr; - dat->buffer = CreateRTFFromEvent(dat->dlgDat, evt, dat->gdat, dat); + dat->buffer = dat->dlgDat->CreateRTFFromEvent(evt, dat->gdat, dat); dat->events = evt->next; freeEvent(evt); } else if (dat->eventsToInsert) { do { - EventData *evt = getEventFromDB(dat->dlgDat, dat->hContact, dat->hDbEvent); + EventData *evt = dat->dlgDat->GetEventFromDB(dat->hContact, dat->hDbEvent); dat->buffer = nullptr; if (evt != nullptr) { - dat->buffer = CreateRTFFromEvent(dat->dlgDat, evt, dat->gdat, dat); + dat->buffer = dat->dlgDat->CreateRTFFromEvent(evt, dat->gdat, dat); freeEvent(evt); } if (dat->buffer) @@ -639,7 +609,7 @@ static DWORD CALLBACK LogStreamInEvents(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG void StreamInTestEvents(HWND hEditWnd, GlobalMessageData *gdat) { - CSrmmWindow *dat = new CSrmmWindow(0, false); + CMsgDialog *dat = new CMsgDialog(0, false); LogStreamData streamData = { 0 }; streamData.isFirst = TRUE; @@ -656,7 +626,7 @@ void StreamInTestEvents(HWND hEditWnd, GlobalMessageData *gdat) delete dat; } -void CSrmmWindow::StreamInEvents(MEVENT hDbEventFirst, int count, int bAppend) +void CMsgDialog::StreamInEvents(MEVENT hDbEventFirst, int count, int bAppend) { // IEVIew MOD Begin if (m_hwndIeview != nullptr) { diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index adf8d22b98..03cfe6049e 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -73,7 +73,7 @@ static INT_PTR ReadMessageCommand(WPARAM, LPARAM lParam) HWND hwndExisting = Srmm_FindWindow(hContact); if (hwndExisting == nullptr) - (new CSrmmWindow(hContact, false))->Show(); + (new CMsgDialog(hContact, false))->Show(); else SendMessage(GetParent(hwndExisting), CM_POPUPWINDOW, 0, (LPARAM)hwndExisting); return 0; @@ -105,7 +105,7 @@ static int MessageEventAdded(WPARAM hContact, LPARAM lParam) /* new message */ Skin_PlaySound("AlertMsg"); if (IsAutoPopup(hContact)) { - (new CSrmmWindow(hContact, true))->Show(); + (new CMsgDialog(hContact, true))->Show(); return 0; } } @@ -150,7 +150,7 @@ static INT_PTR SendMessageCommandWorker(MCONTACT hContact, wchar_t *pszMsg) SendMessage(GetParent(hwnd), CM_POPUPWINDOW, 0, (LPARAM)hwnd); } else { - CSrmmWindow *pDlg = new CSrmmWindow(hContact, false); + CMsgDialog *pDlg = new CMsgDialog(hContact, false); pDlg->m_wszInitialText = pszMsg; pDlg->Show(); } @@ -259,7 +259,7 @@ static void RestoreUnreadMessageAlerts(void) continue; if (IsAutoPopup(hContact) && !windowAlreadyExists) - (new CSrmmWindow(hContact, true))->Show(); + (new CMsgDialog(hContact, true))->Show(); else arEvents.insert(new MSavedEvent(hContact, hDbEvent)); } @@ -281,7 +281,7 @@ static void RestoreUnreadMessageAlerts(void) } } -void CScriverWindow::SetStatusText(const wchar_t *wszText, HICON hIcon) +void CMsgDialog::SetStatusText(const wchar_t *wszText, HICON hIcon) { ParentWindowData *pDat = m_pParent; if (pDat != nullptr) { @@ -319,76 +319,6 @@ static int AvatarChanged(WPARAM wParam, LPARAM lParam) return 0; } -///////////////////////////////////////////////////////////////////////////////////////// -// CScriverWindow - -CScriverWindow::CScriverWindow(int iDialog, SESSION_INFO *si) - : CSrmmBaseDialog(g_plugin, iDialog, si) -{ - m_autoClose = CLOSE_ON_CANCEL; -} - -void CScriverWindow::CloseTab() -{ - Close(); -} - -void CScriverWindow::LoadSettings() -{ - m_clrInputBG = g_plugin.getDword(SRMSGSET_INPUTBKGCOLOUR, SRMSGDEFSET_INPUTBKGCOLOUR); - LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, nullptr, &m_clrInputFG); -} - -void CScriverWindow::Reattach(HWND hwndContainer) -{ - MCONTACT hContact = m_hContact; - - POINT pt; - GetCursorPos(&pt); - HWND hParent = WindowFromPoint(pt); - while (GetParent(hParent) != nullptr) - hParent = GetParent(hParent); - - hParent = WindowList_Find(g_dat.hParentWindowList, (UINT_PTR)hParent); - if ((hParent != nullptr && hParent != hwndContainer) || (hParent == nullptr && m_pParent->childrenCount > 1 && (GetKeyState(VK_CONTROL) & 0x8000))) { - if (hParent == nullptr) { - hParent = GetParentWindow(hContact, false); - - RECT rc; - GetWindowRect(hParent, &rc); - - rc.right = (rc.right - rc.left); - rc.bottom = (rc.bottom - rc.top); - rc.left = pt.x - rc.right / 2; - rc.top = pt.y - rc.bottom / 2; - HMONITOR hMonitor = MonitorFromRect(&rc, MONITOR_DEFAULTTONEAREST); - - MONITORINFO mi; - mi.cbSize = sizeof(mi); - GetMonitorInfo(hMonitor, &mi); - - RECT rcDesktop = mi.rcWork; - if (rc.left < rcDesktop.left) - rc.left = rcDesktop.left; - if (rc.top < rcDesktop.top) - rc.top = rcDesktop.top; - MoveWindow(hParent, rc.left, rc.top, rc.right, rc.bottom, FALSE); - } - NotifyEvent(MSG_WINDOW_EVT_CLOSING); - NotifyEvent(MSG_WINDOW_EVT_CLOSE); - SetParent(hParent); - SendMessage(hwndContainer, CM_REMOVECHILD, 0, (LPARAM)m_hwnd); - SendMessage(m_hwnd, DM_SETPARENT, 0, (LPARAM)hParent); - SendMessage(hParent, CM_ADDCHILD, (WPARAM)this, 0); - SendMessage(m_hwnd, DM_UPDATETABCONTROL, 0, 0); - SendMessage(hParent, CM_ACTIVATECHILD, 0, (LPARAM)m_hwnd); - NotifyEvent(MSG_WINDOW_EVT_OPENING); - NotifyEvent(MSG_WINDOW_EVT_OPEN); - ShowWindow(hParent, SW_SHOWNA); - EnableWindow(hParent, TRUE); - } -} - ///////////////////////////////////////////////////////////////////////////////////////// // status icons processing diff --git a/plugins/Scriver/src/msgs.h b/plugins/Scriver/src/msgs.h index 18f8957ecd..2c4cf6060d 100644 --- a/plugins/Scriver/src/msgs.h +++ b/plugins/Scriver/src/msgs.h @@ -27,6 +27,24 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define MSGERROR_RETRY 1 #define MSGERROR_DONE 2 +struct EventData +{ + int cbSize; + int iType; + DWORD dwFlags; + const char *fontName; + int fontSize; + int fontStyle; + COLORREF color; + MAllStrings szNick; // Nick, usage depends on type of event + MAllStrings szText; // Text, usage depends on type of event + MAllStrings szText2; // Text, usage depends on type of event + DWORD time; + DWORD eventType; + BOOL custom; + EventData *next; +}; + struct ToolbarButton { wchar_t *name; @@ -77,48 +95,35 @@ struct ParentWindowData #define NMWLP_INCOMING 1 -class CScriverWindow : public CSrmmBaseDialog +class CMsgDialog : public CSrmmBaseDialog { typedef CSrmmBaseDialog CSuper; -protected: - CScriverWindow(int iDialog, SESSION_INFO* = nullptr); - - bool CheckSend(); - int InputAreaShortcuts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); - -public: - void CloseTab() override; - void LoadSettings() override; - void SetStatusText(const wchar_t*, HICON) override; + friend INT_PTR CALLBACK InfobarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); - bool IsActive() const - { - return GetActiveWindow() == m_hwndParent && GetForegroundWindow() == m_hwndParent && m_pParent->hwndActive == m_hwnd; - } - - void Reattach(HWND hwndContainer); - - ParentWindowData *m_pParent; - int m_minLogBoxHeight, m_minEditBoxHeight; - HWND m_hwndIeview; - TCmdList *cmdList, *cmdListCurrent; -}; + bool CheckSend(void); + void GetContactUniqueId(char *buf, int maxlen); + HICON GetTabIcon(void); + void GetTitlebarIcon(struct TitleBarData *tbd); + void Init(void); + int InputAreaShortcuts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); + void MessageDialogResize(int w, int h); + void ShowAvatar(void); + void SetDialogToType(void); + void SetStatusIcon(void); + void StreamInEvents(MEVENT hDbEventFirst, int count, int fAppend); + void UpdateReadChars(void); -class CSrmmWindow : public CScriverWindow -{ - typedef CScriverWindow CSuper; + bool IsTypingNotificationEnabled(void); + bool IsTypingNotificationSupported(void); + void NotifyTyping(int mode); - CCtrlButton m_btnOk, m_btnAdd, m_btnUserMenu, m_btnQuote, m_btnDetails; - CSplitter m_splitter; + static INT_PTR CALLBACK FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); - LRESULT WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam); - LRESULT WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam); + bool m_bIncoming, m_bShowTyping, m_bWindowCascaded; - bool m_bIncoming, m_bShowTyping; - MEVENT m_hDbEventFirst, m_hDbEventLast, m_hDbUnreadEventFirst; - int m_iWindowWasCascaded; + int m_minLogBoxHeight, m_minEditBoxHeight; int m_nTypeSecs, m_nTypeMode, m_nLastTyping; int m_iShowUnread; WORD m_wStatus; @@ -127,21 +132,20 @@ class CSrmmWindow : public CScriverWindow int m_iSendAllConfirm; HICON m_hStatusIcon, m_hStatusIconBig, m_hStatusIconOverlay; - 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(); + char *m_szProto; + time_t m_startTime, m_lastEventTime; + int m_lastEventType; + int m_isMixed; + bool m_bUseRtl, m_bUseIEView; - bool IsTypingNotificationEnabled(); - bool IsTypingNotificationSupported(); - void NotifyTyping(int mode); + HBITMAP m_hbmpAvatarPic; + AVATARCACHEENTRY *m_ace; + + TCmdList *cmdList, *cmdListCurrent; + ParentWindowData *m_pParent; + HWND m_hwndIeview; -public: // info bar support + // info bar support HWND m_hwndInfo; HWND m_hXStatusTip; @@ -149,88 +153,67 @@ public: // info bar support void SetupInfobar(); void RefreshInfobar(); -public: - char *m_szProto; - time_t m_startTime, m_lastEventTime; - int m_lastEventType; - int m_isMixed; - bool m_bUseRtl, m_bUseIEView; + // autocomplete + void TabAutoComplete(void); + wchar_t m_wszSearch[255]; + wchar_t *m_wszSearchQuery, *m_wszSearchResult; + SESSION_INFO *m_pLastSession; - wchar_t *m_wszInitialText; - HBITMAP m_hbmpAvatarPic; - AVATARCACHEENTRY *m_ace; + CCtrlButton m_btnOk, m_btnAdd, m_btnUserMenu, m_btnQuote, m_btnDetails; + CSplitter m_splitterX, m_splitterY; public: - CSrmmWindow(MCONTACT hContact, bool bIncoming); + CMsgDialog(MCONTACT hContact, bool bIncoming); + CMsgDialog(SESSION_INFO *); bool OnInitDialog() override; void OnDestroy() override; - void ScrollToBottom() override; - void UpdateStatusBar() override; - void UpdateTitle() override; - INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override; - 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 onClick_Ok(CCtrlButton *); + void onClick_Add(CCtrlButton *); + void onClick_Filter(CCtrlButton *); + void onClick_Details(CCtrlButton *); + void onClick_History(CCtrlButton *); + void onClick_Quote(CCtrlButton *); + void onClick_UserMenu(CCtrlButton *); + void onClick_ShowList(CCtrlButton *); - void onChange_Message(CCtrlEdit*); + void onChange_Message(CCtrlEdit *); - void onChanged_Splitter(CSplitter*); -}; - -class CMsgDialog : public CScriverWindow -{ - typedef CScriverWindow CSuper; + void onChange_SplitterX(CSplitter *); + void onChange_SplitterY(CSplitter *); - CCtrlButton m_btnOk; - CSplitter m_splitterX, m_splitterY; - - void MessageDialogResize(int w, int h); - void TabAutoComplete(void); - - LRESULT WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam) override; - LRESULT WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) override; - LRESULT WndProc_Nicklist(UINT msg, WPARAM wParam, LPARAM lParam) override; - - static INT_PTR CALLBACK FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); - - wchar_t m_wszSearch[255]; - wchar_t *m_wszSearchQuery, *m_wszSearchResult; - SESSION_INFO *m_pLastSession; - -public: - CMsgDialog(SESSION_INFO *si); - - bool OnInitDialog() override; - void OnDestroy() override; - - INT_PTR DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) override; - + void CloseTab() override; + void LoadSettings() override; void RedrawLog() override; void ScrollToBottom() override; + void SetStatusText(const wchar_t *, HICON) override; void ShowFilterMenu() override; - void StreamInEvents(LOGINFO* lin, bool bRedraw) override; + void StreamInEvents(LOGINFO *lin, bool bRedraw) override; void UpdateNickList() override; void UpdateOptions() override; void UpdateStatusBar() override; void UpdateTitle() override; - void onChange_Message(CCtrlEdit*); + void FixTabIcons(); + + LRESULT WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam) override; + LRESULT WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) override; + LRESULT WndProc_Nicklist(UINT msg, WPARAM wParam, LPARAM lParam) override; - void onClick_Ok(CCtrlButton*); - void onClick_Filter(CCtrlButton*); - void onClick_ShowList(CCtrlButton*); + bool IsActive() const + { + return GetActiveWindow() == m_hwndParent && GetForegroundWindow() == m_hwndParent && m_pParent->hwndActive == m_hwnd; + } - void OnSplitterX(CSplitter*); - void OnSplitterY(CSplitter*); + wchar_t *m_wszInitialText; - void FixTabIcons(); + char* CreateRTFFromEvent(EventData *evt, GlobalMessageData *gdat, struct LogStreamData *streamData); + EventData *GetEventFromDB(MCONTACT hContact, MEVENT hDbEvent); + + void Reattach(HWND hwndContainer); }; #define HM_DBEVENTADDED (WM_USER+10) diff --git a/plugins/Scriver/src/resource.h b/plugins/Scriver/src/resource.h index 902a55c782..bef57bae9d 100644 --- a/plugins/Scriver/src/resource.h +++ b/plugins/Scriver/src/resource.h @@ -35,7 +35,6 @@ #define IDI_FOODNETWORK 147 #define IDI_LASTICON 148 #define IDR_CONTEXT 180 -#define IDD_CHANNEL 401 #define IDD_OPTIONS1 402 #define IDD_OPTIONS2 403 #define IDD_FILTER 405 diff --git a/plugins/Scriver/src/tabs.cpp b/plugins/Scriver/src/tabs.cpp index 8b24e91df9..00d6e7e065 100644 --- a/plugins/Scriver/src/tabs.cpp +++ b/plugins/Scriver/src/tabs.cpp @@ -74,31 +74,31 @@ static int GetTabFromHWND(ParentWindowData *dat, HWND child) TCITEM tci = { 0 }; tci.mask = TCIF_PARAM; TabCtrl_GetItem(dat->hwndTabs, i, &tci); - CScriverWindow *pDlg = (CScriverWindow *)tci.lParam; + CMsgDialog *pDlg = (CMsgDialog *)tci.lParam; if (pDlg->GetHwnd() == child) return i; } return -1; } -static CScriverWindow* GetChildFromTab(HWND hwndTabs, int tabId) +static CMsgDialog* GetChildFromTab(HWND hwndTabs, int tabId) { TCITEM tci = { 0 }; tci.mask = TCIF_PARAM; if (TabCtrl_GetItem(hwndTabs, tabId, &tci)) - return (CScriverWindow *)tci.lParam; + return (CMsgDialog *)tci.lParam; return nullptr; } -static CScriverWindow* GetChildFromHWND(ParentWindowData *dat, HWND hwnd) +static CMsgDialog* GetChildFromHWND(ParentWindowData *dat, HWND hwnd) { int l = TabCtrl_GetItemCount(dat->hwndTabs); for (int i = 0; i < l; i++) { TCITEM tci = { 0 }; tci.mask = TCIF_PARAM; TabCtrl_GetItem(dat->hwndTabs, i, &tci); - CScriverWindow *pDlg = (CScriverWindow *)tci.lParam; + CMsgDialog *pDlg = (CMsgDialog *)tci.lParam; if (pDlg->GetHwnd() == hwnd) return pDlg; } @@ -113,7 +113,7 @@ static void GetMinimunWindowSize(ParentWindowData *dat, SIZE *size) GetWindowRect(dat->hwnd, &rcWindow); GetChildWindowRect(dat, &rc); for (int i = 0; i < dat->childrenCount; i++) { - CScriverWindow * pDlg = GetChildFromTab(dat->hwndTabs, i); + CMsgDialog * pDlg = GetChildFromTab(dat->hwndTabs, i); SendMessage(pDlg->GetHwnd(), WM_GETMINMAXINFO, 0, (LPARAM)&mmi); if (i == 0 || mmi.ptMinTrackSize.x > minW) minW = mmi.ptMinTrackSize.x; if (i == 0 || mmi.ptMinTrackSize.y > minH) minH = mmi.ptMinTrackSize.y; @@ -184,7 +184,7 @@ static void ActivateChild(ParentWindowData *dat, HWND child) if (i == -1) return; - CScriverWindow *pDlg = GetChildFromTab(dat->hwndTabs, i); + CMsgDialog *pDlg = GetChildFromTab(dat->hwndTabs, i); if (pDlg == nullptr) return; @@ -207,7 +207,7 @@ static void ActivateChild(ParentWindowData *dat, HWND child) SendMessage(dat->hwndActive, DM_ACTIVATE, WA_ACTIVE, 0); } -static void AddChild(ParentWindowData *dat, CScriverWindow *pDlg) +static void AddChild(ParentWindowData *dat, CMsgDialog *pDlg) { dat->childrenCount++; @@ -247,7 +247,7 @@ static void CloseOtherChilden(ParentWindowData *dat, HWND child) { ActivateChild(dat, child); for (int i = dat->childrenCount - 1; i >= 0; i--) { - CScriverWindow *pDlg = GetChildFromTab(dat->hwndTabs, i); + CMsgDialog *pDlg = GetChildFromTab(dat->hwndTabs, i); if (pDlg != nullptr && pDlg->GetHwnd() != child) pDlg->Close(); } @@ -274,7 +274,7 @@ static void ActivateChildByIndex(ParentWindowData *dat, int index) { int l = TabCtrl_GetItemCount(dat->hwndTabs); if (index < l) { - CScriverWindow *pDlg = GetChildFromTab(dat->hwndTabs, index); + CMsgDialog *pDlg = GetChildFromTab(dat->hwndTabs, index); if (pDlg != nullptr) ActivateChild(dat, pDlg->GetHwnd()); } @@ -341,7 +341,7 @@ static LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l TCITEM tci; tci.mask = TCIF_PARAM; TabCtrl_GetItem(hwnd, tabId, &tci); - CScriverWindow *pDlg = (CScriverWindow *)tci.lParam; + CMsgDialog *pDlg = (CMsgDialog *)tci.lParam; if (pDlg != nullptr) { SendMessage(pDlg->GetHwnd(), WM_CLOSE, 0, 0); dat->srcTab = -1; @@ -428,7 +428,7 @@ static LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l TCITEM tci; tci.mask = TCIF_PARAM; TabCtrl_GetItem(hwnd, dat->srcTab, &tci); - CScriverWindow *pDlg = (CScriverWindow*)tci.lParam; + CMsgDialog *pDlg = (CMsgDialog*)tci.lParam; if (pDlg != nullptr) pDlg->Reattach(GetParent(hwnd)); } @@ -734,7 +734,7 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara { LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam; if (dat && dat->hwndActive && dis->hwndItem == dat->hwndStatus) { - CScriverWindow *pDlg = GetChildFromHWND(dat, dat->hwndActive); + CMsgDialog *pDlg = GetChildFromHWND(dat, dat->hwndActive); if (pDlg != nullptr) DrawStatusIcons(pDlg->m_hContact, dis->hDC, dis->rcItem, 2); return TRUE; @@ -765,7 +765,7 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara int iSel = TabCtrl_GetCurSel(dat->hwndTabs); tci.mask = TCIF_PARAM; if (TabCtrl_GetItem(dat->hwndTabs, iSel, &tci)) { - CScriverWindow * pDlg = (CScriverWindow *)tci.lParam; + CMsgDialog * pDlg = (CMsgDialog *)tci.lParam; ActivateChild(dat, pDlg->GetHwnd()); SetFocus(dat->hwndActive); } @@ -781,7 +781,7 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara ScreenToClient(dat->hwndTabs, &thinfo.pt); int tabId = TabCtrl_HitTest(dat->hwndTabs, &thinfo); if (tabId != -1) { - CScriverWindow *pDlg = GetChildFromTab(dat->hwndTabs, tabId); + CMsgDialog *pDlg = GetChildFromTab(dat->hwndTabs, tabId); HMENU hMenu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_CONTEXT)); HMENU hSubMenu = GetSubMenu(hMenu, 3); TranslateMenu(hSubMenu); @@ -815,7 +815,7 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara NMMOUSE *nm = (NMMOUSE*)lParam; SendMessage(dat->hwndStatus, SB_GETRECT, SendMessage(dat->hwndStatus, SB_GETPARTS, 0, 0) - 2, (LPARAM)&rc); if (nm->pt.x >= rc.left) { - CScriverWindow *pDlg = GetChildFromHWND(dat, dat->hwndActive); + CMsgDialog *pDlg = GetChildFromHWND(dat, dat->hwndActive); if (pDlg != nullptr) CheckStatusIconClick(pDlg->m_hContact, dat->hwndStatus, nm->pt, rc, 2, 0); } @@ -852,7 +852,7 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara RECT rc; SendMessage(dat->hwndStatus, SB_GETRECT, SendMessage(dat->hwndStatus, SB_GETPARTS, 0, 0) - 2, (LPARAM)&rc); if (pt.x >= rc.left) { - CScriverWindow *pDlg = GetChildFromHWND(dat, dat->hwndActive); + CMsgDialog *pDlg = GetChildFromHWND(dat, dat->hwndActive); if (pDlg != nullptr) CheckStatusIconClick(pDlg->m_hContact, dat->hwndStatus, pt, rc, 2, MBCF_RIGHTBUTTON); break; @@ -1040,7 +1040,7 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara return TRUE; case CM_ADDCHILD: - AddChild(dat, (CScriverWindow*)wParam); + AddChild(dat, (CMsgDialog*)wParam); return TRUE; case CM_ACTIVATECHILD: @@ -1066,17 +1066,9 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, (LONG_PTR)GetChildCount(dat)); return TRUE; - case CM_GETACTIVECHILD: - SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, (LONG_PTR)dat->hwndActive); - return TRUE; - - case CM_GETTOOLBARSTATUS: - SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, (LONG_PTR)(dat->flags2.bShowToolBar) != 0); - return TRUE; - case DM_SENDMESSAGE: for (int i = 0; i < dat->childrenCount; i++) { - CScriverWindow * pDlg = GetChildFromTab(dat->hwndTabs, i); + CMsgDialog * pDlg = GetChildFromTab(dat->hwndTabs, i); SendMessage(pDlg->GetHwnd(), DM_SENDMESSAGE, wParam, lParam); } break; @@ -1168,7 +1160,7 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara dat->flags2.bShowInfoBar = !dat->flags2.bShowInfoBar; for (int i = 0; i < dat->childrenCount; i++) { - CScriverWindow * pDlg = GetChildFromTab(dat->hwndTabs, i); + CMsgDialog * pDlg = GetChildFromTab(dat->hwndTabs, i); SendMessage(pDlg->GetHwnd(), DM_SWITCHINFOBAR, 0, 0); } SendMessage(hwndDlg, WM_SIZE, 0, 0); @@ -1184,7 +1176,7 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara dat->flags2.bShowToolBar = !dat->flags2.bShowToolBar; for (int i = 0; i < dat->childrenCount; i++) { - CScriverWindow * pDlg = GetChildFromTab(dat->hwndTabs, i); + CMsgDialog * pDlg = GetChildFromTab(dat->hwndTabs, i); SendMessage(pDlg->GetHwnd(), DM_SWITCHTOOLBAR, 0, 0); } diff --git a/plugins/Scriver/src/tabs.h b/plugins/Scriver/src/tabs.h index 463bf90d10..a4068b37d7 100644 --- a/plugins/Scriver/src/tabs.h +++ b/plugins/Scriver/src/tabs.h @@ -32,8 +32,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define CM_ACTIVATEBYINDEX (WM_USER+0x185) #define CM_GETCHILDCOUNT (WM_USER+0x188) -#define CM_GETACTIVECHILD (WM_USER+0x189) -#define CM_GETFLAGS (WM_USER+0x18A) #define CM_UPDATETITLEBAR (WM_USER+0x190) #define CM_UPDATESTATUSBAR (WM_USER+0x191) @@ -41,8 +39,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define CM_STARTFLASHING (WM_USER+0x1A0) #define CM_POPUPWINDOW (WM_USER+0x1A1) -#define CM_GETTOOLBARSTATUS (WM_USER+0x1A2) - /* child window services */ #define DM_UPDATETABCONTROL (WM_USER+0x1B2) #define DM_SETPARENT (WM_USER+0x1B3) diff --git a/plugins/Scriver/src/utils.cpp b/plugins/Scriver/src/utils.cpp index e8f9590391..d268ab4c62 100644 --- a/plugins/Scriver/src/utils.cpp +++ b/plugins/Scriver/src/utils.cpp @@ -277,7 +277,7 @@ void SetSearchEngineIcons(HMENU hMenu, HIMAGELIST hImageList) } } -void CSrmmWindow::GetContactUniqueId(char *buf, int maxlen) +void CMsgDialog::GetContactUniqueId(char *buf, int maxlen) { ptrW id(Contact_GetInfo(CNF_UNIQUEID, m_hContact, m_szProto)); if (id != nullptr) -- cgit v1.2.3