From f3b5ee60a8e1ada21848105d839198956af6df79 Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Sun, 27 Apr 2014 16:07:42 +0000 Subject: Fixed broken font settings (fixes #658) String "%s (colors only)" must be translated manually for each git-svn-id: http://svn.miranda-ng.org/main/trunk@9091 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Popup/src/font.cpp | 48 ++++++++++++++++++------------------- plugins/Popup/src/font.h | 10 ++++---- plugins/Popup/src/notifications.cpp | 22 ++++++++--------- plugins/Popup/src/popup_gdiplus.cpp | 15 ++++-------- plugins/Popup/src/services.cpp | 10 ++++---- 5 files changed, 50 insertions(+), 55 deletions(-) (limited to 'plugins/Popup') diff --git a/plugins/Popup/src/font.cpp b/plugins/Popup/src/font.cpp index df6e1640ca..defe5852c6 100644 --- a/plugins/Popup/src/font.cpp +++ b/plugins/Popup/src/font.cpp @@ -29,8 +29,8 @@ void InitFonts() { // Fonts FontIDT fid = {0}; fid.cbSize = sizeof(FontIDT); - lstrcpy(fid.group, _T(PU_FNT_AND_COLOR)); - strcpy(fid.dbSettingsGroup, PU_FNT_AND_COLOR_DB); + lstrcpyn(fid.group, _T(PU_FNT_AND_COLOR), SIZEOF(fid.group)); + strncpy(fid.dbSettingsGroup, PU_FNT_AND_COLOR_DB, SIZEOF(fid.dbSettingsGroup)); fid.flags = FIDF_DEFAULTVALID; fid.deffontsettings.charset = DEFAULT_CHARSET; fid.deffontsettings.size = -11; @@ -38,32 +38,32 @@ void InitFonts() { lstrcpyn(fid.backgroundName,PU_COL_BACK_NAME, SIZEOF(fid.backgroundName)); lstrcpyn(fid.deffontsettings.szFace, _T("Tahoma"), SIZEOF(fid.deffontsettings.szFace)); - lstrcpyn(fid.name, PU_FNT_NAME_TITLE, SIZEOF(fid.name)); + lstrcpyn(fid.name, _T(PU_FNT_NAME_TITLE), SIZEOF(fid.name)); mir_snprintf(fid.prefix, sizeof(fid.prefix), PU_FNT_PREFIX, PU_FNT_NAME_TITLE); fid.deffontsettings.style = DBFONTF_BOLD; fid.deffontsettings.colour = RGB(0,0,0); FontRegisterT(&fid); - lstrcpyn(fid.name, PU_FNT_NAME_CLOCK, SIZEOF(fid.name)); + lstrcpyn(fid.name, _T(PU_FNT_NAME_CLOCK), SIZEOF(fid.name)); mir_snprintf(fid.prefix, sizeof(fid.prefix), PU_FNT_PREFIX, PU_FNT_NAME_CLOCK); //fid.deffontsettings.style = DBFONTF_BOLD; //fid.deffontsettings.colour = RGB(0,0,0); FontRegisterT(&fid); - lstrcpyn(fid.name, PU_FNT_NAME_TEXT, SIZEOF(fid.name)); + lstrcpyn(fid.name, _T(PU_FNT_NAME_TEXT), SIZEOF(fid.name)); mir_snprintf(fid.prefix, sizeof(fid.prefix), PU_FNT_PREFIX, PU_FNT_NAME_TEXT); fid.deffontsettings.style = 0; //fid.deffontsettings.colour = RGB(0,0,0); FontRegisterT(&fid); - lstrcpyn(fid.name, _T("Action"), SIZEOF(fid.name)); - mir_snprintf(fid.prefix, sizeof(fid.prefix), PU_FNT_PREFIX, "Action"); + lstrcpyn(fid.name, _T(PU_FNT_NAME_ACTION), SIZEOF(fid.name)); + mir_snprintf(fid.prefix, sizeof(fid.prefix), PU_FNT_PREFIX, PU_FNT_NAME_ACTION); //fid.deffontsettings.style = 0; fid.deffontsettings.colour = RGB(0,0,255); FontRegisterT(&fid); - lstrcpyn(fid.name, LPGENT("Hovered Action"), SIZEOF(fid.name)); - mir_snprintf(fid.prefix, sizeof(fid.prefix), PU_FNT_PREFIX, "Hovered Action"); + lstrcpyn(fid.name, _T(PU_FNT_NAME_HOVERED_ACTION), SIZEOF(fid.name)); + mir_snprintf(fid.prefix, sizeof(fid.prefix), PU_FNT_PREFIX, PU_FNT_NAME_HOVERED_ACTION); fid.deffontsettings.style = DBFONTF_UNDERLINE; //fid.deffontsettings.colour = RGB(0,0,255); FontRegisterT(&fid); @@ -100,25 +100,25 @@ void ReloadFonts() fid.cbSize = sizeof(FontIDT); lstrcpyn(fid.group, _T(PU_FNT_AND_COLOR),SIZEOF(fid.name)); - lstrcpyn(fid.name, PU_FNT_NAME_TITLE,SIZEOF(fid.name)); - fonts.clTitle = (COLORREF)CallService(MS_FONT_GETT, (WPARAM)&fid, (LPARAM)&lf); - fonts.title = CreateFontIndirect(&lf); + lstrcpyn(fid.name, _T(PU_FNT_NAME_TITLE),SIZEOF(fid.name)); + fonts.clTitle = (COLORREF)CallService(MS_FONT_GETT, (WPARAM)&fid, (LPARAM)&lf); + fonts.title = CreateFontIndirect(&lf); - lstrcpyn(fid.name, LPGENT("Clock"),SIZEOF(fid.name)); - fonts.clClock = (COLORREF)CallService(MS_FONT_GETT, (WPARAM)&fid, (LPARAM)&lf); - fonts.clock = CreateFontIndirect(&lf); + lstrcpyn(fid.name, _T(PU_FNT_NAME_CLOCK),SIZEOF(fid.name)); + fonts.clClock = (COLORREF)CallService(MS_FONT_GETT, (WPARAM)&fid, (LPARAM)&lf); + fonts.clock = CreateFontIndirect(&lf); - lstrcpyn(fid.name, PU_FNT_NAME_TEXT,SIZEOF(fid.name)); - fonts.clText = (COLORREF)CallService(MS_FONT_GETT, (WPARAM)&fid, (LPARAM)&lf); - fonts.text = CreateFontIndirect(&lf); + lstrcpyn(fid.name, _T(PU_FNT_NAME_TEXT),SIZEOF(fid.name)); + fonts.clText = (COLORREF)CallService(MS_FONT_GETT, (WPARAM)&fid, (LPARAM)&lf); + fonts.text = CreateFontIndirect(&lf); - lstrcpyn(fid.name, LPGENT("Action"),SIZEOF(fid.name)); - fonts.clAction = (COLORREF)CallService(MS_FONT_GETT, (WPARAM)&fid, (LPARAM)&lf); - fonts.action = CreateFontIndirect(&lf); + lstrcpyn(fid.name, _T(PU_FNT_NAME_ACTION),SIZEOF(fid.name)); + fonts.clAction = (COLORREF)CallService(MS_FONT_GETT, (WPARAM)&fid, (LPARAM)&lf); + fonts.action = CreateFontIndirect(&lf); - lstrcpyn(fid.name, LPGENT("Hovered Action"),SIZEOF(fid.name)); - fonts.clActionHover = (COLORREF)CallService(MS_FONT_GETT, (WPARAM)&fid, (LPARAM)&lf); - fonts.actionHover = CreateFontIndirect(&lf); + lstrcpyn(fid.name, _T(PU_FNT_NAME_HOVERED_ACTION),SIZEOF(fid.name)); + fonts.clActionHover = (COLORREF)CallService(MS_FONT_GETT, (WPARAM)&fid, (LPARAM)&lf); + fonts.actionHover = CreateFontIndirect(&lf); ColourIDT cid = {0}; cid.cbSize = sizeof(ColourIDT); diff --git a/plugins/Popup/src/font.h b/plugins/Popup/src/font.h index c22a08811f..b015cfc90b 100644 --- a/plugins/Popup/src/font.h +++ b/plugins/Popup/src/font.h @@ -25,13 +25,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define __font_h__ //basic constants for all popup plugins -#define PU_FNT_AND_COLOR "Popups" //common main group for customice\font&color +#define PU_FNT_AND_COLOR LPGEN("Popups") //common main group for customice\font&color #define PU_FNT_AND_COLOR_DB MODULNAME //use eg strcpy(fid.dbSettingsGroup, PU_FNT_GROUP_DB); #define PU_FNT_PREFIX "fnt%s" //use eg mir_snprintf(fid.prefix, sizeof(fid.prefix), PU_FNT_PREFIX, PU_FNT_NAME_....); -#define PU_FNT_NAME_TITLE LPGENT("Title") //use eg lstrcpy(fid.name, _T(FNT_NAME_....)) for FontIDT -#define PU_FNT_NAME_CLOCK LPGENT("Clock") -#define PU_FNT_NAME_TEXT LPGENT("Text") +#define PU_FNT_NAME_TITLE LPGEN("Title") //use eg lstrcpy(fid.name, _T(FNT_NAME_....)) for FontIDT +#define PU_FNT_NAME_CLOCK LPGEN("Clock") +#define PU_FNT_NAME_TEXT LPGEN("Text") +#define PU_FNT_NAME_ACTION LPGEN("Action") +#define PU_FNT_NAME_HOVERED_ACTION LPGEN("Hovered Action") #define PU_COL_BACK_NAME LPGENT("Background") #define PU_COL_BACK_SETTING "ColourBg" diff --git a/plugins/Popup/src/notifications.cpp b/plugins/Popup/src/notifications.cpp index cb1453dee5..f8ebfe9eda 100644 --- a/plugins/Popup/src/notifications.cpp +++ b/plugins/Popup/src/notifications.cpp @@ -187,31 +187,31 @@ HANDLE RegisterNotification(POPUPNOTIFICATION *notification) FontID fontid = {0}; fontid.cbSize = sizeof(fontid); - mir_snprintf(fontid.group, sizeof(fontid.group), "%s/%s", PU_FNT_AND_COLOR, notification->lpzGroup); + mir_snprintf(fontid.group, sizeof(fontid.group), PU_FNT_AND_COLOR"/%s", notification->lpzGroup); lstrcpyA(fontid.dbSettingsGroup, "PopupNotifications"); fontid.flags = FIDF_DEFAULTVALID; fontid.deffontsettings.charset = DEFAULT_CHARSET; fontid.deffontsettings.colour = ptd->notification.colorText; fontid.deffontsettings.size = -11; - lstrcpyA(fontid.deffontsettings.szFace, "MS Shell Dlg"); + lstrcpynA(fontid.deffontsettings.szFace, "MS Shell Dlg", SIZEOF(fontid.deffontsettings.szFace)); fontid.deffontsettings.style = 0; - mir_snprintf(fontid.name, SIZEOF(fontid.name), LPGEN("%s (colors only)"), notification->lpzName); + mir_snprintf(fontid.name, SIZEOF(fontid.name), "%s (colors only)", notification->lpzName); mir_snprintf(fontid.prefix, SIZEOF(fontid.prefix), "{%s/%s}text", notification->lpzGroup, notification->lpzName); fontid.deffontsettings.style = 0; FontRegister(&fontid); ColourID colourid = {0}; colourid.cbSize = sizeof(colourid); - mir_snprintf(colourid.group, sizeof(colourid.group), "%s/%s", PU_FNT_AND_COLOR, notification->lpzGroup); + mir_snprintf(colourid.group, sizeof(colourid.group), PU_FNT_AND_COLOR"/%s", notification->lpzGroup); lstrcpyA(colourid.dbSettingsGroup, "PopupNotifications"); - mir_snprintf(colourid.name, SIZEOF(colourid.name), LPGEN("%s (colors only)"), notification->lpzName); + mir_snprintf(colourid.name, SIZEOF(colourid.name), "%s (colors only)", notification->lpzName); mir_snprintf(colourid.setting, SIZEOF(colourid.setting), "{%s/%s}backColor", notification->lpzGroup, notification->lpzName); colourid.defcolour = ptd->notification.colorBack; ColourRegister(&colourid); char section[MAXMODULELABELLENGTH], setting[MAXMODULELABELLENGTH]; mir_snprintf(section, sizeof(section), "Popups/%s", notification->lpzGroup); - mir_snprintf(setting, sizeof(setting), "%s_%s_%s", MODULNAME, notification->lpzGroup, notification->lpzName); + mir_snprintf(setting, sizeof(setting), MODULNAME"_%s_%s", notification->lpzGroup, notification->lpzName); SKINICONDESC sid = { sizeof(sid) }; sid.pszSection = section; @@ -254,18 +254,18 @@ void FillNotificationData(POPUPDATA2 *ppd, DWORD *disableWhen) LOGFONTA lf; //dummy to make FS happy (use LOGFONTA coz we use MS_FONT_GET) FontID fontid = {0}; //use ansi version of fontID coz POPUPNOTIFICATION use char fontid.cbSize = sizeof(fontid); - mir_snprintf(fontid.group, sizeof(fontid.group), "%s/%s", PU_FNT_AND_COLOR, ptd->notification.lpzGroup); - mir_snprintf(fontid.name, SIZEOF(fontid.name), LPGEN("%s (colors only)"), ptd->notification.lpzName); + mir_snprintf(fontid.group, sizeof(fontid.group), PU_FNT_AND_COLOR"/%s", ptd->notification.lpzGroup); + mir_snprintf(fontid.name, SIZEOF(fontid.name), "%s (colors only)", ptd->notification.lpzName); ppd->colorText = (COLORREF)CallService(MS_FONT_GET, (WPARAM)&fontid, (LPARAM)&lf); ColourID colourid = {0}; //use ansi version of ColourID coz POPUPNOTIFICATION use char colourid.cbSize = sizeof(colourid); - mir_snprintf(colourid.group, sizeof(colourid.group), "%s/%s", PU_FNT_AND_COLOR, ptd->notification.lpzGroup); - mir_snprintf(colourid.name, SIZEOF(colourid.name), LPGEN("%s (colors only)"), ptd->notification.lpzName); + mir_snprintf(colourid.group, sizeof(colourid.group), PU_FNT_AND_COLOR"/%s", ptd->notification.lpzGroup); + mir_snprintf(colourid.name, SIZEOF(colourid.name), "%s (colors only)", ptd->notification.lpzName); ppd->colorBack = (COLORREF)CallService(MS_COLOUR_GET, (WPARAM)&colourid, 0); char setting[MAXMODULELABELLENGTH]; - mir_snprintf(setting, sizeof(setting), "%s_%s_%s", MODULNAME, ptd->notification.lpzGroup, ptd->notification.lpzName); + mir_snprintf(setting, sizeof(setting), MODULNAME"_%s_%s", ptd->notification.lpzGroup, ptd->notification.lpzName); ppd->lchIcon = Skin_GetIcon(setting); } diff --git a/plugins/Popup/src/popup_gdiplus.cpp b/plugins/Popup/src/popup_gdiplus.cpp index a3ce6ce41f..f024eaa31e 100644 --- a/plugins/Popup/src/popup_gdiplus.cpp +++ b/plugins/Popup/src/popup_gdiplus.cpp @@ -71,14 +71,11 @@ using namespace Gdiplus; HBITMAP SkinEngine_CreateDIB32(int cx, int cy) { - BITMAPINFO RGB32BitsBITMAPINFO; - UINT * ptPixels; - HBITMAP DirectBitmap; - if ( cx < 0 || cy < 0 ) { return NULL; } + BITMAPINFO RGB32BitsBITMAPINFO; ZeroMemory(&RGB32BitsBITMAPINFO,sizeof(BITMAPINFO)); RGB32BitsBITMAPINFO.bmiHeader.biSize=sizeof(BITMAPINFOHEADER); RGB32BitsBITMAPINFO.bmiHeader.biWidth=cx;//bm.bmWidth; @@ -88,11 +85,8 @@ HBITMAP SkinEngine_CreateDIB32(int cx, int cy) // pointer used for direct Bitmap pixels access - DirectBitmap = CreateDIBSection(NULL, - (BITMAPINFO *)&RGB32BitsBITMAPINFO, - DIB_RGB_COLORS, - (void **)&ptPixels, - NULL, 0); + UINT *ptPixels; + HBITMAP DirectBitmap = CreateDIBSection(NULL, &RGB32BitsBITMAPINFO, DIB_RGB_COLORS, (void **)&ptPixels, NULL, 0); if ((DirectBitmap == NULL || ptPixels == NULL) && cx!= 0 && cy!=0) { ; @@ -109,9 +103,8 @@ BOOL GDIPlus_IsAnimatedGIF(TCHAR * szName) { int nFrameCount=0; Image image(szName); - UINT count = 0; - count = image.GetFrameDimensionsCount(); + UINT count = image.GetFrameDimensionsCount(); GUID* pDimensionIDs = new GUID[count]; // Get the list of frame dimensions from the Image object. diff --git a/plugins/Popup/src/services.cpp b/plugins/Popup/src/services.cpp index f9d69ab9a8..96ab772199 100644 --- a/plugins/Popup/src/services.cpp +++ b/plugins/Popup/src/services.cpp @@ -406,13 +406,13 @@ INT_PTR Popup_RegisterPopupClass(WPARAM, LPARAM lParam) ptd->pupClass.colorText = (COLORREF)db_get_dw(NULL, PU_MODULCLASS, setting, fonts.clText/*pc->colorText*/); FontIDT fid = {0}; fid.cbSize = sizeof(FontIDT); - mir_sntprintf(fid.group, SIZEOF(fid.group), _T("%s/%S"), PU_FNT_AND_COLOR, ptd->pupClass.pszName); - strcpy(fid.dbSettingsGroup, PU_MODULCLASS); + mir_sntprintf(fid.group, SIZEOF(fid.group), _T(PU_FNT_AND_COLOR)_T("/%S"), ptd->pupClass.pszName); + strncpy(fid.dbSettingsGroup, PU_MODULCLASS, SIZEOF(fid.dbSettingsGroup)); fid.flags = FIDF_DEFAULTVALID; fid.deffontsettings.charset = DEFAULT_CHARSET; fid.deffontsettings.size = -11; _tcsncpy(fid.deffontsettings.szFace, _T("Verdana"), SIZEOF(fid.deffontsettings.szFace)); - _tcsncpy(fid.name, PU_FNT_NAME_TEXT, SIZEOF(fid.name)); + _tcsncpy(fid.name, _T(PU_FNT_NAME_TEXT), SIZEOF(fid.name)); strncpy(fid.prefix, setting, SIZEOF(fid.prefix)); mir_snprintf(fid.prefix, sizeof(fid.prefix), "%s/Text", ptd->pupClass.pszName); // result is "%s/TextCol" fid.deffontsettings.style = 0; @@ -424,8 +424,8 @@ INT_PTR Popup_RegisterPopupClass(WPARAM, LPARAM lParam) ptd->pupClass.colorBack = (COLORREF)db_get_dw(NULL, PU_MODULCLASS, setting, (DWORD)fonts.clBack/*pc->colorBack*/); ColourIDT cid = {0}; cid.cbSize = sizeof(ColourIDT); - mir_sntprintf(cid.group, SIZEOF(cid.group), _T("%s/%S"), PU_FNT_AND_COLOR, ptd->pupClass.pszName); - strcpy(cid.dbSettingsGroup, PU_MODULCLASS); + mir_sntprintf(cid.group, SIZEOF(cid.group), _T(PU_FNT_AND_COLOR)_T("/%S"), ptd->pupClass.pszName); + strncpy(cid.dbSettingsGroup, PU_MODULCLASS, SIZEOF(fid.dbSettingsGroup)); _tcsncpy(cid.name, PU_COL_BACK_NAME, SIZEOF(cid.name)); mir_snprintf(cid.setting, sizeof(cid.setting), "%s/BgCol", ptd->pupClass.pszName); cid.defcolour = fonts.clBack; -- cgit v1.2.3