From 04ac06b7119933997ee0b407478d4cb409007098 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 18 Jan 2014 09:34:05 +0000 Subject: end of crazy matrix mechanics in chat's icon ordering git-svn-id: http://svn.miranda-ng.org/main/trunk@7708 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TabSRMM/src/chat/chat.h | 2 + plugins/TabSRMM/src/chat/log.cpp | 113 ++++++++++++++++++++++++++---------- plugins/TabSRMM/src/chat/main.cpp | 1 + plugins/TabSRMM/src/chat/window.cpp | 9 ++- 4 files changed, 89 insertions(+), 36 deletions(-) (limited to 'plugins') diff --git a/plugins/TabSRMM/src/chat/chat.h b/plugins/TabSRMM/src/chat/chat.h index ecfbf2b503..605e9fefc0 100644 --- a/plugins/TabSRMM/src/chat/chat.h +++ b/plugins/TabSRMM/src/chat/chat.h @@ -132,6 +132,7 @@ INT_PTR CALLBACK DlgProcColorToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, L // log.c void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, bool bRedraw, bool bPhaseTwo); +char* Log_CreateRtfHeader(MODULEINFO *mi); TCHAR* GetChatLogsFilename(SESSION_INFO *si, time_t tTime); void Log_SetStyles(); @@ -180,6 +181,7 @@ TCHAR* Chat_DoRtfToTags(char* pszRtfText, SESSION_INFO *si); #include "chat_resource.h" extern char *szChatIconString; +extern char szIndicators[]; #define DEFLOGFILENAME _T("%miranda_logpath%\\%proto%\\%userid%.log") diff --git a/plugins/TabSRMM/src/chat/log.cpp b/plugins/TabSRMM/src/chat/log.cpp index 424c5526ff..df8875ab11 100644 --- a/plugins/TabSRMM/src/chat/log.cpp +++ b/plugins/TabSRMM/src/chat/log.cpp @@ -739,6 +739,79 @@ static void AddEventToBuffer(char **buffer, int *bufferEnd, int *bufferAlloced, } } +char* Log_CreateRtfHeader(MODULEINFO *mi) +{ + int bufferAlloced, bufferEnd, i = 0; + + // guesstimate amount of memory for the RTF header + bufferEnd = 0; + bufferAlloced = 4096; + char *buffer = (char *)mir_realloc(mi->pszHeader, bufferAlloced); + buffer[0] = '\0'; + + + //get the number of pixels per logical inch + if (logPixelSY == 0) { + HDC hdc; + hdc = GetDC(NULL); + logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY); + logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX); + ReleaseDC(NULL, hdc); + } + + // ### RTF HEADER + + // font table + Log_Append(&buffer, &bufferEnd, &bufferAlloced, "{\\rtf1\\ansi\\deff0{\\fonttbl"); + for (i = 0; i < OPTIONS_FONTCOUNT; i++) + Log_Append(&buffer, &bufferEnd, &bufferAlloced, "{\\f%u\\fnil\\fcharset%u%S;}", i, pci->aFonts[i].lf.lfCharSet, pci->aFonts[i].lf.lfFaceName); + + // colour table + Log_Append(&buffer, &bufferEnd, &bufferAlloced, "}{\\colortbl ;"); + + for (i = 0; i < OPTIONS_FONTCOUNT; i++) + Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(pci->aFonts[i].color), GetGValue(pci->aFonts[i].color), GetBValue(pci->aFonts[i].color)); + + for (i = 0; i < mi->nColorCount; i++) + Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(mi->crColors[i]), GetGValue(mi->crColors[i]), GetBValue(mi->crColors[i])); + + for (i = 0; i < STATUSICONCOUNT; i++) + Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(g_Settings.nickColors[i]), GetGValue(g_Settings.nickColors[i]), GetBValue(g_Settings.nickColors[i])); + + // new paragraph + Log_Append(&buffer, &bufferEnd, &bufferAlloced, "}\\pard\\sl%d", 1000); + + // set tabs and indents + int iIndent = 0; + + if (g_Settings.bLogSymbols) { + TCHAR szString[2]; + LOGFONT lf; + + szString[1] = 0; + szString[0] = 0x28; + pci->LoadMsgDlgFont(17, &lf, NULL); + HFONT hFont = CreateFontIndirect(&lf); + int iText = GetTextPixelSize(szString, hFont, true) + 3; + DeleteObject(hFont); + iIndent += (iText * 1440) / logPixelSX; + Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent); + } + else if (g_Settings.dwIconFlags) { + iIndent += ((g_Settings.bScaleIcons ? 14 : 20) * 1440) / logPixelSX; + Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent); + } + if (g_Settings.ShowTime) { + int iSize = (g_Settings.LogTextIndent * 1440) / logPixelSX; + Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent + iSize); + if (g_Settings.LogIndentEnabled) + iIndent += iSize; + } + Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\fi-%u\\li%u", iIndent, iIndent); + + return buffer; +} + static char* Log_CreateRTF(LOGSTREAMDATA *streamData) { char *buffer, *header; @@ -755,7 +828,7 @@ static char* Log_CreateRTF(LOGSTREAMDATA *streamData) // ### RTF HEADER if (0 == mi->pszHeader) - mi->pszHeader = pci->Log_CreateRtfHeader(mi); + mi->pszHeader = Log_CreateRtfHeader(mi); header = mi->pszHeader; streamData->crCount = mi->nColorCount; @@ -838,39 +911,17 @@ static char* Log_CreateRTF(LOGSTREAMDATA *streamData) TCHAR pszTemp[300], *p1; char pszIndicator[3] = "\0\0"; int crNickIndex = 0; - //mad + if (g_Settings.bLogClassicIndicators || g_Settings.bColorizeNicksInLog) { USERINFO *ui = streamData->si->pUsers; while (ui) { if (!lstrcmp(ui->pszNick, lin->ptszNick)) { STATUSINFO *ti = pci->TM_FindStatus(streamData->si->pStatuses, pci->TM_WordToString(streamData->si->pStatuses, ui->Status)); - 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; - } + if (ti && (UINT_PTR)ti->hIcon < streamData->si->iStatusCount) { + pszIndicator[0] = szIndicators[(int)ti->hIcon]; + crNickIndex = streamData->si->iStatusCount - (int)ti->hIcon; // color table's index is not zero-based } + else pszIndicator[0] = 0; break; } ui = ui->next; @@ -892,11 +943,11 @@ static char* Log_CreateRTF(LOGSTREAMDATA *streamData) _tcsnrplc(pszTemp, 300, _T("%s"), _T("~~++#%s#++~~")); pszTemp[299] = 0; } - - if (g_Settings.bColorizeNicksInLog && pszIndicator[0]) - Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\cf%u ", OPTIONS_FONTCOUNT + streamData->crCount + crNickIndex + 1); } + if (g_Settings.bColorizeNicksInLog && pszIndicator[0]) + Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\cf%u ", OPTIONS_FONTCOUNT + streamData->crCount + crNickIndex); + Log_AppendRTF(streamData, TRUE, &buffer, &bufferEnd, &bufferAlloced, pszTemp, lin->ptszNick); Log_Append(&buffer, &bufferEnd, &bufferAlloced, " "); } diff --git a/plugins/TabSRMM/src/chat/main.cpp b/plugins/TabSRMM/src/chat/main.cpp index 3c15eefb0a..c367f9cef0 100644 --- a/plugins/TabSRMM/src/chat/main.cpp +++ b/plugins/TabSRMM/src/chat/main.cpp @@ -273,6 +273,7 @@ int Chat_Load() // this operation is unsafe, that's why we restore the old pci state on exit pci->DoSoundsFlashPopupTrayStuff = DoSoundsFlashPopupTrayStuff; pci->IsHighlighted = IsHighlighted; + pci->Log_CreateRtfHeader = Log_CreateRtfHeader; pci->ReloadSettings(); g_hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU)); diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index df7b271eb8..ea559adc64 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -45,8 +45,7 @@ extern HMENU g_hMenu; static HKL hkl = NULL; static HCURSOR hCurHyperlinkHand; -static char szIndicators[] = { '+', '%', '@', '!', 0, '*' }; -static int nickOrders[] = { 2, 1, 0, 3, 5, 4 }; +char szIndicators[] = { '@', '%', '+', '!', '*', 0 }; struct MESSAGESUBDATA { @@ -2271,8 +2270,8 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar int nickIndex = -1; for (int i = 0; i < STATUSICONCOUNT; i++) { - if (hIcon == pci->hIcons[ICON_STATUS1 + i]) { - nickIndex = nickOrders[i]; + if (hIcon == pci->hIcons[ICON_STATUS0 + i]) { + nickIndex = i; break; } } @@ -2284,7 +2283,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar else { FillRect(dis->hDC, &dis->rcItem, pci->hListBkgBrush); if (g_Settings.bColorizeNicks && nickIndex != -1) - SetTextColor(dis->hDC, g_Settings.nickColors[nickIndex]); + SetTextColor(dis->hDC, g_Settings.nickColors[si->iStatusCount - nickIndex - 1]); else SetTextColor(dis->hDC, g_Settings.UserListColors[ui->iStatusEx]); } -- cgit v1.2.3