From 4bde5895768659f0d1dad4dddc700ea44d4f96f8 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@4f64403b-2f21-0410-a795-97e2b3489a10> Date: Tue, 5 Oct 2010 05:26:45 +0000 Subject: Completed split up of Unicode and ANSI version git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@542 4f64403b-2f21-0410-a795-97e2b3489a10 --- tipper/tipper.cpp | 372 +++++++++++++++++------------------------------------- 1 file changed, 114 insertions(+), 258 deletions(-) (limited to 'tipper/tipper.cpp') diff --git a/tipper/tipper.cpp b/tipper/tipper.cpp index 6a8600a..206d981 100644 --- a/tipper/tipper.cpp +++ b/tipper/tipper.cpp @@ -9,22 +9,17 @@ #include "popwin.h" #include "str_utils.h" -HMODULE hInst = 0; -HANDLE mainThread = 0; +HMODULE hInst; -bool unicode_system; +FontIDT font_id_title, font_id_labels, font_id_values; +ColourIDT colour_id_bg, colour_id_border, colour_id_divider, colour_id_sidebar; -FontID font_id_title = {0}, font_id_labels = {0}, font_id_values = {0}; -ColourID colour_id_bg = {0}, colour_id_border = {0}, colour_id_divider = {0}, colour_id_sidebar = {0}; -FontIDW font_id_titlew = {0}, font_id_labelsw = {0}, font_id_valuesw = {0}; -ColourIDW colour_id_bgw = {0}, colour_id_borderw = {0}, colour_id_dividerw = {0}, colour_id_sidebarw = {0}; - -HFONT hFontTitle = 0, hFontLabels = 0, hFontValues = 0; +HFONT hFontTitle, hFontLabels, hFontValues; // hooked here so it's in the main thread -HANDLE hAvChangeEvent = 0, hAvContactChangeEvent = 0, hShowTipEvent = 0, hHideTipEvent = 0, hAckEvent = 0, hFramesSBShow = 0, hFramesSBHide = 0, hSettingChangedEvent = 0; - -HANDLE hShowTipService = 0, hShowTipWService = 0, hHideTipService = 0; +HANDLE hAvChangeEvent, hAvContactChangeEvent, hShowTipEvent, hHideTipEvent; +HANDLE hAckEvent, hFramesSBShow, hFramesSBHide, hSettingChangedEvent; +HANDLE hShowTipService, hShowTipWService, hHideTipService; MM_INTERFACE mmi; TIME_API tmi; @@ -48,7 +43,7 @@ PLUGININFOEX pluginInfo={ #endif }; -PLUGINLINK *pluginLink = 0; +PLUGINLINK *pluginLink; extern "C" BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { @@ -62,11 +57,6 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda return &pluginInfo; } -extern "C" __declspec(dllexport) PLUGININFO* MirandaPluginInfo(DWORD mirandaVersion) -{ - pluginInfo.cbSize = sizeof(PLUGININFO); - return (PLUGININFO*)&pluginInfo; -} static const MUUID interfaces[] = {MIID_TOOLTIPS, MIID_LAST}; extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) @@ -78,39 +68,21 @@ extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) int ReloadFont(WPARAM wParam, LPARAM lParam) { - if(ServiceExists(MS_FONT_GETW)) { - LOGFONTW log_font; - if(hFontTitle) DeleteObject(hFontTitle); - options.title_col = CallService(MS_FONT_GETW, (WPARAM)&font_id_titlew, (LPARAM)&log_font); - hFontTitle = CreateFontIndirectW(&log_font); - if(hFontLabels) DeleteObject(hFontLabels); - options.label_col = CallService(MS_FONT_GETW, (WPARAM)&font_id_labelsw, (LPARAM)&log_font); - hFontLabels = CreateFontIndirectW(&log_font); - if(hFontValues) DeleteObject(hFontValues); - options.value_col = CallService(MS_FONT_GETW, (WPARAM)&font_id_valuesw, (LPARAM)&log_font); - hFontValues = CreateFontIndirectW(&log_font); - - options.bg_col = CallService(MS_COLOUR_GETW, (WPARAM)&colour_id_bgw, 0); - options.border_col = CallService(MS_COLOUR_GETW, (WPARAM)&colour_id_borderw, 0); - options.sidebar_col = CallService(MS_COLOUR_GETW, (WPARAM)&colour_id_sidebarw, 0); - options.div_col = CallService(MS_COLOUR_GETW, (WPARAM)&colour_id_dividerw, 0); - } else { - LOGFONTA log_font; - if(hFontTitle) DeleteObject(hFontTitle); - options.title_col = CallService(MS_FONT_GET, (WPARAM)&font_id_title, (LPARAM)&log_font); - hFontTitle = CreateFontIndirectA(&log_font); - if(hFontLabels) DeleteObject(hFontLabels); - options.label_col = CallService(MS_FONT_GET, (WPARAM)&font_id_labels, (LPARAM)&log_font); - hFontLabels = CreateFontIndirectA(&log_font); - if(hFontValues) DeleteObject(hFontValues); - options.value_col = CallService(MS_FONT_GET, (WPARAM)&font_id_values, (LPARAM)&log_font); - hFontValues = CreateFontIndirectA(&log_font); - - options.bg_col = CallService(MS_COLOUR_GET, (WPARAM)&colour_id_bg, 0); - options.border_col = CallService(MS_COLOUR_GET, (WPARAM)&colour_id_border, 0); - options.sidebar_col = CallService(MS_COLOUR_GET, (WPARAM)&colour_id_sidebar, 0); - options.div_col = CallService(MS_COLOUR_GET, (WPARAM)&colour_id_divider, 0); - } + LOGFONT log_font; + if(hFontTitle) DeleteObject(hFontTitle); + options.title_col = CallService(MS_FONT_GETT, (WPARAM)&font_id_title, (LPARAM)&log_font); + hFontTitle = CreateFontIndirect(&log_font); + if(hFontLabels) DeleteObject(hFontLabels); + options.label_col = CallService(MS_FONT_GETT, (WPARAM)&font_id_labels, (LPARAM)&log_font); + hFontLabels = CreateFontIndirect(&log_font); + if(hFontValues) DeleteObject(hFontValues); + options.value_col = CallService(MS_FONT_GETT, (WPARAM)&font_id_values, (LPARAM)&log_font); + hFontValues = CreateFontIndirect(&log_font); + + options.bg_col = CallService(MS_COLOUR_GETT, (WPARAM)&colour_id_bg, 0); + options.border_col = CallService(MS_COLOUR_GETT, (WPARAM)&colour_id_border, 0); + options.sidebar_col = CallService(MS_COLOUR_GETT, (WPARAM)&colour_id_sidebar, 0); + options.div_col = CallService(MS_COLOUR_GETT, (WPARAM)&colour_id_divider, 0); return 0; } @@ -161,202 +133,92 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) { CallService(MS_UPDATE_REGISTER, 0, (WPARAM)&update); } - if(ServiceExists(MS_FONT_REGISTERW)) { - font_id_titlew.cbSize = sizeof(FontIDW); - font_id_titlew.flags = FIDF_ALLOWEFFECTS; - t2w(TranslateT("Tooltips"), font_id_titlew.group, 64); - t2w(TranslateT("Title"), font_id_titlew.name, 64); - strcpy(font_id_titlew.dbSettingsGroup, MODULE); - strcpy(font_id_titlew.prefix, "FontFirst"); - font_id_titlew.order = 0; - - font_id_titlew.deffontsettings.charset = DEFAULT_CHARSET; - font_id_titlew.deffontsettings.size = -14; - font_id_titlew.deffontsettings.style = DBFONTF_BOLD; - font_id_titlew.deffontsettings.colour = RGB(255, 0, 0); - font_id_titlew.flags |= FIDF_DEFAULTVALID; - - font_id_labelsw.cbSize = sizeof(FontIDW); - font_id_labelsw.flags = FIDF_ALLOWEFFECTS; - t2w(TranslateT("Tooltips"), font_id_labelsw.group, 64); - t2w(TranslateT("Labels"), font_id_labelsw.name, 64); - strcpy(font_id_labelsw.dbSettingsGroup, MODULE); - strcpy(font_id_labelsw.prefix, "FontLabels"); - font_id_labelsw.order = 1; - - font_id_labelsw.deffontsettings.charset = DEFAULT_CHARSET; - font_id_labelsw.deffontsettings.size = -12; - font_id_labelsw.deffontsettings.style = DBFONTF_ITALIC; - font_id_labelsw.deffontsettings.colour = RGB(128, 128, 128); - font_id_labelsw.flags |= FIDF_DEFAULTVALID; - - font_id_valuesw.cbSize = sizeof(FontIDW); - font_id_valuesw.flags = FIDF_ALLOWEFFECTS; - t2w(TranslateT("Tooltips"), font_id_valuesw.group, 64); - t2w(TranslateT("Values"), font_id_valuesw.name, 64); - strcpy(font_id_valuesw.dbSettingsGroup, MODULE); - strcpy(font_id_valuesw.prefix, "FontValues"); - font_id_valuesw.order = 2; - - font_id_valuesw.deffontsettings.charset = DEFAULT_CHARSET; - font_id_valuesw.deffontsettings.size = -12; - font_id_valuesw.deffontsettings.style = 0; - font_id_valuesw.deffontsettings.colour = RGB(0, 0, 0); - font_id_valuesw.flags |= FIDF_DEFAULTVALID; - - CallService(MS_FONT_REGISTERW, (WPARAM)&font_id_titlew, 0); - CallService(MS_FONT_REGISTERW, (WPARAM)&font_id_labelsw, 0); - CallService(MS_FONT_REGISTERW, (WPARAM)&font_id_valuesw, 0); - - colour_id_bgw.cbSize = sizeof(ColourIDW); - t2w(TranslateT("Tooltips"), colour_id_bgw.group, 64); - t2w(TranslateT("Background"), colour_id_bgw.name, 64); - strcpy(colour_id_bgw.dbSettingsGroup, MODULE); - strcpy(colour_id_bgw.setting, "ColourBg"); - colour_id_bgw.defcolour = RGB(219, 219, 219); - colour_id_bgw.order = 0; - - colour_id_borderw.cbSize = sizeof(ColourIDW); - t2w(TranslateT("Tooltips"), colour_id_borderw.group, 64); - t2w(TranslateT("Border"), colour_id_borderw.name, 64); - strcpy(colour_id_borderw.dbSettingsGroup, MODULE); - strcpy(colour_id_borderw.setting, "BorderCol"); - colour_id_borderw.defcolour = 0; - colour_id_borderw.order = 0; - - colour_id_dividerw.cbSize = sizeof(ColourIDW); - t2w(TranslateT("Tooltips"), colour_id_dividerw.group, 64); - t2w(TranslateT("Dividers"), colour_id_dividerw.name, 64); - strcpy(colour_id_dividerw.dbSettingsGroup, MODULE); - strcpy(colour_id_dividerw.setting, "DividerCol"); - colour_id_dividerw.defcolour = 0; - colour_id_dividerw.order = 0; - - colour_id_sidebarw.cbSize = sizeof(ColourIDW); - t2w(TranslateT("Tooltips"), colour_id_sidebarw.group, 64); - t2w(TranslateT("Sidebar"), colour_id_sidebarw.name, 64); - strcpy(colour_id_sidebarw.dbSettingsGroup, MODULE); - strcpy(colour_id_sidebarw.setting, "SidebarCol"); - colour_id_sidebarw.defcolour = RGB(192, 192, 192); - colour_id_sidebarw.order = 0; - - CallService(MS_COLOUR_REGISTERW, (WPARAM)&colour_id_bgw, 0); - CallService(MS_COLOUR_REGISTERW, (WPARAM)&colour_id_borderw, 0); - CallService(MS_COLOUR_REGISTERW, (WPARAM)&colour_id_dividerw, 0); - CallService(MS_COLOUR_REGISTERW, (WPARAM)&colour_id_sidebarw, 0); - - ReloadFont(0, 0); - - HookEvent(ME_FONT_RELOAD, ReloadFont); - } else if(ServiceExists(MS_FONT_REGISTER)) { - font_id_title.cbSize = sizeof(FontID); - font_id_title.flags = FIDF_ALLOWEFFECTS; - t2a(TranslateT("Tooltips"), font_id_title.group, 64); - t2a(TranslateT("Title"), font_id_title.name, 64); - strcpy(font_id_title.dbSettingsGroup, MODULE); - strcpy(font_id_title.prefix, "FontFirst"); - font_id_title.order = 0; - - font_id_title.deffontsettings.charset = DEFAULT_CHARSET; - font_id_title.deffontsettings.size = -14; - font_id_title.deffontsettings.style = DBFONTF_BOLD; - font_id_title.deffontsettings.colour = RGB(255, 0, 0); - font_id_title.flags |= FIDF_DEFAULTVALID; - - font_id_labels.cbSize = sizeof(FontID); - font_id_labels.flags = FIDF_ALLOWEFFECTS; - t2a(TranslateT("Tooltips"), font_id_labels.group, 64); - t2a(TranslateT("Labels"), font_id_labels.name, 64); - strcpy(font_id_labels.dbSettingsGroup, MODULE); - strcpy(font_id_labels.prefix, "FontLabels"); - font_id_labels.order = 1; - - font_id_labels.deffontsettings.charset = DEFAULT_CHARSET; - font_id_labels.deffontsettings.size = -12; - font_id_labels.deffontsettings.style = DBFONTF_ITALIC; - font_id_labels.deffontsettings.colour = RGB(128, 128, 128); - font_id_labels.flags |= FIDF_DEFAULTVALID; - - font_id_values.cbSize = sizeof(FontID); - font_id_values.flags = FIDF_ALLOWEFFECTS; - t2a(TranslateT("Tooltips"), font_id_values.group, 64); - t2a(TranslateT("Values"), font_id_values.name, 64); - strcpy(font_id_values.dbSettingsGroup, MODULE); - strcpy(font_id_values.prefix, "FontValues"); - font_id_values.order = 2; - - font_id_values.deffontsettings.charset = DEFAULT_CHARSET; - font_id_values.deffontsettings.size = -12; - font_id_values.deffontsettings.style = 0; - font_id_values.deffontsettings.colour = RGB(0, 0, 0); - font_id_values.flags |= FIDF_DEFAULTVALID; - - CallService(MS_FONT_REGISTER, (WPARAM)&font_id_title, 0); - CallService(MS_FONT_REGISTER, (WPARAM)&font_id_labels, 0); - CallService(MS_FONT_REGISTER, (WPARAM)&font_id_values, 0); - - colour_id_bg.cbSize = sizeof(ColourID); - t2a(TranslateT("Tooltips"), colour_id_bg.group, 64); - t2a(TranslateT("Background"), colour_id_bg.name, 64); - strcpy(colour_id_bg.dbSettingsGroup, MODULE); - strcpy(colour_id_bg.setting, "ColourBg"); - colour_id_bg.defcolour = RGB(219, 219, 219); - colour_id_bg.order = 0; - - colour_id_border.cbSize = sizeof(ColourID); - t2a(TranslateT("Tooltips"), colour_id_border.group, 64); - t2a(TranslateT("Border"), colour_id_border.name, 64); - strcpy(colour_id_border.dbSettingsGroup, MODULE); - strcpy(colour_id_border.setting, "BorderCol"); - colour_id_border.defcolour = 0; - colour_id_border.order = 0; - - colour_id_divider.cbSize = sizeof(ColourID); - t2a(TranslateT("Tooltips"), colour_id_divider.group, 64); - t2a(TranslateT("Dividers"), colour_id_divider.name, 64); - strcpy(colour_id_divider.dbSettingsGroup, MODULE); - strcpy(colour_id_divider.setting, "DividerCol"); - colour_id_divider.defcolour = 0; - colour_id_divider.order = 0; - - colour_id_sidebar.cbSize = sizeof(ColourID); - t2a(TranslateT("Tooltips"), colour_id_sidebar.group, 64); - t2a(TranslateT("Sidebar"), colour_id_sidebar.name, 64); - strcpy(colour_id_sidebar.dbSettingsGroup, MODULE); - strcpy(colour_id_sidebar.setting, "SidebarCol"); - colour_id_sidebar.defcolour = RGB(192, 192, 192); - colour_id_sidebar.order = 0; - - CallService(MS_COLOUR_REGISTER, (WPARAM)&colour_id_bg, 0); - CallService(MS_COLOUR_REGISTER, (WPARAM)&colour_id_border, 0); - CallService(MS_COLOUR_REGISTER, (WPARAM)&colour_id_divider, 0); - CallService(MS_COLOUR_REGISTER, (WPARAM)&colour_id_sidebar, 0); - - ReloadFont(0, 0); - - HookEvent(ME_FONT_RELOAD, ReloadFont); - } else { - options.title_col = RGB(255, 0, 0); options.label_col = RGB(128, 128, 128), options.value_col = 0; - options.bg_col = RGB(219, 219, 219); - options.border_col = options.div_col = 0; - options.sidebar_col = RGB(192, 192, 192); - - LOGFONT lf = {0}; - lf.lfCharSet = DEFAULT_CHARSET; - lf.lfHeight = -14; - lf.lfWeight = FW_BOLD; - hFontTitle = CreateFontIndirect(&lf); - - lf.lfHeight = -12; - lf.lfWeight = 0; - lf.lfItalic = TRUE; - hFontLabels = CreateFontIndirect(&lf); - - lf.lfHeight = -12; - lf.lfWeight = 0; - lf.lfItalic = FALSE; - hFontValues = CreateFontIndirect(&lf); - } + font_id_title.cbSize = sizeof(FontIDT); + font_id_title.flags = FIDF_ALLOWEFFECTS; + _tcscpy(font_id_title.group, LPGENT("Tooltips")); + _tcscpy(font_id_title.name, LPGENT("Title")); + strcpy(font_id_title.dbSettingsGroup, MODULE); + strcpy(font_id_title.prefix, "FontFirst"); + font_id_title.order = 0; + + font_id_title.deffontsettings.charset = DEFAULT_CHARSET; + font_id_title.deffontsettings.size = -14; + font_id_title.deffontsettings.style = DBFONTF_BOLD; + font_id_title.deffontsettings.colour = RGB(255, 0, 0); + font_id_title.flags |= FIDF_DEFAULTVALID; + + font_id_labels.cbSize = sizeof(FontIDT); + font_id_labels.flags = FIDF_ALLOWEFFECTS; + _tcscpy(font_id_labels.group, LPGENT("Tooltips")); + _tcscpy(font_id_labels.name, LPGENT("Labels")); + strcpy(font_id_labels.dbSettingsGroup, MODULE); + strcpy(font_id_labels.prefix, "FontLabels"); + font_id_labels.order = 1; + + font_id_labels.deffontsettings.charset = DEFAULT_CHARSET; + font_id_labels.deffontsettings.size = -12; + font_id_labels.deffontsettings.style = DBFONTF_ITALIC; + font_id_labels.deffontsettings.colour = RGB(128, 128, 128); + font_id_labels.flags |= FIDF_DEFAULTVALID; + + font_id_values.cbSize = sizeof(FontIDT); + font_id_values.flags = FIDF_ALLOWEFFECTS; + _tcscpy(font_id_values.group, LPGENT("Tooltips")); + _tcscpy(font_id_values.name, LPGENT("Values")); + strcpy(font_id_values.dbSettingsGroup, MODULE); + strcpy(font_id_values.prefix, "FontValues"); + font_id_values.order = 2; + + font_id_values.deffontsettings.charset = DEFAULT_CHARSET; + font_id_values.deffontsettings.size = -12; + font_id_values.deffontsettings.style = 0; + font_id_values.deffontsettings.colour = RGB(0, 0, 0); + font_id_values.flags |= FIDF_DEFAULTVALID; + + CallService(MS_FONT_REGISTERT, (WPARAM)&font_id_title, 0); + CallService(MS_FONT_REGISTERT, (WPARAM)&font_id_labels, 0); + CallService(MS_FONT_REGISTERT, (WPARAM)&font_id_values, 0); + + colour_id_bg.cbSize = sizeof(ColourIDT); + _tcscpy(colour_id_bg.group, LPGENT("Tooltips")); + _tcscpy(colour_id_bg.name, LPGENT("Background")); + strcpy(colour_id_bg.dbSettingsGroup, MODULE); + strcpy(colour_id_bg.setting, "ColourBg"); + colour_id_bg.defcolour = RGB(219, 219, 219); + colour_id_bg.order = 0; + + colour_id_border.cbSize = sizeof(ColourIDT); + _tcscpy(colour_id_border.group, LPGENT("Tooltips")); + _tcscpy(colour_id_border.name, LPGENT("Border")); + strcpy(colour_id_border.dbSettingsGroup, MODULE); + strcpy(colour_id_border.setting, "BorderCol"); + colour_id_border.defcolour = 0; + colour_id_border.order = 0; + + colour_id_divider.cbSize = sizeof(ColourIDT); + _tcscpy(colour_id_divider.group, LPGENT("Tooltips")); + _tcscpy(colour_id_divider.name, LPGENT("Dividers")); + strcpy(colour_id_divider.dbSettingsGroup, MODULE); + strcpy(colour_id_divider.setting, "DividerCol"); + colour_id_divider.defcolour = 0; + colour_id_divider.order = 0; + + colour_id_sidebar.cbSize = sizeof(ColourIDT); + _tcscpy(colour_id_sidebar.group, LPGENT("Tooltips")); + _tcscpy(colour_id_sidebar.name, LPGENT("Sidebar")); + strcpy(colour_id_sidebar.dbSettingsGroup, MODULE); + strcpy(colour_id_sidebar.setting, "SidebarCol"); + colour_id_sidebar.defcolour = RGB(192, 192, 192); + colour_id_sidebar.order = 0; + + CallService(MS_COLOUR_REGISTERT, (WPARAM)&colour_id_bg, 0); + CallService(MS_COLOUR_REGISTERT, (WPARAM)&colour_id_border, 0); + CallService(MS_COLOUR_REGISTERT, (WPARAM)&colour_id_divider, 0); + CallService(MS_COLOUR_REGISTERT, (WPARAM)&colour_id_sidebar, 0); + + ReloadFont(0, 0); + + HookEvent(ME_FONT_RELOAD, ReloadFont); hAvChangeEvent = HookEvent(ME_AV_AVATARCHANGED, AvatarChanged); hAvContactChangeEvent = HookEvent(ME_AV_CONTACTAVATARCHANGED, AvatarChanged); @@ -397,13 +259,8 @@ HANDLE hEventPreShutdown, hEventModulesLoaded; extern "C" int TIPPER_API Load(PLUGINLINK *link) { pluginLink = link; - DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &mainThread, 0, FALSE, DUPLICATE_SAME_ACCESS); - set_codepage(); - char szVer[128]; - unicode_system = (CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM)sizeof(szVer), (LPARAM)szVer) == 0 && strstr(szVer, "Unicode")); - mir_getMMI(&mmi); mir_getTMI(&tmi); @@ -425,7 +282,9 @@ extern "C" int TIPPER_API Load(PLUGINLINK *link) { // for compatibility with mToolTip status tooltips hShowTipService = CreateServiceFunction("mToolTip/ShowTip", ShowTip); +#ifdef _UNICODE hShowTipWService = CreateServiceFunction("mToolTip/ShowTipW", ShowTipW); +#endif hHideTipService = CreateServiceFunction("mToolTip/HideTip", HideTip); hEventPreShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, Shutdown); @@ -442,12 +301,9 @@ extern "C" int TIPPER_API Unload() { UnhookEvent(hEventModulesLoaded); DeinitOptions(); - if(ServiceExists(MS_FONT_REGISTERW)) { - DeleteObject(hFontTitle); - DeleteObject(hFontLabels); - DeleteObject(hFontValues); - } // otherwise, no need to delete the handle + DeleteObject(hFontTitle); + DeleteObject(hFontLabels); + DeleteObject(hFontValues); DeinitTranslations(); - CloseHandle(mainThread); return 0; } -- cgit v1.2.3