From df19fbdf4e4dac7dbcd6735472eb66efd02850e2 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 26 Jul 2014 16:08:22 +0000 Subject: all clists to inherit the kernel settings loading code git-svn-id: http://svn.miranda-ng.org/main/trunk@9948 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Clist_modern/src/modern_clcutils.cpp | 25 +----------- plugins/Clist_nicer/src/clcutils.cpp | 61 +++++++++++++++++++--------- src/core/stdclist/src/clcfonts.cpp | 40 ++++++++++++++++++ src/core/stdclist/src/commonheaders.h | 11 +---- src/core/stdclist/src/init.cpp | 6 ++- src/modules/clist/clcutils.cpp | 36 +--------------- 6 files changed, 89 insertions(+), 90 deletions(-) diff --git a/plugins/Clist_modern/src/modern_clcutils.cpp b/plugins/Clist_modern/src/modern_clcutils.cpp index 5d5149c840..4d9ce604f9 100644 --- a/plugins/Clist_modern/src/modern_clcutils.cpp +++ b/plugins/Clist_modern/src/modern_clcutils.cpp @@ -657,24 +657,13 @@ void LoadCLCOptions(HWND hwnd, ClcData *dat, BOOL bFirst) dat->third_line_use_name_and_message_for_xstatus = 0; } - dat->leftMargin = db_get_b(NULL, "CLC", "LeftMargin", CLCDEFAULT_LEFTMARGIN); dat->rightMargin = db_get_b(NULL, "CLC", "RightMargin", CLCDEFAULT_RIGHTMARGIN); - dat->exStyle = db_get_dw(NULL, "CLC", "ExStyle", GetDefaultExStyle()); - dat->scrollTime = db_get_w(NULL, "CLC", "ScrollTime", CLCDEFAULT_SCROLLTIME); dat->force_in_dialog = (pcli->hwndContactTree) ? (hwnd != pcli->hwndContactTree) : 0; - dat->groupIndent = db_get_b(NULL, "CLC", "GroupIndent", CLCDEFAULT_GROUPINDENT); dat->subIndent = db_get_b(NULL, "CLC", "SubIndent", CLCDEFAULT_GROUPINDENT); - dat->gammaCorrection = db_get_b(NULL, "CLC", "GammaCorrect", CLCDEFAULT_GAMMACORRECT); - dat->showIdle = db_get_b(NULL, "CLC", "ShowIdle", CLCDEFAULT_SHOWIDLE); - dat->noVScrollbar = db_get_b(NULL, "CLC", "NoVScrollBar", CLCDEFAULT_NOVSCROLL); - dat->filterSearch = db_get_b(NULL, "CLC", "FilterSearch", 0); - SendMessage(hwnd, INTM_SCROLLBARCHANGED, 0, 0); if (dat->hBmpBackground) { DeleteObject(dat->hBmpBackground); dat->hBmpBackground = NULL; } if (dat->hMenuBackground) { DeleteObject(dat->hMenuBackground); dat->hMenuBackground = NULL; } - dat->useWindowsColours = db_get_b(NULL, "CLC", "UseWinColours", CLCDEFAULT_USEWINDOWSCOLOURS); - if (g_CluiData.fDisableSkinEngine) { if (!dat->bkChanged) { dat->bkColour = sttGetColor("CLC", "BkColour", GetSysColor(COLOR_3DFACE)); @@ -700,12 +689,6 @@ void LoadCLCOptions(HWND hwnd, ClcData *dat, BOOL bFirst) dat->MenuBmpUse = db_get_w(NULL, "Menu", "BkBmpUse", CLCDEFAULT_BKBMPUSE); } - dat->greyoutFlags = db_get_dw(NULL, "CLC", "GreyoutFlags", CLCDEFAULT_GREYOUTFLAGS); - dat->offlineModes = db_get_dw(NULL, "CLC", "OfflineModes", CLCDEFAULT_OFFLINEMODES); - dat->selBkColour = sttGetColor("CLC", "SelBkColour", CLCDEFAULT_SELBKCOLOUR); - dat->selTextColour = db_get_dw(NULL, "CLC", "SelTextColour", CLCDEFAULT_MODERN_SELTEXTCOLOUR); - dat->hotTextColour = db_get_dw(NULL, "CLC", "HotTextColour", CLCDEFAULT_MODERN_HOTTEXTCOLOUR); - dat->quickSearchColour = db_get_dw(NULL, "CLC", "QuickSearchColour", CLCDEFAULT_MODERN_QUICKSEARCHCOLOUR); dat->IsMetaContactsEnabled = (!(GetWindowLongPtr(hwnd, GWL_STYLE)&CLS_MANUALUPDATE)) && db_get_b(NULL, META_PROTO, "Enabled", 1); if (pcli->hwndContactTree == NULL || dat->hWnd == pcli->hwndContactTree) @@ -725,13 +708,7 @@ void LoadCLCOptions(HWND hwnd, ClcData *dat, BOOL bFirst) if ((pcli->hwndContactTree == hwnd || pcli->hwndContactTree == NULL)) IvalidateDisplayNameCache(16); - NMHDR hdr; - hdr.code = CLN_OPTIONSCHANGED; - hdr.hwndFrom = hwnd; - hdr.idFrom = (bFirst) ? 0 : GetDlgCtrlID(hwnd); - SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM)&hdr); - - SendMessage(hwnd, WM_SIZE, 0, 0); + corecli.pfnLoadClcOptions(hwnd, dat, bFirst); } int ExpandMetaContact(HWND hwnd, ClcContact *contact, ClcData *dat, BOOL bExpand) diff --git a/plugins/Clist_nicer/src/clcutils.cpp b/plugins/Clist_nicer/src/clcutils.cpp index 65cb2954a6..80bb802e79 100644 --- a/plugins/Clist_nicer/src/clcutils.cpp +++ b/plugins/Clist_nicer/src/clcutils.cpp @@ -544,9 +544,26 @@ void BeginRenameSelection(HWND hwnd, struct ClcData *dat) void LoadClcOptions(HWND hwnd, struct ClcData *dat, BOOL bFirst) { - dat->bkChanged = 0; + HDC hdc = GetDC(hwnd); + for (int i = 0; i <= FONTID_MAX; i++) { + if (!dat->fontInfo[i].changed) + DeleteObject(dat->fontInfo[i].hFont); - coreCli.pfnLoadClcOptions(hwnd, dat, bFirst); + LOGFONT lf; + pcli->pfnGetFontSetting(i, &lf, &dat->fontInfo[i].colour); + lf.lfHeight = -MulDiv(lf.lfHeight, GetDeviceCaps(hdc, LOGPIXELSY), 72); + + dat->fontInfo[i].hFont = CreateFontIndirect(&lf); + dat->fontInfo[i].changed = 0; + + HFONT holdfont = (HFONT)SelectObject(hdc, dat->fontInfo[i].hFont); + SIZE fontSize; + GetTextExtentPoint32(hdc, _T("x"), 1, &fontSize); + SelectObject(hdc, holdfont); + + dat->fontInfo[i].fontHeight = fontSize.cy; + } + ReleaseDC(hwnd, hdc); dat->min_row_heigh = (int)cfg::getByte("CLC","RowHeight",CLCDEFAULT_ROWHEIGHT); dat->group_row_height = (int)cfg::getByte("CLC","GRowHeight",CLCDEFAULT_ROWHEIGHT); @@ -554,27 +571,29 @@ void LoadClcOptions(HWND hwnd, struct ClcData *dat, BOOL bFirst) dat->rightMargin = cfg::getByte("CLC", "RightMargin", CLCDEFAULT_LEFTMARGIN); dat->bkColour = cfg::getByte("CLC", "UseWinColours", CLCDEFAULT_USEWINDOWSCOLOURS) ? GetSysColor(COLOR_3DFACE) : cfg::getDword("CLC", "BkColour", CLCDEFAULT_BKCOLOUR); - if ( !dat->bkChanged) { - if (cfg::dat.hBrushCLCBk) - DeleteObject(cfg::dat.hBrushCLCBk); - cfg::dat.hBrushCLCBk = CreateSolidBrush(dat->bkColour); - if (dat->hBmpBackground) { - if (cfg::dat.hdcPic) { - SelectObject(cfg::dat.hdcPic, cfg::dat.hbmPicOld); - DeleteDC(cfg::dat.hdcPic); - cfg::dat.hdcPic = 0; - cfg::dat.hbmPicOld = 0; - } } - cfg::dat.bmpBackground = dat->hBmpBackground; - if (cfg::dat.bmpBackground) { - HDC hdcThis = GetDC(pcli->hwndContactList); - GetObject(cfg::dat.bmpBackground, sizeof(cfg::dat.bminfoBg), &(cfg::dat.bminfoBg)); - cfg::dat.hdcPic = CreateCompatibleDC(hdcThis); - cfg::dat.hbmPicOld = reinterpret_cast(SelectObject(cfg::dat.hdcPic, cfg::dat.bmpBackground)); - ReleaseDC(pcli->hwndContactList, hdcThis); + dat->bkChanged = 0; + if (cfg::dat.hBrushCLCBk) + DeleteObject(cfg::dat.hBrushCLCBk); + cfg::dat.hBrushCLCBk = CreateSolidBrush(dat->bkColour); + if (dat->hBmpBackground) { + if (cfg::dat.hdcPic) { + SelectObject(cfg::dat.hdcPic, cfg::dat.hbmPicOld); + DeleteDC(cfg::dat.hdcPic); + cfg::dat.hdcPic = 0; + cfg::dat.hbmPicOld = 0; } } + + cfg::dat.bmpBackground = dat->hBmpBackground; + if (cfg::dat.bmpBackground) { + HDC hdcThis = GetDC(pcli->hwndContactList); + GetObject(cfg::dat.bmpBackground, sizeof(cfg::dat.bminfoBg), &(cfg::dat.bminfoBg)); + cfg::dat.hdcPic = CreateCompatibleDC(hdcThis); + cfg::dat.hbmPicOld = reinterpret_cast(SelectObject(cfg::dat.hdcPic, cfg::dat.bmpBackground)); + ReleaseDC(pcli->hwndContactList, hdcThis); + } + if (cfg::getByte("CLCExt", "EXBK_FillWallpaper", 0)) { char wpbuf[MAX_PATH]; if (dat->hBmpBackground) { @@ -597,4 +616,6 @@ void LoadClcOptions(HWND hwnd, struct ClcData *dat, BOOL bFirst) ReleaseDC(pcli->hwndContactList, hdcThis); } } + + coreCli.pfnLoadClcOptions(hwnd, dat, bFirst); } diff --git a/src/core/stdclist/src/clcfonts.cpp b/src/core/stdclist/src/clcfonts.cpp index 3951ca6cc4..593f37cb3b 100644 --- a/src/core/stdclist/src/clcfonts.cpp +++ b/src/core/stdclist/src/clcfonts.cpp @@ -112,3 +112,43 @@ void RegisterCListFonts() HookEvent(ME_FONT_RELOAD, FS_FontsChanged); } + +void LoadClcOptions(HWND hwnd, struct ClcData *dat, BOOL bFirst) +{ + HDC hdc = GetDC(hwnd); + for (int i = 0; i <= FONTID_MAX; i++) { + if (!dat->fontInfo[i].changed) + DeleteObject(dat->fontInfo[i].hFont); + + LOGFONT lf; + pcli->pfnGetFontSetting(i, &lf, &dat->fontInfo[i].colour); + lf.lfHeight = -MulDiv(lf.lfHeight, GetDeviceCaps(hdc, LOGPIXELSY), 72); + + dat->fontInfo[i].hFont = CreateFontIndirect(&lf); + dat->fontInfo[i].changed = 0; + + HFONT holdfont = (HFONT)SelectObject(hdc, dat->fontInfo[i].hFont); + SIZE fontSize; + GetTextExtentPoint32(hdc, _T("x"), 1, &fontSize); + SelectObject(hdc, holdfont); + + dat->fontInfo[i].fontHeight = fontSize.cy; + } + ReleaseDC(hwnd, hdc); + + if (!dat->bkChanged) { + dat->bkColour = db_get_dw(NULL, "CLC", "BkColour", CLCDEFAULT_BKCOLOUR); + if (dat->hBmpBackground) { + DeleteObject(dat->hBmpBackground); + dat->hBmpBackground = NULL; + } + if (db_get_b(NULL, "CLC", "UseBitmap", CLCDEFAULT_USEBITMAP)) { + ptrA szBitmap(db_get_sa(NULL, "CLC", "BkBitmap")); + if (szBitmap) + dat->hBmpBackground = (HBITMAP)CallService(MS_UTILS_LOADBITMAP, 0, szBitmap); + } + dat->backgroundBmpUse = db_get_w(NULL, "CLC", "BkBmpUse", CLCDEFAULT_BKBMPUSE); + } + + coreCli.pfnLoadClcOptions(hwnd, dat, bFirst); +} diff --git a/src/core/stdclist/src/commonheaders.h b/src/core/stdclist/src/commonheaders.h index 45828cfa1b..cc2dfa7d4a 100644 --- a/src/core/stdclist/src/commonheaders.h +++ b/src/core/stdclist/src/commonheaders.h @@ -64,13 +64,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // shared vars extern HINSTANCE g_hInst; +extern CLIST_INTERFACE coreCli; -/* most free()'s are invalid when the code is executed from a dll, so this changes - all the bad free()'s to good ones, however it's still incorrect code. The reasons for not - changing them include: - - * db_free has a CallService() lookup - * free() is executed in some large loops to do with clist creation of group data - * easy search and replace - -*/ +void LoadClcOptions(HWND hwnd, struct ClcData *dat, BOOL bFirst); diff --git a/src/core/stdclist/src/init.cpp b/src/core/stdclist/src/init.cpp index 7ec9cfebc4..f84aca0ff1 100644 --- a/src/core/stdclist/src/init.cpp +++ b/src/core/stdclist/src/init.cpp @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "commonheaders.h" HINSTANCE g_hInst = 0; -CLIST_INTERFACE* pcli = NULL; +CLIST_INTERFACE* pcli = NULL, coreCli; HIMAGELIST himlCListClc = NULL; int hLangpack; @@ -135,8 +135,10 @@ extern "C" __declspec(dllexport) int CListInitialise() mir_getLP( &pluginInfo ); mir_getCLI(); + coreCli = *pcli; pcli->hInst = g_hInst; pcli->pfnPaintClc = PaintClc; + pcli->pfnLoadClcOptions = LoadClcOptions; CreateServiceFunction(MS_CLIST_GETSTATUSMODE, GetStatusMode); @@ -162,4 +164,4 @@ extern "C" __declspec(dllexport) int Load(void) extern "C" __declspec(dllexport) int Unload(void) { return 0; -} \ No newline at end of file +} diff --git a/src/modules/clist/clcutils.cpp b/src/modules/clist/clcutils.cpp index f31aecedd0..0a155c8e22 100644 --- a/src/modules/clist/clcutils.cpp +++ b/src/modules/clist/clcutils.cpp @@ -719,28 +719,6 @@ void fnLoadClcOptions(HWND hwnd, struct ClcData *dat, BOOL bFirst) { dat->rowHeight = db_get_b(NULL, "CLC", "RowHeight", CLCDEFAULT_ROWHEIGHT); - LOGFONT lf; - SIZE fontSize; - - HDC hdc = GetDC(hwnd); - for (int i=0; i <= FONTID_MAX; i++) { - if (!dat->fontInfo[i].changed) - DeleteObject(dat->fontInfo[i].hFont); - - cli.pfnGetFontSetting(i, &lf, &dat->fontInfo[i].colour); - lf.lfHeight = -MulDiv(lf.lfHeight, GetDeviceCaps(hdc, LOGPIXELSY), 72); - - dat->fontInfo[i].hFont = CreateFontIndirect(&lf); - dat->fontInfo[i].changed = 0; - - HFONT holdfont = (HFONT)SelectObject(hdc, dat->fontInfo[i].hFont); - GetTextExtentPoint32(hdc, _T("x"), 1, &fontSize); - SelectObject(hdc, holdfont); - - dat->fontInfo[i].fontHeight = fontSize.cy; - } - ReleaseDC(hwnd, hdc); - dat->leftMargin = db_get_b(NULL, "CLC", "LeftMargin", CLCDEFAULT_LEFTMARGIN); dat->exStyle = db_get_dw(NULL, "CLC", "ExStyle", cli.pfnGetDefaultExStyle()); dat->scrollTime = db_get_w(NULL, "CLC", "ScrollTime", CLCDEFAULT_SCROLLTIME); @@ -750,19 +728,7 @@ void fnLoadClcOptions(HWND hwnd, struct ClcData *dat, BOOL bFirst) dat->noVScrollbar = db_get_b(NULL, "CLC", "NoVScrollBar", 0); dat->filterSearch = db_get_b(NULL, "CLC", "FilterSearch", 1); SendMessage(hwnd, INTM_SCROLLBARCHANGED, 0, 0); - if (!dat->bkChanged) { - dat->bkColour = db_get_dw(NULL, "CLC", "BkColour", CLCDEFAULT_BKCOLOUR); - if (dat->hBmpBackground) { - DeleteObject(dat->hBmpBackground); - dat->hBmpBackground = NULL; - } - if (db_get_b(NULL, "CLC", "UseBitmap", CLCDEFAULT_USEBITMAP)) { - ptrA szBitmap(db_get_sa(NULL, "CLC", "BkBitmap")); - if (szBitmap) - dat->hBmpBackground = (HBITMAP)CallService(MS_UTILS_LOADBITMAP, 0, szBitmap); - } - dat->backgroundBmpUse = db_get_w(NULL, "CLC", "BkBmpUse", CLCDEFAULT_BKBMPUSE); - } + dat->greyoutFlags = db_get_dw(NULL, "CLC", "GreyoutFlags", CLCDEFAULT_GREYOUTFLAGS); dat->offlineModes = db_get_dw(NULL, "CLC", "OfflineModes", CLCDEFAULT_OFFLINEMODES); dat->selBkColour = db_get_dw(NULL, "CLC", "SelBkColour", CLCDEFAULT_SELBKCOLOUR); -- cgit v1.2.3