From f8f8072f5195d00bdd8967f291c680643659d919 Mon Sep 17 00:00:00 2001 From: sje Date: Wed, 29 Nov 2006 14:29:15 +0000 Subject: added font service entry for tab labels git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@69 4f64403b-2f21-0410-a795-97e2b3489a10 --- justtabs/justtabs.cpp | 62 ++++++++++++++++++++++++++++++++++++++++++++++---- justtabs/justtabs.mdsp | 11 +++++---- justtabs/options.cpp | 2 +- justtabs/win.cpp | 15 +++++++----- justtabs/win.h | 4 ++++ 5 files changed, 79 insertions(+), 15 deletions(-) diff --git a/justtabs/justtabs.cpp b/justtabs/justtabs.cpp index 6b76e8d..9b7c6a4 100644 --- a/justtabs/justtabs.cpp +++ b/justtabs/justtabs.cpp @@ -18,10 +18,14 @@ HANDLE hEventClistDblClick, hEventWindow, hEventIconChanged; typedef LRESULT (CALLBACK *WNDPROC)(HWND, UINT, WPARAM, LPARAM); +FontID font_id_tabs = {0}; +FontIDW font_id_tabsw = {0}; +HFONT hFontTabs = 0; + PLUGININFO pluginInfo={ sizeof(PLUGININFO), MODULE, - PLUGIN_MAKE_VERSION(0,0,2,2), + PLUGIN_MAKE_VERSION(0,0,2,3), "Put SRMM windows into a single frame", "Scott Ellis", "mail@scottellis.com.au", @@ -75,8 +79,8 @@ void ShowPopup(HANDLE hContact, const char *msg) { lpzContactName = (char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,0); - lstrcpy(ppd.lpzContactName, lpzContactName); - lstrcpy(ppd.lpzText, msg); + strcpy(ppd.lpzContactName, lpzContactName); + strcpy(ppd.lpzText, msg); ppd.colorBack = GetSysColor(COLOR_BTNFACE);; ppd.colorText = RGB(0,0,0); ppd.PluginWindowProc = (WNDPROC)PopupDlgProc; @@ -119,6 +123,22 @@ int ContactIconChanged(WPARAM wParam, LPARAM lParam) { return 0; } +int ReloadFont(WPARAM wParam, LPARAM lParam) { + if(ServiceExists(MS_FONT_GETW)) { + LOGFONTW log_font; + if(hFontTabs) DeleteObject(hFontTabs); + CallService(MS_FONT_GETW, (WPARAM)&font_id_tabsw, (LPARAM)&log_font); + hFontTabs = CreateFontIndirectW(&log_font); + } else { + LOGFONTA log_font; + if(hFontTabs) DeleteObject(hFontTabs); + CallService(MS_FONT_GET, (WPARAM)&font_id_tabs, (LPARAM)&log_font); + hFontTabs = CreateFontIndirectA(&log_font); + } + SendMessage(pluginwind, WM_FONTRELOAD, 0, 0); + return 0; +} + static int MainInit(WPARAM wParam,LPARAM lParam) { if(ServiceExists(MS_UPDATE_REGISTER)) { // register with updater @@ -147,13 +167,47 @@ static int MainInit(WPARAM wParam,LPARAM lParam) { } // plugin only works for srmm classic - if(GetModuleHandle("srmm")) { + if(GetModuleHandle(_T("srmm"))) { CreateFrame((HWND)CallService(MS_CLUI_GETHWND, 0, 0), hInst); hEventWindow = HookEvent(ME_MSG_WINDOWEVENT, WindowEvent); hEventClistDblClick = HookEvent(ME_CLIST_DOUBLECLICKED, ClistDblClick); hEventIconChanged = HookEvent(ME_CLIST_CONTACTICONCHANGED, ContactIconChanged); } + if(ServiceExists(MS_FONT_REGISTERW)) { + font_id_tabsw.cbSize = sizeof(FontIDW); + font_id_tabsw.flags = FIDF_ALLOWEFFECTS; + //wcsncpy(font_id_tabsw.group, TranslateW("Container"), 64); + //wcsncpy(font_id_tabsw.name, TranslateW("Tabs"), 64); + wcsncpy(font_id_tabsw.group, TranslateW(L"Container"), 64); + wcsncpy(font_id_tabsw.name, TranslateW(L"Tabs"), 64); + strcpy(font_id_tabsw.dbSettingsGroup, MODULE); + strcpy(font_id_tabsw.prefix, "FontTabs"); + font_id_tabsw.order = 0; + + CallService(MS_FONT_REGISTERW, (WPARAM)&font_id_tabsw, 0); + ReloadFont(0, 0); + HookEvent(ME_FONT_RELOAD, ReloadFont); + } else if(ServiceExists(MS_FONT_REGISTER)) { + font_id_tabs.cbSize = sizeof(FontID); + font_id_tabs.flags = FIDF_ALLOWEFFECTS; + strncpy(font_id_tabs.group, Translate("Container"), 64); + strncpy(font_id_tabs.name, Translate("Tabs"), 64); + strcpy(font_id_tabs.dbSettingsGroup, MODULE); + strcpy(font_id_tabs.prefix, "FontTabs"); + font_id_tabs.order = 0; + + CallService(MS_FONT_REGISTER, (WPARAM)&font_id_tabs, 0); + ReloadFont(0, 0); + HookEvent(ME_FONT_RELOAD, ReloadFont); + } else { + LOGFONT lf = {0}; + lf.lfCharSet = DEFAULT_CHARSET; + lf.lfHeight = -14; + lf.lfWeight = FW_BOLD; + hFontTabs = CreateFontIndirect(&lf); + } + return 0; } diff --git a/justtabs/justtabs.mdsp b/justtabs/justtabs.mdsp index 2ccd298..4ed3d97 100644 --- a/justtabs/justtabs.mdsp +++ b/justtabs/justtabs.mdsp @@ -10,7 +10,7 @@ workingDirectory= arguments= intermediateFilesDirectory=Debug outputFilesDirectory=Debug -compilerPreprocessor= +compilerPreprocessor=_UNICODE, UNICODE extraCompilerOptions= compilerIncludeDirectory=..\..\include noWarning=0 @@ -48,7 +48,7 @@ workingDirectory= arguments= intermediateFilesDirectory=Release outputFilesDirectory=Release -compilerPreprocessor= +compilerPreprocessor=_UNICODE, UNICODE extraCompilerOptions= compilerIncludeDirectory=..\..\include noWarning=0 @@ -92,5 +92,8 @@ extraResourceOptions= 1=resource.rc [Other] [History] -justtabs.cpp,979 -win.cpp,25753 +options.cpp,1924 +..\..\include\m_fontservice.h,0 +..\tipper\tipper.cpp,7257 +win.cpp,15080 +justtabs.cpp,6924 diff --git a/justtabs/options.cpp b/justtabs/options.cpp index 5175cc7..985fd6c 100644 --- a/justtabs/options.cpp +++ b/justtabs/options.cpp @@ -58,7 +58,7 @@ int OptInit(WPARAM wParam,LPARAM lParam) odp.cbSize = sizeof(odp); odp.position = -790000000; odp.hInstance = hInst; - odp.pszTemplate = MAKEINTRESOURCE(IDD_OPT1); + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT1); odp.pszTitle = Translate("Messaging Tabs"); odp.pszGroup = Translate("Events"); odp.flags = ODPF_BOLDGROUPS; diff --git a/justtabs/win.cpp b/justtabs/win.cpp index e2f286c..b85cd9c 100644 --- a/justtabs/win.cpp +++ b/justtabs/win.cpp @@ -124,12 +124,6 @@ BOOL CALLBACK FrameProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { TabCtrl_SetImageList(tab_ctrl, clist_imagelist); - LOGFONT lf; - SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &lf, FALSE); - lf.lfHeight = -12; - HFONT hFont = CreateFontIndirect(&lf); - SendMessage(tab_ctrl, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0)); - SubclassTabCtrl(tab_ctrl); active_window = 0; @@ -513,6 +507,15 @@ BOOL CALLBACK FrameProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { } } break; + case WM_FONTRELOAD: + //LOGFONT lf; + //SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &lf, FALSE); + //lf.lfHeight = -12; + //HFONT hFont = CreateFontIndirect(&lf); + SendMessage(tab_ctrl, WM_SETFONT, (WPARAM)hFontTabs, MAKELPARAM(TRUE, 0)); + //RedrawWindow(hwnd, 0, 0, RDW_INVALIDATE); + SendMessage(hwnd, WM_SIZE, 0, 0); + return TRUE; } //return DefWindowProc(hwnd, msg, wParam, lParam); diff --git a/justtabs/win.h b/justtabs/win.h index 14f2cf5..9d3902f 100644 --- a/justtabs/win.h +++ b/justtabs/win.h @@ -24,6 +24,7 @@ #include #include #include +#include #define MODULE "JustTabs" @@ -36,6 +37,7 @@ extern HINSTANCE hInst; #define WM_SHOWCONTACTWND (WM_USER + 0x202) #define WM_HIGHLIGHTCONTACTWND (WM_USER + 0x203) #define WM_RESETTABICONS (WM_USER + 0x204) +#define WM_FONTRELOAD (WM_USER + 0x205) #define STYLE_TITLE ((DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME) & ~WS_VISIBLE) #define STYLE_NOTITLE ((DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_THICKFRAME) & ~WS_VISIBLE) @@ -45,4 +47,6 @@ int CreateFrame(HWND parent, HINSTANCE hInst); void FixWindowStyle(); +extern HFONT hFontTabs; + #endif -- cgit v1.2.3