From b638838fd6ec1eb32d096e0244e8e0d2a8196c73 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 17 Jan 2014 14:41:49 +0000 Subject: - kernel chat module loads automatically, not on request; - the special structure, CHAT_MANAGER_INITDATA, is used to customize chats; - fix for fonts group for all plugins; - fix for options in tabSRMM git-svn-id: http://svn.miranda-ng.org/main/trunk@7688 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Scriver/src/chat/main.cpp | 9 +-- plugins/Scriver/src/chat/window.cpp | 6 +- plugins/Scriver/src/globals.cpp | 2 +- plugins/Scriver/src/infobar.cpp | 4 +- plugins/Scriver/src/msgdialog.cpp | 2 +- plugins/Scriver/src/msglog.cpp | 6 +- plugins/Scriver/src/msgoptions.cpp | 115 ++++++------------------------------ plugins/Scriver/src/msgs.h | 2 +- 8 files changed, 32 insertions(+), 114 deletions(-) (limited to 'plugins/Scriver/src') diff --git a/plugins/Scriver/src/chat/main.cpp b/plugins/Scriver/src/chat/main.cpp index d37559ea20..6a54c7b865 100644 --- a/plugins/Scriver/src/chat/main.cpp +++ b/plugins/Scriver/src/chat/main.cpp @@ -21,9 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "../commonheaders.h" -void RegisterChatFonts( void ); - -//globals +// globals CHAT_MANAGER *pci; HMENU g_hMenu = NULL; @@ -144,9 +142,8 @@ void LoadChatIcons(void) int Chat_Load() { - mir_getCI(&g_Settings); - pci->cbModuleInfo = sizeof(MODULEINFO); - pci->cbSession = sizeof(SESSION_INFO); + CHAT_MANAGER_INITDATA data = { &g_Settings, sizeof(MODULEINFO), sizeof(SESSION_INFO), LPGENT("Messaging")_T("/")LPGENT("Group chats") }; + mir_getCI(&data); pci->OnCreateModule = OnCreateModule; pci->OnNewUser = OnNewUser; diff --git a/plugins/Scriver/src/chat/window.cpp b/plugins/Scriver/src/chat/window.cpp index 091bab7cbd..40ae167644 100644 --- a/plugins/Scriver/src/chat/window.cpp +++ b/plugins/Scriver/src/chat/window.cpp @@ -470,7 +470,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, UINT u2 = 0; COLORREF cr; - LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, NULL, &cr, FALSE); + LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, NULL, &cr); CHARFORMAT2 cf; cf.cbSize = sizeof(CHARFORMAT2); @@ -1142,7 +1142,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar { // messagebox COLORREF crFore; - LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, NULL, &crFore, FALSE); + LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, NULL, &crFore); CHARFORMAT2 cf; cf.cbSize = sizeof(CHARFORMAT2); @@ -1893,7 +1893,7 @@ LABEL_SHOWWINDOW: } else { COLORREF cr; - LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, NULL, &cr, FALSE); + LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, NULL, &cr); cf.dwMask = CFM_COLOR; cf.crTextColor = cr; if (pInfo->bSingleFormat) diff --git a/plugins/Scriver/src/globals.cpp b/plugins/Scriver/src/globals.cpp index 943895004d..65a04c3f12 100644 --- a/plugins/Scriver/src/globals.cpp +++ b/plugins/Scriver/src/globals.cpp @@ -219,7 +219,7 @@ static BOOL CALLBACK LangAddCallback(CHAR * str) void LoadInfobarFonts() { LOGFONT lf; - LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, &lf, NULL, FALSE); + LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, &lf, NULL); g_dat.minInputAreaHeight = db_get_dw(NULL, SRMMMOD, SRMSGSET_AUTORESIZELINES, SRMSGDEFSET_AUTORESIZELINES) * abs(lf.lfHeight) * g_dat.logPixelSY / 72; if (g_dat.hInfobarBrush != NULL) DeleteObject(g_dat.hInfobarBrush); diff --git a/plugins/Scriver/src/infobar.cpp b/plugins/Scriver/src/infobar.cpp index a7ce5bfa30..d4c7caee6d 100644 --- a/plugins/Scriver/src/infobar.cpp +++ b/plugins/Scriver/src/infobar.cpp @@ -31,7 +31,7 @@ void SetupInfobar(InfobarWindowData* idat) { DWORD colour = db_get_dw(NULL, SRMMMOD, SRMSGSET_INFOBARBKGCOLOUR, SRMSGDEFSET_INFOBARBKGCOLOUR); SendDlgItemMessage(hwnd, IDC_INFOBAR_NAME, EM_SETBKGNDCOLOR, 0, colour); SendDlgItemMessage(hwnd, IDC_INFOBAR_STATUS, EM_SETBKGNDCOLOR, 0, colour); - LoadMsgDlgFont(MSGFONTID_INFOBAR_NAME, &lf, &colour, FALSE); + LoadMsgDlgFont(MSGFONTID_INFOBAR_NAME, &lf, &colour); cf2.dwMask = CFM_COLOR | CFM_FACE | CFM_CHARSET | CFM_SIZE | CFM_WEIGHT | CFM_BOLD | CFM_ITALIC; cf2.cbSize = sizeof(cf2); cf2.crTextColor = colour; @@ -43,7 +43,7 @@ void SetupInfobar(InfobarWindowData* idat) { cf2.yHeight = abs(lf.lfHeight) * 1440 / g_dat.logPixelSY; SendDlgItemMessageA(hwnd, IDC_INFOBAR_NAME, EM_SETCHARFORMAT, 0, (LPARAM)&cf2); - LoadMsgDlgFont(MSGFONTID_INFOBAR_STATUS, &lf, &colour, FALSE); + LoadMsgDlgFont(MSGFONTID_INFOBAR_STATUS, &lf, &colour); cf2.dwMask = CFM_COLOR | CFM_FACE | CFM_CHARSET | CFM_SIZE | CFM_WEIGHT | CFM_BOLD | CFM_ITALIC; cf2.cbSize = sizeof(cf2); cf2.crTextColor = colour; diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 8a43b212e7..51bf39deb2 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -1154,7 +1154,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP colour = db_get_dw(NULL, SRMMMOD, SRMSGSET_INPUTBKGCOLOUR, SRMSGDEFSET_INPUTBKGCOLOUR); SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETBKGNDCOLOR, 0, colour); InvalidateRect(GetDlgItem(hwndDlg, IDC_MESSAGE), NULL, FALSE); - LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, &lf, &colour, FALSE); + LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, &lf, &colour); cf2.cbSize = sizeof(cf2); cf2.dwMask = CFM_COLOR | CFM_FACE | CFM_CHARSET | CFM_SIZE | CFM_WEIGHT | CFM_BOLD | CFM_ITALIC; cf2.crTextColor = colour; diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp index f1255c6456..a6c124cb08 100644 --- a/plugins/Scriver/src/msglog.cpp +++ b/plugins/Scriver/src/msglog.cpp @@ -363,13 +363,13 @@ static char *CreateRTFHeader(struct SrmmWindowData *dat, struct GlobalMessageDat buffer[0] = '\0'; AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced,"{\\rtf1\\ansi\\deff0{\\fonttbl"); for (i = 0; i < fontOptionsListSize; i++) { - LoadMsgDlgFont(i, &lf, NULL, FALSE); + LoadMsgDlgFont(i, &lf, NULL); AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "{\\f%u\\fnil\\fcharset%u %S;}", i, (!forceCharset) ? lf.lfCharSet : charset, lf.lfFaceName); } AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "}{\\colortbl "); for (i = 0; i < fontOptionsListSize; i++) { - LoadMsgDlgFont(i, NULL, &colour, FALSE); + LoadMsgDlgFont(i, NULL, &colour); AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(colour), GetGValue(colour), GetBValue(colour)); } if (GetSysColorBrush(COLOR_HOTLIGHT) == NULL) @@ -404,7 +404,7 @@ static char* SetToStyle(int style) { static char szStyle[128]; LOGFONT lf; - LoadMsgDlgFont(style, &lf, NULL, FALSE); + LoadMsgDlgFont(style, &lf, NULL); mir_snprintf(szStyle, SIZEOF(szStyle), "\\f%u\\cf%u\\b%d\\i%d\\fs%u", style, style, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / logPixelSY); return szStyle; } diff --git a/plugins/Scriver/src/msgoptions.cpp b/plugins/Scriver/src/msgoptions.cpp index e14213c100..21a5586116 100644 --- a/plugins/Scriver/src/msgoptions.cpp +++ b/plugins/Scriver/src/msgoptions.cpp @@ -78,30 +78,6 @@ static const FontOptionsList fontOptionsList[] = { int fontOptionsListSize = SIZEOF(fontOptionsList); -//remeber to put these in the Translate( ) template file too -static const FontOptionsList chatFontOptionsList[] = { - { LPGENT("Timestamp"), RGB(50, 50, 240), _T("Terminal"), 0, -8, LPGENT("Background")}, - { LPGENT("Others nicknames"), RGB(0, 0, 0), _T("Verdana"), FONTF_BOLD, -13, LPGENT("Background")}, - { LPGENT("Your nickname"), RGB(0, 0, 0), _T("Verdana"), FONTF_BOLD, -13, LPGENT("Background")}, - { LPGENT("User has joined"), RGB(90, 160, 90), _T("Verdana"), 0, -13, LPGENT("Background")}, - { LPGENT("User has left"), RGB(160, 160, 90), _T("Verdana"), 0, -13, LPGENT("Background")}, - { LPGENT("User has disconnected"), RGB(160, 90, 90), _T("Verdana"), 0, -13, LPGENT("Background")}, - { LPGENT("User kicked ..."), RGB(100, 100, 100), _T("Verdana"), 0, -13, LPGENT("Background")}, - { LPGENT("User is now known as ..."), RGB(90, 90, 160), _T("Verdana"), 0, -13, LPGENT("Background")}, - { LPGENT("Notice from user"), RGB(160, 130, 60), _T("Verdana"), 0, -13, LPGENT("Background")}, - { LPGENT("Incoming message"), RGB(90, 90, 90), _T("Verdana"), 0, -13, LPGENT("Background")}, - { LPGENT("Outgoing message"), RGB(90, 90, 90), _T("Verdana"), 0, -13, LPGENT("Background")}, - { LPGENT("The topic is ..."), RGB(70, 70, 160), _T("Verdana"), 0, -13, LPGENT("Background")}, - { LPGENT("Information messages"), RGB(130, 130, 195), _T("Verdana"), 0, -13, LPGENT("Background")}, - { LPGENT("User enables status for ..."), RGB(70, 150, 70), _T("Verdana"), 0, -13, LPGENT("Background")}, - { LPGENT("User disables status for ..."), RGB(150, 70, 70), _T("Verdana"), 0, -13, LPGENT("Background")}, - { LPGENT("Action message"), RGB(160, 90, 160), _T("Verdana"), 0, -13, LPGENT("Background")}, - { LPGENT("Highlighted message"), RGB(180, 150, 80), _T("Verdana"), 0, -13, LPGENT("Background")}, - { LPGENT("Message typing area"), RGB(0, 0, 40), _T("Verdana"), 0, -14, LPGENT("Message background")}, - { LPGENT("User list members (online)"), RGB(0,0, 0), _T("Verdana"), 0, -12, LPGENT("User list background")}, - { LPGENT("User list members (away)"), RGB(170, 170, 170), _T("Verdana"), 0, -12, LPGENT("User list background")}, -}; - struct ColourOptionsList { const TCHAR *szName; @@ -172,58 +148,6 @@ void RegisterFontServiceFonts() } } -void RegisterChatFonts(void) -{ - FontIDT fid = { 0 }; - ColourIDT colourid; - char idstr[10]; - int index = 0, i; - fid.cbSize = sizeof(FontIDT); - mir_sntprintf(fid.group, SIZEOF(fid.group), _T("%s/%s"), LPGENT("Messaging"), LPGENT("Group chats")); - mir_sntprintf(fid.backgroundGroup, SIZEOF(fid.backgroundGroup), _T("%s/%s"), LPGENT("Messaging"), LPGENT("Group chats")); - strncpy(fid.dbSettingsGroup, "ChatFonts", sizeof(fid.dbSettingsGroup)); - fid.flags = FIDF_ALLOWREREGISTER | FIDF_DEFAULTVALID | FIDF_NEEDRESTART; - for (i = 0; i < SIZEOF(chatFontOptionsList); i++) { - if (i == 17) continue; - fid.order = index++; - mir_snprintf(idstr, SIZEOF(idstr), "Font%d", i); - strncpy(fid.prefix, idstr, sizeof(fid.prefix)); - _tcsncpy(fid.name, chatFontOptionsList[i].szDescr, SIZEOF(fid.name)); - fid.deffontsettings.colour = chatFontOptionsList[i].defColour; - fid.deffontsettings.size = chatFontOptionsList[i].defSize; - fid.deffontsettings.style = chatFontOptionsList[i].defStyle; - fid.deffontsettings.charset = MsgDlgGetFontDefaultCharset(fontOptionsList[i].szDefFace); - _tcsncpy(fid.deffontsettings.szFace, chatFontOptionsList[i].szDefFace, SIZEOF(fid.deffontsettings.szFace)); - _tcsncpy(fid.backgroundName, chatFontOptionsList[i].szBkgName, SIZEOF(fid.backgroundName)); - FontRegisterT(&fid); - } - - colourid.cbSize = sizeof(ColourIDT); - colourid.order = 0; - strncpy(colourid.dbSettingsGroup, "Chat", sizeof(colourid.dbSettingsGroup)); - - strncpy(colourid.setting, "ColorLogBG", SIZEOF(colourid.setting)); - _tcsncpy(colourid.name, LPGENT("Background"), SIZEOF(colourid.name)); - mir_sntprintf(colourid.group, SIZEOF(colourid.group), _T("%s/%s"), LPGENT("Messaging"), LPGENT("Group chats")); - colourid.defcolour = GetSysColor(COLOR_WINDOW); - ColourRegisterT(&colourid); - - strncpy(colourid.setting, "ColorNicklistBG", SIZEOF(colourid.setting)); - _tcsncpy(colourid.name, LPGENT("User list background"), SIZEOF(colourid.name)); - colourid.defcolour = GetSysColor(COLOR_WINDOW); - ColourRegisterT(&colourid); - - strncpy(colourid.setting, "ColorNicklistLines", SIZEOF(colourid.setting)); - _tcsncpy(colourid.name, LPGENT("User list lines"), SIZEOF(colourid.name)); - colourid.defcolour = GetSysColor(COLOR_INACTIVEBORDER); - ColourRegisterT(&colourid); - - strncpy(colourid.setting, "ColorNicklistSelectedBG", SIZEOF(colourid.setting)); - _tcsncpy(colourid.name, LPGENT("User list background (selected)"), SIZEOF(colourid.name)); - colourid.defcolour = GetSysColor(COLOR_HIGHLIGHT); - ColourRegisterT(&colourid); -} - int IconsChanged(WPARAM wParam, LPARAM lParam) { ReleaseIcons(); @@ -242,27 +166,23 @@ int SmileySettingsChanged(WPARAM wParam, LPARAM lParam) return 0; } -void LoadMsgDlgFont(int i, LOGFONT * lf, COLORREF * colour, BOOL chatMode) +void LoadMsgDlgFont(int i, LOGFONT *lf, COLORREF *colour) { char str[32]; - int style; - DBVARIANT dbv; - const char * module = chatMode ? "ChatFonts" : SRMMMOD; - const char * prefix = chatMode ? "Font" : "SRMFont"; - const FontOptionsList * fontList = chatMode ? chatFontOptionsList : fontOptionsList; if (colour) { - mir_snprintf(str, SIZEOF(str), "%s%dCol", prefix, i); - *colour = db_get_dw(NULL, module, str, fontList[i].defColour); + mir_snprintf(str, SIZEOF(str), "%s%dCol", "SRMFont", i); + *colour = db_get_dw(NULL, SRMMMOD, str, fontOptionsList[i].defColour); } + if (lf) { - mir_snprintf(str, SIZEOF(str), "%s%dSize", prefix, i); - lf->lfHeight = (char)db_get_b(NULL, module, str, fontList[i].defSize); + mir_snprintf(str, SIZEOF(str), "%s%dSize", "SRMFont", i); + lf->lfHeight = (char)db_get_b(NULL, SRMMMOD, str, fontOptionsList[i].defSize); lf->lfWidth = 0; lf->lfEscapement = 0; lf->lfOrientation = 0; - mir_snprintf(str, SIZEOF(str), "%s%dSty", prefix, i); - style = db_get_b(NULL, module, str, fontList[i].defStyle); + mir_snprintf(str, SIZEOF(str), "%s%dSty", "SRMFont", i); + int style = db_get_b(NULL, SRMMMOD, str, fontOptionsList[i].defStyle); lf->lfWeight = style & FONTF_BOLD ? FW_BOLD : FW_NORMAL; lf->lfItalic = style & FONTF_ITALIC ? 1 : 0; lf->lfUnderline = 0; @@ -271,15 +191,16 @@ void LoadMsgDlgFont(int i, LOGFONT * lf, COLORREF * colour, BOOL chatMode) lf->lfClipPrecision = CLIP_DEFAULT_PRECIS; lf->lfQuality = DEFAULT_QUALITY; lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; - mir_snprintf(str, SIZEOF(str), "%s%d", prefix, i); - if (db_get_ts(NULL, module, str, &dbv)) - lstrcpy(lf->lfFaceName, fontList[i].szDefFace); - else { - _tcsncpy(lf->lfFaceName, dbv.ptszVal, SIZEOF(lf->lfFaceName)); - db_free(&dbv); - } - mir_snprintf(str, SIZEOF(str), "%s%dSet", prefix, i); - lf->lfCharSet = db_get_b(NULL, module, str, MsgDlgGetFontDefaultCharset(lf->lfFaceName)); + mir_snprintf(str, SIZEOF(str), "%s%d", "SRMFont", i); + + ptrT tszFace(db_get_tsa(NULL, SRMMMOD, str)); + if (tszFace == NULL) + lstrcpy(lf->lfFaceName, fontOptionsList[i].szDefFace); + else + _tcsncpy(lf->lfFaceName, tszFace, SIZEOF(lf->lfFaceName)); + + mir_snprintf(str, SIZEOF(str), "%s%dSet", "SRMFont", i); + lf->lfCharSet = db_get_b(NULL, SRMMMOD, str, MsgDlgGetFontDefaultCharset(lf->lfFaceName)); } } diff --git a/plugins/Scriver/src/msgs.h b/plugins/Scriver/src/msgs.h index 39c8f53331..7e593ec9a4 100644 --- a/plugins/Scriver/src/msgs.h +++ b/plugins/Scriver/src/msgs.h @@ -250,7 +250,7 @@ int IsAutoPopup(HANDLE hContact); #define MSGFONTID_INFOBAR_NAME 12 #define MSGFONTID_INFOBAR_STATUS 13 -void LoadMsgDlgFont(int i, LOGFONT * lf, COLORREF * colour, BOOL chatMode); +void LoadMsgDlgFont(int i, LOGFONT *lf, COLORREF *colour); extern int fontOptionsListSize; #define LOADHISTORY_UNREAD 0 -- cgit v1.2.3