From 3e5dab1a8298130da0ebfb20d91b6963a64367b1 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 11 Dec 2014 17:07:25 +0000 Subject: chat's component COLORCHOOSER standardized in the core git-svn-id: http://svn.miranda-ng.org/main/trunk@11332 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TabSRMM/src/chat/chat.h | 12 -- plugins/TabSRMM/src/chat/chat_resource.h | 2 - plugins/TabSRMM/src/chat/colorchooser.cpp | 261 ------------------------------ plugins/TabSRMM/src/chat/window.cpp | 38 ++--- 4 files changed, 11 insertions(+), 302 deletions(-) delete mode 100644 plugins/TabSRMM/src/chat/colorchooser.cpp (limited to 'plugins/TabSRMM/src/chat') diff --git a/plugins/TabSRMM/src/chat/chat.h b/plugins/TabSRMM/src/chat/chat.h index a3196ebb2c..52c2067274 100644 --- a/plugins/TabSRMM/src/chat/chat.h +++ b/plugins/TabSRMM/src/chat/chat.h @@ -106,22 +106,10 @@ struct FLASH_PARAMS extern TMUCSettings g_Settings; extern CHAT_MANAGER saveCI; -struct COLORCHOOSER -{ - MODULEINFO *pModule; - int xPosition, yPosition; - HWND hWndTarget; - bool bForeground; - SESSION_INFO *si; -}; - #pragma comment(lib,"comctl32.lib") ////////////////////////////////////////////////////////////////////////////////// -// colorchooser.c -INT_PTR CALLBACK DlgProcColorToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); - // log.c void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, bool bRedraw, bool bPhaseTwo); char* Log_CreateRtfHeader(MODULEINFO *mi); diff --git a/plugins/TabSRMM/src/chat/chat_resource.h b/plugins/TabSRMM/src/chat/chat_resource.h index 07a9bb8ba4..3be170399d 100644 --- a/plugins/TabSRMM/src/chat/chat_resource.h +++ b/plugins/TabSRMM/src/chat/chat_resource.h @@ -8,7 +8,6 @@ #define IDD_OPTIONS2 403 #define IDD_FILTER 404 #define IDD_OPTIONSPOPUP 405 -#define IDD_COLORCHOOSER 406 #define IDD_OPTIONS3 407 #define IDD_OPTIONS4 408 #define IDD_ADDHIGHLIGHT 409 @@ -48,7 +47,6 @@ #define IDC_TIMEOUT 1067 #define IDC_TEXTO 1069 #define IDC_LOGGING 1069 -#define IDC_COLORTEXT 1070 #define IDC_TEXTO2 1070 #define IDC_TEXTO3 1071 #define IDC_LIST 1072 diff --git a/plugins/TabSRMM/src/chat/colorchooser.cpp b/plugins/TabSRMM/src/chat/colorchooser.cpp deleted file mode 100644 index 12d25fa73b..0000000000 --- a/plugins/TabSRMM/src/chat/colorchooser.cpp +++ /dev/null @@ -1,261 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////////////// -// Miranda NG: the free IM client for Microsoft* Windows* -// -// Copyright (c) 2012-14 Miranda NG project, -// Copyright (c) 2000-09 Miranda ICQ/IM project, -// all portions of this codebase are copyrighted to the people -// listed in contributors.txt. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// you should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// part of tabSRMM messaging plugin for Miranda. -// -// (C) 2005-2010 by silvercircle _at_ gmail _dot_ com and contributors -// -// Color chooser for group chats - -#include "..\commonheaders.h" - -static int CalculateCoordinatesToButton(COLORCHOOSER * pCC, POINT pt) -{ - int iSquareRoot = (int)sqrt(static_cast(pCC->pModule->nColorCount)); - int nCols = iSquareRoot * iSquareRoot < pCC->pModule->nColorCount ? iSquareRoot + 1 : iSquareRoot; - - int col = pt.x / 25; - int row = (pt.y - 20) / 20; - int pos = nCols * row + col; - - if (pt.y < 20 && pos >= pCC->pModule->nColorCount) - pos = -1; - - return pos; -} - -static RECT CalculateButtonToCoordinates(COLORCHOOSER * pCC, int buttonPosition) -{ - RECT pt; - int iSquareRoot = (int)sqrt(static_cast(pCC->pModule->nColorCount)); - int nCols = iSquareRoot * iSquareRoot < pCC->pModule->nColorCount ? iSquareRoot + 1 : iSquareRoot; - - int row = buttonPosition / nCols; - int col = buttonPosition % nCols; - - pt.left = col * 25 + 1; - pt.top = row * 20 + 20; - pt.right = pt.left + 25 - 1; - pt.bottom = pt.top + 20; - - return pt; -} - -INT_PTR CALLBACK DlgProcColorToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - static COLORCHOOSER* pCC = NULL; - static int iCurrentHotTrack; - static BOOL bChoosing; - static int iRows; - static int iColumns; - static HWND hPreviousActiveWindow; - - switch (msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - { - pCC = (COLORCHOOSER*) lParam; - - iCurrentHotTrack = -2; - bChoosing = FALSE; - - int iSquareRoot = (int)sqrt(static_cast(pCC->pModule->nColorCount)); - - iColumns = iSquareRoot * iSquareRoot == pCC->pModule->nColorCount ? iSquareRoot : iSquareRoot + 1; - iRows = iSquareRoot; - - RECT rc; - rc.top = rc.left = 100; - rc.right = 100 + iColumns * 25 + 1; - rc.bottom = iRows * 20 + 100 + 20; - - AdjustWindowRectEx(&rc, GetWindowLongPtr(hwndDlg, GWL_STYLE), FALSE, GetWindowLongPtr(hwndDlg, GWL_EXSTYLE)); - - int width = rc.right - rc.left; - int height = rc.bottom - rc.top; - - pCC->yPosition -= height; - - SetDlgItemText(hwndDlg, IDC_COLORTEXT, pCC->bForeground ? TranslateT("Text color") : TranslateT("Background color")); - SetWindowPos(GetDlgItem(hwndDlg, IDC_COLORTEXT), NULL, 0, 0, width, 20, 0); - SetWindowPos(hwndDlg, NULL, pCC->xPosition, pCC->yPosition, width, height, SWP_SHOWWINDOW); - } - break; - - case WM_CTLCOLOREDIT: - case WM_CTLCOLORSTATIC: - if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_COLORTEXT)) { - SetTextColor((HDC)wParam, RGB(60, 60, 150)); - SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); - return (INT_PTR)GetSysColorBrush(COLOR_WINDOW); - } - break; - - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDOK: - if (iCurrentHotTrack >= 0) - PostMessage(hwndDlg, WM_LBUTTONUP, 0, 0); - break; - case IDCANCEL: - DestroyWindow(hwndDlg); - break; - } - break; - - case WM_LBUTTONUP: - if (iCurrentHotTrack >= 0 && iCurrentHotTrack < pCC->pModule->nColorCount && pCC->hWndTarget != NULL) { - HWND hWindow; - CHARFORMAT2 cf; - cf.cbSize = sizeof(CHARFORMAT2); - cf.dwMask = 0; - cf.dwEffects = 0; - hWindow = GetParent(pCC->hWndTarget); - - if (pCC->bForeground) { - pCC->si->bFGSet = TRUE; - pCC->si->iFG = iCurrentHotTrack; - if (IsDlgButtonChecked(hWindow, IDC_COLOR)) { - cf.dwMask = CFM_COLOR; - cf.crTextColor = pCC->pModule->crColors[iCurrentHotTrack]; - SendMessage(pCC->hWndTarget, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); - } - } else { - pCC->si->bBGSet = TRUE; - pCC->si->iBG = iCurrentHotTrack; - if (IsDlgButtonChecked(hWindow, IDC_BKGCOLOR)) { - cf.dwMask = CFM_BACKCOLOR; - cf.crBackColor = pCC->pModule->crColors[iCurrentHotTrack]; - SendMessage(pCC->hWndTarget, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); - } - } - } - PostMessage(hwndDlg, WM_CLOSE, 0, 0); - break; - - case WM_ACTIVATE: - if (wParam == WA_INACTIVE) - PostMessage(hwndDlg, WM_CLOSE, 0, 0); - else if ((wParam == WA_ACTIVE) || (wParam == WA_CLICKACTIVE)) - hPreviousActiveWindow = (HWND)lParam; - break; - - case WM_MOUSEMOVE: - { - HDC hdc = GetDC(hwndDlg); - POINT pt; - RECT rect; - int but; - - pt.x = LOWORD(lParam); - pt.y = HIWORD(lParam); - - if (iCurrentHotTrack == -2) - return 0; // prevent focussing when not drawn yet! - - but = CalculateCoordinatesToButton(pCC, pt); - - // weird stuff - if (but != iCurrentHotTrack) { - if (iCurrentHotTrack >= 0) { - rect = CalculateButtonToCoordinates(pCC, iCurrentHotTrack); - DrawFocusRect(hdc, &rect); - iCurrentHotTrack = -1; - } - iCurrentHotTrack = but; - - if (iCurrentHotTrack >= 0) { - rect = CalculateButtonToCoordinates(pCC, iCurrentHotTrack); - DrawFocusRect(hdc, &rect); - } - } - ReleaseDC(hwndDlg, hdc); - } - break; - - case WM_PAINT: - { - PAINTSTRUCT ps; - int iThisRow = 1; - int iThisColumn = 0; - - RECT rc; - GetClientRect(hwndDlg, &rc); - rc.top += 20; - - HDC hdc = BeginPaint(hwndDlg, &ps); - - // fill background - FillRect(hdc, &rc, GetSysColorBrush(COLOR_WINDOW)); - - for (int i=0; i < pCC->pModule->nColorCount; i++) { - // decide place to draw the color block in the window - iThisColumn ++; - if (iThisColumn > iColumns) { - iThisColumn = 1; - iThisRow++; - } - - if (pCC->bForeground && pCC->si->bFGSet && pCC->si->iFG == i || !pCC->bForeground && pCC->si->bBGSet && pCC->si->iBG == i) { - rc.top = (iThisRow - 1) * 20 + 1 + 20 ; - rc.left = (iThisColumn - 1) * 25 + 1 + 1 ; - rc.bottom = iThisRow * 20 - 1 + 20 ; - rc.right = iThisColumn * 25 - 1 ; - - DrawEdge(hdc, &rc, EDGE_RAISED, BF_TOP | BF_LEFT | BF_RIGHT | BF_BOTTOM); - } - - rc.top = (iThisRow - 1) * 20 + 3 + 20 ; - rc.left = (iThisColumn - 1) * 25 + 3 + 1 ; - rc.bottom = iThisRow * 20 - 3 + 20 ; - rc.right = iThisColumn * 25 - 3 ; - - FillRect(hdc, &rc, CSkin::m_BrushBack); - - HBRUSH hbr = CreateSolidBrush(pCC->pModule->crColors[i]); - - rc.top = (iThisRow - 1) * 20 + 4 + 20; - rc.left = (iThisColumn - 1) * 25 + 4 + 1; - rc.bottom = iThisRow * 20 - 4 + 20; - rc.right = iThisColumn * 25 - 4; - - FillRect(hdc, &rc, hbr); - DeleteObject(hbr); - } - - EndPaint(hwndDlg, &ps); - iCurrentHotTrack = -1; - } - break; - - case WM_CLOSE: - SetFocus(pCC->hWndTarget); - DestroyWindow(hwndDlg); - break; - - case WM_DESTROY: - mir_free(pCC); - return TRUE; - } - - return FALSE; -} diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index 8a60369600..1c027c954f 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -1823,6 +1823,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar CHARFORMAT2 cf; POINT pt, tmp, cur; + RECT rc; switch (uMsg) { case WM_INITDIALOG: @@ -1935,7 +1936,6 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar SendMessage(hwndDlg, GC_UPDATESTATUSBAR, 0, 0); SendMessage(hwndDlg, GC_UPDATETITLE, 0, 1); - RECT rc; SendMessage(dat->pContainer->hwnd, DM_QUERYCLIENTAREA, 0, (LPARAM)&rc); SetWindowPos(hwndDlg, HWND_TOP, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), 0); ShowWindow(hwndDlg, SW_SHOW); @@ -2121,7 +2121,6 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar BB_SetButtonsPos(dat); - RECT rc; GetClientRect(hwndDlg, &rc); int cx = rc.right; @@ -2415,8 +2414,8 @@ LABEL_SHOWWINDOW: break; case DM_SPLITTERMOVED: + RECT rcLog; { - RECT rc, rcLog; GetWindowRect(GetDlgItem(hwndDlg, IDC_CHAT_LOG), &rcLog); if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_SPLITTERX)) { GetClientRect(hwndDlg, &rc); @@ -2485,15 +2484,15 @@ LABEL_SHOWWINDOW: case GC_SHOWFILTERMENU: si->hwndStatus = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_FILTER), dat->pContainer->hwnd, FilterWndProc, (LPARAM)si); TranslateDialogDefault(si->hwndStatus); - { - RECT rcFilter, rcLog; - GetClientRect(si->hwndStatus, &rcFilter); - GetWindowRect(GetDlgItem(hwndDlg, IDC_CHAT_LOG), &rcLog); - POINT pt = { rcLog.right, rcLog.bottom }; - ScreenToClient(dat->pContainer->hwnd, &pt); - SetWindowPos(si->hwndStatus, HWND_TOP, pt.x - rcFilter.right, pt.y - rcFilter.bottom, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); - } + RECT rcFilter; + GetClientRect(si->hwndStatus, &rcFilter); + GetWindowRect(GetDlgItem(hwndDlg, IDC_CHAT_LOG), &rcLog); + + pt.x = rcLog.right; pt.y = rcLog.bottom; + ScreenToClient(dat->pContainer->hwnd, &pt); + + SetWindowPos(si->hwndStatus, HWND_TOP, pt.x - rcFilter.right, pt.y - rcFilter.bottom, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); break; case DM_SPLITTERGLOBALEVENT: @@ -2501,20 +2500,7 @@ LABEL_SHOWWINDOW: return 0; case GC_SHOWCOLORCHOOSER: - { - bool bFG = (lParam == IDC_COLOR); - - RECT rc; - GetWindowRect(GetDlgItem(hwndDlg, bFG ? IDC_COLOR : IDC_BKGCOLOR), &rc); - COLORCHOOSER *pCC = (COLORCHOOSER *)mir_alloc(sizeof(COLORCHOOSER)); - pCC->hWndTarget = GetDlgItem(hwndDlg, IDC_CHAT_MESSAGE); - pCC->pModule = pci->MM_FindModule(si->pszModule); - pCC->xPosition = rc.left + 3; - pCC->yPosition = IsWindowVisible(GetDlgItem(hwndDlg, IDC_COLOR)) ? rc.top - 1 : rc.top + 20; - pCC->bForeground = bFG; - pCC->si = si; - CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_COLORCHOOSER), hwndDlg, DlgProcColorToolWindow, (LPARAM)pCC); - } + pci->ColorChooser(si, lParam == IDC_COLOR, hwndDlg, GetDlgItem(hwndDlg, IDC_CHAT_MESSAGE), GetDlgItem(hwndDlg, lParam)); break; case GC_SCROLLTOBOTTOM: @@ -3048,7 +3034,6 @@ LABEL_SHOWWINDOW: case IDC_SMILEY: case IDC_SMILEYBTN: { - RECT rc; if (lParam == 0) GetWindowRect(GetDlgItem(hwndDlg, IDC_SMILEYBTN), &rc); else @@ -3414,7 +3399,6 @@ LABEL_SHOWWINDOW: TabCtrl_GetItem(hwndTab, i, &item); // retrieve dialog hwnd for the now active tab... dat->pContainer->hwndActive = (HWND) item.lParam; - RECT rc; SendMessage(dat->pContainer->hwnd, DM_QUERYCLIENTAREA, 0, (LPARAM)&rc); SetWindowPos(dat->pContainer->hwndActive, HWND_TOP, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), SWP_SHOWWINDOW); ShowWindow((HWND)item.lParam, SW_SHOW); -- cgit v1.2.3