From d4eaaec055bbdc940f5758cc1fd7b22b2cb105d8 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 4 Mar 2013 16:05:07 +0000 Subject: further code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@3883 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TabSRMM/src/chat/colorchooser.cpp | 159 +++-- plugins/TabSRMM/src/chat/log.cpp | 460 +++++++------- plugins/TabSRMM/src/chat/message.cpp | 302 ++++----- plugins/TabSRMM/src/chat/options.cpp | 979 +++++++++++++++--------------- plugins/TabSRMM/src/chat/window.cpp | 328 +++++----- 5 files changed, 1097 insertions(+), 1131 deletions(-) (limited to 'plugins/TabSRMM/src/chat') diff --git a/plugins/TabSRMM/src/chat/colorchooser.cpp b/plugins/TabSRMM/src/chat/colorchooser.cpp index 72366db24b..2bf8b4ded2 100644 --- a/plugins/TabSRMM/src/chat/colorchooser.cpp +++ b/plugins/TabSRMM/src/chat/colorchooser.cpp @@ -81,101 +81,97 @@ INT_PTR CALLBACK DlgProcColorToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, L static HWND hPreviousActiveWindow; switch (msg) { - case WM_INITDIALOG: { - RECT rc; - int iSquareRoot; - int width ; - int height; - - TranslateDialogDefault(hwndDlg); + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + { pCC = (COLORCHOOSER*) lParam; iCurrentHotTrack = -2; bChoosing = FALSE; - iSquareRoot = (int)sqrt(static_cast(pCC->pModule->nColorCount)); + 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)); - width = rc.right - rc.left; - height = rc.bottom - rc.top; + 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")); + 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_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; - } + 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); - } + 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; + } + 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_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: { + case WM_MOUSEMOVE: + { HDC hdc = GetDC(hwndDlg); POINT pt; RECT rect; @@ -207,26 +203,22 @@ INT_PTR CALLBACK DlgProcColorToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, L } break; - case WM_PAINT: { + case WM_PAINT: + { PAINTSTRUCT ps; - HDC hdc; - RECT rc; - int i = 0; int iThisRow = 1; int iThisColumn = 0; + RECT rc; GetClientRect(hwndDlg, &rc); - rc.top += 20; - hdc = BeginPaint(hwndDlg, &ps); + HDC hdc = BeginPaint(hwndDlg, &ps); // fill background FillRect(hdc, &rc, GetSysColorBrush(COLOR_WINDOW)); - for (i; i < pCC->pModule->nColorCount; i++) { - HBRUSH hbr; - + for (int i=0; i < pCC->pModule->nColorCount; i++) { // decide place to draw the color block in the window iThisColumn ++; if (iThisColumn > iColumns) { @@ -234,8 +226,7 @@ INT_PTR CALLBACK DlgProcColorToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, L iThisRow++; } - if (pCC->bForeground && pCC->si->bFGSet && pCC->si->iFG == i || - !pCC->bForeground && pCC->si->bBGSet && pCC->si->iBG == i) { + 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 ; @@ -251,7 +242,7 @@ INT_PTR CALLBACK DlgProcColorToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, L FillRect(hdc, &rc, CSkin::m_BrushBack); - hbr = CreateSolidBrush(pCC->pModule->crColors[i]); + HBRUSH hbr = CreateSolidBrush(pCC->pModule->crColors[i]); rc.top = (iThisRow - 1) * 20 + 4 + 20; rc.left = (iThisColumn - 1) * 25 + 4 + 1; @@ -267,14 +258,14 @@ INT_PTR CALLBACK DlgProcColorToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, L } break; - case WM_CLOSE: - SetFocus(pCC->hWndTarget); - DestroyWindow(hwndDlg); - break; + case WM_CLOSE: + SetFocus(pCC->hWndTarget); + DestroyWindow(hwndDlg); + break; - case WM_DESTROY: - mir_free(pCC); - return TRUE; + case WM_DESTROY: + mir_free(pCC); + return TRUE; } return FALSE; diff --git a/plugins/TabSRMM/src/chat/log.cpp b/plugins/TabSRMM/src/chat/log.cpp index 57b6fadff8..9aa450af3d 100644 --- a/plugins/TabSRMM/src/chat/log.cpp +++ b/plugins/TabSRMM/src/chat/log.cpp @@ -344,34 +344,34 @@ static void LogEventIEView(LOGSTREAMDATA *streamData, TCHAR *ptszNick) static int EventToIndex(LOGINFO * lin) { switch (lin->iType) { - case GC_EVENT_MESSAGE: - if (lin->bIsMe) - return 10; - else - return 9; - - case GC_EVENT_JOIN: - return 3; - case GC_EVENT_PART: - return 4; - case GC_EVENT_QUIT: - return 5; - case GC_EVENT_NICK: - return 7; - case GC_EVENT_KICK: - return 6; - case GC_EVENT_NOTICE: - return 8; - case GC_EVENT_TOPIC: - return 11; - case GC_EVENT_INFORMATION: - return 12; - case GC_EVENT_ADDSTATUS: - return 13; - case GC_EVENT_REMOVESTATUS: - return 14; - case GC_EVENT_ACTION: - return 15; + case GC_EVENT_MESSAGE: + if (lin->bIsMe) + return 10; + else + return 9; + + case GC_EVENT_JOIN: + return 3; + case GC_EVENT_PART: + return 4; + case GC_EVENT_QUIT: + return 5; + case GC_EVENT_NICK: + return 7; + case GC_EVENT_KICK: + return 6; + case GC_EVENT_NOTICE: + return 8; + case GC_EVENT_TOPIC: + return 11; + case GC_EVENT_INFORMATION: + return 12; + case GC_EVENT_ADDSTATUS: + return 13; + case GC_EVENT_REMOVESTATUS: + return 14; + case GC_EVENT_ACTION: + return 15; } return 0; } @@ -379,28 +379,28 @@ static int EventToIndex(LOGINFO * lin) static BYTE EventToSymbol(LOGINFO *lin) { switch (lin->iType) { - case GC_EVENT_MESSAGE: - return (lin->bIsMe) ? 0x37 : 0x38; - case GC_EVENT_JOIN: - return 0x34; - case GC_EVENT_PART: - return 0x33; - case GC_EVENT_QUIT: - return 0x39; - case GC_EVENT_NICK: - return 0x71; - case GC_EVENT_KICK: - return 0x72; - case GC_EVENT_NOTICE: - return 0x28; - case GC_EVENT_INFORMATION: - return 0x69; - case GC_EVENT_ADDSTATUS: - return 0x35; - case GC_EVENT_REMOVESTATUS: - return 0x36; - case GC_EVENT_ACTION: - return 0x60; + case GC_EVENT_MESSAGE: + return (lin->bIsMe) ? 0x37 : 0x38; + case GC_EVENT_JOIN: + return 0x34; + case GC_EVENT_PART: + return 0x33; + case GC_EVENT_QUIT: + return 0x39; + case GC_EVENT_NICK: + return 0x71; + case GC_EVENT_KICK: + return 0x72; + case GC_EVENT_NOTICE: + return 0x28; + case GC_EVENT_INFORMATION: + return 0x69; + case GC_EVENT_ADDSTATUS: + return 0x35; + case GC_EVENT_REMOVESTATUS: + return 0x36; + case GC_EVENT_ACTION: + return 0x60; } return 0x73; } @@ -408,34 +408,34 @@ static BYTE EventToSymbol(LOGINFO *lin) static int EventToIcon(LOGINFO * lin) { switch (lin->iType) { - case GC_EVENT_MESSAGE: - if (lin->bIsMe) - return ICON_MESSAGEOUT; - else - return ICON_MESSAGE; - - case GC_EVENT_JOIN: - return ICON_JOIN; - case GC_EVENT_PART: - return ICON_PART; - case GC_EVENT_QUIT: - return ICON_QUIT; - case GC_EVENT_NICK: - return ICON_NICK; - case GC_EVENT_KICK: - return ICON_KICK; - case GC_EVENT_NOTICE: - return ICON_NOTICE; - case GC_EVENT_TOPIC: - return ICON_TOPIC; - case GC_EVENT_INFORMATION: - return ICON_INFO; - case GC_EVENT_ADDSTATUS: - return ICON_ADDSTATUS; - case GC_EVENT_REMOVESTATUS: - return ICON_REMSTATUS; - case GC_EVENT_ACTION: - return ICON_ACTION; + case GC_EVENT_MESSAGE: + if (lin->bIsMe) + return ICON_MESSAGEOUT; + else + return ICON_MESSAGE; + + case GC_EVENT_JOIN: + return ICON_JOIN; + case GC_EVENT_PART: + return ICON_PART; + case GC_EVENT_QUIT: + return ICON_QUIT; + case GC_EVENT_NICK: + return ICON_NICK; + case GC_EVENT_KICK: + return ICON_KICK; + case GC_EVENT_NOTICE: + return ICON_NOTICE; + case GC_EVENT_TOPIC: + return ICON_TOPIC; + case GC_EVENT_INFORMATION: + return ICON_INFO; + case GC_EVENT_ADDSTATUS: + return ICON_ADDSTATUS; + case GC_EVENT_REMOVESTATUS: + return ICON_REMSTATUS; + case GC_EVENT_ACTION: + return ICON_ACTION; } return 0; } @@ -557,61 +557,61 @@ static int Log_AppendRTF(LOGSTREAMDATA* streamData, BOOL simpleMode, char **buff szTemp[0] = '\0'; switch (*++line) { - case '\0': - case '%': - *d++ = '%'; - break; - - case 'c': - case 'f': - if (g_Settings.StripFormat || streamData->bStripFormat) - line += 2; + case '\0': + case '%': + *d++ = '%'; + break; - else if (line[1] != '\0' && line[2] != '\0') { - TCHAR szTemp3[3], c = *line; - int col; - szTemp3[0] = line[1]; - szTemp3[1] = line[2]; - szTemp3[2] = '\0'; - line += 2; + case 'c': + case 'f': + if (g_Settings.StripFormat || streamData->bStripFormat) + line += 2; + + else if (line[1] != '\0' && line[2] != '\0') { + TCHAR szTemp3[3], c = *line; + int col; + szTemp3[0] = line[1]; + szTemp3[1] = line[2]; + szTemp3[2] = '\0'; + line += 2; + + col = _ttoi(szTemp3); + col += (OPTIONS_FONTCOUNT + 1); + mir_snprintf(szTemp, SIZEOF(szTemp), (c == 'c') ? "\\cf%u " : "\\highlight%u ", col); + } + break; + case 'C': + case 'F': + if (!g_Settings.StripFormat && !streamData->bStripFormat) { + int j = streamData->lin->bIsHighlighted ? 16 : EventToIndex(streamData->lin); + if (*line == 'C') + mir_snprintf(szTemp, SIZEOF(szTemp), "\\cf%u ", j + 1); + else + mir_snprintf(szTemp, SIZEOF(szTemp), "\\highlight0 "); + } + break; + case 'b': + case 'u': + case 'i': + if (!streamData->bStripFormat) + mir_snprintf(szTemp, SIZEOF(szTemp), (*line == 'u') ? "\\%cl " : "\\%c ", *line); + break; - col = _ttoi(szTemp3); - col += (OPTIONS_FONTCOUNT + 1); - mir_snprintf(szTemp, SIZEOF(szTemp), (c == 'c') ? "\\cf%u " : "\\highlight%u ", col); - } - break; - case 'C': - case 'F': - if (!g_Settings.StripFormat && !streamData->bStripFormat) { - int j = streamData->lin->bIsHighlighted ? 16 : EventToIndex(streamData->lin); - if (*line == 'C') - mir_snprintf(szTemp, SIZEOF(szTemp), "\\cf%u ", j + 1); - else - mir_snprintf(szTemp, SIZEOF(szTemp), "\\highlight0 "); - } - break; - case 'b': - case 'u': - case 'i': - if (!streamData->bStripFormat) - mir_snprintf(szTemp, SIZEOF(szTemp), (*line == 'u') ? "\\%cl " : "\\%c ", *line); - break; - - case 'B': - case 'U': - case 'I': - if (!streamData->bStripFormat) { - mir_snprintf(szTemp, SIZEOF(szTemp), (*line == 'U') ? "\\%cl0 " : "\\%c0 ", *line); - CharLowerA(szTemp); - } - break; + case 'B': + case 'U': + case 'I': + if (!streamData->bStripFormat) { + mir_snprintf(szTemp, SIZEOF(szTemp), (*line == 'U') ? "\\%cl0 " : "\\%c0 ", *line); + CharLowerA(szTemp); + } + break; - case 'r': - if (!streamData->bStripFormat) { - int index = EventToIndex(streamData->lin); - mir_snprintf(szTemp, SIZEOF(szTemp), "%s ", Log_SetStyle(index, index)); - } - break; + case 'r': + if (!streamData->bStripFormat) { + int index = EventToIndex(streamData->lin); + mir_snprintf(szTemp, SIZEOF(szTemp), "%s ", Log_SetStyle(index, index)); + } + break; } if (szTemp[0]) { @@ -665,85 +665,85 @@ static void AddEventToBuffer(char **buffer, int *bufferEnd, int *bufferAlloced, } switch (streamData->lin->iType) { - case GC_EVENT_MESSAGE: - if (streamData->lin->ptszText) - Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T("%s"), streamData->lin->ptszText); - break; - case GC_EVENT_ACTION: - if (streamData->lin->ptszNick && streamData->lin->ptszText) { - Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, _T("%s "), streamData->lin->ptszNick); - Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T("%s"), streamData->lin->ptszText); - } - break; - case GC_EVENT_JOIN: - if (pszNick) { - if (!streamData->lin->bIsMe) - /* replace nick of a newcomer with a link */ + case GC_EVENT_MESSAGE: + if (streamData->lin->ptszText) + Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T("%s"), streamData->lin->ptszText); + break; + case GC_EVENT_ACTION: + if (streamData->lin->ptszNick && streamData->lin->ptszText) { + Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, _T("%s "), streamData->lin->ptszNick); + Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T("%s"), streamData->lin->ptszText); + } + break; + case GC_EVENT_JOIN: + if (pszNick) { + if (!streamData->lin->bIsMe) + /* replace nick of a newcomer with a link */ Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s has joined"), pszNick); - else - Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("You have joined %s"), streamData->si->ptszName); - } - break; - case GC_EVENT_PART: - if (pszNick) - Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s has left"), pszNick); - if (streamData->lin->ptszText) - Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T(": %s"), streamData->lin->ptszText); - break; - case GC_EVENT_QUIT: - if (pszNick) - Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s has disconnected"), pszNick); - if (streamData->lin->ptszText) - Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T(": %s"), streamData->lin->ptszText); - break; - case GC_EVENT_NICK: - if (pszNick && streamData->lin->ptszText) { - if (!streamData->lin->bIsMe) - Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s is now known as %s"), pszNick, streamData->lin->ptszText); - else - Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("You are now known as %s"), streamData->lin->ptszText); - } - break; - case GC_EVENT_KICK: - if (pszNick && streamData->lin->ptszStatus) - Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, - TranslateT("%s kicked %s"), streamData->lin->ptszStatus, pszNick); - - if (streamData->lin->ptszText) - Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T(": %s"), streamData->lin->ptszText); - break; - case GC_EVENT_NOTICE: - if (pszNick && streamData->lin->ptszText) { - Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("Notice from %s: "), pszNick); - Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T("%s"), streamData->lin->ptszText); - } - break; - case GC_EVENT_TOPIC: - if (streamData->lin->ptszText) - Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, TranslateT("The topic is \'%s%s\'"), streamData->lin->ptszText, _T("%r")); - if (pszNick) - Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, - (streamData->lin->ptszUserInfo) ? TranslateT(" (set by %s on %s)") : - TranslateT(" (set by %s)"), - pszNick, streamData->lin->ptszUserInfo); - break; - case GC_EVENT_INFORMATION: - if (streamData->lin->ptszText) - Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, (streamData->lin->bIsMe) ? _T("--> %s") : _T("%s"), streamData->lin->ptszText); - break; - case GC_EVENT_ADDSTATUS: - if (pszNick && streamData->lin->ptszText && streamData->lin->ptszStatus) - Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, - TranslateT("%s enables \'%s\' status for %s"), - streamData->lin->ptszText, streamData->lin->ptszStatus, pszNick); - break; - case GC_EVENT_REMOVESTATUS: - if (pszNick && streamData->lin->ptszText && streamData->lin->ptszStatus) { - Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, - TranslateT("%s disables \'%s\' status for %s"), - streamData->lin->ptszText , streamData->lin->ptszStatus, pszNick); - } - break; + else + Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("You have joined %s"), streamData->si->ptszName); + } + break; + case GC_EVENT_PART: + if (pszNick) + Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s has left"), pszNick); + if (streamData->lin->ptszText) + Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T(": %s"), streamData->lin->ptszText); + break; + case GC_EVENT_QUIT: + if (pszNick) + Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s has disconnected"), pszNick); + if (streamData->lin->ptszText) + Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T(": %s"), streamData->lin->ptszText); + break; + case GC_EVENT_NICK: + if (pszNick && streamData->lin->ptszText) { + if (!streamData->lin->bIsMe) + Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s is now known as %s"), pszNick, streamData->lin->ptszText); + else + Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("You are now known as %s"), streamData->lin->ptszText); + } + break; + case GC_EVENT_KICK: + if (pszNick && streamData->lin->ptszStatus) + Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, + TranslateT("%s kicked %s"), streamData->lin->ptszStatus, pszNick); + + if (streamData->lin->ptszText) + Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T(": %s"), streamData->lin->ptszText); + break; + case GC_EVENT_NOTICE: + if (pszNick && streamData->lin->ptszText) { + Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("Notice from %s: "), pszNick); + Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T("%s"), streamData->lin->ptszText); + } + break; + case GC_EVENT_TOPIC: + if (streamData->lin->ptszText) + Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, TranslateT("The topic is \'%s%s\'"), streamData->lin->ptszText, _T("%r")); + if (pszNick) + Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, + (streamData->lin->ptszUserInfo) ? TranslateT(" (set by %s on %s)") : + TranslateT(" (set by %s)"), + pszNick, streamData->lin->ptszUserInfo); + break; + case GC_EVENT_INFORMATION: + if (streamData->lin->ptszText) + Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, (streamData->lin->bIsMe) ? _T("--> %s") : _T("%s"), streamData->lin->ptszText); + break; + case GC_EVENT_ADDSTATUS: + if (pszNick && streamData->lin->ptszText && streamData->lin->ptszStatus) + Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, + TranslateT("%s enables \'%s\' status for %s"), + streamData->lin->ptszText, streamData->lin->ptszStatus, pszNick); + break; + case GC_EVENT_REMOVESTATUS: + if (pszNick && streamData->lin->ptszText && streamData->lin->ptszStatus) { + Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, + TranslateT("%s disables \'%s\' status for %s"), + streamData->lin->ptszText , streamData->lin->ptszStatus, pszNick); + } + break; } } @@ -861,28 +861,28 @@ static char* Log_CreateRTF(LOGSTREAMDATA *streamData) if (ti && (int)ti->hIcon < streamData->si->iStatusCount) { int id = streamData->si->iStatusCount - (int)ti->hIcon - 1; switch (id) { - case 1: - pszIndicator[0] = '+'; - crNickIndex = 2; - break; - case 2: - pszIndicator[0] = '%'; - crNickIndex = 1; - break; - case 3: - pszIndicator[0] = '@'; - crNickIndex = 0; - break; - case 4: - pszIndicator[0] = '!'; - crNickIndex = 3; - break; - case 5: - pszIndicator[0] = '*'; - crNickIndex = 4; - break; - default: - pszIndicator[0] = 0; + case 1: + pszIndicator[0] = '+'; + crNickIndex = 2; + break; + case 2: + pszIndicator[0] = '%'; + crNickIndex = 1; + break; + case 3: + pszIndicator[0] = '@'; + crNickIndex = 0; + break; + case 4: + pszIndicator[0] = '!'; + crNickIndex = 3; + break; + case 5: + pszIndicator[0] = '*'; + crNickIndex = 4; + break; + default: + pszIndicator[0] = 0; } } break; diff --git a/plugins/TabSRMM/src/chat/message.cpp b/plugins/TabSRMM/src/chat/message.cpp index 48ccf0ff64..5fb99a38c4 100644 --- a/plugins/TabSRMM/src/chat/message.cpp +++ b/plugins/TabSRMM/src/chat/message.cpp @@ -119,167 +119,167 @@ TCHAR* Chat_DoRtfToTags(char* pszText, SESSION_INFO* si) iRemoveChars = 0; switch (*p1) { - case '\\': - if (!memcmp(p1, "\\cf", 3)) { // foreground color - int iCol, iInd; - iRemoveChars = 3 + ReadInteger(p1 + 3, &iCol); - iInd = RTFColorToIndex(pIndex, iCol, si); - bJustRemovedRTF = TRUE; - - if (bTextHasStarted || iInd >= 0) - mir_snprintf(InsertThis, SIZEOF(InsertThis), (iInd >= 0) ? "%%c%02u" : "%%C", iInd); - } else if (!memcmp(p1, "\\highlight", 10)) { //background color - int iCol, iInd; - iRemoveChars = 10 + ReadInteger(p1 + 10, &iCol); - iInd = RTFColorToIndex(pIndex, iCol, si); - bJustRemovedRTF = TRUE; - - if (bTextHasStarted || iInd >= 0) - mir_snprintf(InsertThis, SIZEOF(InsertThis), (iInd >= 0) ? "%%f%02u" : "%%F", iInd); - } else if (!memcmp(p1, "\\lang", 5)) { // language id - bTextHasStarted = bJustRemovedRTF = TRUE; - iRemoveChars = 5 + ReadInteger(p1 + 5, NULL); - } else if (!memcmp(p1, "\\par", 4)) { // newline - bTextHasStarted = bJustRemovedRTF = TRUE; - iRemoveChars = 4; - strcpy(InsertThis, "\n"); - } else if (!memcmp(p1, "\\endash", 7)) { - bTextHasStarted = bJustRemovedRTF = TRUE; - iRemoveChars = 7; - strcpy(InsertThis, "\xE2\x80\x93"); - } else if (!memcmp(p1, "\\emdash", 7)) { - bTextHasStarted = bJustRemovedRTF = TRUE; - iRemoveChars = 7; - strcpy(InsertThis, "\xE2\x80\x94"); - } else if (!memcmp(p1, "\\bullet", 7)) { - bTextHasStarted = bJustRemovedRTF = TRUE; + case '\\': + if (!memcmp(p1, "\\cf", 3)) { // foreground color + int iCol, iInd; + iRemoveChars = 3 + ReadInteger(p1 + 3, &iCol); + iInd = RTFColorToIndex(pIndex, iCol, si); + bJustRemovedRTF = TRUE; + + if (bTextHasStarted || iInd >= 0) + mir_snprintf(InsertThis, SIZEOF(InsertThis), (iInd >= 0) ? "%%c%02u" : "%%C", iInd); + } else if (!memcmp(p1, "\\highlight", 10)) { //background color + int iCol, iInd; + iRemoveChars = 10 + ReadInteger(p1 + 10, &iCol); + iInd = RTFColorToIndex(pIndex, iCol, si); + bJustRemovedRTF = TRUE; + + if (bTextHasStarted || iInd >= 0) + mir_snprintf(InsertThis, SIZEOF(InsertThis), (iInd >= 0) ? "%%f%02u" : "%%F", iInd); + } else if (!memcmp(p1, "\\lang", 5)) { // language id + bTextHasStarted = bJustRemovedRTF = TRUE; + iRemoveChars = 5 + ReadInteger(p1 + 5, NULL); + } else if (!memcmp(p1, "\\par", 4)) { // newline + bTextHasStarted = bJustRemovedRTF = TRUE; + iRemoveChars = 4; + strcpy(InsertThis, "\n"); + } else if (!memcmp(p1, "\\endash", 7)) { + bTextHasStarted = bJustRemovedRTF = TRUE; + iRemoveChars = 7; + strcpy(InsertThis, "\xE2\x80\x93"); + } else if (!memcmp(p1, "\\emdash", 7)) { + bTextHasStarted = bJustRemovedRTF = TRUE; + iRemoveChars = 7; + strcpy(InsertThis, "\xE2\x80\x94"); + } else if (!memcmp(p1, "\\bullet", 7)) { + bTextHasStarted = bJustRemovedRTF = TRUE; + iRemoveChars = 7; + strcpy(InsertThis, "\xE2\x80\xA2"); + } else if (!memcmp(p1, "\\line", 5)) { // newline + bTextHasStarted = bJustRemovedRTF = TRUE; + iRemoveChars = 5; + strcpy(InsertThis, "\n"); + } else if (!memcmp(p1, "\\b", 2)) { //bold + bTextHasStarted = bJustRemovedRTF = TRUE; + iRemoveChars = (p1[2] != '0') ? 2 : 3; + strcpy(InsertThis, (p1[2] != '0') ? "%b" : "%B"); + } else if (!memcmp(p1, "\\i", 2)) { // italics + bTextHasStarted = bJustRemovedRTF = TRUE; + iRemoveChars = (p1[2] != '0') ? 2 : 3; + strcpy(InsertThis, (p1[2] != '0') ? "%i" : "%I"); + } else if (!memcmp(p1, "\\uc", 3)) { // number of Unicode chars + bTextHasStarted = bJustRemovedRTF = TRUE; + iUcMode = p1[3] - '0'; + iRemoveChars = 4; + } else if (!memcmp(p1, "\\ul", 3)) { // underlined + bTextHasStarted = bJustRemovedRTF = TRUE; + if (p1[3] == 'n') iRemoveChars = 7; - strcpy(InsertThis, "\xE2\x80\xA2"); - } else if (!memcmp(p1, "\\line", 5)) { // newline - bTextHasStarted = bJustRemovedRTF = TRUE; - iRemoveChars = 5; - strcpy(InsertThis, "\n"); - } else if (!memcmp(p1, "\\b", 2)) { //bold - bTextHasStarted = bJustRemovedRTF = TRUE; - iRemoveChars = (p1[2] != '0') ? 2 : 3; - strcpy(InsertThis, (p1[2] != '0') ? "%b" : "%B"); - } else if (!memcmp(p1, "\\i", 2)) { // italics - bTextHasStarted = bJustRemovedRTF = TRUE; - iRemoveChars = (p1[2] != '0') ? 2 : 3; - strcpy(InsertThis, (p1[2] != '0') ? "%i" : "%I"); - } else if (!memcmp(p1, "\\uc", 3)) { // number of Unicode chars - bTextHasStarted = bJustRemovedRTF = TRUE; - iUcMode = p1[3] - '0'; + else if (p1[3] == '0') iRemoveChars = 4; - } else if (!memcmp(p1, "\\ul", 3)) { // underlined - bTextHasStarted = bJustRemovedRTF = TRUE; - if (p1[3] == 'n') - iRemoveChars = 7; - else if (p1[3] == '0') - iRemoveChars = 4; - else - iRemoveChars = 3; - mir_snprintf(InsertThis, SIZEOF(InsertThis), (p1[3] != '0' && p1[3] != 'n') ? "%%u" : "%%U"); - } else if (p1[1] == 'f' && isdigit(p1[2])) { // unicode char - bTextHasStarted = bJustRemovedRTF = TRUE; - iRemoveChars = 2 + ReadInteger(p1 + 2, NULL); - } else if (p1[1] == '\\' || p1[1] == '{' || p1[1] == '}') { // escaped characters - bTextHasStarted = TRUE; - bJustRemovedRTF = FALSE; - iRemoveChars = 2; - mir_snprintf(InsertThis, SIZEOF(InsertThis), "%c", p1[1]); - } else if (p1[1] == '~') { // non-breaking space - bTextHasStarted = TRUE; - bJustRemovedRTF = FALSE; - iRemoveChars = 2; - strcpy(InsertThis, "\xC2\xA0"); - } - - - else if (!memcmp(p1, "\\tab",4)) { // tab - bTextHasStarted = TRUE; - bJustRemovedRTF = TRUE; - iRemoveChars = 4; - strcpy(InsertThis, "\x09"); - } - else if (!memcmp(p1, "\\ldblquote",10)) { - bTextHasStarted = TRUE; - bJustRemovedRTF = TRUE; - iRemoveChars = 10; - strcpy(InsertThis, "\xe2\x80\x9c"); - } - else if (!memcmp(p1, "\\rdblquote",10)) { - bTextHasStarted = TRUE; - bJustRemovedRTF = TRUE; - iRemoveChars = 10; - strcpy(InsertThis, "\xe2\x80\x9d"); - } - else if (!memcmp(p1, "\\lquote",7)) { - bTextHasStarted = TRUE; - bJustRemovedRTF = TRUE; - iRemoveChars = 7; - strcpy(InsertThis, "\xE2\x80\x98"); - } - else if (!memcmp(p1, "\\rquote",7)) { - bTextHasStarted = TRUE; - bJustRemovedRTF = TRUE; - iRemoveChars = 7; - strcpy(InsertThis, "\xE2\x80\x99"); - } - - else if (p1[1] == '\'') { // special character - char tmp[4], *p3 = tmp; - bTextHasStarted = TRUE; - bJustRemovedRTF = FALSE; - if (p1[2] != ' ' && p1[2] != '\\') { - *p3++ = p1[2]; - iRemoveChars = 3; - if (p1[3] != ' ' && p1[3] != '\\') { - *p3++ = p1[3]; - iRemoveChars++; - } - *p3 = 0; - sscanf(tmp, "%x", InsertThis); - - InsertThis[1] = 0; - } else iRemoveChars = 2; - } else if (bJustRemovedRTF) { // remove unknown RTF command - int j = 1; - bJustRemovedRTF = TRUE; - while (p1[j] != ' ' && p1[j] != '\\' && p1[j] != '\0') - j++; - iRemoveChars = j; - } - break; - - case '{': // other RTF control characters - case '}': - iRemoveChars = 1; - break; - - case '\r': case '\n': + else + iRemoveChars = 3; + mir_snprintf(InsertThis, SIZEOF(InsertThis), (p1[3] != '0' && p1[3] != 'n') ? "%%u" : "%%U"); + } else if (p1[1] == 'f' && isdigit(p1[2])) { // unicode char + bTextHasStarted = bJustRemovedRTF = TRUE; + iRemoveChars = 2 + ReadInteger(p1 + 2, NULL); + } else if (p1[1] == '\\' || p1[1] == '{' || p1[1] == '}') { // escaped characters bTextHasStarted = TRUE; bJustRemovedRTF = FALSE; - iRemoveChars = 1; - break; - - case '%': // escape chat -> protocol control character + iRemoveChars = 2; + mir_snprintf(InsertThis, SIZEOF(InsertThis), "%c", p1[1]); + } else if (p1[1] == '~') { // non-breaking space bTextHasStarted = TRUE; bJustRemovedRTF = FALSE; - iRemoveChars = 1; - strcpy(InsertThis, "%%"); - break; - case ' ': // remove spaces following a RTF command - if (bJustRemovedRTF) - iRemoveChars = 1; - bJustRemovedRTF = FALSE; + iRemoveChars = 2; + strcpy(InsertThis, "\xC2\xA0"); + } + + + else if (!memcmp(p1, "\\tab",4)) { // tab + bTextHasStarted = TRUE; + bJustRemovedRTF = TRUE; + iRemoveChars = 4; + strcpy(InsertThis, "\x09"); + } + else if (!memcmp(p1, "\\ldblquote",10)) { bTextHasStarted = TRUE; - break; + bJustRemovedRTF = TRUE; + iRemoveChars = 10; + strcpy(InsertThis, "\xe2\x80\x9c"); + } + else if (!memcmp(p1, "\\rdblquote",10)) { + bTextHasStarted = TRUE; + bJustRemovedRTF = TRUE; + iRemoveChars = 10; + strcpy(InsertThis, "\xe2\x80\x9d"); + } + else if (!memcmp(p1, "\\lquote",7)) { + bTextHasStarted = TRUE; + bJustRemovedRTF = TRUE; + iRemoveChars = 7; + strcpy(InsertThis, "\xE2\x80\x98"); + } + else if (!memcmp(p1, "\\rquote",7)) { + bTextHasStarted = TRUE; + bJustRemovedRTF = TRUE; + iRemoveChars = 7; + strcpy(InsertThis, "\xE2\x80\x99"); + } - default: // other text that should not be touched + else if (p1[1] == '\'') { // special character + char tmp[4], *p3 = tmp; bTextHasStarted = TRUE; bJustRemovedRTF = FALSE; - break; + if (p1[2] != ' ' && p1[2] != '\\') { + *p3++ = p1[2]; + iRemoveChars = 3; + if (p1[3] != ' ' && p1[3] != '\\') { + *p3++ = p1[3]; + iRemoveChars++; + } + *p3 = 0; + sscanf(tmp, "%x", InsertThis); + + InsertThis[1] = 0; + } else iRemoveChars = 2; + } else if (bJustRemovedRTF) { // remove unknown RTF command + int j = 1; + bJustRemovedRTF = TRUE; + while (p1[j] != ' ' && p1[j] != '\\' && p1[j] != '\0') + j++; + iRemoveChars = j; + } + break; + + case '{': // other RTF control characters + case '}': + iRemoveChars = 1; + break; + + case '\r': case '\n': + bTextHasStarted = TRUE; + bJustRemovedRTF = FALSE; + iRemoveChars = 1; + break; + + case '%': // escape chat -> protocol control character + bTextHasStarted = TRUE; + bJustRemovedRTF = FALSE; + iRemoveChars = 1; + strcpy(InsertThis, "%%"); + break; + case ' ': // remove spaces following a RTF command + if (bJustRemovedRTF) + iRemoveChars = 1; + bJustRemovedRTF = FALSE; + bTextHasStarted = TRUE; + break; + + default: // other text that should not be touched + bTextHasStarted = TRUE; + bJustRemovedRTF = FALSE; + break; } // move the memory and paste in new commands instead of the old RTF diff --git a/plugins/TabSRMM/src/chat/options.cpp b/plugins/TabSRMM/src/chat/options.cpp index 302a64fd91..b1fa380e26 100644 --- a/plugins/TabSRMM/src/chat/options.cpp +++ b/plugins/TabSRMM/src/chat/options.cpp @@ -235,11 +235,10 @@ void LoadMsgDlgFont(int section, int i, LOGFONT *lf, COLORREF* colour, char *szM int j = (i >= 100 ? i - 100 : i); struct FontOptionsList *fol = fontOptionsList; - switch (section) - { - case FONTSECTION_CHAT: fol = CHAT_fontOptionsList; break; - case FONTSECTION_IM: fol = IM_fontOptionsList; break; - case FONTSECTION_IP: fol = IP_fontOptionsList; break; + switch (section) { + case FONTSECTION_CHAT: fol = CHAT_fontOptionsList; break; + case FONTSECTION_IM: fol = IM_fontOptionsList; break; + case FONTSECTION_IP: fol = IP_fontOptionsList; break; } if (colour) { @@ -398,15 +397,14 @@ static INT CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM p { char szDir[MAX_PATH]; switch (uMsg) { - case BFFM_INITIALIZED: { - const TCHAR *szData = M->getUserDir(); - SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)szData); - break; - } - case BFFM_SELCHANGED: - if (SHGetPathFromIDListA((LPITEMIDLIST) lp , szDir)) - SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM)szDir); - break; + case BFFM_INITIALIZED: + SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)M->getUserDir()); + break; + + case BFFM_SELCHANGED: + if (SHGetPathFromIDListA((LPITEMIDLIST) lp , szDir)) + SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM)szDir); + break; } return 0; } @@ -512,131 +510,125 @@ INT_PTR CALLBACK DlgProcOptions1(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM static HTREEITEM hListHeading2 = 0; switch (uMsg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - if (PluginConfig.m_chat_enabled) { - SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_CHECKBOXES), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_CHECKBOXES), GWL_STYLE) | TVS_NOHSCROLL | TVS_CHECKBOXES); - - HIMAGELIST himlOptions = (HIMAGELIST)SendDlgItemMessage(hwndDlg, IDC_CHECKBOXES, TVM_SETIMAGELIST, TVSIL_STATE, (LPARAM)CreateStateImageList()); - ImageList_Destroy(himlOptions); + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + if (PluginConfig.m_chat_enabled) { + SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_CHECKBOXES), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_CHECKBOXES), GWL_STYLE) | TVS_NOHSCROLL | TVS_CHECKBOXES); - hListHeading1 = InsertBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), TranslateT("Appearance and functionality of chat room windows"), TRUE); - hListHeading2 = InsertBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), TranslateT("Appearance of the message log"), TRUE); + HIMAGELIST himlOptions = (HIMAGELIST)SendDlgItemMessage(hwndDlg, IDC_CHECKBOXES, TVM_SETIMAGELIST, TVSIL_STATE, (LPARAM)CreateStateImageList()); + ImageList_Destroy(himlOptions); - FillBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading1, branch1, SIZEOF(branch1), 0x0000); - FillBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading2, branch2, SIZEOF(branch2), 0x0000); + hListHeading1 = InsertBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), TranslateT("Appearance and functionality of chat room windows"), TRUE); + hListHeading2 = InsertBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), TranslateT("Appearance of the message log"), TRUE); - { - TCHAR* pszGroup = NULL; - InitSetting(&pszGroup, "AddToGroup", _T("Chat rooms")); - SetWindowText(GetDlgItem(hwndDlg, IDC_GROUP), pszGroup); - mir_free(pszGroup); - Utils::showDlgControl(hwndDlg, IDC_STATIC_MESSAGE, SW_HIDE); - } - } else { - int i = 0; + FillBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading1, branch1, SIZEOF(branch1), 0x0000); + FillBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading2, branch2, SIZEOF(branch2), 0x0000); - while (_o1controls[i]) - Utils::showDlgControl(hwndDlg, _o1controls[i++], SW_HIDE); + { + TCHAR* pszGroup = NULL; + InitSetting(&pszGroup, "AddToGroup", _T("Chat rooms")); + SetWindowText(GetDlgItem(hwndDlg, IDC_GROUP), pszGroup); + mir_free(pszGroup); + Utils::showDlgControl(hwndDlg, IDC_STATIC_MESSAGE, SW_HIDE); } - break; + } + else { + int i = 0; - case WM_COMMAND: - if ((LOWORD(wParam) == IDC_GROUP) - && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return 0; + while (_o1controls[i]) + Utils::showDlgControl(hwndDlg, _o1controls[i++], SW_HIDE); + } + break; - if (lParam != 0) - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; + case WM_COMMAND: + if ((LOWORD(wParam) == IDC_GROUP) && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) + return 0; - case WM_NOTIFY: { - switch (((LPNMHDR)lParam)->idFrom) { - case IDC_CHECKBOXES: - if (((LPNMHDR)lParam)->code == NM_CLICK || (((LPNMHDR)lParam)->code == TVN_KEYDOWN && ((LPNMTVKEYDOWN)lParam)->wVKey == VK_SPACE)) { - TVHITTESTINFO hti; - hti.pt.x = (short)LOWORD(GetMessagePos()); - hti.pt.y = (short)HIWORD(GetMessagePos()); - ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt); - if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti) || ((LPNMHDR)lParam)->code == TVN_KEYDOWN) { - if (((LPNMHDR)lParam)->code == TVN_KEYDOWN) - hti.flags |= TVHT_ONITEMSTATEICON; - if (hti.flags&TVHT_ONITEMSTATEICON) { - TVITEM tvi = {0}; - - tvi.mask = TVIF_HANDLE | TVIF_STATE; - tvi.stateMask = TVIS_STATEIMAGEMASK | TVIS_BOLD; - - if (((LPNMHDR)lParam)->code == TVN_KEYDOWN) - tvi.hItem = TreeView_GetSelection(((LPNMHDR)lParam)->hwndFrom); - else - tvi.hItem = (HTREEITEM)hti.hItem; - - TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom, &tvi); - - if (tvi.state & TVIS_BOLD && hti.flags & TVHT_ONITEMSTATEICON) { - tvi.state = INDEXTOSTATEIMAGEMASK(0) | TVIS_BOLD; - SendDlgItemMessageA(hwndDlg, IDC_CHECKBOXES, TVM_SETITEMA, 0, (LPARAM)&tvi); - } else if (hti.flags&TVHT_ONITEMSTATEICON) { - if (((tvi.state & TVIS_STATEIMAGEMASK) >> 12) == 3) { - tvi.state = INDEXTOSTATEIMAGEMASK(1); - SendDlgItemMessageA(hwndDlg, IDC_CHECKBOXES, TVM_SETITEMA, 0, (LPARAM)&tvi); - } - } - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - } - } + if (lParam != 0) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; - break; - - case 0: - switch (((LPNMHDR)lParam)->code) { - case PSN_APPLY: { - if (PluginConfig.m_chat_enabled) { - int iLen; - TCHAR *pszText = NULL; - BYTE b; - - iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_GROUP)); - if (iLen > 0) { - pszText = (TCHAR *)realloc(pszText, (iLen + 2) * sizeof(TCHAR)); - GetDlgItemText(hwndDlg, IDC_GROUP, pszText, iLen + 1); - M->WriteTString(NULL, "Chat", "AddToGroup", pszText); - } else - M->WriteTString(NULL, "Chat", "AddToGroup", _T("")); - - g_Settings.hGroup = 0; - - if (pszText) - free(pszText); - - b = M->GetByte("Chat", "Tabs", 1); - SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch1, sizeof(branch1) / sizeof(branch1[0])); - SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch2, sizeof(branch2) / sizeof(branch2[0])); - - LoadGlobalSettings(); - MM_FontsChanged(); - FreeMsgLogBitmaps(); - LoadMsgLogBitmaps(); - SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE); - SM_ReconfigureFilters(); + case WM_NOTIFY: + switch (((LPNMHDR)lParam)->idFrom) { + case IDC_CHECKBOXES: + if (((LPNMHDR)lParam)->code == NM_CLICK || (((LPNMHDR)lParam)->code == TVN_KEYDOWN && ((LPNMTVKEYDOWN)lParam)->wVKey == VK_SPACE)) { + TVHITTESTINFO hti; + hti.pt.x = (short)LOWORD(GetMessagePos()); + hti.pt.y = (short)HIWORD(GetMessagePos()); + ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt); + if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti) || ((LPNMHDR)lParam)->code == TVN_KEYDOWN) { + if (((LPNMHDR)lParam)->code == TVN_KEYDOWN) + hti.flags |= TVHT_ONITEMSTATEICON; + if (hti.flags&TVHT_ONITEMSTATEICON) { + TVITEM tvi = {0}; + + tvi.mask = TVIF_HANDLE | TVIF_STATE; + tvi.stateMask = TVIS_STATEIMAGEMASK | TVIS_BOLD; + + if (((LPNMHDR)lParam)->code == TVN_KEYDOWN) + tvi.hItem = TreeView_GetSelection(((LPNMHDR)lParam)->hwndFrom); + else + tvi.hItem = (HTREEITEM)hti.hItem; + + TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom, &tvi); + + if (tvi.state & TVIS_BOLD && hti.flags & TVHT_ONITEMSTATEICON) { + tvi.state = INDEXTOSTATEIMAGEMASK(0) | TVIS_BOLD; + SendDlgItemMessageA(hwndDlg, IDC_CHECKBOXES, TVM_SETITEMA, 0, (LPARAM)&tvi); + } else if (hti.flags&TVHT_ONITEMSTATEICON) { + if (((tvi.state & TVIS_STATEIMAGEMASK) >> 12) == 3) { + tvi.state = INDEXTOSTATEIMAGEMASK(1); + SendDlgItemMessageA(hwndDlg, IDC_CHECKBOXES, TVM_SETITEMA, 0, (LPARAM)&tvi); } } - return TRUE; + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } + } + } + break; + + case 0: + switch (((LPNMHDR)lParam)->code) { + case PSN_APPLY: + if (PluginConfig.m_chat_enabled) { + int iLen; + TCHAR *pszText = NULL; + BYTE b; + + iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_GROUP)); + if (iLen > 0) { + pszText = (TCHAR *)realloc(pszText, (iLen + 2) * sizeof(TCHAR)); + GetDlgItemText(hwndDlg, IDC_GROUP, pszText, iLen + 1); + M->WriteTString(NULL, "Chat", "AddToGroup", pszText); + } else + M->WriteTString(NULL, "Chat", "AddToGroup", _T("")); + + g_Settings.hGroup = 0; + + if (pszText) + free(pszText); + + b = M->GetByte("Chat", "Tabs", 1); + SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch1, sizeof(branch1) / sizeof(branch1[0])); + SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch2, sizeof(branch2) / sizeof(branch2[0])); + + LoadGlobalSettings(); + MM_FontsChanged(); + FreeMsgLogBitmaps(); + LoadMsgLogBitmaps(); + SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE); + SM_ReconfigureFilters(); + } + return TRUE; } - } - break; - case WM_DESTROY: { - BYTE b = TreeView_GetItemState(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading1, TVIS_EXPANDED) & TVIS_EXPANDED ? 1 : 0; - M->WriteByte("Chat", "Branch1Exp", b); - b = TreeView_GetItemState(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading2, TVIS_EXPANDED) & TVIS_EXPANDED ? 1 : 0; - M->WriteByte("Chat", "Branch2Exp", b); } break; - default: - break; + case WM_DESTROY: + BYTE b = TreeView_GetItemState(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading1, TVIS_EXPANDED) & TVIS_EXPANDED ? 1 : 0; + M->WriteByte("Chat", "Branch1Exp", b); + b = TreeView_GetItemState(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading2, TVIS_EXPANDED) & TVIS_EXPANDED ? 1 : 0; + M->WriteByte("Chat", "Branch2Exp", b); } return FALSE; } @@ -652,7 +644,7 @@ static TCHAR* chatcolorsnames[] ={ LPGENT("Selection background"), LPGENT("Selected text"), LPGENT("Incremental search highlight") - }; +}; void RegisterFontServiceFonts() { char szTemp[100]; @@ -681,48 +673,48 @@ void RegisterFontServiceFonts() { _tcsncpy(fid.backgroundGroup, LPGENT("Message Sessions")_T("/")LPGENT("Single Messaging"), SIZEOF(fid.backgroundGroup)); _tcsncpy(fid.group, LPGENT("Message Sessions")_T("/")LPGENT("Single Messaging"), SIZEOF(fid.group)); switch (i) { - case MSGFONTID_MYMSG: - case 1: - case MSGFONTID_MYNAME: - case MSGFONTID_MYTIME: - case 21: - _tcsncpy(fid.backgroundName, LPGENT("Outgoing background"), SIZEOF(fid.backgroundName)); - break; - case 8: - case 9: - case 12: - case 13: - _tcsncpy(fid.backgroundName, LPGENT("Outgoing background(old)"), SIZEOF(fid.backgroundName)); - break; - case 10: - case 11: - case 14: - case 15: - _tcsncpy(fid.backgroundName, LPGENT("Incoming background(old)"), SIZEOF(fid.backgroundName)); - break; - case MSGFONTID_MESSAGEAREA: - _tcsncpy(fid.group, LPGENT("Message Sessions"), SIZEOF(fid.group)); - _tcsncpy(fid.backgroundGroup, LPGENT("Message Sessions"), SIZEOF(fid.backgroundGroup)); - _tcsncpy(fid.backgroundName, LPGENT("Input area background"), SIZEOF(fid.backgroundName)); - fid.flags |= FIDF_DISABLESTYLES; - fid.flags &= ~FIDF_ALLOWEFFECTS; - break; - case 17: - _tcsncpy(fid.backgroundName, LPGENT("Status background"), SIZEOF(fid.backgroundName)); - break; - case 18: - _tcsncpy(fid.backgroundGroup, LPGENT("Message Sessions"), SIZEOF(fid.backgroundGroup)); - _tcsncpy(fid.backgroundName, LPGENT("Log background"), SIZEOF(fid.backgroundName)); - break; - case 19: - _tcsncpy(fid.backgroundName, _T(""), SIZEOF(fid.backgroundName)); - break; - default: - _tcsncpy(fid.backgroundName, LPGENT("Incoming background"), SIZEOF(fid.backgroundName)); - break; - } - FontRegisterT(&fid); + case MSGFONTID_MYMSG: + case 1: + case MSGFONTID_MYNAME: + case MSGFONTID_MYTIME: + case 21: + _tcsncpy(fid.backgroundName, LPGENT("Outgoing background"), SIZEOF(fid.backgroundName)); + break; + case 8: + case 9: + case 12: + case 13: + _tcsncpy(fid.backgroundName, LPGENT("Outgoing background(old)"), SIZEOF(fid.backgroundName)); + break; + case 10: + case 11: + case 14: + case 15: + _tcsncpy(fid.backgroundName, LPGENT("Incoming background(old)"), SIZEOF(fid.backgroundName)); + break; + case MSGFONTID_MESSAGEAREA: + _tcsncpy(fid.group, LPGENT("Message Sessions"), SIZEOF(fid.group)); + _tcsncpy(fid.backgroundGroup, LPGENT("Message Sessions"), SIZEOF(fid.backgroundGroup)); + _tcsncpy(fid.backgroundName, LPGENT("Input area background"), SIZEOF(fid.backgroundName)); + fid.flags |= FIDF_DISABLESTYLES; + fid.flags &= ~FIDF_ALLOWEFFECTS; + break; + case 17: + _tcsncpy(fid.backgroundName, LPGENT("Status background"), SIZEOF(fid.backgroundName)); + break; + case 18: + _tcsncpy(fid.backgroundGroup, LPGENT("Message Sessions"), SIZEOF(fid.backgroundGroup)); + _tcsncpy(fid.backgroundName, LPGENT("Log background"), SIZEOF(fid.backgroundName)); + break; + case 19: + _tcsncpy(fid.backgroundName, _T(""), SIZEOF(fid.backgroundName)); + break; + default: + _tcsncpy(fid.backgroundName, LPGENT("Incoming background"), SIZEOF(fid.backgroundName)); + break; } + FontRegisterT(&fid); + } fontOptionsList = IP_fontOptionsList; fid.flags = FIDF_DEFAULTVALID|FIDF_ALLOWEFFECTS; @@ -841,12 +833,11 @@ void RegisterFontServiceFonts() { int FontServiceFontsChanged(WPARAM,LPARAM) { if (PluginConfig.m_chat_enabled) { - LOGFONT lf; - LoadLogFonts(); FreeMsgLogBitmaps(); LoadMsgLogBitmaps(); + LOGFONT lf; LoadMsgDlgFont(FONTSECTION_CHAT, 0, &lf, NULL, CHAT_FONTMODULE); HFONT hFont = CreateFontIndirect(&lf); int iText = GetTextPixelSize(MakeTimeStamp(g_Settings.pszTimeStamp, time(NULL)), hFont, TRUE); @@ -882,287 +873,280 @@ static UINT _o3chatcontrols[] = {0}; INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { - case WM_INITDIALOG: { - - TranslateDialogDefault(hwndDlg); - - if (PluginConfig.m_chat_enabled) { - - SendDlgItemMessage(hwndDlg, IDC_CHAT_SPIN2, UDM_SETRANGE, 0, MAKELONG(5000, 0)); - SendDlgItemMessage(hwndDlg, IDC_CHAT_SPIN2, UDM_SETPOS, 0, MAKELONG(db_get_w(NULL, "Chat", "LogLimit", 100), 0)); - SendDlgItemMessage(hwndDlg, IDC_CHAT_SPIN3, UDM_SETRANGE, 0, MAKELONG(255, 10)); - SendDlgItemMessage(hwndDlg, IDC_CHAT_SPIN3, UDM_SETPOS, 0, MAKELONG(M->GetByte("Chat", "NicklistRowDist", 12), 0)); - SetDlgItemText(hwndDlg, IDC_LOGTIMESTAMP, g_Settings.pszTimeStampLog); - SetDlgItemText(hwndDlg, IDC_TIMESTAMP, g_Settings.pszTimeStamp); - SetDlgItemText(hwndDlg, IDC_OUTSTAMP, g_Settings.pszOutgoingNick); - SetDlgItemText(hwndDlg, IDC_INSTAMP, g_Settings.pszIncomingNick); - CheckDlgButton(hwndDlg, IDC_LOGGING, g_Settings.LoggingEnabled); - SetDlgItemText(hwndDlg, IDC_LOGDIRECTORY, g_Settings.pszLogDir); - Utils::enableDlgControl(hwndDlg, IDC_LOGDIRECTORY, g_Settings.LoggingEnabled ? TRUE : FALSE); - Utils::enableDlgControl(hwndDlg, IDC_FONTCHOOSE, g_Settings.LoggingEnabled ? TRUE : FALSE); - SendDlgItemMessage(hwndDlg, IDC_CHAT_SPIN4, UDM_SETRANGE, 0, MAKELONG(10000, 0)); - SendDlgItemMessage(hwndDlg, IDC_CHAT_SPIN4, UDM_SETPOS, 0, MAKELONG(db_get_w(NULL, "Chat", "LoggingLimit", 100), 0)); - Utils::enableDlgControl(hwndDlg, IDC_LIMIT, g_Settings.LoggingEnabled ? TRUE : FALSE); - - if (ServiceExists(MS_UTILS_REPLACEVARS)) { - TCHAR tszTooltipText[2048]; - - mir_sntprintf(tszTooltipText, SIZEOF(tszTooltipText), - _T("%s - %s\n%s - %s\n%s - %s\n\n") - _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n\n") - _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s"), - // contact vars - _T("%nick%"), TranslateT("nick of current contact (if defined)"), - _T("%proto%"), TranslateT("protocol name of current contact (if defined). Account name is used when protocol supports multiaccounts"), - _T("%userid%"), TranslateT("UserID of current contact (if defined). It is like UIN Number for ICQ, JID for Jabber, etc."), - // global vars - _T("%miranda_path%"), TranslateT("path to root miranda folder"), - _T("%miranda_profile%"), TranslateT("path to current miranda profile"), - _T("%miranda_profilename%"), TranslateT("name of current miranda profile (filename, without extension)"), - _T("%miranda_userdata%"), TranslateT("will return parsed string %miranda_profile%\\Profiles\\%miranda_profilename%"), - _T("%appdata%"), TranslateT("same as environment variable %APPDATA% for currently logged-on Windows user"), - _T("%username%"), TranslateT("username for currently logged-on Windows user"), - _T("%mydocuments%"), TranslateT("\"My Documents\" folder for currently logged-on Windows user"), - _T("%desktop%"), TranslateT("\"Desktop\" folder for currently logged-on Windows user"), - _T("%xxxxxxx%"), TranslateT("any environment variable defined in current Windows session (like %systemroot%, %allusersprofile%, etc.)"), - // date/time vars - _T("%d%"), TranslateT("day of month, 1-31"), - _T("%dd%"), TranslateT("day of month, 01-31"), - _T("%m%"), TranslateT("month number, 1-12"), - _T("%mm%"), TranslateT("month number, 01-12"), - _T("%mon%"), TranslateT("abbreviated month name"), - _T("%month%"), TranslateT("full month name"), - _T("%yy%"), TranslateT("year without century, 01-99"), - _T("%yyyy%"), TranslateT("year with century, 1901-9999"), - _T("%wday%"), TranslateT("abbreviated weekday name"), - _T("%weekday%"), TranslateT("full weekday name")); - hPathTip = CreateToolTip(GetDlgItem(hwndDlg, IDC_LOGDIRECTORY), tszTooltipText, TranslateT("Variables")); - } - - } else { - int i = 0; - - while (_o2chatcontrols[i]) - Utils::enableDlgControl(hwndDlg, _o2chatcontrols[i++], FALSE); + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + + if (PluginConfig.m_chat_enabled) { + SendDlgItemMessage(hwndDlg, IDC_CHAT_SPIN2, UDM_SETRANGE, 0, MAKELONG(5000, 0)); + SendDlgItemMessage(hwndDlg, IDC_CHAT_SPIN2, UDM_SETPOS, 0, MAKELONG(db_get_w(NULL, "Chat", "LogLimit", 100), 0)); + SendDlgItemMessage(hwndDlg, IDC_CHAT_SPIN3, UDM_SETRANGE, 0, MAKELONG(255, 10)); + SendDlgItemMessage(hwndDlg, IDC_CHAT_SPIN3, UDM_SETPOS, 0, MAKELONG(M->GetByte("Chat", "NicklistRowDist", 12), 0)); + SetDlgItemText(hwndDlg, IDC_LOGTIMESTAMP, g_Settings.pszTimeStampLog); + SetDlgItemText(hwndDlg, IDC_TIMESTAMP, g_Settings.pszTimeStamp); + SetDlgItemText(hwndDlg, IDC_OUTSTAMP, g_Settings.pszOutgoingNick); + SetDlgItemText(hwndDlg, IDC_INSTAMP, g_Settings.pszIncomingNick); + CheckDlgButton(hwndDlg, IDC_LOGGING, g_Settings.LoggingEnabled); + SetDlgItemText(hwndDlg, IDC_LOGDIRECTORY, g_Settings.pszLogDir); + Utils::enableDlgControl(hwndDlg, IDC_LOGDIRECTORY, g_Settings.LoggingEnabled ? TRUE : FALSE); + Utils::enableDlgControl(hwndDlg, IDC_FONTCHOOSE, g_Settings.LoggingEnabled ? TRUE : FALSE); + SendDlgItemMessage(hwndDlg, IDC_CHAT_SPIN4, UDM_SETRANGE, 0, MAKELONG(10000, 0)); + SendDlgItemMessage(hwndDlg, IDC_CHAT_SPIN4, UDM_SETPOS, 0, MAKELONG(db_get_w(NULL, "Chat", "LoggingLimit", 100), 0)); + Utils::enableDlgControl(hwndDlg, IDC_LIMIT, g_Settings.LoggingEnabled ? TRUE : FALSE); + + if (ServiceExists(MS_UTILS_REPLACEVARS)) { + TCHAR tszTooltipText[2048]; + + mir_sntprintf(tszTooltipText, SIZEOF(tszTooltipText), + _T("%s - %s\n%s - %s\n%s - %s\n\n") + _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n\n") + _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s"), + // contact vars + _T("%nick%"), TranslateT("nick of current contact (if defined)"), + _T("%proto%"), TranslateT("protocol name of current contact (if defined). Account name is used when protocol supports multiaccounts"), + _T("%userid%"), TranslateT("UserID of current contact (if defined). It is like UIN Number for ICQ, JID for Jabber, etc."), + // global vars + _T("%miranda_path%"), TranslateT("path to root miranda folder"), + _T("%miranda_profile%"), TranslateT("path to current miranda profile"), + _T("%miranda_profilename%"), TranslateT("name of current miranda profile (filename, without extension)"), + _T("%miranda_userdata%"), TranslateT("will return parsed string %miranda_profile%\\Profiles\\%miranda_profilename%"), + _T("%appdata%"), TranslateT("same as environment variable %APPDATA% for currently logged-on Windows user"), + _T("%username%"), TranslateT("username for currently logged-on Windows user"), + _T("%mydocuments%"), TranslateT("\"My Documents\" folder for currently logged-on Windows user"), + _T("%desktop%"), TranslateT("\"Desktop\" folder for currently logged-on Windows user"), + _T("%xxxxxxx%"), TranslateT("any environment variable defined in current Windows session (like %systemroot%, %allusersprofile%, etc.)"), + // date/time vars + _T("%d%"), TranslateT("day of month, 1-31"), + _T("%dd%"), TranslateT("day of month, 01-31"), + _T("%m%"), TranslateT("month number, 1-12"), + _T("%mm%"), TranslateT("month number, 01-12"), + _T("%mon%"), TranslateT("abbreviated month name"), + _T("%month%"), TranslateT("full month name"), + _T("%yy%"), TranslateT("year without century, 01-99"), + _T("%yyyy%"), TranslateT("year with century, 1901-9999"), + _T("%wday%"), TranslateT("abbreviated weekday name"), + _T("%weekday%"), TranslateT("full weekday name")); + hPathTip = CreateToolTip(GetDlgItem(hwndDlg, IDC_LOGDIRECTORY), tszTooltipText, TranslateT("Variables")); } - if (hPathTip) - SetTimer(hwndDlg, 0, 3000, NULL); - break; } - case WM_COMMAND: - if ((LOWORD(wParam) == IDC_INSTAMP - || LOWORD(wParam) == IDC_OUTSTAMP - || LOWORD(wParam) == IDC_TIMESTAMP - || LOWORD(wParam) == IDC_LOGLIMIT - || LOWORD(wParam) == IDC_NICKROW2 - || LOWORD(wParam) == IDC_LOGDIRECTORY - || LOWORD(wParam) == IDC_LIMIT - || LOWORD(wParam) == IDC_LOGTIMESTAMP) - && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return 0; - - switch (LOWORD(wParam)) { - /* - * open the base directory for MUC logs, using a standard file selector - * dialog. Simply allows the user to view what log files are there - * and possibly delete archived logs. - */ - case IDC_MUC_OPENLOGBASEDIR: { - OPENFILENAME ofn = {0}; - SESSION_INFO si = {0}; - TCHAR tszReturnName[MAX_PATH]; - TCHAR tszInitialDir[_MAX_DRIVE + _MAX_PATH + 10]; - TCHAR tszTemp[MAX_PATH + 20], *p = 0, *p1 = 0; - - mir_sntprintf(tszTemp, MAX_PATH + 20, _T("%s"), g_Settings.pszLogDir); - - p = tszTemp; - while(*p && (*p == '\\' || *p == '.')) - p++; - - if (*p) { - if ((p1 = _tcschr(p, '\\'))) - *p1 = 0; - } + else { + int i = 0; + while (_o2chatcontrols[i]) + Utils::enableDlgControl(hwndDlg, _o2chatcontrols[i++], FALSE); + } + if (hPathTip) + SetTimer(hwndDlg, 0, 3000, NULL); + break; - mir_sntprintf(tszInitialDir, MAX_PATH, _T("%s%s"), M->getChatLogPath(), p); - if (PathFileExists(tszInitialDir)) - ofn.lpstrInitialDir = tszInitialDir; - else { - mir_sntprintf(tszInitialDir, MAX_PATH, _T("%s"), M->getChatLogPath()); - ofn.lpstrInitialDir = tszInitialDir; - } + case WM_COMMAND: + if ((LOWORD(wParam) == IDC_INSTAMP + || LOWORD(wParam) == IDC_OUTSTAMP + || LOWORD(wParam) == IDC_TIMESTAMP + || LOWORD(wParam) == IDC_LOGLIMIT + || LOWORD(wParam) == IDC_NICKROW2 + || LOWORD(wParam) == IDC_LOGDIRECTORY + || LOWORD(wParam) == IDC_LIMIT + || LOWORD(wParam) == IDC_LOGTIMESTAMP) + && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return 0; + + switch (LOWORD(wParam)) { + /* + * open the base directory for MUC logs, using a standard file selector + * dialog. Simply allows the user to view what log files are there + * and possibly delete archived logs. + */ + case IDC_MUC_OPENLOGBASEDIR: { + OPENFILENAME ofn = {0}; + SESSION_INFO si = {0}; + TCHAR tszReturnName[MAX_PATH]; + TCHAR tszInitialDir[_MAX_DRIVE + _MAX_PATH + 10]; + TCHAR tszTemp[MAX_PATH + 20], *p = 0, *p1 = 0; + + mir_sntprintf(tszTemp, MAX_PATH + 20, _T("%s"), g_Settings.pszLogDir); + + p = tszTemp; + while(*p && (*p == '\\' || *p == '.')) + p++; + + if (*p) { + if ((p1 = _tcschr(p, '\\'))) + *p1 = 0; + } - tszReturnName[0] = 0; - mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("%s%c*.*%c%c"), TranslateT("All Files"), 0, 0, 0); - - ofn.lpstrFilter = tszTemp; - ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; - ofn.hwndOwner = 0; - ofn.lpstrFile = tszReturnName; - ofn.nMaxFile = MAX_PATH; - ofn.nMaxFileTitle = MAX_PATH; - ofn.Flags = OFN_HIDEREADONLY | OFN_DONTADDTORECENT; - ofn.lpstrDefExt = _T("log"); - GetOpenFileName(&ofn); - break; - } + mir_sntprintf(tszInitialDir, MAX_PATH, _T("%s%s"), M->getChatLogPath(), p); + if (PathFileExists(tszInitialDir)) + ofn.lpstrInitialDir = tszInitialDir; + else { + mir_sntprintf(tszInitialDir, MAX_PATH, _T("%s"), M->getChatLogPath()); + ofn.lpstrInitialDir = tszInitialDir; + } - case IDC_FONTCHOOSE: { - TCHAR tszDirectory[MAX_PATH]; - LPITEMIDLIST idList; - LPMALLOC psMalloc; - BROWSEINFO bi = {0}; - - if (SUCCEEDED(CoGetMalloc(1, &psMalloc))) { - TCHAR tszTemp[MAX_PATH]; - bi.hwndOwner = hwndDlg; - bi.pszDisplayName = tszDirectory; - bi.lpszTitle = TranslateT("Select Folder"); - bi.ulFlags = BIF_NEWDIALOGSTYLE | BIF_EDITBOX | BIF_RETURNONLYFSDIRS; - bi.lpfn = BrowseCallbackProc; - bi.lParam = (LPARAM)tszDirectory; - - - idList = SHBrowseForFolder(&bi); - if (idList) { - const TCHAR *szUserDir = M->getUserDir(); - SHGetPathFromIDList(idList, tszDirectory); - lstrcat(tszDirectory, _T("\\")); - M->pathToRelative(tszDirectory, tszTemp, const_cast(szUserDir)); - SetWindowText(GetDlgItem(hwndDlg, IDC_LOGDIRECTORY), lstrlen(tszTemp) > 1 ? tszTemp : DEFLOGFILENAME); - } - psMalloc->Free(idList); - psMalloc->Release(); - } - break; + tszReturnName[0] = 0; + mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("%s%c*.*%c%c"), TranslateT("All Files"), 0, 0, 0); + + ofn.lpstrFilter = tszTemp; + ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; + ofn.hwndOwner = 0; + ofn.lpstrFile = tszReturnName; + ofn.nMaxFile = MAX_PATH; + ofn.nMaxFileTitle = MAX_PATH; + ofn.Flags = OFN_HIDEREADONLY | OFN_DONTADDTORECENT; + ofn.lpstrDefExt = _T("log"); + GetOpenFileName(&ofn); + break; + } + + case IDC_FONTCHOOSE: { + TCHAR tszDirectory[MAX_PATH]; + LPITEMIDLIST idList; + LPMALLOC psMalloc; + BROWSEINFO bi = {0}; + + if (SUCCEEDED(CoGetMalloc(1, &psMalloc))) { + TCHAR tszTemp[MAX_PATH]; + bi.hwndOwner = hwndDlg; + bi.pszDisplayName = tszDirectory; + bi.lpszTitle = TranslateT("Select Folder"); + bi.ulFlags = BIF_NEWDIALOGSTYLE | BIF_EDITBOX | BIF_RETURNONLYFSDIRS; + bi.lpfn = BrowseCallbackProc; + bi.lParam = (LPARAM)tszDirectory; + + + idList = SHBrowseForFolder(&bi); + if (idList) { + const TCHAR *szUserDir = M->getUserDir(); + SHGetPathFromIDList(idList, tszDirectory); + lstrcat(tszDirectory, _T("\\")); + M->pathToRelative(tszDirectory, tszTemp, const_cast(szUserDir)); + SetWindowText(GetDlgItem(hwndDlg, IDC_LOGDIRECTORY), lstrlen(tszTemp) > 1 ? tszTemp : DEFLOGFILENAME); } - - case IDC_LOGGING: - if (PluginConfig.m_chat_enabled) { - Utils::enableDlgControl(hwndDlg, IDC_LOGDIRECTORY, IsDlgButtonChecked(hwndDlg, IDC_LOGGING) == BST_CHECKED ? TRUE : FALSE); - Utils::enableDlgControl(hwndDlg, IDC_FONTCHOOSE, IsDlgButtonChecked(hwndDlg, IDC_LOGGING) == BST_CHECKED ? TRUE : FALSE); - Utils::enableDlgControl(hwndDlg, IDC_LIMIT, IsDlgButtonChecked(hwndDlg, IDC_LOGGING) == BST_CHECKED ? TRUE : FALSE); - } - break; + psMalloc->Free(idList); + psMalloc->Release(); } - - if (lParam != 0) - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; + } - case WM_NOTIFY: - if (((LPNMHDR)lParam)->idFrom == 0 && ((LPNMHDR)lParam)->code == PSN_APPLY) { - int iLen; - TCHAR *p2 = NULL; - char *pszText = NULL; - TCHAR *ptszPath = NULL; - - if (PluginConfig.m_chat_enabled) { - - iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_LOGDIRECTORY)); - if (iLen > 0) { - TCHAR *pszText1 = (TCHAR *)malloc(iLen*sizeof(TCHAR) + 2); - GetDlgItemText(hwndDlg, IDC_LOGDIRECTORY, pszText1, iLen + 1); - M->WriteTString(NULL, "Chat", "LogDirectory", pszText1); - free(pszText1); - g_Settings.LoggingEnabled = IsDlgButtonChecked(hwndDlg, IDC_LOGGING) == BST_CHECKED ? TRUE : FALSE; - M->WriteByte("Chat", "LoggingEnabled", (BYTE)g_Settings.LoggingEnabled); - } else { - DBDeleteContactSetting(NULL, "Chat", "LogDirectory"); - M->WriteByte("Chat", "LoggingEnabled", 0); - } - SM_InvalidateLogDirectories(); - - iLen = SendDlgItemMessage(hwndDlg, IDC_CHAT_SPIN4, UDM_GETPOS, 0, 0); - DBWriteContactSettingWord(NULL, "Chat", "LoggingLimit", (WORD)iLen); - - iLen = SendDlgItemMessage(hwndDlg, IDC_CHAT_SPIN3, UDM_GETPOS, 0, 0); - if (iLen > 0) - M->WriteByte("Chat", "NicklistRowDist", (BYTE)iLen); - else - DBDeleteContactSetting(NULL, "Chat", "NicklistRowDist"); - - iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_LOGTIMESTAMP)); - if (iLen > 0) { - pszText = (char *)realloc(pszText, iLen + 1); - GetDlgItemTextA(hwndDlg, IDC_LOGTIMESTAMP, pszText, iLen + 1); - DBWriteContactSettingString(NULL, "Chat", "LogTimestamp", pszText); - } else DBDeleteContactSetting(NULL, "Chat", "LogTimestamp"); + case IDC_LOGGING: + if (PluginConfig.m_chat_enabled) { + Utils::enableDlgControl(hwndDlg, IDC_LOGDIRECTORY, IsDlgButtonChecked(hwndDlg, IDC_LOGGING) == BST_CHECKED ? TRUE : FALSE); + Utils::enableDlgControl(hwndDlg, IDC_FONTCHOOSE, IsDlgButtonChecked(hwndDlg, IDC_LOGGING) == BST_CHECKED ? TRUE : FALSE); + Utils::enableDlgControl(hwndDlg, IDC_LIMIT, IsDlgButtonChecked(hwndDlg, IDC_LOGGING) == BST_CHECKED ? TRUE : FALSE); + } + break; + } - iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_TIMESTAMP)); - if (iLen > 0) { - pszText = (char *)realloc(pszText, iLen + 1); - GetDlgItemTextA(hwndDlg, IDC_TIMESTAMP, pszText, iLen + 1); - DBWriteContactSettingString(NULL, "Chat", "HeaderTime", pszText); - } else DBDeleteContactSetting(NULL, "Chat", "HeaderTime"); + if (lParam != 0) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; - iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_INSTAMP)); - if (iLen > 0) { - pszText = (char *)realloc(pszText, iLen + 1); - GetDlgItemTextA(hwndDlg, IDC_INSTAMP, pszText, iLen + 1); - DBWriteContactSettingString(NULL, "Chat", "HeaderIncoming", pszText); - } else DBDeleteContactSetting(NULL, "Chat", "HeaderIncoming"); + case WM_NOTIFY: + if (((LPNMHDR)lParam)->idFrom == 0 && ((LPNMHDR)lParam)->code == PSN_APPLY) { + int iLen; + TCHAR *p2 = NULL; + char *pszText = NULL; + TCHAR *ptszPath = NULL; - iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_OUTSTAMP)); - if (iLen > 0) { - pszText = (char *)realloc(pszText, iLen + 1); - GetDlgItemTextA(hwndDlg, IDC_OUTSTAMP, pszText, iLen + 1); - DBWriteContactSettingString(NULL, "Chat", "HeaderOutgoing", pszText); - } else DBDeleteContactSetting(NULL, "Chat", "HeaderOutgoing"); + if (PluginConfig.m_chat_enabled) { - iLen = SendDlgItemMessage(hwndDlg, IDC_CHAT_SPIN2, UDM_GETPOS, 0, 0); - DBWriteContactSettingWord(NULL, "Chat", "LogLimit", (WORD)iLen); + iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_LOGDIRECTORY)); + if (iLen > 0) { + TCHAR *pszText1 = (TCHAR *)malloc(iLen*sizeof(TCHAR) + 2); + GetDlgItemText(hwndDlg, IDC_LOGDIRECTORY, pszText1, iLen + 1); + M->WriteTString(NULL, "Chat", "LogDirectory", pszText1); + free(pszText1); + g_Settings.LoggingEnabled = IsDlgButtonChecked(hwndDlg, IDC_LOGGING) == BST_CHECKED ? TRUE : FALSE; + M->WriteByte("Chat", "LoggingEnabled", (BYTE)g_Settings.LoggingEnabled); + } else { + DBDeleteContactSetting(NULL, "Chat", "LogDirectory"); + M->WriteByte("Chat", "LoggingEnabled", 0); } + SM_InvalidateLogDirectories(); + + iLen = SendDlgItemMessage(hwndDlg, IDC_CHAT_SPIN4, UDM_GETPOS, 0, 0); + DBWriteContactSettingWord(NULL, "Chat", "LoggingLimit", (WORD)iLen); + + iLen = SendDlgItemMessage(hwndDlg, IDC_CHAT_SPIN3, UDM_GETPOS, 0, 0); + if (iLen > 0) + M->WriteByte("Chat", "NicklistRowDist", (BYTE)iLen); + else + DBDeleteContactSetting(NULL, "Chat", "NicklistRowDist"); + + iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_LOGTIMESTAMP)); + if (iLen > 0) { + pszText = (char *)realloc(pszText, iLen + 1); + GetDlgItemTextA(hwndDlg, IDC_LOGTIMESTAMP, pszText, iLen + 1); + DBWriteContactSettingString(NULL, "Chat", "LogTimestamp", pszText); + } else DBDeleteContactSetting(NULL, "Chat", "LogTimestamp"); + + iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_TIMESTAMP)); + if (iLen > 0) { + pszText = (char *)realloc(pszText, iLen + 1); + GetDlgItemTextA(hwndDlg, IDC_TIMESTAMP, pszText, iLen + 1); + DBWriteContactSettingString(NULL, "Chat", "HeaderTime", pszText); + } else DBDeleteContactSetting(NULL, "Chat", "HeaderTime"); + + iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_INSTAMP)); + if (iLen > 0) { + pszText = (char *)realloc(pszText, iLen + 1); + GetDlgItemTextA(hwndDlg, IDC_INSTAMP, pszText, iLen + 1); + DBWriteContactSettingString(NULL, "Chat", "HeaderIncoming", pszText); + } else DBDeleteContactSetting(NULL, "Chat", "HeaderIncoming"); + + iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_OUTSTAMP)); + if (iLen > 0) { + pszText = (char *)realloc(pszText, iLen + 1); + GetDlgItemTextA(hwndDlg, IDC_OUTSTAMP, pszText, iLen + 1); + DBWriteContactSettingString(NULL, "Chat", "HeaderOutgoing", pszText); + } else DBDeleteContactSetting(NULL, "Chat", "HeaderOutgoing"); + + iLen = SendDlgItemMessage(hwndDlg, IDC_CHAT_SPIN2, UDM_GETPOS, 0, 0); + DBWriteContactSettingWord(NULL, "Chat", "LogLimit", (WORD)iLen); + } + if (pszText != NULL) + free(pszText); + if (hListBkgBrush) + DeleteObject(hListBkgBrush); + hListBkgBrush = CreateSolidBrush(M->GetDword("Chat", "ColorNicklistBG", SRMSGDEFSET_BKGCOLOUR)); - if (pszText != NULL) - free(pszText); - if (hListBkgBrush) - DeleteObject(hListBkgBrush); - hListBkgBrush = CreateSolidBrush(M->GetDword("Chat", "ColorNicklistBG", SRMSGDEFSET_BKGCOLOUR)); - - - if (PluginConfig.m_chat_enabled) { - LOGFONT lf; - HFONT hFont; - int iText; - - LoadLogFonts(); - FreeMsgLogBitmaps(); - LoadMsgLogBitmaps(); + if (PluginConfig.m_chat_enabled) { + LoadLogFonts(); + FreeMsgLogBitmaps(); + LoadMsgLogBitmaps(); + + LOGFONT lf; + LoadMsgDlgFont(FONTSECTION_CHAT, 0, &lf, NULL, CHAT_FONTMODULE); + HFONT hFont = CreateFontIndirect(&lf); + int iText = GetTextPixelSize(MakeTimeStamp(g_Settings.pszTimeStamp, time(NULL)), hFont, TRUE); + DeleteObject(hFont); + g_Settings.LogTextIndent = iText; + g_Settings.LogTextIndent = g_Settings.LogTextIndent * 12 / 10; + g_Settings.LogIndentEnabled = (M->GetByte("Chat", "LogIndentEnabled", 1) != 0) ? TRUE : FALSE; + + LoadGlobalSettings(); + MM_FontsChanged(); + MM_FixColors(); + SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE); + } - LoadMsgDlgFont(FONTSECTION_CHAT, 0, &lf, NULL, CHAT_FONTMODULE); - hFont = CreateFontIndirect(&lf); - iText = GetTextPixelSize(MakeTimeStamp(g_Settings.pszTimeStamp, time(NULL)), hFont, TRUE); - DeleteObject(hFont); - g_Settings.LogTextIndent = iText; - g_Settings.LogTextIndent = g_Settings.LogTextIndent * 12 / 10; - g_Settings.LogIndentEnabled = (M->GetByte("Chat", "LogIndentEnabled", 1) != 0) ? TRUE : FALSE; + PluginConfig.reloadSettings(); + CacheMsgLogIcons(); + CacheLogFonts(); + return TRUE; + } + break; - LoadGlobalSettings(); - MM_FontsChanged(); - MM_FixColors(); - SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE); - } + case WM_TIMER: + if (IsWindow(hPathTip)) + KillTimer(hPathTip, 4); // It will prevent tooltip autoclosing + break; - PluginConfig.reloadSettings(); - CacheMsgLogIcons(); - CacheLogFonts(); - return TRUE; - } - break; - case WM_TIMER: - if (IsWindow(hPathTip)) - KillTimer(hPathTip, 4); // It will prevent tooltip autoclosing - break; - case WM_DESTROY: - if (hPathTip) - { - KillTimer(hwndDlg, 0); - DestroyWindow(hPathTip); - hPathTip = 0; - } - break; + case WM_DESTROY: + if (hPathTip) { + KillTimer(hwndDlg, 0); + DestroyWindow(hPathTip); + hPathTip = 0; + } + break; } return FALSE; } @@ -1196,82 +1180,75 @@ static UINT _eventorder[] = { GC_EVENT_ACTION, INT_PTR CALLBACK DlgProcOptions3(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { - case WM_INITDIALOG: { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + + if (PluginConfig.m_chat_enabled) { + DWORD dwFilterFlags = M->GetDword("Chat", "FilterFlags", GC_EVENT_ALL); + DWORD dwTrayFlags = M->GetDword("Chat", "TrayIconFlags", GC_EVENT_ALL); + DWORD dwPopupFlags = M->GetDword("Chat", "PopupFlags", GC_EVENT_ALL); + DWORD dwLogFlags = M->GetDword("Chat", "DiskLogFlags", GC_EVENT_ALL); + + for (int i = 0; _eventorder[i]; i++) { + if (_eventorder[i] != GC_EVENT_HIGHLIGHT) { + CheckDlgButton(hwndDlg, IDC_1 + i, dwFilterFlags & _eventorder[i] ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_L1 + i, dwLogFlags & _eventorder[i] ? BST_CHECKED : BST_UNCHECKED); + } + CheckDlgButton(hwndDlg, IDC_P1 + i, dwPopupFlags & _eventorder[i] ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_T1 + i, dwTrayFlags & _eventorder[i] ? BST_CHECKED : BST_UNCHECKED); + } + SendDlgItemMessage(hwndDlg, IDC_LOGICONTYPE, CB_ADDSTRING, -1, (LPARAM)TranslateT("No markers")); + SendDlgItemMessage(hwndDlg, IDC_LOGICONTYPE, CB_ADDSTRING, -1, (LPARAM)TranslateT("Show as icons")); + SendDlgItemMessage(hwndDlg, IDC_LOGICONTYPE, CB_ADDSTRING, -1, (LPARAM)TranslateT("Show as text symbols")); - TranslateDialogDefault(hwndDlg); + SendDlgItemMessage(hwndDlg, IDC_LOGICONTYPE, CB_SETCURSEL, (g_Settings.LogSymbols ? 2 : (g_Settings.dwIconFlags ? 1 : 0)), 0); - if (PluginConfig.m_chat_enabled) { - DWORD dwFilterFlags = M->GetDword("Chat", "FilterFlags", GC_EVENT_ALL); - DWORD dwTrayFlags = M->GetDword("Chat", "TrayIconFlags", GC_EVENT_ALL); - DWORD dwPopupFlags = M->GetDword("Chat", "PopupFlags", GC_EVENT_ALL); - DWORD dwLogFlags = M->GetDword("Chat", "DiskLogFlags", GC_EVENT_ALL); + CheckDlgButton(hwndDlg, IDC_NOPOPUPSFORCLOSEDWINDOWS, M->GetByte("Chat", "SkipWhenNoWindow", 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_TRAYONLYFORINACTIVE, M->GetByte("Chat", "TrayIconInactiveOnly", 0) ? BST_CHECKED : BST_UNCHECKED); + } + break; + + case WM_COMMAND: + if (lParam != 0) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + + case WM_NOTIFY: + switch (((LPNMHDR)lParam)->idFrom) { + case 0: + switch (((LPNMHDR)lParam)->code) { + case PSN_APPLY: + DWORD dwFilterFlags = 0, dwTrayFlags = 0, + dwPopupFlags = 0, dwLogFlags = 0; for (int i = 0; _eventorder[i]; i++) { if (_eventorder[i] != GC_EVENT_HIGHLIGHT) { - CheckDlgButton(hwndDlg, IDC_1 + i, dwFilterFlags & _eventorder[i] ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_L1 + i, dwLogFlags & _eventorder[i] ? BST_CHECKED : BST_UNCHECKED); + dwFilterFlags |= (IsDlgButtonChecked(hwndDlg, IDC_1 + i) ? _eventorder[i] : 0); + dwLogFlags |= (IsDlgButtonChecked(hwndDlg, IDC_L1 + i) ? _eventorder[i] : 0); } - CheckDlgButton(hwndDlg, IDC_P1 + i, dwPopupFlags & _eventorder[i] ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_T1 + i, dwTrayFlags & _eventorder[i] ? BST_CHECKED : BST_UNCHECKED); + dwPopupFlags |= (IsDlgButtonChecked(hwndDlg, IDC_P1 + i) ? _eventorder[i] : 0); + dwTrayFlags |= (IsDlgButtonChecked(hwndDlg, IDC_T1 + i) ? _eventorder[i] : 0); } - SendDlgItemMessage(hwndDlg, IDC_LOGICONTYPE, CB_ADDSTRING, -1, (LPARAM)TranslateT("No markers")); - SendDlgItemMessage(hwndDlg, IDC_LOGICONTYPE, CB_ADDSTRING, -1, (LPARAM)TranslateT("Show as icons")); - SendDlgItemMessage(hwndDlg, IDC_LOGICONTYPE, CB_ADDSTRING, -1, (LPARAM)TranslateT("Show as text symbols")); - - SendDlgItemMessage(hwndDlg, IDC_LOGICONTYPE, CB_SETCURSEL, (g_Settings.LogSymbols ? 2 : (g_Settings.dwIconFlags ? 1 : 0)), 0); - - CheckDlgButton(hwndDlg, IDC_NOPOPUPSFORCLOSEDWINDOWS, M->GetByte("Chat", "SkipWhenNoWindow", 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_TRAYONLYFORINACTIVE, M->GetByte("Chat", "TrayIconInactiveOnly", 0) ? BST_CHECKED : BST_UNCHECKED); + M->WriteDword("Chat", "FilterFlags", dwFilterFlags); + M->WriteDword("Chat", "PopupFlags", dwPopupFlags); + M->WriteDword("Chat", "TrayIconFlags", dwTrayFlags); + M->WriteDword("Chat", "DiskLogFlags", dwLogFlags); + + LRESULT lr = SendDlgItemMessage(hwndDlg, IDC_LOGICONTYPE, CB_GETCURSEL, 0, 0); + + M->WriteDword("Chat", "IconFlags", lr == 1 ? 1 : 0); + M->WriteByte("Chat", "LogSymbols", lr == 2 ? 1 : 0); + + M->WriteByte("Chat", "SkipWhenNoWindow", IsDlgButtonChecked(hwndDlg, IDC_NOPOPUPSFORCLOSEDWINDOWS) ? 1 : 0); + M->WriteByte("Chat", "TrayIconInactiveOnly", IsDlgButtonChecked(hwndDlg, IDC_TRAYONLYFORINACTIVE) ? 1 : 0); + LoadGlobalSettings(); + MM_FontsChanged(); + SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE); + SM_ReconfigureFilters(); + return TRUE; } - break; } - case WM_COMMAND: - if (lParam != 0) - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - - case WM_NOTIFY: - switch (((LPNMHDR)lParam)->idFrom) { - case 0: - switch (((LPNMHDR)lParam)->code) { - case PSN_APPLY: { - DWORD dwFilterFlags = 0, dwTrayFlags = 0, - dwPopupFlags = 0, dwLogFlags = 0; - - for (int i = 0; _eventorder[i]; i++) { - if (_eventorder[i] != GC_EVENT_HIGHLIGHT) { - dwFilterFlags |= (IsDlgButtonChecked(hwndDlg, IDC_1 + i) ? _eventorder[i] : 0); - dwLogFlags |= (IsDlgButtonChecked(hwndDlg, IDC_L1 + i) ? _eventorder[i] : 0); - } - dwPopupFlags |= (IsDlgButtonChecked(hwndDlg, IDC_P1 + i) ? _eventorder[i] : 0); - dwTrayFlags |= (IsDlgButtonChecked(hwndDlg, IDC_T1 + i) ? _eventorder[i] : 0); - } - M->WriteDword("Chat", "FilterFlags", dwFilterFlags); - M->WriteDword("Chat", "PopupFlags", dwPopupFlags); - M->WriteDword("Chat", "TrayIconFlags", dwTrayFlags); - M->WriteDword("Chat", "DiskLogFlags", dwLogFlags); - - LRESULT lr = SendDlgItemMessage(hwndDlg, IDC_LOGICONTYPE, CB_GETCURSEL, 0, 0); - - M->WriteDword("Chat", "IconFlags", lr == 1 ? 1 : 0); - M->WriteByte("Chat", "LogSymbols", lr == 2 ? 1 : 0); - - M->WriteByte("Chat", "SkipWhenNoWindow", IsDlgButtonChecked(hwndDlg, IDC_NOPOPUPSFORCLOSEDWINDOWS) ? 1 : 0); - M->WriteByte("Chat", "TrayIconInactiveOnly", IsDlgButtonChecked(hwndDlg, IDC_TRAYONLYFORINACTIVE) ? 1 : 0); - LoadGlobalSettings(); - MM_FontsChanged(); - SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE); - SM_ReconfigureFilters(); - break; - } - return TRUE; - } - } - break; - - case WM_DESTROY: - break; - + break; } return FALSE; } @@ -1325,7 +1302,6 @@ void LoadGlobalSettings(void) g_Settings.ShowContactStatus = M->GetByte("Chat", "ShowContactStatus", 1); g_Settings.ContactStatusFirst = M->GetByte("Chat", "ContactStatusFirst", 0); - if (hListBkgBrush) DeleteObject(hListBkgBrush); hListBkgBrush = CreateSolidBrush(M->GetDword("Chat", "ColorNicklistBG", SRMSGDEFSET_BKGCOLOUR)); @@ -1340,14 +1316,13 @@ void LoadGlobalSettings(void) if (!M->GetTString(NULL, "Chat", "LogDirectory", &dbv)) { lstrcpyn(g_Settings.pszLogDir, dbv.ptszVal, MAX_PATH); db_free(&dbv); - } else - lstrcpyn(g_Settings.pszLogDir, DEFLOGFILENAME, MAX_PATH); + } + else lstrcpyn(g_Settings.pszLogDir, DEFLOGFILENAME, MAX_PATH); g_Settings.pszLogDir[MAX_PATH - 1] = 0; g_Settings.LogIndentEnabled = (M->GetByte("Chat", "LogIndentEnabled", 1) != 0) ? TRUE : FALSE; - // nicklist if (g_Settings.UserListFont) { @@ -1397,9 +1372,9 @@ static void FreeGlobalSettings(void) int OptionsInit(void) { - LOGFONT lf; - LoadLogFonts(); + + LOGFONT lf; LoadMsgDlgFont(FONTSECTION_CHAT, 17, &lf, NULL, CHAT_FONTMODULE); lstrcpy(lf.lfFaceName, _T("MS Shell Dlg")); lf.lfUnderline = lf.lfItalic = lf.lfStrikeOut = 0; diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index 20e6058a91..17c8f5580a 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -469,86 +469,87 @@ static int RoomWndResize(HWND hwndDlg, LPARAM lParam, UTILRESIZECONTROL *urc) //ShowWindow(GetDlgItem(hwndDlg, IDC_CHAT_TOGGLESIDEBAR), dat->pContainer->dwFlags & CNT_SIDEBAR ? SW_SHOW : SW_HIDE); switch (urc->wId) { - case IDC_PANELSPLITTER: - urc->rcItem.bottom = panelHeight; - urc->rcItem.top = panelHeight - 2; - return RD_ANCHORX_WIDTH | RD_ANCHORY_TOP; - case IDC_CHAT_LOG: - urc->rcItem.top = 0; - urc->rcItem.left = 0; - urc->rcItem.right = bNick ? urc->dlgNewSize.cx - si->iSplitterX : urc->dlgNewSize.cx; - urc->rcItem.bottom = (bToolbar&&!bBottomToolbar) ? (urc->dlgNewSize.cy - si->iSplitterY - (PluginConfig.g_DPIscaleY > 1.0 ? DPISCALEY_S(24) : DPISCALEY_S(23))) : (urc->dlgNewSize.cy - si->iSplitterY - DPISCALEY_S(2)); - if (fInfoPanel) - urc->rcItem.top += panelHeight; - if (CSkin::m_skinEnabled) { - CSkinItem *item = &SkinItems[ID_EXTBKHISTORY]; - if (!item->IGNORED) { - urc->rcItem.left += item->MARGIN_LEFT; - urc->rcItem.right -= item->MARGIN_RIGHT; - urc->rcItem.top += item->MARGIN_TOP; - urc->rcItem.bottom -= item->MARGIN_BOTTOM; - } - } - return RD_ANCHORX_CUSTOM | RD_ANCHORY_CUSTOM; - - case IDC_LIST: - urc->rcItem.top = 0; - urc->rcItem.right = urc->dlgNewSize.cx ; - urc->rcItem.left = urc->dlgNewSize.cx - si->iSplitterX + 2; - urc->rcItem.bottom = (bToolbar&&!bBottomToolbar) ? (urc->dlgNewSize.cy - si->iSplitterY - DPISCALEY_S(23)) : (urc->dlgNewSize.cy - si->iSplitterY - DPISCALEY_S(2)); - if (fInfoPanel) - urc->rcItem.top += panelHeight; - if (CSkin::m_skinEnabled) { - CSkinItem *item = &SkinItems[ID_EXTBKUSERLIST]; - if (!item->IGNORED) { - urc->rcItem.left += item->MARGIN_LEFT; - urc->rcItem.right -= item->MARGIN_RIGHT; - urc->rcItem.top += item->MARGIN_TOP; - urc->rcItem.bottom -= item->MARGIN_BOTTOM; - } - } - return RD_ANCHORX_CUSTOM | RD_ANCHORY_CUSTOM; - - case IDC_SPLITTERX: - urc->rcItem.right = urc->dlgNewSize.cx - si->iSplitterX + 2; - urc->rcItem.left = urc->dlgNewSize.cx - si->iSplitterX; - urc->rcItem.bottom = (bToolbar&&!bBottomToolbar) ? (urc->dlgNewSize.cy - si->iSplitterY - DPISCALEY_S(23)) : (urc->dlgNewSize.cy - si->iSplitterY - DPISCALEY_S(2)); - urc->rcItem.top = 0; - if (fInfoPanel) - urc->rcItem.top += panelHeight; - return RD_ANCHORX_CUSTOM | RD_ANCHORY_CUSTOM; - - case IDC_SPLITTERY: - urc->rcItem.right = urc->dlgNewSize.cx; - urc->rcItem.top = (bToolbar&&!bBottomToolbar) ? urc->dlgNewSize.cy - si->iSplitterY : urc->dlgNewSize.cy - si->iSplitterY; - urc->rcItem.bottom = (bToolbar&&!bBottomToolbar) ? (urc->dlgNewSize.cy - si->iSplitterY + DPISCALEY_S(2)) : (urc->dlgNewSize.cy - si->iSplitterY + DPISCALEY_S(2)); - urc->rcItem.left = 0; - urc->rcItem.bottom++; - urc->rcItem.top++; - return RD_ANCHORX_CUSTOM | RD_ANCHORY_CUSTOM; - - case IDC_CHAT_MESSAGE: - urc->rcItem.right = urc->dlgNewSize.cx ; - urc->rcItem.top = urc->dlgNewSize.cy - si->iSplitterY + 3; - urc->rcItem.bottom = urc->dlgNewSize.cy; // - 1 ; - msgBottom = urc->rcItem.bottom; - - if (dat->fIsAutosizingInput) - urc->rcItem.top -= DPISCALEY_S(1); - - msgTop = urc->rcItem.top; - if (bBottomToolbar&&bToolbar) - urc->rcItem.bottom -= DPISCALEY_S(22); - if (CSkin::m_skinEnabled) { - CSkinItem *item = &SkinItems[ID_EXTBKINPUTAREA]; - if (!item->IGNORED) { - urc->rcItem.left += item->MARGIN_LEFT; - urc->rcItem.right -= item->MARGIN_RIGHT; - urc->rcItem.top += item->MARGIN_TOP; - urc->rcItem.bottom -= item->MARGIN_BOTTOM; - } - } - return RD_ANCHORX_CUSTOM | RD_ANCHORY_CUSTOM; + case IDC_PANELSPLITTER: + urc->rcItem.bottom = panelHeight; + urc->rcItem.top = panelHeight - 2; + return RD_ANCHORX_WIDTH | RD_ANCHORY_TOP; + + case IDC_CHAT_LOG: + urc->rcItem.top = 0; + urc->rcItem.left = 0; + urc->rcItem.right = bNick ? urc->dlgNewSize.cx - si->iSplitterX : urc->dlgNewSize.cx; + urc->rcItem.bottom = (bToolbar&&!bBottomToolbar) ? (urc->dlgNewSize.cy - si->iSplitterY - (PluginConfig.g_DPIscaleY > 1.0 ? DPISCALEY_S(24) : DPISCALEY_S(23))) : (urc->dlgNewSize.cy - si->iSplitterY - DPISCALEY_S(2)); + if (fInfoPanel) + urc->rcItem.top += panelHeight; + if (CSkin::m_skinEnabled) { + CSkinItem *item = &SkinItems[ID_EXTBKHISTORY]; + if (!item->IGNORED) { + urc->rcItem.left += item->MARGIN_LEFT; + urc->rcItem.right -= item->MARGIN_RIGHT; + urc->rcItem.top += item->MARGIN_TOP; + urc->rcItem.bottom -= item->MARGIN_BOTTOM; + } + } + return RD_ANCHORX_CUSTOM | RD_ANCHORY_CUSTOM; + + case IDC_LIST: + urc->rcItem.top = 0; + urc->rcItem.right = urc->dlgNewSize.cx ; + urc->rcItem.left = urc->dlgNewSize.cx - si->iSplitterX + 2; + urc->rcItem.bottom = (bToolbar&&!bBottomToolbar) ? (urc->dlgNewSize.cy - si->iSplitterY - DPISCALEY_S(23)) : (urc->dlgNewSize.cy - si->iSplitterY - DPISCALEY_S(2)); + if (fInfoPanel) + urc->rcItem.top += panelHeight; + if (CSkin::m_skinEnabled) { + CSkinItem *item = &SkinItems[ID_EXTBKUSERLIST]; + if (!item->IGNORED) { + urc->rcItem.left += item->MARGIN_LEFT; + urc->rcItem.right -= item->MARGIN_RIGHT; + urc->rcItem.top += item->MARGIN_TOP; + urc->rcItem.bottom -= item->MARGIN_BOTTOM; + } + } + return RD_ANCHORX_CUSTOM | RD_ANCHORY_CUSTOM; + + case IDC_SPLITTERX: + urc->rcItem.right = urc->dlgNewSize.cx - si->iSplitterX + 2; + urc->rcItem.left = urc->dlgNewSize.cx - si->iSplitterX; + urc->rcItem.bottom = (bToolbar&&!bBottomToolbar) ? (urc->dlgNewSize.cy - si->iSplitterY - DPISCALEY_S(23)) : (urc->dlgNewSize.cy - si->iSplitterY - DPISCALEY_S(2)); + urc->rcItem.top = 0; + if (fInfoPanel) + urc->rcItem.top += panelHeight; + return RD_ANCHORX_CUSTOM | RD_ANCHORY_CUSTOM; + + case IDC_SPLITTERY: + urc->rcItem.right = urc->dlgNewSize.cx; + urc->rcItem.top = (bToolbar&&!bBottomToolbar) ? urc->dlgNewSize.cy - si->iSplitterY : urc->dlgNewSize.cy - si->iSplitterY; + urc->rcItem.bottom = (bToolbar&&!bBottomToolbar) ? (urc->dlgNewSize.cy - si->iSplitterY + DPISCALEY_S(2)) : (urc->dlgNewSize.cy - si->iSplitterY + DPISCALEY_S(2)); + urc->rcItem.left = 0; + urc->rcItem.bottom++; + urc->rcItem.top++; + return RD_ANCHORX_CUSTOM | RD_ANCHORY_CUSTOM; + + case IDC_CHAT_MESSAGE: + urc->rcItem.right = urc->dlgNewSize.cx ; + urc->rcItem.top = urc->dlgNewSize.cy - si->iSplitterY + 3; + urc->rcItem.bottom = urc->dlgNewSize.cy; // - 1 ; + msgBottom = urc->rcItem.bottom; + + if (dat->fIsAutosizingInput) + urc->rcItem.top -= DPISCALEY_S(1); + + msgTop = urc->rcItem.top; + if (bBottomToolbar&&bToolbar) + urc->rcItem.bottom -= DPISCALEY_S(22); + if (CSkin::m_skinEnabled) { + CSkinItem *item = &SkinItems[ID_EXTBKINPUTAREA]; + if (!item->IGNORED) { + urc->rcItem.left += item->MARGIN_LEFT; + urc->rcItem.right -= item->MARGIN_RIGHT; + urc->rcItem.top += item->MARGIN_TOP; + urc->rcItem.bottom -= item->MARGIN_BOTTOM; + } + } + return RD_ANCHORX_CUSTOM | RD_ANCHORY_CUSTOM; } return RD_ANCHORX_LEFT | RD_ANCHORY_TOP; } @@ -1180,8 +1181,8 @@ static INT_PTR CALLBACK FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP { SESSION_INFO * si = (SESSION_INFO *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (uMsg) { - case WM_INITDIALOG: { - + case WM_INITDIALOG: + { si = (SESSION_INFO *)lParam; DWORD dwMask = M->GetDword(si->hContact, "Chat", "FilterMask", 0); DWORD dwFlags = M->GetDword(si->hContact, "Chat", "FilterFlags", 0); @@ -1199,89 +1200,90 @@ static INT_PTR CALLBACK FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP CheckDlgButton(hwndDlg, IDC_P1 + i, dwPopupMask & _eventorder[i] ? (dwPopupFlags & _eventorder[i] ? BST_CHECKED : BST_UNCHECKED) : BST_INDETERMINATE); CheckDlgButton(hwndDlg, IDC_T1 + i, dwTrayMask & _eventorder[i] ? (dwTrayFlags & _eventorder[i] ? BST_CHECKED : BST_UNCHECKED) : BST_INDETERMINATE); } - return(FALSE); } - case WM_CTLCOLOREDIT: - case WM_CTLCOLORSTATIC: - SetTextColor((HDC)wParam, RGB(60, 60, 150)); - SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); - return (INT_PTR)GetSysColorBrush(COLOR_WINDOW); + return FALSE; - case WM_CLOSE: - if (wParam == 1 && lParam == 1) { - int iFlags = 0, i; - UINT result; - DWORD dwMask = 0, dwFlags = 0; - - for (i=0; _eventorder[i]; i++) { - result = IsDlgButtonChecked(hwndDlg, IDC_1 + i); - dwMask |= (result != BST_INDETERMINATE ? _eventorder[i] : 0); - iFlags |= (result == BST_CHECKED ? _eventorder[i] : 0); - } + case WM_CTLCOLOREDIT: + case WM_CTLCOLORSTATIC: + SetTextColor((HDC)wParam, RGB(60, 60, 150)); + SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); + return (INT_PTR)GetSysColorBrush(COLOR_WINDOW); - if (iFlags&GC_EVENT_ADDSTATUS) - iFlags |= GC_EVENT_REMOVESTATUS; + case WM_CLOSE: + if (wParam == 1 && lParam == 1) { + int iFlags = 0, i; + UINT result; + DWORD dwMask = 0, dwFlags = 0; - if (si) { - if (dwMask == 0) { - DBDeleteContactSetting(si->hContact, "Chat", "FilterFlags"); - DBDeleteContactSetting(si->hContact, "Chat", "FilterMask"); - } else { - M->WriteDword(si->hContact, "Chat", "FilterFlags", iFlags); - M->WriteDword(si->hContact, "Chat", "FilterMask", dwMask); - } - } + for (i=0; _eventorder[i]; i++) { + result = IsDlgButtonChecked(hwndDlg, IDC_1 + i); + dwMask |= (result != BST_INDETERMINATE ? _eventorder[i] : 0); + iFlags |= (result == BST_CHECKED ? _eventorder[i] : 0); + } - dwMask = iFlags = 0; + if (iFlags&GC_EVENT_ADDSTATUS) + iFlags |= GC_EVENT_REMOVESTATUS; - for (i=0; _eventorder[i]; i++) { - result = IsDlgButtonChecked(hwndDlg, IDC_P1 + i); - dwMask |= (result != BST_INDETERMINATE ? _eventorder[i] : 0); - iFlags |= (result == BST_CHECKED ? _eventorder[i] : 0); + if (si) { + if (dwMask == 0) { + DBDeleteContactSetting(si->hContact, "Chat", "FilterFlags"); + DBDeleteContactSetting(si->hContact, "Chat", "FilterMask"); + } else { + M->WriteDword(si->hContact, "Chat", "FilterFlags", iFlags); + M->WriteDword(si->hContact, "Chat", "FilterMask", dwMask); } + } - if (iFlags&GC_EVENT_ADDSTATUS) - iFlags |= GC_EVENT_REMOVESTATUS; + dwMask = iFlags = 0; - if (si) { - if (dwMask == 0) { - DBDeleteContactSetting(si->hContact, "Chat", "PopupFlags"); - DBDeleteContactSetting(si->hContact, "Chat", "PopupMask"); - } else { - M->WriteDword(si->hContact, "Chat", "PopupFlags", iFlags); - M->WriteDword(si->hContact, "Chat", "PopupMask", dwMask); - } - } + for (i=0; _eventorder[i]; i++) { + result = IsDlgButtonChecked(hwndDlg, IDC_P1 + i); + dwMask |= (result != BST_INDETERMINATE ? _eventorder[i] : 0); + iFlags |= (result == BST_CHECKED ? _eventorder[i] : 0); + } - dwMask = iFlags = 0; + if (iFlags&GC_EVENT_ADDSTATUS) + iFlags |= GC_EVENT_REMOVESTATUS; - for (i=0; _eventorder[i]; i++) { - result = IsDlgButtonChecked(hwndDlg, IDC_T1 + i); - dwMask |= (result != BST_INDETERMINATE ? _eventorder[i] : 0); - iFlags |= (result == BST_CHECKED ? _eventorder[i] : 0); + if (si) { + if (dwMask == 0) { + DBDeleteContactSetting(si->hContact, "Chat", "PopupFlags"); + DBDeleteContactSetting(si->hContact, "Chat", "PopupMask"); + } else { + M->WriteDword(si->hContact, "Chat", "PopupFlags", iFlags); + M->WriteDword(si->hContact, "Chat", "PopupMask", dwMask); } - if (iFlags&GC_EVENT_ADDSTATUS) - iFlags |= GC_EVENT_REMOVESTATUS; + } - if (si) { - if (dwMask == 0) { - DBDeleteContactSetting(si->hContact, "Chat", "TrayIconFlags"); - DBDeleteContactSetting(si->hContact, "Chat", "TrayIconMask"); - } else { - M->WriteDword(si->hContact, "Chat", "TrayIconFlags", iFlags); - M->WriteDword(si->hContact, "Chat", "TrayIconMask", dwMask); - } - Chat_SetFilters(si); - SendMessage(si->hWnd, GC_CHANGEFILTERFLAG, 0, (LPARAM)iFlags); - if (si->bFilterEnabled) - SendMessage(si->hWnd, GC_REDRAWLOG, 0, 0); + dwMask = iFlags = 0; + + for (i=0; _eventorder[i]; i++) { + result = IsDlgButtonChecked(hwndDlg, IDC_T1 + i); + dwMask |= (result != BST_INDETERMINATE ? _eventorder[i] : 0); + iFlags |= (result == BST_CHECKED ? _eventorder[i] : 0); + } + if (iFlags&GC_EVENT_ADDSTATUS) + iFlags |= GC_EVENT_REMOVESTATUS; + + if (si) { + if (dwMask == 0) { + DBDeleteContactSetting(si->hContact, "Chat", "TrayIconFlags"); + DBDeleteContactSetting(si->hContact, "Chat", "TrayIconMask"); + } else { + M->WriteDword(si->hContact, "Chat", "TrayIconFlags", iFlags); + M->WriteDword(si->hContact, "Chat", "TrayIconMask", dwMask); } + Chat_SetFilters(si); + SendMessage(si->hWnd, GC_CHANGEFILTERFLAG, 0, (LPARAM)iFlags); + if (si->bFilterEnabled) + SendMessage(si->hWnd, GC_REDRAWLOG, 0, 0); } - DestroyWindow(hwndDlg); - break; - case WM_DESTROY: - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); - break; + } + DestroyWindow(hwndDlg); + break; + case WM_DESTROY: + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); + break; } return(FALSE); } @@ -1295,19 +1297,18 @@ static LRESULT CALLBACK ButtonSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, L HWND hwndParent = GetParent(hwnd); switch (msg) { - case WM_RBUTTONUP: { - HWND hFilter = GetDlgItem(hwndParent, IDC_FILTER); - HWND hColor = GetDlgItem(hwndParent, IDC_COLOR); - HWND hBGColor = GetDlgItem(hwndParent, IDC_BKGCOLOR); - - if (M->GetByte("Chat", "RightClickFilter", 0) != 0) { - if (hFilter == hwnd) - SendMessage(hwndParent, GC_SHOWFILTERMENU, 0, 0); - if (hColor == hwnd) - SendMessage(hwndParent, GC_SHOWCOLORCHOOSER, 0, (LPARAM)IDC_COLOR); - if (hBGColor == hwnd) - SendMessage(hwndParent, GC_SHOWCOLORCHOOSER, 0, (LPARAM)IDC_BKGCOLOR); - } + case WM_RBUTTONUP: + HWND hFilter = GetDlgItem(hwndParent, IDC_FILTER); + HWND hColor = GetDlgItem(hwndParent, IDC_COLOR); + HWND hBGColor = GetDlgItem(hwndParent, IDC_BKGCOLOR); + + if (M->GetByte("Chat", "RightClickFilter", 0) != 0) { + if (hFilter == hwnd) + SendMessage(hwndParent, GC_SHOWFILTERMENU, 0, 0); + if (hColor == hwnd) + SendMessage(hwndParent, GC_SHOWCOLORCHOOSER, 0, (LPARAM)IDC_COLOR); + if (hBGColor == hwnd) + SendMessage(hwndParent, GC_SHOWCOLORCHOOSER, 0, (LPARAM)IDC_BKGCOLOR); } break; } @@ -1315,7 +1316,6 @@ static LRESULT CALLBACK ButtonSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, L return mir_callNextSubclass(hwnd, ButtonSubclassProc, msg, wParam, lParam); } - /* * subclassing for the message history display (rich edit control in which the chat history appears) */ -- cgit v1.2.3