From 38200b7236c5c290d75a36cb431c78beeb98dbbd Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 29 Aug 2014 18:42:56 +0000 Subject: code cleaning towards smiley drawing git-svn-id: http://svn.miranda-ng.org/main/trunk@10336 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TabSRMM/src/chat/window.cpp | 2 +- plugins/TabSRMM/src/controls.cpp | 356 +++++++++---------- plugins/TabSRMM/src/generic_msghandlers.cpp | 20 +- plugins/TabSRMM/src/globals.cpp | 2 +- plugins/TabSRMM/src/msgdialog.cpp | 18 +- plugins/TabSRMM/src/msgdlgutils.cpp | 12 +- plugins/TabSRMM/src/msglog.cpp | 522 +++++++++++++--------------- plugins/TabSRMM/src/msgs.h | 12 +- plugins/TabSRMM/src/tabctrl.cpp | 44 +-- 9 files changed, 460 insertions(+), 528 deletions(-) (limited to 'plugins/TabSRMM/src') diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index cf12f38349..8b247b793d 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -2224,7 +2224,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar dat->nTypeSecs = (int) lParam > 0 ? (int) lParam : 0; if(dat->nTypeSecs) - dat->showTyping = 0; + dat->bShowTyping = 0; SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, preTyping); } diff --git a/plugins/TabSRMM/src/controls.cpp b/plugins/TabSRMM/src/controls.cpp index 0ae33e8a60..022b81432c 100644 --- a/plugins/TabSRMM/src/controls.cpp +++ b/plugins/TabSRMM/src/controls.cpp @@ -125,31 +125,32 @@ void CMenuBar::releaseHook() m_hHook = 0; } } -/** - * Retrieve the height of the rebar control - * - * @return LONG: height of the rebar, in pixels - */ + +///////////////////////////////////////////////////////////////////////////////////////// +// Retrieve the height of the rebar control +// +// @return LONG: height of the rebar, in pixels + LONG CMenuBar::getHeight() const { return((m_pContainer->dwFlags & CNT_NOMENUBAR) ? 0 : m_size_y); } -/** - * process all relevant messages. Must be called by the parent window's - * window procedure. - * - * @param msg - * @param wParam - * @param lParam - * - * @return LRESULT: message processing result. Win32 conform. - * -1 means: nothing processed, caller should continue as usual. - */ +///////////////////////////////////////////////////////////////////////////////////////// +// process all relevant messages. Must be called by the parent window's +// window procedure. +// +// @param msg +// @param wParam +// @param lParam +// +// @return LRESULT: message processing result. Win32 conform. +// -1 means: nothing processed, caller should continue as usual. + LONG_PTR CMenuBar::processMsg(const UINT msg, const WPARAM wParam, const LPARAM lParam) { if (msg == WM_NOTIFY) { - NMHDR* pNMHDR = (NMHDR*)lParam; + NMHDR *pNMHDR = (NMHDR*)lParam; switch(pNMHDR->code) { case NM_CUSTOMDRAW: { @@ -190,10 +191,9 @@ LONG_PTR CMenuBar::processMsg(const UINT msg, const WPARAM wParam, const LPARAM return -1; } -/** - * subclass the toolbar control to handle some keyboard events and improve - * keyboard navigation - */ +///////////////////////////////////////////////////////////////////////////////////////// +// subclass the toolbar control to handle some keyboard events and improve +// keyboard navigation LRESULT CALLBACK CMenuBar::wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -210,17 +210,17 @@ LRESULT CALLBACK CMenuBar::wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP return ::mir_callNextSubclass(hWnd, CMenuBar::wndProc, msg, wParam, lParam); } -/** - * Implements NM_CUSTOMDRAW for the toolbar - * - * @param nm NMCUSTOMDRAW *: sent via NM_CUSTOMDRAW message - * - * @return LONG_PTR: see Win32 NM_CUSTOMDRAW message. The function must return a valid - * message return value to indicate how Windows should continue with the drawing process. - * - * It may return zero in which case, the caller should allow default processing for - * the NM_CUSTOMDRAW message. - */ +///////////////////////////////////////////////////////////////////////////////////////// +// Implements NM_CUSTOMDRAW for the toolbar +// +// @param nm NMCUSTOMDRAW *: sent via NM_CUSTOMDRAW message +// +// @return LONG_PTR: see Win32 NM_CUSTOMDRAW message. The function must return a valid +// message return value to indicate how Windows should continue with the drawing process. +// +// It may return zero in which case, the caller should allow default processing for +// the NM_CUSTOMDRAW message. + LONG_PTR CMenuBar::customDrawWorker(NMCUSTOMDRAW *nm) { bool fMustDraw = true; @@ -265,12 +265,11 @@ LONG_PTR CMenuBar::customDrawWorker(NMCUSTOMDRAW *nm) else ::FillRect(m_hdcDraw, &nm->rc, GetSysColorBrush(COLOR_3DFACE)); } - return(CDRF_NOTIFYITEMDRAW | CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYPOSTERASE); - } - else { - m_hdcDraw = 0; - return(CDRF_DODEFAULT); + return CDRF_NOTIFYITEMDRAW | CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYPOSTERASE; } + + m_hdcDraw = 0; + return CDRF_DODEFAULT; case CDDS_ITEMPREPAINT: if (fMustDraw) { @@ -278,11 +277,10 @@ LONG_PTR CMenuBar::customDrawWorker(NMCUSTOMDRAW *nm) bool fDraw = true; int iIndex = idToIndex(nmtb->nmcd.dwItemSpec); - if (iIndex >= 0 && iIndex < NR_BUTTONS) szText = (TCHAR*)m_TbButtons[iIndex].iString; - UINT uState = nmtb->nmcd.uItemState; + UINT uState = nmtb->nmcd.uItemState; nmtb->nmcd.rc.bottom--; if (CSkin::m_skinEnabled) { @@ -326,18 +324,18 @@ LONG_PTR CMenuBar::customDrawWorker(NMCUSTOMDRAW *nm) (nmtb->nmcd.rc.top + nmtb->nmcd.rc.bottom) / 2 - 8, LoadSkinnedIcon(SKINICON_OTHER_MIRANDA), 16, 16, 0, 0, DI_NORMAL); - return(CDRF_SKIPDEFAULT); + return CDRF_SKIPDEFAULT; } - else return(CDRF_DODEFAULT); + else return CDRF_DODEFAULT; case CDDS_PREERASE: case CDDS_ITEMPOSTERASE: case CDDS_ITEMPOSTPAINT: case CDDS_ITEMPREERASE: - return(fMustDraw ? CDRF_SKIPDEFAULT : CDRF_DODEFAULT); + return fMustDraw ? CDRF_SKIPDEFAULT : CDRF_DODEFAULT; case CDDS_POSTERASE: - return(fMustDraw ? CDRF_SKIPDEFAULT : CDRF_DODEFAULT); + return fMustDraw ? CDRF_SKIPDEFAULT : CDRF_DODEFAULT; case CDDS_POSTPAINT: if (nmtb->nmcd.dwItemSpec == 0 && m_hdcDraw) { @@ -350,44 +348,41 @@ LONG_PTR CMenuBar::customDrawWorker(NMCUSTOMDRAW *nm) m_hdcDraw = 0; if (m_hTheme) CloseThemeData(m_hTheme); - return(CDRF_SKIPDEFAULT); + return CDRF_SKIPDEFAULT; } - else - return(CDRF_DODEFAULT); + return CDRF_DODEFAULT; default: - return(CDRF_DODEFAULT); + return CDRF_DODEFAULT; } - - return 0; } return 0; } -/** - * Handle the TBN_DROPDOWN notification message sent by the - * toolbar control. - * - * @param nmtb NMTOOLBAR *: notification message structure - * - * @return LONG_PTR: must be a valid return value. See Win32 API, TBN_DROPDOWN - */ +///////////////////////////////////////////////////////////////////////////////////////// +// Handle the TBN_DROPDOWN notification message sent by the +// toolbar control. +// +// @param nmtb NMTOOLBAR *: notification message structure +// +// @return LONG_PTR: must be a valid return value. See Win32 API, TBN_DROPDOWN + LONG_PTR CMenuBar::Handle(const NMTOOLBAR *nmtb) { if (nmtb->hdr.hwndFrom != m_hwndToolbar) - return(TBDDRET_NODEFAULT); + return TBDDRET_NODEFAULT; const int index = idToIndex(nmtb->iItem); invoke(nmtb->iItem); - return(TBDDRET_DEFAULT); + return TBDDRET_DEFAULT; } -/** - * Invoke the dropdown menu for the button with the given control id. - * - * @param id int: the control id of the toolbar button which has been activated - */ +///////////////////////////////////////////////////////////////////////////////////////// +// Invoke the dropdown menu for the button with the given control id. +// +// @param id int: the control id of the toolbar button which has been activated + void CMenuBar::invoke(const int id) { const int index = idToIndex(id); @@ -440,9 +435,6 @@ void CMenuBar::cancel(const int id) ::EndMenu(); } -/** - * Cancel menu tracking completely - */ void CMenuBar::Cancel(void) { cancel(0); @@ -453,7 +445,6 @@ void CMenuBar::Cancel(void) void CMenuBar::updateState(const HMENU hMenu) const { TWindowData *dat = (TWindowData*)GetWindowLongPtr(m_pContainer->hwndActive, GWLP_USERDATA); - if (dat) { ::CheckMenuItem(hMenu, ID_VIEW_SHOWMENUBAR, MF_BYCOMMAND | m_pContainer->dwFlags & CNT_NOMENUBAR ? MF_UNCHECKED : MF_CHECKED); ::CheckMenuItem(hMenu, ID_VIEW_SHOWSTATUSBAR, MF_BYCOMMAND | m_pContainer->dwFlags & CNT_NOSTATUSBAR ? MF_UNCHECKED : MF_CHECKED); @@ -483,19 +474,18 @@ void CMenuBar::updateState(const HMENU hMenu) const } } -/* - * this updates the container menu bar and other window elements depending on the current child - * session (IM, chat etc.). It fully supports IEView and will disable/enable the message log menus - * depending on the configuration of IEView (e.g. when template mode is on, the message log settin - * menus have no functionality, thus can be disabled to improve ui feedback quality). - */ +///////////////////////////////////////////////////////////////////////////////////////// +// this updates the container menu bar and other window elements depending on the current +// child session (IM, chat etc.). It fully supports IEView and will disable/enable the +// message log menus depending on the configuration of IEView (e.g. when template mode +// is on, the message log settin menus have no functionality, thus can be disabled to +// improve ui feedback quality). void CMenuBar::configureMenu() const { - TWindowData *dat = (TWindowData*)::GetWindowLongPtr(m_pContainer->hwndActive, GWLP_USERDATA); - BOOL fDisable = FALSE; + TWindowData *dat = (TWindowData*)::GetWindowLongPtr(m_pContainer->hwndActive, GWLP_USERDATA); if (dat) { bool fChat = (dat->bType == SESSIONTYPE_CHAT); @@ -508,10 +498,10 @@ void CMenuBar::configureMenu() const } } -/** - * Automatically shows or hides the menu bar. Depends on the current state, - * used when the ALT key is hit in the message window. - */ +///////////////////////////////////////////////////////////////////////////////////////// +// Automatically shows or hides the menu bar. Depends on the current state, +// used when the ALT key is hit in the message window. + void CMenuBar::autoShow(const int showcmd) { if (m_mustAutoHide && !(m_pContainer->dwFlags & CNT_NOMENUBAR)) { @@ -531,11 +521,10 @@ void CMenuBar::autoShow(const int showcmd) m_pContainer->dwFlags &= ~CNT_NOMENUBAR; ::SendMessage(m_pContainer->hwnd, WM_SIZE, 0, 1); } - else // do nothing, already visible + else // do nothing, already visible m_mustAutoHide = false; - //obtainHook(); + ::SetFocus(m_hwndToolbar); - //::SendMessage(m_hwndToolbar, TB_SETHOTITEM, 0, HICF_ACCELERATOR); } void CMenuBar::checkButtons() @@ -543,8 +532,8 @@ void CMenuBar::checkButtons() if (!m_buttonsInit) { ::ZeroMemory(m_TbButtons, sizeof(m_TbButtons)); - m_TbButtons[0].iBitmap = 0;//I_IMAGENONE; - m_TbButtons[0].iString = 0;//(INT_PTR)TranslateT("&Main"); + m_TbButtons[0].iBitmap = 0; + m_TbButtons[0].iString = 0; m_TbButtons[0].fsState = TBSTATE_ENABLED; m_TbButtons[0].fsStyle = BTNS_DROPDOWN|BTNS_AUTOSIZE; m_TbButtons[0].idCommand = 100; @@ -621,17 +610,15 @@ void CMenuBar::resetLP() checkButtons(); } -/** - * Message hook function, installed by the menu handler to support - * hot-tracking and keyboard navigation for the menu bar while a modal - * popup menu is active. - * - * Hook is only active while a (modal) popup menu is processed. - * - * @params See Win32, message hooks - * - * @return - */ +///////////////////////////////////////////////////////////////////////////////////////// +// Message hook function, installed by the menu handler to support +// hot-tracking and keyboard navigation for the menu bar while a modal +// popup menu is active. +// +// Hook is only active while a (modal) popup menu is processed. +// +// @params See Win32, message hooks + LRESULT CALLBACK CMenuBar::MessageHook(int nCode, WPARAM wParam, LPARAM lParam) { MSG *pMsg = reinterpret_cast(lParam); @@ -662,9 +649,7 @@ LRESULT CALLBACK CMenuBar::MessageHook(int nCode, WPARAM wParam, LPARAM lParam) return 0; } - /* - * allow hottracking by the toolbar control - */ + // allow hottracking by the toolbar control case WM_MOUSEMOVE: ::GetCursorPos(&pt); ::ScreenToClient(m_Owner->m_hwndToolbar, &pt); @@ -673,9 +658,7 @@ LRESULT CALLBACK CMenuBar::MessageHook(int nCode, WPARAM wParam, LPARAM lParam) break; } - /* - * some key event requested to cancel the menu - */ + // some key event requested to cancel the menu if (fCancel) { int iIndex = m_Owner->idToIndex(m_Owner->m_activeID); if (iIndex != -1) @@ -689,17 +672,16 @@ LRESULT CALLBACK CMenuBar::MessageHook(int nCode, WPARAM wParam, LPARAM lParam) return ::CallNextHookEx(m_hHook, nCode, wParam, lParam); } -/* - * window procedure for the status bar class. - */ +// window procedure for the status bar class. -static int tooltip_active = FALSE; -static POINT ptMouse = {0}; -RECT rcLastStatusBarClick; // remembers click (down event) point for status bar clicks +static int tooltip_active = FALSE; +static POINT ptMouse = {0}; +RECT rcLastStatusBarClick; // remembers click (down event) point for status bar clicks LONG_PTR CALLBACK StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { TContainerData *pContainer = (TContainerData*)GetWindowLongPtr(GetParent(hWnd), GWLP_USERDATA); + POINT pt; if (OldStatusBarproc == 0) { WNDCLASSEX wc = {0}; @@ -707,28 +689,27 @@ LONG_PTR CALLBACK StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPAR GetClassInfoEx(g_hInst, STATUSCLASSNAME, &wc); OldStatusBarproc = wc.lpfnWndProc; } + switch (msg) { case WM_CREATE: + LRESULT ret; { CREATESTRUCT *cs = (CREATESTRUCT *)lParam; - LRESULT ret; HWND hwndParent = GetParent(hWnd); - /* - * dirty trick to get rid of that annoying sizing gripper - */ + + // dirty trick to get rid of that annoying sizing gripper SetWindowLongPtr(hwndParent, GWL_STYLE, GetWindowLongPtr(hwndParent, GWL_STYLE) & ~WS_THICKFRAME); SetWindowLongPtr(hwndParent, GWL_EXSTYLE, GetWindowLongPtr(hwndParent, GWL_EXSTYLE) & ~WS_EX_APPWINDOW); cs->style &= ~SBARS_SIZEGRIP; ret = CallWindowProc(OldStatusBarproc, hWnd, msg, wParam, lParam); SetWindowLongPtr(hwndParent, GWL_STYLE, GetWindowLongPtr(hwndParent, GWL_STYLE) | WS_THICKFRAME); SetWindowLongPtr(hwndParent, GWL_EXSTYLE, GetWindowLongPtr(hwndParent, GWL_EXSTYLE) | WS_EX_APPWINDOW); - return ret; } + return ret; case WM_NCHITTEST: + RECT r; { - RECT r; - POINT pt; LRESULT lr = SendMessage(GetParent(hWnd), WM_NCHITTEST, wParam, lParam); int clip = CSkin::m_bClipBorder; @@ -748,33 +729,25 @@ LONG_PTR CALLBACK StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPAR return 1; case WM_PAINT: + PAINTSTRUCT ps; { - PAINTSTRUCT ps; - TCHAR szText[1024]; - int i; - RECT itemRect; - HICON hIcon; - LONG height, width; - HDC hdc = BeginPaint(hWnd, &ps); - HFONT hFontOld = 0; - UINT nParts = SendMessage(hWnd, SB_GETPARTS, 0, 0); - LRESULT result; - RECT rcClient; - HDC hdcMem; - HBITMAP hbm, hbmOld; - HANDLE hbp = 0; - CSkinItem * item = &SkinItems[ID_EXTBKSTATUSBARPANEL]; - COLORREF clr = 0; - - BOOL bAero = M.isAero(); - HANDLE hTheme = bAero ? OpenThemeData(hWnd, L"ButtonStyle") : 0; - TWindowData *dat = 0; + HDC hdc = BeginPaint(hWnd, &ps); + int nParts = SendMessage(hWnd, SB_GETPARTS, 0, 0); + CSkinItem *item = &SkinItems[ID_EXTBKSTATUSBARPANEL]; + BOOL bAero = M.isAero(); + HANDLE hTheme = bAero ? OpenThemeData(hWnd, L"ButtonStyle") : 0; + + TWindowData *dat = 0; if (pContainer) dat = (TWindowData*)GetWindowLongPtr(pContainer->hwndActive, GWLP_USERDATA); + RECT rcClient; GetClientRect(hWnd, &rcClient); + HBITMAP hbm, hbmOld; + HANDLE hbp = 0; + HDC hdcMem; if (CMimAPI::m_haveBufferedPaint) hbp = CMimAPI::m_pfnBeginBufferedPaint(hdc, &rcClient, BPBF_TOPDOWNDIB, NULL, &hdcMem); else { @@ -785,16 +758,17 @@ LONG_PTR CALLBACK StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPAR SetBkMode(hdcMem, TRANSPARENT); - clr = CSkin::m_skinEnabled ? CSkin::m_DefaultFontColor : (PluginConfig.m_fillColor ? PluginConfig.m_genericTxtColor : GetSysColor(COLOR_BTNTEXT)); + COLORREF clr = CSkin::m_skinEnabled ? CSkin::m_DefaultFontColor : (PluginConfig.m_fillColor ? PluginConfig.m_genericTxtColor : GetSysColor(COLOR_BTNTEXT)); - hFontOld = (HFONT)SelectObject(hdcMem, GetStockObject(DEFAULT_GUI_FONT)); + HFONT hFontOld = (HFONT)SelectObject(hdcMem, GetStockObject(DEFAULT_GUI_FONT)); if (pContainer && CSkin::m_skinEnabled) CSkin::SkinDrawBG(hWnd, GetParent(hWnd), pContainer, &rcClient, hdcMem); else if (bAero) { FillRect(hdcMem, &rcClient, CSkin::m_BrushBack); CSkin::ApplyAeroEffect(hdcMem, &rcClient, CSkin::AERO_EFFECT_AREA_STATUSBAR); - } else { + } + else { CSkin::FillBack(hdcMem, &rcClient); RECT rcFrame = rcClient; if (PluginConfig.m_fillColor == 0) { @@ -806,7 +780,9 @@ LONG_PTR CALLBACK StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPAR CSkin::m_switchBarItem->Render(hdcMem, &rcFrame, true); } } - for (i=0; i < (int)nParts; i++) { + + for (int i = 0; i < nParts; i++) { + RECT itemRect; SendMessage(hWnd, SB_GETRECT, (WPARAM)i, (LPARAM)&itemRect); if (!item->IGNORED && !bAero && pContainer && CSkin::m_skinEnabled) CSkin::DrawItem(hdcMem, &itemRect, item); @@ -814,17 +790,13 @@ LONG_PTR CALLBACK StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPAR if (i == 0) itemRect.left += 2; - /* - * draw visual message length indicator in the leftmost status bar field - */ - + // draw visual message length indicator in the leftmost status bar field if (PluginConfig.m_visualMessageSizeIndicator && i == 0) { - if (dat && dat->bType == SESSIONTYPE_IM) { HBRUSH br = CreateSolidBrush(RGB(0, 255, 0)); HBRUSH brOld = (HBRUSH)SelectObject(hdcMem, br); + RECT rc = itemRect; - rc.top = rc.bottom - 3; rc.left = 0; @@ -835,7 +807,8 @@ LONG_PTR CALLBACK StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPAR rc.right = (LONG)fx; FillRect(hdcMem, &rc, br); - } else { + } + else { float baselen = (dat->textLen <= dat->nMax) ? (float)dat->textLen : (float)dat->nMax; float fMax = (float)dat->nMax; float uPercent = baselen / ((fMax / (float)100.0) ? (fMax / (float)100.0) : (float)75.0); @@ -864,14 +837,14 @@ LONG_PTR CALLBACK StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPAR } } - height = itemRect.bottom - itemRect.top; - width = itemRect.right - itemRect.left; - hIcon = (HICON)SendMessage(hWnd, SB_GETICON, i, 0); - szText[0] = 0; - result = SendMessage(hWnd, SB_GETTEXT, i, (LPARAM)szText); + int height = itemRect.bottom - itemRect.top; + int width = itemRect.right - itemRect.left; + HICON hIcon = (HICON)SendMessage(hWnd, SB_GETICON, i, 0); + + TCHAR szText[1024]; szText[0] = 0; + LRESULT result = SendMessage(hWnd, SB_GETTEXT, i, (LPARAM)szText); if (i == 2 && pContainer) { TWindowData *dat = (TWindowData*)GetWindowLongPtr(pContainer->hwndActive, GWLP_USERDATA); - if (dat) DrawStatusIcons(dat, hdcMem, itemRect, 2); } @@ -880,24 +853,23 @@ LONG_PTR CALLBACK StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPAR if (LOWORD(result) > 1) { // we have a text DrawIconEx(hdcMem, itemRect.left + 3, (height / 2 - 8) + itemRect.top, hIcon, 16, 16, 0, 0, DI_NORMAL); if (dat) { - if (dat->showTyping == 2) + if (dat->bShowTyping == 2) DrawIconEx(hdcMem, itemRect.left + 3, (height / 2 - 8) + itemRect.top, PluginConfig.g_iconOverlayEnabled, 16, 16, 0, 0, DI_NORMAL); } itemRect.left += 20; CSkin::RenderText(hdcMem, hTheme, szText, &itemRect, DT_VCENTER | DT_END_ELLIPSIS | DT_SINGLELINE | DT_NOPREFIX, CSkin::m_glowSize, clr); } - else - DrawIconEx(hdcMem, itemRect.left + 3, (height / 2 - 8) + itemRect.top, hIcon, 16, 16, 0, 0, DI_NORMAL); + else DrawIconEx(hdcMem, itemRect.left + 3, (height / 2 - 8) + itemRect.top, hIcon, 16, 16, 0, 0, DI_NORMAL); } else { itemRect.left += 2; itemRect.right -= 2; - CSkin::RenderText(hdcMem, hTheme, szText, &itemRect, DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOPREFIX, - CSkin::m_glowSize, clr); + CSkin::RenderText(hdcMem, hTheme, szText, &itemRect, DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOPREFIX, CSkin::m_glowSize, clr); } } } + if (hbp) CSkin::FinalizeBufferedPaint(hbp, &rcClient); else { @@ -915,10 +887,8 @@ LONG_PTR CALLBACK StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPAR } return 0; - /* - * tell status bar to update the part layout (re-calculate part widths) - * needed when an icon is added to or removed from the icon area - */ + // tell status bar to update the part layout (re-calculate part widths) + // needed when an icon is added to or removed from the icon area case WM_USER + 101: { int list_icons = 0; @@ -941,54 +911,45 @@ LONG_PTR CALLBACK StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPAR return 0; case WM_SETCURSOR: - { - POINT pt; + GetCursorPos(&pt); + SendMessage(GetParent(hWnd), msg, wParam, lParam); + if (pt.x == ptMouse.x && pt.y == ptMouse.y) + return 1; - GetCursorPos(&pt); - SendMessage(GetParent(hWnd), msg, wParam, lParam); - if (pt.x == ptMouse.x && pt.y == ptMouse.y) - return 1; - - ptMouse = pt; - if (tooltip_active) { - KillTimer(hWnd, TIMERID_HOVER); - CallService("mToolTip/HideTip", 0, 0); - tooltip_active = FALSE; - } + ptMouse = pt; + if (tooltip_active) { KillTimer(hWnd, TIMERID_HOVER); - SetTimer(hWnd, TIMERID_HOVER, 450, 0); + CallService("mToolTip/HideTip", 0, 0); + tooltip_active = FALSE; } + KillTimer(hWnd, TIMERID_HOVER); + SetTimer(hWnd, TIMERID_HOVER, 450, 0); break; case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: - { - POINT pt; - - KillTimer(hWnd, TIMERID_HOVER); - CallService("mToolTip/HideTip", 0, 0); - tooltip_active = FALSE; - GetCursorPos(&pt); - rcLastStatusBarClick.left = pt.x - 2; - rcLastStatusBarClick.right = pt.x + 2; - rcLastStatusBarClick.top = pt.y - 2; - rcLastStatusBarClick.bottom = pt.y + 2; - - if (pContainer->dwFlags & CNT_NOTITLE) { - POINT pt1 = pt; - RECT rcIconpart; - - ScreenToClient(hWnd, &pt1); - SendMessage(hWnd, SB_GETRECT, 2, (LPARAM)&rcIconpart); - if (!PtInRect(&rcIconpart, pt1)) - return SendMessage(pContainer->hwnd, WM_SYSCOMMAND, SC_MOVE | HTCAPTION, MAKELPARAM(pt.x, pt.y)); - } + KillTimer(hWnd, TIMERID_HOVER); + CallService("mToolTip/HideTip", 0, 0); + tooltip_active = FALSE; + GetCursorPos(&pt); + rcLastStatusBarClick.left = pt.x - 2; + rcLastStatusBarClick.right = pt.x + 2; + rcLastStatusBarClick.top = pt.y - 2; + rcLastStatusBarClick.bottom = pt.y + 2; + + if (pContainer->dwFlags & CNT_NOTITLE) { + POINT pt1 = pt; + ScreenToClient(hWnd, &pt1); + + RECT rcIconpart; + SendMessage(hWnd, SB_GETRECT, 2, (LPARAM)&rcIconpart); + if (!PtInRect(&rcIconpart, pt1)) + return SendMessage(pContainer->hwnd, WM_SYSCOMMAND, SC_MOVE | HTCAPTION, MAKELPARAM(pt.x, pt.y)); } break; case WM_TIMER: if (wParam == TIMERID_HOVER) { - POINT pt; CLCINFOTIP ti = {0}; ti.cbSize = sizeof(ti); @@ -1073,4 +1034,3 @@ LONG_PTR CALLBACK StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPAR } return CallWindowProc(OldStatusBarproc, hWnd, msg, wParam, lParam); } - diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp index 3af3c110ec..40b5ad4a0f 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.cpp +++ b/plugins/TabSRMM/src/generic_msghandlers.cpp @@ -298,7 +298,7 @@ LRESULT TSAPI DM_MsgWindowCmdHandler(HWND hwndDlg, TContainerData *m_pContainer, break; case IDC_SMILEYBTN: - if (dat->doSmileys && PluginConfig.g_SmileyAddAvail) { + if (dat->bShowSmileys && PluginConfig.g_SmileyAddAvail) { MCONTACT hContact = dat->cache->getActiveContact(); if (CheckValidSmileyPack(dat->cache->getProto(), hContact) != 0) { SMADD_SHOWSEL3 smaddInfo = {0}; @@ -1050,7 +1050,7 @@ void TSAPI DM_UpdateLastMessage(const TWindowData *dat) return; TCHAR szBuf[100]; - if (dat->showTyping) { + if (dat->bShowTyping) { SendMessage(dat->pContainer->hwndStatus, SB_SETICON, 0, (LPARAM)PluginConfig.g_buttonBarIcons[ICON_DEFAULT_TYPING]); mir_sntprintf(szBuf, SIZEOF(szBuf), TranslateT("%s is typing a message..."), dat->cache->getNick()); } @@ -1353,7 +1353,7 @@ void TSAPI DM_OptionsApplied(TWindowData *dat, WPARAM wParam, LPARAM lParam) LoadTimeZone(dat); - dat->showUIElements = m_pContainer->dwFlags & CNT_HIDETOOLBAR ? 0 : 1; + dat->bShowUIElements = (m_pContainer->dwFlags & CNT_HIDETOOLBAR) == 0; dat->dwFlagsEx = M.GetByte(dat->hContact, "splitoverride", 0) ? MWF_SHOW_SPLITTEROVERRIDE : 0; dat->Panel->getVisibility(); @@ -1391,7 +1391,7 @@ void TSAPI DM_Typing(TWindowData *dat, bool fForceOff) if (dat->nTypeMode == PROTOTYPE_SELFTYPING_ON && GetTickCount() - dat->nLastTyping > TIMEOUT_TYPEOFF) DM_NotifyTyping(dat, PROTOTYPE_SELFTYPING_OFF); - if (dat->showTyping == 1) { + if (dat->bShowTyping == 1) { if (dat->nTypeSecs > 0) { dat->nTypeSecs--; if (GetForegroundWindow() == hwndContainer) @@ -1399,7 +1399,7 @@ void TSAPI DM_Typing(TWindowData *dat, bool fForceOff) } else { if (!fForceOff) { - dat->showTyping = 2; + dat->bShowTyping = 2; dat->nTypeSecs = 86400; mir_sntprintf(dat->szStatusBar, SIZEOF(dat->szStatusBar), TranslateT("%s has entered text."), dat->cache->getNick()); @@ -1417,12 +1417,12 @@ void TSAPI DM_Typing(TWindowData *dat, bool fForceOff) ReflashContainer(dat->pContainer); } } - else if (dat->showTyping == 2) { + else if (dat->bShowTyping == 2) { if (dat->nTypeSecs > 0) dat->nTypeSecs--; else { dat->szStatusBar[0] = 0; - dat->showTyping = 0; + dat->bShowTyping = 0; } UpdateStatusBar(dat); } @@ -1455,7 +1455,7 @@ void TSAPI DM_Typing(TWindowData *dat, bool fForceOff) if ((GetForegroundWindow() != hwndContainer) || (dat->pContainer->hwndStatus == 0) || (dat->pContainer->hwndActive != hwndDlg)) SendMessage(hwndContainer, DM_SETICON, (WPARAM)dat, (LPARAM)PluginConfig.g_buttonBarIcons[ICON_DEFAULT_TYPING]); - dat->showTyping = 1; + dat->bShowTyping = 1; } } @@ -1576,10 +1576,10 @@ void TSAPI DM_EventAdded(TWindowData *dat, WPARAM hContact, LPARAM lParam) if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & (DBEF_SENT))) { dat->lastMessage = dbei.timestamp; dat->szStatusBar[0] = 0; - if (dat->showTyping) { + if (dat->bShowTyping) { dat->nTypeSecs = 0; DM_Typing(dat, true); - dat->showTyping = 0; + dat->bShowTyping = 0; } HandleIconFeedback(dat, (HICON)-1); if (m_pContainer->hwndStatus) diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp index 56d95ec1cd..2be3094c7a 100644 --- a/plugins/TabSRMM/src/globals.cpp +++ b/plugins/TabSRMM/src/globals.cpp @@ -458,7 +458,7 @@ int CGlobals::DBSettingChanged(WPARAM hContact, LPARAM lParam) TWindowData *dat = c->getDat(); if (dat) { dat->nTypeSecs = 0; - dat->showTyping = 0; + dat->bShowTyping = 0; dat->szStatusBar[0] = 0; PostMessage(c->getHwnd(), DM_UPDATELASTMESSAGE, 0, 0); } diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index b9da26406e..68b285ef28 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -1046,9 +1046,9 @@ static int MessageDialogResize(HWND hwndDlg, LPARAM lParam, UTILRESIZECONTROL * urc->rcItem.left = urc->rcItem.right - (dat->pic.cx + 2); if ((urc->rcItem.bottom - urc->rcItem.top) < (dat->pic.cy/* + 2*/) && dat->bShowAvatar) { urc->rcItem.top = urc->rcItem.bottom - dat->pic.cy; - dat->fMustOffset = true; + dat->bUseOffset = true; } - else dat->fMustOffset = false; + else dat->bUseOffset = false; if (showToolbar && bBottomToolbar && (PluginConfig.m_AlwaysFullToolbarWidth || ((dat->pic.cy - DPISCALEY_S(6)) < rc.bottom))) { urc->rcItem.bottom -= DPISCALEY_S(22); @@ -1071,7 +1071,7 @@ static int MessageDialogResize(HWND hwndDlg, LPARAM lParam, UTILRESIZECONTROL * OffsetRect(&urc->rcItem, 0, 1); urc->rcItem.left = 0; - if (dat->fMustOffset) + if (dat->bUseOffset) urc->rcItem.right -= (dat->pic.cx); // + DPISCALEX(2)); return RD_ANCHORX_CUSTOM | RD_ANCHORY_BOTTOM; @@ -1252,7 +1252,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP dat->hwndPanelPicParent = CreateWindowEx(WS_EX_TOPMOST, _T("Static"), _T(""), SS_OWNERDRAW | WS_VISIBLE | WS_CHILD, 1, 1, 1, 1, hwndDlg, (HMENU)6000, NULL, NULL); mir_subclassWindow(dat->hwndPanelPicParent, CInfoPanel::avatarParentSubclass); - dat->showUIElements = m_pContainer->dwFlags & CNT_HIDETOOLBAR ? 0 : 1; + dat->bShowUIElements = (m_pContainer->dwFlags & CNT_HIDETOOLBAR) == 0; dat->sendMode |= M.GetByte(dat->hContact, "forceansi", 0) ? SMODE_FORCEANSI : 0; dat->sendMode |= dat->hContact == 0 ? SMODE_MULTIPLE : 0; dat->sendMode |= M.GetByte(dat->hContact, "no_ack", 0) ? SMODE_NOACK : 0; @@ -1290,12 +1290,6 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (dat->hContact && M.GetDword(dat->hContact, "mwmask", 0)) LoadLocalFlags(hwndDlg, dat); - // allow disabling emoticons per contact (note: currently unused feature) - { - int dwLocalSmAdd = M.GetByte(dat->hContact, "doSmileys", 0xff); - if (dwLocalSmAdd != 0xffffffff) - dat->doSmileys = dwLocalSmAdd; - } DM_InitTip(dat); dat->Panel->getVisibility(); @@ -2150,7 +2144,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP dat->nTypeSecs = (int)lParam > 0 ? (int)lParam : 0; if (dat->nTypeSecs) - dat->showTyping = 0; + dat->bShowTyping = 0; SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, preTyping); } @@ -2181,7 +2175,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP // configures the toolbar only... if lParam != 0, then it also calls // SetDialogToType() to reconfigure the message window case DM_CONFIGURETOOLBAR: - dat->showUIElements = m_pContainer->dwFlags & CNT_HIDETOOLBAR ? 0 : 1; + dat->bShowUIElements = m_pContainer->dwFlags & CNT_HIDETOOLBAR ? 0 : 1; SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_SPLITTER), GWL_EXSTYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_SPLITTER), GWL_EXSTYLE) & ~WS_EX_STATICEDGE); diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp index 85a872ac5e..a6bed193e1 100644 --- a/plugins/TabSRMM/src/msgdlgutils.cpp +++ b/plugins/TabSRMM/src/msgdlgutils.cpp @@ -229,10 +229,10 @@ void TSAPI CalcDynamicAvatarSize(TWindowData *dat, BITMAP *bminfo) int iSplitOffset = dat->bIsAutosizingInput ? 1 : 0; double picAspect = (bminfo->bmWidth == 0 || bminfo->bmHeight == 0) ? 1.0 : (double)(bminfo->bmWidth / (double)bminfo->bmHeight); - double picProjectedWidth = (double)((dat->dynaSplitter - ((bBottomToolBar && bToolBar) ? DPISCALEX_S(24) : 0) + ((dat->showUIElements != 0) ? DPISCALEX_S(28) : DPISCALEX_S(2)))) * picAspect; + double picProjectedWidth = (double)((dat->dynaSplitter - ((bBottomToolBar && bToolBar) ? DPISCALEX_S(24) : 0) + ((dat->bShowUIElements) ? DPISCALEX_S(28) : DPISCALEX_S(2)))) * picAspect; if ((rc.right - (int)picProjectedWidth) > (dat->iButtonBarReallyNeeds) && !PluginConfig.m_AlwaysFullToolbarWidth && bToolBar) - dat->iRealAvatarHeight = dat->dynaSplitter + 3 + (dat->showUIElements ? DPISCALEY_S(28) : DPISCALEY_S(2)); + dat->iRealAvatarHeight = dat->dynaSplitter + 3 + (dat->bShowUIElements ? DPISCALEY_S(28) : DPISCALEY_S(2)); else dat->iRealAvatarHeight = dat->dynaSplitter + DPISCALEY_S(6) + DPISCALEY_S(iSplitOffset); @@ -1747,14 +1747,14 @@ void TSAPI ConfigureSmileyButton(TWindowData *dat) if (PluginConfig.g_SmileyAddAvail) { nrSmileys = CheckValidSmileyPack(dat->cache->getActiveProto(), dat->cache->getActiveContact()); - dat->doSmileys = 1; + dat->bShowSmileys = true; } if (nrSmileys == 0 || dat->hContact == 0) - dat->doSmileys = 0; + dat->bShowSmileys = false; - Utils::showDlgControl(hwndDlg, iItemID, (dat->doSmileys && showToolbar) ? SW_SHOW : SW_HIDE); - Utils::enableDlgControl(hwndDlg, iItemID, dat->doSmileys ? TRUE : FALSE); + Utils::showDlgControl(hwndDlg, iItemID, (dat->bShowSmileys && showToolbar) ? SW_SHOW : SW_HIDE); + Utils::enableDlgControl(hwndDlg, iItemID, dat->bShowSmileys); } HICON TSAPI GetXStatusIcon(const TWindowData *dat) diff --git a/plugins/TabSRMM/src/msglog.cpp b/plugins/TabSRMM/src/msglog.cpp index 5ffcf79407..7b4a7312b3 100644 --- a/plugins/TabSRMM/src/msglog.cpp +++ b/plugins/TabSRMM/src/msglog.cpp @@ -60,9 +60,6 @@ wchar_t* months[12] = LPGENT("July"), LPGENT("August"), LPGENT("September"), LPGENT("October"), LPGENT("November"), LPGENT("December") }; -static TCHAR *Template_MakeRelativeDate(TWindowData *dat, HANDLE hTimeZone, time_t check, int groupBreak, TCHAR code); -static void ReplaceIcons(HWND hwndDlg, TWindowData *dat, LONG startAt, int fAppend, BOOL isSent); - static time_t today; int g_groupBreak = TRUE; @@ -124,7 +121,7 @@ static void TrimMessage(TCHAR *msg) i--; } if (i < iLen) - msg[i+1] = '\0'; + msg[i + 1] = '\0'; } void TSAPI CacheLogFonts() @@ -135,9 +132,9 @@ void TSAPI CacheLogFonts() ReleaseDC(NULL, hdc); ZeroMemory(logfonts, sizeof(LOGFONTA) * MSGDLGFONTCOUNT + 2); - for (i=0; i < MSGDLGFONTCOUNT; i++) { + for (i = 0; i < MSGDLGFONTCOUNT; i++) { LoadLogfont(i, &logfonts[i], &fontcolors[i], FONTMODULE); - mir_snprintf(rtfFontsGlobal[i], SIZEOF(rtfFontsGlobal[i]), "\\f%u\\cf%u\\b%d\\i%d\\ul%d\\fs%u", i, i, logfonts[i].lfWeight >= FW_BOLD ? 1 : 0, logfonts[i].lfItalic,logfonts[i].lfUnderline, 2 * abs(logfonts[i].lfHeight) * 74 / logPixelSY); + mir_snprintf(rtfFontsGlobal[i], SIZEOF(rtfFontsGlobal[i]), "\\f%u\\cf%u\\b%d\\i%d\\ul%d\\fs%u", i, i, logfonts[i].lfWeight >= FW_BOLD ? 1 : 0, logfonts[i].lfItalic, logfonts[i].lfUnderline, 2 * abs(logfonts[i].lfHeight) * 74 / logPixelSY); } mir_snprintf(rtfFontsGlobal[MSGDLGFONTCOUNT], SIZEOF(rtfFontsGlobal[MSGDLGFONTCOUNT]), "\\f%u\\cf%u\\b%d\\i%d\\fs%u", MSGDLGFONTCOUNT, MSGDLGFONTCOUNT, 0, 0, 0); @@ -152,7 +149,7 @@ void TSAPI CacheLogFonts() COLORREF clr; LOGFONTA lf; - for (i=0; i < IPFONTCOUNT; i++) { + for (i = 0; i < IPFONTCOUNT; i++) { if (CInfoPanel::m_ipConfig.hFonts[i]) DeleteObject(CInfoPanel::m_ipConfig.hFonts[i]); LoadLogfont(i + 100, &lf, &clr, FONTMODULE); @@ -185,7 +182,7 @@ void TSAPI CacheLogFonts() void FreeLogFonts() { - for (int i=0; i < IPFONTCOUNT; i++) + for (int i = 0; i < IPFONTCOUNT; i++) if (CInfoPanel::m_ipConfig.hFonts[i]) DeleteObject(CInfoPanel::m_ipConfig.hFonts[i]); } @@ -232,7 +229,7 @@ static int AppendUnicodeToBuffer(char **buffer, int *cbBufferEnd, int *cbBufferA int lineLen = (int)(wcslen(line)) * 9 + 8; if (*cbBufferEnd + lineLen > *cbBufferAlloced) { cbBufferAlloced[0] += (lineLen + 1024UL - lineLen % 1024UL); - *buffer = (char *) mir_realloc(*buffer, *cbBufferAlloced); + *buffer = (char*)mir_realloc(*buffer, *cbBufferAlloced); } char *d = *buffer + *cbBufferEnd; @@ -333,7 +330,7 @@ static int AppendToBufferWithRTF(int mode, char **buffer, int *cbBufferEnd, int if (charsDone >= 0) break; *cbBufferAlloced += 1024; - *buffer = (char *) mir_realloc(*buffer, *cbBufferAlloced); + *buffer = (char *)mir_realloc(*buffer, *cbBufferAlloced); } va_end(va); *cbBufferEnd += charsDone; @@ -349,39 +346,38 @@ static int AppendToBufferWithRTF(int mode, char **buffer, int *cbBufferEnd, int if (*cbBufferEnd + 5 > *cbBufferAlloced) { *cbBufferAlloced += 1024; - *buffer = (char *) mir_realloc(*buffer, *cbBufferAlloced); + *buffer = (char *)mir_realloc(*buffer, *cbBufferAlloced); } switch (tag) { - case 'b': - CopyMemory(*buffer + i, begin ? "\\b1 " : "\\b0 ", 4); - continue; - case 'i': - CopyMemory(*buffer + i, begin ? "\\i1 " : "\\i0 ", 4); - continue; - case 'u': - MoveMemory(*buffer + i + 2, *buffer + i + 1, *cbBufferEnd - i); - CopyMemory(*buffer + i, begin ? "\\ul1 " : "\\ul0 ", 5); - *cbBufferEnd += 1; - continue; - case 's': - *cbBufferAlloced += 20; - *buffer = (char *)mir_realloc(*buffer, *cbBufferAlloced); - MoveMemory(*buffer + i + 6, *buffer + i + 1, (*cbBufferEnd - i) + 1); - CopyMemory(*buffer + i, begin ? "\\strike1 " : "\\strike0 ", begin ? 9 : 9); - *cbBufferEnd += 5; - continue; - case 'c': - begin = (code == 'x'); - CopyMemory(*buffer + i, "\\cf", 3); - if (begin) { - } else { - char szTemp[10]; - int colindex = GetColorIndex(GetRTFFont(LOWORD(mode) ? (MSGFONTID_MYMSG + (HIWORD(mode) ? 8 : 0)) : (MSGFONTID_YOURMSG + (HIWORD(mode) ? 8 : 0)))); - mir_snprintf(szTemp, 4, "%02d", colindex); - (*buffer)[i + 3] = szTemp[0]; - (*buffer)[i + 4] = szTemp[1]; - } - continue; + case 'b': + CopyMemory(*buffer + i, begin ? "\\b1 " : "\\b0 ", 4); + continue; + case 'i': + CopyMemory(*buffer + i, begin ? "\\i1 " : "\\i0 ", 4); + continue; + case 'u': + MoveMemory(*buffer + i + 2, *buffer + i + 1, *cbBufferEnd - i); + CopyMemory(*buffer + i, begin ? "\\ul1 " : "\\ul0 ", 5); + *cbBufferEnd += 1; + continue; + case 's': + *cbBufferAlloced += 20; + *buffer = (char *)mir_realloc(*buffer, *cbBufferAlloced); + MoveMemory(*buffer + i + 6, *buffer + i + 1, (*cbBufferEnd - i) + 1); + CopyMemory(*buffer + i, begin ? "\\strike1 " : "\\strike0 ", begin ? 9 : 9); + *cbBufferEnd += 5; + continue; + case 'c': + begin = (code == 'x'); + CopyMemory(*buffer + i, "\\cf", 3); + if (!begin) { + char szTemp[10]; + int colindex = GetColorIndex(GetRTFFont(LOWORD(mode) ? (MSGFONTID_MYMSG + (HIWORD(mode) ? 8 : 0)) : (MSGFONTID_YOURMSG + (HIWORD(mode) ? 8 : 0)))); + mir_snprintf(szTemp, 4, "%02d", colindex); + (*buffer)[i + 3] = szTemp[0]; + (*buffer)[i + 4] = szTemp[1]; + } + continue; } } } @@ -390,31 +386,34 @@ static int AppendToBufferWithRTF(int mode, char **buffer, int *cbBufferEnd, int if ((*buffer)[i] == '\r' && (*buffer)[i + 1] == '\n') { if (*cbBufferEnd + 5 > *cbBufferAlloced) { *cbBufferAlloced += 1024; - *buffer = (char *) mir_realloc(*buffer, *cbBufferAlloced); + *buffer = (char *)mir_realloc(*buffer, *cbBufferAlloced); } MoveMemory(*buffer + i + 6, *buffer + i + 2, *cbBufferEnd - i - 1); CopyMemory(*buffer + i, "\\line ", 6); *cbBufferEnd += 4; - } else if ((*buffer)[i] == '\n') { + } + else if ((*buffer)[i] == '\n') { if (*cbBufferEnd + 6 > *cbBufferAlloced) { *cbBufferAlloced += 1024; - *buffer = (char *) mir_realloc(*buffer, *cbBufferAlloced); + *buffer = (char *)mir_realloc(*buffer, *cbBufferAlloced); } MoveMemory(*buffer + i + 6, *buffer + i + 1, *cbBufferEnd - i); CopyMemory(*buffer + i, "\\line ", 6); *cbBufferEnd += 5; - } else if ((*buffer)[i] == '\t') { + } + else if ((*buffer)[i] == '\t') { if (*cbBufferEnd + 5 > *cbBufferAlloced) { *cbBufferAlloced += 1024; - *buffer = (char *) mir_realloc(*buffer, *cbBufferAlloced); + *buffer = (char *)mir_realloc(*buffer, *cbBufferAlloced); } MoveMemory(*buffer + i + 5, *buffer + i + 1, *cbBufferEnd - i); CopyMemory(*buffer + i, "\\tab ", 5); *cbBufferEnd += 4; - } else if ((*buffer)[i] == '\\' || (*buffer)[i] == '{' || (*buffer)[i] == '}') { + } + else if ((*buffer)[i] == '\\' || (*buffer)[i] == '{' || (*buffer)[i] == '}') { if (*cbBufferEnd + 2 > *cbBufferAlloced) { *cbBufferAlloced += 1024; - *buffer = (char *) mir_realloc(*buffer, *cbBufferAlloced); + *buffer = (char *)mir_realloc(*buffer, *cbBufferAlloced); } MoveMemory(*buffer + i + 1, *buffer + i, *cbBufferEnd - i + 1); (*buffer)[i] = '\\'; @@ -427,11 +426,10 @@ static int AppendToBufferWithRTF(int mode, char **buffer, int *cbBufferEnd, int static void Build_RTF_Header(char **buffer, int *bufferEnd, int *bufferAlloced, TWindowData *dat) { - COLORREF colour; - int i; - char szTemp[30]; - LOGFONTA* logFonts = dat->pContainer->theme.logFonts; - COLORREF* fontColors = dat->pContainer->theme.fontColors; + int i; + char szTemp[30]; + LOGFONTA *logFonts = dat->pContainer->theme.logFonts; + COLORREF *fontColors = dat->pContainer->theme.fontColors; TLogTheme *theme = &dat->pContainer->theme; // rtl @@ -440,20 +438,18 @@ static void Build_RTF_Header(char **buffer, int *bufferEnd, int *bufferAlloced, else AppendToBuffer(buffer, bufferEnd, bufferAlloced, "{\\rtf1\\ansi\\deff0{\\fonttbl"); - for (i=0; i < MSGDLGFONTCOUNT; i++) + for (i = 0; i < MSGDLGFONTCOUNT; i++) AppendToBuffer(buffer, bufferEnd, bufferAlloced, "{\\f%u\\fnil\\fcharset%u %s;}", i, logFonts[i].lfCharSet, logFonts[i].lfFaceName); AppendToBuffer(buffer, bufferEnd, bufferAlloced, "{\\f%u\\fnil\\fcharset%u %s;}", MSGDLGFONTCOUNT, logFonts[i].lfCharSet, "Arial"); AppendToBuffer(buffer, bufferEnd, bufferAlloced, "}{\\colortbl "); - for (i=0; i < MSGDLGFONTCOUNT; i++) + for (i = 0; i < MSGDLGFONTCOUNT; i++) AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(fontColors[i]), GetGValue(fontColors[i]), GetBValue(fontColors[i])); - if (GetSysColorBrush(COLOR_HOTLIGHT) == NULL) - colour = RGB(0, 0, 255); - else - colour = GetSysColor(COLOR_HOTLIGHT); + + COLORREF colour = (GetSysColorBrush(COLOR_HOTLIGHT) == NULL) ? RGB(0, 0, 255) : GetSysColor(COLOR_HOTLIGHT); AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(colour), GetGValue(colour), GetBValue(colour)); - /* OnO: Create incoming and outcoming colours */ + // OnO: Create incoming and outcoming colours colour = theme->inbg; AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(colour), GetGValue(colour), GetBValue(colour)); colour = theme->outbg; @@ -470,7 +466,6 @@ static void Build_RTF_Header(char **buffer, int *bufferEnd, int *bufferAlloced, AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(colour), GetGValue(colour), GetBValue(colour)); // custom template colors... - for (i = 1; i <= 5; i++) { mir_snprintf(szTemp, 10, "cc%d", i); colour = theme->custom_colors[i - 1]; @@ -480,31 +475,25 @@ static void Build_RTF_Header(char **buffer, int *bufferEnd, int *bufferAlloced, } // bbcode colors... - - for (i=0; i < Utils::rtf_ctable_size; i++) + for (i = 0; i < Utils::rtf_ctable_size; i++) AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(Utils::rtf_ctable[i].clr), GetGValue(Utils::rtf_ctable[i].clr), GetBValue(Utils::rtf_ctable[i].clr)); - /* - * paragraph header - */ + // paragraph header AppendToBuffer(buffer, bufferEnd, bufferAlloced, "}"); - /* - * indent: - * real indent is set in msgdialog.c (DM_OPTIONSAPPLIED) - */ - + // indent: + // real indent is set in msgdialog.c (DM_OPTIONSAPPLIED) if (!(dat->dwFlags & MWF_LOG_INDENT)) - AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\li%u\\ri%u\\fi%u\\tx%u", 2*15, 2*15, 0, 70 * 15); + AppendToBuffer(buffer, bufferEnd, bufferAlloced, "\\li%u\\ri%u\\fi%u\\tx%u", 2 * 15, 2 * 15, 0, 70 * 15); } -//mir_free() the return value -static char *CreateRTFHeader(TWindowData *dat) +// mir_free() the return value +static char* CreateRTFHeader(TWindowData *dat) { int bufferEnd = 0; int bufferAlloced = 1024; - char *buffer = (char *) mir_alloc(bufferAlloced); + char *buffer = (char*)mir_alloc(bufferAlloced); buffer[0] = '\0'; Build_RTF_Header(&buffer, &bufferEnd, &bufferAlloced, dat); @@ -512,17 +501,41 @@ static char *CreateRTFHeader(TWindowData *dat) } static void AppendTimeStamp(TCHAR *szFinalTimestamp, int isSent, char **buffer, int *bufferEnd, int *bufferAlloced, int skipFont, - TWindowData *dat, int iFontIDOffset) + TWindowData *dat, int iFontIDOffset) { if (skipFont) - AppendUnicodeToBuffer(buffer, bufferEnd, bufferAlloced, szFinalTimestamp, MAKELONG(isSent, dat->isHistory)); + AppendUnicodeToBuffer(buffer, bufferEnd, bufferAlloced, szFinalTimestamp, MAKELONG(isSent, dat->bIsHistory)); else { AppendToBuffer(buffer, bufferEnd, bufferAlloced, "%s ", GetRTFFont(isSent ? MSGFONTID_MYTIME + iFontIDOffset : MSGFONTID_YOURTIME + iFontIDOffset)); - AppendUnicodeToBuffer(buffer, bufferEnd, bufferAlloced, szFinalTimestamp, MAKELONG(isSent, dat->isHistory)); + AppendUnicodeToBuffer(buffer, bufferEnd, bufferAlloced, szFinalTimestamp, MAKELONG(isSent, dat->bIsHistory)); } } -//mir_free() the return value +static TCHAR* Template_MakeRelativeDate(TWindowData *dat, HANDLE hTimeZone, time_t check, int groupBreak, TCHAR code) +{ + static TCHAR szResult[100]; + const TCHAR *szFormat; + + if ((code == (TCHAR)'R' || code == (TCHAR)'r') && check >= today) + _tcscpy(szResult, szToday); + else if ((code == (TCHAR)'R' || code == (TCHAR)'r') && check > (today - 86400)) + _tcscpy(szResult, szYesterday); + else { + if (code == 'D' || code == 'R') + szFormat = _T("D"); + else if (code == 'T') + szFormat = _T("s"); + else if (code == 't') + szFormat = _T("t"); + else + szFormat = _T("d"); + + tmi.printTimeStamp(hTimeZone, check, szFormat, szResult, SIZEOF(szResult), 0); + } + return szResult; +} + +// mir_free() the return value static char *CreateRTFTail(TWindowData *dat) { char *buffer; @@ -530,7 +543,7 @@ static char *CreateRTFTail(TWindowData *dat) bufferEnd = 0; bufferAlloced = 1024; - buffer = (char *) mir_alloc(bufferAlloced); + buffer = (char *)mir_alloc(bufferAlloced); buffer[0] = '\0'; AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "}"); return buffer; @@ -572,7 +585,7 @@ static char *Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, mir_free(buffer); return NULL; } - dbei.pBlob = (PBYTE) mir_alloc(dbei.cbBlob); + dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob); db_event_get(hDbEvent, &dbei); if (!DbEventIsShown(dat, &dbei)) { mir_free(dbei.pBlob); @@ -582,7 +595,7 @@ static char *Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, } if (dbei.eventType == EVENTTYPE_MESSAGE && !dbei.markedRead()) - dat->cache->updateStats(TSessionStats::SET_LAST_RCV, lstrlenA((char *) dbei.pBlob)); + dat->cache->updateStats(TSessionStats::SET_LAST_RCV, lstrlenA((char *)dbei.pBlob)); TCHAR *formatted = NULL; if (rtfMessage == NULL) { @@ -612,8 +625,8 @@ static char *Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, DWORD dwEffectiveFlags = dat->dwFlags; - dat->isHistory = (dbei.timestamp < dat->cache->getSessionStart() && dbei.markedRead()); - int iFontIDOffset = dat->isHistory ? 8 : 0; // offset into the font table for either history (old) or new events... (# of fonts per configuration set) + dat->bIsHistory = (dbei.timestamp < dat->cache->getSessionStart() && dbei.markedRead()); + int iFontIDOffset = dat->bIsHistory ? 8 : 0; // offset into the font table for either history (old) or new events... (# of fonts per configuration set) BOOL isSent = (dbei.flags & DBEF_SENT); if (!isSent && (bIsStatusChangeEvent || dbei.eventType == EVENTTYPE_MESSAGE || DbEventIsForMsgWindow(&dbei))) { @@ -648,7 +661,7 @@ static char *Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, if (bIsStatusChangeEvent) AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\highlight%d\\cf%d", MSGDLGFONTCOUNT + 7, MSGDLGFONTCOUNT + 7); else - AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\highlight%d\\cf%d", MSGDLGFONTCOUNT + (dat->isHistory?5:1) + ((isSent) ? 1 : 0), MSGDLGFONTCOUNT + (dat->isHistory?5:1) + ((isSent) ? 1 : 0)); + AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\highlight%d\\cf%d", MSGDLGFONTCOUNT + (dat->bIsHistory ? 5 : 1) + ((isSent) ? 1 : 0), MSGDLGFONTCOUNT + (dat->bIsHistory ? 5 : 1) + ((isSent) ? 1 : 0)); streamData->isEmpty = FALSE; @@ -665,7 +678,7 @@ static char *Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, time_t local_time = tmi.timeStampToTimeZoneTimeStamp(hTimeZone, dbei.timestamp); event_time = *gmtime(&local_time); } - + TTemplateSet *this_templateset = dbei.flags & DBEF_RTL ? dat->pContainer->rtl_templates : dat->pContainer->ltr_templates; TCHAR *szTemplate; @@ -676,7 +689,7 @@ static char *Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, else { if (dwEffectiveFlags & MWF_LOG_GROUPMODE) szTemplate = isSent ? (g_groupBreak ? this_templateset->szTemplates[TMPL_GRPSTARTOUT] : this_templateset->szTemplates[TMPL_GRPINNEROUT]) : - (g_groupBreak ? this_templateset->szTemplates[TMPL_GRPSTARTIN] : this_templateset->szTemplates[TMPL_GRPINNERIN]); + (g_groupBreak ? this_templateset->szTemplates[TMPL_GRPSTARTIN] : this_templateset->szTemplates[TMPL_GRPINNERIN]); else szTemplate = isSent ? this_templateset->szTemplates[TMPL_MSGOUT] : this_templateset->szTemplates[TMPL_MSGIN]; } @@ -695,7 +708,7 @@ static char *Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\ul0\\b0\\i0 "); - for (size_t i = 0; i < iTemplateLen; ) { + for (size_t i = 0; i < iTemplateLen;) { TCHAR ci = szTemplate[i]; if (ci == '%') { TCHAR cc = szTemplate[i + 1]; @@ -707,7 +720,7 @@ static char *Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, while (cc == '#' || cc == '$' || cc == '&' || cc == '?' || cc == '\\') { switch (cc) { case '#': - if (!dat->isHistory) { + if (!dat->bIsHistory) { skipToNext = TRUE; goto skip; } @@ -716,7 +729,7 @@ static char *Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, continue; case '$': - if (dat->isHistory) { + if (dat->bIsHistory) { skipToNext = TRUE; goto skip; } @@ -844,10 +857,10 @@ static char *Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, case 'O': // month (name) if (showTime && showDate) { if (skipFont) - AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, TranslateTS(months[event_time.tm_mon]), MAKELONG(isSent, dat->isHistory)); + AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, TranslateTS(months[event_time.tm_mon]), MAKELONG(isSent, dat->bIsHistory)); else { AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s ", GetRTFFont(isSent ? MSGFONTID_MYTIME + iFontIDOffset : MSGFONTID_YOURTIME + iFontIDOffset)); - AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, TranslateTS(months[event_time.tm_mon]), MAKELONG(isSent, dat->isHistory)); + AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, TranslateTS(months[event_time.tm_mon]), MAKELONG(isSent, dat->bIsHistory)); } } else skipToNext = TRUE; @@ -864,10 +877,10 @@ static char *Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, case 'w': // day of week if (showTime && showDate) { if (skipFont) - AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, TranslateTS(weekDays[event_time.tm_wday]), MAKELONG(isSent, dat->isHistory)); + AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, TranslateTS(weekDays[event_time.tm_wday]), MAKELONG(isSent, dat->bIsHistory)); else { AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s ", GetRTFFont(isSent ? MSGFONTID_MYTIME + iFontIDOffset : MSGFONTID_YOURTIME + iFontIDOffset)); - AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, TranslateTS(weekDays[event_time.tm_wday]), MAKELONG(isSent, dat->isHistory)); + AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, TranslateTS(weekDays[event_time.tm_wday]), MAKELONG(isSent, dat->bIsHistory)); } } else skipToNext = TRUE; @@ -937,21 +950,21 @@ static char *Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, if (!skipFont) AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s ", GetRTFFont(isSent ? MSGFONTID_MYNAME + iFontIDOffset : MSGFONTID_YOURNAME + iFontIDOffset)); if (isSent) - AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, szMyName, MAKELONG(isSent, dat->isHistory)); + AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, szMyName, MAKELONG(isSent, dat->bIsHistory)); else - AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, szYourName, MAKELONG(isSent, dat->isHistory)); + AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, szYourName, MAKELONG(isSent, dat->bIsHistory)); break; case 'U': // UIN if (!skipFont) AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s ", GetRTFFont(isSent ? MSGFONTID_MYNAME + iFontIDOffset : MSGFONTID_YOURNAME + iFontIDOffset)); if (!isSent) - AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, dat->cache->getUIN(), MAKELONG(isSent, dat->isHistory)); + AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, dat->cache->getUIN(), MAKELONG(isSent, dat->bIsHistory)); else - AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, dat->myUin, MAKELONG(isSent, dat->isHistory)); + AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, dat->myUin, MAKELONG(isSent, dat->bIsHistory)); break; case 'e': // error message AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s ", GetRTFFont(MSGFONTID_ERROR)); - AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, (wchar_t *)dbei.szModule, MAKELONG(isSent, dat->isHistory)); + AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, (wchar_t *)dbei.szModule, MAKELONG(isSent, dat->bIsHistory)); break; case 'M': // message switch (dbei.eventType) { @@ -975,7 +988,7 @@ static char *Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, if (rtfMessage != NULL) AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s", rtfMessage); else - AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, formatted, MAKELONG(isSent, dat->isHistory)); + AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, formatted, MAKELONG(isSent, dat->bIsHistory)); AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s", "\\b0\\ul0\\i0 "); break; @@ -1003,7 +1016,7 @@ static char *Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, default: if (!skipFont) AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s ", GetRTFFont(isSent ? MSGFONTID_MYMSG + iFontIDOffset : MSGFONTID_YOURMSG + iFontIDOffset)); - + ptrT tszText(DbGetEventTextT(&dbei, CP_ACP)); AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, tszText, 0); } @@ -1037,7 +1050,7 @@ static char *Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\highlight%d", MSGDLGFONTCOUNT + 8 + (color - '0')); i++; } - else AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\highlight%d", (MSGDLGFONTCOUNT + (dat->isHistory ? 5 : 1) + ((isSent) ? 1 : 0))); + else AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\highlight%d", (MSGDLGFONTCOUNT + (dat->bIsHistory ? 5 : 1) + ((isSent) ? 1 : 0))); break; case '|': // tab if (dwEffectiveFlags & MWF_LOG_INDENT) @@ -1136,7 +1149,7 @@ skip: static DWORD CALLBACK LogStreamInEvents(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG * pcb) { - LogStreamData *dat = (LogStreamData *) dwCookie; + LogStreamData *dat = (LogStreamData *)dwCookie; if (dat->buffer == NULL) { dat->bufferOffset = 0; @@ -1158,11 +1171,10 @@ static DWORD CALLBACK LogStreamInEvents(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG if (--dat->eventsToInsert == 0) break; } - while (dat->buffer == NULL && dat->hDbEvent); - if (dat->buffer) { - //dat->isEmpty = 0; + while (dat->buffer == NULL && dat->hDbEvent); + + if (dat->buffer) break; - } } dat->stage = STREAMSTAGE_TAIL; @@ -1197,16 +1209,137 @@ static void SetupLogFormatting(TWindowData *dat) mir_snprintf(dat->szMicroLf, sizeof(dat->szMicroLf), "%s\\par\\ltrpar\\sl-1%s ", GetRTFFont(MSGDLGFONTCOUNT), GetRTFFont(MSGDLGFONTCOUNT)); } +static void ReplaceIcons(HWND hwndDlg, TWindowData *dat, LONG startAt, int fAppend, BOOL isSent) +{ + DWORD dwScale = M.GetDword("iconscale", 0); + + TCHAR trbuffer[40]; + TEXTRANGE tr; + tr.lpstrText = trbuffer; + + HWND hwndrtf = GetDlgItem(hwndDlg, IDC_LOG); + + FINDTEXTEX fi; + fi.chrg.cpMin = startAt; + if (dat->clr_added) { + fi.lpstrText = _T("##col##"); + fi.chrg.cpMax = -1; + CHARFORMAT2 cf2; + ZeroMemory(&cf2, sizeof(cf2)); + cf2.cbSize = sizeof(cf2); + cf2.dwMask = CFM_COLOR; + while (SendMessage(hwndrtf, EM_FINDTEXTEX, FR_DOWN, (LPARAM)&fi) > -1) { + tr.chrg.cpMin = fi.chrgText.cpMin; + tr.chrg.cpMax = tr.chrg.cpMin + 18; + trbuffer[0] = 0; + SendMessage(hwndrtf, EM_GETTEXTRANGE, 0, (LPARAM)&tr); + trbuffer[18] = 0; + + CHARRANGE cr; + cr.cpMin = fi.chrgText.cpMin; + cr.cpMax = cr.cpMin + 18; + SendMessage(hwndrtf, EM_EXSETSEL, 0, (LPARAM)&cr); + SendMessage(hwndrtf, EM_REPLACESEL, FALSE, (LPARAM)_T("")); + UINT length = (unsigned int)_ttol(&trbuffer[7]); + int index = _ttol(&trbuffer[14]); + if (length > 0 && length < 20000 && index >= RTF_CTABLE_DEFSIZE && index < Utils::rtf_ctable_size) { + cf2.crTextColor = Utils::rtf_ctable[index].clr; + cr.cpMin = fi.chrgText.cpMin; + cr.cpMax = cr.cpMin + length; + SendMessage(hwndrtf, EM_EXSETSEL, 0, (LPARAM)&cr); + SendMessage(hwndrtf, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); + } + } + } + + fi.chrg.cpMin = startAt; + if (dat->dwFlags & MWF_LOG_SHOWICONS) { + BYTE bIconIndex = 0; + char bDirection = 0; + fi.lpstrText = _T("#~#"); + fi.chrg.cpMax = -1; + + CHARFORMAT2 cf2; + ZeroMemory(&cf2, sizeof(cf2)); + cf2.cbSize = sizeof(cf2); + cf2.dwMask = CFM_BACKCOLOR; + + IRichEditOle *ole; + SendMessage(hwndrtf, EM_GETOLEINTERFACE, 0, (LPARAM)&ole); + while (SendMessageA(hwndrtf, EM_FINDTEXTEX, FR_DOWN, (LPARAM)&fi) > -1) { + CHARRANGE cr; + cr.cpMin = fi.chrgText.cpMin; + cr.cpMax = fi.chrgText.cpMax + 2; + SendMessage(hwndrtf, EM_EXSETSEL, 0, (LPARAM)&cr); + + tr.chrg.cpMin = fi.chrgText.cpMin + 3; + tr.chrg.cpMax = fi.chrgText.cpMin + 5; + SendMessage(hwndrtf, EM_GETTEXTRANGE, 0, (LPARAM)&tr); + bIconIndex = ((BYTE)trbuffer[0] - (BYTE)'0'); + if (bIconIndex >= NR_LOGICONS) { + fi.chrg.cpMin = fi.chrgText.cpMax + 6; + continue; + } + bDirection = trbuffer[1]; + SendMessage(hwndrtf, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); + COLORREF crDefault = cf2.crBackColor == 0 ? (true ? (bDirection == '>' ? (fAppend ? dat->pContainer->theme.outbg : dat->pContainer->theme.oldoutbg) : + (fAppend ? dat->pContainer->theme.inbg : dat->pContainer->theme.oldinbg)) : dat->pContainer->theme.bg) : cf2.crBackColor; + + TLogIcon theIcon; + CacheIconToBMP(&theIcon, Logicons[bIconIndex], crDefault, dwScale, dwScale); + ImageDataInsertBitmap(ole, theIcon.hBmp); + DeleteCachedIcon(&theIcon); + fi.chrg.cpMin = cr.cpMax + 6; + } + ole->Release(); + } + + // do smiley replacing, using the service + if (PluginConfig.g_SmileyAddAvail) { + CHARRANGE sel; + sel.cpMin = startAt; + sel.cpMax = -1; + + SMADD_RICHEDIT3 smadd = { sizeof(smadd) }; + smadd.hwndRichEditControl = GetDlgItem(hwndDlg, IDC_LOG); + smadd.Protocolname = const_cast(dat->cache->getActiveProto()); + smadd.hContact = dat->cache->getActiveContact(); + smadd.flags = isSent ? SAFLRE_OUTGOING : 0; + if (startAt > 0) + smadd.rangeToReplace = &sel; + else + smadd.rangeToReplace = NULL; + smadd.disableRedraw = TRUE; + if (dat->bShowSmileys) + CallService(MS_SMILEYADD_REPLACESMILEYS, TABSRMM_SMILEYADD_BKGCOLORMODE, (LPARAM)&smadd); + } + + if (dat->hHistoryEvents && dat->curHistory == dat->maxHistory) { + char szPattern[50]; + mir_snprintf(szPattern, 40, "~-+%d+-~", (INT_PTR)dat->hHistoryEvents[0]); + + FINDTEXTEXA fi; + fi.lpstrText = szPattern; + fi.chrg.cpMin = 0; + fi.chrg.cpMax = -1; + if (SendMessageA(hwndrtf, EM_FINDTEXTEX, FR_DOWN, (LPARAM)&fi) != 0) { + CHARRANGE sel; + sel.cpMin = 0; + sel.cpMax = 20; + SendMessage(hwndrtf, EM_SETSEL, 0, fi.chrgText.cpMax + 1); + SendMessageA(hwndrtf, EM_REPLACESEL, TRUE, (LPARAM)""); + } + } +} + void TSAPI StreamInEvents(HWND hwndDlg, HANDLE hDbEventFirst, int count, int fAppend, DBEVENTINFO *dbei_s) { - TWindowData *dat = (TWindowData*) GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + TWindowData *dat = (TWindowData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); CHARRANGE oldSel, sel; - POINT pt = {0}; + POINT pt = { 0 }; BOOL wasFirstAppend = (dat->isAutoRTL & 2) ? TRUE : FALSE; - /* - * calc time limit for grouping - */ + // calc time limit for grouping HWND hwndrtf = dat->hwndIEView ? dat->hwndIWebBrowserControl : GetDlgItem(hwndDlg, IDC_LOG); SCROLLINFO si = { 0 }, *psi = &si; @@ -1278,7 +1411,6 @@ void TSAPI StreamInEvents(HWND hwndDlg, HANDLE hDbEventFirst, int count, int fAp } // separator strings used for grid lines, message separation and so on... - dat->clr_added = FALSE; if (dat->szMicroLf[0] == 0) @@ -1289,7 +1421,7 @@ void TSAPI StreamInEvents(HWND hwndDlg, HANDLE hDbEventFirst, int count, int fAp SendDlgItemMessage(hwndDlg, IDC_LOG, EM_HIDESELECTION, TRUE, 0); SendDlgItemMessage(hwndDlg, IDC_LOG, EM_EXGETSEL, 0, (LPARAM)&oldSel); - + LogStreamData streamData = { 0 }; streamData.hContact = dat->hContact; streamData.hDbEvent = hDbEventFirst; @@ -1323,17 +1455,17 @@ void TSAPI StreamInEvents(HWND hwndDlg, HANDLE hDbEventFirst, int count, int fAp SendMessage(hwndrtf, WM_SETREDRAW, FALSE, 0); - SendDlgItemMessage(hwndDlg, IDC_LOG, EM_STREAMIN, fAppend ? SFF_SELECTION | SF_RTF : SFF_SELECTION | SF_RTF, (LPARAM)&stream); + SendDlgItemMessage(hwndDlg, IDC_LOG, EM_STREAMIN, fAppend ? SFF_SELECTION | SF_RTF : SFF_SELECTION | SF_RTF, (LPARAM)&stream); SendDlgItemMessage(hwndDlg, IDC_LOG, EM_EXSETSEL, 0, (LPARAM)&oldSel); SendDlgItemMessage(hwndDlg, IDC_LOG, EM_HIDESELECTION, FALSE, 0); dat->hDbEventLast = streamData.hDbEventLast; - if (dat->isAutoRTL & 1) + if (dat->isAutoRTL & 1) SendMessage(hwndrtf, EM_SETBKGNDCOLOR, 0, (LOWORD(dat->iLastEventType) & DBEF_SENT) ? (fAppend ? dat->pContainer->theme.outbg : dat->pContainer->theme.oldoutbg) : (fAppend ? dat->pContainer->theme.inbg : dat->pContainer->theme.oldinbg)); if (!(dat->isAutoRTL & 1)) { - GETTEXTLENGTHEX gtxl = {0}; + GETTEXTLENGTHEX gtxl = { 0 }; gtxl.codepage = 1200; gtxl.flags = GTL_DEFAULT | GTL_PRECISE | GTL_NUMCHARS; @@ -1365,141 +1497,13 @@ void TSAPI StreamInEvents(HWND hwndDlg, HANDLE hDbEventFirst, int count, int fAp if (streamData.buffer) mir_free(streamData.buffer); } -static void ReplaceIcons(HWND hwndDlg, TWindowData *dat, LONG startAt, int fAppend, BOOL isSent) -{ - DWORD dwScale = M.GetDword("iconscale", 0); - - TCHAR trbuffer[40]; - TEXTRANGE tr; - tr.lpstrText = trbuffer; - - HWND hwndrtf = GetDlgItem(hwndDlg, IDC_LOG); - - FINDTEXTEX fi; - fi.chrg.cpMin = startAt; - if (dat->clr_added) { - unsigned int length; - int index; - CHARRANGE cr; - fi.lpstrText = _T("##col##"); - fi.chrg.cpMax = -1; - CHARFORMAT2 cf2; - ZeroMemory(&cf2, sizeof(cf2)); - cf2.cbSize = sizeof(cf2); - cf2.dwMask = CFM_COLOR; - while (SendMessage(hwndrtf, EM_FINDTEXTEX, FR_DOWN, (LPARAM)&fi) > -1) { - tr.chrg.cpMin = fi.chrgText.cpMin; - tr.chrg.cpMax = tr.chrg.cpMin + 18; - trbuffer[0] = 0; - SendMessage(hwndrtf, EM_GETTEXTRANGE, 0, (LPARAM)&tr); - trbuffer[18] = 0; - cr.cpMin = fi.chrgText.cpMin; - cr.cpMax = cr.cpMin + 18; - SendMessage(hwndrtf, EM_EXSETSEL, 0, (LPARAM)&cr); - SendMessage(hwndrtf, EM_REPLACESEL, FALSE, (LPARAM)_T("")); - length = (unsigned int)_ttol(&trbuffer[7]); - index = _ttol(&trbuffer[14]); - if (length > 0 && length < 20000 && index >= RTF_CTABLE_DEFSIZE && index < Utils::rtf_ctable_size) { - cf2.crTextColor = Utils::rtf_ctable[index].clr; - cr.cpMin = fi.chrgText.cpMin; - cr.cpMax = cr.cpMin + length; - SendMessage(hwndrtf, EM_EXSETSEL, 0, (LPARAM)&cr); - SendMessage(hwndrtf, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); - } - } - } - fi.chrg.cpMin = startAt; - if (dat->dwFlags & MWF_LOG_SHOWICONS) { - BYTE bIconIndex = 0; - char bDirection = 0; - fi.lpstrText = _T("#~#"); - fi.chrg.cpMax = -1; - - CHARFORMAT2 cf2; - ZeroMemory(&cf2, sizeof(cf2)); - cf2.cbSize = sizeof(cf2); - cf2.dwMask = CFM_BACKCOLOR; - - IRichEditOle *ole; - SendMessage(hwndrtf, EM_GETOLEINTERFACE, 0, (LPARAM)&ole); - while (SendMessageA(hwndrtf, EM_FINDTEXTEX, FR_DOWN, (LPARAM)&fi) > -1) { - CHARRANGE cr; - cr.cpMin = fi.chrgText.cpMin; - cr.cpMax = fi.chrgText.cpMax + 2; - SendMessage(hwndrtf, EM_EXSETSEL, 0, (LPARAM)&cr); - - tr.chrg.cpMin = fi.chrgText.cpMin + 3; - tr.chrg.cpMax = fi.chrgText.cpMin + 5; - SendMessage(hwndrtf, EM_GETTEXTRANGE, 0, (LPARAM)&tr); - bIconIndex = ((BYTE)trbuffer[0] - (BYTE)'0'); - if (bIconIndex >= NR_LOGICONS) { - fi.chrg.cpMin = fi.chrgText.cpMax + 6; - continue; - } - bDirection = trbuffer[1]; - SendMessage(hwndrtf, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); - COLORREF crDefault = cf2.crBackColor == 0 ? (true ? (bDirection == '>' ? (fAppend ? dat->pContainer->theme.outbg : dat->pContainer->theme.oldoutbg) : - (fAppend ? dat->pContainer->theme.inbg : dat->pContainer->theme.oldinbg)) : dat->pContainer->theme.bg) : cf2.crBackColor; - - TLogIcon theIcon; - CacheIconToBMP(&theIcon, Logicons[bIconIndex], crDefault, dwScale, dwScale); - ImageDataInsertBitmap(ole, theIcon.hBmp); - DeleteCachedIcon(&theIcon); - fi.chrg.cpMin = cr.cpMax + 6; - } - ole->Release(); - } - - /* - * do smiley replacing, using the service - */ - if (PluginConfig.g_SmileyAddAvail) { - CHARRANGE sel; - sel.cpMin = startAt; - sel.cpMax = -1; - - SMADD_RICHEDIT3 smadd = { sizeof(smadd) }; - smadd.hwndRichEditControl = GetDlgItem(hwndDlg, IDC_LOG); - smadd.Protocolname = const_cast(dat->cache->getActiveProto()); - smadd.hContact = dat->cache->getActiveContact(); - smadd.flags = isSent ? SAFLRE_OUTGOING : 0; - if (startAt > 0) - smadd.rangeToReplace = &sel; - else - smadd.rangeToReplace = NULL; - smadd.disableRedraw = TRUE; - if (dat->doSmileys) - CallService(MS_SMILEYADD_REPLACESMILEYS, TABSRMM_SMILEYADD_BKGCOLORMODE, (LPARAM)&smadd); - } - - if (dat->hHistoryEvents && dat->curHistory == dat->maxHistory) { - char szPattern[50]; - mir_snprintf(szPattern, 40, "~-+%d+-~", (INT_PTR)dat->hHistoryEvents[0]); - - FINDTEXTEXA fi; - fi.lpstrText = szPattern; - fi.chrg.cpMin = 0; - fi.chrg.cpMax = -1; - if (SendMessageA(hwndrtf, EM_FINDTEXTEX, FR_DOWN, (LPARAM)&fi) != 0) { - CHARRANGE sel; - sel.cpMin = 0; - sel.cpMax = 20; - SendMessage(hwndrtf, EM_SETSEL, 0, fi.chrgText.cpMax + 1); - SendMessageA(hwndrtf, EM_REPLACESEL, TRUE, (LPARAM)""); - } - } -} - -/* -* NLS functions (for unicode version only) encoding stuff.. -*/ - +// NLS functions (for unicode version only) encoding stuff.. static BOOL CALLBACK LangAddCallback(LPTSTR str) { int i, count; UINT cp = _ttoi(str); count = SIZEOF(cpTable); - for (i=0; i < count && cpTable[i].cpId != cp; i++); + for (i = 0; i < count && cpTable[i].cpId != cp; i++); if (i < count) AppendMenu(PluginConfig.g_hMenuEncoding, MF_STRING, cp, TranslateTS(cpTable[i].cpName)); @@ -1513,27 +1517,3 @@ void TSAPI BuildCodePageList() AppendMenuA(PluginConfig.g_hMenuEncoding, MF_SEPARATOR, 0, 0); EnumSystemCodePages(LangAddCallback, CP_INSTALLED); } - -static TCHAR *Template_MakeRelativeDate(TWindowData *dat, HANDLE hTimeZone, time_t check, int groupBreak, TCHAR code) -{ - static TCHAR szResult[100]; - const TCHAR *szFormat; - - if ((code == (TCHAR)'R' || code == (TCHAR)'r') && check >= today) - _tcscpy(szResult, szToday); - else if ((code == (TCHAR)'R' || code == (TCHAR)'r') && check > (today - 86400)) - _tcscpy(szResult, szYesterday); - else { - if (code == 'D' || code == 'R') - szFormat = _T("D"); - else if (code == 'T') - szFormat = _T("s"); - else if (code == 't') - szFormat = _T("t"); - else - szFormat = _T("d"); - - tmi.printTimeStamp(hTimeZone, check, szFormat, szResult, SIZEOF(szResult), 0); - } - return szResult; -} diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h index c30a477652..ed18f1e48b 100644 --- a/plugins/TabSRMM/src/msgs.h +++ b/plugins/TabSRMM/src/msgs.h @@ -272,21 +272,19 @@ struct TWindowData int splitterY, originalSplitterY, dynaSplitter, savedSplitter, savedSplitY, savedDynaSplit; int multiSplitterX; SIZE minEditBoxSize; - int showUIElements; int nTypeSecs; int nTypeMode; DWORD nLastTyping; - int showTyping; DWORD lastMessage; int iTabID; HKL hkl; // keyboard layout identifier DWORD dwTickLastEvent, dwUnread; HBITMAP hOwnPic; SIZE pic; - bool bShowAvatar, bShowInfoAvatar; - bool fMustOffset; - bool isHistory; - int doSmileys; + BYTE bShowTyping; + bool bShowAvatar, bShowInfoAvatar, bShowSmileys, bShowUIElements; + bool bUseOffset; + bool bIsHistory, bIsMeta, bNotOnList; UINT codePage; HICON hSmileyIcon; int iLastEventType; @@ -296,10 +294,8 @@ struct TWindowData DWORD dwLastActivity; int iOpenJobs; int iCurrentQueueError; - BOOL bIsMeta; HANDLE hFlashingEvent; TCHAR myUin[80]; - BOOL bNotOnList; int SendFormat; HANDLE *hQueuedEvents; int iNextQueuedEvent; diff --git a/plugins/TabSRMM/src/tabctrl.cpp b/plugins/TabSRMM/src/tabctrl.cpp index ac9d41bfb4..4690906a14 100644 --- a/plugins/TabSRMM/src/tabctrl.cpp +++ b/plugins/TabSRMM/src/tabctrl.cpp @@ -1503,33 +1503,35 @@ INT_PTR CALLBACK DlgProcTabConfig(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM int TSAPI RegisterTabCtrlClass(void) { - WNDCLASSEX wc = { sizeof(wc) }; - wc.lpszClassName = _T("TSTabCtrlClass"); - wc.lpfnWndProc = TabControlSubclassProc; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.cbWndExtra = sizeof(TabControlData*); - wc.style = CS_GLOBALCLASS | CS_DBLCLKS | CS_PARENTDC; + WNDCLASSEX wc = { 0 }; + wc.cbSize = sizeof(wc); + + wc.lpszClassName = _T("TSTabCtrlClass"); + wc.lpfnWndProc = TabControlSubclassProc; + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.cbWndExtra = sizeof(TabControlData*); + wc.style = CS_GLOBALCLASS | CS_DBLCLKS | CS_PARENTDC; RegisterClassEx(&wc); - wc.lpszClassName = _T("TSStatusBarClass"); - wc.lpfnWndProc = StatusBarSubclassProc; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.cbWndExtra = sizeof(void*); - wc.style = CS_GLOBALCLASS | CS_DBLCLKS | CS_PARENTDC; + wc.lpszClassName = _T("TSStatusBarClass"); + wc.lpfnWndProc = StatusBarSubclassProc; + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.cbWndExtra = sizeof(void*); + wc.style = CS_GLOBALCLASS | CS_DBLCLKS | CS_PARENTDC; RegisterClassEx(&wc); - wc.lpszClassName = _T("TS_SideBarClass"); - wc.lpfnWndProc = CSideBar::wndProcStub; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.cbWndExtra = sizeof(void*); - wc.style = CS_GLOBALCLASS;// | CS_DBLCLKS; // | CS_PARENTDC; + wc.lpszClassName = _T("TS_SideBarClass"); + wc.lpfnWndProc = CSideBar::wndProcStub; + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.cbWndExtra = sizeof(void*); + wc.style = CS_GLOBALCLASS;// | CS_DBLCLKS; // | CS_PARENTDC; RegisterClassEx(&wc); - wc.lpszClassName = _T("TSHK"); - wc.lpfnWndProc = HotkeyHandlerDlgProc; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.cbWndExtra = sizeof(void*); - wc.style = CS_GLOBALCLASS;// | CS_DBLCLKS; // | CS_PARENTDC; + wc.lpszClassName = _T("TSHK"); + wc.lpfnWndProc = HotkeyHandlerDlgProc; + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.cbWndExtra = sizeof(void*); + wc.style = CS_GLOBALCLASS;// | CS_DBLCLKS; // | CS_PARENTDC; RegisterClassEx(&wc); return 0; } -- cgit v1.2.3