From 1e92bf5cf72665b5fec103a0a70d734340725539 Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Tue, 24 Jul 2012 09:26:39 +0000 Subject: StopSpamPlus, TipperYM, TooltipNotify, TopToolBar, TranslitSwitcher, UserGuide: changed folder structure git-svn-id: http://svn.miranda-ng.org/main/trunk@1159 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- .../StopSpamPlus/docs/stopspamplus-translation.txt | 33 + plugins/StopSpamPlus/headers.h | 71 - plugins/StopSpamPlus/res/resource.h | 33 - plugins/StopSpamPlus/res/stopspam.rc | 4 +- plugins/StopSpamPlus/res/version.h | 51 - plugins/StopSpamPlus/res/version.rc | 2 +- plugins/StopSpamPlus/src/events.cpp | 2 +- plugins/StopSpamPlus/src/headers.h | 71 + plugins/StopSpamPlus/src/opt_proto.cpp | 2 +- plugins/StopSpamPlus/src/options.cpp | 2 +- plugins/StopSpamPlus/src/resource.h | 33 + plugins/StopSpamPlus/src/services.cpp | 2 +- plugins/StopSpamPlus/src/settings.cpp | 2 +- plugins/StopSpamPlus/src/settings.h | 2 +- plugins/StopSpamPlus/src/stopspam.cpp | 2 +- plugins/StopSpamPlus/src/utils.cpp | 2 +- plugins/StopSpamPlus/src/version.h | 51 + plugins/StopSpamPlus/stopspam_10.vcxproj | 14 +- plugins/StopSpamPlus/stopspam_10.vcxproj.filters | 8 +- plugins/StopSpamPlus/stopspamplus-translation.txt | 33 - plugins/TipperYM/bitmap_func.cpp | 776 ------ plugins/TipperYM/bitmap_func.h | 71 - plugins/TipperYM/common.h | 103 - plugins/TipperYM/docs/tipperym-translation.txt | 352 +++ plugins/TipperYM/message_pump.cpp | 413 ---- plugins/TipperYM/message_pump.h | 71 - plugins/TipperYM/mir_smileys.cpp | 514 ---- plugins/TipperYM/mir_smileys.h | 70 - plugins/TipperYM/options.cpp | 2495 -------------------- plugins/TipperYM/options.h | 196 -- plugins/TipperYM/popwin.cpp | 2016 ---------------- plugins/TipperYM/popwin.h | 140 -- plugins/TipperYM/preset_items.cpp | 131 - plugins/TipperYM/preset_items.h | 57 - plugins/TipperYM/res/resource.rc | 386 +++ plugins/TipperYM/res/version.rc | 40 + plugins/TipperYM/resource.h | 137 -- plugins/TipperYM/resource.rc | 386 --- plugins/TipperYM/skin_parser.cpp | 417 ---- plugins/TipperYM/skin_parser.h | 30 - plugins/TipperYM/src/bitmap_func.cpp | 776 ++++++ plugins/TipperYM/src/bitmap_func.h | 71 + plugins/TipperYM/src/common.h | 105 + plugins/TipperYM/src/message_pump.cpp | 413 ++++ plugins/TipperYM/src/message_pump.h | 71 + plugins/TipperYM/src/mir_smileys.cpp | 514 ++++ plugins/TipperYM/src/mir_smileys.h | 70 + plugins/TipperYM/src/options.cpp | 2495 ++++++++++++++++++++ plugins/TipperYM/src/options.h | 196 ++ plugins/TipperYM/src/popwin.cpp | 2016 ++++++++++++++++ plugins/TipperYM/src/popwin.h | 140 ++ plugins/TipperYM/src/preset_items.cpp | 131 + plugins/TipperYM/src/preset_items.h | 57 + plugins/TipperYM/src/resource.h | 137 ++ plugins/TipperYM/src/skin_parser.cpp | 417 ++++ plugins/TipperYM/src/skin_parser.h | 30 + plugins/TipperYM/src/str_utils.cpp | 231 ++ plugins/TipperYM/src/str_utils.h | 66 + plugins/TipperYM/src/subst.cpp | 1011 ++++++++ plugins/TipperYM/src/subst.h | 47 + plugins/TipperYM/src/tipper.cpp | 362 +++ plugins/TipperYM/src/translations.cpp | 744 ++++++ plugins/TipperYM/src/translations.h | 125 + plugins/TipperYM/src/version.h | 4 + plugins/TipperYM/str_utils.cpp | 231 -- plugins/TipperYM/str_utils.h | 66 - plugins/TipperYM/subst.cpp | 1011 -------- plugins/TipperYM/subst.h | 47 - plugins/TipperYM/tipper.cpp | 362 --- plugins/TipperYM/tipper_ym_10.vcxproj | 73 +- plugins/TipperYM/tipper_ym_10.vcxproj.filters | 75 +- plugins/TipperYM/tipperym-translation.txt | 352 --- plugins/TipperYM/translations.cpp | 744 ------ plugins/TipperYM/translations.h | 125 - plugins/TipperYM/version.h | 4 - plugins/TipperYM/version.rc | 40 - plugins/TooltipNotify/doc/todo.txt | 0 plugins/TooltipNotify/doc/tt_wnd_def_style.txt | 9 - plugins/TooltipNotify/doc/ttnotify-readme.txt | 128 - plugins/TooltipNotify/doc/ttnotify_translation.txt | 47 - plugins/TooltipNotify/docs/todo.txt | 0 .../docs/tooltipnotify-translation.txt | 55 + plugins/TooltipNotify/docs/tt_wnd_def_style.txt | 9 + plugins/TooltipNotify/docs/ttnotify-readme.txt | 128 + .../TooltipNotify/docs/ttnotify_translation.txt | 47 + plugins/TooltipNotify/res/main.rc | 204 ++ plugins/TooltipNotify/res/version.rc | 53 + plugins/TooltipNotify/src/main.rc | 204 -- plugins/TooltipNotify/src/version.rc | 52 - .../TooltipNotify/tooltipnotify-translation.txt | 55 - plugins/TooltipNotify/ttnotify_10.vcxproj | 17 +- plugins/TooltipNotify/ttnotify_10.vcxproj.filters | 61 +- plugins/TopToolBar/BkgrCfg.h | 18 - plugins/TopToolBar/InternalButtons.cpp | 121 - plugins/TopToolBar/TopToolBar.vcxproj | 114 +- plugins/TopToolBar/TopToolBar.vcxproj.filters | 62 +- plugins/TopToolBar/bmp/sep.bmp | Bin 1194 -> 0 bytes plugins/TopToolBar/common.h | 157 -- plugins/TopToolBar/docs/toptoolbar-translation.txt | 40 + plugins/TopToolBar/docs/ttb-readme.txt | 160 ++ plugins/TopToolBar/icos/Find_Add Contacts_UP.ico | Bin 2038 -> 0 bytes plugins/TopToolBar/icos/Groups On_Off_DN.ico | Bin 2038 -> 0 bytes plugins/TopToolBar/icos/Groups On_Off_UP.ico | Bin 2038 -> 0 bytes plugins/TopToolBar/icos/Minimize Button_UP.ico | Bin 2038 -> 0 bytes plugins/TopToolBar/icos/Run.ico | Bin 1406 -> 0 bytes plugins/TopToolBar/icos/Show Main Menu_UP.ico | Bin 2038 -> 0 bytes plugins/TopToolBar/icos/Show Options Page_UP.ico | Bin 2038 -> 0 bytes .../TopToolBar/icos/Show only Online Users_DN.ico | Bin 2038 -> 0 bytes .../TopToolBar/icos/Show only Online Users_UP.ico | Bin 2038 -> 0 bytes .../TopToolBar/icos/Sounds Enable_Disable_DN.ico | Bin 2038 -> 0 bytes .../TopToolBar/icos/Sounds Enable_Disable_UP.ico | Bin 2038 -> 0 bytes plugins/TopToolBar/main.cpp | 51 - plugins/TopToolBar/main.rc | 147 -- plugins/TopToolBar/res/Find_Add Contacts_UP.ico | Bin 0 -> 2038 bytes plugins/TopToolBar/res/Groups On_Off_DN.ico | Bin 0 -> 2038 bytes plugins/TopToolBar/res/Groups On_Off_UP.ico | Bin 0 -> 2038 bytes plugins/TopToolBar/res/Minimize Button_UP.ico | Bin 0 -> 2038 bytes plugins/TopToolBar/res/Run.ico | Bin 0 -> 1406 bytes plugins/TopToolBar/res/Show Main Menu_UP.ico | Bin 0 -> 2038 bytes plugins/TopToolBar/res/Show Options Page_UP.ico | Bin 0 -> 2038 bytes .../TopToolBar/res/Show only Online Users_DN.ico | Bin 0 -> 2038 bytes .../TopToolBar/res/Show only Online Users_UP.ico | Bin 0 -> 2038 bytes .../TopToolBar/res/Sounds Enable_Disable_DN.ico | Bin 0 -> 2038 bytes .../TopToolBar/res/Sounds Enable_Disable_UP.ico | Bin 0 -> 2038 bytes plugins/TopToolBar/res/main.rc | 147 ++ plugins/TopToolBar/res/sep.bmp | Bin 0 -> 1194 bytes plugins/TopToolBar/res/version.rc | 64 + plugins/TopToolBar/resource.h | 66 - plugins/TopToolBar/src/BkgrCfg.h | 18 + plugins/TopToolBar/src/InternalButtons.cpp | 121 + plugins/TopToolBar/src/common.h | 157 ++ plugins/TopToolBar/src/main.cpp | 51 + plugins/TopToolBar/src/resource.h | 66 + plugins/TopToolBar/src/toolbar.cpp | 707 ++++++ plugins/TopToolBar/src/toolbarwnd.cpp | 330 +++ plugins/TopToolBar/src/topbutton.cpp | 178 ++ plugins/TopToolBar/src/ttbopt.cpp | 559 +++++ plugins/TopToolBar/src/version.h | 46 + plugins/TopToolBar/toolbar.cpp | 707 ------ plugins/TopToolBar/toolbarwnd.cpp | 330 --- plugins/TopToolBar/topbutton.cpp | 178 -- plugins/TopToolBar/toptoolbar-translation.txt | 40 - plugins/TopToolBar/ttb-readme.txt | 160 -- plugins/TopToolBar/ttbopt.cpp | 559 ----- plugins/TopToolBar/version.h | 46 - plugins/TopToolBar/version.rc | 65 - .../Docs/translitswitcher-translation.txt | 10 + plugins/TranslitSwitcher/Res/Resource.rc | 48 + plugins/TranslitSwitcher/Res/Version.rc | 42 + plugins/TranslitSwitcher/Resource.h | 18 - plugins/TranslitSwitcher/Resource.rc | 48 - plugins/TranslitSwitcher/Src/Resource.h | 18 + plugins/TranslitSwitcher/Src/TranslitSwitcher.h | 4 +- plugins/TranslitSwitcher/Src/Version.h | 20 + .../TranslitSwitcher/TranslitSwitcher_10.vcxproj | 20 +- .../TranslitSwitcher_10.vcxproj.filters | 8 +- plugins/TranslitSwitcher/Version.h | 20 - plugins/TranslitSwitcher/Version.rc | 42 - .../translitswitcher-translation.txt | 10 - plugins/UserGuide/UserGuide_10.vcxproj | 12 +- plugins/UserGuide/UserGuide_10.vcxproj.filters | 8 +- plugins/UserGuide/commonheaders.h | 14 - plugins/UserGuide/docs/userguide-translation.txt | 5 + plugins/UserGuide/main.cpp | 122 - plugins/UserGuide/src/commonheaders.h | 14 + plugins/UserGuide/src/main.cpp | 122 + plugins/UserGuide/userguide-translation.txt | 5 - 167 files changed, 14778 insertions(+), 14946 deletions(-) create mode 100644 plugins/StopSpamPlus/docs/stopspamplus-translation.txt delete mode 100644 plugins/StopSpamPlus/headers.h delete mode 100644 plugins/StopSpamPlus/res/resource.h delete mode 100644 plugins/StopSpamPlus/res/version.h create mode 100644 plugins/StopSpamPlus/src/headers.h create mode 100644 plugins/StopSpamPlus/src/resource.h create mode 100644 plugins/StopSpamPlus/src/version.h delete mode 100644 plugins/StopSpamPlus/stopspamplus-translation.txt delete mode 100644 plugins/TipperYM/bitmap_func.cpp delete mode 100644 plugins/TipperYM/bitmap_func.h delete mode 100644 plugins/TipperYM/common.h create mode 100644 plugins/TipperYM/docs/tipperym-translation.txt delete mode 100644 plugins/TipperYM/message_pump.cpp delete mode 100644 plugins/TipperYM/message_pump.h delete mode 100644 plugins/TipperYM/mir_smileys.cpp delete mode 100644 plugins/TipperYM/mir_smileys.h delete mode 100644 plugins/TipperYM/options.cpp delete mode 100644 plugins/TipperYM/options.h delete mode 100644 plugins/TipperYM/popwin.cpp delete mode 100644 plugins/TipperYM/popwin.h delete mode 100644 plugins/TipperYM/preset_items.cpp delete mode 100644 plugins/TipperYM/preset_items.h create mode 100644 plugins/TipperYM/res/resource.rc create mode 100644 plugins/TipperYM/res/version.rc delete mode 100644 plugins/TipperYM/resource.h delete mode 100644 plugins/TipperYM/resource.rc delete mode 100644 plugins/TipperYM/skin_parser.cpp delete mode 100644 plugins/TipperYM/skin_parser.h create mode 100644 plugins/TipperYM/src/bitmap_func.cpp create mode 100644 plugins/TipperYM/src/bitmap_func.h create mode 100644 plugins/TipperYM/src/common.h create mode 100644 plugins/TipperYM/src/message_pump.cpp create mode 100644 plugins/TipperYM/src/message_pump.h create mode 100644 plugins/TipperYM/src/mir_smileys.cpp create mode 100644 plugins/TipperYM/src/mir_smileys.h create mode 100644 plugins/TipperYM/src/options.cpp create mode 100644 plugins/TipperYM/src/options.h create mode 100644 plugins/TipperYM/src/popwin.cpp create mode 100644 plugins/TipperYM/src/popwin.h create mode 100644 plugins/TipperYM/src/preset_items.cpp create mode 100644 plugins/TipperYM/src/preset_items.h create mode 100644 plugins/TipperYM/src/resource.h create mode 100644 plugins/TipperYM/src/skin_parser.cpp create mode 100644 plugins/TipperYM/src/skin_parser.h create mode 100644 plugins/TipperYM/src/str_utils.cpp create mode 100644 plugins/TipperYM/src/str_utils.h create mode 100644 plugins/TipperYM/src/subst.cpp create mode 100644 plugins/TipperYM/src/subst.h create mode 100644 plugins/TipperYM/src/tipper.cpp create mode 100644 plugins/TipperYM/src/translations.cpp create mode 100644 plugins/TipperYM/src/translations.h create mode 100644 plugins/TipperYM/src/version.h delete mode 100644 plugins/TipperYM/str_utils.cpp delete mode 100644 plugins/TipperYM/str_utils.h delete mode 100644 plugins/TipperYM/subst.cpp delete mode 100644 plugins/TipperYM/subst.h delete mode 100644 plugins/TipperYM/tipper.cpp delete mode 100644 plugins/TipperYM/tipperym-translation.txt delete mode 100644 plugins/TipperYM/translations.cpp delete mode 100644 plugins/TipperYM/translations.h delete mode 100644 plugins/TipperYM/version.h delete mode 100644 plugins/TipperYM/version.rc delete mode 100644 plugins/TooltipNotify/doc/todo.txt delete mode 100644 plugins/TooltipNotify/doc/tt_wnd_def_style.txt delete mode 100644 plugins/TooltipNotify/doc/ttnotify-readme.txt delete mode 100644 plugins/TooltipNotify/doc/ttnotify_translation.txt create mode 100644 plugins/TooltipNotify/docs/todo.txt create mode 100644 plugins/TooltipNotify/docs/tooltipnotify-translation.txt create mode 100644 plugins/TooltipNotify/docs/tt_wnd_def_style.txt create mode 100644 plugins/TooltipNotify/docs/ttnotify-readme.txt create mode 100644 plugins/TooltipNotify/docs/ttnotify_translation.txt create mode 100644 plugins/TooltipNotify/res/main.rc create mode 100644 plugins/TooltipNotify/res/version.rc delete mode 100644 plugins/TooltipNotify/src/main.rc delete mode 100644 plugins/TooltipNotify/src/version.rc delete mode 100644 plugins/TooltipNotify/tooltipnotify-translation.txt delete mode 100644 plugins/TopToolBar/BkgrCfg.h delete mode 100644 plugins/TopToolBar/InternalButtons.cpp delete mode 100644 plugins/TopToolBar/bmp/sep.bmp delete mode 100644 plugins/TopToolBar/common.h create mode 100644 plugins/TopToolBar/docs/toptoolbar-translation.txt create mode 100644 plugins/TopToolBar/docs/ttb-readme.txt delete mode 100644 plugins/TopToolBar/icos/Find_Add Contacts_UP.ico delete mode 100644 plugins/TopToolBar/icos/Groups On_Off_DN.ico delete mode 100644 plugins/TopToolBar/icos/Groups On_Off_UP.ico delete mode 100644 plugins/TopToolBar/icos/Minimize Button_UP.ico delete mode 100644 plugins/TopToolBar/icos/Run.ico delete mode 100644 plugins/TopToolBar/icos/Show Main Menu_UP.ico delete mode 100644 plugins/TopToolBar/icos/Show Options Page_UP.ico delete mode 100644 plugins/TopToolBar/icos/Show only Online Users_DN.ico delete mode 100644 plugins/TopToolBar/icos/Show only Online Users_UP.ico delete mode 100644 plugins/TopToolBar/icos/Sounds Enable_Disable_DN.ico delete mode 100644 plugins/TopToolBar/icos/Sounds Enable_Disable_UP.ico delete mode 100644 plugins/TopToolBar/main.cpp delete mode 100644 plugins/TopToolBar/main.rc create mode 100644 plugins/TopToolBar/res/Find_Add Contacts_UP.ico create mode 100644 plugins/TopToolBar/res/Groups On_Off_DN.ico create mode 100644 plugins/TopToolBar/res/Groups On_Off_UP.ico create mode 100644 plugins/TopToolBar/res/Minimize Button_UP.ico create mode 100644 plugins/TopToolBar/res/Run.ico create mode 100644 plugins/TopToolBar/res/Show Main Menu_UP.ico create mode 100644 plugins/TopToolBar/res/Show Options Page_UP.ico create mode 100644 plugins/TopToolBar/res/Show only Online Users_DN.ico create mode 100644 plugins/TopToolBar/res/Show only Online Users_UP.ico create mode 100644 plugins/TopToolBar/res/Sounds Enable_Disable_DN.ico create mode 100644 plugins/TopToolBar/res/Sounds Enable_Disable_UP.ico create mode 100644 plugins/TopToolBar/res/main.rc create mode 100644 plugins/TopToolBar/res/sep.bmp create mode 100644 plugins/TopToolBar/res/version.rc delete mode 100644 plugins/TopToolBar/resource.h create mode 100644 plugins/TopToolBar/src/BkgrCfg.h create mode 100644 plugins/TopToolBar/src/InternalButtons.cpp create mode 100644 plugins/TopToolBar/src/common.h create mode 100644 plugins/TopToolBar/src/main.cpp create mode 100644 plugins/TopToolBar/src/resource.h create mode 100644 plugins/TopToolBar/src/toolbar.cpp create mode 100644 plugins/TopToolBar/src/toolbarwnd.cpp create mode 100644 plugins/TopToolBar/src/topbutton.cpp create mode 100644 plugins/TopToolBar/src/ttbopt.cpp create mode 100644 plugins/TopToolBar/src/version.h delete mode 100644 plugins/TopToolBar/toolbar.cpp delete mode 100644 plugins/TopToolBar/toolbarwnd.cpp delete mode 100644 plugins/TopToolBar/topbutton.cpp delete mode 100644 plugins/TopToolBar/toptoolbar-translation.txt delete mode 100644 plugins/TopToolBar/ttb-readme.txt delete mode 100644 plugins/TopToolBar/ttbopt.cpp delete mode 100644 plugins/TopToolBar/version.h delete mode 100644 plugins/TopToolBar/version.rc create mode 100644 plugins/TranslitSwitcher/Docs/translitswitcher-translation.txt create mode 100644 plugins/TranslitSwitcher/Res/Resource.rc create mode 100644 plugins/TranslitSwitcher/Res/Version.rc delete mode 100644 plugins/TranslitSwitcher/Resource.h delete mode 100644 plugins/TranslitSwitcher/Resource.rc create mode 100644 plugins/TranslitSwitcher/Src/Resource.h create mode 100644 plugins/TranslitSwitcher/Src/Version.h delete mode 100644 plugins/TranslitSwitcher/Version.h delete mode 100644 plugins/TranslitSwitcher/Version.rc delete mode 100644 plugins/TranslitSwitcher/translitswitcher-translation.txt delete mode 100644 plugins/UserGuide/commonheaders.h create mode 100644 plugins/UserGuide/docs/userguide-translation.txt delete mode 100644 plugins/UserGuide/main.cpp create mode 100644 plugins/UserGuide/src/commonheaders.h create mode 100644 plugins/UserGuide/src/main.cpp delete mode 100644 plugins/UserGuide/userguide-translation.txt diff --git a/plugins/StopSpamPlus/docs/stopspamplus-translation.txt b/plugins/StopSpamPlus/docs/stopspamplus-translation.txt new file mode 100644 index 0000000000..50b195e9f2 --- /dev/null +++ b/plugins/StopSpamPlus/docs/stopspamplus-translation.txt @@ -0,0 +1,33 @@ +; Common strings that belong to many files +;[] + +; ../../plugins/StopSpamPlus/res/stopspam.rc +;[ questions to one contact (0 - for no limit)] +;[Add contact permanently] +;[Answer (Use divider to separate answers):] +;[Answer is not case sensitive] +;[Auth. request reply:] +;[Congratulation:] +;[Disable protection for following protocols:] +;[Divider:] +;[Do not send more than ] +;[Enable StopSpam-StopSpam infinite talk protection] +;[Enable auth. requests blocking] +;[Log Spammers to system history] +;[Question: (Ctrl-Enter for carriage return)] +;[Remove all tempory contacts after restart] +;[Restore defaults] +;[Vars] + +; ../../plugins/StopSpamPlus/src/events.cpp +;[Main] +;[Message Sessions] +;[Messages] +;[Protocols] + +; ../../plugins/StopSpamPlus/src/services.cpp +;[Complete] +;[Not In List] + +; ../../plugins/StopSpamPlus/src/settings.h +;[nospam] diff --git a/plugins/StopSpamPlus/headers.h b/plugins/StopSpamPlus/headers.h deleted file mode 100644 index d80060d668..0000000000 --- a/plugins/StopSpamPlus/headers.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef _stopspam_headers_h -#define _stopspam_headers_h - -// disable security warnings about "*_s" functions -#define _CRT_SECURE_NO_DEPRECATE - -// disable warnings about underscore in stdc functions -#pragma warning(disable: 4996) - -#define MIRANDA_VER 0x0A00 - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "src/eventhooker.h" -#include "res/version.h" -#include "res/resource.h" -#include "m_stopspam.h" - -#include "m_variables.h" - -#define pluginName "StopSpam" - -extern char * pluginDescription; -extern TCHAR const * infTalkProtPrefix; -extern char const * answeredSetting; -extern char const * questCountSetting; -extern HANDLE hLoadHook; -extern HINSTANCE hInst; - -#ifdef _UNICODE - typedef std::wstring tstring; - #define PREF_TCHAR2 PREF_UTF -#else - typedef std::string tstring; - #define PREF_TCHAR2 0 -#endif //_UNICODE - -#include "src/settings.h" - -//options -INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); -INT_PTR CALLBACK MessagesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); -INT_PTR CALLBACK ProtoDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); - -//utils -void SetDlgItemString(HWND hwndDlg, UINT idItem, std::string const &str); -void SetDlgItemString(HWND hwndDlg, UINT idItem, std::wstring const &str); -tstring &GetDlgItemString(HWND hwnd, int id); -bool IsExistMyMessage(HANDLE hContact); -tstring variables_parse(tstring const &tstrFormat, HANDLE hContact); -tstring trim(tstring const &tstr, tstring const &trimChars = _T(" \f\n\r\t\v")); - -INT_PTR IsContactPassed(WPARAM wParam, LPARAM /*lParam*/); -INT_PTR RemoveTempContacts(WPARAM wParam,LPARAM lParam); -int OnSystemModulesLoaded(WPARAM wParam, LPARAM lParam); -#endif diff --git a/plugins/StopSpamPlus/res/resource.h b/plugins/StopSpamPlus/res/resource.h deleted file mode 100644 index 62e603cb2e..0000000000 --- a/plugins/StopSpamPlus/res/resource.h +++ /dev/null @@ -1,33 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by stopspam.rc -// -#define IDD_MESSAGES 101 -#define IDD_MAIN 102 -#define IDD_PROTO 103 -#define ID_DESCRIPTION 1001 -#define ID_QUESTION 1002 -#define ID_ANSWER 1003 -#define ID_CONGRATULATION 1004 -#define ID_RESTOREDEFAULTS 1005 -#define ID_AUTHREPL 1007 -#define ID_MAXQUESTCOUNT 1008 -#define IDC_PROTO 1009 -#define ID_INFTALKPROT 1010 -#define ID_ADDPERMANENT 1011 -#define ID_HANDLEAUTHREQ 1012 -#define ID_NOTCASESENS 1013 -#define ID_DIVIDER 1014 -#define IDC_VARS 1015 -#define ID_REMOVE_TMP_ALL 1016 -#define ID_HISTORY_LOG 1017 -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 104 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1018 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/plugins/StopSpamPlus/res/stopspam.rc b/plugins/StopSpamPlus/res/stopspam.rc index e6f3f1ffc1..4cb4a45a1c 100644 --- a/plugins/StopSpamPlus/res/stopspam.rc +++ b/plugins/StopSpamPlus/res/stopspam.rc @@ -1,6 +1,6 @@ // Microsoft Visual C++ generated resource script. // -#include "resource.h" +#include "..\src\resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// @@ -123,7 +123,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 1 TEXTINCLUDE BEGIN - "resource.h\0" + "..\\src\\resource.h\0" END 2 TEXTINCLUDE diff --git a/plugins/StopSpamPlus/res/version.h b/plugins/StopSpamPlus/res/version.h deleted file mode 100644 index feb992d6a3..0000000000 --- a/plugins/StopSpamPlus/res/version.h +++ /dev/null @@ -1,51 +0,0 @@ -// Set the version number here - it will affect the version resource and the version field of the pluginInfo structure -// (Be careful that you don't have the resource file open when you change this and rebuild, otherwise the changes may not -// take effect within the version resource) -// Do not forget to define symbol "_DEBUG" for resource compiler if you use debug configuration (in VisualStudio you can -// find it under Project properties - Configuration properties - Resource - General - Preprocessor definitions) - -// plugin version part -#define __MAJOR_VERSION 0 -#define __MINOR_VERSION 0 -#define __RELEASE_NUM 1 -#define __BUILD_NUM 4 -// plugin SVN Revision number -#define __REV_NUM 1548 - -// minimal MirandaIM version number, with which this plugin supposed to work -#define __PROD_MAJOR_VERSION 0 -#define __PROD_MINOR_VERSION 8 -#define __PROD_RELEASE_NUM 0 -#define __PROD_BUILD_NUM 0 -// if your plugin works only with Miranda core beginning from specific revision, you can include this information in Product Version resource -//#define __PROD_REV_NUM 1234 - -// stuff that will be used in PluginInfo section and in Version resource -#define __PLUGIN_NAME "StopSpam+" -#define __FILENAME "StopSpam.dll" -#define __DESC "No more spam! Robots can't go! Only human beings invited!" -#define __AUTHOR "Roman Miklashevsky, A. Petkevich, Kosh&chka, persei" -#define __AUTHOREMAIL "koshechka@miranda.im" -#define __AUTHORWEB "http://nightly.miranda.im/" -#define __COPYRIGHT "© 2004-2010 Roman Miklashevsky, A. Petkevich, Kosh&chka, persei" - -// other stuff for Version resource -#define __STRINGIFY_IMPL(x) #x -#define __STRINGIFY(x) __STRINGIFY_IMPL(x) - -#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM -#define __FILEVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM - -#ifdef __REV_NUM -#define __VERSION_STRING __STRINGIFY(__FILEVERSION_STRING_DOTS rev. __REV_NUM) -#else -#define __VERSION_STRING __STRINGIFY(__FILEVERSION_STRING_DOTS) -#endif - -#define __PRODVERSION_STRING __PROD_MAJOR_VERSION,__PROD_MINOR_VERSION,__PROD_RELEASE_NUM,__PROD_BUILD_NUM -#define __PRODVERSION_STRING_DOTS __PROD_MAJOR_VERSION.__PROD_MINOR_VERSION.__PROD_RELEASE_NUM.__PROD_BUILD_NUM -#ifdef __PROD_REV_NUM -#define __PROD_VERSION_STRING __STRINGIFY(__PRODVERSION_STRING_DOTS rev. __PROD_REV_NUM) -#else -#define __PROD_VERSION_STRING __STRINGIFY(__PRODVERSION_STRING_DOTS+) -#endif diff --git a/plugins/StopSpamPlus/res/version.rc b/plugins/StopSpamPlus/res/version.rc index ebf0f96c65..75748ead8a 100644 --- a/plugins/StopSpamPlus/res/version.rc +++ b/plugins/StopSpamPlus/res/version.rc @@ -3,7 +3,7 @@ #endif //APSTUDIO_INVOKED #include "afxres.h" -#include "version.h" +#include "..\src\version.h" #ifdef _WIN32 LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL diff --git a/plugins/StopSpamPlus/src/events.cpp b/plugins/StopSpamPlus/src/events.cpp index c4943f8e0f..41f4d9e8eb 100644 --- a/plugins/StopSpamPlus/src/events.cpp +++ b/plugins/StopSpamPlus/src/events.cpp @@ -1,4 +1,4 @@ -#include "../headers.h" +#include "headers.h" MIRANDA_HOOK_EVENT(ME_DB_EVENT_ADDED, wParam, lParam) diff --git a/plugins/StopSpamPlus/src/headers.h b/plugins/StopSpamPlus/src/headers.h new file mode 100644 index 0000000000..6da161f793 --- /dev/null +++ b/plugins/StopSpamPlus/src/headers.h @@ -0,0 +1,71 @@ +#ifndef _stopspam_headers_h +#define _stopspam_headers_h + +// disable security warnings about "*_s" functions +#define _CRT_SECURE_NO_DEPRECATE + +// disable warnings about underscore in stdc functions +#pragma warning(disable: 4996) + +#define MIRANDA_VER 0x0A00 + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "eventhooker.h" +#include "version.h" +#include "resource.h" +#include "m_stopspam.h" + +#include "m_variables.h" + +#define pluginName "StopSpam" + +extern char * pluginDescription; +extern TCHAR const * infTalkProtPrefix; +extern char const * answeredSetting; +extern char const * questCountSetting; +extern HANDLE hLoadHook; +extern HINSTANCE hInst; + +#ifdef _UNICODE + typedef std::wstring tstring; + #define PREF_TCHAR2 PREF_UTF +#else + typedef std::string tstring; + #define PREF_TCHAR2 0 +#endif //_UNICODE + +#include "settings.h" + +//options +INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK MessagesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK ProtoDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); + +//utils +void SetDlgItemString(HWND hwndDlg, UINT idItem, std::string const &str); +void SetDlgItemString(HWND hwndDlg, UINT idItem, std::wstring const &str); +tstring &GetDlgItemString(HWND hwnd, int id); +bool IsExistMyMessage(HANDLE hContact); +tstring variables_parse(tstring const &tstrFormat, HANDLE hContact); +tstring trim(tstring const &tstr, tstring const &trimChars = _T(" \f\n\r\t\v")); + +INT_PTR IsContactPassed(WPARAM wParam, LPARAM /*lParam*/); +INT_PTR RemoveTempContacts(WPARAM wParam,LPARAM lParam); +int OnSystemModulesLoaded(WPARAM wParam, LPARAM lParam); +#endif diff --git a/plugins/StopSpamPlus/src/opt_proto.cpp b/plugins/StopSpamPlus/src/opt_proto.cpp index 014a44e7c7..cfdfe0b991 100644 --- a/plugins/StopSpamPlus/src/opt_proto.cpp +++ b/plugins/StopSpamPlus/src/opt_proto.cpp @@ -1,4 +1,4 @@ -#include "../headers.h" +#include "headers.h" struct ProtocolData { diff --git a/plugins/StopSpamPlus/src/options.cpp b/plugins/StopSpamPlus/src/options.cpp index 52fab03e8f..221a06f480 100644 --- a/plugins/StopSpamPlus/src/options.cpp +++ b/plugins/StopSpamPlus/src/options.cpp @@ -1,4 +1,4 @@ -#include "../headers.h" +#include "headers.h" char * pluginDescription = "No more spam! Robots can't go! Only human beings invited!\r\n\r\n" "This plugin works pretty simple:\r\n" diff --git a/plugins/StopSpamPlus/src/resource.h b/plugins/StopSpamPlus/src/resource.h new file mode 100644 index 0000000000..62e603cb2e --- /dev/null +++ b/plugins/StopSpamPlus/src/resource.h @@ -0,0 +1,33 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by stopspam.rc +// +#define IDD_MESSAGES 101 +#define IDD_MAIN 102 +#define IDD_PROTO 103 +#define ID_DESCRIPTION 1001 +#define ID_QUESTION 1002 +#define ID_ANSWER 1003 +#define ID_CONGRATULATION 1004 +#define ID_RESTOREDEFAULTS 1005 +#define ID_AUTHREPL 1007 +#define ID_MAXQUESTCOUNT 1008 +#define IDC_PROTO 1009 +#define ID_INFTALKPROT 1010 +#define ID_ADDPERMANENT 1011 +#define ID_HANDLEAUTHREQ 1012 +#define ID_NOTCASESENS 1013 +#define ID_DIVIDER 1014 +#define IDC_VARS 1015 +#define ID_REMOVE_TMP_ALL 1016 +#define ID_HISTORY_LOG 1017 +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 104 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1018 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/plugins/StopSpamPlus/src/services.cpp b/plugins/StopSpamPlus/src/services.cpp index 1f9097446d..7fe08a9600 100644 --- a/plugins/StopSpamPlus/src/services.cpp +++ b/plugins/StopSpamPlus/src/services.cpp @@ -1,4 +1,4 @@ -#include "../headers.h" +#include "headers.h" INT_PTR IsContactPassed(WPARAM wParam, LPARAM /*lParam*/) { diff --git a/plugins/StopSpamPlus/src/settings.cpp b/plugins/StopSpamPlus/src/settings.cpp index 7d74b63919..05a9007d0c 100644 --- a/plugins/StopSpamPlus/src/settings.cpp +++ b/plugins/StopSpamPlus/src/settings.cpp @@ -1,4 +1,4 @@ -#include "../headers.h" +#include "headers.h" //reading from database------------- tstring db_usage::DBGetPluginSetting(std::string const &name, tstring const &defValue) diff --git a/plugins/StopSpamPlus/src/settings.h b/plugins/StopSpamPlus/src/settings.h index 99aa9322e8..86219ebf10 100644 --- a/plugins/StopSpamPlus/src/settings.h +++ b/plugins/StopSpamPlus/src/settings.h @@ -1,6 +1,6 @@ #pragma once -#include "../headers.h" +#include "headers.h" class db_usage { diff --git a/plugins/StopSpamPlus/src/stopspam.cpp b/plugins/StopSpamPlus/src/stopspam.cpp index 72d5e175c6..e58b8846ff 100644 --- a/plugins/StopSpamPlus/src/stopspam.cpp +++ b/plugins/StopSpamPlus/src/stopspam.cpp @@ -1,4 +1,4 @@ -#include "../headers.h" +#include "headers.h" HANDLE hFunc, hTempRemove, hLoadHook; int hLangpack; diff --git a/plugins/StopSpamPlus/src/utils.cpp b/plugins/StopSpamPlus/src/utils.cpp index 673a858ad2..7d8bc28050 100644 --- a/plugins/StopSpamPlus/src/utils.cpp +++ b/plugins/StopSpamPlus/src/utils.cpp @@ -1,4 +1,4 @@ -#include "../headers.h" +#include "headers.h" tstring &GetDlgItemString(HWND hwnd, int id) diff --git a/plugins/StopSpamPlus/src/version.h b/plugins/StopSpamPlus/src/version.h new file mode 100644 index 0000000000..feb992d6a3 --- /dev/null +++ b/plugins/StopSpamPlus/src/version.h @@ -0,0 +1,51 @@ +// Set the version number here - it will affect the version resource and the version field of the pluginInfo structure +// (Be careful that you don't have the resource file open when you change this and rebuild, otherwise the changes may not +// take effect within the version resource) +// Do not forget to define symbol "_DEBUG" for resource compiler if you use debug configuration (in VisualStudio you can +// find it under Project properties - Configuration properties - Resource - General - Preprocessor definitions) + +// plugin version part +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 0 +#define __RELEASE_NUM 1 +#define __BUILD_NUM 4 +// plugin SVN Revision number +#define __REV_NUM 1548 + +// minimal MirandaIM version number, with which this plugin supposed to work +#define __PROD_MAJOR_VERSION 0 +#define __PROD_MINOR_VERSION 8 +#define __PROD_RELEASE_NUM 0 +#define __PROD_BUILD_NUM 0 +// if your plugin works only with Miranda core beginning from specific revision, you can include this information in Product Version resource +//#define __PROD_REV_NUM 1234 + +// stuff that will be used in PluginInfo section and in Version resource +#define __PLUGIN_NAME "StopSpam+" +#define __FILENAME "StopSpam.dll" +#define __DESC "No more spam! Robots can't go! Only human beings invited!" +#define __AUTHOR "Roman Miklashevsky, A. Petkevich, Kosh&chka, persei" +#define __AUTHOREMAIL "koshechka@miranda.im" +#define __AUTHORWEB "http://nightly.miranda.im/" +#define __COPYRIGHT "© 2004-2010 Roman Miklashevsky, A. Petkevich, Kosh&chka, persei" + +// other stuff for Version resource +#define __STRINGIFY_IMPL(x) #x +#define __STRINGIFY(x) __STRINGIFY_IMPL(x) + +#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM +#define __FILEVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM + +#ifdef __REV_NUM +#define __VERSION_STRING __STRINGIFY(__FILEVERSION_STRING_DOTS rev. __REV_NUM) +#else +#define __VERSION_STRING __STRINGIFY(__FILEVERSION_STRING_DOTS) +#endif + +#define __PRODVERSION_STRING __PROD_MAJOR_VERSION,__PROD_MINOR_VERSION,__PROD_RELEASE_NUM,__PROD_BUILD_NUM +#define __PRODVERSION_STRING_DOTS __PROD_MAJOR_VERSION.__PROD_MINOR_VERSION.__PROD_RELEASE_NUM.__PROD_BUILD_NUM +#ifdef __PROD_REV_NUM +#define __PROD_VERSION_STRING __STRINGIFY(__PRODVERSION_STRING_DOTS rev. __PROD_REV_NUM) +#else +#define __PROD_VERSION_STRING __STRINGIFY(__PRODVERSION_STRING_DOTS+) +#endif diff --git a/plugins/StopSpamPlus/stopspam_10.vcxproj b/plugins/StopSpamPlus/stopspam_10.vcxproj index 5b1d4d75fc..48a8b01d0c 100644 --- a/plugins/StopSpamPlus/stopspam_10.vcxproj +++ b/plugins/StopSpamPlus/stopspam_10.vcxproj @@ -74,7 +74,7 @@ Full OnlyExplicitInline ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;STOPSPAM_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true true Level3 @@ -100,7 +100,7 @@ Full OnlyExplicitInline ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN64;NDEBUG;_WINDOWS;_USRDLL;STOPSPAM_EXPORTS;%(PreprocessorDefinitions) + WIN64;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true true Level3 @@ -125,7 +125,7 @@ Disabled ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;STOPSPAM_EXPORTS;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true MultiThreadedDebugDLL Level3 @@ -148,7 +148,7 @@ Disabled ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN64;_DEBUG;_WINDOWS;_USRDLL;STOPSPAM_EXPORTS;%(PreprocessorDefinitions) + WIN64;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) MultiThreadedDebugDLL Level3 @@ -176,11 +176,11 @@ - - + + - + diff --git a/plugins/StopSpamPlus/stopspam_10.vcxproj.filters b/plugins/StopSpamPlus/stopspam_10.vcxproj.filters index e997e2959c..51bdd7ab12 100644 --- a/plugins/StopSpamPlus/stopspam_10.vcxproj.filters +++ b/plugins/StopSpamPlus/stopspam_10.vcxproj.filters @@ -44,16 +44,16 @@ Header Files - + Header Files - + Header Files - + Header Files - + Header Files diff --git a/plugins/StopSpamPlus/stopspamplus-translation.txt b/plugins/StopSpamPlus/stopspamplus-translation.txt deleted file mode 100644 index 50b195e9f2..0000000000 --- a/plugins/StopSpamPlus/stopspamplus-translation.txt +++ /dev/null @@ -1,33 +0,0 @@ -; Common strings that belong to many files -;[] - -; ../../plugins/StopSpamPlus/res/stopspam.rc -;[ questions to one contact (0 - for no limit)] -;[Add contact permanently] -;[Answer (Use divider to separate answers):] -;[Answer is not case sensitive] -;[Auth. request reply:] -;[Congratulation:] -;[Disable protection for following protocols:] -;[Divider:] -;[Do not send more than ] -;[Enable StopSpam-StopSpam infinite talk protection] -;[Enable auth. requests blocking] -;[Log Spammers to system history] -;[Question: (Ctrl-Enter for carriage return)] -;[Remove all tempory contacts after restart] -;[Restore defaults] -;[Vars] - -; ../../plugins/StopSpamPlus/src/events.cpp -;[Main] -;[Message Sessions] -;[Messages] -;[Protocols] - -; ../../plugins/StopSpamPlus/src/services.cpp -;[Complete] -;[Not In List] - -; ../../plugins/StopSpamPlus/src/settings.h -;[nospam] diff --git a/plugins/TipperYM/bitmap_func.cpp b/plugins/TipperYM/bitmap_func.cpp deleted file mode 100644 index 0a33c7b1d8..0000000000 --- a/plugins/TipperYM/bitmap_func.cpp +++ /dev/null @@ -1,776 +0,0 @@ -/* -Copyright (C) 2006-2007 Scott Ellis -Copyright (C) 2007-2011 Jan Holub - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this file; see the file license.txt. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. -*/ - -#include "common.h" -#include "options.h" -#include "bitmap_func.h" -#include "message_pump.h" - -TOOLTIPSKIN skin = {0}; - -HBITMAP CreateBitmapPart(FIBITMAP *fibSrc, int iSrcWidth, int iSrcHeight, int iDesWidth, int iDesHeight, TransformationMode transfMode) -{ - FIBITMAP *fibMem = NULL; - HBITMAP hbmpDes = NULL; - - if (!fibSrc) - return NULL; - - switch (transfMode) - { - case TM_NONE: - case TM_CENTRE: - case TM_TILE_ALL: - { - hbmpDes = fii->FI_CreateHBITMAPFromDIB(fibSrc); - break; - } - case TM_STRECH_ALL: - { - fibMem = fii->FI_Rescale(fibSrc, iDesWidth, iDesHeight, FILTER_BILINEAR); - hbmpDes = fii->FI_CreateHBITMAPFromDIB(fibMem); - break; - } - case TM_STRECH_HORIZONTAL: - case TM_TILE_VERTICAL: - { - fibMem = fii->FI_Rescale(fibSrc, iDesWidth, iSrcHeight, FILTER_BILINEAR); - hbmpDes = fii->FI_CreateHBITMAPFromDIB(fibMem); - break; - } - case TM_STRECH_VERTICAL: - case TM_TILE_HORIZONTAL: - { - fibMem = fii->FI_Rescale(fibSrc, iSrcWidth, iSrcHeight, FILTER_BILINEAR); - hbmpDes = fii->FI_CreateHBITMAPFromDIB(fibMem); - break; - } - } - - if (fibMem) fii->FI_Unload(fibMem); - return hbmpDes; -} - -void DrawBitmapPart(HDC hdcMem, HBITMAP hbmpPart, RECT *rcDes, TransformationMode transfMode) -{ - if (!hbmpPart) - return; - - BLENDFUNCTION blend; - blend.BlendOp = AC_SRC_OVER; - blend.BlendFlags = 0; - blend.SourceConstantAlpha = 255; - blend.AlphaFormat = AC_SRC_ALPHA; - - BITMAP bitmap; - GetObject(hbmpPart, sizeof(bitmap), &bitmap); - int iBmpWidth = bitmap.bmWidth; - int iBmpHeight = bitmap.bmHeight; - - int iDesWidth = rcDes->right - rcDes->left; - int iDesHeight = rcDes->bottom - rcDes->top; - - SelectObject(hdcMem, hbmpPart); - - switch (transfMode) - { - case TM_NONE: - case TM_STRECH_ALL: - case TM_STRECH_HORIZONTAL: - case TM_STRECH_VERTICAL: - { - AlphaBlend(skin.hdc, rcDes->left, rcDes->top, iBmpWidth, iBmpHeight, hdcMem, 0, 0, iBmpWidth, iBmpHeight, blend); - break; - } - case TM_CENTRE: - { - int iPosX = rcDes->left + ((iDesWidth - iBmpWidth) / 2); - int iPosY = rcDes->top + ((iDesHeight - iBmpHeight) / 2); - AlphaBlend(skin.hdc, iPosX, iPosY, iBmpWidth, iBmpHeight, hdcMem, 0, 0, iBmpWidth, iBmpHeight, blend); - break; - } - case TM_TILE_ALL: - { - int iRepX = iDesWidth / iBmpWidth; - int iRepY = iDesHeight / iBmpHeight; - int iEndX = iDesWidth % iBmpWidth; - int iEndY = iDesHeight % iBmpHeight; - int x,y; - - for (y = 0; y < iRepY; y++) - { - for (x = 0; x < iRepX; x++) - { - AlphaBlend(skin.hdc, rcDes->left + (x * iBmpWidth), rcDes->top + (y * iBmpHeight), iBmpWidth, iBmpHeight, hdcMem, 0, 0, iBmpWidth, iBmpHeight, blend); - } - - AlphaBlend(skin.hdc, rcDes->left + (x * iBmpWidth), rcDes->top + (y * iBmpHeight), iEndX, iBmpHeight, hdcMem, 0, 0, iEndX, iBmpHeight, blend); - } - - for (x = 0; x < iRepX; x++) - { - AlphaBlend(skin.hdc, rcDes->left + (x * iBmpWidth), rcDes->top + (y * iBmpHeight), iBmpWidth, iEndY, hdcMem, 0, 0, iBmpWidth, iEndY, blend); - } - - AlphaBlend(skin.hdc, rcDes->left + (x * iBmpWidth), rcDes->top + (y * iBmpHeight), iEndX, iEndY, hdcMem, 0, 0, iEndX, iEndY, blend); - break; - } - case TM_TILE_HORIZONTAL: - { - int iRepX = iDesWidth / iBmpWidth; - int iEndX = iDesWidth % iBmpWidth; - int x; - - for (x = 0; x < iRepX; x++) - { - AlphaBlend(skin.hdc, rcDes->left + (x * iBmpWidth), rcDes->top, iBmpWidth, iDesHeight, hdcMem, 0, 0, iBmpWidth, iDesHeight, blend); - } - - AlphaBlend(skin.hdc, rcDes->left + (x * iBmpWidth), rcDes->top, iEndX, iDesHeight, hdcMem, 0, 0, iEndX, iDesHeight, blend); - break; - } - case TM_TILE_VERTICAL: - { - int iRepY = iDesHeight / iBmpHeight; - int iEndY = iDesHeight % iBmpHeight; - int y; - - for(y = 0; y < iRepY; y++) - { - AlphaBlend(skin.hdc, rcDes->left, rcDes->top + (y * iBmpHeight), iDesWidth, iBmpHeight, hdcMem, 0, 0, iDesWidth, iBmpHeight, blend); - } - - AlphaBlend(skin.hdc, rcDes->left, rcDes->top + (y * iBmpHeight), iDesWidth, iEndY, hdcMem, 0, 0, iDesWidth, iEndY, blend); - break; - } - } -} - -void CreateFromBitmaps(bool bServiceTip) -{ - int rcWidth, rcHeight; - int iCentWidth, iCentHeight; - int iBmpWidth, iBmpHeight; - int top, right, bottom, left; - - BLENDFUNCTION blend; - blend.BlendOp = AC_SRC_OVER; - blend.BlendFlags = 0; - blend.SourceConstantAlpha = 255; - blend.AlphaFormat = AC_SRC_ALPHA; - - for (int i = 0; i < SKIN_ITEMS_COUNT; i++) - { - if (i == SKIN_ITEM_SIDEBAR && (!opt.iSidebarWidth || bServiceTip)) - continue; - - TCHAR* tszFileName = opt.szImgFile[i]; - if (tszFileName && *tszFileName != 0) - { - FIBITMAP *fib = NULL; - if (!skin.bCached) - { - FIBITMAP *fibLoad = (FIBITMAP *)CallService(MS_IMG_LOAD, (WPARAM)tszFileName, (LPARAM)(IMGL_TCHAR | IMGL_RETURNDIB)); - if (!fibLoad) continue; - - if (fii->FI_GetBPP(fibLoad) != 32) - fib = fii->FI_ConvertTo32Bits(fibLoad); - else - fib = fibLoad; - - if (fib != fibLoad) - fii->FI_Unload(fibLoad); - - skin.fib[i] = fib; - } - else - { - fib = skin.fib[i]; - } - - // destination rectangle size - if (i == SKIN_ITEM_BG) - { - rcWidth = skin.iWidth; - rcHeight = skin.iHeight; - } - else if (i == SKIN_ITEM_SIDEBAR) - { - rcWidth = opt.iSidebarWidth; - rcHeight = skin.iHeight; - } - - // bitmap size - iBmpWidth = fii->FI_GetWidth(fib); - iBmpHeight = fii->FI_GetHeight(fib); - - // margins - top = opt.margins[i].top < iBmpHeight ? opt.margins[i].top : 0; - right = opt.margins[i].right < iBmpWidth ? opt.margins[i].right : 0; - bottom = opt.margins[i].bottom < iBmpHeight ? opt.margins[i].bottom : 0; - left = opt.margins[i].left < iBmpWidth ? opt.margins[i].left : 0; - - // centre area size - iCentWidth = max(rcWidth - left - right, 0); - iCentHeight = max(rcHeight - top - bottom, 0); - - FIBITMAP *fibCentre = NULL, *fibMem = NULL; - if (opt.margins[i].left || opt.margins[i].top || opt.margins[i].right || opt.margins[i].bottom) - { - // create corners bitmaps - if (!skin.bCached) - { - if (top > 0 && left > 0) // TL - { - fibMem = fii->FI_Copy(fib, 0, 0, left, top); - skin.hbmpSkinParts[i][SP_CORNER_TL] = fii->FI_CreateHBITMAPFromDIB(fibMem); - if (fibMem) fii->FI_Unload(fibMem); - } - if (top > 0 && right > 0) // TR - { - fibMem = fii->FI_Copy(fib, iBmpWidth - right, 0, iBmpWidth, top); - skin.hbmpSkinParts[i][SP_CORNER_TR] = fii->FI_CreateHBITMAPFromDIB(fibMem); - if (fibMem) fii->FI_Unload(fibMem); - } - if (bottom > 0 && right > 0) // BR - { - fibMem = fii->FI_Copy(fib, iBmpWidth - right, iBmpHeight - bottom, iBmpWidth, iBmpHeight); - skin.hbmpSkinParts[i][SP_CORNER_BR] = fii->FI_CreateHBITMAPFromDIB(fibMem); - if (fibMem) fii->FI_Unload(fibMem); - } - if (bottom > 0 && left > 0) // BL - { - fibMem = fii->FI_Copy(fib, 0, iBmpHeight - bottom, left, iBmpHeight); - skin.hbmpSkinParts[i][SP_CORNER_BL] = fii->FI_CreateHBITMAPFromDIB(fibMem); - if (fibMem) fii->FI_Unload(fibMem); - } - } - - // create edge parts bitmaps - if (top > 0 && iCentWidth > 0) // top - { - fibMem = fii->FI_Copy(fib, left, 0, iBmpWidth - right, top); - skin.hbmpSkinParts[i][SP_EDGE_TOP] = CreateBitmapPart(fibMem, iBmpWidth - left - right, top, iCentWidth, top, opt.transfMode[i]); - if (fibMem) fii->FI_Unload(fibMem); - } - if (right > 0 && iCentHeight > 0) // right - { - fibMem = fii->FI_Copy(fib, iBmpWidth - right, top, iBmpWidth, iBmpHeight - bottom); - skin.hbmpSkinParts[i][SP_EDGE_RIGHT] = CreateBitmapPart(fibMem, right, iBmpHeight - top - bottom, right, iCentHeight, opt.transfMode[i]); - if (fibMem) fii->FI_Unload(fibMem); - } - if (bottom > 0 && iCentWidth > 0) // bottom - { - fibMem = fii->FI_Copy(fib, left, iBmpHeight - bottom, iBmpWidth - right, iBmpHeight); - skin.hbmpSkinParts[i][SP_EDGE_BOTTOM] = CreateBitmapPart(fibMem, iBmpWidth - left - right, bottom, iCentWidth, bottom, opt.transfMode[i]); - if (fibMem) fii->FI_Unload(fibMem); - } - if (left > 0 && iCentHeight > 0) // left - { - fibMem = fii->FI_Copy(fib, 0, top, left, iBmpHeight - bottom); - skin.hbmpSkinParts[i][SP_EDGE_LEFT] = CreateBitmapPart(fibMem, left, iBmpHeight - top - bottom, left, iCentHeight, opt.transfMode[i]); - if (fibMem) fii->FI_Unload(fibMem); - } - - fibCentre = fii->FI_Copy(fib, left, top, iBmpWidth - right, iBmpHeight - bottom); - if (fibCentre) - { - fib = fibCentre; - iBmpWidth = fii->FI_GetWidth(fib); - iBmpHeight = fii->FI_GetHeight(fib); - } - } - - // create centre area bitmap - skin.hbmpSkinParts[i][SP_CENTRE_AREA] = CreateBitmapPart(fib, iBmpWidth, iBmpHeight, iCentWidth, iCentHeight, opt.transfMode[i]); - if (fibCentre) - fii->FI_Unload(fibCentre); - - if (i == SKIN_ITEM_SIDEBAR) - { - int limit = skin.bCached ? SP_CORNER_TL : SKIN_PARTS_COUNT; // don't premultiply corner bitmaps multiple times - for (int j = 0; j < limit; j++) - { - if (skin.hbmpSkinParts[i][j]) - fii->FI_Premultiply(skin.hbmpSkinParts[i][j]); - } - } - - HDC hdcMem = CreateCompatibleDC(0); - RECT rc = {0}; - - if (skin.hbmpSkinParts[i][SP_CENTRE_AREA]) - { - SetRect(&rc, left, top, rcWidth - right, rcHeight - bottom); - DrawBitmapPart(hdcMem, skin.hbmpSkinParts[i][SP_CENTRE_AREA], &rc, opt.transfMode[i]); - } - - if (opt.margins[i].left || opt.margins[i].top || opt.margins[i].right || opt.margins[i].bottom) - { - // draw edge parts - if (skin.hbmpSkinParts[i][SP_EDGE_TOP]) // top - { - SetRect(&rc, left, 0, rcWidth - right, top); - DrawBitmapPart(hdcMem, skin.hbmpSkinParts[i][SP_EDGE_TOP], &rc, opt.transfMode[i]); - } - if (skin.hbmpSkinParts[i][SP_EDGE_RIGHT]) // right - { - SetRect(&rc, rcWidth - right, top, rcWidth, rcHeight - bottom); - DrawBitmapPart(hdcMem, skin.hbmpSkinParts[i][SP_EDGE_RIGHT], &rc, opt.transfMode[i]); - } - if (skin.hbmpSkinParts[i][SP_EDGE_BOTTOM]) // bottom - { - SetRect(&rc, left, rcHeight - bottom, rcWidth - right, rcHeight); - DrawBitmapPart(hdcMem, skin.hbmpSkinParts[i][SP_EDGE_BOTTOM], &rc, opt.transfMode[i]); - } - if (skin.hbmpSkinParts[i][SP_EDGE_LEFT]) // left - { - SetRect(&rc, 0, top, left, rcHeight - bottom); - DrawBitmapPart(hdcMem, skin.hbmpSkinParts[i][SP_EDGE_LEFT], &rc, opt.transfMode[i]); - } - - // draw corners - if (skin.hbmpSkinParts[i][SP_CORNER_TL]) // TL - { - SelectObject(hdcMem, skin.hbmpSkinParts[i][SP_CORNER_TL]); - AlphaBlend(skin.hdc, 0, 0, left, top, hdcMem, 0, 0, left, top, blend); - } - if (skin.hbmpSkinParts[i][SP_CORNER_TR]) // TR - { - SelectObject(hdcMem, skin.hbmpSkinParts[i][SP_CORNER_TR]); - AlphaBlend(skin.hdc, rcWidth - right, 0, right, top, hdcMem, 0, 0, right, top, blend); - } - if (skin.hbmpSkinParts[i][SP_CORNER_BR]) // BR - { - SelectObject(hdcMem, skin.hbmpSkinParts[i][SP_CORNER_BR]); - AlphaBlend(skin.hdc, rcWidth - right, rcHeight - bottom, right, bottom, hdcMem, 0, 0, right, bottom, blend); - } - if (skin.hbmpSkinParts[i][SP_CORNER_BL]) // BL - { - SelectObject(hdcMem, skin.hbmpSkinParts[i][SP_CORNER_BL]); - AlphaBlend(skin.hdc, 0, rcHeight - bottom, left, bottom, hdcMem, 0, 0, left, bottom, blend); - } - } - - for (int j = 0; j < SP_CORNER_TL; j++) - { - if (skin.hbmpSkinParts[i][j]) - { - DeleteObject(skin.hbmpSkinParts[i][j]); - skin.hbmpSkinParts[i][j] = NULL; - } - } - - if (MyUpdateLayeredWindow) - skin.bNeedLayerUpdate = true; - - DeleteDC(hdcMem); - } - } - - skin.bCached = true; -} - -void SolidColorFill(bool bServiceTip) -{ - RECT rc = {0}; - rc.right = skin.iWidth; - rc.bottom = skin.iHeight; - HBRUSH hBrush = CreateSolidBrush(opt.colBg); - FillRect(skin.hdc, &rc, hBrush); - DeleteObject(hBrush); - - if (opt.iSidebarWidth > 0 && !bServiceTip) - { - rc.right = opt.iSidebarWidth; - hBrush = CreateSolidBrush(opt.colSidebar); - FillRect(skin.hdc, &rc, hBrush); - DeleteObject(hBrush); - } -} - -void CreateSkinBitmap(int iWidth, int iHeight, bool bServiceTip) -{ - if (skin.hBitmap) DeleteObject(skin.hBitmap); - if (skin.hdc) DeleteDC(skin.hdc); - skin.hBitmap = NULL; - skin.hdc = NULL; - - skin.iWidth = iWidth; - skin.iHeight = iHeight; - skin.bNeedLayerUpdate = false; - - BITMAPINFO bi; - bi.bmiHeader.biSize = sizeof(bi.bmiHeader); - bi.bmiHeader.biWidth = skin.iWidth; - bi.bmiHeader.biHeight = -skin.iHeight; - bi.bmiHeader.biPlanes = 1; - bi.bmiHeader.biBitCount = 32; - bi.bmiHeader.biCompression = BI_RGB; - skin.hBitmap = (HBITMAP)CreateDIBSection(0, &bi, DIB_RGB_COLORS, (void **)&skin.colBits, 0, 0); - - if (!skin.hBitmap) - return; - - skin.hdc = CreateCompatibleDC(0); - DeleteObject(SelectObject(skin.hdc, skin.hBitmap)); - - if (opt.skinMode == SM_COLORFILL) - { - SolidColorFill(bServiceTip); - } - else - { - CreateFromBitmaps(bServiceTip); - if (opt.iEnableColoring == 1) - ColorizeBitmap(); - } -} - -void DestroySkinBitmap() -{ - for (int i = 0; i < SKIN_ITEMS_COUNT; i++) - { - if (skin.fib[i]) - { - fii->FI_Unload(skin.fib[i]); - skin.fib[i] = NULL; - } - - for (int j = SP_CORNER_TL; j < SKIN_PARTS_COUNT; j++) - { - if (skin.hbmpSkinParts[i][j]) - { - DeleteObject(skin.hbmpSkinParts[i][j]); - skin.hbmpSkinParts[i][j] = NULL; - } - } - } - - skin.bCached = false; -} - -void SaveAlpha(LPRECT lpRect) -{ - if (skin.colSavedBits) - { - mir_free(skin.colSavedBits); - skin.colSavedBits = 0; - } - GdiFlush(); - - if (lpRect->left < 0) lpRect->left = 0; - if (lpRect->top < 0) lpRect->top = 0; - if (lpRect->right > skin.iWidth) lpRect->right = skin.iWidth; - if (lpRect->bottom > skin.iHeight) lpRect->bottom = skin.iHeight; - - int x = lpRect->left; - int y = lpRect->top; - int w = lpRect->right - lpRect->left; - int h = lpRect->bottom - lpRect->top; - - skin.colSavedBits = (COLOR32 *)mir_alloc(sizeof(COLOR32) * w * h); - COLOR32 *p1 = skin.colSavedBits; - - for (int i = 0; i < h; i++) - { - if (i+y < 0) continue; - if (i+y >= skin.iHeight) break; - COLOR32 *p2 = skin.colBits + (y+i)*skin.iWidth + x; - for (int j = 0; j < w; j++) - { - if (j+x < 0) continue; - if (j+x >= skin.iWidth) break; - *p1++ = *p2++; - } - } -} - -void RestoreAlpha(LPRECT lpRect, BYTE alpha) -{ - if (!skin.colSavedBits) - return; - - GdiFlush(); - - if (lpRect->left < 0) lpRect->left = 0; - if (lpRect->top < 0) lpRect->top = 0; - if (lpRect->right > skin.iWidth) lpRect->right = skin.iWidth; - if (lpRect->bottom > skin.iHeight) lpRect->bottom = skin.iHeight; - - int x = lpRect->left; - int y = lpRect->top; - int w = lpRect->right - lpRect->left; - int h = lpRect->bottom - lpRect->top; - - COLOR32 *p1 = skin.colSavedBits; - - for (int i = 0; i < h; i++) - { - if (i+y < 0) continue; - if (i+y >= skin.iHeight) break; - COLOR32 *p2 = skin.colBits + (y+i)*skin.iWidth + x; - for (int j = 0; j < w; j++) - { - if (j+x < 0) continue; - if (j+x >= skin.iWidth) break; - if ((*p1&0x00ffffff) != (*p2&0x00ffffff)) - { - *p2 |= (alpha << 24); - } - else - { - *p2 = (*p2&0x00ffffff) | (*p1&0xff000000); - } - ++p1; - ++p2; - } - } - - mir_free(skin.colSavedBits); - skin.colSavedBits = 0; -} - -BOOL IsAlphaTransparent(HBITMAP hBitmap) -{ - BITMAP bmp; - DWORD dwLen; - BYTE *p; - - GetObject(hBitmap, sizeof(bmp), &bmp); - - if (bmp.bmBitsPixel != 32) - return FALSE; - - dwLen = bmp.bmWidth * bmp.bmHeight * (bmp.bmBitsPixel / 8); - p = (BYTE *)mir_alloc(dwLen); - if (p == NULL) return FALSE; - memset(p, 0, dwLen); - - GetBitmapBits(hBitmap, dwLen, p); - - for (int y = 0; y < bmp.bmHeight; y++) - { - BYTE *px = p + bmp.bmWidth * 4 * y; - for (int x = 0; x < bmp.bmWidth; x++) - { - if (px[3] != 0) - { - mir_free(p); - return TRUE; - } - - px += 4; - } - } - - mir_free(p); - return FALSE; -} - -void DrawIconExAlpha(HDC hdc, int xLeft, int yTop, HICON hIcon, int cxWidth, int cyWidth, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags, bool bIsSmiley) -{ - bool restore = false; - - if (skin.bNeedLayerUpdate && !bIsSmiley) - { - ICONINFO icon; - if (GetIconInfo(hIcon, &icon)) - { - if (!IsAlphaTransparent(icon.hbmColor)) - { - RECT rc; - SetRect(&rc, xLeft, yTop, xLeft + cxWidth, yTop + cyWidth); - SaveAlpha(&rc); - restore = true; - } - - DeleteObject(icon.hbmColor); - DeleteObject(icon.hbmMask); - } - } - - DrawIconEx(hdc, xLeft, yTop, hIcon, cxWidth, cyWidth, istepIfAniCur, hbrFlickerFreeDraw, diFlags); - - if (skin.bNeedLayerUpdate && restore) - { - RECT rc; - SetRect(&rc, xLeft, yTop, xLeft + cxWidth, yTop + cyWidth); - RestoreAlpha(&rc); - } -} - -int DrawTextAlpha(HDC hdc, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat) -{ - RECT rc; - SetRect(&rc, lpRect->left - 1, lpRect->top - 1, lpRect->right + 1, lpRect->bottom + 1); - - if (skin.bNeedLayerUpdate) SaveAlpha(&rc); - int result = DrawText(hdc, lpString, nCount, lpRect, uFormat); - if (skin.bNeedLayerUpdate) RestoreAlpha(&rc); - - return result; -} - -static __forceinline COLOR32 rgba(COLOR32 r, COLOR32 g, COLOR32 b, COLOR32 a) -{ - return ((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); -} - -static __forceinline COLOR32 getr(COLOR32 c) -{ - return (c >> 16) & 0xff; -} - -static __forceinline COLOR32 getg(COLOR32 c) -{ - return (c >> 8) & 0xff; -} - -static __forceinline COLOR32 getb(COLOR32 c) -{ - return c & 0xff; -} - -static __forceinline COLOR32 geta(COLOR32 c) -{ - return (c >> 24) & 0xff; -} - -void PremultipleChannels() -{ - for (int i = 0; i < skin.iWidth * skin.iHeight; i++) - skin.colBits[i] = rgba( getr(skin.colBits[i])*geta(skin.colBits[i])/255, - getg(skin.colBits[i])*geta(skin.colBits[i])/255, - getb(skin.colBits[i])*geta(skin.colBits[i])/255, - geta(skin.colBits[i])); -} - -#define PU_DIV255(x) ((x)/255) - -void ColorizeBitmap() -{ - if (!skin.colBits) - return; - - GdiFlush(); - - int w = skin.iWidth; - int h = skin.iHeight; - - // we should swap B and R channels when working with win32 COLORREF - float koef1r = (255 - getb(opt.colBg)) / 128.0; - float koef1g = (255 - getg(opt.colBg)) / 128.0; - float koef1b = (255 - getr(opt.colBg)) / 128.0; - - int br = - 255 + 2 * getb(opt.colBg); - int bg = - 255 + 2 * getg(opt.colBg); - int bb = - 255 + 2 * getr(opt.colBg); - - float koef2r = (getb(opt.colBg)) / 128.0; - float koef2g = (getg(opt.colBg)) / 128.0; - float koef2b = (getr(opt.colBg)) / 128.0; - - for (int i = 0; i < w * h; i++) - { - long alpha = geta(skin.colBits[i]); - COLOR32 cl = alpha ? getr(skin.colBits[i])*255/alpha : 0; - - skin.colBits[i] = (cl > 128) ? - rgba( - PU_DIV255((koef1r * cl + br)*alpha), - PU_DIV255((koef1g * cl + bg)*alpha), - PU_DIV255((koef1b * cl + bb)*alpha), - alpha): - rgba( - PU_DIV255(koef2r * cl * alpha), - PU_DIV255(koef2g * cl * alpha), - PU_DIV255(koef2b * cl * alpha), - alpha); - } -} - -// code from Clist Modern by FYR -HRGN CreateOpaqueRgn(BYTE level, bool bOpaque) -{ - if (!skin.colBits) - return NULL; - - GdiFlush(); - - RGBQUAD *buff = (RGBQUAD *)skin.colBits; - - int x,y; - unsigned int cRect = 64; - PRGNDATA pRgnData = (PRGNDATA)malloc(sizeof(RGNDATAHEADER) + (cRect)*sizeof(RECT)); - memset(pRgnData, 0, sizeof(RGNDATAHEADER)); - pRgnData->rdh.dwSize = sizeof(RGNDATAHEADER); - pRgnData->rdh.iType = RDH_RECTANGLES; - - for (y = 0; y < skin.iHeight; ++y) - { - bool inside = false; - bool lastin = false; - unsigned int entry = 0; - - for (x = 0; x < skin.iWidth; ++x) - { - inside = bOpaque ? (buff->rgbReserved > level) : (buff->rgbReserved < level); - ++buff; - - if (inside != lastin) - { - if (inside) - { - lastin = true; - entry = x; - } - else - { - if (pRgnData->rdh.nCount == cRect) - { - cRect = cRect + 64; - pRgnData = (PRGNDATA)realloc(pRgnData, sizeof(RGNDATAHEADER) + (cRect)*sizeof(RECT)); - } - - SetRect(((LPRECT)pRgnData->Buffer) + pRgnData->rdh.nCount, entry, skin.iHeight - y, x, skin.iHeight - y + 1); - pRgnData->rdh.nCount++; - lastin = false; - } - } - } - - if (lastin) - { - if (pRgnData->rdh.nCount == cRect) - { - cRect = cRect + 64; - pRgnData = (PRGNDATA)realloc(pRgnData, sizeof(RGNDATAHEADER) + (cRect)*sizeof(RECT)); - } - - SetRect(((LPRECT)pRgnData->Buffer) + pRgnData->rdh.nCount, entry, skin.iHeight - y, x, skin.iHeight - y + 1); - pRgnData->rdh.nCount++; - } - } - - HRGN hRgn = ExtCreateRegion(NULL, sizeof(RGNDATAHEADER) + pRgnData->rdh.nCount*sizeof(RECT), (LPRGNDATA)pRgnData); - free(pRgnData); - return hRgn; -} \ No newline at end of file diff --git a/plugins/TipperYM/bitmap_func.h b/plugins/TipperYM/bitmap_func.h deleted file mode 100644 index e6ffbc4880..0000000000 --- a/plugins/TipperYM/bitmap_func.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -Copyright (C) 2006-2007 Scott Ellis -Copyright (C) 2007-2011 Jan Holub - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this file; see the file license.txt. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. -*/ - -#ifndef _BITMAP_FUNC_INC -#define _BITMAP_FUNC_INC - -// tooltip skin -#define SKIN_ITEMS_COUNT 2 -#define SKIN_PARTS_COUNT 9 -#define SKIN_ITEM_BG 0 -#define SKIN_ITEM_SIDEBAR 1 - -// skin parts -#define SP_CENTRE_AREA 0 -#define SP_EDGE_TOP 1 -#define SP_EDGE_RIGHT 2 -#define SP_EDGE_BOTTOM 3 -#define SP_EDGE_LEFT 4 -#define SP_CORNER_TL 5 -#define SP_CORNER_TR 6 -#define SP_CORNER_BR 7 -#define SP_CORNER_BL 8 - -// image paint options -typedef enum { - TM_NONE = 0, TM_CENTRE = 1, TM_STRECH_ALL = 2, TM_STRECH_HORIZONTAL = 3, TM_STRECH_VERTICAL = 4, - TM_TILE_ALL = 5, TM_TILE_HORIZONTAL = 6, TM_TILE_VERTICAL = 7 -} TransformationMode; - -typedef unsigned long COLOR32; -typedef struct { - HDC hdc; - HBITMAP hBitmap; - HBITMAP hbmpSkinParts[SKIN_ITEMS_COUNT][SKIN_PARTS_COUNT]; - FIBITMAP *fib[SKIN_ITEMS_COUNT]; - COLOR32 *colBits; - COLOR32 *colSavedBits; - int iWidth; - int iHeight; - bool bNeedLayerUpdate; - bool bCached; -} TOOLTIPSKIN; - -void CreateSkinBitmap(int iWidth, int iHeight, bool bServiceTip); -void DestroySkinBitmap(); -int DrawTextAlpha(HDC hdc, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat); -void DrawIconExAlpha(HDC hdc, int xLeft, int yTop, HICON hIcon, int cxWidth, int cyWidth, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags, bool bIsSmiley); -void SaveAlpha(LPRECT lpRect); -void RestoreAlpha(LPRECT lpRect, BYTE alpha = 0xff); -void PremultipleChannels(); -void ColorizeBitmap(); -HRGN CreateOpaqueRgn(BYTE level, bool bOpaque); - -#endif diff --git a/plugins/TipperYM/common.h b/plugins/TipperYM/common.h deleted file mode 100644 index ab678bac79..0000000000 --- a/plugins/TipperYM/common.h +++ /dev/null @@ -1,103 +0,0 @@ -/* -Copyright (C) 2006-2007 Scott Ellis -Copyright (C) 2007-2011 Jan Holub - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this file; see the file license.txt. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. -*/ - -#pragma once - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Allow use of features specific to Windows XP or later. -#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. -#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later. -#define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE. -#endif - -#define MIRANDA_VER 0x0A00 - -#include - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files: -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "resource.h" -#include "m_tipper.h" -#include "m_fingerprint.h" -#include "m_flags.h" -#include "m_folders.h" -#include "m_metacontacts.h" -#include "m_variables.h" -#include "m_smileyadd.h" - -// {8392DF1D-9090-4f8e-9DF6-2FE058EDD800} -#define MIID_TIPPER { 0x8392df1d, 0x9090, 0x4f8e, { 0x9d, 0xf6, 0x2f, 0xe0, 0x58, 0xed, 0xd8, 0x00 } } - -#define MODULE "Tipper" -#define MODULE_ITEMS "Tipper_Items" -#define DEFAULT_SKIN_FOLDER "Skins\\Tipper" - -extern HMODULE hInst; - -extern HFONT hFontTitle, hFontLabels, hFontValues, hFontTrayTitle; -extern COLORREF colTitle, colLabels, colBg, colValues; - -extern int iCodePage; -extern char szMetaModuleName[256]; - -extern FI_INTERFACE *fii; \ No newline at end of file diff --git a/plugins/TipperYM/docs/tipperym-translation.txt b/plugins/TipperYM/docs/tipperym-translation.txt new file mode 100644 index 0000000000..f13fb40443 --- /dev/null +++ b/plugins/TipperYM/docs/tipperym-translation.txt @@ -0,0 +1,352 @@ +; Common strings that belong to many files +;[%dd %dh %dm] +;[%dh %dm] +;[%dm] +;[Add] +;[Apply skin] +;[Avatar border] +;[Avatar size:] +;[Border] +;[Client] +;[Edit] +;[Favourite contacts] +;[Gender] +;[Get more skins] +;[Listening to] +;[Listening to:] +;[None] +;[Reload skin list] +;[Remove] +;[Skins] +;[Status] +;[Status message] +;[Status message:] +;[Status:] +;[Tooltips] + +; ../../plugins/TipperYM/mir_smileys.cpp +;[Tipper smileys] + +; ../../plugins/TipperYM/options.cpp +;[] +;[Add item] +;[Add separator] +;[Animation] +;[Appearance] +;[Bottom] +;[Bottom left] +;[Bottom right] +;[Centre] +;[Content] +;[Customize] +;[Extra] +;[Fade] +;[Icon on left] +;[Icon on right] +;[Invalid Substitution] +;[Left] +;[Left avatar] +;[Max avatar size:] +;[Move down] +;[Move up] +;[No avatar] +;[No icon] +;[No title] +;[Right] +;[Right avatar] +;[Top] +;[Top left] +;[Top right] +;[Tray tooltip] +;[You must enter a label] + +; ../../plugins/TipperYM/options.h +;[Clist event] +;[Country flag] +;[Extra status] +;[Jabber activity] +;[Logon time] +;[Miranda uptime] +;[Number of contacts] +;[Protocol lock status] +;[Unread emails] + +; ../../plugins/TipperYM/popwin.cpp +;[ ago] +;[%s (locked)] +;[: ] +;[] +;[Activity:] +;[Copy all items] +;[Copy all items with labels] +;[Copy avatar] +;[Fav. contacts] +;[Log off:] +;[Log on:] +;[Miranda uptime:] +;[Mood:] +;[Other] +;[Unread emails:] +;[XStatus:] + +; ../../plugins/TipperYM/preset_items.cpp +;[%sys:uidname|UID^!MetaContacts%:] +;[Activity text:] +;[Activity title:] +;[Birthday] +;[Birthday:] +;[Client:] +;[Condition:] +;[Contact time] +;[Email] +;[Email:] +;[Gender:] +;[Homepage] +;[Homepage:] +;[Humidity:] +;[IP] +;[IP internal] +;[IP internal:] +;[IP:] +;[Identifier] +;[Idle] +;[Idle:] +;[Last message] +;[Last message: (%sys:last_msg_reltime% ago)] +;[Last seen status:] +;[Last seen time:] +;[Logoff time:] +;[Logon time:] +;[Max/Min:] +;[Moon:] +;[Name] +;[Name:] +;[Number of msg [IN]:] +;[Number of msg [OUT]:] +;[Number of received messages] +;[Number of sended messages] +;[Pressure:] +;[Sunrise:] +;[Sunset:] +;[Temperature:] +;[Time:] +;[UV Index:] +;[Update time:] +;[Visibility:] +;[Wind:] +;[XStatus text] +;[XStatus text:] +;[XStatus title] +;[XStatus title:] +;[[jabber.dll] Activity text] +;[[jabber.dll] Activity title] +;[[menuex.dll] Logoff time] +;[[menuex.dll] Logon time] +;[[seenplugin.dll] Last seen status] +;[[seenplugin.dll] Last seen time] +;[[weather.dll] Condition] +;[[weather.dll] Humidity] +;[[weather.dll] Max/Min temperature] +;[[weather.dll] Moon] +;[[weather.dll] Pressure] +;[[weather.dll] Sunrise] +;[[weather.dll] Sunset] +;[[weather.dll] Temperature] +;[[weather.dll] UV Index] +;[[weather.dll] Update time] +;[[weather.dll] Visibility] +;[[weather.dll] Wind] + +; ../../plugins/TipperYM/resource.rc +;[Advanced options] +;[Aero Glass (Vista+)] +;[Alignment] +;[Animation speed:] +;[Append protocol name] +;[Cancel] +;[Contact protocol module] +;[Disable in invisible status] +;[Down] +;[Draw a line above] +;[Effects] +;[Enable SmileyAdd support] +;[Enable skin coloring] +;[Enable tray tooltips] +;[Expand to second level after:] +;[Extra icons] +;[First level tooltip] +;[General padding:] +;[Handle tray tooltips by Tipper] +;[Hide offline] +;[Hide offline protocols] +;[Hover time:] +;[Inner avatar padding:] +;[Item] +;[Items] +;[Keep original avatar size] +;[Label:] +;[Labels:] +;[Layout] +;[Limit status messages in status bar and tray tooltips to:] +;[Load fonts and colors] +;[Load tooltip proportions] +;[Max height:] +;[Max width:] +;[Min height:] +;[Min width:] +;[Module:] +;[No preview] +;[OK] +;[Opacity(%):] +;[Options] +;[Outer avatar padding:] +;[Parse Tipper variables first] +;[Preset items:] +;[Preview] +;[Replace only isolated smileys] +;[Resize smileys] +;[Retrieve XStatus details if auto-retrieve is disabled] +;[Retrieve new status message] +;[Round corners (avatar)] +;[Round corners (window)] +;[Second level tooltip] +;[Separator] +;[Setting or prefix:] +;[Shadow] +;[Show if list not focused] +;[Show tooltip after all content is ready (avatar && status message)] +;[Sidebar width:] +;[Skin option] +;[Smileys support] +;[Status bar and tray tooltip] +;[Status bar tips] +;[Substitution] +;[Substitutions] +;[Text indent:] +;[Text padding:] +;[Title indent:] +;[Translation:] +;[Transparency] +;[Up] +;[Use protocol smileys] +;[Value indent:] +;[Value on a new line] +;[Value:] +;[Values:] +;[Variables] +;[Window] +;[characters] +;[ms] + +; ../../plugins/TipperYM/skin_parser.cpp +;[# Solid color fill] + +; ../../plugins/TipperYM/tipper.cpp +;[Background] +;[Cannot obtain required interfaces!\nTooltips will not be available until you upgrade Miranda IM to the newest version.] +;[Dividers] +;[Labels] +;[Sidebar] +;[Tipper error] +;[Title] +;[Tray title] +;[Values] + +; ../../plugins/TipperYM/translations.cpp +;[%dd] +;[%dy %dd %dh %dm] +;[Female] +;[Male] + +; ../../plugins/TipperYM/translations.h +;[Afrikaans] +;[Albanian] +;[April] +;[Arabic] +;[Armenian] +;[August] +;[Azerbaijani] +;[Belorussian] +;[Bhojpuri] +;[Bosnian] +;[Bulgarian] +;[Burmese] +;[Cantonese] +;[Catalan] +;[Chamorro] +;[Chinese] +;[Croatian] +;[Czech] +;[Danish] +;[December] +;[Dutch] +;[English] +;[Esperanto] +;[Estonian] +;[Farsi] +;[February] +;[Finnish] +;[French] +;[Friday] +;[Gaelic] +;[German] +;[Greek] +;[Gujarati] +;[Hebrew] +;[Hindi] +;[Hungarian] +;[Icelandic] +;[Indonesian] +;[Italian] +;[January] +;[Japanese] +;[July] +;[June] +;[Khmer] +;[Korean] +;[Kurdish] +;[Lao] +;[Latvian] +;[Lithuanian] +;[Macedonian] +;[Malay] +;[Mandarin] +;[March] +;[May] +;[Monday] +;[Mongolian] +;[Norwegian] +;[November] +;[October] +;[Persian] +;[Polish] +;[Portuguese] +;[Punjabi] +;[Romanian] +;[Russian] +;[Saturday] +;[September] +;[Serbo-Croatian] +;[Sindhi] +;[Slovak] +;[Slovenian] +;[Somali] +;[Spanish] +;[Sunday] +;[Swahili] +;[Swedish] +;[Tagalog] +;[Taiwanese] +;[Tamil] +;[Tatar] +;[Thai] +;[Thursday] +;[Tuesday] +;[Turkish] +;[Ukrainian] +;[Urdu] +;[Vietnamese] +;[Wednesday] +;[Welsh] +;[Yiddish] +;[Yoruba] diff --git a/plugins/TipperYM/message_pump.cpp b/plugins/TipperYM/message_pump.cpp deleted file mode 100644 index 7032ad84b2..0000000000 --- a/plugins/TipperYM/message_pump.cpp +++ /dev/null @@ -1,413 +0,0 @@ -/* -Copyright (C) 2006-2007 Scott Ellis -Copyright (C) 2007-2011 Jan Holub - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this file; see the file license.txt. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. -*/ - -#include "common.h" -#include "message_pump.h" -#include "popwin.h" -#include "options.h" -#include "str_utils.h" -#include "subst.h" - -BOOL (WINAPI *MySetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD) = 0; -BOOL (WINAPI *MyUpdateLayeredWindow)(HWND hwnd, HDC hdcDST, POINT *pptDst, SIZE *psize, HDC hdcSrc, POINT *pptSrc, COLORREF crKey, BLENDFUNCTION *pblend, DWORD dwFlags) = 0; -BOOL (WINAPI *MyAnimateWindow)(HWND hWnd,DWORD dwTime,DWORD dwFlags) = 0; -HMONITOR (WINAPI *MyMonitorFromPoint)(POINT, DWORD); -BOOL (WINAPI *MyGetMonitorInfo)(HMONITOR, LPMONITORINFO); -HRESULT (WINAPI *MyDwmEnableBlurBehindWindow)(HWND hWnd, DWM_BLURBEHIND *pBlurBehind) = 0; - -unsigned int uintMessagePumpThreadId = 0; -POINT pt = {-1}; -UINT WaitForContentTimerID = 0; -bool bAvatarReady = false; -bool bStatusMsgReady = false; - -__inline bool IsContactTooltip(CLCINFOTIPEX *clc) -{ - return (clc->szProto || clc->swzText) == false; -} - -void CALLBACK TimerProcWaitForContent(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) -{ - KillTimer(0, WaitForContentTimerID); - WaitForContentTimerID = 0; - bStatusMsgReady = true; - bAvatarReady = true; - PostMPMessage(MUM_CREATEPOPUP, 0, 0); -} - -bool NeedWaitForContent(CLCINFOTIPEX *clcitex) -{ - bool bNeedWait = false; - - if (opt.bWaitForContent && IsContactTooltip(clcitex)) - { - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)clcitex->hItem, 0); - if (!szProto) return false; - - if (opt.bWaitForStatusMsg && !bStatusMsgReady) - { - DBDeleteContactSetting(clcitex->hItem, MODULE, "TempStatusMsg"); - if (CanRetrieveStatusMsg(clcitex->hItem, szProto) && - CallContactService(clcitex->hItem, PSS_GETAWAYMSG, 0, 0)) - { - if (WaitForContentTimerID) - KillTimer(0, WaitForContentTimerID); - - WaitForContentTimerID = SetTimer(NULL, 0, WAIT_TIMER_INTERVAL, TimerProcWaitForContent); - bNeedWait = true; - } - } - - if (opt.bWaitForAvatar && !bAvatarReady && - CallProtoService(szProto, PS_GETAVATARCAPS, AF_ENABLED, 0)) - { - DBVARIANT dbv; - if (!DBGetContactSettingString(clcitex->hItem, "ContactPhoto", "File", &dbv)) - { - if (!strstr(dbv.pszVal, ".xml")) - { - AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)clcitex->hItem, 0); - if (!ace) - { - if (WaitForContentTimerID) - KillTimer(0, WaitForContentTimerID); - - WaitForContentTimerID = SetTimer(NULL, 0, WAIT_TIMER_INTERVAL, TimerProcWaitForContent); - bNeedWait = true; - } - else - bAvatarReady = true; - } - else - bAvatarReady = true; - - DBFreeVariant(&dbv); - } - else - bAvatarReady = true; - } - - } - - return bNeedWait; -} - -unsigned int CALLBACK MessagePumpThread(void *param) -{ - HWND hwndTip = 0; - CLCINFOTIPEX *clcitex = 0; - - MSG hwndMsg = {0}; - while (GetMessage(&hwndMsg, 0, 0, 0) > 0 && !Miranda_Terminated()) - { - if (!IsDialogMessage(hwndMsg.hwnd, &hwndMsg)) - { - switch (hwndMsg.message) - { - case MUM_CREATEPOPUP: - { - if (!clcitex) - { - if (hwndMsg.lParam) clcitex = (CLCINFOTIPEX *)hwndMsg.lParam; - else break; - } - - if (!NeedWaitForContent(clcitex)) - { - if (hwndTip) MyDestroyWindow(hwndTip); - hwndTip = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, POP_WIN_CLASS, NULL, WS_POPUP, 0, 0, 0, 0, 0, 0, hInst, (LPVOID)clcitex); - - if (clcitex) - { - mir_free(clcitex); - clcitex = 0; - } - - bStatusMsgReady = false; - bAvatarReady = false; - } - break; - } - case MUM_DELETEPOPUP: - { - if (hwndTip) - { - MyDestroyWindow(hwndTip); - hwndTip = 0; - } - - if (clcitex) - { - mir_free(clcitex); - clcitex = 0; - } - - bStatusMsgReady = false; - bAvatarReady = false; - break; - } - case MUM_GOTSTATUS: - { - HANDLE hContact = (HANDLE)hwndMsg.wParam; - TCHAR *swzMsg = (TCHAR *)hwndMsg.lParam; - - if (opt.bWaitForContent && - bStatusMsgReady == false && - clcitex && - clcitex->hItem == hContact) - { - if (WaitForContentTimerID) - { - KillTimer(0, WaitForContentTimerID); - WaitForContentTimerID = 0; - } - - if (swzMsg) - { - DBWriteContactSettingTString(clcitex->hItem, MODULE, "TempStatusMsg", swzMsg); - mir_free(swzMsg); - } - - bStatusMsgReady = true; - PostMPMessage(MUM_CREATEPOPUP, 0, 0); - } - else if (!opt.bWaitForContent && hwndTip) - SendMessage(hwndTip, PUM_SETSTATUSTEXT, (WPARAM)hContact, (LPARAM)swzMsg); - else if (swzMsg) - mir_free(swzMsg); - - break; - } - case MUM_GOTXSTATUS: - { - if (hwndTip && !opt.bWaitForContent) - SendMessage(hwndTip, PUM_SHOWXSTATUS, hwndMsg.wParam, 0); - break; - } - case MUM_GOTAVATAR: - { - HANDLE hContact = (HANDLE)hwndMsg.wParam; - - if (opt.bWaitForContent && - bAvatarReady == false && - clcitex && - clcitex->hItem == hContact) - { - if (WaitForContentTimerID) - { - KillTimer(0, WaitForContentTimerID); - WaitForContentTimerID = 0; - } - - bAvatarReady = true; - PostMPMessage(MUM_CREATEPOPUP, 0, 0); - } - else if (!opt.bWaitForContent && hwndTip) - SendMessage(hwndTip, PUM_SETAVATAR, hwndMsg.wParam, 0); - - break; - } - default: - { - TranslateMessage(&hwndMsg); - DispatchMessage(&hwndMsg); - break; - } - } - } - } - - return 0; -} - -void PostMPMessage(UINT msg, WPARAM wParam, LPARAM lParam) -{ - PostThreadMessage(uintMessagePumpThreadId, msg, wParam, lParam); -} - -void InitMessagePump() -{ - WNDCLASSEX wcl = {0}; - wcl.cbSize = sizeof(wcl); - wcl.lpfnWndProc = PopupWindowProc; - wcl.hInstance = hInst; - wcl.hCursor = LoadCursor(NULL, IDC_ARROW); - wcl.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH); - wcl.lpszClassName = POP_WIN_CLASS; - RegisterClassEx(&wcl); - - HMODULE hUserDll = LoadLibrary(_T("user32.dll")); - if (hUserDll) - { - MySetLayeredWindowAttributes = (BOOL (WINAPI *)(HWND,COLORREF,BYTE,DWORD))GetProcAddress(hUserDll, "SetLayeredWindowAttributes"); - MyUpdateLayeredWindow = (BOOL (WINAPI *)(HWND hwnd, HDC hdcDST, POINT *pptDst, SIZE *psize, HDC hdcSrc, POINT *pptSrc, COLORREF crKey, BLENDFUNCTION *pblend, DWORD dwFlags))GetProcAddress(hUserDll, "UpdateLayeredWindow"); - MyAnimateWindow =(BOOL (WINAPI*)(HWND,DWORD,DWORD))GetProcAddress(hUserDll, "AnimateWindow"); - MyMonitorFromPoint = (HMONITOR (WINAPI*)(POINT, DWORD))GetProcAddress(hUserDll, "MonitorFromPoint"); - MyGetMonitorInfo = (BOOL (WINAPI*)(HMONITOR, LPMONITORINFO))GetProcAddress(hUserDll, "GetMonitorInfoW"); - - } - - HMODULE hDwmapiDll = LoadLibrary(_T("dwmapi.dll")); - if (hDwmapiDll) - MyDwmEnableBlurBehindWindow = (HRESULT (WINAPI *)(HWND, DWM_BLURBEHIND *))GetProcAddress(hDwmapiDll, "DwmEnableBlurBehindWindow"); - - CloseHandle(mir_forkthreadex(MessagePumpThread, NULL, &uintMessagePumpThreadId)); -} - -void DeinitMessagePump() -{ - PostMPMessage(WM_QUIT, 0, 0); - UnregisterClass(POP_WIN_CLASS, hInst); -} - -INT_PTR ShowTip(WPARAM wParam, LPARAM lParam) -{ - CLCINFOTIP *clcit = (CLCINFOTIP *)lParam; - HWND clist = (HWND)CallService(MS_CLUI_GETHWNDTREE, 0, 0); - - if (clcit->isGroup) return 0; // no group tips (since they're pretty useless) - if (clcit->isTreeFocused == 0 && opt.bShowNoFocus == false && clist == WindowFromPoint(clcit->ptCursor)) return 0; - if (clcit->ptCursor.x == pt.x && clcit->ptCursor.y == pt.y) return 0; - pt.x = pt.y = 0; - - CLCINFOTIPEX *clcit2 = (CLCINFOTIPEX *)mir_alloc(sizeof(CLCINFOTIPEX)); - memcpy(clcit2, clcit, sizeof(CLCINFOTIP)); - clcit2->cbSize = sizeof(CLCINFOTIPEX); - clcit2->szProto = NULL; - clcit2->swzText = NULL; - - if (wParam) // wParam is char pointer containing text - e.g. status bar tooltip - { - clcit2->swzText = a2t((char *)wParam); - GetCursorPos(&clcit2->ptCursor); - } - - PostMPMessage(MUM_CREATEPOPUP, 0, (LPARAM)clcit2); - return 1; -} - -int ShowTipHook(WPARAM wParam, LPARAM lParam) -{ - ShowTip(wParam, lParam); - return 0; -} - -INT_PTR ShowTipW(WPARAM wParam, LPARAM lParam) -{ - CLCINFOTIP *clcit = (CLCINFOTIP *)lParam; - HWND clist = (HWND)CallService(MS_CLUI_GETHWNDTREE, 0, 0); - - if (clcit->isGroup) return 0; // no group tips (since they're pretty useless) - if (clcit->isTreeFocused == 0 && opt.bShowNoFocus == false && clist == WindowFromPoint(clcit->ptCursor)) return 0; - if (clcit->ptCursor.x == pt.x && clcit->ptCursor.y == pt.y) return 0; - pt.x = pt.y = -1; - - CLCINFOTIPEX *clcit2 = (CLCINFOTIPEX *)mir_alloc(sizeof(CLCINFOTIPEX)); - memcpy(clcit2, clcit, sizeof(CLCINFOTIP)); - clcit2->cbSize = sizeof(CLCINFOTIPEX); - clcit2->szProto = NULL; - clcit2->swzText = NULL; - - if (wParam) // wParam is char pointer containing text - e.g. status bar tooltip - { - clcit2->swzText = mir_tstrdup((TCHAR *)wParam); - GetCursorPos(&clcit2->ptCursor); - } - - PostMPMessage(MUM_CREATEPOPUP, 0, (LPARAM)clcit2); - return 1; -} - -INT_PTR HideTip(WPARAM wParam, LPARAM lParam) -{ - //CLCINFOTIP *clcit = (CLCINFOTIP *)lParam; - if (GetAsyncKeyState(VK_CONTROL) & 0x8000) - return 0; - - GetCursorPos(&pt); - PostMPMessage(MUM_DELETEPOPUP, 0, 0); - return 1; -} - -int HideTipHook(WPARAM wParam, LPARAM lParam) -{ - HideTip(wParam, lParam); - return 0; -} - -int ProtoAck(WPARAM wParam, LPARAM lParam) -{ - ACKDATA *ack = (ACKDATA *)lParam; - if (ack->result != ACKRESULT_SUCCESS) - return 0; - - if (ack->type == ACKTYPE_AWAYMSG) { - TCHAR* tszMsg = ( TCHAR* )ack->lParam; - if ( lstrlen(tszMsg)) - PostMPMessage(MUM_GOTSTATUS, (WPARAM)ack->hContact, (LPARAM)mir_tstrdup(tszMsg)); - } - else if (ack->type == ICQACKTYPE_XSTATUS_RESPONSE) - { - PostMPMessage(MUM_GOTXSTATUS, (WPARAM)ack->hContact, 0); - } - - return 0; -} - -int AvatarChanged(WPARAM wParam, LPARAM lParam) -{ - HANDLE hContact = (HANDLE)wParam; - PostMPMessage(MUM_GOTAVATAR, (WPARAM)hContact, 0); - return 0; -} - -int FramesShowSBTip(WPARAM wParam, LPARAM lParam) -{ - if (opt.bStatusBarTips) - { - char *szProto = (char *)wParam; - - CLCINFOTIPEX *clcit2 = (CLCINFOTIPEX *)mir_alloc(sizeof(CLCINFOTIPEX)); - memset(clcit2, 0, sizeof(CLCINFOTIPEX)); - clcit2->cbSize = sizeof(CLCINFOTIPEX); - clcit2->szProto= szProto; // assume static string - GetCursorPos(&clcit2->ptCursor); - - PostMPMessage(MUM_CREATEPOPUP, 0, (LPARAM)clcit2); - return 1; - } - return 0; -} - -int FramesHideSBTip(WPARAM wParam, LPARAM lParam) -{ - if (opt.bStatusBarTips) - { - PostMPMessage(MUM_DELETEPOPUP, 0, 0); - return 1; - } - return 0; -} - -BOOL MyDestroyWindow(HWND hwnd) -{ - SendMessage(hwnd, PUM_FADEOUTWINDOW, 0, 0); - return DestroyWindow(hwnd); -} \ No newline at end of file diff --git a/plugins/TipperYM/message_pump.h b/plugins/TipperYM/message_pump.h deleted file mode 100644 index a8858e3865..0000000000 --- a/plugins/TipperYM/message_pump.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -Copyright (C) 2006-2007 Scott Ellis -Copyright (C) 2007-2011 Jan Holub - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this file; see the file license.txt. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. -*/ - -#ifndef _MESSAGE_PUMP_INC -#define _MESSAGE_PUMP_INC - -#define WAIT_TIMER_INTERVAL 500 - -#define MUM_CREATEPOPUP (WM_USER + 0x011) -#define MUM_DELETEPOPUP (WM_USER + 0x012) -#define MUM_GOTSTATUS (WM_USER + 0x013) -#define MUM_GOTAVATAR (WM_USER + 0x014) -#define MUM_GOTXSTATUS (WM_USER + 0x015) - -extern BOOL (WINAPI *MySetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD); -extern BOOL (WINAPI *MyUpdateLayeredWindow)(HWND hwnd, HDC hdcDST, POINT *pptDst, SIZE *psize, HDC hdcSrc, POINT *pptSrc, COLORREF crKey, BLENDFUNCTION *pblend, DWORD dwFlags); -extern BOOL (WINAPI *MyAnimateWindow)(HWND hWnd,DWORD dwTime,DWORD dwFlags); -extern HMONITOR (WINAPI *MyMonitorFromPoint)(POINT, DWORD); -extern BOOL (WINAPI *MyGetMonitorInfo)(HMONITOR, LPMONITORINFO); - -#define DWM_BB_ENABLE 0x00000001 -#define DWM_BB_BLURREGION 0x00000002 -#define DWM_BB_TRANSITIONONMAXIMIZED 0x00000004 -struct DWM_BLURBEHIND -{ - DWORD dwFlags; - BOOL fEnable; - HRGN hRgnBlur; - BOOL fTransitionOnMaximized; -}; - -extern HRESULT (WINAPI *MyDwmEnableBlurBehindWindow)(HWND hWnd, DWM_BLURBEHIND *pBlurBehind); - -void InitMessagePump(); -void DeinitMessagePump(); - -INT_PTR ShowTip(WPARAM wParam, LPARAM lParam); -INT_PTR ShowTipW(WPARAM wParam, LPARAM lParam); -INT_PTR HideTip(WPARAM wParam, LPARAM lParam); - -int ShowTipHook(WPARAM wParam, LPARAM lParam); -int HideTipHook(WPARAM wParam, LPARAM lParam); - -int FramesShowSBTip(WPARAM wParam, LPARAM lParam); -int FramesHideSBTip(WPARAM wParam, LPARAM lParam); - -int ProtoAck(WPARAM wParam, LPARAM lParam); -int AvatarChanged(WPARAM wParam, LPARAM lParam); - -BOOL MyDestroyWindow(HWND hwnd); -void PostMPMessage(UINT msg, WPARAM, LPARAM); - - -#endif diff --git a/plugins/TipperYM/mir_smileys.cpp b/plugins/TipperYM/mir_smileys.cpp deleted file mode 100644 index 5af05c4b22..0000000000 --- a/plugins/TipperYM/mir_smileys.cpp +++ /dev/null @@ -1,514 +0,0 @@ -/* -Copyright (C) 2005 Ricardo Pescuma Domenecci -Copyright (C) 2007-2010 Jan Holub - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this file; see the file license.txt. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. -*/ - -#include "common.h" -#include "options.h" -#include "mir_smileys.h" - - - -void *mir_alloc0(size_t size) -{ - void *ptr = mir_alloc(size); - if (ptr) memset(ptr, 0, size); - - return ptr; -} - -int InitTipperSmileys() -{ - // Register smiley category - if (ServiceExists(MS_SMILEYADD_REGISTERCATEGORY)) - { - SMADD_REGCAT rc; - rc.cbSize = sizeof(rc); - rc.name = "tipper"; - rc.dispname = Translate("Tipper smileys"); - CallService(MS_SMILEYADD_REGISTERCATEGORY, 0, (LPARAM)&rc); - } - - return 0; -} - -SMILEYPARSEINFO Smileys_PreParse(LPCTSTR lpString, int nCount, const char *protocol) -{ - if (!(opt.iSmileyAddFlags & SMILEYADD_ENABLE)) - return NULL; - - if (nCount == -1) - nCount = (int)lstrlen(lpString); - - SMILEYPARSEINFO info = (SMILEYPARSEINFO) mir_alloc0(sizeof(tagSMILEYPARSEINFO)); - info->pieces = ReplaceSmileys(lpString, nCount, protocol, &info->max_height); - - if (!info->pieces) - { - mir_free(info); - return NULL; - } - - return info; -} - -void Smileys_FreeParse(SMILEYPARSEINFO parseInfo) -{ - if (parseInfo != NULL) - { - if (parseInfo->pieces != NULL) - DestroySmileyList(parseInfo->pieces); - - mir_free(parseInfo); - } -} - -// Similar to DrawText win32 api function -// Pass uFormat | DT_CALCRECT to calc rectangle to be returned by lpRect -// parseInfo is optional (pass NULL and it will be calculated and deleted inside function -int Smileys_DrawText(HDC hDC, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat, const char *protocol, SMILEYPARSEINFO parseInfo) -{ - int result; - - if (nCount == -1) - nCount = (int)lstrlen(lpString); - - if (uFormat & DT_CALCRECT) - { - SIZE text_size = GetTextSize(hDC, lpString, parseInfo, uFormat, parseInfo->max_height, (lpRect->right - lpRect->left)); - lpRect->bottom = text_size.cy; - - if (text_size.cx < lpRect->right - lpRect->left) - { - if (uFormat & DT_RIGHT) - lpRect->left = lpRect->right - text_size.cx; - else - lpRect->right = lpRect->left + text_size.cx; - } - - result = text_size.cy; - } - else - { - // Draw - if (parseInfo->pieces == NULL) - { - result = DrawText(hDC, lpString, nCount, lpRect, uFormat); - } - else - { - RECT rc = *lpRect; - SIZE text_size = GetTextSize(hDC, lpString, parseInfo, uFormat, parseInfo->max_height, (lpRect->right - lpRect->left)); - - if (text_size.cx < rc.right - rc.left) - { - if (uFormat & DT_RIGHT) - rc.left = rc.right - text_size.cx; - else - rc.right = rc.left + text_size.cx; - } - - result = text_size.cy; - DrawTextSmiley(hDC, rc, lpString, nCount, parseInfo, uFormat, parseInfo->max_height); - } - } - - return result; -} - -SIZE GetTextSize(HDC hdcMem, const TCHAR *szText, SMILEYPARSEINFO info, UINT uTextFormat, int max_smiley_height, int max_width) -{ - SIZE text_size = {0}; - int text_height; - int row_count = 0, pos_x = 0; - - if (szText == NULL || _tcsclen(szText) == 0) - { - text_size.cy = 0; - text_size.cx = 0; - } - else - { - RECT text_rc = {0, 0, 2048, 2048}; - - if (info->pieces == NULL) - { - DrawText(hdcMem, szText, -1, &text_rc, DT_CALCRECT | uTextFormat); - text_size.cx = text_rc.right - text_rc.left; - text_size.cy = text_rc.bottom - text_rc.top; - } - else - { - // Get real height of the line - text_height = DrawText(hdcMem, _T("A"), 1, &text_rc, DT_CALCRECT | uTextFormat); - - // See each item of list - int i; - for (i = 0; i < info->pieces->realCount; i++) - { - TEXTPIECE *piece = (TEXTPIECE *) info->pieces->items[i]; - info->row_height[row_count] = max(info->row_height[row_count], text_height); - - if (piece->type == TEXT_PIECE_TYPE_TEXT) - { - RECT text_rc = {0, 0, 2048, 2048}; - - DrawText(hdcMem, szText + piece->start_pos, piece->len, &text_rc, DT_CALCRECT | uTextFormat); - pos_x += (text_rc.right - text_rc.left); - if (pos_x > max_width) - { - text_size.cx = max(text_size.cx, pos_x - (text_rc.right - text_rc.left)); - pos_x = text_rc.right - text_rc.left; - info->row_height[++row_count] = text_height; - } - - if (szText[piece->start_pos + piece->len - 1] == '\n') - { - text_size.cx = max(text_size.cx, pos_x); - pos_x = 0; - info->row_height[++row_count] = 0; - } - - } - else - { - double factor; - - if (uTextFormat & DT_RESIZE_SMILEYS && piece->smiley_height > text_height) - factor = text_height / (double) piece->smiley_height; - else - factor = 1; - - info->row_height[row_count] = max(info->row_height[row_count], piece->smiley_height * factor); - - pos_x += piece->smiley_width * factor; - if (pos_x > max_width) - { - text_size.cx = max(text_size.cx, pos_x - (piece->smiley_width * factor)); - pos_x = piece->smiley_width * factor; - info->row_height[++row_count] = piece->smiley_height * factor; - } - } - } - - text_size.cx = max(text_size.cx, pos_x); - for (i = 0; i < row_count + 1; i++) - text_size.cy += info->row_height[i]; - } - } - - return text_size; -} - -void DrawTextSmiley(HDC hdcMem, RECT free_rc, const TCHAR *szText, int len, SMILEYPARSEINFO info, UINT uTextFormat, int max_smiley_height) -{ - if (szText == NULL) - return; - - uTextFormat &= ~DT_RIGHT; - - // Draw list - int text_height, i, shift; - int row_count = 0, pos_x = 0; - - RECT tmp_rc = free_rc; - - if (uTextFormat & DT_RTLREADING) - i = info->pieces->realCount - 1; - else - i = 0; - - // Get real height of the line - text_height = DrawText(hdcMem, _T("A"), 1, &tmp_rc, DT_CALCRECT | uTextFormat); - - if (IsWinVer2000Plus()) - SaveAlpha(&free_rc); - - // Just draw ellipsis - if (free_rc.right <= free_rc.left) - { - DrawText(hdcMem, _T("..."), 3, &free_rc, uTextFormat & ~DT_END_ELLIPSIS); - } - else - { - // Draw text and smileys - RECT text_rc = free_rc; - for (; i < info->pieces->realCount && i >= 0 && len > 0; i += (uTextFormat & DT_RTLREADING ? -1 : 1)) - { - TEXTPIECE *piece = (TEXTPIECE *) info->pieces->items[i]; - - if (uTextFormat & DT_RTLREADING) - text_rc.right = free_rc.right - pos_x; - else - text_rc.left = free_rc.left + pos_x; - - if (piece->type == TEXT_PIECE_TYPE_TEXT) - { - tmp_rc = text_rc; - tmp_rc.right = 2048; - - DrawText(hdcMem, szText + piece->start_pos, min(len, piece->len), &tmp_rc, DT_CALCRECT | (uTextFormat & ~DT_END_ELLIPSIS)); - - pos_x += (tmp_rc.right - tmp_rc.left); - if (pos_x > (free_rc.right - free_rc.left)) - { - pos_x = tmp_rc.right - tmp_rc.left; - text_rc.left = free_rc.left; - text_rc.right = free_rc.right; - text_rc.top += info->row_height[row_count]; - row_count++; - } - - shift = (info->row_height[row_count] - text_height) >> 1; - text_rc.top += shift; - - if (uTextFormat & DT_RTLREADING) - text_rc.left = max(text_rc.left, text_rc.right - (tmp_rc.right - tmp_rc.left)); - - DrawText(hdcMem, szText + piece->start_pos, min(len, piece->len), &text_rc, uTextFormat); - len -= piece->len; - text_rc.top -= shift; - - if (szText[piece->start_pos + piece->len - 1] == '\n') - { - text_rc.left = free_rc.left; - text_rc.right = free_rc.right; - text_rc.top += info->row_height[row_count]; - pos_x = 0; - row_count++; - } - } - else - { - double factor; - - if (len < piece->len) - { - len = 0; - } - else - { - len -= piece->len; - - if (uTextFormat & DT_RESIZE_SMILEYS && piece->smiley_height > text_height) - factor = text_height / (double) piece->smiley_height; - else - factor = 1; - - if (uTextFormat & DT_RTLREADING) - text_rc.left = max(text_rc.right - (int)(piece->smiley_width * factor), text_rc.left); - - pos_x += piece->smiley_width * factor; - if (pos_x > (free_rc.right - free_rc.left)) - { - pos_x = piece->smiley_width * factor; - text_rc.left = free_rc.left; - text_rc.right = free_rc.right; - text_rc.top += info->row_height[row_count]; - row_count++; - } - - shift = (info->row_height[row_count] - (LONG)(piece->smiley_height * factor)) >> 1; - DrawIconExAlpha(hdcMem, text_rc.left, text_rc.top + shift, piece->smiley, piece->smiley_width * factor, piece->smiley_height * factor, 0, NULL, DI_NORMAL, true); - } - } - } - } - - if (IsWinVer2000Plus()) - RestoreAlpha(&free_rc); -} - -void DestroySmileyList(SortedList* p_list) -{ - if (p_list == NULL) - return; - - if (p_list->items != NULL) - { - int i; - for (i = 0 ; i < p_list->realCount ; i++) - { - TEXTPIECE *piece = (TEXTPIECE *)p_list->items[i]; - if (piece != NULL) - { - if (piece->type == TEXT_PIECE_TYPE_SMILEY) - DestroyIcon(piece->smiley); - - mir_free(piece); //this free the p_list->items[i] - } - } - } - List_Destroy(p_list); //this free the p_list->items member - mir_free(p_list); //this free the p_list itself (alloc by List_Create) -} - -// Generete the list of smileys / text to be drawn -SortedList *ReplaceSmileys(const TCHAR *text, int text_size, const char *protocol, int *max_smiley_height) -{ - SMADD_BATCHPARSE2 sp = {0}; - SMADD_BATCHPARSERES *spres; - char smileyProto[64]; - - *max_smiley_height = 0; - - if (!text || !text[0] || !ServiceExists(MS_SMILEYADD_BATCHPARSE)) - return NULL; - - if (protocol == NULL) - strcpy(smileyProto, "tipper"); - else if (strcmp(protocol, szMetaModuleName) == 0) - strcpy(smileyProto, "tipper"); - else - strcpy(smileyProto, protocol); - - // Parse it! - sp.cbSize = sizeof(sp); - sp.str = (TCHAR *)text; - sp.flag = SAFL_TCHAR; - sp.Protocolname = (opt.iSmileyAddFlags & SMILEYADD_USEPROTO) ? smileyProto : "tipper"; - spres = (SMADD_BATCHPARSERES *)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&sp); - - if (!spres) // Did not find a smiley - return NULL; - - // Lets add smileys - SortedList *plText = List_Create(0, 10); - - TCHAR *word_start, *word_end; - TCHAR *smiley_start, *smiley_end; - TCHAR *last_text_pos = _tcsninc(text, text_size); - - word_start = word_end = (TCHAR *)text; - - for (unsigned i = 0; i < sp.numSmileys; i++) - { - // Get smile position - smiley_start = _tcsninc(text, spres[i].startChar); - smiley_end = _tcsninc(smiley_start, spres[i].size); - - if (spres[i].hIcon) // For deffective smileypacks - { - if (opt.iSmileyAddFlags & SMILEYADD_ONLYISOLATED) - { - if ((smiley_start > text && *(smiley_start - 1) != ' ' && *(smiley_start - 1) != '\n' && *smiley_end != '\r') || - (*smiley_end != '\0' && *smiley_end != ' ' && *smiley_end != '\n' && *smiley_end != '\r')) - continue; - } - - // Add text - while (word_end != smiley_start) - { - while (word_end[0] != ' ' && word_end[0] != '\n') - word_end++; - - if (word_end > smiley_start) - word_end = smiley_start; - else - word_end++; - - if (word_end > word_start) - { - TEXTPIECE *piece = (TEXTPIECE *)mir_alloc0(sizeof(TEXTPIECE)); - piece->type = TEXT_PIECE_TYPE_TEXT; - piece->start_pos = word_start - text; - piece->len = word_end - word_start; - List_Insert(plText, piece, plText->realCount); - word_start = word_end; - } - } - - // Add smiley - { - BITMAP bm; - ICONINFO icon; - TEXTPIECE *piece = (TEXTPIECE *) mir_alloc0(sizeof(TEXTPIECE)); - - piece->type = TEXT_PIECE_TYPE_SMILEY; - piece->len = spres[i].size; - piece->smiley = spres[i].hIcon; - - piece->smiley_width = 16; - piece->smiley_height = 16; - if (GetIconInfo(piece->smiley, &icon)) - { - if (GetObject(icon.hbmColor, sizeof(BITMAP), &bm)) - { - piece->smiley_width = bm.bmWidth; - piece->smiley_height = bm.bmHeight; - } - - DeleteObject(icon.hbmMask); - DeleteObject(icon.hbmColor); - } - - *max_smiley_height = max(piece->smiley_height, *max_smiley_height); - List_Insert(plText, piece, plText->realCount); - } - - word_start = word_end = smiley_end; - } - } - - // Add rest of the text - while (word_end != last_text_pos) - { - while (word_end[0] && word_end[0] != ' ' && word_end[0] != '\n') - word_end++; - - if (word_end[0]) - word_end++; - - if (word_end > word_start) - { - TEXTPIECE *piece = (TEXTPIECE *)mir_alloc0(sizeof(TEXTPIECE)); - piece->type = TEXT_PIECE_TYPE_TEXT; - piece->start_pos = word_start - text; - piece->len = word_end - word_start; - List_Insert(plText, piece, plText->realCount); - word_start = word_end; - } - - } - - CallService(MS_SMILEYADD_BATCHFREE, 0, (LPARAM)spres); - - return plText; -} - -int DrawTextExt(HDC hdc, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat, LPCSTR lpProto, SMILEYPARSEINFO spi) -{ - if ((opt.iSmileyAddFlags & SMILEYADD_ENABLE) && spi != NULL) - { - if (opt.iSmileyAddFlags & SMILEYADD_RESIZE) - uFormat |= DT_RESIZE_SMILEYS; - - return Smileys_DrawText(hdc, lpString, nCount, lpRect, uFormat, lpProto, spi); - } - else - { - if (uFormat & DT_CALCRECT) - { - return DrawText(hdc, lpString, nCount, lpRect, uFormat); - } - else - { - return DrawTextAlpha(hdc, lpString, nCount, lpRect, uFormat); - } - } -} diff --git a/plugins/TipperYM/mir_smileys.h b/plugins/TipperYM/mir_smileys.h deleted file mode 100644 index 5f78ac8f09..0000000000 --- a/plugins/TipperYM/mir_smileys.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -Copyright (C) 2005 Ricardo Pescuma Domenecci - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this file; see the file license.txt. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. -*/ - -#ifndef __MIR_SMILEYS_H__ -#define __MIR_SMILEYS_H__ - -#define DT_RESIZE_SMILEYS 0x10000000 - -// smileyadd options -#define SMILEYADD_ENABLE 1 -#define SMILEYADD_USEPROTO 2 -#define SMILEYADD_ONLYISOLATED 4 -#define SMILEYADD_RESIZE 8 - -#define TEXT_PIECE_TYPE_TEXT 0 -#define TEXT_PIECE_TYPE_SMILEY 1 - -typedef struct { - int type; - int len; - union - { - struct - { - int start_pos; - }; - struct - { - HICON smiley; - int smiley_width; - int smiley_height; - }; - }; -} TEXTPIECE; - -typedef struct tagSMILEYPARSEINFO { - SortedList *pieces; - int row_height[512]; // max 512 rows - int max_height; -} *SMILEYPARSEINFO; - -int InitTipperSmileys(); -SMILEYPARSEINFO Smileys_PreParse(LPCTSTR lpString, int nCount, const char *protocol); -void Smileys_FreeParse(SMILEYPARSEINFO parseInfo); - -SortedList *ReplaceSmileys(const TCHAR *text, int text_size, const char *protocol, int *max_smiley_height); -SIZE GetTextSize(HDC hdcMem, const TCHAR *szText, SMILEYPARSEINFO info, UINT uTextFormat, int max_smiley_height, int max_width); -void DrawTextSmiley(HDC hdcMem, RECT free_rc, const TCHAR *szText, int len, SMILEYPARSEINFO info, UINT uTextFormat, int max_smiley_height); -void DestroySmileyList(SortedList* p_list); - -int Smileys_DrawText(HDC hDC, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat, const char *protocol, SMILEYPARSEINFO parseInfo); -int DrawTextExt(HDC hdc, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat, LPCSTR lpProto, SMILEYPARSEINFO spi); - -#endif // __MIR_SMILEYS_H__ diff --git a/plugins/TipperYM/options.cpp b/plugins/TipperYM/options.cpp deleted file mode 100644 index ceb4a223b5..0000000000 --- a/plugins/TipperYM/options.cpp +++ /dev/null @@ -1,2495 +0,0 @@ -/* -Copyright (C) 2006-2007 Scott Ellis -Copyright (C) 2007-2011 Jan Holub - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this file; see the file license.txt. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. -*/ - -#include "common.h" -#include "options.h" -#include "popwin.h" -#include "str_utils.h" -#include "message_pump.h" -#include "preset_items.h" -#include "skin_parser.h" - -OPTIONS opt; -ICONSTATE exIcons[EXICONS_COUNT]; - -extern TOOLTIPSKIN skin; -extern int ReloadFont(WPARAM wParam, LPARAM lParam); - - -extern int IsTrayProto(const TCHAR *swzProto, BOOL bExtendedTip) -{ - if (swzProto == NULL) - return 0; - - char szSetting[64]; - if (bExtendedTip) - strcpy(szSetting, "TrayProtocolsEx"); - else - strcpy(szSetting, "TrayProtocols"); - - DBVARIANT dbv; - int result = 1; - if (!DBGetContactSettingTString(NULL, MODULE, szSetting, &dbv)) - { - result = _tcsstr(dbv.ptszVal, swzProto) ? 1 : 0; - DBFreeVariant(&dbv); - } - - return result; -} - -void CreateDefaultItems() -{ - DSListNode *ds_node; - DIListNode *di_node; - - for (int i = 0; defaultItemList[i].szName; i++) - { - if (defaultItemList[i].szName[0] == '-') - { - di_node = (DIListNode *)mir_alloc(sizeof(DIListNode)); - _tcsncpy(di_node->di.swzLabel, _T(""), LABEL_LEN); - _tcsncpy(di_node->di.swzValue, _T(""), VALUE_LEN); - di_node->di.bLineAbove = true; - di_node->di.bIsVisible = true; - di_node->di.bParseTipperVarsFirst = false; - di_node->next = opt.diList; - opt.diList = di_node; - opt.iDiCount++; - } - else - { - PRESETITEM *item = GetPresetItemByName(defaultItemList[i].szName); - if (item == NULL) continue; - - for (int j = 0; j < MAX_PRESET_SUBST_COUNT; j++) - { - PRESETSUBST *subst = GetPresetSubstByName(item->szNeededSubst[j]); - if (subst == NULL) continue; - - ds_node = (DSListNode *)mir_alloc(sizeof(DSListNode)); - _tcsncpy(ds_node->ds.swzName, subst->swzName, LABEL_LEN); - ds_node->ds.type = subst->type; - strncpy(ds_node->ds.szSettingName, subst->szSettingName, SETTING_NAME_LEN); - ds_node->ds.iTranslateFuncId = subst->iTranslateFuncId; - ds_node->next = opt.dsList; - opt.dsList = ds_node; - opt.iDsCount++; - } - - di_node = (DIListNode *)mir_alloc(sizeof(DIListNode)); - _tcsncpy(di_node->di.swzLabel, TranslateTS(item->swzLabel), LABEL_LEN); - _tcsncpy(di_node->di.swzValue, item->swzValue, VALUE_LEN); - di_node->di.bLineAbove = false; - di_node->di.bValueNewline = defaultItemList[i].bValueNewline; - di_node->di.bIsVisible = true; - di_node->di.bParseTipperVarsFirst = false; - di_node->next = opt.diList; - opt.diList = di_node; - opt.iDiCount++; - } - } -} - - -bool LoadDS(DISPLAYSUBST *ds, int index) -{ - char setting[512]; - DBVARIANT dbv; - - mir_snprintf(setting, SIZEOF(setting), "Name%d", index); - ds->swzName[0] = 0; - if (!DBGetContactSettingTString(0, MODULE_ITEMS, setting, &dbv)) - { - _tcsncpy(ds->swzName, dbv.ptszVal, SIZEOF(ds->swzName)); - ds->swzName[SIZEOF(ds->swzName) - 1] = 0; - DBFreeVariant(&dbv); - } else - return false; - - mir_snprintf(setting, SIZEOF(setting), "Type%d", index); - ds->type = (DisplaySubstType)DBGetContactSettingByte(0, MODULE_ITEMS, setting, DVT_PROTODB); - - mir_snprintf(setting, SIZEOF(setting), "Module%d", index); - ds->szModuleName[0] = 0; - if (!DBGetContactSetting(0, MODULE_ITEMS, setting, &dbv)) - { - strncpy(ds->szModuleName, dbv.pszVal, MODULE_NAME_LEN); - ds->szModuleName[MODULE_NAME_LEN - 1] = 0; - DBFreeVariant(&dbv); - } - - mir_snprintf(setting, SIZEOF(setting), "Setting%d", index); - ds->szSettingName[0] = 0; - if (!DBGetContactSetting(0, MODULE_ITEMS, setting, &dbv)) - { - strncpy(ds->szSettingName, dbv.pszVal, SETTING_NAME_LEN); - ds->szSettingName[SETTING_NAME_LEN - 1] = 0; - DBFreeVariant(&dbv); - } - - mir_snprintf(setting, SIZEOF(setting), "TransFuncId%d", index); - ds->iTranslateFuncId = DBGetContactSettingDword(0, MODULE_ITEMS, setting, (DWORD)-1); - - // a little backward compatibility - if ((DWORD)ds->iTranslateFuncId == (DWORD)-1) - { - mir_snprintf(setting, SIZEOF(setting), "TransFunc%d", index); - ds->iTranslateFuncId = (DWORD)DBGetContactSettingWord(0, MODULE_ITEMS, setting, 0); - } - - return true; -} - - -void SaveDS(DISPLAYSUBST *ds, int index) -{ - char setting[512]; - - mir_snprintf(setting, SIZEOF(setting), "Name%d", index); - DBWriteContactSettingTString(0, MODULE_ITEMS, setting, ds->swzName); - mir_snprintf(setting, SIZEOF(setting), "Type%d", index); - DBWriteContactSettingByte(0, MODULE_ITEMS, setting, (BYTE)ds->type); - mir_snprintf(setting, SIZEOF(setting), "Module%d", index); - DBWriteContactSettingString(0, MODULE_ITEMS, setting, ds->szModuleName); - mir_snprintf(setting, SIZEOF(setting), "Setting%d", index); - DBWriteContactSettingString(0, MODULE_ITEMS, setting, ds->szSettingName); - mir_snprintf(setting, SIZEOF(setting), "TransFuncId%d", index); - DBWriteContactSettingDword(0, MODULE_ITEMS, setting, (WORD)ds->iTranslateFuncId); -} - - -bool LoadDI(DISPLAYITEM *di, int index) -{ - char setting[512]; - DBVARIANT dbv; - - mir_snprintf(setting, SIZEOF(setting), "DILabel%d", index); - di->swzLabel[0] = 0; - if (!DBGetContactSettingTString(0, MODULE_ITEMS, setting, &dbv)) - { - _tcsncpy( di->swzLabel, dbv.ptszVal, SIZEOF(di->swzLabel)); - di->swzLabel[SIZEOF(di->swzLabel) - 1] = 0; - DBFreeVariant(&dbv); - } else - return false; - - mir_snprintf(setting, SIZEOF(setting), "DIValue%d", index); - di->swzValue[0] = 0; - if (!DBGetContactSettingTString(0, MODULE_ITEMS, setting, &dbv)) - { - _tcsncpy(di->swzValue, dbv.ptszVal, SIZEOF(di->swzValue)); - di->swzValue[SIZEOF(di->swzValue) - 1] = 0; - DBFreeVariant(&dbv); - } - - mir_snprintf(setting, SIZEOF(setting), "DILineAbove%d", index); - di->bLineAbove = (DBGetContactSettingByte(0, MODULE_ITEMS, setting, 0) == 1); - mir_snprintf(setting, SIZEOF(setting), "DIValNewline%d", index); - di->bValueNewline = (DBGetContactSettingByte(0, MODULE_ITEMS, setting, 0) == 1); - mir_snprintf(setting, SIZEOF(setting), "DIVisible%d", index); - di->bIsVisible = (DBGetContactSettingByte(0, MODULE_ITEMS, setting, 1) == 1); - mir_snprintf(setting, SIZEOF(setting), "DITipperVarsFirst%d", index); - di->bParseTipperVarsFirst = (DBGetContactSettingByte(0, MODULE_ITEMS, setting, 0) == 1); - - return true; -} - - -void SaveDI(DISPLAYITEM *di, int index) -{ - char setting[512]; - - mir_snprintf(setting, SIZEOF(setting), "DILabel%d", index); - if (DBWriteContactSettingTString(0, MODULE_ITEMS, setting, di->swzLabel)) - { - char buff[LABEL_LEN]; - t2a(di->swzLabel, buff, LABEL_LEN); - DBWriteContactSettingString(0, MODULE_ITEMS, setting, buff); - } - - mir_snprintf(setting, SIZEOF(setting), "DIValue%d", index); - if (DBWriteContactSettingTString(0, MODULE_ITEMS, setting, di->swzValue)) - { - char buff[VALUE_LEN]; - t2a(di->swzValue, buff, VALUE_LEN); - DBWriteContactSettingString(0, MODULE_ITEMS, setting, buff); - } - - mir_snprintf(setting, SIZEOF(setting), "DILineAbove%d", index); - DBWriteContactSettingByte(0, MODULE_ITEMS, setting, di->bLineAbove ? 1 : 0); - mir_snprintf(setting, SIZEOF(setting), "DIValNewline%d", index); - DBWriteContactSettingByte(0, MODULE_ITEMS, setting, di->bValueNewline ? 1 : 0); - mir_snprintf(setting, SIZEOF(setting), "DIVisible%d", index); - DBWriteContactSettingByte(0, MODULE_ITEMS, setting, di->bIsVisible ? 1 : 0); - mir_snprintf(setting, SIZEOF(setting), "DITipperVarsFirst%d", index); - DBWriteContactSettingByte(0, MODULE_ITEMS, setting, di->bParseTipperVarsFirst ? 1 : 0); -} - - -void SaveOptions() -{ - DBWriteContactSettingDword(0, MODULE, "MaxWidth", opt.iWinWidth); - DBWriteContactSettingDword(0, MODULE, "MaxHeight", opt.iWinMaxHeight); - DBWriteContactSettingByte(0, MODULE, "AvatarOpacity", (BYTE)opt.iAvatarOpacity); - DBWriteContactSettingByte(0, MODULE, "AvatarRoundCorners", (opt.bAvatarRound ? 1 : 0)); - DBWriteContactSettingByte(0, MODULE, "TitleLayout", (BYTE)opt.titleLayout); - if (ServiceExists(MS_AV_DRAWAVATAR)) - DBWriteContactSettingByte(0, MODULE, "AVLayout", (BYTE)opt.avatarLayout); - opt.bWaitForAvatar = (opt.avatarLayout == PAV_NONE) ? false : true; - - DBWriteContactSettingDword(0, MODULE, "AVSize", opt.iAvatarSize); - DBWriteContactSettingDword(0, MODULE, "TextIndent", opt.iTextIndent); - DBWriteContactSettingDword(0, MODULE, "TitleIndent", opt.iTitleIndent); - DBWriteContactSettingDword(0, MODULE, "ValueIndent", opt.iValueIndent); - DBWriteContactSettingByte(0, MODULE, "ShowNoFocus", (opt.bShowNoFocus ? 1 : 0)); - - DBWriteContactSettingWord(0, MODULE, "TimeIn", opt.iTimeIn); - CallService(MS_CLC_SETINFOTIPHOVERTIME, opt.iTimeIn, 0); - - DBWriteContactSettingWord(0, MODULE, "Padding", opt.iPadding); - DBWriteContactSettingWord(0, MODULE, "OuterAvatarPadding", opt.iOuterAvatarPadding); - DBWriteContactSettingWord(0, MODULE, "InnerAvatarPadding", opt.iInnerAvatarPadding); - DBWriteContactSettingWord(0, MODULE, "TextPadding", opt.iTextPadding); - DBWriteContactSettingByte(0, MODULE, "Position", (BYTE)opt.pos); - DBWriteContactSettingDword(0, MODULE, "MinWidth", (DWORD)opt.iMinWidth); - DBWriteContactSettingDword(0, MODULE, "MinHeight", (DWORD)opt.iMinHeight); - DBWriteContactSettingDword(0, MODULE, "SidebarWidth", (DWORD)opt.iSidebarWidth); - DBWriteContactSettingByte(0, MODULE, "MouseTollerance", (BYTE)opt.iMouseTollerance); - DBWriteContactSettingByte(0, MODULE, "SBarTips", (opt.bStatusBarTips ? 1 : 0)); - - DBWriteContactSettingWord(0, MODULE, "LabelVAlign", opt.iLabelValign); - DBWriteContactSettingWord(0, MODULE, "LabelHAlign", opt.iLabelHalign); - DBWriteContactSettingWord(0, MODULE, "ValueVAlign", opt.iValueValign); - DBWriteContactSettingWord(0, MODULE, "ValueHAlign", opt.iValueHalign); - - DBWriteContactSettingByte(0, MODULE, "OriginalAvSize", (opt.bOriginalAvatarSize ? 1 : 0)); - DBWriteContactSettingByte(0, MODULE, "AvatarBorder", (opt.bAvatarBorder ? 1 : 0)); -} - -void SaveItems() -{ - int index = 0; - DSListNode *ds_node = opt.dsList; - while (ds_node) - { - SaveDS(&ds_node->ds, index); - ds_node = ds_node->next; - index++; - } - - DBWriteContactSettingWord(0, MODULE_ITEMS, "DSNumValues", index); - - index = 0; - DIListNode *di_node = opt.diList; - opt.bWaitForStatusMsg = false; - while (di_node) - { - SaveDI(&di_node->di, index); - if (di_node->di.bIsVisible && _tcsstr(di_node->di.swzValue, _T("sys:status_msg"))) - opt.bWaitForStatusMsg = true; - di_node = di_node->next; - index++; - } - - DBWriteContactSettingWord(0, MODULE_ITEMS, "DINumValues", index); -} - -void SaveSkinOptions() -{ - DBWriteContactSettingByte(0, MODULE, "Border", (opt.bBorder ? 1 : 0)); - DBWriteContactSettingByte(0, MODULE, "DropShadow", (opt.bDropShadow ? 1 : 0)); - DBWriteContactSettingByte(0, MODULE, "RoundCorners", (opt.bRound ? 1 : 0)); - DBWriteContactSettingByte(0, MODULE, "AeroGlass", (opt.bAeroGlass ? 1 : 0)); - DBWriteContactSettingByte(0, MODULE, "Opacity", (BYTE)opt.iOpacity); - DBWriteContactSettingByte(0, MODULE, "ShowEffect", (BYTE)opt.showEffect); - DBWriteContactSettingByte(0, MODULE, "ShowEffectSpeed", (BYTE)opt.iAnimateSpeed); - DBWriteContactSettingByte(0, MODULE, "LoadFonts", (opt.bLoadFonts ? 1 : 0)); - DBWriteContactSettingByte(0, MODULE, "LoadProportions", (opt.bLoadProportions ? 1 : 0)); - DBWriteContactSettingDword(0, MODULE, "EnableColoring", opt.iEnableColoring); -} - -void LoadObsoleteSkinSetting() -{ - char setting[128]; - DBVARIANT dbv; - - for (int i = 0; i < SKIN_ITEMS_COUNT; i++) - { - mir_snprintf(setting, 128, "SPaintMode%d", i); - opt.transfMode[i] = (TransformationMode)DBGetContactSettingByte(0, MODULE, setting, 0); - mir_snprintf(setting, 128, "SImgFile%d", i); - if (!DBGetContactSettingTString(NULL, MODULE, setting, &dbv)) - { - opt.szImgFile[i] = mir_tstrdup(dbv.ptszVal); - DBFreeVariant(&dbv); - } - - mir_snprintf(setting, 128, "SGlyphMargins%d", i); - DWORD margins = DBGetContactSettingDword(NULL, MODULE, setting, 0); - opt.margins[i].top = LOBYTE(LOWORD(margins)); - opt.margins[i].right = HIBYTE(LOWORD(margins)); - opt.margins[i].bottom = LOBYTE(HIWORD(margins)); - opt.margins[i].left = HIBYTE(HIWORD(margins)); - } -} - -void LoadOptions() -{ - opt.iWinWidth = DBGetContactSettingDword(0, MODULE, "MaxWidth", 420); - opt.iWinMaxHeight = DBGetContactSettingDword(0, MODULE, "MaxHeight", 400); - opt.iAvatarOpacity = DBGetContactSettingByte(0, MODULE, "AvatarOpacity", 100); - if (opt.iAvatarOpacity > 100) opt.iAvatarOpacity = 100; - opt.bAvatarRound = (DBGetContactSettingByte(0, MODULE, "AvatarRoundCorners", opt.bRound ? 1 : 0) == 1); - opt.titleLayout = (PopupTitleLayout)DBGetContactSettingByte(0, MODULE, "TitleLayout", (BYTE)PTL_LEFTICON); - if (ServiceExists(MS_AV_DRAWAVATAR)) - opt.avatarLayout = (PopupAvLayout)DBGetContactSettingByte(0, MODULE, "AVLayout", PAV_RIGHT); - else - opt.avatarLayout = PAV_NONE; - - opt.bWaitForAvatar = (opt.avatarLayout == PAV_NONE) ? false : true; - opt.iAvatarSize = DBGetContactSettingDword(0, MODULE, "AVSize", 60); //tweety - opt.iTextIndent = DBGetContactSettingDword(0, MODULE, "TextIndent", 22); - opt.iTitleIndent = DBGetContactSettingDword(0, MODULE, "TitleIndent", 22); - opt.iValueIndent = DBGetContactSettingDword(0, MODULE, "ValueIndent", 10); - opt.iSidebarWidth = DBGetContactSettingDword(0, MODULE, "SidebarWidth", 22); - opt.bShowNoFocus = (DBGetContactSettingByte(0, MODULE, "ShowNoFocus", 1) == 1); - - int i, real_count = 0; - opt.dsList = 0; - DSListNode *ds_node; - - opt.iDsCount = DBGetContactSettingWord(0, MODULE_ITEMS, "DSNumValues", 0); - for (i = opt.iDsCount - 1; i >= 0; i--) - { - ds_node = (DSListNode *)mir_alloc(sizeof(DSListNode)); - if (LoadDS(&ds_node->ds, i)) - { - ds_node->next = opt.dsList; - opt.dsList = ds_node; - real_count++; - } - else - { - mir_free(ds_node); - } - } - opt.iDsCount = real_count; - - real_count = 0; - opt.diList = 0; - DIListNode *di_node; - - opt.bWaitForStatusMsg = false; - opt.iDiCount = DBGetContactSettingWord(0, MODULE_ITEMS, "DINumValues", 0); - for (i = opt.iDiCount - 1; i >= 0; i--) - { - di_node = (DIListNode *)mir_alloc(sizeof(DIListNode)); - if (LoadDI(&di_node->di, i)) - { - di_node->next = opt.diList; - opt.diList = di_node; - real_count++; - if (di_node->di.bIsVisible && _tcsstr(di_node->di.swzValue, _T("sys:status_msg"))) - opt.bWaitForStatusMsg = true; - } - else - { - mir_free(di_node); - } - } - opt.iDiCount = real_count; - - opt.iTimeIn = DBGetContactSettingWord(0, MODULE, "TimeIn", 750); - opt.iPadding = DBGetContactSettingWord(0, MODULE, "Padding", 4); - opt.iOuterAvatarPadding = DBGetContactSettingWord(0, MODULE, "OuterAvatarPadding", 6); - opt.iInnerAvatarPadding = DBGetContactSettingWord(0, MODULE, "InnerAvatarPadding", 10); - opt.iTextPadding = DBGetContactSettingWord(0, MODULE, "TextPadding", 4); - opt.pos = (PopupPosition)DBGetContactSettingByte(0, MODULE, "Position", (BYTE)PP_BOTTOMRIGHT); - opt.iMinWidth = DBGetContactSettingDword(0, MODULE, "MinWidth", 0); - opt.iMinHeight = DBGetContactSettingDword(0, MODULE, "MinHeight", 0); - - opt.iMouseTollerance = DBGetContactSettingByte(0, MODULE, "MouseTollerance", (BYTE)GetSystemMetrics(SM_CXSMICON)); - opt.bStatusBarTips = (DBGetContactSettingByte(0, MODULE, "SBarTips", 1) == 1); - - // convert defunct last message and status message options to new 'sys' items, and remove the old settings - if (DBGetContactSettingByte(0, MODULE, "ShowLastMessage", 0)) - { - DBDeleteContactSetting(0, MODULE, "ShowLastMessage"); - - // find end of list - di_node = opt.diList; - while(di_node && di_node->next) - di_node = di_node->next; - - // last message item - if (di_node) - { - di_node->next = (DIListNode *)mir_alloc(sizeof(DIListNode)); - di_node = di_node->next; - } - else - { - opt.diList = (DIListNode *)mir_alloc(sizeof(DIListNode)); - di_node = opt.diList; - } - - _tcsncpy(di_node->di.swzLabel, _T("Last message: (%sys:last_msg_reltime% ago)"), LABEL_LEN); - _tcsncpy(di_node->di.swzValue, _T("%sys:last_msg%"), VALUE_LEN); - di_node->di.bLineAbove = di_node->di.bValueNewline = true; - di_node->next = 0; - opt.iDiCount++; - } - - if (DBGetContactSettingByte(0, MODULE, "ShowStatusMessage", 0)) - { - DBDeleteContactSetting(0, MODULE, "ShowStatusMessage"); - - // find end of list - di_node = opt.diList; - while(di_node && di_node->next) - di_node = di_node->next; - - // status message item - if (di_node) - { - di_node->next = (DIListNode *)mir_alloc(sizeof(DIListNode)); - di_node = di_node->next; - } - else - { - opt.diList = (DIListNode *)mir_alloc(sizeof(DIListNode)); - di_node = opt.diList; - } - - _tcsncpy(di_node->di.swzLabel, _T("Status message:"), LABEL_LEN); - _tcsncpy(di_node->di.swzValue, _T("%sys:status_msg%"), VALUE_LEN); - di_node->di.bLineAbove = di_node->di.bValueNewline = true; - di_node->next = 0; - opt.iDiCount++; - } - - opt.iLabelValign = DBGetContactSettingWord(0, MODULE, "LabelVAlign", DT_TOP /*DT_VCENTER*/); - opt.iLabelHalign = DBGetContactSettingWord(0, MODULE, "LabelHAlign", DT_LEFT); - opt.iValueValign = DBGetContactSettingWord(0, MODULE, "ValueVAlign", DT_TOP /*DT_VCENTER*/); - opt.iValueHalign = DBGetContactSettingWord(0, MODULE, "ValueHAlign", DT_LEFT); - - // tray tooltip - opt.bTraytip = DBGetContactSettingByte(0, MODULE, "TrayTip", 1) ? true : false; - opt.bHandleByTipper = DBGetContactSettingByte(0, MODULE, "ExtendedTrayTip", 1) ? true : false; - opt.bExpandTraytip = DBGetContactSettingByte(0, MODULE, "ExpandTrayTip", 1) ? true : false; - opt.bHideOffline = DBGetContactSettingByte(0, MODULE, "HideOffline", 0) ? true : false; - opt.iExpandTime = DBGetContactSettingDword(0, MODULE, "ExpandTime", 1000); - opt.iFirstItems = DBGetContactSettingDword(0, MODULE, "TrayTipItems", TRAYTIP_NUMCONTACTS | TRAYTIP_LOGON | TRAYTIP_STATUS | TRAYTIP_CLIST_EVENT); - opt.iSecondItems = DBGetContactSettingDword(0, MODULE, "TrayTipItemsEx", TRAYTIP_NUMCONTACTS | TRAYTIP_LOGON | TRAYTIP_STATUS | TRAYTIP_STATUS_MSG | TRAYTIP_EXTRA_STATUS | TRAYTIP_MIRANDA_UPTIME | TRAYTIP_CLIST_EVENT); - opt.iFavoriteContFlags = DBGetContactSettingDword(0, MODULE, "FavContFlags", FAVCONT_APPEND_PROTO); - - // extra setting - opt.bWaitForContent= DBGetContactSettingByte(0, MODULE, "WaitForContent", 0) ? true : false; - opt.bGetNewStatusMsg = DBGetContactSettingByte(0, MODULE, "GetNewStatusMsg", 0) ? true : false; - opt.bDisableIfInvisible = DBGetContactSettingByte(0, MODULE, "DisableInvisible", 1) ? true : false; - opt.bRetrieveXstatus = DBGetContactSettingByte(0, MODULE, "RetrieveXStatus", 0) ? true : false; - opt.bOriginalAvatarSize = DBGetContactSettingByte(0, MODULE, "OriginalAvSize", 0) ? true : false; - opt.bAvatarBorder = DBGetContactSettingByte(0, MODULE, "AvatarBorder", 0) ? true : false; - opt.bLimitMsg = DBGetContactSettingByte(0, MODULE, "LimitMsg", 0) ? true : false; - opt.iLimitCharCount = DBGetContactSettingByte(0, MODULE, "LimitCharCount", 64); - opt.iSmileyAddFlags = DBGetContactSettingDword(0, MODULE, "SmileyAddFlags", SMILEYADD_ENABLE); - - DBVARIANT dbv; - // Load the icons order - for(i = 0; i < EXICONS_COUNT; i++) - { - opt.exIconsOrder[i]=i; - opt.exIconsVis[i]=1; - } - - if (!DBGetContactSetting(NULL, MODULE, "IconOrder", &dbv)) - { - CopyMemory(opt.exIconsOrder,dbv.pbVal,dbv.cpbVal); - DBFreeVariant(&dbv); - } - - if (!DBGetContactSetting(NULL, MODULE, "icons_vis", &dbv)) - { - CopyMemory(opt.exIconsVis,dbv.pbVal,dbv.cpbVal); - DBFreeVariant(&dbv); - } - - for(i = 0; i < EXICONS_COUNT; i++) - { - exIcons[i].order = opt.exIconsOrder[i]; - exIcons[i].vis = opt.exIconsVis[i]; - } - - opt.iOpacity = DBGetContactSettingByte(0, MODULE, "Opacity", 75); - opt.bBorder = DBGetContactSettingByte(0, MODULE, "Border", 1) ? true : false; - opt.bDropShadow = DBGetContactSettingByte(0, MODULE, "DropShadow", 1) ? true : false; - opt.bRound = DBGetContactSettingByte(0, MODULE, "RoundCorners", 1) ? true : false; - opt.bAeroGlass = DBGetContactSettingByte(0, MODULE, "AeroGlass", 0) ? true : false; - opt.showEffect = (PopupShowEffect)DBGetContactSettingByte(0, MODULE, "ShowEffect", (BYTE)PSE_FADE); - opt.iAnimateSpeed = DBGetContactSettingByte(0, MODULE, "ShowEffectSpeed", 12); - - if (opt.iAnimateSpeed < 1) - opt.iAnimateSpeed = 1; - else if (opt.iAnimateSpeed > 20) - opt.iAnimateSpeed = 20; - - int iBgImg = DBGetContactSettingByte(0, MODULE, "SBgImage", 0); - opt.skinMode = (SkinMode)DBGetContactSettingByte(0, MODULE, "SkinEngine", iBgImg ? SM_OBSOLOTE : SM_COLORFILL); - opt.bLoadFonts = DBGetContactSettingByte(0, MODULE, "LoadFonts", 1) ? true : false; - opt.bLoadProportions= DBGetContactSettingByte(0, MODULE, "LoadProportions", 1) ? true : false; - opt.iEnableColoring = DBGetContactSettingDword(0, MODULE, "EnableColoring", 0); - opt.szSkinName[0] = 0; - - if (opt.skinMode == SM_OBSOLOTE) - { - LoadObsoleteSkinSetting(); - } - else if (opt.skinMode == SM_IMAGE) - { - if (!DBGetContactSettingTString(NULL, MODULE, "SkinName", &dbv)) - { - _tcscpy(opt.szSkinName, dbv.ptszVal); - DBFreeVariant(&dbv); - } - } - - if (opt.iDsCount == 0 && opt.iDiCount == 0) - { - // set up some reasonable defaults - CreateDefaultItems(); - SaveOptions(); - SaveItems(); - } -} - -INT_PTR CALLBACK DlgProcAddItem(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - DISPLAYITEM *di = (DISPLAYITEM *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - - switch (msg) - { - case WM_INITDIALOG: - { - TranslateDialogDefault( hwndDlg ); - di = (DISPLAYITEM *)lParam; - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)di); - - SetDlgItemText(hwndDlg, IDC_ED_LABEL, di->swzLabel); - SetDlgItemText(hwndDlg, IDC_ED_VALUE, di->swzValue); - - CheckDlgButton(hwndDlg, IDC_CHK_LINEABOVE, di->bLineAbove ? TRUE : FALSE); - CheckDlgButton(hwndDlg, IDC_CHK_VALNEWLINE, di->bValueNewline ? TRUE : FALSE); - CheckDlgButton(hwndDlg, IDC_CHK_PARSETIPPERFIRST, di->bParseTipperVarsFirst ? TRUE : FALSE); - - int i; - for (i = 0; presetItems[i].szID; i++) - SendDlgItemMessage(hwndDlg, IDC_CMB_PRESETITEMS, CB_ADDSTRING, 0, (LPARAM)TranslateTS(presetItems[i].swzName)); - - variables_skin_helpbutton(hwndDlg, IDC_BTN_VARIABLE); - - SetFocus(GetDlgItem(hwndDlg, IDC_ED_LABEL)); - return TRUE; - } - case WM_COMMAND: - { - if (HIWORD(wParam) == BN_CLICKED) - { - switch(LOWORD(wParam)) - { - case IDOK: - { - int sel; - GetDlgItemText(hwndDlg, IDC_ED_LABEL, di->swzLabel, LABEL_LEN); - GetDlgItemText(hwndDlg, IDC_ED_VALUE, di->swzValue, VALUE_LEN); - - di->bLineAbove = (IsDlgButtonChecked(hwndDlg, IDC_CHK_LINEABOVE) ? true : false); - di->bValueNewline = (IsDlgButtonChecked(hwndDlg, IDC_CHK_VALNEWLINE) ? true : false); - di->bParseTipperVarsFirst = (IsDlgButtonChecked(hwndDlg, IDC_CHK_PARSETIPPERFIRST) ? true : false); - - sel = SendDlgItemMessage(hwndDlg, IDC_CMB_PRESETITEMS, CB_GETCURSEL, 0, 0); - if (sel != CB_ERR) - { - TCHAR buff[256]; int i; - SendDlgItemMessage(hwndDlg, IDC_CMB_PRESETITEMS, CB_GETLBTEXT, sel, (LPARAM)buff); - for (i = 0; presetItems[i].szID; i++) - { - if (_tcscmp(buff, TranslateTS(presetItems[i].swzName)) == 0) - break; - } - - if (presetItems[i].szNeededSubst[0]) - EndDialog(hwndDlg, IDPRESETITEM + i); - else - EndDialog(hwndDlg, IDOK); - } - else - { - EndDialog(hwndDlg, IDOK); - } - - return TRUE; - } - case IDCANCEL: - { - EndDialog(hwndDlg, IDCANCEL); - return TRUE; - } - case IDC_BTN_VARIABLE: - { - if (GetFocus() == GetDlgItem(hwndDlg, IDC_ED_LABEL)) - variables_showhelp(hwndDlg, IDC_ED_LABEL, VHF_FULLDLG, NULL, NULL); - else - variables_showhelp(hwndDlg, IDC_ED_VALUE, VHF_FULLDLG, NULL, NULL); - return TRUE; - } - } - } - else if (HIWORD(wParam) == CBN_SELCHANGE) - { - if (LOWORD(wParam) == IDC_CMB_PRESETITEMS) - { - int sel = SendDlgItemMessage(hwndDlg, IDC_CMB_PRESETITEMS, CB_GETCURSEL, 0, 0); - if (sel != CB_ERR) - { - TCHAR buff[256]; int i; - SendDlgItemMessage(hwndDlg, IDC_CMB_PRESETITEMS, CB_GETLBTEXT, sel, (LPARAM)buff); - for (i = 0; presetItems[i].szID; i++) - { - if (_tcscmp(buff, TranslateTS(presetItems[i].swzName)) == 0) - break; - } - - SetDlgItemText(hwndDlg, IDC_ED_LABEL, TranslateTS(presetItems[i].swzLabel)); - SetDlgItemText(hwndDlg, IDC_ED_VALUE, presetItems[i].swzValue); - } - } - } - break; - } - } - - return 0; -} - -INT_PTR CALLBACK DlgProcAddSubst(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - DISPLAYSUBST *ds = (DISPLAYSUBST *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - - switch (msg) - { - case WM_INITDIALOG: - { - TranslateDialogDefault( hwndDlg ); - ds = (DISPLAYSUBST *)lParam; - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)ds); - - SetDlgItemText(hwndDlg, IDC_ED_LABEL, ds->swzName); - - switch(ds->type) - { - case DVT_PROTODB: - CheckDlgButton(hwndDlg, IDC_CHK_PROTOMOD, TRUE); - SetDlgItemTextA(hwndDlg, IDC_ED_SETTING, ds->szSettingName); - break; - case DVT_DB: - SetDlgItemTextA(hwndDlg, IDC_ED_MODULE, ds->szModuleName); - SetDlgItemTextA(hwndDlg, IDC_ED_SETTING, ds->szSettingName); - break; - } - - int index, id, i; - for (i = 0; i < iTransFuncsCount; i++) - { - index = SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_ADDSTRING, (WPARAM)-1, (LPARAM)TranslateTS(translations[i].swzName)); - SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_SETITEMDATA, index, (LPARAM)translations[i].id); - } - - for (i = 0; i < iTransFuncsCount; i++) - { - id = SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_GETITEMDATA, i, 0); - if (id == ds->iTranslateFuncId) - SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_SETCURSEL, i, 0); - } - - SendMessage(hwndDlg, WMU_ENABLE_MODULE_ENTRY, 0, 0); - SetFocus(GetDlgItem(hwndDlg, IDC_ED_LABEL)); - return TRUE; - } - case WMU_ENABLE_MODULE_ENTRY: - { - HWND hw = GetDlgItem(hwndDlg, IDC_CHK_PROTOMOD); - EnableWindow(hw, TRUE); - hw = GetDlgItem(hwndDlg, IDC_ED_MODULE); - EnableWindow(hw, !IsDlgButtonChecked(hwndDlg, IDC_CHK_PROTOMOD)); - hw = GetDlgItem(hwndDlg, IDC_ED_SETTING); - EnableWindow(hw, TRUE); - return TRUE; - } - case WM_COMMAND: - { - if (HIWORD(wParam) == BN_CLICKED) - { - switch(LOWORD(wParam)) - { - case IDC_CHK_PROTOMOD: - { - SendMessage(hwndDlg, WMU_ENABLE_MODULE_ENTRY, 0, 0); - break; - } - case IDOK: - { - GetDlgItemText(hwndDlg, IDC_ED_LABEL, ds->swzName, LABEL_LEN); - if (ds->swzName[0] == 0) - { - MessageBox(hwndDlg, TranslateT("You must enter a label"), TranslateT("Invalid Substitution"), MB_OK | MB_ICONWARNING); - return TRUE; - } - - if (IsDlgButtonChecked(hwndDlg, IDC_CHK_PROTOMOD)) - { - ds->type = DVT_PROTODB; - } - else - { - ds->type = DVT_DB; - GetDlgItemTextA(hwndDlg, IDC_ED_MODULE, ds->szModuleName, MODULE_NAME_LEN); - } - - GetDlgItemTextA(hwndDlg, IDC_ED_SETTING, ds->szSettingName, SETTING_NAME_LEN); - - int sel = SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_GETCURSEL, 0, 0); - ds->iTranslateFuncId = SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_GETITEMDATA, sel, 0); - - EndDialog(hwndDlg, IDOK); - return TRUE; - } - case IDCANCEL: - { - EndDialog(hwndDlg, IDCANCEL); - return TRUE; - } - } - } - else if (HIWORD(wParam) == CBN_SELCHANGE) - { - return TRUE; - } - - break; - } - } - - return 0; -} - -static void SetTreeItemText(DIListNode *node, TCHAR **pszText) -{ - if (node->di.swzLabel[0] == 0) - { - if (node->di.swzValue[0] == 0 && node->di.bLineAbove) - *pszText = _T("--------------------------------------"); - else - *pszText = TranslateT(""); - } - else - { - *pszText = node->di.swzLabel; - } -} - - -static OPTBUTTON btns[9] = -{ - IDC_BTN_ADD, SKINICON_OTHER_ADDCONTACT, 0, LPGENT("Add item"), - IDC_BTN_SEPARATOR, 0, IDI_SEPARATOR, LPGENT("Add separator"), - IDC_BTN_EDIT, SKINICON_OTHER_RENAME, 0, LPGENT("Edit"), - IDC_BTN_REMOVE, SKINICON_OTHER_DELETE, 0, LPGENT("Remove"), - IDC_BTN_UP, 0, IDI_UP, LPGENT("Move up"), - IDC_BTN_DOWN, 0, IDI_DOWN, LPGENT("Move down"), - IDC_BTN_ADD2, SKINICON_OTHER_ADDCONTACT, 0, LPGENT("Add"), - IDC_BTN_REMOVE2, SKINICON_OTHER_DELETE, 0, LPGENT("Remove"), - IDC_BTN_EDIT2, SKINICON_OTHER_RENAME, 0, LPGENT("Edit") -}; - -INT_PTR CALLBACK DlgProcOptsContent(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) - { - case WM_INITDIALOG: - { - TranslateDialogDefault(hwndDlg); - - for (int i = 0; i < SIZEOF(btns); i++) - { - SendDlgItemMessage(hwndDlg, btns[i].id, BUTTONSETASFLATBTN, TRUE, 0); - SendDlgItemMessage(hwndDlg, btns[i].id, BUTTONADDTOOLTIP, (WPARAM)TranslateTS(btns[i].swzTooltip), BATF_TCHAR); - if (btns[i].uintCoreIconId) - { - SendDlgItemMessage(hwndDlg, btns[i].id, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadSkinnedIcon(btns[i].uintCoreIconId)); - } - else - { - HICON hIcon = LoadIcon(hInst, MAKEINTRESOURCE(btns[i].uintResIconId)); - SendDlgItemMessage(hwndDlg, btns[i].id, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); - DestroyIcon(hIcon); - } - } - - HIMAGELIST himlStates = ImageList_Create(16, 16, IsWinVerXPPlus() ? ILC_COLOR32 | ILC_MASK : ILC_COLOR8 | ILC_MASK, 3, 0); - ImageList_AddIcon(himlStates, LoadSkinnedIcon(SKINICON_OTHER_NOTICK)); - ImageList_AddIcon(himlStates, LoadSkinnedIcon(SKINICON_OTHER_NOTICK)); - ImageList_AddIcon(himlStates, LoadSkinnedIcon(SKINICON_OTHER_TICK)); - TreeView_SetImageList(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), himlStates, TVSIL_STATE); - - TVINSERTSTRUCT tvi = {0}; - tvi.hInsertAfter = TVI_LAST; - tvi.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_STATE; - tvi.item.stateMask = TVIS_STATEIMAGEMASK; - - DIListNode *di_node = opt.diList, *di_value; - while (di_node) - { - di_value = (DIListNode *)mir_alloc(sizeof(DIListNode)); - *di_value = *di_node; - tvi.item.lParam = (LPARAM)di_value; - tvi.item.state = INDEXTOSTATEIMAGEMASK(di_value->di.bIsVisible ? 2 : 1); - SetTreeItemText(di_value, &tvi.item.pszText); - TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &tvi); - di_node = di_node->next; - } - - DSListNode *ds_node = opt.dsList, *ds_value; - while (ds_node) - { - ds_value = (DSListNode *)mir_alloc(sizeof(DSListNode)); - *ds_value = *ds_node; - int index = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_ADDSTRING, 0, (LPARAM)ds_value->ds.swzName); - SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_SETITEMDATA, index, (LPARAM)ds_value); - ds_node = ds_node->next; - } - - SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0); - return FALSE; - } - case WMU_ENABLE_LIST_BUTTONS: - { - HTREEITEM hItem = TreeView_GetSelection(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS)); - if (hItem) - { - EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_REMOVE), TRUE); - EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_UP), TreeView_GetPrevSibling(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), hItem) ? TRUE : FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DOWN), TreeView_GetNextSibling(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), hItem) ? TRUE : FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_EDIT), TRUE); - } - else - { - EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_REMOVE), FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_UP), FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DOWN), FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_EDIT), FALSE); - } - - int sel = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETCURSEL, 0, 0); - if (sel == -1) - { - HWND hw = GetDlgItem(hwndDlg, IDC_BTN_REMOVE2); - EnableWindow(hw, FALSE); - hw = GetDlgItem(hwndDlg, IDC_BTN_EDIT2); - EnableWindow(hw, FALSE); - } - else - { - HWND hw = GetDlgItem(hwndDlg, IDC_BTN_REMOVE2); - EnableWindow(hw, TRUE); - hw = GetDlgItem(hwndDlg, IDC_BTN_EDIT2); - EnableWindow(hw, TRUE); - } - return TRUE; - } - case WM_COMMAND: - { - if (HIWORD(wParam) == LBN_SELCHANGE && LOWORD(wParam) == IDC_LST_SUBST) - { - SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0); - } - else if (HIWORD(wParam) == CBN_SELCHANGE) - { - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - else if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) - { - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - else if (HIWORD(wParam) == LBN_DBLCLK && LOWORD(wParam) == IDC_LST_SUBST) - { - int sel = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETCURSEL, 0, 0); - if (sel != CB_ERR) - { - DSListNode *ds_value = (DSListNode *)SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETITEMDATA, sel, 0); - if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SUBST), hwndDlg, DlgProcAddSubst, (LPARAM)&ds_value->ds) == IDOK) - { - SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_DELETESTRING, (WPARAM)sel, 0); - - sel = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_ADDSTRING, 0, (LPARAM)ds_value->ds.swzName); - SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_SETITEMDATA, sel, (LPARAM)ds_value); - - SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_SETCURSEL, sel, 0); - SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0); - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - } - } - else if (HIWORD(wParam) == BN_CLICKED) - { - switch(LOWORD(wParam)) - { - case IDC_BTN_ADD: - { - DIListNode *di_value = (DIListNode *)mir_alloc(sizeof(DIListNode)); - memset(di_value, 0, sizeof(DIListNode)); - di_value->di.bIsVisible = true; - - int result = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ITEM), hwndDlg, DlgProcAddItem, (LPARAM)&di_value->di); - if (result == IDOK || (result >= IDPRESETITEM && result < (IDPRESETITEM + 100))) - { - TVINSERTSTRUCT tvi = {0}; - tvi.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_STATE; - tvi.item.stateMask = TVIS_STATEIMAGEMASK; - tvi.item.lParam = (LPARAM)di_value; - tvi.item.state = INDEXTOSTATEIMAGEMASK(2); - SetTreeItemText(di_value, &tvi.item.pszText); - - HTREEITEM hItem = TreeView_GetSelection(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS)); - if (hItem) tvi.hInsertAfter = hItem; - else tvi.hInsertAfter = TVI_LAST; - TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &tvi); - - if (hItem) - { - HTREEITEM hNewItem = TreeView_GetNextSibling(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), hItem); - if (hNewItem) TreeView_SelectItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), hNewItem); - } - - if (result >= IDPRESETITEM) - { - for (int i = 0; i < MAX_PRESET_SUBST_COUNT; i++) - { - - PRESETSUBST *subst = GetPresetSubstByName(presetItems[result - IDPRESETITEM].szNeededSubst[i]); - if (subst == NULL) break; - if (SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_FINDSTRING, -1, (LPARAM)subst->swzName) == LB_ERR) - { - DSListNode *ds_value = (DSListNode *)mir_alloc(sizeof(DSListNode)); - memset(ds_value, 0, sizeof(DSListNode)); - ds_value->next = NULL; - ds_value->ds.type = subst->type; - _tcscpy(ds_value->ds.swzName, subst->swzName); - - if (ds_value->ds.type == DVT_DB && subst->szModuleName) - strcpy(ds_value->ds.szModuleName, subst->szModuleName); - - if (subst->szSettingName) - strcpy(ds_value->ds.szSettingName, subst->szSettingName); - - ds_value->ds.iTranslateFuncId = subst->iTranslateFuncId; - - int index = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_ADDSTRING, 0, (LPARAM)ds_value->ds.swzName); - SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_SETITEMDATA, index, (LPARAM)ds_value); - SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_SETCURSEL, index, 0); - } - } - } - - SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0); - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - - return TRUE; - } - case IDC_BTN_SEPARATOR: - { - DIListNode *di_value = (DIListNode *)mir_alloc(sizeof(DIListNode)); - memset(di_value, 0, sizeof(DIListNode)); - di_value->di.bIsVisible = true; - di_value->di.bLineAbove = true; - - TVINSERTSTRUCT tvi = {0}; - tvi.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_STATE; - tvi.item.stateMask = TVIS_STATEIMAGEMASK; - tvi.item.lParam = (LPARAM)di_value; - tvi.item.state = INDEXTOSTATEIMAGEMASK(2); - tvi.item.pszText = _T("---------------------------------"); - - HTREEITEM hItem = TreeView_GetSelection(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS)); - if (hItem) tvi.hInsertAfter = hItem; - else tvi.hInsertAfter = TVI_LAST; - TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &tvi); - - SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0); - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - return TRUE; - } - case IDC_BTN_REMOVE: - { - TVITEM item = {0}; - item.mask = TVIF_PARAM; - item.hItem = TreeView_GetSelection(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS)); - if (item.hItem) - { - if (TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &item)) - { - DIListNode *di_value = (DIListNode *)item.lParam; - mir_free(di_value); - TreeView_DeleteItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), item.hItem); - SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0); - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - } - return TRUE; - } - case IDC_BTN_UP: - case IDC_BTN_DOWN: - { - HTREEITEM hItem = TreeView_GetSelection(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS)); - if (hItem) - { - HTREEITEM hNewItem; - if (LOWORD(wParam) == IDC_BTN_UP) - hNewItem = TreeView_GetPrevSibling(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), hItem); - else - hNewItem = TreeView_GetNextSibling(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), hItem); - - if (hNewItem) - { - TCHAR buff[512], buff2[512]; - LPARAM tmpParam; - UINT tmpState; - - TVITEM item = {0}; - item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_STATE; - item.stateMask = TVIS_STATEIMAGEMASK; - item.hItem = hItem; - item.pszText = buff; - item.cchTextMax = 512; - if (TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &item)) - { - tmpParam = item.lParam; - tmpState = item.state; - item.hItem = hNewItem; - item.pszText = buff2; - if (TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &item)) - { - item.hItem = hItem; - TreeView_SetItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &item); - - item.hItem = hNewItem; - item.pszText = buff; - item.lParam = tmpParam; - item.state = tmpState; - TreeView_SetItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &item); - TreeView_SelectItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), hNewItem); - } - } - } - } - - SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0); - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - return TRUE; - } - case IDC_BTN_EDIT: - { - TVITEM item = {0}; - item.mask = TVIF_PARAM; - item.hItem = TreeView_GetSelection(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS)); - if (item.hItem ) - { - if (TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &item)) - { - DIListNode *di_value = (DIListNode *)item.lParam; - if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ITEM), hwndDlg, DlgProcAddItem, (LPARAM)&di_value->di) == IDOK) - { - item.mask = TVIF_TEXT; - SetTreeItemText(di_value, &item.pszText); - TreeView_SetItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &item); - SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0); - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - } - } - - return TRUE; - } - case IDC_BTN_ADD2: - { - DSListNode *ds_value = (DSListNode *)mir_alloc(sizeof(DSListNode)); - memset(ds_value, 0, sizeof(DSListNode)); - if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SUBST), hwndDlg, DlgProcAddSubst, (LPARAM)&ds_value->ds) == IDOK) - { - int index = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_ADDSTRING, 0, (LPARAM)ds_value->ds.swzName); - SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_SETITEMDATA, index, (LPARAM)ds_value); - SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_SETCURSEL, index, 0); - SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0); - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - - return TRUE; - } - case IDC_BTN_REMOVE2: - { - int sel = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETCURSEL, 0, 0); - if (sel != LB_ERR) - { - DSListNode *ds_value = (DSListNode *)SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETITEMDATA, sel, 0); - mir_free(ds_value); - - SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_DELETESTRING, (WPARAM)sel, 0); - SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0); - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - - return TRUE; - } - case IDC_BTN_EDIT2: - { - int sel = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETCURSEL, 0, 0); - if (sel != LB_ERR) - { - DSListNode *ds_value = (DSListNode *)SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETITEMDATA, sel, 0); - if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SUBST), hwndDlg, DlgProcAddSubst, (LPARAM)&ds_value->ds) == IDOK) - { - SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_DELETESTRING, (WPARAM)sel, 0); - - sel = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_ADDSTRING, 0, (LPARAM)ds_value->ds.swzName); - SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_SETITEMDATA, sel, (LPARAM)ds_value); - - SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_SETCURSEL, sel, 0); - SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0); - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - } - - return TRUE; - } - default: - { - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - return TRUE; - } - } - } - break; - } - case WM_NOTIFY: - { - switch (((LPNMHDR)lParam)->code) - { - case PSN_APPLY: - { - DIListNode *di_node; - while (opt.diList) - { - di_node = opt.diList; - opt.diList = opt.diList->next; - mir_free(di_node); - } - - DIListNode *di_value; - opt.iDiCount = TreeView_GetCount(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS)); - - TVITEM item = {0}; - item.mask = TVIF_PARAM; - item.hItem = TreeView_GetLastVisible(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS)); - while (item.hItem != NULL) - { - if (TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &item)) - { - di_node = (DIListNode *)item.lParam; - di_value = (DIListNode *)mir_alloc(sizeof(DIListNode)); - *di_value = *di_node; - di_value->next = opt.diList; - opt.diList = di_value; - } - item.hItem = TreeView_GetPrevSibling(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), item.hItem); - } - - DSListNode *ds_node; - while (opt.dsList) - { - ds_node = opt.dsList; - opt.dsList = opt.dsList->next; - mir_free(ds_node); - } - - DSListNode *ds_value; - opt.iDsCount = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETCOUNT, 0, 0); - for (int i = opt.iDsCount - 1; i >= 0; i--) - { - ds_node = (DSListNode *)SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETITEMDATA, i, 0); - ds_value = (DSListNode *)mir_alloc(sizeof(DSListNode)); - *ds_value = *ds_node; - ds_value->next = opt.dsList; - opt.dsList = ds_value; - } - - SaveItems(); - return TRUE; - } - case NM_DBLCLK: - { - TVITEM item = {0}; - item.mask = TVIF_PARAM; - item.hItem = TreeView_GetSelection(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS)); - if (item.hItem) - { - if (TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &item)) - { - DIListNode *di_value = (DIListNode *)item.lParam; - if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ITEM), hwndDlg, DlgProcAddItem, (LPARAM)&di_value->di) == IDOK) - { - item.mask = TVIF_TEXT; - SetTreeItemText(di_value, &item.pszText); - TreeView_SetItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &item); - SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0); - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - } - } - break; - } - case NM_CLICK: - { - TVHITTESTINFO hti; - hti.pt.x = (short)LOWORD(GetMessagePos()); - hti.pt.y = (short)HIWORD(GetMessagePos()); - ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt); - if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti)) - { - if (hti.flags & TVHT_ONITEMSTATEICON) - { - TVITEMA item = {0}; - item.hItem = hti.hItem; - item.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_STATE; - item.stateMask = TVIS_STATEIMAGEMASK; - TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item); - - if (((item.state & TVIS_STATEIMAGEMASK) >> 12) == 1) - { - item.state = INDEXTOSTATEIMAGEMASK(2); - ((DIListNode *)item.lParam)->di.bIsVisible = true; - } - else - { - item.state = INDEXTOSTATEIMAGEMASK(1); - ((DIListNode *)item.lParam)->di.bIsVisible = false; - } - - TreeView_SetItem(((LPNMHDR)lParam)->hwndFrom, &item); - SendMessage((GetParent(hwndDlg)), PSM_CHANGED, (WPARAM)hwndDlg, 0); - } - } - break; - } - case TVN_SELCHANGEDA: - case TVN_SELCHANGEDW: - { - SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0); - break; - } - } - break; - } - case WM_DESTROY: - { - DIListNode *di_value; - TVITEM tvi = {0}; - tvi.mask = TVIF_PARAM; - HTREEITEM hItem = TreeView_GetRoot(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS)); - - while (hItem != NULL) - { - tvi.hItem = hItem; - if (TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &tvi)) - { - di_value = (DIListNode *)tvi.lParam; - mir_free(di_value); - } - hItem = TreeView_GetNextSibling(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), hItem); - } - - DSListNode *ds_value; - int count = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETCOUNT, 0, 0); - for (int i = 0; i < count; i++) - { - ds_value = (DSListNode *)SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETITEMDATA, i, 0); - mir_free(ds_value); - } - - ImageList_Destroy(TreeView_GetImageList(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), TVSIL_STATE)); - break; - } - } - - return 0; -} - -INT_PTR CALLBACK DlgProcOptsAppearance(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) - { - case WM_INITDIALOG: - { - TranslateDialogDefault( hwndDlg ); - - CheckDlgButton(hwndDlg, IDC_CHK_NOFOCUS, opt.bShowNoFocus ? TRUE : FALSE); - CheckDlgButton(hwndDlg, IDC_CHK_SBAR, opt.bStatusBarTips ? TRUE : FALSE); - - SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("Icon on left")); - SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("Icon on right")); - SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("No icon")); - SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("No title")); - SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_SETCURSEL, (int)opt.titleLayout, 0); - - SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom right")); - SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom left")); - SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top right")); - SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top left")); - SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_SETCURSEL, (int)opt.pos, 0); - - SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top")); - SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Centre")); - SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom")); - switch (opt.iLabelValign) - { - case DT_TOP: SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_SETCURSEL, 0, 0); break; - case DT_VCENTER: SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_SETCURSEL, 1, 0); break; - case DT_BOTTOM: SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_SETCURSEL, 2, 0); break; - } - - SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top")); - SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Centre")); - SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom")); - switch (opt.iValueValign) - { - case DT_TOP: SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_SETCURSEL, 0, 0); break; - case DT_VCENTER: SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_SETCURSEL, 1, 0); break; - case DT_BOTTOM: SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_SETCURSEL, 2, 0); break; - } - - SendDlgItemMessage(hwndDlg, IDC_CMB_LH, CB_ADDSTRING, 0, (LPARAM)TranslateT("Left")); - SendDlgItemMessage(hwndDlg, IDC_CMB_LH, CB_ADDSTRING, 0, (LPARAM)TranslateT("Right")); - switch (opt.iLabelHalign) - { - case DT_LEFT: SendDlgItemMessage(hwndDlg, IDC_CMB_LH, CB_SETCURSEL, 0, 0); break; - case DT_RIGHT: SendDlgItemMessage(hwndDlg, IDC_CMB_LH, CB_SETCURSEL, 1, 0); break; - } - - SendDlgItemMessage(hwndDlg, IDC_CMB_VH, CB_ADDSTRING, 0, (LPARAM)TranslateT("Left")); - SendDlgItemMessage(hwndDlg, IDC_CMB_VH, CB_ADDSTRING, 0, (LPARAM)TranslateT("Right")); - switch (opt.iValueHalign) - { - case DT_LEFT: SendDlgItemMessage(hwndDlg, IDC_CMB_VH, CB_SETCURSEL, 0, 0); break; - case DT_RIGHT: SendDlgItemMessage(hwndDlg, IDC_CMB_VH, CB_SETCURSEL, 1, 0); break; - } - - SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("No avatar")); - if (ServiceExists(MS_AV_DRAWAVATAR)) - { - SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Left avatar")); - SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Right avatar")); - } - else - { - HWND hw = GetDlgItem(hwndDlg, IDC_CMB_AV); - EnableWindow(hw, FALSE); - hw = GetDlgItem(hwndDlg, IDC_SPIN_AVSIZE); - EnableWindow(hw, FALSE); - hw = GetDlgItem(hwndDlg, IDC_ED_AVSIZE); - EnableWindow(hw, FALSE); - } - SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_SETCURSEL, (int)opt.avatarLayout, 0); - - SendDlgItemMessage(hwndDlg, IDC_SPIN_WIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16)); - SendDlgItemMessage(hwndDlg, IDC_SPIN_MINWIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16)); - SendDlgItemMessage(hwndDlg, IDC_SPIN_MAXHEIGHT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16)); - SendDlgItemMessage(hwndDlg, IDC_SPIN_MINHEIGHT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16)); - SendDlgItemMessage(hwndDlg, IDC_SPIN_AVSIZE, UDM_SETRANGE, 0, (LPARAM)MAKELONG(100, 16)); - SendDlgItemMessage(hwndDlg, IDC_SPIN_INDENT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(400, 0)); - SendDlgItemMessage(hwndDlg, IDC_SPIN_TITLEINDENT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(400, 0)); - SendDlgItemMessage(hwndDlg, IDC_SPIN_VALUEINDENT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(400, 0)); - SendDlgItemMessage(hwndDlg, IDC_SPIN_PADDING, UDM_SETRANGE, 0, (LPARAM)MAKELONG(128, 0)); - SendDlgItemMessage(hwndDlg, IDC_SPIN_TEXTPADDING, UDM_SETRANGE, 0, (LPARAM)MAKELONG(128, 0)); - SendDlgItemMessage(hwndDlg, IDC_SPIN_OUTAVPADDING, UDM_SETRANGE, 0, (LPARAM)MAKELONG(128, 0)); - SendDlgItemMessage(hwndDlg, IDC_SPIN_INAVPADDING, UDM_SETRANGE, 0, (LPARAM)MAKELONG(128, 0)); - SendDlgItemMessage(hwndDlg, IDC_SPIN_HOVER, UDM_SETRANGE, 0, (LPARAM)MAKELONG(5000, 5)); - SendDlgItemMessage(hwndDlg, IDC_SPIN_SBWIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 0)); - - SetDlgItemInt(hwndDlg, IDC_ED_WIDTH, opt.iWinWidth, FALSE); - SetDlgItemInt(hwndDlg, IDC_ED_MAXHEIGHT, opt.iWinMaxHeight, FALSE); - SetDlgItemInt(hwndDlg, IDC_ED_MINWIDTH, opt.iMinWidth, FALSE); - SetDlgItemInt(hwndDlg, IDC_ED_MINHEIGHT, opt.iMinHeight, FALSE); - SetDlgItemInt(hwndDlg, IDC_ED_AVSIZE, opt.iAvatarSize, FALSE); - SetDlgItemInt(hwndDlg, IDC_ED_INDENT, opt.iTextIndent, FALSE); - SetDlgItemInt(hwndDlg, IDC_ED_TITLEINDENT, opt.iTitleIndent, FALSE); - SetDlgItemInt(hwndDlg, IDC_ED_VALUEINDENT, opt.iValueIndent, FALSE); - SetDlgItemInt(hwndDlg, IDC_ED_PADDING, opt.iPadding, FALSE); - SetDlgItemInt(hwndDlg, IDC_ED_TEXTPADDING, opt.iTextPadding, FALSE); - SetDlgItemInt(hwndDlg, IDC_ED_OUTAVPADDING, opt.iOuterAvatarPadding, FALSE); - SetDlgItemInt(hwndDlg, IDC_ED_INAVPADDING, opt.iInnerAvatarPadding, FALSE); - SetDlgItemInt(hwndDlg, IDC_ED_HOVER, opt.iTimeIn, FALSE); - SetDlgItemInt(hwndDlg, IDC_ED_SBWIDTH, opt.iSidebarWidth, FALSE); - - CheckDlgButton(hwndDlg, IDC_CHK_ROUNDCORNERSAV, opt.bAvatarRound); - CheckDlgButton(hwndDlg, IDC_CHK_AVBORDER, opt.bAvatarBorder); - CheckDlgButton(hwndDlg, IDC_CHK_ORIGINALAVSIZE, opt.bOriginalAvatarSize); - - if (opt.bOriginalAvatarSize) - SetDlgItemText(hwndDlg, IDC_STATIC_AVATARSIZE, TranslateT("Max avatar size:")); - - return FALSE; - } - case WM_COMMAND: - { - if (LOWORD(wParam) == IDC_CHK_ORIGINALAVSIZE) - { - if (IsDlgButtonChecked(hwndDlg, IDC_CHK_ORIGINALAVSIZE)) - SetDlgItemText(hwndDlg, IDC_STATIC_AVATARSIZE, TranslateT("Max avatar size:")); - else - SetDlgItemText(hwndDlg, IDC_STATIC_AVATARSIZE, TranslateT("Avatar size:")); - } - - if (HIWORD(wParam) == CBN_SELCHANGE) - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - else if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - else if (HIWORD(wParam) == BN_CLICKED) - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - - break; - } - case WM_NOTIFY: - { - if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY) - { - BOOL trans; - int new_val; - new_val = GetDlgItemInt(hwndDlg, IDC_ED_WIDTH, &trans, FALSE); - if (trans) opt.iWinWidth = new_val; - new_val = GetDlgItemInt(hwndDlg, IDC_ED_MINWIDTH, &trans, FALSE); - if (trans) opt.iMinWidth = new_val; - new_val = GetDlgItemInt(hwndDlg, IDC_ED_MAXHEIGHT, &trans, FALSE); - if (trans) opt.iWinMaxHeight = new_val; - new_val = GetDlgItemInt(hwndDlg, IDC_ED_MINHEIGHT, &trans, FALSE); - if (trans) opt.iMinHeight = new_val; - new_val = GetDlgItemInt(hwndDlg, IDC_ED_AVSIZE, &trans, FALSE); - if (trans) opt.iAvatarSize = new_val; - new_val = GetDlgItemInt(hwndDlg, IDC_ED_INDENT, &trans, FALSE); - if (trans) opt.iTextIndent = new_val; - new_val = GetDlgItemInt(hwndDlg, IDC_ED_TITLEINDENT, &trans, FALSE); - if (trans) opt.iTitleIndent = new_val; - new_val = GetDlgItemInt(hwndDlg, IDC_ED_VALUEINDENT, &trans, FALSE); - if (trans) opt.iValueIndent = new_val; - new_val = GetDlgItemInt(hwndDlg, IDC_ED_PADDING, &trans, FALSE); - if (trans) opt.iPadding = new_val; - new_val = GetDlgItemInt(hwndDlg, IDC_ED_TEXTPADDING, &trans, FALSE); - if (trans) opt.iTextPadding = new_val; - new_val = GetDlgItemInt(hwndDlg, IDC_ED_OUTAVPADDING, &trans, FALSE); - if (trans) opt.iOuterAvatarPadding = new_val; - new_val = GetDlgItemInt(hwndDlg, IDC_ED_INAVPADDING, &trans, FALSE); - if (trans) opt.iInnerAvatarPadding = new_val; - new_val = GetDlgItemInt(hwndDlg, IDC_ED_HOVER, &trans, FALSE); - if (trans) opt.iTimeIn = new_val; - new_val = GetDlgItemInt(hwndDlg, IDC_ED_SBWIDTH, &trans, FALSE); - if (trans) opt.iSidebarWidth = new_val; - - opt.titleLayout = (PopupTitleLayout)SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_GETCURSEL, 0, 0); - opt.avatarLayout = (PopupAvLayout)SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_GETCURSEL, 0, 0); - opt.pos = (PopupPosition)SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_GETCURSEL, 0, 0); - - opt.bAvatarBorder = IsDlgButtonChecked(hwndDlg, IDC_CHK_AVBORDER) ? true : false; - opt.bAvatarRound = IsDlgButtonChecked(hwndDlg, IDC_CHK_ROUNDCORNERSAV) && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHK_ROUNDCORNERSAV)) ? true : false; - opt.bOriginalAvatarSize = IsDlgButtonChecked(hwndDlg, IDC_CHK_ORIGINALAVSIZE) ? true : false; - - opt.bShowNoFocus = IsDlgButtonChecked(hwndDlg, IDC_CHK_NOFOCUS) ? true : false; - opt.bStatusBarTips = IsDlgButtonChecked(hwndDlg, IDC_CHK_SBAR) ? true : false; - - switch(SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_GETCURSEL, 0, 0)) - { - case 0: opt.iLabelValign = DT_TOP; break; - case 1: opt.iLabelValign = DT_VCENTER; break; - case 2: opt.iLabelValign = DT_BOTTOM; break; - } - - switch(SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_GETCURSEL, 0, 0)) - { - case 0: opt.iValueValign = DT_TOP; break; - case 1: opt.iValueValign = DT_VCENTER; break; - case 2: opt.iValueValign = DT_BOTTOM; break; - } - - switch(SendDlgItemMessage(hwndDlg, IDC_CMB_LH, CB_GETCURSEL, 0, 0)) - { - case 0: opt.iLabelHalign = DT_LEFT; break; - case 1: opt.iLabelHalign = DT_RIGHT; break; - } - - switch(SendDlgItemMessage(hwndDlg, IDC_CMB_VH, CB_GETCURSEL, 0, 0)) - { - case 0: opt.iValueHalign = DT_LEFT; break; - case 1: opt.iValueHalign = DT_RIGHT; break; - } - - SaveOptions(); - return TRUE; - } - break; - } - } - - return 0; -} - -INT_PTR CALLBACK DlgProcOptsExtra(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - EXTRAICONDATA *dat; - dat = (EXTRAICONDATA *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - - switch (msg) - { - case WM_INITDIALOG: - { - TranslateDialogDefault(hwndDlg); - - CheckDlgButton(hwndDlg, IDC_CHK_WAITFORCONTENT, opt.bWaitForContent); - CheckDlgButton(hwndDlg, IDC_CHK_GETSTATUSMSG, opt.bGetNewStatusMsg); - CheckDlgButton(hwndDlg, IDC_CHK_DISABLEINVISIBLE, opt.bDisableIfInvisible); - CheckDlgButton(hwndDlg, IDC_CHK_RETRIEVEXSTATUS, opt.bRetrieveXstatus); - CheckDlgButton(hwndDlg, IDC_CHK_LIMITMSG, opt.bLimitMsg); - CheckDlgButton(hwndDlg, IDC_CHK_ENABLESMILEYS, opt.iSmileyAddFlags & SMILEYADD_ENABLE); - CheckDlgButton(hwndDlg, IDC_CHK_USEPROTOSMILEYS, opt.iSmileyAddFlags & SMILEYADD_USEPROTO); - CheckDlgButton(hwndDlg, IDC_CHK_ONLYISOLATED, opt.iSmileyAddFlags & SMILEYADD_ONLYISOLATED); - CheckDlgButton(hwndDlg, IDC_CHK_RESIZESMILEYS, opt.iSmileyAddFlags & SMILEYADD_RESIZE); - - EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DISABLEINVISIBLE), opt.bGetNewStatusMsg); - - BOOL bEnable = opt.iSmileyAddFlags & SMILEYADD_ENABLE; - EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_USEPROTOSMILEYS), bEnable); - EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_ONLYISOLATED), bEnable); - EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_RESIZESMILEYS), bEnable); - - SendDlgItemMessage(hwndDlg, IDC_SPIN_CHARCOUNT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(1024, 16)); - SetDlgItemInt(hwndDlg, IDC_ED_CHARCOUNT, opt.iLimitCharCount, FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_ED_CHARCOUNT), opt.bLimitMsg); - - HIMAGELIST himlStates = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 2, 2); - ImageList_AddIcon(himlStates, LoadSkinnedIcon(SKINICON_OTHER_NOTICK)); - ImageList_AddIcon(himlStates, LoadSkinnedIcon(SKINICON_OTHER_NOTICK)); - ImageList_AddIcon(himlStates, LoadSkinnedIcon(SKINICON_OTHER_TICK)); - TreeView_SetImageList(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), himlStates, TVSIL_STATE); - - int i; - for (i = 0; i < EXICONS_COUNT; i++) - { - exIcons[i].order = opt.exIconsOrder[i]; - exIcons[i].vis = opt.exIconsVis[i]; - } - - dat = (EXTRAICONDATA *)mir_alloc(sizeof(EXTRAICONDATA)); - dat->bDragging = false; - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); - SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), GWL_STYLE) | TVS_NOHSCROLL); - - TVINSERTSTRUCT tvi = {0}; - tvi.hParent = 0; - tvi.hInsertAfter = TVI_LAST; - tvi.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_STATE; - tvi.item.stateMask = TVIS_STATEIMAGEMASK; - for (i = 0; i < SIZEOF(extraIconName); i++ ) - { - tvi.item.lParam = (LPARAM)(&exIcons[i]); - tvi.item.pszText = TranslateTS(extraIconName[exIcons[i].order]); - tvi.item.state = INDEXTOSTATEIMAGEMASK(exIcons[i].vis ? 2 : 1); - TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &tvi); - } - - return TRUE; - } - case WM_COMMAND: - { - switch(LOWORD(wParam)) - { - case IDC_CHK_ENABLESMILEYS: - { - BOOL bEnable; - bEnable = IsDlgButtonChecked(hwndDlg, IDC_CHK_ENABLESMILEYS); - EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_RESIZESMILEYS), bEnable); - EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_USEPROTOSMILEYS), bEnable); - EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_ONLYISOLATED), bEnable); - EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_RESIZESMILEYS), bEnable); - break; - } - case IDC_CHK_LIMITMSG: - { - EnableWindow(GetDlgItem(hwndDlg, IDC_ED_CHARCOUNT), IsDlgButtonChecked(hwndDlg, IDC_CHK_LIMITMSG)); - break; - } - case IDC_CHK_GETSTATUSMSG: - { - EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DISABLEINVISIBLE), IsDlgButtonChecked(hwndDlg, IDC_CHK_GETSTATUSMSG)); - break; - } - } - - if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus()) - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - - break; - } - case WM_NOTIFY: - { - switch (((LPNMHDR)lParam)->idFrom) - { - case 0: - { - if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY) - { - TVITEM item = {0}; - int i = 0; - DBCONTACTWRITESETTING cws; - cws.szModule = MODULE; - cws.szSetting = "IconOrder"; - cws.value.type = DBVT_BLOB; - cws.value.cpbVal = SIZEOF(extraIconName); - cws.value.pbVal = opt.exIconsOrder; - - item.hItem = TreeView_GetRoot(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS)); - while (item.hItem != NULL) - { - item.mask = TVIF_HANDLE | TVIF_PARAM; - TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &item); - opt.exIconsOrder[i++] = ((ICONSTATE *)item.lParam)->order; - item.hItem = TreeView_GetNextSibling(GetDlgItem(hwndDlg,IDC_TREE_EXTRAICONS), item.hItem); - } - CallService(MS_DB_CONTACT_WRITESETTING, 0,(LPARAM)&cws); - - i = 0; - cws.szModule = MODULE; - cws.szSetting = "icons_vis"; - cws.value.type = DBVT_BLOB; - cws.value.cpbVal = SIZEOF(extraIconName); - cws.value.pbVal = opt.exIconsVis; - item.hItem = TreeView_GetRoot(GetDlgItem(hwndDlg,IDC_TREE_EXTRAICONS)); - - while (item.hItem != NULL) - { - item.mask = TVIF_HANDLE | TVIF_PARAM; - TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &item); - opt.exIconsVis[i++] = ((ICONSTATE *)item.lParam)->vis; - item.hItem = TreeView_GetNextSibling(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), item.hItem); - } - CallService(MS_DB_CONTACT_WRITESETTING, 0, (LPARAM)&cws); - - opt.iSmileyAddFlags = 0; - opt.iSmileyAddFlags |= (IsDlgButtonChecked(hwndDlg, IDC_CHK_ENABLESMILEYS) ? SMILEYADD_ENABLE : 0) | - (IsDlgButtonChecked(hwndDlg, IDC_CHK_USEPROTOSMILEYS) ? SMILEYADD_USEPROTO : 0) | - (IsDlgButtonChecked(hwndDlg, IDC_CHK_ONLYISOLATED) ? SMILEYADD_ONLYISOLATED : 0) | - (IsDlgButtonChecked(hwndDlg, IDC_CHK_RESIZESMILEYS) ? SMILEYADD_RESIZE : 0); - - opt.bWaitForContent = IsDlgButtonChecked(hwndDlg, IDC_CHK_WAITFORCONTENT) ? true : false; - opt.bGetNewStatusMsg = IsDlgButtonChecked(hwndDlg, IDC_CHK_GETSTATUSMSG) ? true : false; - opt.bDisableIfInvisible = IsDlgButtonChecked(hwndDlg, IDC_CHK_DISABLEINVISIBLE) ? true : false; - opt.bRetrieveXstatus = IsDlgButtonChecked(hwndDlg, IDC_CHK_RETRIEVEXSTATUS) ? true : false; - opt.bLimitMsg = IsDlgButtonChecked(hwndDlg, IDC_CHK_LIMITMSG) ? true : false; - opt.iLimitCharCount = GetDlgItemInt(hwndDlg, IDC_ED_CHARCOUNT, 0, FALSE); - - DBWriteContactSettingDword(0, MODULE, "SmileyAddFlags", opt.iSmileyAddFlags); - DBWriteContactSettingByte(0, MODULE, "WaitForContent", opt.bWaitForContent ? 1 : 0); - DBWriteContactSettingByte(0, MODULE, "GetNewStatusMsg", opt.bGetNewStatusMsg ? 1 : 0); - DBWriteContactSettingByte(0, MODULE, "DisableInvisible", opt.bDisableIfInvisible ? 1 : 0); - DBWriteContactSettingByte(0, MODULE, "RetrieveXStatus", opt.bRetrieveXstatus ? 1 : 0); - DBWriteContactSettingByte(0, MODULE, "LimitMsg", opt.bLimitMsg ? 1 : 0); - DBWriteContactSettingByte(0, MODULE, "LimitCharCount", opt.iLimitCharCount); - - return TRUE; - } - break; - } - case IDC_TREE_EXTRAICONS: - { - switch (((LPNMHDR)lParam)->code) - { - case TVN_BEGINDRAGA: - case TVN_BEGINDRAGW: - { - SetCapture(hwndDlg); - dat->bDragging = true; - dat->hDragItem = ((LPNMTREEVIEW)lParam)->itemNew.hItem; - TreeView_SelectItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), dat->hDragItem); - break; - } - case NM_CLICK: - { - TVHITTESTINFO hti; - hti.pt.x = (short)LOWORD(GetMessagePos()); - hti.pt.y = (short)HIWORD(GetMessagePos()); - ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt); - if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti)) - { - if (hti.flags & TVHT_ONITEMSTATEICON) - { - TVITEMA item; - item.mask = TVIF_HANDLE | TVIF_STATE; - item.stateMask = TVIS_STATEIMAGEMASK; - item.hItem = hti.hItem; - TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item); - if (((item.state & TVIS_STATEIMAGEMASK) >> 12) == 1) - { - item.state = INDEXTOSTATEIMAGEMASK(2); - ((ICONSTATE *)item.lParam)->vis = 1; - } - else - { - item.state = INDEXTOSTATEIMAGEMASK(1); - ((ICONSTATE *)item.lParam)->vis = 0; - } - - TreeView_SetItem(((LPNMHDR)lParam)->hwndFrom, &item); - SendMessage((GetParent(hwndDlg)), PSM_CHANGED, (WPARAM)hwndDlg, 0); - } - } - break; - } - } - break; - } - } - break; - } - case WM_MOUSEMOVE: - { - if (!dat->bDragging) - break; - - TVHITTESTINFO hti; - hti.pt.x = (short)LOWORD(lParam); - hti.pt.y = (short)HIWORD(lParam); - ClientToScreen(hwndDlg, &hti.pt); - ScreenToClient(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &hti.pt); - TreeView_HitTest(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &hti); - if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) - { - HTREEITEM hItem = hti.hItem; - hti.pt.y -= TreeView_GetItemHeight(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS)) / 2; - TreeView_HitTest(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &hti); - if (!(hti.flags & TVHT_ABOVE)) - TreeView_SetInsertMark(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), hti.hItem, 1); - else - TreeView_SetInsertMark(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), hItem, 0); - } - else - { - if (hti.flags & TVHT_ABOVE) - SendDlgItemMessage(hwndDlg, IDC_TREE_EXTRAICONS, WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0); - if (hti.flags & TVHT_BELOW) - SendDlgItemMessage(hwndDlg, IDC_TREE_EXTRAICONS, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0); - - TreeView_SetInsertMark(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), 0, 0); - } - break; - } - case WM_LBUTTONUP: - { - if (!dat->bDragging) - break; - - TreeView_SetInsertMark(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), 0, 0); - dat->bDragging = false; - ReleaseCapture(); - - TVHITTESTINFO hti; - hti.pt.x = (short)LOWORD(lParam); - hti.pt.y = (short)HIWORD(lParam); - ClientToScreen(hwndDlg, &hti.pt); - ScreenToClient(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &hti.pt); - hti.pt.y -= TreeView_GetItemHeight(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS)) / 2; - TreeView_HitTest(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &hti); - if (dat->hDragItem == hti.hItem) - break; - - if (hti.flags & TVHT_ABOVE) - hti.hItem = TVI_FIRST; - - TVITEM item; - item.mask = TVIF_HANDLE | TVIF_PARAM; - item.hItem = dat->hDragItem; - TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &item); - if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT) || (hti.hItem == TVI_FIRST)) - { - TVINSERTSTRUCT tvis; - TCHAR swzName[256]; - tvis.item.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT | TVIF_STATE; - tvis.item.stateMask = TVIS_STATEIMAGEMASK; - tvis.item.pszText = swzName; - tvis.item.cchTextMax = 256; - tvis.item.hItem = dat->hDragItem; - tvis.item.state = INDEXTOSTATEIMAGEMASK(((ICONSTATE *)item.lParam)->vis ? 2 : 1); - TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &tvis.item); - TreeView_DeleteItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), dat->hDragItem); - tvis.hParent = NULL; - tvis.hInsertAfter = hti.hItem; - TreeView_SelectItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &tvis)); - SendMessage((GetParent(hwndDlg)), PSM_CHANGED, (WPARAM)hwndDlg, 0); - } - - break; - } - case WM_DESTROY: - { - ImageList_Destroy(TreeView_GetImageList(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), TVSIL_STATE)); - mir_free(dat); - break; - } - } - return 0; -} - -void EnableControls(HWND hwndDlg, BOOL bEnableSkin) -{ - ShowWindow(GetDlgItem(hwndDlg, IDC_ST_PREVIEW), (bEnableSkin && opt.szPreviewFile[0]) ? SW_HIDE : SW_SHOW); - ShowWindow(GetDlgItem(hwndDlg, IDC_PIC_PREVIEW), (bEnableSkin && opt.szPreviewFile[0]) ? SW_SHOW : SW_HIDE); - EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_SHADOW), !bEnableSkin); - EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_BORDER), !bEnableSkin); - EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_ROUNDCORNERS), !bEnableSkin); - EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_LOADFONTS), bEnableSkin); - EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_LOADPROPORTIONS), bEnableSkin); - EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_ENABLECOLORING), bEnableSkin && opt.iEnableColoring != -1); -} - -int iLastSel; -INT_PTR CALLBACK DlgProcOptsSkin(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) - { - case WM_INITDIALOG: - { - TranslateDialogDefault(hwndDlg); - iLastSel = RefreshSkinList(hwndDlg); - - SendDlgItemMessage(hwndDlg, IDC_BTN_RELOADLIST, BUTTONSETASFLATBTN, TRUE, 0); - SendDlgItemMessage(hwndDlg, IDC_BTN_RELOADLIST, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Reload skin list"), BATF_TCHAR); - HICON hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_RELOAD)); - SendDlgItemMessage(hwndDlg, IDC_BTN_RELOADLIST, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); - DestroyIcon(hIcon); - - SendDlgItemMessage(hwndDlg, IDC_BTN_APPLYSKIN, BUTTONSETASFLATBTN, TRUE, 0); - SendDlgItemMessage(hwndDlg, IDC_BTN_APPLYSKIN, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Apply skin"), BATF_TCHAR); - hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_APPLY)); - SendDlgItemMessage(hwndDlg, IDC_BTN_APPLYSKIN, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); - DestroyIcon(hIcon); - - SendDlgItemMessage(hwndDlg, IDC_BTN_GETSKINS, BUTTONSETASFLATBTN, TRUE, 0); - SendDlgItemMessage(hwndDlg, IDC_BTN_GETSKINS, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Get more skins"), BATF_TCHAR); - SendDlgItemMessage(hwndDlg, IDC_BTN_GETSKINS, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadSkinnedIcon(SKINICON_EVENT_URL)); - - - SendDlgItemMessage(hwndDlg, IDC_SPIN_TRANS, UDM_SETRANGE, 0, (LPARAM)MAKELONG(100, 0)); - SetDlgItemInt(hwndDlg, IDC_ED_TRANS, opt.iOpacity, FALSE); - - CheckDlgButton(hwndDlg, IDC_CHK_BORDER, opt.bBorder); - CheckDlgButton(hwndDlg, IDC_CHK_ROUNDCORNERS, opt.bRound); - CheckDlgButton(hwndDlg, IDC_CHK_SHADOW, opt.bDropShadow); - CheckDlgButton(hwndDlg, IDC_CHK_AEROGLASS, opt.bAeroGlass); - CheckDlgButton(hwndDlg, IDC_CHK_LOADFONTS, opt.bLoadFonts); - CheckDlgButton(hwndDlg, IDC_CHK_LOADPROPORTIONS, opt.bLoadProportions); - if (opt.iEnableColoring != -1) - CheckDlgButton(hwndDlg, IDC_CHK_ENABLECOLORING, opt.iEnableColoring ? 1 : 0); - - EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_AEROGLASS), MyDwmEnableBlurBehindWindow != 0); - - SendDlgItemMessage(hwndDlg, IDC_CMB_EFFECT, CB_ADDSTRING, 0, (LPARAM)TranslateT("None")); - SendDlgItemMessage(hwndDlg, IDC_CMB_EFFECT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Animation")); - SendDlgItemMessage(hwndDlg, IDC_CMB_EFFECT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Fade")); - SendDlgItemMessage(hwndDlg, IDC_CMB_EFFECT, CB_SETCURSEL, (int)opt.showEffect, 0); - - SendDlgItemMessage(hwndDlg, IDC_SPIN_SPEED, UDM_SETRANGE, 0, (LPARAM)MAKELONG(20, 1)); - SetDlgItemInt(hwndDlg, IDC_ED_SPEED, opt.iAnimateSpeed, FALSE); - - EnableControls(hwndDlg, opt.skinMode == SM_IMAGE); - return TRUE; - } - case WM_DRAWITEM: - { - if (wParam == IDC_PIC_PREVIEW) - { - DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)lParam; - HBRUSH hbr = GetSysColorBrush(COLOR_BTNFACE); - FillRect(dis->hDC, &dis->rcItem, hbr); - - if (opt.szPreviewFile[0]) - { - HDC hdcMem = CreateCompatibleDC(dis->hDC); - HBITMAP hbmpPreview = (HBITMAP)CallService(MS_IMG_LOAD, (WPARAM)opt.szPreviewFile, IMGL_TCHAR); - if (hbmpPreview) - { - int iWidth = dis->rcItem.right - dis->rcItem.left; - int iHeight = dis->rcItem.bottom - dis->rcItem.top; - - ResizeBitmap rb = {0}; - rb.size = sizeof(rb); - rb.hBmp = hbmpPreview; - rb.max_width = iWidth; - rb.max_height = iHeight; - rb.fit = RESIZEBITMAP_KEEP_PROPORTIONS; - HBITMAP hbmpRes = (HBITMAP)CallService(MS_IMG_RESIZE, (WPARAM)&rb, 0); - if (hbmpRes) - { - BITMAP bmp; - GetObject(hbmpRes, sizeof(bmp), &bmp); - SelectObject(hdcMem, hbmpRes); - BitBlt(dis->hDC, (iWidth - bmp.bmWidth) / 2, (iHeight - bmp.bmHeight) / 2, iWidth, iHeight, hdcMem, 0, 0, SRCCOPY); - if (hbmpPreview != hbmpRes) - DeleteBitmap(hbmpRes); - } - - DeleteBitmap(hbmpPreview); - } - - DeleteDC(hdcMem); - } - } - break; - } - case WM_COMMAND: - { - switch (HIWORD(wParam)) - { - case LBN_SELCHANGE: - { - if (LOWORD(wParam) == IDC_LB_SKINS) - { - HWND hwndList = GetDlgItem(hwndDlg, IDC_LB_SKINS); - int iSel = ListBox_GetCurSel(hwndList); - if (iSel != iLastSel) - { - if (iSel == 0) - { - opt.szPreviewFile[0] = 0; - EnableControls(hwndDlg, FALSE); - } - else if (iSel != LB_ERR) - { - TCHAR swzSkinName[256]; - if (ListBox_GetText(hwndList, iSel, swzSkinName) > 0) - ParseSkinFile(swzSkinName, false, true); - EnableControls(hwndDlg, TRUE); - if (opt.iEnableColoring != -1) - CheckDlgButton(hwndDlg, IDC_CHK_ENABLECOLORING, opt.iEnableColoring ? 1 : 0); - } - - InvalidateRect(GetDlgItem(hwndDlg, IDC_PIC_PREVIEW), 0, FALSE); - iLastSel = iSel; - } - } - else if (LOWORD(wParam) == IDC_CMB_EFFECT) - { - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - - break; - } - case BN_CLICKED: - { - if (LOWORD(wParam) == IDC_BTN_APPLYSKIN) - { - int iSel = ListBox_GetCurSel(GetDlgItem(hwndDlg, IDC_LB_SKINS)); - if (iSel == 0) - { - opt.skinMode = SM_COLORFILL; - opt.szSkinName[0] = 0; - } - else if (iSel != LB_ERR) - { - if (ListBox_GetText(GetDlgItem(hwndDlg, IDC_LB_SKINS), iSel, opt.szSkinName) > 0) - { - opt.skinMode = SM_IMAGE; - ParseSkinFile(opt.szSkinName, false, false); - ReloadFont(0, 0); - SaveOptions(); - } - } - - DBWriteContactSettingByte(0, MODULE, "SkinEngine", opt.skinMode); - DBWriteContactSettingTString(0, MODULE, "SkinName", opt.szSkinName); - - DestroySkinBitmap(); - SetDlgItemInt(hwndDlg, IDC_ED_TRANS, opt.iOpacity, FALSE); - } - else if (LOWORD(wParam) == IDC_BTN_RELOADLIST) - iLastSel = RefreshSkinList(hwndDlg); - else if (LOWORD(wParam) == IDC_CHK_LOADFONTS) - opt.bLoadFonts = IsDlgButtonChecked(hwndDlg, IDC_CHK_LOADFONTS) ? true : false; - else if (LOWORD(wParam) == IDC_CHK_LOADPROPORTIONS) - opt.bLoadProportions = IsDlgButtonChecked(hwndDlg, IDC_CHK_LOADPROPORTIONS) ? true : false; - else if (LOWORD(wParam) == IDC_BTN_GETSKINS) - CallService(MS_UTILS_OPENURL, 0, (LPARAM)"http://www.miranda-easy.net/tipper"); - - break; - } - } - - if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus()) - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - - break; - } - case WM_NOTIFY: - { - if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY ) - { - opt.iOpacity = GetDlgItemInt(hwndDlg, IDC_ED_TRANS, 0, 0); - opt.bDropShadow = IsDlgButtonChecked(hwndDlg, IDC_CHK_SHADOW) ? true : false; - opt.bBorder = IsDlgButtonChecked(hwndDlg, IDC_CHK_BORDER) ? true : false; - opt.bRound = IsDlgButtonChecked(hwndDlg, IDC_CHK_ROUNDCORNERS) ? true : false; - opt.bAeroGlass = IsDlgButtonChecked(hwndDlg, IDC_CHK_AEROGLASS) ? true : false; - opt.showEffect = (PopupShowEffect)SendDlgItemMessage(hwndDlg, IDC_CMB_EFFECT, CB_GETCURSEL, 0, 0); - opt.iAnimateSpeed = GetDlgItemInt(hwndDlg, IDC_ED_SPEED, 0, 0); - opt.bLoadFonts = IsDlgButtonChecked(hwndDlg, IDC_CHK_LOADFONTS) ? true : false; - opt.bLoadProportions = IsDlgButtonChecked(hwndDlg, IDC_CHK_LOADPROPORTIONS) ? true : false; - - if (opt.iEnableColoring != -1) - opt.iEnableColoring = IsDlgButtonChecked(hwndDlg, IDC_CHK_ENABLECOLORING) ? true : false; - - SaveSkinOptions(); - return TRUE; - } - } - } - - return FALSE; -} - -INT_PTR CALLBACK DlgProcFavouriteContacts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) - { - case WM_INITDIALOG: - { - TranslateDialogDefault(hwndDlg); - - if (CallService(MS_CLUI_GETCAPS, 0, 0) & CLUIF_DISABLEGROUPS && !DBGetContactSettingByte(NULL, "CList", "UseGroups", SETTING_USEGROUPS_DEFAULT)) - SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETUSEGROUPS, (WPARAM) FALSE, 0); - else - SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETUSEGROUPS, (WPARAM) TRUE, 0); - - SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETHIDEEMPTYGROUPS, 1, 0); - SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETGREYOUTFLAGS, 0, 0); - SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETLEFTMARGIN, 2, 0); - - HANDLE hContact, hItem; - hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - while (hContact) - { - hItem = (HANDLE) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0); - if (hItem && DBGetContactSettingByte(hContact, MODULE, "FavouriteContact", 0)) - SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM)hItem, 1); - - hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0); - } - - CheckDlgButton(hwndDlg, IDC_CHK_HIDEOFFLINE, opt.iFavoriteContFlags & FAVCONT_HIDE_OFFLINE); - CheckDlgButton(hwndDlg, IDC_CHK_APPENDPROTO, opt.iFavoriteContFlags & FAVCONT_APPEND_PROTO); - - return TRUE; - } - case WM_COMMAND: - { - switch(LOWORD(wParam)) - { - case IDC_BTN_OK: - { - HANDLE hContact, hItem; - BYTE isChecked; - int count = 0; - - hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - while (hContact) - { - hItem = (HANDLE) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0); - if (hItem) - { - isChecked = (BYTE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM)hItem, 0); - DBWriteContactSettingByte(hContact, MODULE, "FavouriteContact", isChecked); - if (isChecked) count++; - } - - hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0); - } - DBWriteContactSettingDword(0, MODULE, "FavouriteContactsCount", count); - - opt.iFavoriteContFlags = 0; - opt.iFavoriteContFlags |= IsDlgButtonChecked(hwndDlg, IDC_CHK_HIDEOFFLINE) ? FAVCONT_HIDE_OFFLINE : 0 | - IsDlgButtonChecked(hwndDlg, IDC_CHK_APPENDPROTO) ? FAVCONT_APPEND_PROTO : 0; - - DBWriteContactSettingDword(0, MODULE, "FavContFlags", opt.iFavoriteContFlags); - } // fall through - case IDC_BTN_CANCEL: - { - DestroyWindow(hwndDlg); - break; - } - } - return TRUE; - } - case WM_CLOSE: - { - DestroyWindow(hwndDlg); - return TRUE; - } - } - - return FALSE; -} - -INT_PTR CALLBACK DlgProcOptsTraytip(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) - { - case WM_INITDIALOG: - { - TranslateDialogDefault(hwndDlg); - - CheckDlgButton(hwndDlg, IDC_CHK_ENABLETRAYTIP, opt.bTraytip); - CheckDlgButton(hwndDlg, IDC_CHK_HANDLEBYTIPPER, opt.bHandleByTipper); - CheckDlgButton(hwndDlg, IDC_CHK_EXPAND, opt.bExpandTraytip); - CheckDlgButton(hwndDlg, IDC_CHK_HIDEOFFLINE, opt.bHideOffline); - SendDlgItemMessage(hwndDlg, IDC_SPIN_EXPANDTIME, UDM_SETRANGE, 0, (LPARAM)MAKELONG(5000, 10)); - SetDlgItemInt(hwndDlg, IDC_ED_EXPANDTIME, opt.iExpandTime, FALSE); - SendMessage(hwndDlg, WM_COMMAND, MAKELONG(IDC_CHK_ENABLETRAYTIP, 0), 0); - - SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_FIRST_PROTOS), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_FIRST_PROTOS), GWL_STYLE) | TVS_NOHSCROLL); - SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_SECOND_PROTOS), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_SECOND_PROTOS), GWL_STYLE) | TVS_NOHSCROLL); - SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), GWL_STYLE) | TVS_NOHSCROLL); - SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_SECOND_ITEMS), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_SECOND_ITEMS), GWL_STYLE) | TVS_NOHSCROLL); - - HIMAGELIST himlCheckBoxes; - himlCheckBoxes = ImageList_Create(16, 16, IsWinVerXPPlus() ? ILC_COLOR32 | ILC_MASK : ILC_COLOR8 | ILC_MASK, 3, 0); - ImageList_AddIcon(himlCheckBoxes, LoadSkinnedIcon(SKINICON_OTHER_NOTICK)); - ImageList_AddIcon(himlCheckBoxes, LoadSkinnedIcon(SKINICON_OTHER_NOTICK)); - ImageList_AddIcon(himlCheckBoxes, LoadSkinnedIcon(SKINICON_OTHER_TICK)); - - TreeView_SetImageList(GetDlgItem(hwndDlg, IDC_TREE_FIRST_PROTOS), himlCheckBoxes, TVSIL_STATE); - TreeView_SetImageList(GetDlgItem(hwndDlg, IDC_TREE_SECOND_PROTOS), himlCheckBoxes, TVSIL_STATE); - TreeView_SetImageList(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), himlCheckBoxes, TVSIL_STATE); - TreeView_SetImageList(GetDlgItem(hwndDlg, IDC_TREE_SECOND_ITEMS), himlCheckBoxes, TVSIL_STATE); - - TVINSERTSTRUCT tvi = {0}; - tvi.hParent = 0; - tvi.hInsertAfter = TVI_LAST; - tvi.item.mask = TVIF_TEXT | TVIF_STATE; - - int i, count = 0; - PROTOACCOUNT **accs; - ProtoEnumAccounts(&count, &accs); - - for (i = 0; i < count; i++) - { - if (accs[i]->type == PROTOTYPE_PROTOCOL && CallProtoService(accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) != 0) - { - tvi.item.pszText = accs[i]->tszAccountName; - tvi.item.stateMask = TVIS_STATEIMAGEMASK; - tvi.item.state = INDEXTOSTATEIMAGEMASK(IsTrayProto(accs[i]->tszAccountName, false) ? 2 : 1); - TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_PROTOS), &tvi); - tvi.item.state = INDEXTOSTATEIMAGEMASK(IsTrayProto(accs[i]->tszAccountName, true) ? 2 : 1); - TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_TREE_SECOND_PROTOS), &tvi); - } - } - - for (i = 0; i < SIZEOF(trayTipItems); i++) - { - tvi.item.pszText = TranslateTS(trayTipItems[i]); - tvi.item.state = INDEXTOSTATEIMAGEMASK(opt.iFirstItems & (1 << i) ? 2 : 1); - TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &tvi); - tvi.item.state = INDEXTOSTATEIMAGEMASK(opt.iSecondItems & (1 << i) ? 2 : 1); - TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_TREE_SECOND_ITEMS), &tvi); - } - - return TRUE; - } - case WM_COMMAND: - { - switch(LOWORD(wParam)) - { - UINT state; - case IDC_CHK_ENABLETRAYTIP: - { - state = IsDlgButtonChecked(hwndDlg, IDC_CHK_ENABLETRAYTIP); - EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_HANDLEBYTIPPER), state); - } // fall through - case IDC_CHK_HANDLEBYTIPPER: - { - state = IsDlgButtonChecked(hwndDlg, IDC_CHK_HANDLEBYTIPPER) & - IsDlgButtonChecked(hwndDlg, IDC_CHK_ENABLETRAYTIP); - - EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_HIDEOFFLINE), state); - EnableWindow(GetDlgItem(hwndDlg, IDC_TREE_FIRST_PROTOS), state); - EnableWindow(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), state); - EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_FAVCONTACTS), state); - EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_EXPAND), state); - } // fall through - case IDC_CHK_EXPAND: - { - state = IsDlgButtonChecked(hwndDlg, IDC_CHK_HANDLEBYTIPPER) & - IsDlgButtonChecked(hwndDlg, IDC_CHK_ENABLETRAYTIP) & - IsDlgButtonChecked(hwndDlg, IDC_CHK_EXPAND); - EnableWindow(GetDlgItem(hwndDlg, IDC_TREE_SECOND_PROTOS), state); - EnableWindow(GetDlgItem(hwndDlg, IDC_TREE_SECOND_ITEMS), state); - EnableWindow(GetDlgItem(hwndDlg, IDC_ED_EXPANDTIME), state); - break; - } - case IDC_BTN_FAVCONTACTS: - { - CreateDialog(hInst, MAKEINTRESOURCE(IDD_FAVCONTACTS), 0, DlgProcFavouriteContacts); - break; - } - } - - if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus()) - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - - break; - } - case WM_NOTIFY: - { - switch (((LPNMHDR)lParam)->idFrom) - { - case 0: - { - if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY) - { - TCHAR buff[256]; - TCHAR swzProtos[1024] = {0}; - - TVITEM item; - item.hItem = TreeView_GetRoot(GetDlgItem(hwndDlg,IDC_TREE_FIRST_PROTOS)); - item.pszText = buff; - item.cchTextMax = 256; - item.mask = TVIF_HANDLE | TVIF_TEXT | TVIF_STATE; - item.stateMask = TVIS_STATEIMAGEMASK; - while (item.hItem != NULL) - { - TreeView_GetItem(GetDlgItem(hwndDlg,IDC_TREE_FIRST_PROTOS), &item); - if (((item.state & TVIS_STATEIMAGEMASK) >> 12) == 2) - { - _tcscat(swzProtos, buff); - _tcscat(swzProtos, _T(" ")); - } - - item.hItem = TreeView_GetNextSibling(GetDlgItem(hwndDlg, IDC_TREE_FIRST_PROTOS), item.hItem); - } - - DBWriteContactSettingTString(0, MODULE, "TrayProtocols", swzProtos); - - swzProtos[0] = 0; - item.hItem = TreeView_GetRoot(GetDlgItem(hwndDlg,IDC_TREE_SECOND_PROTOS)); - item.pszText = buff; - while (item.hItem != NULL) - { - TreeView_GetItem(GetDlgItem(hwndDlg,IDC_TREE_SECOND_PROTOS), &item); - if (((item.state & TVIS_STATEIMAGEMASK) >> 12) == 2) - { - _tcscat(swzProtos, buff); - _tcscat(swzProtos, _T(" ")); - } - - item.hItem = TreeView_GetNextSibling(GetDlgItem(hwndDlg, IDC_TREE_SECOND_PROTOS), item.hItem); - } - - DBWriteContactSettingTString(0, MODULE, "TrayProtocolsEx", swzProtos); - - int count = 0; - opt.iFirstItems = 0; - item.hItem = TreeView_GetRoot(GetDlgItem(hwndDlg,IDC_TREE_FIRST_ITEMS)); - item.mask = TVIF_HANDLE | TVIF_STATE; - item.stateMask = TVIS_STATEIMAGEMASK; - while (item.hItem != NULL) - { - TreeView_GetItem(GetDlgItem(hwndDlg,IDC_TREE_FIRST_ITEMS), &item); - if (((item.state & TVIS_STATEIMAGEMASK) >> 12) == 2) - opt.iFirstItems |= (1 << count); - - item.hItem = TreeView_GetNextSibling(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), item.hItem); - count++; - } - - count = 0; - opt.iSecondItems = 0; - item.hItem = TreeView_GetRoot(GetDlgItem(hwndDlg,IDC_TREE_SECOND_ITEMS)); - while (item.hItem != NULL) - { - TreeView_GetItem(GetDlgItem(hwndDlg,IDC_TREE_SECOND_ITEMS), &item); - if (((item.state & TVIS_STATEIMAGEMASK) >> 12) == 2) - opt.iSecondItems |= (1 << count); - - item.hItem = TreeView_GetNextSibling(GetDlgItem(hwndDlg, IDC_TREE_SECOND_ITEMS), item.hItem); - count++; - } - - opt.bTraytip = IsDlgButtonChecked(hwndDlg, IDC_CHK_ENABLETRAYTIP) ? true : false; - opt.bHandleByTipper = IsDlgButtonChecked(hwndDlg, IDC_CHK_HANDLEBYTIPPER) ? true : false; - opt.bExpandTraytip = IsDlgButtonChecked(hwndDlg, IDC_CHK_EXPAND) ? true : false; - opt.bHideOffline = IsDlgButtonChecked(hwndDlg, IDC_CHK_HIDEOFFLINE) ? true : false; - opt.iExpandTime = max(min(GetDlgItemInt(hwndDlg, IDC_ED_EXPANDTIME, 0, FALSE), 5000), 10); - - DBWriteContactSettingByte(0, MODULE, "TrayTip", (opt.bTraytip ? 1 : 0)); - DBWriteContactSettingByte(0, MODULE, "ExtendedTrayTip", (opt.bHandleByTipper ? 1 : 0)); - DBWriteContactSettingByte(0, MODULE, "ExpandTrayTip", (opt.bExpandTraytip ? 1 : 0)); - DBWriteContactSettingByte(0, MODULE, "HideOffline", (opt.bHideOffline ? 1 : 0)); - DBWriteContactSettingDword(0, MODULE, "ExpandTime", opt.iExpandTime); - DBWriteContactSettingDword(0, MODULE, "TrayTipItems", opt.iFirstItems); - DBWriteContactSettingDword(0, MODULE, "TrayTipItemsEx", opt.iSecondItems); - return TRUE; - } - break; - } - case IDC_TREE_FIRST_PROTOS: - case IDC_TREE_SECOND_PROTOS: - case IDC_TREE_FIRST_ITEMS: - case IDC_TREE_SECOND_ITEMS: - { - if (((LPNMHDR)lParam)->code == NM_CLICK) - { - TVHITTESTINFO hti; - hti.pt.x = (short)LOWORD(GetMessagePos()); - hti.pt.y = (short)HIWORD(GetMessagePos()); - ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt); - if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti)) - { - if (hti.flags & TVHT_ONITEMSTATEICON) - { - TVITEMA item = {0}; - item.hItem = hti.hItem; - item.mask = TVIF_HANDLE | TVIF_STATE; - item.stateMask = TVIS_STATEIMAGEMASK; - TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item); - - if (((item.state & TVIS_STATEIMAGEMASK) >> 12) == 1) - item.state = INDEXTOSTATEIMAGEMASK(2); - else - item.state = INDEXTOSTATEIMAGEMASK(1); - - TreeView_SetItem(((LPNMHDR)lParam)->hwndFrom, &item); - SendMessage((GetParent(hwndDlg)), PSM_CHANGED, (WPARAM)hwndDlg, 0); - } - } - } - break; - } - } - break; - } - case WM_DESTROY: - { - ImageList_Destroy(TreeView_GetImageList(GetDlgItem(hwndDlg, IDC_TREE_FIRST_PROTOS), TVSIL_STATE)); - break; - } - } - - return FALSE; -} - -int OptInit(WPARAM wParam, LPARAM lParam) -{ - OPTIONSDIALOGPAGE odp = {0}; - odp.cbSize = sizeof(odp); - odp.flags = ODPF_BOLDGROUPS; - odp.position = -790000000; - odp.hInstance = hInst; - - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_APPEARANCE); - odp.pszTab = LPGEN("Appearance"); - odp.pszTitle = LPGEN("Tooltips"); - odp.pszGroup = LPGEN("Customize"); - odp.pfnDlgProc = DlgProcOptsAppearance; - Options_AddPage(wParam, &odp); - - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_SKIN); - odp.pszTab = LPGEN("Tooltips"); - odp.pszGroup = LPGEN("Skins"); - odp.pfnDlgProc = DlgProcOptsSkin; - Options_AddPage(wParam, &odp); - - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_CONTENT); - odp.pszTab = LPGEN("Content"); - odp.pszTitle = LPGEN("Tooltips"); - odp.pszGroup = LPGEN("Customize"); - odp.pfnDlgProc = DlgProcOptsContent; - Options_AddPage(wParam, &odp); - - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_TRAYTIP); - odp.pszTab = LPGEN("Tray tooltip"); - odp.pszTitle = LPGEN("Tooltips"); - odp.pszGroup = LPGEN("Customize"); - odp.pfnDlgProc = DlgProcOptsTraytip; - Options_AddPage(wParam, &odp); - - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_EXTRA); - odp.pszTab = LPGEN("Extra"); - odp.pszTitle = LPGEN("Tooltips"); - odp.pszGroup = LPGEN("Customize"); - odp.pfnDlgProc = DlgProcOptsExtra; - Options_AddPage(wParam, &odp); - - return 0; -} - -HANDLE hEventOptInit; - -void InitOptions() -{ - hEventOptInit = HookEvent(ME_OPT_INITIALISE, OptInit); -} - -void DeinitOptions() -{ - UnhookEvent(hEventOptInit); - - DIListNode *di_node = opt.diList; - while(opt.diList) - { - di_node = opt.diList; - opt.diList = opt.diList->next; - mir_free(di_node); - } - - DSListNode *ds_node = opt.dsList; - while(opt.dsList) - { - ds_node = opt.dsList; - opt.dsList = opt.dsList->next; - mir_free(ds_node); - } - - for (int i = 0; i < SKIN_ITEMS_COUNT; i++) - { - if (opt.szImgFile[i]) - mir_free(opt.szImgFile[i]); - } -} diff --git a/plugins/TipperYM/options.h b/plugins/TipperYM/options.h deleted file mode 100644 index 52411110fb..0000000000 --- a/plugins/TipperYM/options.h +++ /dev/null @@ -1,196 +0,0 @@ -/* -Copyright (C) 2006-2007 Scott Ellis -Copyright (C) 2007-2011 Jan Holub - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this file; see the file license.txt. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. -*/ - -#ifndef _OPTIONS_INC -#define _OPTIONS_INC - -#include "translations.h" -#include "popwin.h" -#include "bitmap_func.h" -#include "skin_parser.h" - -#define WMU_ENABLE_LIST_BUTTONS (WM_USER + 0x030) -#define WMU_ENABLE_MODULE_ENTRY (WM_USER + 0x031) - -#define LABEL_LEN 1024 -#define VALUE_LEN 8192 -#define MODULE_NAME_LEN 512 -#define SETTING_NAME_LEN 512 - -// chekcbox icons -#define IDI_NOTICK 205 -#define IDI_TICK 206 -#define IDPRESETITEM 1000 - -#define MS_TOOLTIP_SHOWTIP "mToolTip/ShowTip" - -typedef struct { - UINT id, uintCoreIconId, uintResIconId; - TCHAR *swzTooltip; -} OPTBUTTON; - -typedef struct { - TCHAR swzLabel[LABEL_LEN]; - TCHAR swzValue[VALUE_LEN]; - bool bLineAbove, bValueNewline; - bool bIsVisible; - bool bParseTipperVarsFirst; -} DISPLAYITEM; - -typedef enum {DVT_DB = 0, DVT_PROTODB = 1} DisplaySubstType; -typedef struct { - TCHAR swzName[LABEL_LEN]; - DisplaySubstType type; - char szModuleName[MODULE_NAME_LEN]; - char szSettingName[SETTING_NAME_LEN]; - int iTranslateFuncId; -} DISPLAYSUBST; - -struct DSListNode { - DISPLAYSUBST ds; - DSListNode *next; -}; - -struct DIListNode { - DISPLAYITEM di; - DIListNode *next; -}; - -typedef struct { - BYTE top; - BYTE right; - BYTE bottom; - BYTE left; -} MARGINS; - -// tray tooltip items -static TCHAR* trayTipItems[TRAYTIP_ITEMS_COUNT] = -{ - LPGENT("Number of contacts"), - LPGENT("Protocol lock status"), - LPGENT("Logon time"), - LPGENT("Unread emails"), - LPGENT("Status"), - LPGENT("Status message"), - LPGENT("Extra status"), - LPGENT("Listening to"), - LPGENT("Favourite contacts"), - LPGENT("Miranda uptime"), - LPGENT("Clist event") -}; - -// extra icons -static TCHAR* extraIconName[6] = -{ - LPGENT("Status"), - LPGENT("Extra status"), - LPGENT("Jabber activity"), - LPGENT("Gender"), - LPGENT("Country flag"), - LPGENT("Client") -}; - -typedef struct { - bool bDragging; - HTREEITEM hDragItem; -} EXTRAICONDATA; - -typedef struct { - BYTE order; - BYTE vis; -} ICONSTATE; - -typedef enum {PAV_NONE=0, PAV_LEFT=1, PAV_RIGHT=2} PopupAvLayout; -typedef enum {PTL_LEFTICON=0, PTL_RIGHTICON=1, PTL_NOICON=2, PTL_NOTITLE=3} PopupTitleLayout; -typedef enum {PP_BOTTOMRIGHT=0, PP_BOTTOMLEFT=1, PP_TOPRIGHT=2, PP_TOPLEFT=3} PopupPosition; -typedef enum {PSE_NONE=0, PSE_ANIMATE=1, PSE_FADE=2} PopupShowEffect; - -typedef struct { - int iWinWidth, iWinMaxHeight, iAvatarSize; //tweety - PopupTitleLayout titleLayout; - PopupAvLayout avatarLayout; - int iTextIndent, iTitleIndent, iValueIndent; - bool bShowNoFocus; - DSListNode *dsList; - int iDsCount; - DIListNode *diList; - int iDiCount; - int iTimeIn; - int iPadding, iOuterAvatarPadding, iInnerAvatarPadding, iTextPadding; - PopupPosition pos; - int iMinWidth, iMinHeight; // no UI for these - int iMouseTollerance; - bool bStatusBarTips; - int iSidebarWidth; - COLORREF colBg, colBorder, colAvatarBorder, colDivider, colBar, colTitle, colLabel, colValue, colTrayTitle, colSidebar; - int iLabelValign, iLabelHalign, iValueValign, iValueHalign; - bool bWaitForStatusMsg, bWaitForAvatar; - - // tooltip skin - SkinMode skinMode; - TCHAR szSkinName[256]; - TCHAR szPreviewFile[1024]; - TCHAR *szImgFile[SKIN_ITEMS_COUNT]; - MARGINS margins[SKIN_ITEMS_COUNT]; - TransformationMode transfMode[SKIN_ITEMS_COUNT]; - PopupShowEffect showEffect; - bool bLoadFonts; - bool bLoadProportions; - int iEnableColoring; - int iAnimateSpeed; - int iOpacity; - int iAvatarOpacity; - bool bBorder; - bool bRound, bAvatarRound; - bool bDropShadow; - bool bAeroGlass; - - // tray tooltip - bool bTraytip; - bool bHandleByTipper; - bool bExpandTraytip; - bool bHideOffline; - int iExpandTime; - int iFirstItems, iSecondItems; - int iFavoriteContFlags; - - // extra setting - bool bOriginalAvatarSize; - bool bAvatarBorder; - bool bWaitForContent; - bool bGetNewStatusMsg; - bool bDisableIfInvisible; - bool bRetrieveXstatus; - bool bLimitMsg; - int iLimitCharCount; - int iSmileyAddFlags; - BYTE exIconsOrder[EXICONS_COUNT]; - BYTE exIconsVis[EXICONS_COUNT]; -} OPTIONS; - - -extern OPTIONS opt; - -void InitOptions(); -void LoadOptions(); -void SaveOptions(); -void DeinitOptions(); - -#endif diff --git a/plugins/TipperYM/popwin.cpp b/plugins/TipperYM/popwin.cpp deleted file mode 100644 index 964069ce2d..0000000000 --- a/plugins/TipperYM/popwin.cpp +++ /dev/null @@ -1,2016 +0,0 @@ -/* -Copyright (C) 2006-2007 Scott Ellis -Copyright (C) 2007-2011 Jan Holub - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this file; see the file license.txt. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. -*/ - -#include "common.h" -#include "subst.h" -#include "popwin.h" -#include "message_pump.h" -#include "str_utils.h" -#include "bitmap_func.h" -#include "translations.h" -#include "m_gender.h" - -extern TOOLTIPSKIN skin; - -__inline void AddRow(PopupWindowData *pwd, TCHAR *swzLabel, TCHAR *swzValue, char *szProto, bool bParseSmileys, bool bNewline, bool bLineAbove, bool bIsTitle = false, HICON hIcon = NULL) -{ - pwd->rows = (RowData *)mir_realloc(pwd->rows, sizeof(RowData) * (pwd->iRowCount + 1)); - pwd->rows[pwd->iRowCount].swzLabel = swzLabel ? mir_tstrdup(swzLabel) : NULL; - pwd->rows[pwd->iRowCount].swzValue = swzValue ? mir_tstrdup(swzValue) : NULL; - pwd->rows[pwd->iRowCount].spi = bParseSmileys ? Smileys_PreParse(swzValue, (int)_tcslen(swzValue), szProto) : NULL; - pwd->rows[pwd->iRowCount].bValueNewline = bNewline; - pwd->rows[pwd->iRowCount].bLineAbove = bLineAbove; - pwd->rows[pwd->iRowCount].bIsTitle = bIsTitle; - pwd->rows[pwd->iRowCount].hIcon = hIcon; - pwd->iRowCount++; -} - -LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - PopupWindowData *pwd = (PopupWindowData *)GetWindowLongPtr(hwnd, GWLP_USERDATA); - - switch(uMsg) - { - case WM_CREATE: - { - CREATESTRUCT *cs = (CREATESTRUCT *)lParam; - pwd = (PopupWindowData *)mir_alloc(sizeof(PopupWindowData)); - memset(pwd, 0, sizeof(PopupWindowData)); - pwd->clcit = *(CLCINFOTIPEX *)cs->lpCreateParams; - pwd->iIconIndex = -1; - pwd->hpenBorder = CreatePen(PS_SOLID, 1, opt.bBorder ? opt.colBorder : opt.colBg); - pwd->hpenDivider = CreatePen(PS_SOLID, 1, opt.colDivider); - pwd->iTrans = (int)(opt.iOpacity / 100.0 * 255); - - // load icons order - for (int i = 0; i < EXICONS_COUNT; i++) - pwd->bIsIconVisible[opt.exIconsOrder[i]] = opt.exIconsVis[i] ? true : false; - - SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pwd); - - // work around bug hiding tips - GetCursorPos(&pwd->ptCursorStartPos); - SetTimer(hwnd, ID_TIMER_CHECKMOUSE, CHECKMOUSE_ELAPSE, 0); - - //Register copy menu hotkey (CTRL+C) - pwd->iHotkeyId = GlobalAddAtom(_T("Tipper")); - RegisterHotKey(hwnd, pwd->iHotkeyId, MOD_CONTROL, 0x43); - - if (pwd->clcit.szProto) - { - pwd->bIsTextTip= false; - pwd->iIndent = opt.iTextIndent; - pwd->iSidebarWidth= opt.iSidebarWidth; - - if (ServiceExists(MS_PROTO_GETACCOUNT)) - { - PROTOACCOUNT *pa = ProtoGetAccount(pwd->clcit.szProto); - if (pa) _tcscpy(pwd->swzTitle, pa->tszAccountName); - } - - if (_tcslen(pwd->swzTitle) == 0) - a2t(pwd->clcit.szProto, pwd->swzTitle, TITLE_TEXT_LEN); - - if (CallService(MS_PROTO_ISACCOUNTLOCKED,0,(LPARAM)pwd->clcit.szProto)) - mir_sntprintf(pwd->swzTitle, SIZEOF(pwd->swzTitle), TranslateT("%s (locked)"), pwd->swzTitle); - - // protocol status - WORD wStatus = (WORD)CallProtoService(pwd->clcit.szProto, PS_GETSTATUS, 0, 0); - - // get status icon - if (pwd->bIsIconVisible[0]) - { - pwd->extraIcons[0].hIcon = LoadSkinnedProtoIcon(pwd->clcit.szProto, wStatus); - pwd->extraIcons[0].bDestroy = false; - } - - // get activity icon - if (pwd->bIsIconVisible[2]) - { - pwd->extraIcons[2].hIcon = GetJabberActivityIcon(0, pwd->clcit.szProto); - pwd->extraIcons[2].bDestroy = false; - } - - // uid info - TCHAR swzUid[256], swzUidName[256]; - if (Uid(0, pwd->clcit.szProto, swzUid, 256) && UidName(pwd->clcit.szProto, swzUidName, 253)) - { - _tcscat(swzUidName, _T(": ")); - AddRow(pwd, swzUidName, swzUid, NULL, false, false, false); - } - - // logon info - TCHAR swzLogon[64]; - if (TimestampToTimeDifference(NULL, pwd->clcit.szProto, "LogonTS", swzLogon, 59)) - { - _tcscat(swzLogon, TranslateT(" ago")); - AddRow(pwd, TranslateT("Log on:"), swzLogon, NULL, false, false, false); - } - - // logoff info - TCHAR swzLogoff[64]; - if (TimestampToTimeDifference(NULL, pwd->clcit.szProto, "LogoffTS", swzLogoff, 59)) - { - _tcscat(swzLogoff, TranslateT(" ago")); - AddRow(pwd, TranslateT("Log off:"), swzLogoff, NULL, false, false, false); - } - - // number of unread emails - TCHAR swzEmailCount[64]; - if (ProtoServiceExists(pwd->clcit.szProto, "/GetUnreadEmailCount")) - { - int iCount = (int)CallProtoService(pwd->clcit.szProto, "/GetUnreadEmailCount", 0, 0); - if (iCount > 0) - { - _itot(iCount, swzEmailCount, 10); - AddRow(pwd, TranslateT("Unread emails:"), swzEmailCount, NULL, false, false, false); - } - } - - TCHAR *swzText = (TCHAR *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, wStatus, GSMDF_TCHAR); - if (swzText) - { - AddRow(pwd, TranslateT("Status:"), swzText, NULL, false, false, false); - } - - if (wStatus >= ID_STATUS_ONLINE && wStatus <= ID_STATUS_OUTTOLUNCH) - { - // status message - TCHAR *swzText = GetProtoStatusMessage(pwd->clcit.szProto, wStatus); - if (swzText) - { - StripBBCodesInPlace(swzText); - AddRow(pwd, TranslateT("Status message:"), swzText, pwd->clcit.szProto, true, true, true); - mir_free(swzText); - } - - // jabber mood or icq xstatus - TCHAR *swzAdvTitle = GetJabberAdvStatusText(pwd->clcit.szProto, "mood", "title"); - if (swzAdvTitle) - { - StripBBCodesInPlace(swzAdvTitle); - AddRow(pwd, TranslateT("Mood:"), swzAdvTitle, pwd->clcit.szProto, true, false, true); - - TCHAR *swzAdvText = GetJabberAdvStatusText(pwd->clcit.szProto, "mood", "text"); - if (swzAdvText) - { - StripBBCodesInPlace(swzAdvText); - AddRow(pwd, _T(""), swzAdvText, pwd->clcit.szProto, true, true, false); - mir_free(swzAdvText); - } - } - else - { - if (DBGetContactSettingByte(0, pwd->clcit.szProto, "XStatusId", 0)) - { - // xstatus title - swzAdvTitle = GetProtoExtraStatusTitle(pwd->clcit.szProto); - if (swzAdvTitle) - { - StripBBCodesInPlace(swzAdvTitle); - AddRow(pwd, TranslateT("XStatus:"), swzAdvTitle, pwd->clcit.szProto, true, false, true); - } - - // xstatus message - TCHAR *swzAdvText = GetProtoExtraStatusMessage(pwd->clcit.szProto); - if (swzAdvText) - { - StripBBCodesInPlace(swzAdvText); - AddRow(pwd, _T(""), swzAdvText, pwd->clcit.szProto, true, true, false); - mir_free(swzAdvText); - } - } - } - - if (swzAdvTitle) - { - mir_free(swzAdvTitle); - // get advanced status icon - if (pwd->bIsIconVisible[1]) - { - pwd->extraIcons[1].hIcon = (HICON)CallProtoService(pwd->clcit.szProto, PS_ICQ_GETCUSTOMSTATUSICON, 0, 0); - pwd->extraIcons[1].bDestroy = true; - } - } - - // jabber activity - TCHAR *swzActTitle = GetJabberAdvStatusText(pwd->clcit.szProto, "activity", "title"); - if (swzActTitle) - { - StripBBCodesInPlace(swzActTitle); - AddRow(pwd, TranslateT("Activity:"), swzActTitle, pwd->clcit.szProto, true, false, true); - mir_free(swzActTitle); - } - - TCHAR *swzActText = GetJabberAdvStatusText(pwd->clcit.szProto, "activity", "text"); - if (swzActText) - { - StripBBCodesInPlace(swzActText); - AddRow(pwd, _T(""), swzActText, pwd->clcit.szProto, true, true, false); - mir_free(swzActText); - } - - // listening to - TCHAR *swzListening = GetListeningTo(pwd->clcit.szProto); - if (swzListening) - { - StripBBCodesInPlace(swzListening); - AddRow(pwd, TranslateT("Listening to:"), swzListening, NULL, false, true, true); - mir_free(swzListening); - } - } - } - else if (pwd->clcit.swzText) - { - pwd->bIsTextTip = true; - pwd->iIndent = 0; - pwd->iSidebarWidth= 0; - - RECT rc = pwd->clcit.rcItem; - bool mirandaTrayTip = ((rc.right - rc.left) == 20) && ((rc.bottom - rc.top) == 20) ? true : false; - - if (mirandaTrayTip && !opt.bTraytip) - { - MyDestroyWindow(hwnd); - return 0; - } - - if (mirandaTrayTip && opt.bHandleByTipper) // extended tray tooltip - { - pwd->bIsTrayTip = true; - pwd->iIndent = opt.iTextIndent; - pwd->iSidebarWidth= opt.iSidebarWidth; - - SendMessage(hwnd, PUM_REFRESHTRAYTIP, 0, 0); - - if (opt.bExpandTraytip) - SetTimer(hwnd, ID_TIMER_TRAYTIP, opt.iExpandTime, 0); - } - else - { - - TCHAR buff[2048], *swzText = pwd->clcit.swzText; - size_t iBuffPos, i = 0, iSize = _tcslen(pwd->clcit.swzText); - bool bTopMessage = false; - - while (i < iSize && swzText[i] != _T('<')) - { - iBuffPos = 0; - while (swzText[i] != _T('\n') && swzText[i] != _T('\r') && i < iSize && iBuffPos < 2048) - { - if (swzText[i] != _T('\t')) - buff[iBuffPos++] = swzText[i]; - i++; - } - - buff[iBuffPos] = 0; - - if (iBuffPos) - { - AddRow(pwd, _T(""), buff, NULL, false, true, false); - bTopMessage = true; - } - - while (i < iSize && (swzText[i] == _T('\n') || swzText[i] == _T('\r'))) - i++; - } - - // parse bold bits into labels and the rest into items - while (i < iSize) - { - while (i + 2 < iSize - && (swzText[i] != _T('<') - || swzText[i + 1] != _T('b') - || swzText[i + 2] != _T('>'))) - { - i++; - } - - i += 3; - - iBuffPos = 0; - while (i + 3 < iSize - && iBuffPos < 2048 - && (swzText[i] != _T('<') - || swzText[i + 1] != _T('/') - || swzText[i + 2] != _T('b') - || swzText[i + 3] != _T('>'))) - { - if (swzText[i] != _T('\t')) - buff[iBuffPos++] = swzText[i]; - i++; - } - - i += 4; - - buff[iBuffPos] = 0; - - if (iBuffPos) - { - pwd->rows = (RowData *)mir_realloc(pwd->rows, sizeof(RowData) * (pwd->iRowCount + 1)); - pwd->rows[pwd->iRowCount].bValueNewline = false; - pwd->rows[pwd->iRowCount].swzLabel = mir_tstrdup(buff); - if (pwd->iRowCount == 1 && bTopMessage) - pwd->rows[pwd->iRowCount].bLineAbove = true; - else - pwd->rows[pwd->iRowCount].bLineAbove = false; - - iBuffPos = 0; - while (i < iSize - && iBuffPos < 2048 - && swzText[i] != _T('\n')) - { - if (swzText[i] != _T('\t') && swzText[i] != _T('\r')) - buff[iBuffPos++] = swzText[i]; - i++; - } - buff[iBuffPos] = 0; - - pwd->rows[pwd->iRowCount].swzValue = mir_tstrdup(buff); - pwd->rows[pwd->iRowCount].spi = NULL; - pwd->iRowCount++; - } - - i++; - } - - if (pwd->iRowCount == 0) - { - // single item - pwd->iRowCount = 1; - pwd->rows = (RowData *)mir_alloc(sizeof(RowData)); - pwd->rows[0].bLineAbove = pwd->rows[0].bValueNewline = false; - pwd->rows[0].swzLabel = 0; - pwd->rows[0].swzValue = swzText; - pwd->rows[0].spi = NULL; - } - } - } - else - { - pwd->bIsTextTip = false; - pwd->iIndent = opt.iTextIndent; - pwd->iSidebarWidth= opt.iSidebarWidth; - pwd->hContact = pwd->clcit.hItem; - pwd->iIconIndex = (int)CallService(MS_CLIST_GETCONTACTICON, (WPARAM)pwd->hContact, 0); - - // don't use stored status message - if (!opt.bWaitForContent) - DBDeleteContactSetting(pwd->hContact, MODULE, "TempStatusMsg"); - - TCHAR *swzNick = (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)pwd->hContact, GCDNF_TCHAR); - _tcsncpy(pwd->swzTitle, swzNick, TITLE_TEXT_LEN); - - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)pwd->hContact, 0); - pwd->spiTitle = Smileys_PreParse(pwd->swzTitle, -1, szProto); - - // get extra icons - DBVARIANT dbv = {0}; - int i = 0; - - if (szProto) - { - // status icon - if (pwd->bIsIconVisible[0]) - { - for (i = 0; opt.exIconsOrder[i] != 0; i++); - pwd->extraIcons[i].hIcon = ImageList_GetIcon((HIMAGELIST)CallService(MS_CLIST_GETICONSIMAGELIST, 0, 0), pwd->iIconIndex, 0); - pwd->extraIcons[i].bDestroy = true; - } - - // xstatus icon - if (pwd->bIsIconVisible[1]) - { - for (i = 0; opt.exIconsOrder[i] != 1; i++); - int iXstatus = DBGetContactSettingByte(pwd->hContact, szProto, "XStatusId", 0); - if (iXstatus) - { - char szIconProto[64]; - if (strcmp(szProto, szMetaModuleName) != 0) - { - strcpy(szIconProto, szProto); - } - else if (!DBGetContactSettingString(pwd->hContact, szProto, "XStatusProto", &dbv)) - { - strcpy(szIconProto, dbv.pszVal); - DBFreeVariant(&dbv); - } - - pwd->extraIcons[i].hIcon = (HICON)CallProtoService(szIconProto, PS_ICQ_GETCUSTOMSTATUSICON, (WPARAM)iXstatus, LR_SHARED); - pwd->extraIcons[i].bDestroy = false; - } - } - - // activity icon - if (pwd->bIsIconVisible[2]) - { - for (i = 0; opt.exIconsOrder[i] != 2; i++); - pwd->extraIcons[i].hIcon = GetJabberActivityIcon(pwd->hContact, szProto); - pwd->extraIcons[i].bDestroy = false; - } - - // gender icon - if (pwd->bIsIconVisible[3]) - { - for (i = 0; opt.exIconsOrder[i] != 3; i++); - if (ServiceExists(MS_GENDER_GETICON)) - { - pwd->extraIcons[i].hIcon = (HICON)CallService(MS_GENDER_GETICON, (WPARAM)pwd->hContact, 0); - } - else - { - int iGender = DBGetContactSettingByte(pwd->hContact, "UserInfo", "Gender", 0); - if (iGender == 0) - iGender = DBGetContactSettingByte(pwd->hContact, szProto, "Gender", 0); - - if (iGender == GEN_FEMALE) - pwd->extraIcons[i].hIcon = (HICON)CallService(MS_SKIN2_GETICON, NULL, (LPARAM)"UserInfoEx_common_female"); - else if (iGender == GEN_MALE) - pwd->extraIcons[i].hIcon = (HICON)CallService(MS_SKIN2_GETICON, NULL, (LPARAM)"UserInfoEx_common_male"); - } - pwd->extraIcons[i].bDestroy = false; - } - - // flags icon - if (pwd->bIsIconVisible[4]) - { - for (i = 0; opt.exIconsOrder[i] != 4; i++); - - int iCountry = 0; - if (ServiceExists(MS_FLAGS_DETECTCONTACTORIGINCOUNTRY)) - iCountry = CallService(MS_FLAGS_DETECTCONTACTORIGINCOUNTRY, (WPARAM)pwd->hContact, 0); - else if (ServiceExists(MS_FLAGS_GETCONTACTORIGINCOUNTRY)) - iCountry = CallService(MS_FLAGS_GETCONTACTORIGINCOUNTRY, (WPARAM)pwd->hContact, 0); - - if (iCountry != 0 && iCountry != CTRY_UNKNOWN && iCountry != CTRY_ERROR) - { - pwd->extraIcons[i].hIcon = LoadFlagIcon(iCountry); - pwd->extraIcons[i].bDestroy = false; - } - } - - // fingerprint icon - if (pwd->bIsIconVisible[5]) - { - - if (ServiceExists(MS_FP_GETCLIENTICONT)) - { - for (i = 0; opt.exIconsOrder[i] != 5; i++); - if (!DBGetContactSettingTString(pwd->hContact, szProto, "MirVer", &dbv)) - { - pwd->extraIcons[i].hIcon = (HICON)CallService(MS_FP_GETCLIENTICONT, (WPARAM)dbv.ptszVal, 0); - pwd->extraIcons[i].bDestroy = true; - DBFreeVariant(&dbv); - } - } - else - - if (ServiceExists(MS_FP_GETCLIENTICON)) - { - for (i = 0; opt.exIconsOrder[i] != 5; i++); - if (!DBGetContactSettingString(pwd->hContact, szProto, "MirVer", &dbv)) - { - pwd->extraIcons[i].hIcon = (HICON)CallService(MS_FP_GETCLIENTICON, (WPARAM)dbv.pszVal, 0); - pwd->extraIcons[i].bDestroy = true; - DBFreeVariant(&dbv); - } - } - } - - //request xstatus details - if (opt.bRetrieveXstatus) - { - if (!DBGetContactSettingByte(0, szProto, "XStatusAuto", 1) && ProtoServiceExists(szProto, PS_ICQ_REQUESTCUSTOMSTATUS)) - CallProtoService(szProto, PS_ICQ_REQUESTCUSTOMSTATUS, (WPARAM)pwd->hContact, 0); - } - } - - SendMessage(hwnd, PUM_REFRESH_VALUES, FALSE, 0); - } - - SendMessage(hwnd, PUM_GETHEIGHT, 0, 0); - SendMessage(hwnd, PUM_CALCPOS, 0, 0); - - // transparency - SetWindowLongPtr(hwnd, GWL_EXSTYLE, GetWindowLongPtr(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED); - - if (opt.bDropShadow && opt.skinMode == SM_COLORFILL) - SetClassLongPtr(hwnd, GCL_STYLE, CS_DROPSHADOW); - else - SetClassLongPtr(hwnd, GCL_STYLE, 0); - - if (!skin.bNeedLayerUpdate && MySetLayeredWindowAttributes) - MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), 0, LWA_ALPHA); - - if (opt.showEffect) - SetTimer(hwnd, ID_TIMER_ANIMATE, ANIM_ELAPSE, 0); - - ShowWindow(hwnd, SW_SHOWNOACTIVATE); - InvalidateRect(hwnd, 0, FALSE); - - // since tipper win is topmost, this should put it at top of topmost windows - SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); - return 0; - } - case WM_ERASEBKGND: - { - if (!skin.bNeedLayerUpdate) - { - HDC hdc = (HDC)wParam; - RECT rc; - GetClientRect(hwnd, &rc); - - BitBlt(hdc, 0, 0, skin.iWidth, skin.iHeight, skin.hdc, 0, 0, SRCCOPY); - - // border - if (opt.bBorder) - { - HBRUSH hOldBrush = (HBRUSH)SelectObject(hdc, GetStockObject(NULL_BRUSH)); - HPEN hOldPen = (HPEN)SelectObject(hdc, pwd->hpenBorder); - - int h = 0; - if (opt.bRound) - { - int v; - int w = 14; - h = (rc.right-rc.left) > (w*2) ? w : (rc.right-rc.left); - v = (rc.bottom-rc.top) > (w*2) ? w : (rc.bottom-rc.top); - h = (h < v) ? h : v; - } - - RoundRect(hdc, 0, 0, (rc.right - rc.left), (rc.bottom - rc.top), h, h); - - SelectObject(hdc, hOldBrush); - SelectObject(hdc, hOldPen); - } - } - return TRUE; - } - case WM_PAINT: - { - RECT r, r2; - PAINTSTRUCT ps; - BeginPaint(hwnd, &ps); - HDC hdc = skin.bNeedLayerUpdate ? skin.hdc : ps.hdc; - - GetClientRect(hwnd, &r); - r2 = r; - HFONT hOldFont = (HFONT)GetCurrentObject(hdc,OBJ_FONT); - - // text background - SetBkMode(hdc, TRANSPARENT); - - BLENDFUNCTION blend; - blend.BlendOp = AC_SRC_OVER; - blend.BlendFlags = 0; - blend.SourceConstantAlpha = 255; - blend.AlphaFormat = AC_SRC_ALPHA; - - // avatar - if (!pwd->bIsTextTip&& opt.avatarLayout != PAV_NONE && pwd->iAvatarHeight) - { - RECT rcAvatar; - rcAvatar.top = opt.iOuterAvatarPadding; - - if (opt.avatarLayout == PAV_LEFT) - { - rcAvatar.left = r.left + opt.iOuterAvatarPadding; - rcAvatar.right = rcAvatar.left + pwd->iRealAvatarWidth; - r2.left += pwd->iRealAvatarWidth + (opt.iOuterAvatarPadding + opt.iInnerAvatarPadding - opt.iPadding); // padding re-added for text - } - else if (opt.avatarLayout == PAV_RIGHT) - { - rcAvatar.right = r.right - opt.iOuterAvatarPadding; - rcAvatar.left = rcAvatar.right - pwd->iRealAvatarWidth; - r2.right -= pwd->iRealAvatarWidth + (opt.iOuterAvatarPadding + opt.iInnerAvatarPadding - opt.iPadding); - } - - rcAvatar.bottom = rcAvatar.top + pwd->iRealAvatarHeight; - - AVATARCACHEENTRY *ace = 0; - if (pwd->hContact) - ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)pwd->hContact, 0); - else - ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETMYAVATAR, 0, (LPARAM)pwd->clcit.szProto); - - if (ace && ace->hbmPic && (ace->dwFlags & AVS_BITMAP_VALID) && !(ace->dwFlags & AVS_HIDEONCLIST)) - { - ResizeBitmap rb = {0}; - rb.size = sizeof(rb); - rb.max_width = pwd->iRealAvatarWidth; - rb.max_height = pwd->iRealAvatarHeight; - rb.fit = RESIZEBITMAP_STRETCH | RESIZEBITMAP_KEEP_PROPORTIONS; - rb.hBmp = ace->hbmPic; - HBITMAP hbmpAvatar = (HBITMAP)CallService(MS_IMG_RESIZE, (WPARAM)&rb, 0); - - if (hbmpAvatar) - { - HRGN hrgnAvatar = 0; - if (opt.bAvatarRound) - { - hrgnAvatar = CreateRoundRectRgn(rcAvatar.left, rcAvatar.top, rcAvatar.right + 1, rcAvatar.bottom + 1, 9, 9); - SelectClipRgn(hdc, hrgnAvatar); - } - - BITMAP bm; - GetObject(hbmpAvatar, sizeof(bm), &bm); - HDC hdcMem = CreateCompatibleDC(hdc); - SelectObject(hdcMem, hbmpAvatar); - - blend.SourceConstantAlpha = (BYTE)(opt.iAvatarOpacity / 100.0 * 255); - AlphaBlend(hdc, rcAvatar.left, rcAvatar.top, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, bm.bmWidth, bm.bmHeight, blend); - blend.SourceConstantAlpha = 255; - - if (opt.bAvatarBorder) - { - SaveAlpha(&rcAvatar); - HBRUSH hbrBorder = CreateSolidBrush(opt.colAvatarBorder); - if (opt.bAvatarRound) - FrameRgn(hdc, hrgnAvatar, hbrBorder, 1, 1); - else - FrameRect(hdc, &rcAvatar, hbrBorder); - - DeleteObject(hbrBorder); - RestoreAlpha(&rcAvatar, (BYTE)(opt.iAvatarOpacity / 100.0 * 255)); - } - - if (hrgnAvatar) - { - SelectClipRgn(hdc, 0); - DeleteObject(hrgnAvatar); - } - - if (hbmpAvatar != ace->hbmPic) - DeleteObject(hbmpAvatar); - - DeleteDC(hdcMem); - } - } - } - - RECT tr; - tr.left = r2.left + opt.iPadding + opt.iTitleIndent; - tr.right = r2.right - opt.iPadding; - tr.top = 0; - tr.bottom = opt.iPadding; - - if (!pwd->bIsTextTip&& opt.titleLayout != PTL_NOTITLE) - { - if (opt.titleLayout != PTL_NOICON) - { - // draw icons - int iIconX, iIconY; - iIconY = opt.iPadding + opt.iTextPadding; - - if (opt.titleLayout == PTL_RIGHTICON) - iIconX = r2.right - 16 - opt.iPadding; - else - iIconX = r2.left + opt.iPadding; - - for (int i = 0; i < EXICONS_COUNT; i++) - { - if (pwd->extraIcons[i].hIcon) - { - DrawIconExAlpha(hdc, iIconX, iIconY, pwd->extraIcons[i].hIcon, 16, 16, 0, NULL, DI_NORMAL, false); - iIconY += 20; - } - } - } - - // title text - if (hFontTitle) SelectObject(hdc, (HGDIOBJ)hFontTitle); - SetTextColor(hdc, opt.colTitle); - tr.top = opt.iPadding; - tr.bottom = tr.top + pwd->iTitleHeight - opt.iPadding; - UINT uTextFormat = DT_TOP | DT_LEFT | DT_WORDBREAK | DT_WORD_ELLIPSIS | DT_END_ELLIPSIS | DT_NOPREFIX; - DrawTextExt(hdc, pwd->swzTitle, -1, &tr, uTextFormat, NULL, pwd->spiTitle); - } - - // values - pwd->iTextHeight = 0; - bool bIconPainted, bUseRect = true; - int iRowHeight; - for (int i = 0; i < pwd->iRowCount; i++) - { - tr.top = tr.bottom; - bUseRect = (tr.top + opt.iTextPadding >= pwd->iAvatarHeight); - bIconPainted = false; - if (bUseRect) - { - if (pwd->rows[i].bLineAbove) - { - HPEN hOldPen = (HPEN)SelectObject(hdc, pwd->hpenDivider); - tr.top += opt.iTextPadding; - RECT rec; - SetRect(&rec, r.left + opt.iPadding + pwd->iIndent, tr.top, r.right - opt.iPadding, tr.top + 1); - SaveAlpha(&rec); - Rectangle(hdc, rec.left, rec.top, rec.right, rec.bottom ); - RestoreAlpha(&rec); - SelectObject(hdc, hOldPen); - } - - tr.left = r.left + opt.iPadding + pwd->iIndent; - if (pwd->rows[i].bValueNewline) - tr.right = r.right - opt.iPadding; - else - tr.right = r.left + opt.iPadding + pwd->iIndent + pwd->iLabelWidth; - } - else - { - if (pwd->rows[i].bLineAbove) - { - HPEN hOldPen = (HPEN)SelectObject(hdc, pwd->hpenDivider); - tr.top += opt.iTextPadding; - RECT rec; - SetRect(&rec, r2.left + opt.iPadding + pwd->iIndent, tr.top, r2.right - opt.iPadding, tr.top + 1); - SaveAlpha(&rec); - Rectangle(hdc, rec.left, rec.top, rec.right, rec.bottom ); - RestoreAlpha(&rec); - SelectObject(hdc, hOldPen); - } - - tr.left = r2.left + opt.iPadding + pwd->iIndent; - if (pwd->rows[i].bValueNewline) - tr.right = r2.right - opt.iPadding; - else - tr.right = r2.left + opt.iPadding + pwd->iIndent + pwd->iLabelWidth; - } - - if (pwd->rows[i].bValueNewline) - iRowHeight = pwd->rows[i].iLabelHeight; - else - iRowHeight = max(pwd->rows[i].iLabelHeight, pwd->rows[i].iValueHeight); - - if (pwd->rows[i].iLabelHeight) - { - tr.top += opt.iTextPadding; - tr.bottom = tr.top + iRowHeight; - - if (pwd->bIsTrayTip && pwd->rows[i].bIsTitle) - { - if (hFontTrayTitle) SelectObject(hdc, (HGDIOBJ)hFontTrayTitle); - SetTextColor(hdc, opt.colTrayTitle); - } - else - { - if (hFontLabels) SelectObject(hdc, (HGDIOBJ)hFontLabels); - SetTextColor(hdc, opt.colLabel); - } - - // status icon in tray tooltip - if (opt.titleLayout != PTL_NOICON && pwd->bIsTrayTip && pwd->rows[i].hIcon) - { - DrawIconExAlpha(hdc, opt.iPadding, tr.top + (pwd->rows[i].iLabelHeight - 16) / 2, pwd->rows[i].hIcon, 16, 16, 0, NULL, DI_NORMAL, false); - bIconPainted = true; - } - - DrawTextAlpha(hdc, pwd->rows[i].swzLabel, -1, &tr, opt.iLabelValign | ((opt.iLabelHalign == DT_RIGHT && !pwd->rows[i].bValueNewline) ? DT_RIGHT : DT_LEFT) | DT_END_ELLIPSIS | DT_SINGLELINE | DT_NOPREFIX); - if (pwd->rows[i].bValueNewline) - tr.top = tr.bottom; - } - else - { - tr.bottom = tr.top; - } - - if (pwd->rows[i].bValueNewline) - iRowHeight = pwd->rows[i].iValueHeight; - - if (hFontValues) SelectObject(hdc, (HGDIOBJ)hFontValues); - SetTextColor(hdc, opt.colValue); - if (bUseRect) - { - tr.left = r.left + opt.iPadding + pwd->iIndent; - if (!pwd->rows[i].bValueNewline) - tr.left += pwd->iLabelWidth + opt.iValueIndent; - - tr.right = r.right - opt.iPadding; - } - else - { - tr.left = r2.left + opt.iPadding + pwd->iIndent; - if (!pwd->rows[i].bValueNewline) - tr.left += pwd->iLabelWidth + opt.iValueIndent; - - tr.right = r2.right - opt.iPadding; - } - - if (pwd->rows[i].iValueHeight) - { - if (pwd->rows[i].bValueNewline || !pwd->rows[i].iLabelHeight) tr.top += opt.iTextPadding; - if (pwd->rows[i].iLabelHeight > pwd->rows[i].iValueHeight && pwd->bIsTextTip&& pwd->rows[i].bIsTitle) - tr.top = tr.bottom - pwd->rows[i].iValueHeight - 2; - else - tr.bottom = tr.top + iRowHeight; - - if (opt.titleLayout != PTL_NOICON && pwd->bIsTrayTip && pwd->rows[i].hIcon && !bIconPainted) - DrawIconExAlpha(hdc, opt.iPadding, tr.top + (pwd->rows[i].iValueHeight - 16) / 2, pwd->rows[i].hIcon, 16, 16, 0, NULL, DI_NORMAL, false); - - UINT uFormat = opt.iValueValign | opt.iValueHalign | DT_WORDBREAK | DT_WORD_ELLIPSIS | DT_END_ELLIPSIS | DT_NOPREFIX; - DrawTextExt(hdc, pwd->rows[i].swzValue, -1, &tr, uFormat, NULL, pwd->rows[i].spi); - } - } - - PremultipleChannels(); - - if (opt.showEffect == PSE_NONE) - { - if (skin.bNeedLayerUpdate) - { - POINT ptSrc = {0, 0}; - SIZE szTip = {r.right - r.left, r.bottom - r.top}; - blend.SourceConstantAlpha = pwd->iTrans; - MyUpdateLayeredWindow(hwnd, NULL, NULL, &szTip, skin.hdc, &ptSrc, 0xffffffff, &blend, LWA_ALPHA); - - if (opt.bAeroGlass && MyDwmEnableBlurBehindWindow) - { - DWM_BLURBEHIND bb = {0}; - bb.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION; - bb.fEnable = TRUE; - bb.hRgnBlur = CreateOpaqueRgn(25, true); - MyDwmEnableBlurBehindWindow(hwnd, &bb); - } - } - else if (MySetLayeredWindowAttributes) - { - MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), pwd->iTrans, LWA_ALPHA); - } - } - - SelectObject(hdc, hOldFont); - EndPaint(hwnd, &ps); - pwd->bIsPainted = true; - return 0; - } - case WM_HOTKEY: - { - if (LOWORD(lParam) == MOD_CONTROL && HIWORD(lParam) == 0x43) // CTRL+C - { - ICONINFO iconInfo; - - if (pwd->iRowCount == 0) - return 0; - - ShowWindow(hwnd, SW_HIDE); - HMENU hMenu = CreatePopupMenu(); - if (!hMenu) return 0; - - HICON hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_ITEM_ALL), IMAGE_ICON, 0, 0, LR_LOADTRANSPARENT); - if (!hIcon) - { - DestroyMenu(hMenu); - return 0; - } - - GetIconInfo(hIcon, &iconInfo); - HBITMAP hbmpAllItems = iconInfo.hbmColor; - DestroyIcon(hIcon); - - AppendMenu(hMenu, MF_STRING, COPYMENU_ALLITEMS_LABELS, LPGENT("Copy all items with labels")); - AppendMenu(hMenu, MF_STRING, COPYMENU_ALLITEMS, LPGENT("Copy all items")); - if (pwd->clcit.szProto || pwd->hContact) - AppendMenu(hMenu, MF_STRING, COPYMENU_AVATAR, LPGENT("Copy avatar")); - AppendMenu(hMenu, MF_SEPARATOR, 2000, 0); - TranslateMenu(hMenu); - - SetMenuItemBitmaps(hMenu, COPYMENU_ALLITEMS_LABELS, MF_BYCOMMAND, hbmpAllItems, hbmpAllItems); - SetMenuItemBitmaps(hMenu, COPYMENU_ALLITEMS, MF_BYCOMMAND, hbmpAllItems, hbmpAllItems); - SetMenuItemBitmaps(hMenu, COPYMENU_AVATAR, MF_BYCOMMAND, hbmpAllItems, hbmpAllItems); - - hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_ITEM), IMAGE_ICON, 0, 0, LR_LOADTRANSPARENT); - if (!hIcon) - { - DeleteObject(hbmpAllItems); - DestroyMenu(hMenu); - return 0; - } - - GetIconInfo(hIcon, &iconInfo); - HBITMAP hbmpItem = iconInfo.hbmColor; - DestroyIcon(hIcon); - - for (int i = 0; i < pwd->iRowCount; i++) - { - if (pwd->rows[i].swzValue) - { - TCHAR buff[128]; - int iLen = (int)_tcslen(pwd->rows[i].swzValue); - if (iLen) - { - if (iLen > MAX_VALUE_LEN) - { - _tcsncpy(buff, pwd->rows[i].swzValue, MAX_VALUE_LEN); - buff[MAX_VALUE_LEN] = 0; - _tcscat(buff, _T("...")); - } - else - { - _tcscpy(buff, pwd->rows[i].swzValue); - } - - AppendMenu(hMenu, MF_STRING, i + 1, buff); // first id = 1, because no select have id = 0 - SetMenuItemBitmaps(hMenu, i + 1, MF_BYCOMMAND, hbmpItem, hbmpItem); - } - else - { - AppendMenu(hMenu, MF_SEPARATOR, 0, 0); - } - } - } - - POINT pt; - GetCursorPos(&pt); - SetForegroundWindow(hwnd); - int iSelItem = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, 0); - DeleteObject(hbmpAllItems); - DeleteObject(hbmpItem); - DestroyMenu(hMenu); - - if (iSelItem == 0) - return 0; // no item was selected - - if (OpenClipboard(NULL)) - { - EmptyClipboard(); - if (iSelItem == COPYMENU_AVATAR) // copy avatar - { - AVATARCACHEENTRY *ace = 0; - if (pwd->hContact) ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)pwd->hContact, 0); - else ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETMYAVATAR, 0, (LPARAM)pwd->clcit.szProto); - if (ace && ace->hbmPic && (ace->dwFlags & AVS_BITMAP_VALID) && !(ace->dwFlags & AVS_HIDEONCLIST)) - { - HDC hdc = GetDC(hwnd); - HDC hdcSrc = CreateCompatibleDC(hdc); - HDC hdcDes = CreateCompatibleDC(hdc); - HBITMAP hbmAvr = CreateCompatibleBitmap(hdc, ace->bmWidth, ace->bmHeight); - SelectObject(hdcSrc, ace->hbmPic); - SelectObject(hdcDes, hbmAvr); - BitBlt(hdcDes, 0, 0, ace->bmWidth, ace->bmHeight, hdcSrc, 0, 0, SRCCOPY); - SetClipboardData(CF_BITMAP, hbmAvr); - ReleaseDC(hwnd, hdc); - DeleteDC(hdcSrc); - DeleteDC(hdcDes); - } - } - else // copy text - { - HGLOBAL hClipboardData = GlobalAlloc(GMEM_DDESHARE, 4096); - TCHAR *pchData = (TCHAR *)GlobalLock(hClipboardData); - pchData[0] = 0; - if (iSelItem == COPYMENU_ALLITEMS_LABELS) // copy all items with labels - { - for (int i = 0; i < pwd->iRowCount; i++) - { - if ((pwd->rows[i].swzLabel && pwd->rows[i].swzLabel[0]) || - (pwd->rows[i].swzValue && pwd->rows[i].swzValue[0])) - { - if (pwd->rows[i].swzLabel && pwd->rows[i].swzLabel[0]) - { - _tcscat(pchData, pwd->rows[i].swzLabel); - _tcscat(pchData, _T(" ")); - } - else - { - _tcscat(pchData, TranslateT(": ")); - } - - if (pwd->rows[i].swzValue && pwd->rows[i].swzValue[0]) - _tcscat(pchData, pwd->rows[i].swzValue); - else - _tcscat(pchData, TranslateT("")); - - _tcscat(pchData, _T("\r\n")); - } - } - } - else if (iSelItem == COPYMENU_ALLITEMS) // copy all items - { - for (int i = 0; i < pwd->iRowCount; i++) - { - if (pwd->rows[i].swzValue && pwd->rows[i].swzValue[0]) - { - _tcscat(pchData, pwd->rows[i].swzValue); - _tcscat(pchData, _T("\r\n")); - } - } - } - else // single row - { - _tcscpy(pchData, pwd->rows[iSelItem - 1].swzValue); - } - - GlobalUnlock(hClipboardData); - - SetClipboardData(CF_UNICODETEXT, hClipboardData); - - } - - CloseClipboard(); - } - } - break; - } - case PUM_FADEOUTWINDOW: - { - // kill timers - KillTimer(hwnd, ID_TIMER_ANIMATE); - KillTimer(hwnd, ID_TIMER_CHECKMOUSE); - KillTimer(hwnd, ID_TIMER_TRAYTIP); - - if (opt.showEffect != PSE_NONE) - { - if (skin.bNeedLayerUpdate) - { - POINT ptSrc = {0, 0}; - SIZE sz = {pwd->rcWindow.right - pwd->rcWindow.left, pwd->rcWindow.bottom - pwd->rcWindow.top}; - - BLENDFUNCTION blend; - blend.BlendOp = AC_SRC_OVER; - blend.BlendFlags = 0; - blend.SourceConstantAlpha = pwd->iTrans; - blend.AlphaFormat = AC_SRC_ALPHA; - - while (blend.SourceConstantAlpha != 0) - { - MyUpdateLayeredWindow(hwnd, NULL, NULL, &sz, skin.hdc, &ptSrc, 0xffffffff, &blend, LWA_ALPHA); - blend.SourceConstantAlpha = max(blend.SourceConstantAlpha - opt.iAnimateSpeed, 0); - Sleep(ANIM_ELAPSE); - } - } - else if (MySetLayeredWindowAttributes) - { - int iTrans = pwd->iTrans; - while (iTrans != 0) - { - MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), iTrans, LWA_ALPHA); - iTrans = max(iTrans - opt.iAnimateSpeed, 0); - Sleep(ANIM_ELAPSE); - } - } - } - break; - } - case WM_DESTROY: - { - ShowWindow(hwnd, SW_HIDE); - - // unregister hotkey - UnregisterHotKey(hwnd, pwd->iHotkeyId); - - DeleteObject(pwd->hpenBorder); - DeleteObject(pwd->hpenDivider); - - if (pwd->hrgnAeroGlass) - DeleteObject(pwd->hrgnAeroGlass); - - Smileys_FreeParse(pwd->spiTitle); - - int i; - for (i = 0; i < pwd->iRowCount; i++) - { - mir_free(pwd->rows[i].swzLabel); - mir_free(pwd->rows[i].swzValue); - Smileys_FreeParse(pwd->rows[i].spi); - } - - if (pwd->rows) - mir_free(pwd->rows); - pwd->rows = NULL; - - // destroy icons - for (i = 0; i < EXICONS_COUNT; i++) - { - if (pwd->extraIcons[i].bDestroy) - DestroyIcon(pwd->extraIcons[i].hIcon); - } - - if (pwd->clcit.swzText) - { - mir_free(pwd->clcit.swzText); - pwd->clcit.swzText = NULL; - } - - mir_free(pwd); - pwd = NULL; - - if (skin.colSavedBits) mir_free(skin.colSavedBits); - if (skin.hBitmap)DeleteObject(skin.hBitmap); - if (skin.hdc) DeleteDC(skin.hdc); - skin.colSavedBits = NULL; - skin.hBitmap = NULL; - skin.hdc = NULL; - - SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); - break; - } - case WM_TIMER: - { - if (wParam == ID_TIMER_ANIMATE) - { - pwd->iAnimStep++; - if (pwd->iAnimStep == ANIM_STEPS) - KillTimer(hwnd, ID_TIMER_ANIMATE); - - SendMessage(hwnd, PUM_UPDATERGN, 1, 0); - } - else if (wParam == ID_TIMER_CHECKMOUSE) - { - // workaround for tips that just won't go away - POINT pt; - GetCursorPos(&pt); - - if (abs(pt.x - pwd->ptCursorStartPos.x) > opt.iMouseTollerance - || abs(pt.y - pwd->ptCursorStartPos.y) > opt.iMouseTollerance) // mouse has moved beyond tollerance - { - PostMPMessage(MUM_DELETEPOPUP, 0, 0); - } - } - else if (wParam == ID_TIMER_TRAYTIP) - { - KillTimer(hwnd, ID_TIMER_TRAYTIP); - SendMessage(hwnd, PUM_EXPANDTRAYTIP, 0, 0); - } - - break; - } - case PUM_SETSTATUSTEXT: - { - if (pwd && (HANDLE)wParam == pwd->hContact) - { - DBWriteContactSettingTString(pwd->hContact, MODULE, "TempStatusMsg", (TCHAR *)lParam); - pwd->bIsPainted = false; - pwd->bNeedRefresh = true; - SendMessage(hwnd, PUM_REFRESH_VALUES, TRUE, 0); - InvalidateRect(hwnd, 0, TRUE); - } - - if (lParam) mir_free((void *)lParam); - return TRUE; - } - case PUM_SHOWXSTATUS: - { - if (pwd && (HANDLE)wParam == pwd->hContact) - { - // in case we have retrieve xstatus - pwd->bIsPainted = false; - SendMessage(hwnd, PUM_REFRESH_VALUES, TRUE, 0); - InvalidateRect(hwnd, 0, TRUE); - } - return TRUE; - } - case PUM_SETAVATAR: - { - if (pwd && (HANDLE)wParam == pwd->hContact) - { - pwd->bIsPainted = false; - SendMessage(hwnd, PUM_GETHEIGHT, 0, 0); - SendMessage(hwnd, PUM_CALCPOS, 0, 0); - InvalidateRect(hwnd, 0, TRUE); - } - return TRUE; - } - case PUM_EXPANDTRAYTIP: - { - pwd->bIsPainted = false; - if (skin.bNeedLayerUpdate) - { - RECT r = pwd->rcWindow; - POINT ptSrc = {0, 0}; - SIZE sz = {r.right - r.left, r.bottom - r.top}; - - BLENDFUNCTION blend; - blend.BlendOp = AC_SRC_OVER; - blend.BlendFlags = 0; - blend.SourceConstantAlpha = 0; - blend.AlphaFormat = AC_SRC_ALPHA; - - MyUpdateLayeredWindow(hwnd, NULL, NULL, &sz, skin.hdc, &ptSrc, 0xffffffff, &blend, LWA_ALPHA); - } - else if (MySetLayeredWindowAttributes) - { - MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), 0, LWA_ALPHA); - } - - SendMessage(hwnd, PUM_REFRESHTRAYTIP, 1, 0); - SendMessage(hwnd, PUM_GETHEIGHT, 0, 0); - SendMessage(hwnd, PUM_CALCPOS, 0, 0); - InvalidateRect(hwnd, 0, TRUE); - - if (opt.showEffect) - { - KillTimer(hwnd, ID_TIMER_ANIMATE); - SetTimer(hwnd, ID_TIMER_ANIMATE, ANIM_ELAPSE, 0); - pwd->iAnimStep = 0; - pwd->iCurrentTrans = 0; - } - - return TRUE; - } - case PUM_REFRESH_VALUES: - { - if (pwd && pwd->clcit.szProto == 0 && !pwd->bIsTextTip) - { - for (int i = 0; i < pwd->iRowCount; i++) - { - mir_free(pwd->rows[i].swzLabel); - mir_free(pwd->rows[i].swzValue); - Smileys_FreeParse(pwd->rows[i].spi); - } - - if (pwd->rows) - { - mir_free(pwd->rows); - pwd->rows = 0; - } - pwd->iRowCount = 0; - - DIListNode *node = opt.diList; - TCHAR buff_label[LABEL_LEN], buff[VALUE_LEN]; - while (node) - { - if (node->di.bIsVisible) - { - if (GetLabelText(pwd->hContact, node->di, buff_label, LABEL_LEN) && GetValueText(pwd->hContact, node->di, buff, VALUE_LEN)) - { - if (node->di.bLineAbove // we have a line above - && pwd->iRowCount > 0 // and we're not the first row - && pwd->rows[pwd->iRowCount - 1].bLineAbove // and above us there's a line above - && pwd->rows[pwd->iRowCount - 1].swzLabel[0] == 0 // with no label - && pwd->rows[pwd->iRowCount - 1].swzValue[0] == 0) // and no value - { - // overwrite item above - pwd->iRowCount--; - mir_free(pwd->rows[pwd->iRowCount].swzLabel); - mir_free(pwd->rows[pwd->iRowCount].swzValue); - Smileys_FreeParse(pwd->rows[pwd->iRowCount].spi); //prevent possible mem leak - } - else - { - pwd->rows = (RowData *)mir_realloc(pwd->rows, sizeof(RowData) * (pwd->iRowCount + 1)); - } - - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)pwd->hContact, 0); - - pwd->rows[pwd->iRowCount].swzLabel = mir_tstrdup(buff_label); - pwd->rows[pwd->iRowCount].swzValue = mir_tstrdup(buff); - pwd->rows[pwd->iRowCount].spi = Smileys_PreParse(buff, (int)_tcslen(buff), szProto); - pwd->rows[pwd->iRowCount].bValueNewline = node->di.bValueNewline; - pwd->rows[pwd->iRowCount].bLineAbove = node->di.bLineAbove; - pwd->iRowCount++; - } - } - node = node->next; - } - - // if the last item is just a divider, remove it - if (pwd->iRowCount > 0 - && pwd->rows[pwd->iRowCount - 1].bLineAbove // and above us there's a line above - && pwd->rows[pwd->iRowCount - 1].swzLabel[0] == 0 // with no label - && pwd->rows[pwd->iRowCount - 1].swzValue[0] == 0) // and no value - { - pwd->iRowCount--; - mir_free(pwd->rows[pwd->iRowCount].swzLabel); - mir_free(pwd->rows[pwd->iRowCount].swzValue); - Smileys_FreeParse(pwd->rows[pwd->iRowCount].spi); //prevent possible mem leak - - if (pwd->iRowCount == 0) - { - mir_free(pwd->rows); - pwd->rows = 0; - } - } - - if (wParam == TRUE) - { - SendMessage(hwnd, PUM_GETHEIGHT, 0, 0); - SendMessage(hwnd, PUM_CALCPOS, 0, 0); - } - } - return TRUE; - } - case PUM_GETHEIGHT: - { - int *pHeight = (int *)wParam; - HDC hdc = GetDC(hwnd); - SIZE sz; - RECT rc, smr; - rc.top = rc.left = 0; - rc.right = opt.iWinWidth; - int iWidth = opt.iPadding; - int iWinAvatarHeight = 0; - bool bStatusMsg = false; - HFONT hOldFont = (HFONT)GetCurrentObject(hdc,OBJ_FONT); - - // avatar height - pwd->iAvatarHeight = 0; - if (!pwd->bIsTextTip && opt.avatarLayout != PAV_NONE && ServiceExists(MS_AV_GETAVATARBITMAP)) - { - AVATARCACHEENTRY *ace = 0; - if (pwd->hContact) ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)pwd->hContact, 0); - else ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETMYAVATAR, 0, (LPARAM)pwd->clcit.szProto); - - if (ace && (ace->dwFlags & AVS_BITMAP_VALID) && !(ace->dwFlags & AVS_HIDEONCLIST)) - { - if (opt.bOriginalAvatarSize && max(ace->bmWidth, ace->bmHeight) <= opt.iAvatarSize) - { - pwd->iRealAvatarHeight = ace->bmHeight; - pwd->iRealAvatarWidth = ace->bmWidth; - } - else - { - if (ace->bmHeight >= ace->bmWidth) - { - pwd->iRealAvatarHeight = opt.iAvatarSize; - pwd->iRealAvatarWidth = (int)(opt.iAvatarSize * (ace->bmWidth / (double)ace->bmHeight)); - } - else - { - pwd->iRealAvatarHeight = (int)(opt.iAvatarSize * (ace->bmHeight / (double)ace->bmWidth)); - pwd->iRealAvatarWidth = opt.iAvatarSize; - } - } - - pwd->iAvatarHeight = opt.iOuterAvatarPadding + opt.iInnerAvatarPadding + pwd->iRealAvatarHeight; - iWinAvatarHeight = 2 * opt.iOuterAvatarPadding + pwd->iRealAvatarHeight; - iWidth += pwd->iRealAvatarWidth + (opt.iOuterAvatarPadding + opt.iInnerAvatarPadding - opt.iPadding); - } - } - - // titlebar height - if (!pwd->bIsTextTip && pwd->swzTitle && opt.titleLayout != PTL_NOTITLE) - { - smr.top = smr.bottom = 0; - smr.left = rc.left + opt.iPadding + pwd->iIndent; - smr.right = rc.right; - - if (pwd->iRealAvatarWidth > 0) - smr.right -= pwd->iRealAvatarWidth + opt.iOuterAvatarPadding + opt.iInnerAvatarPadding; - else - smr.right -= opt.iPadding; - - if (hFontTitle) SelectObject(hdc, (HGDIOBJ)hFontTitle); - DrawTextExt(hdc, pwd->swzTitle, -1, &smr, DT_CALCRECT | DT_LEFT | DT_WORDBREAK | DT_END_ELLIPSIS | DT_NOPREFIX, NULL, pwd->spiTitle); - - iWidth += opt.iPadding + opt.iTitleIndent + smr.right; - pwd->iTitleHeight = opt.iPadding + smr.bottom; - } - else - { - pwd->iTitleHeight = opt.iPadding; - } - - // icon height - int i, iCount = 0; - if (pwd->hContact || pwd->clcit.szProto) - { - for(i = 0; i < EXICONS_COUNT; i++) - { - if ((INT_PTR)pwd->extraIcons[i].hIcon == CALLSERVICE_NOTFOUND) - pwd->extraIcons[i].hIcon = 0; - - if (pwd->extraIcons[i].hIcon) - iCount++; - } - } - pwd->iIconsHeight = (iCount * 20) + 20; - - // text height - pwd->iTextHeight = pwd->iLabelWidth = 0; - // iterate once to find max label width for items with label and value on same line, but don't consider width of labels on a new line - for (i = 0; i < pwd->iRowCount; i++) - { - if (pwd->rows[i].swzLabel && !pwd->rows[i].bValueNewline) - { - if (pwd->bIsTrayTip && pwd->rows[i].bIsTitle) - { - if (hFontTrayTitle) - SelectObject(hdc, (HGDIOBJ)hFontTrayTitle); - } - else - { - if (hFontLabels) - SelectObject(hdc, (HGDIOBJ)hFontLabels); - } - - GetTextExtentPoint32(hdc, pwd->rows[i].swzLabel, (int)_tcslen(pwd->rows[i].swzLabel), &sz); - if (sz.cx > pwd->iLabelWidth) - pwd->iLabelWidth = sz.cx; - } - } - - for (i = 0; i < pwd->iRowCount; i++) - { - if (pwd->bIsTrayTip && pwd->rows[i].bIsTitle) - { - if (hFontTrayTitle) - SelectObject(hdc, (HGDIOBJ)hFontTrayTitle); - } - else - { - if (hFontLabels) - SelectObject(hdc, (HGDIOBJ)hFontLabels); - } - - if (pwd->rows[i].swzLabel && pwd->rows[i].swzLabel[0]) - GetTextExtentPoint32(hdc, pwd->rows[i].swzLabel, (int)_tcslen(pwd->rows[i].swzLabel), &sz); - else - sz.cy = sz.cx = 0; - - // save so we don't have to recalculate - pwd->rows[i].iLabelHeight = sz.cy; - - smr.top = smr.bottom = 0; - smr.left = rc.left + opt.iPadding + pwd->iIndent; - smr.right = rc.right; - if (hFontValues) SelectObject(hdc, (HGDIOBJ)hFontValues); - if (pwd->iTitleHeight + pwd->iTextHeight + opt.iTextPadding < pwd->iAvatarHeight) - smr.right -= pwd->iRealAvatarWidth + opt.iOuterAvatarPadding + opt.iInnerAvatarPadding; - else - smr.right -= opt.iPadding; - - if (!pwd->rows[i].bValueNewline) - smr.right -= pwd->iLabelWidth + opt.iValueIndent; - - if (pwd->rows[i].swzValue && pwd->rows[i].swzValue[0]) - { - if (!bStatusMsg && opt.bGetNewStatusMsg) - { - if (!_tcscmp(pwd->rows[i].swzValue, _T("%sys:status_msg%"))) - bStatusMsg = true; - } - - DrawTextExt(hdc, pwd->rows[i].swzValue, -1, &smr, DT_CALCRECT | DT_LEFT | DT_WORDBREAK | DT_END_ELLIPSIS | DT_NOPREFIX, NULL, pwd->rows[i].spi); - } - else - { - smr.left = smr.right = 0; - } - - // save so we don't have to recalculate - pwd->rows[i].iValueHeight = smr.bottom; - - pwd->rows[i].iTotalHeight = (pwd->rows[i].bLineAbove ? opt.iTextPadding : 0); - if (pwd->rows[i].bValueNewline) - { - if (sz.cy) pwd->rows[i].iTotalHeight += sz.cy + opt.iTextPadding; - if (smr.bottom) pwd->rows[i].iTotalHeight += smr.bottom + opt.iTextPadding; - } - else - { - int maxheight = max(sz.cy, smr.bottom); - if (maxheight) pwd->rows[i].iTotalHeight += maxheight + opt.iTextPadding; - } - - // only consider this item's width, and include it's height, if it doesn't make the window too big - if (max(pwd->iTitleHeight + pwd->iTextHeight + opt.iPadding + pwd->rows[i].iTotalHeight, pwd->iAvatarHeight) <= opt.iWinMaxHeight || pwd->bIsTrayTip) - { - if (iWidth < opt.iWinWidth) - { - int wid = opt.iPadding + pwd->iIndent + (pwd->rows[i].bValueNewline ? max(sz.cx, smr.right - smr.left) : pwd->iLabelWidth + opt.iValueIndent + (smr.right - smr.left)); - if (pwd->iTitleHeight + pwd->iTextHeight + opt.iTextPadding < pwd->iAvatarHeight) - iWidth = max(iWidth, wid + pwd->iRealAvatarWidth + opt.iOuterAvatarPadding + opt.iInnerAvatarPadding); - else - iWidth = max(iWidth, wid + opt.iPadding); - } - - pwd->iTextHeight += pwd->rows[i].iTotalHeight; - } - } - - SelectObject(hdc, hOldFont); - ReleaseDC(hwnd, hdc); - - int iHeight = max(pwd->iTitleHeight + pwd->iTextHeight + opt.iPadding, iWinAvatarHeight); - iHeight = max(pwd->iIconsHeight, iHeight); - if (bStatusMsg) iHeight += 50; - - if (iHeight < opt.iMinHeight) iHeight = opt.iMinHeight; - // ignore minwidth for text tips - if (!pwd->bIsTextTip && iWidth < opt.iMinWidth) iWidth = opt.iMinWidth; - - // ignore maxheight for tray tip - if (!pwd->bIsTrayTip && iHeight > opt.iWinMaxHeight) iHeight = opt.iWinMaxHeight; - if (iWidth > opt.iWinWidth) iWidth = opt.iWinWidth; - - CreateSkinBitmap(iWidth, iHeight, pwd->bIsTextTip && !pwd->bIsTrayTip); - - GetWindowRect(hwnd, &rc); - if (rc.right - rc.left != iWidth || rc.bottom - rc.top != iHeight) - { - SetWindowPos(hwnd, 0, 0, 0, iWidth, iHeight, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); - GetWindowRect(hwnd, &pwd->rcWindow); - SendMessage(hwnd, PUM_UPDATERGN, 0, 0); - InvalidateRect(hwnd, 0, TRUE); - } - - if (pHeight) - *pHeight = iHeight; - - return TRUE; - } - case PUM_UPDATERGN: - { - HRGN hRgn; - RECT r = pwd->rcWindow; - int v, h; - int w = 11; - - r.right -= r.left; - r.left = 0; - r.bottom -= r.top; - r.top = 0; - - if (opt.showEffect == PSE_FADE && wParam == 1) - { - if (skin.bNeedLayerUpdate) - { - POINT ptSrc = {0, 0}; - SIZE sz = {r.right - r.left, r.bottom - r.top}; - - BLENDFUNCTION blend; - blend.BlendOp = AC_SRC_OVER; - blend.BlendFlags = 0; - blend.SourceConstantAlpha = pwd->iCurrentTrans; - blend.AlphaFormat = AC_SRC_ALPHA; - - pwd->iCurrentTrans += opt.iAnimateSpeed; - if (pwd->iCurrentTrans > pwd->iTrans) - { - pwd->iCurrentTrans = pwd->iTrans; - pwd->iAnimStep = ANIM_STEPS; - } - - MyUpdateLayeredWindow(hwnd, NULL, NULL, &sz, skin.hdc, &ptSrc, 0xffffffff, &blend, LWA_ALPHA); - - } - else if (MySetLayeredWindowAttributes) - { - pwd->iCurrentTrans += opt.iAnimateSpeed; - if (pwd->iCurrentTrans > pwd->iTrans) - { - pwd->iCurrentTrans = pwd->iTrans; - pwd->iAnimStep = ANIM_STEPS; - } - - MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), pwd->iCurrentTrans, LWA_ALPHA); - } - - } - else if (opt.showEffect == PSE_ANIMATE && pwd->bIsPainted) - { - if (pwd->iAnimStep <= (ANIM_STEPS / opt.iAnimateSpeed)) - { - float frac = 1.0f - pwd->iAnimStep / ((float)ANIM_STEPS / opt.iAnimateSpeed); - int wi = r.right, hi = r.bottom; - - r.left += (int)(wi / 2.0f * frac + 0.5f); - r.right -= (int)(wi / 2.0f * frac + 0.5f); - r.top += (int)(hi / 2.0f * frac + 0.5f); - r.bottom -= (int)(hi / 2.0f * frac + 0.5f); - } - else - { - pwd->iAnimStep = ANIM_STEPS; - } - - if (skin.bNeedLayerUpdate) - { - RECT r2 = pwd->rcWindow; - POINT ptPos = {r.left + r2.left, r.top + r2.top}; - POINT ptSrc = {r.left, r.top}; - - SIZE sz = {r.right - r.left, r.bottom - r.top}; - - BLENDFUNCTION blend; - blend.BlendOp = AC_SRC_OVER; - blend.BlendFlags = 0; - blend.SourceConstantAlpha = pwd->iTrans; - blend.AlphaFormat = AC_SRC_ALPHA; - - MyUpdateLayeredWindow(hwnd, NULL, &ptPos, &sz, skin.hdc, &ptSrc, 0xffffffff, &blend, LWA_ALPHA); - } - } - - if (!skin.bNeedLayerUpdate) - { - // round corners - if (opt.bRound) - { - h = (r.right-r.left)>(w*2) ? w : (r.right-r.left); - v = (r.bottom-r.top)>(w*2) ? w : (r.bottom-r.top); - h = (hiAnimStep == 1) - { - if (MySetLayeredWindowAttributes) - MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), pwd->iTrans, LWA_ALPHA); - } - - } - else - { - // aero glass (vista+) - if (opt.bAeroGlass && MyDwmEnableBlurBehindWindow && pwd->iAnimStep > 5) - { - if (pwd->hrgnAeroGlass) - { - DeleteObject(pwd->hrgnAeroGlass); - pwd->hrgnAeroGlass = 0; - } - - pwd->hrgnAeroGlass = CreateOpaqueRgn(25, true); - - if (pwd->hrgnAeroGlass) - { - DWM_BLURBEHIND bb = {0}; - bb.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION; - bb.fEnable = TRUE; - bb.hRgnBlur = pwd->hrgnAeroGlass; - MyDwmEnableBlurBehindWindow(hwnd, &bb); - } - } - } - - return TRUE; - } - case PUM_CALCPOS: - { - RECT rcWork, rc; - - SystemParametersInfo(SPI_GETWORKAREA, 0, &rcWork, FALSE); - if (MyMonitorFromPoint) - { - HMONITOR hMon = MyMonitorFromPoint(pwd->clcit.ptCursor, MONITOR_DEFAULTTONEAREST); - MONITORINFO mi; - mi.cbSize = sizeof(mi); - if (MyGetMonitorInfo(hMon, &mi)) - rcWork = mi.rcWork; - } - - GetWindowRect(hwnd, &rc); - - int x = 0, y = 0, iWidth = (rc.right - rc.left), iHeight = (rc.bottom - rc.top); - - switch(opt.pos) - { - case PP_BOTTOMRIGHT: - x = pwd->clcit.ptCursor.x + GetSystemMetrics(SM_CXSMICON); // cursor size is too large - use small icon size - y = pwd->clcit.ptCursor.y + GetSystemMetrics(SM_CYSMICON); - break; - case PP_BOTTOMLEFT: - x = pwd->clcit.ptCursor.x - iWidth - GetSystemMetrics(SM_CXSMICON); - y = pwd->clcit.ptCursor.y + GetSystemMetrics(SM_CYSMICON); - break; - case PP_TOPRIGHT: - x = pwd->clcit.ptCursor.x + GetSystemMetrics(SM_CXSMICON); - y = pwd->clcit.ptCursor.y - iHeight - GetSystemMetrics(SM_CYSMICON); - break; - case PP_TOPLEFT: - x = pwd->clcit.ptCursor.x - iWidth - GetSystemMetrics(SM_CXSMICON); - y = pwd->clcit.ptCursor.y - iHeight - GetSystemMetrics(SM_CYSMICON); - break; - } - - - if (x + iWidth + 8 > rcWork.right) - x = rcWork.right - iWidth - 8; - if (x - 8 < rcWork.left) - x = rcWork.left + 8; - - if (pwd->bAllowReposition || !pwd->bNeedRefresh) - { - if (y + iHeight > rcWork.bottom) - { - y = pwd->clcit.ptCursor.y - iHeight - 8; - pwd->bAllowReposition = true; - } - - if (y - 8 < rcWork.top) - { - y = pwd->clcit.ptCursor.y + GetSystemMetrics(SM_CYSMICON); - pwd->bAllowReposition = true; - } - } - - SetWindowPos(hwnd, 0, x, y, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER); - GetWindowRect(hwnd, &pwd->rcWindow); - return TRUE; - } - case PUM_REFRESHTRAYTIP: - { - int i, j; - for (i = 0; i < pwd->iRowCount; i++) - { - mir_free(pwd->rows[i].swzLabel); - mir_free(pwd->rows[i].swzValue); - Smileys_FreeParse(pwd->rows[i].spi); - } - - if (pwd->rows) - { - mir_free(pwd->rows); - pwd->rows = NULL; - } - - pwd->iRowCount = 0; - - DWORD dwItems = (wParam == 0) ? opt.iFirstItems : opt.iSecondItems; - bool bFirstItem = true; - TCHAR buff[64]; - - int oldOrder = -1, iProtoCount = 0; - PROTOACCOUNT **accs; - ProtoEnumAccounts(&iProtoCount, &accs); - - for (j = 0; j < iProtoCount; j++) - { - PROTOACCOUNT *pa = NULL; - for (i = 0; i < iProtoCount; i++) - { - - if (accs[i]->iOrder > oldOrder && (pa == NULL || accs[i]->iOrder < pa->iOrder)) - pa = accs[i]; - } - - oldOrder = pa->iOrder; - - WORD wStatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0); - if (opt.bHideOffline && wStatus == ID_STATUS_OFFLINE) - continue; - - if (!IsAccountEnabled(pa) || !IsTrayProto(pa->tszAccountName, (BOOL)wParam)) - continue; - - if (dwItems & TRAYTIP_NUMCONTACTS) - { - int iCount = 0, iCountOnline = 0; - HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - while (hContact) - { - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if (proto && !strcmp(proto, pa->szModuleName)) - { - if (DBGetContactSettingWord(hContact, proto, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) - iCountOnline++; - iCount++; - } - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); - } - mir_sntprintf(buff, 64, _T("(%d/%d)"), iCountOnline, iCount); - } - else - { - _tcscpy(buff, _T("")); - } - - TCHAR swzProto[256]; - _tcscpy(swzProto, pa->tszAccountName); - if (dwItems & TRAYTIP_LOCKSTATUS) - { - if (CallService(MS_PROTO_ISACCOUNTLOCKED,0,(LPARAM)pa->szModuleName)) - mir_sntprintf(swzProto, SIZEOF(swzProto), TranslateT("%s (locked)"), pa->tszAccountName); - } - - AddRow(pwd, swzProto, buff, NULL, false, false, !bFirstItem, true, LoadSkinnedProtoIcon(pa->szModuleName, wStatus)); - bFirstItem = false; - - if (dwItems & TRAYTIP_LOGON) - { - if (TimestampToTimeDifference(NULL, pa->szModuleName, "LogonTS", buff, 59)) - { - _tcscat(buff, TranslateT(" ago")); - AddRow(pwd, TranslateT("Log on:"), buff, NULL, false, false, false); - } - - if (TimestampToTimeDifference(NULL, pwd->clcit.szProto, "LogoffTS", buff, 59)) - { - _tcscat(buff, TranslateT(" ago")); - AddRow(pwd, TranslateT("Log off:"), buff, NULL, false, false, false); - } - } - - if (dwItems & TRAYTIP_UNREAD_EMAILS && ProtoServiceExists(pa->szModuleName, "/GetUnreadEmailCount")) - { - int iCount = (int)CallProtoService(pa->szModuleName, "/GetUnreadEmailCount", 0, 0); - if (iCount > 0) - { - _itot(iCount, buff, 10); - AddRow(pwd, TranslateT("Unread emails:"), buff, NULL, false, false, false); - } - } - - if (dwItems & TRAYTIP_STATUS) - { - TCHAR *swzText = (TCHAR *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, wStatus, GSMDF_TCHAR); - if (swzText) - { - AddRow(pwd, TranslateT("Status:"), swzText, NULL, false, false, false); - } - } - - if (wStatus >= ID_STATUS_ONLINE && wStatus <= ID_STATUS_OUTTOLUNCH) - { - if (dwItems & TRAYTIP_STATUS_MSG) - { - TCHAR *swzText = GetProtoStatusMessage(pa->szModuleName, wStatus); - if (swzText) - { - StripBBCodesInPlace(swzText); - AddRow(pwd, TranslateT("Status message:"), swzText, pa->szModuleName, true, true, false); - mir_free(swzText); - } - } - - if (dwItems & TRAYTIP_EXTRA_STATUS) - { - // jabber mood or icq xstatus - TCHAR *swzAdvTitle = GetJabberAdvStatusText(pa->szModuleName, "mood", "title"); - if (swzAdvTitle) - { - StripBBCodesInPlace(swzAdvTitle); - AddRow(pwd, TranslateT("Mood:"), swzAdvTitle, pa->szModuleName, true, false, false); - mir_free(swzAdvTitle); - - TCHAR *swzAdvText = GetJabberAdvStatusText(pa->szModuleName, "mood", "text"); - if (swzAdvText) - { - StripBBCodesInPlace(swzAdvText); - AddRow(pwd, _T(""), swzAdvText, pa->szModuleName, true, true, false); - mir_free(swzAdvText); - } - } - else - { - if (DBGetContactSettingByte(0, pa->szModuleName, "XStatusId", 0)) - { - // xstatus title - swzAdvTitle = GetProtoExtraStatusTitle(pa->szModuleName); - if (swzAdvTitle) - { - StripBBCodesInPlace(swzAdvTitle); - AddRow(pwd, TranslateT("XStatus:"), swzAdvTitle, pa->szModuleName, true, false, false); - mir_free(swzAdvTitle); - } - - // xstatus message - TCHAR *swzAdvText = GetProtoExtraStatusMessage(pa->szModuleName); - if (swzAdvText) - { - StripBBCodesInPlace(swzAdvText); - AddRow(pwd, _T(""), swzAdvText, pa->szModuleName, true, true, false); - mir_free(swzAdvText); - } - } - } - - TCHAR *swzActTitle = GetJabberAdvStatusText(pa->szModuleName, "activity", "title"); - if (swzActTitle) - { - StripBBCodesInPlace(swzActTitle); - AddRow(pwd, TranslateT("Activity:"), swzActTitle, pa->szModuleName, true, false, false); - mir_free(swzActTitle); - } - - TCHAR *swzActText = GetJabberAdvStatusText(pa->szModuleName, "activity", "text"); - if (swzActText) - { - StripBBCodesInPlace(swzActText); - AddRow(pwd, _T(""), swzActText, pa->szModuleName, true, true, false); - mir_free(swzActText); - } - } - - if (dwItems & TRAYTIP_LISTENINGTO) - { - TCHAR *swzListening = GetListeningTo(pa->szModuleName); - if (swzListening) - { - StripBBCodesInPlace(swzListening); - AddRow(pwd, TranslateT("Listening to:"), swzListening, NULL, false, true, false); - mir_free(swzListening); - } - } - } - } - - if (dwItems & TRAYTIP_FAVCONTACTS) - { - if (DBGetContactSettingDword(0, MODULE, "FavouriteContactsCount", 0)) - { - TCHAR swzName[256]; - TCHAR swzStatus[256]; - bool bTitlePainted = false; - int iCount = 0, iCountOnline = 0; - - HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - while (hContact) - { - if (DBGetContactSettingByte(hContact, MODULE, "FavouriteContact", 0)) - { - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if (proto) - { - WORD wStatus = DBGetContactSettingWord(hContact, proto, "Status", ID_STATUS_OFFLINE); - WordToStatusDesc(hContact, proto, "Status", swzStatus, 256); - - if (wStatus != ID_STATUS_OFFLINE) - iCountOnline++; - - iCount++; - - if (!(opt.iFavoriteContFlags & FAVCONT_HIDE_OFFLINE && wStatus == ID_STATUS_OFFLINE)) - { - if (!bTitlePainted) - { - AddRow(pwd, TranslateT("Fav. contacts"), NULL, NULL, false, false, !bFirstItem, true, NULL); - bFirstItem = false; - bTitlePainted = true; - } - - TCHAR *swzNick = (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR); - if (opt.iFavoriteContFlags & FAVCONT_APPEND_PROTO) - { - TCHAR *swzProto = a2t(proto); - mir_sntprintf(swzName, 256, _T("%s (%s)"), swzNick, swzProto); - mir_free(swzProto); - } - else - { - _tcscpy(swzName, swzNick); - } - - AddRow(pwd, swzName, swzStatus, NULL, false, false, false); - } - } - } - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0); - } - - int index = pwd->iRowCount - 1; - if (opt.iFavoriteContFlags & FAVCONT_HIDE_OFFLINE) - index -= iCountOnline; - else - index -= iCount; - - if (index >= 0 && (dwItems & TRAYTIP_NUMCONTACTS) && !((opt.iFavoriteContFlags & FAVCONT_HIDE_OFFLINE) && iCountOnline == 0)) - { - mir_sntprintf(buff, 64, _T("(%d/%d)"), iCountOnline, iCount); - pwd->rows[index].swzValue = mir_tstrdup(buff); - } - } - } - - if (dwItems & TRAYTIP_MIRANDA_UPTIME) - { - if (TimestampToTimeDifference(NULL, MODULE, "MirandaStartTS", buff, 64)) - { - AddRow(pwd, TranslateT("Other"), _T(""), NULL, false, false, !bFirstItem, true, NULL); - AddRow(pwd, TranslateT("Miranda uptime:"), buff, NULL, false, false, false); - } - } - - if (dwItems & TRAYTIP_CLIST_EVENT && pwd->clcit.swzText) - { - TCHAR *pchBr = _tcschr(pwd->clcit.swzText, '\n'); - TCHAR *pchBold = _tcsstr(pwd->clcit.swzText, _T("")); - - if (!pchBold || pchBold != pwd->clcit.swzText) - { - TCHAR swzText[256]; - _tcscpy(swzText, pwd->clcit.swzText); - if (pchBr) swzText[pchBr - pwd->clcit.swzText] = 0; - AddRow(pwd, swzText, _T(""), NULL, false, true, false, true, LoadSkinnedIcon(SKINICON_OTHER_FILLEDBLOB)); - } - } - - return TRUE; - } - } - - return DefWindowProc(hwnd, uMsg, wParam, lParam); -} \ No newline at end of file diff --git a/plugins/TipperYM/popwin.h b/plugins/TipperYM/popwin.h deleted file mode 100644 index b7ba674b08..0000000000 --- a/plugins/TipperYM/popwin.h +++ /dev/null @@ -1,140 +0,0 @@ -/* -Copyright (C) 2006-2007 Scott Ellis -Copyright (C) 2007-2011 Jan Holub - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this file; see the file license.txt. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. -*/ - -#ifndef _POPWIN_INC -#define _POPWIN_INC - -#include "mir_smileys.h" - -#define POP_WIN_CLASS _T(MODULE) _T("MimTTClass") - -#define PUM_GETHEIGHT (WM_USER + 0x020) -#define PUM_CALCPOS (WM_USER + 0x021) -#define PUM_SETSTATUSTEXT (WM_USER + 0x022) -#define PUM_UPDATERGN (WM_USER + 0x023) -#define PUM_SETAVATAR (WM_USER + 0x024) -#define PUM_REFRESH_VALUES (WM_USER + 0x025) -#define PUM_SHOWXSTATUS (WM_USER + 0x026) -#define PUM_EXPANDTRAYTIP (WM_USER + 0x027) -#define PUM_REFRESHTRAYTIP (WM_USER + 0x028) -#define PUM_FADEOUTWINDOW (WM_USER + 0x029) - -// extra icons -#define EXICONS_COUNT 6 -#define CTRY_ERROR 42 //Flags - some strange value ??? -#define GEN_FEMALE 70 -#define GEN_MALE 77 - -// copy menu -#define COPYMENU_ALLITEMS_LABELS 1000 -#define COPYMENU_ALLITEMS 1001 -#define COPYMENU_AVATAR 1002 - -// tray tooltip items -#define TRAYTIP_ITEMS_COUNT 11 - -#define TRAYTIP_NUMCONTACTS 1 -#define TRAYTIP_LOCKSTATUS 2 -#define TRAYTIP_LOGON 4 -#define TRAYTIP_UNREAD_EMAILS 8 -#define TRAYTIP_STATUS 16 -#define TRAYTIP_STATUS_MSG 32 -#define TRAYTIP_EXTRA_STATUS 64 -#define TRAYTIP_LISTENINGTO 128 -#define TRAYTIP_FAVCONTACTS 256 -#define TRAYTIP_MIRANDA_UPTIME 512 -#define TRAYTIP_CLIST_EVENT 1024 - -// favorite contacts options -#define FAVCONT_HIDE_OFFLINE 1 -#define FAVCONT_APPEND_PROTO 2 - -// other -#define TITLE_TEXT_LEN 512 -#define MAX_VALUE_LEN 64 - -#define ANIM_ELAPSE 10 -#define ANIM_STEPS 255 -#define CHECKMOUSE_ELAPSE 250 - -#define ID_TIMER_ANIMATE 0x0100 -#define ID_TIMER_CHECKMOUSE 0x0101 -#define ID_TIMER_TRAYTIP 0x0102 - - -typedef struct { - HICON hIcon; - bool bDestroy; -} ExtraIcons; - -typedef struct { - int cbSize; - int isTreeFocused; //so the plugin can provide an option - int isGroup; //0 if it's a contact, 1 if it's a group - HANDLE hItem; //handle to group or contact - POINT ptCursor; - RECT rcItem; - TCHAR *swzText; // for tips with specific text - char *szProto; // for proto tips -} CLCINFOTIPEX; - -typedef struct { - TCHAR *swzLabel, *swzValue; - HICON hIcon; - bool bValueNewline; - bool bLineAbove; - bool bIsTitle; - int iLabelHeight, iValueHeight, iTotalHeight; - SMILEYPARSEINFO spi; -} RowData; - -typedef struct { - HPEN hpenBorder, hpenDivider; - int iTitleHeight, iAvatarHeight, iIconsHeight, iTextHeight, iLabelWidth; - int iRealAvatarWidth, iRealAvatarHeight; - HANDLE hContact; - int iIconIndex; - CLCINFOTIPEX clcit; - TCHAR swzTitle[TITLE_TEXT_LEN]; - SMILEYPARSEINFO spiTitle; - RowData *rows; - int iRowCount; - int iAnimStep; - int iCurrentTrans; - bool bIsTextTip, bIsTrayTip; - int iIndent, iSidebarWidth; - POINT ptCursorStartPos; // work around bugs with hiding tips (timer check mouse position) - ExtraIcons extraIcons[EXICONS_COUNT]; - bool bIsIconVisible[EXICONS_COUNT]; - int iTrans; - int iHotkeyId; - bool bIsPainted; - bool bNeedRefresh; - bool bAllowReposition; - RECT rcWindow; - HRGN hrgnAeroGlass; -} PopupWindowData; - - -LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); -extern int IsTrayProto(const TCHAR *swzProto, BOOL bExtendedTip); - - -#endif diff --git a/plugins/TipperYM/preset_items.cpp b/plugins/TipperYM/preset_items.cpp deleted file mode 100644 index 629a747a28..0000000000 --- a/plugins/TipperYM/preset_items.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* -Copyright (C) 2006-2007 Scott Ellis -Copyright (C) 2007-2011 Jan Holub - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this file; see the file license.txt. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. -*/ - -#include "common.h" -#include "preset_items.h" - -PRESETITEM presetItems[] = -{ - "birth", LPGENT("Birthday"), LPGENT("Birthday:"), _T("%birthday_date% (%birthday_age%) @ Next: %birthday_next%"), "birthdate", "birthage", "birthnext", - "client", LPGENT("Client"), LPGENT("Client:"), _T("%raw:/MirVer%"), 0, 0, 0, - "email", LPGENT("Email"), LPGENT("Email:"), _T("%raw:/e-mail%"), 0, 0, 0, - "gender", LPGENT("Gender"), LPGENT("Gender:"), _T("%gender%"), 0, 0, 0, - "homepage", LPGENT("Homepage"), LPGENT("Homepage:"), _T("%raw:/Homepage%"), 0, 0, 0, - "id", LPGENT("Identifier"), LPGENT("%sys:uidname|UID^!MetaContacts%:"), _T("%sys:uid%"), 0, 0, 0, - "idle", LPGENT("Idle"), LPGENT("Idle:"), _T("%idle% (%idle_diff% ago)"), "idle", "idlediff", 0, - "ip", LPGENT("IP"), LPGENT("IP:"), _T("%ip%"), "ip", 0, 0, - "ipint", LPGENT("IP internal"), LPGENT("IP internal:"), _T("%ip_internal%"), "ipint", 0, 0, - "lastmsg", LPGENT("Last message"), LPGENT("Last message: (%sys:last_msg_reltime% ago)"), _T("%sys:last_msg%"), 0, 0, 0, - "listening", LPGENT("Listening to"), LPGENT("Listening to:"), _T("%raw:/ListeningTo%"), 0, 0, 0, - "name", LPGENT("Name"), LPGENT("Name:"), _T("%raw:/FirstName|% %raw:/LastName%"), 0, 0, 0, - "received", LPGENT("Number of received messages"), LPGENT("Number of msg [IN]:"), _T("%sys:msg_count_in%"), 0, 0, 0, - "sended", LPGENT("Number of sended messages"), LPGENT("Number of msg [OUT]:"), _T("%sys:msg_count_out%"), 0, 0, 0, - "status", LPGENT("Status"), LPGENT("Status:"), _T("%Status%"), "status", 0, 0, - "statusmsg", LPGENT("Status message"), LPGENT("Status message:"), _T("%sys:status_msg%"), 0, 0, 0, - "time", LPGENT("Contact time"), LPGENT("Time:"), _T("%sys:time%"), 0, 0, 0, - "xtitle", LPGENT("XStatus title"), LPGENT("XStatus title:"), _T("%xsname%"), "xname", 0, 0, - "xtext", LPGENT("XStatus text"), LPGENT("XStatus text:"), _T("%raw:/XStatusMsg%"), 0, 0, 0, - "acttitle", LPGENT("[jabber.dll] Activity title"), LPGENT("Activity title:"), _T("%raw:AdvStatus/?dbsetting(%subject%,Protocol,p)/activity/title%"), 0, 0, 0, - "acttext", LPGENT("[jabber.dll] Activity text"), LPGENT("Activity text:"), _T("%raw:AdvStatus/?dbsetting(%subject%,Protocol,p)/activity/text%"), 0, 0, 0, - "logon", LPGENT("[menuex.dll] Logon time"), LPGENT("Logon time:"), _T("%logon_date% @ %logon_time% (%logon_ago%)"), "logondate", "logontime", "logonago", - "logoff", LPGENT("[menuex.dll] Logoff time"), LPGENT("Logoff time:"), _T("%logoff_date% @ %logoff_time% (%logoff_ago%)"), "logoffdate", "logofftime", "logoffago", - "lastseentime", LPGENT("[seenplugin.dll] Last seen time"), LPGENT("Last seen time:"), _T("%lastseen_date% @ %lastseen_time%"), "lsdate", "lstime", 0, - "lastseenstatus", LPGENT("[seenplugin.dll] Last seen status"), LPGENT("Last seen status:"), _T("%lastseen_status% (%lastseen_ago% ago)"), "lsstatus", "lsago", 0, - "cond", LPGENT("[weather.dll] Condition"), LPGENT("Condition:"), _T("%raw:Current/Condition%"), 0, 0, 0, - "humidity", LPGENT("[weather.dll] Humidity"), LPGENT("Humidity:"), _T("%raw:Current/Humidity%"), 0, 0, 0, - "minmaxtemp", LPGENT("[weather.dll] Max/Min temperature"), LPGENT("Max/Min:"), _T("%raw:Current/High%/%raw:Current/Low%"), 0, 0, 0, - "moon", LPGENT("[weather.dll] Moon"), LPGENT("Moon:"), _T("%raw:Current/Moon%"), 0, 0, 0, - "pressure", LPGENT("[weather.dll] Pressure"), LPGENT("Pressure:"), _T("%raw:Current/Pressure% (%raw:Current/Pressure Tendency%)"), 0, 0, 0, - "sunrise", LPGENT("[weather.dll] Sunrise"), LPGENT("Sunrise:"), _T("%raw:Current/Sunrise%"), 0, 0, 0, - "sunset", LPGENT("[weather.dll] Sunset"), LPGENT("Sunset:"), _T("%raw:Current/Sunset%"), 0, 0, 0, - "temp", LPGENT("[weather.dll] Temperature"), LPGENT("Temperature:"), _T("%raw:Current/Temperature%"), 0, 0, 0, - "uptime", LPGENT("[weather.dll] Update time"), LPGENT("Update time:"), _T("%raw:Current/Update%"), 0, 0, 0, - "uvindex", LPGENT("[weather.dll] UV Index"), LPGENT("UV Index:"), _T("%raw:Current/UV% - %raw:Current/UVI%"), 0, 0, 0, - "vis", LPGENT("[weather.dll] Visibility"), LPGENT("Visibility:"), _T("%raw:Current/Visibility%"), 0, 0, 0, - "wind", LPGENT("[weather.dll] Wind"), LPGENT("Wind:"), _T("%raw:Current/Wind Direction% (%raw:Current/Wind Direction DEG%)/%raw:Current/Wind Speed%"), 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0 -}; - -PRESETSUBST presetSubsts[] = -{ - "gender", _T("gender"), DVT_PROTODB, NULL, "Gender", 5, - "status", _T("Status"), DVT_PROTODB, NULL, "Status", 1, - "ip", _T("ip"), DVT_PROTODB, NULL, "IP", 7, - "ipint", _T("ip_internal"), DVT_PROTODB, NULL, "RealIP", 7, - "idle", _T("idle"), DVT_PROTODB, NULL, "IdleTS", 2, - "idlediff", _T("idle_diff"), DVT_PROTODB, NULL, "IdleTS", 3, - "xname", _T("xsname"), DVT_PROTODB, NULL, "XStatusName", 17, - "lsdate", _T("lastseen_date"), DVT_DB, "SeenModule", NULL, 8, - "lstime", _T("lastseen_time"), DVT_DB, "SeenModule", NULL, 10, - "lsstatus", _T("lastseen_status"), DVT_DB, "SeenModule", "OldStatus", 1, - "lsago", _T("lastseen_ago"), DVT_DB, "SeenModule", "seenTS", 3, - "birthdate", _T("birthday_date"), DVT_PROTODB, NULL, "Birth", 8, - "birthage", _T("birthday_age"), DVT_PROTODB, NULL, "Birth", 9, - "birthnext", _T("birthday_next"), DVT_PROTODB, NULL, "Birth", 12, - "logondate", _T("logon_date"), DVT_PROTODB, NULL, "LogonTS", 15, - "logontime", _T("logon_time"), DVT_PROTODB, NULL, "LogonTS", 13, - "logonago", _T("logon_ago"), DVT_PROTODB, NULL, "LogonTS", 3, - "logoffdate", _T("logoff_date"), DVT_PROTODB, NULL, "LogoffTS", 15, - "logofftime", _T("logoff_time"), DVT_PROTODB, NULL, "LogoffTS", 13, - "logoffago", _T("logoff_ago"), DVT_PROTODB, NULL, "LogoffTS", 3, - 0, 0, DVT_DB, 0, 0, 0 -}; - -DEFAULTITEM defaultItemList[] = -{ - "statusmsg", true, - "-", false, - "lastmsg", true , - "-", false, - "client", false, - "homepage", false, - "email", false, - "birth", false, - "name", false, - "-", false, - "time", false, - "id", false, - "status", false, - 0,0 -}; - -PRESETITEM *GetPresetItemByName(char *szName) -{ - for (int i = 0; presetItems[i].szID; i++) - { - if (strcmp(presetItems[i].szID, szName) == 0) - return &presetItems[i]; - } - - return NULL; -} - -PRESETSUBST *GetPresetSubstByName(char *szName) -{ - if (!szName) return NULL; - for (int i = 0; presetSubsts[i].szID; i++) - { - if (strcmp(presetSubsts[i].szID, szName) == 0) - return &presetSubsts[i]; - } - - return NULL; -} - diff --git a/plugins/TipperYM/preset_items.h b/plugins/TipperYM/preset_items.h deleted file mode 100644 index 5055db3dee..0000000000 --- a/plugins/TipperYM/preset_items.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -Copyright (C) 2006-2007 Scott Ellis -Copyright (C) 2007-2011 Jan Holub - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this file; see the file license.txt. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. -*/ - -#ifndef _PRESETITEMS_INC -#define _PRESETITEMS_INC - -#include "options.h" - -#define MAX_PRESET_SUBST_COUNT 3 - -typedef struct { - char *szID; - TCHAR *swzName; - TCHAR *swzLabel; - TCHAR *swzValue; - char *szNeededSubst[MAX_PRESET_SUBST_COUNT]; -} PRESETITEM; - -typedef struct { - char *szID; - TCHAR *swzName; - DisplaySubstType type; - char *szModuleName; - char *szSettingName; - int iTranslateFuncId; -} PRESETSUBST; - -typedef struct { - char *szName; - bool bValueNewline; -} DEFAULTITEM; - -extern PRESETITEM presetItems[]; -extern PRESETSUBST presetSubsts[]; -extern DEFAULTITEM defaultItemList[]; - -PRESETITEM *GetPresetItemByName(char *szName); -PRESETSUBST *GetPresetSubstByName(char *szName); - -#endif \ No newline at end of file diff --git a/plugins/TipperYM/res/resource.rc b/plugins/TipperYM/res/resource.rc new file mode 100644 index 0000000000..8c7a166d71 --- /dev/null +++ b/plugins/TipperYM/res/resource.rc @@ -0,0 +1,386 @@ +// Microsoft Visual C++ generated resource script. +// +#include "..\src\resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Czech (Czech Republic) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CSY) +LANGUAGE LANG_CZECH, SUBLANG_DEFAULT +#pragma code_page(1250) + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_OPT_APPEARANCE DIALOGEX 0, 0, 300, 230 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + EDITTEXT IDC_ED_WIDTH,249,17,36,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT + CONTROL "",IDC_SPIN_WIDTH,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,277,17,11,12 + EDITTEXT IDC_ED_MAXHEIGHT,249,45,36,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT + CONTROL "",IDC_SPIN_MAXHEIGHT,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,277,45,11,12 + GROUPBOX "Options",IDC_STATIC,159,142,135,78 + GROUPBOX "Layout",IDC_STATIC,5,6,150,165 + EDITTEXT IDC_ED_AVSIZE,249,73,36,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT + CONTROL "",IDC_SPIN_AVSIZE,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,277,73,11,12 + COMBOBOX IDC_CMB_ICON,14,31,133,69,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_CMB_AV,14,45,133,76,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + EDITTEXT IDC_ED_INDENT,117,65,30,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT + CONTROL "",IDC_SPIN_INDENT,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,135,65,11,12 + RTEXT "Text indent:",IDC_STATIC,9,68,104,8 + GROUPBOX "Window",IDC_STATIC,159,6,135,133 + RTEXT "Max width:",IDC_STATIC,165,20,80,8,0,WS_EX_RIGHT + RTEXT "Max height:",IDC_STATIC,165,48,80,8,0,WS_EX_RIGHT + RTEXT "Avatar size:",IDC_STATIC_AVATARSIZE,165,76,80,8,0,WS_EX_RIGHT + CONTROL "Show if list not focused",IDC_CHK_NOFOCUS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,166,122,125,11 + EDITTEXT IDC_ED_PADDING,117,107,30,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT + CONTROL "",IDC_SPIN_PADDING,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,135,107,11,12 + RTEXT "General padding:",IDC_STATIC,9,110,104,8 + EDITTEXT IDC_ED_HOVER,249,101,36,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT + CONTROL "",IDC_SPIN_HOVER,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,277,101,11,12 + RTEXT "Hover time:",IDC_STATIC,165,104,80,8,0,WS_EX_RIGHT + COMBOBOX IDC_CMB_POS,14,17,133,69,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + CONTROL "Status bar tips",IDC_CHK_SBAR,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,166,153,125,11 + GROUPBOX "Alignment",IDC_STATIC,5,175,150,45 + COMBOBOX IDC_CMB_LV,57,186,43,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_CMB_VV,57,202,43,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_CMB_LH,104,186,43,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_CMB_VH,104,202,43,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + RTEXT "Labels:",IDC_STATIC,10,188,44,8 + RTEXT "Values:",IDC_STATIC,10,204,44,8 + EDITTEXT IDC_ED_MINWIDTH,249,31,36,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT + CONTROL "",IDC_SPIN_MINWIDTH,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,277,31,11,12 + RTEXT "Min width:",IDC_STATIC,165,34,80,8,0,WS_EX_RIGHT + EDITTEXT IDC_ED_MINHEIGHT,249,59,36,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT + CONTROL "",IDC_SPIN_MINHEIGHT,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,277,59,11,12 + RTEXT "Min height:",IDC_STATIC,165,62,80,8,0,WS_EX_RIGHT + EDITTEXT IDC_ED_SBWIDTH,249,87,36,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT + CONTROL "",IDC_SPIN_SBWIDTH,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,277,87,11,12 + RTEXT "Sidebar width:",IDC_STATIC,165,90,80,8 + EDITTEXT IDC_ED_TEXTPADDING,117,121,30,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT + CONTROL "",IDC_SPIN_TEXTPADDING,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,135,121,11,12 + RTEXT "Text padding:",IDC_STATIC,9,124,104,8 + EDITTEXT IDC_ED_OUTAVPADDING,117,135,30,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT + CONTROL "",IDC_SPIN_OUTAVPADDING,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,135,135,11,12 + RTEXT "Outer avatar padding:",IDC_STATIC,9,138,104,8 + CONTROL "Round corners (avatar)",IDC_CHK_ROUNDCORNERSAV,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,166,187,125,11 + CONTROL "Keep original avatar size",IDC_CHK_ORIGINALAVSIZE, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,166,204,125,11 + CONTROL "Avatar border",IDC_CHK_AVBORDER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,166,170,125,11 + EDITTEXT IDC_ED_TITLEINDENT,117,79,30,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT + CONTROL "",IDC_SPIN_TITLEINDENT,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,135,79,11,12 + RTEXT "Title indent:",IDC_STATIC,9,82,104,8 + EDITTEXT IDC_ED_VALUEINDENT,117,94,30,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT + CONTROL "",IDC_SPIN_VALUEINDENT,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,135,94,11,12 + RTEXT "Value indent:",IDC_STATIC,9,97,104,8 + EDITTEXT IDC_ED_INAVPADDING,117,150,30,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT + CONTROL "",IDC_SPIN_INAVPADDING,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,135,150,11,12 + RTEXT "Inner avatar padding:",IDC_STATIC,9,153,104,8 +END + +IDD_SUBST DIALOGEX 0, 0, 225, 196 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Substitution" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + LTEXT "Label:",IDC_STATIC,14,10,198,8 + EDITTEXT IDC_ED_LABEL,13,23,198,13,ES_AUTOHSCROLL + CONTROL "Contact protocol module",IDC_CHK_PROTOMOD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,74,198,10 + LTEXT "Module:",IDC_STATIC,14,47,198,8 + EDITTEXT IDC_ED_MODULE,13,58,198,13,ES_AUTOHSCROLL + LTEXT "Setting or prefix:",IDC_STATIC,14,90,198,8 + EDITTEXT IDC_ED_SETTING,13,103,198,13,ES_AUTOHSCROLL + LTEXT "Translation:",IDC_STATIC,14,131,198,8 + COMBOBOX IDC_CMB_TRANSLATE,13,144,198,104,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + DEFPUSHBUTTON "OK",IDOK,59,172,50,14 + PUSHBUTTON "Cancel",IDCANCEL,117,172,50,14 +END + +IDD_ITEM DIALOGEX 0, 0, 225, 207 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Item" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + LTEXT "Label:",IDC_STATIC,14,10,195,8 + LTEXT "Value:",IDC_STATIC,14,47,198,8 + EDITTEXT IDC_ED_LABEL,13,23,198,13,ES_AUTOHSCROLL + EDITTEXT IDC_ED_VALUE,13,58,198,45,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN + CONTROL "Draw a line above",IDC_CHK_LINEABOVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,110,173,10 + CONTROL "Value on a new line",IDC_CHK_VALNEWLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,122,198,10 + DEFPUSHBUTTON "OK",IDOK,58,185,50,14 + PUSHBUTTON "Cancel",IDCANCEL,116,185,50,14 + COMBOBOX IDC_CMB_PRESETITEMS,13,161,198,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + LTEXT "Preset items:",IDC_STATIC,14,151,198,8 + CONTROL "Variables",IDC_BTN_VARIABLE,"MButtonClass",WS_TABSTOP,194,108,16,14 + CONTROL "Parse Tipper variables first",IDC_CHK_PARSETIPPERFIRST, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,134,198,10 +END + +IDD_OPT_CONTENT DIALOGEX 0, 0, 300, 230 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE | WS_SYSMENU +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + GROUPBOX "Items",IDC_STATIC,5,4,142,216 + GROUPBOX "Substitutions",IDC_STATIC,151,4,142,216 + LISTBOX IDC_LST_SUBST,158,17,128,180,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + CONTROL "Add",IDC_BTN_ADD,"MButtonClass",WS_TABSTOP,12,201,16,14 + CONTROL "Remove",IDC_BTN_REMOVE,"MButtonClass",WS_TABSTOP,60,201,16,14 + CONTROL "Up",IDC_BTN_UP,"MButtonClass",WS_TABSTOP,108,201,16,14 + CONTROL "Down",IDC_BTN_DOWN,"MButtonClass",WS_TABSTOP,124,201,16,14 + CONTROL "Edit",IDC_BTN_EDIT,"MButtonClass",WS_TABSTOP,44,201,16,14 + CONTROL "Add",IDC_BTN_ADD2,"MButtonClass",WS_TABSTOP,158,201,16,14 + CONTROL "Remove",IDC_BTN_REMOVE2,"MButtonClass",WS_TABSTOP,173,201,16,14 + CONTROL "Edit",IDC_BTN_EDIT2,"MButtonClass",WS_TABSTOP,189,201,16,14 + CONTROL "",IDC_TREE_FIRST_ITEMS,"SysTreeView32",TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | TVS_FULLROWSELECT | TVS_NOHSCROLL | WS_BORDER | WS_TABSTOP,12,17,128,180 + CONTROL "Separator",IDC_BTN_SEPARATOR,"MButtonClass",WS_TABSTOP,28,201,16,14 +END + +IDD_OPT_EXTRA DIALOGEX 0, 0, 300, 230 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + GROUPBOX "Advanced options",IDC_STATIC,7,96,284,74 + CONTROL "Retrieve XStatus details if auto-retrieve is disabled",IDC_CHK_RETRIEVEXSTATUS, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,153,273,10 + CONTROL "",IDC_TREE_EXTRAICONS,"SysTreeView32",TVS_NOTOOLTIPS | TVS_NOSCROLL | TVS_FULLROWSELECT | WS_BORDER | WS_HSCROLL | WS_TABSTOP,15,18,98,66 + GROUPBOX "Extra icons",IDC_STATIC,7,7,114,84 + GROUPBOX "Smileys support",IDC_STATIC,127,7,164,84 + CONTROL "Enable SmileyAdd support",IDC_CHK_ENABLESMILEYS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,134,18,154,10 + CONTROL "Resize smileys",IDC_CHK_RESIZESMILEYS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,134,54,154,10 + CONTROL "Use protocol smileys",IDC_CHK_USEPROTOSMILEYS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,134,36,154,10 + CONTROL "Replace only isolated smileys",IDC_CHK_ONLYISOLATED, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,134,72,154,10 + CONTROL "Retrieve new status message",IDC_CHK_GETSTATUSMSG, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,123,273,10 + CONTROL "Show tooltip after all content is ready (avatar && status message)",IDC_CHK_WAITFORCONTENT, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,108,273,10 + GROUPBOX "Status bar and tray tooltip",IDC_STATIC,7,176,284,46 + CONTROL "Limit status messages in status bar and tray tooltips to:",IDC_CHK_LIMITMSG, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,189,273,10 + EDITTEXT IDC_ED_CHARCOUNT,26,203,36,12,ES_AUTOHSCROLL + CONTROL "",IDC_SPIN_CHARCOUNT,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,52,200,11,14 + LTEXT "characters",IDC_STATIC,69,205,218,8 + CONTROL "Disable in invisible status",IDC_CHK_DISABLEINVISIBLE, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,27,138,258,10 +END + +IDD_OPT_SKIN DIALOGEX 0, 0, 300, 230 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + GROUPBOX "Skins",IDC_STATIC,5,4,289,125 + EDITTEXT IDC_ED_TRANS,252,193,33,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT + CONTROL "",IDC_SPIN_TRANS,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,277,193,11,12 + RTEXT "Opacity(%):",IDC_STATIC,157,196,90,8,0,WS_EX_RIGHT + GROUPBOX "Transparency",IDC_STATIC,152,185,142,39 + GROUPBOX "Effects",IDC_STATIC,7,133,140,91 + CONTROL "Border",IDC_CHK_BORDER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,194,126,9,WS_EX_RIGHT + CONTROL "Shadow",IDC_CHK_SHADOW,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,181,126,9,WS_EX_RIGHT + CONTROL "Round corners (window)",IDC_CHK_ROUNDCORNERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,207,126,9,WS_EX_RIGHT + COMBOBOX IDC_CMB_EFFECT,16,145,122,69,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + CONTROL "Aero Glass (Vista+)",IDC_CHK_AEROGLASS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,155,211,129,9,WS_EX_RIGHT + RTEXT "Animation speed:",IDC_STATIC,11,164,90,8,0,WS_EX_RIGHT + EDITTEXT IDC_ED_SPEED,105,162,33,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT + CONTROL "",IDC_SPIN_SPEED,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,128,162,11,12 + LISTBOX IDC_LB_SKINS,16,16,87,91,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + GROUPBOX "Preview",IDC_STATIC,112,12,174,110 + CONTROL "",IDC_PIC_PREVIEW,"Static",SS_OWNERDRAW,119,24,159,92 + CTEXT "No preview",IDC_ST_PREVIEW,172,63,56,8 + GROUPBOX "Skin option",IDC_STATIC,152,133,142,49 + CONTROL "Load fonts and colors",IDC_CHK_LOADFONTS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,168,130,10 + CONTROL "Enable skin coloring",IDC_CHK_ENABLECOLORING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,144,130,10 + CONTROL "Reload skin list",IDC_BTN_RELOADLIST,"MButtonClass",WS_TABSTOP,34,111,16,14 + CONTROL "Apply skin",IDC_BTN_APPLYSKIN,"MButtonClass",WS_TABSTOP,16,111,16,14 + CONTROL "Load tooltip proportions",IDC_CHK_LOADPROPORTIONS, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,156,130,10 + CONTROL "Get more skins",IDC_BTN_GETSKINS,"MButtonClass",WS_TABSTOP,87,111,16,14 +END + +IDD_OPT_TRAYTIP DIALOGEX 0, 0, 300, 230 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + CONTROL "",IDC_TREE_FIRST_PROTOS,"SysTreeView32",TVS_NOTOOLTIPS | TVS_NOHSCROLL | WS_BORDER | WS_TABSTOP,17,66,120,60 + CONTROL "Enable tray tooltips",IDC_CHK_ENABLETRAYTIP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,14,142,10 + CONTROL "Handle tray tooltips by Tipper",IDC_CHK_HANDLEBYTIPPER, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,25,142,10 + CONTROL "",IDC_TREE_SECOND_ITEMS,"SysTreeView32",TVS_NOTOOLTIPS | TVS_NOHSCROLL | WS_BORDER | WS_TABSTOP,161,133,120,72 + PUSHBUTTON "Favourite contacts",IDC_BTN_FAVCONTACTS,93,218,113,12 + CONTROL "Expand to second level after:",IDC_CHK_EXPAND,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,162,14,128,10 + EDITTEXT IDC_ED_EXPANDTIME,171,29,37,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT + CONTROL "",IDC_SPIN_EXPANDTIME,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,198,28,11,12 + LTEXT "ms",IDC_STATIC,214,31,53,8 + CONTROL "",IDC_TREE_SECOND_PROTOS,"SysTreeView32",TVS_NOTOOLTIPS | TVS_NOHSCROLL | WS_BORDER | WS_TABSTOP,161,66,120,60 + CONTROL "",IDC_TREE_FIRST_ITEMS,"SysTreeView32",TVS_NOTOOLTIPS | TVS_NOHSCROLL | WS_BORDER | WS_TABSTOP,17,133,120,72 + GROUPBOX "Options",IDC_STATIC,7,3,285,47 + GROUPBOX "First level tooltip",IDC_STATIC,7,52,140,161 + GROUPBOX "Second level tooltip",IDC_STATIC,152,52,140,161 + CONTROL "Hide offline protocols",IDC_CHK_HIDEOFFLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,36,142,10 +END + +IDD_FAVCONTACTS DIALOGEX 0, 0, 140, 213 +STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Favourite contacts" +FONT 8, "Tahoma", 400, 0, 0xEE +BEGIN + DEFPUSHBUTTON "OK",IDC_BTN_OK,74,192,50,14 + PUSHBUTTON "Cancel",IDC_BTN_CANCEL,15,192,50,14 + CONTROL "",IDC_CLIST,"CListControl",WS_TABSTOP | 0x68,5,7,128,152,WS_EX_CLIENTEDGE + CONTROL "Hide offline",IDC_CHK_HIDEOFFLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,164,124,10 + CONTROL "Append protocol name",IDC_CHK_APPENDPROTO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,176,124,10 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_OPT_APPEARANCE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 293 + TOPMARGIN, 7 + BOTTOMMARGIN, 223 + END + + IDD_SUBST, DIALOG + BEGIN + LEFTMARGIN, 13 + RIGHTMARGIN, 212 + TOPMARGIN, 7 + BOTTOMMARGIN, 189 + END + + IDD_ITEM, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 218 + TOPMARGIN, 7 + BOTTOMMARGIN, 200 + END + + IDD_OPT_CONTENT, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 293 + TOPMARGIN, 7 + BOTTOMMARGIN, 223 + END + + IDD_OPT_EXTRA, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 293 + TOPMARGIN, 7 + BOTTOMMARGIN, 223 + END + + IDD_OPT_SKIN, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 293 + TOPMARGIN, 7 + BOTTOMMARGIN, 223 + END + + IDD_OPT_TRAYTIP, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 293 + TOPMARGIN, 7 + BOTTOMMARGIN, 223 + END + + IDD_FAVCONTACTS, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 133 + TOPMARGIN, 7 + BOTTOMMARGIN, 206 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_ITEM ICON "copy_item.ico" +IDI_ITEM_ALL ICON "copy_all_items.ico" +IDI_UP ICON "arrow_up.ico" +IDI_DOWN ICON "arrow_down.ico" +IDI_SEPARATOR ICON "separator.ico" +IDI_RELOAD ICON "reload.ico" +IDI_APPLY ICON "apply.ico" +#endif // Czech (Czech Republic) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\\src\\resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/TipperYM/res/version.rc b/plugins/TipperYM/res/version.rc new file mode 100644 index 0000000000..724de5240a --- /dev/null +++ b/plugins/TipperYM/res/version.rc @@ -0,0 +1,40 @@ +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + +#include +#include "..\src\version.h" + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __FILEVERSION_STRING + PRODUCTVERSION __FILEVERSION_STRING + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "Author", "Scott Ellis, yaho" + VALUE "CompanyName", "yaho" + VALUE "FileDescription", "Tool Tip notification windows" + VALUE "FileVersion", __VERSION_STRING + VALUE "InternalName", "Tipper YM" + VALUE "LegalCopyright", "(c) 2005-2007 Scott Ellis, 2007-2011 Jan Holub" + VALUE "OriginalFilename", "tipper.dll" + VALUE "ProductName", "Tipper YM" + VALUE "ProductVersion", __VERSION_STRING + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END diff --git a/plugins/TipperYM/resource.h b/plugins/TipperYM/resource.h deleted file mode 100644 index 0e850b25ea..0000000000 --- a/plugins/TipperYM/resource.h +++ /dev/null @@ -1,137 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by resource.rc -// -#define IDD_OPT_APPEARANCE 101 -#define IDD_SUBST 103 -#define IDD_ITEM 104 -#define IDD_OPT_CONTENT 105 -#define IDD_OPT_SKIN 106 -#define IDI_ITEM 107 -#define IDI_ITEM_ALL 108 -#define IDD_OPT_EXTRA 109 -#define IDD_OPT_TRAYTIP 110 -#define IDD_FAVCONTACTS 111 -#define IDI_UP 112 -#define IDI_DOWN 113 -#define IDI_SEPARATOR 114 -#define IDI_RELOAD 116 -#define IDI_APPLY 117 -#define IDC_ED_WIDTH 1005 -#define IDC_ED_MAXHEIGHT 1006 -#define IDC_SPIN_WIDTH 1007 -#define IDC_SPIN_MAXHEIGHT 1008 -#define IDC_ED_INDENT 1009 -#define IDC_SPIN_INDENT 1010 -#define IDC_ED_PADDING 1011 -#define IDC_SPIN_PADDING 1012 -#define IDC_ED_TRANS 1013 -#define IDC_SPIN_TRANS 1014 -#define IDC_CHK_BORDER 1015 -#define IDC_CHK_ROUNDCORNERS 1016 -#define IDC_ED_MINWIDTH 1017 -#define IDC_ED_SPEED 1017 -#define IDC_CHK_AEROGLASS 1018 -#define IDC_SPIN_SPEED 1019 -#define IDC_CHK_SHADOW 1020 -#define IDC_SPIN_MINWIDTH 1021 -#define IDC_ED_MINHEIGHT 1022 -#define IDC_SPIN_MINHEIGHT 1023 -#define IDC_ED_SBWIDTH 1024 -#define IDC_SPIN_SBWIDTH 1025 -#define IDC_ED_TEXTPADDING 1026 -#define IDC_ED_AVSIZE 1027 -#define IDC_SPIN_AVSIZE 1028 -#define IDC_ED_HOVER 1029 -#define IDC_SPIN_HOVER 1030 -#define IDC_SPIN_TEXTPADDING 1031 -#define IDC_CMB_ICON 1032 -#define IDC_CMB_AV 1033 -#define IDC_CMB_POS 1034 -#define IDC_ED_OUTAVPADDING 1035 -#define IDC_BTN_ADD 1036 -#define IDC_SPIN_OUTAVPADDING 1036 -#define IDC_BTN_REMOVE 1037 -#define IDC_CHK_ROUNDCORNERSAV 1037 -#define IDC_BTN_UP 1038 -#define IDC_CHK_ORIGINALAVSIZE 1038 -#define IDC_BTN_DOWN 1039 -#define IDC_CHK_AVBORDER 1039 -#define IDC_CHK_NOFOCUS 1040 -#define IDC_BTN_ADD2 1040 -#define IDC_BTN_EDIT 1041 -#define IDC_ED_TITLEINDENT 1041 -#define IDC_LST_SUBST 1042 -#define IDC_SPIN_TITLEINDENT 1042 -#define IDC_ED_VALUEINDENT 1043 -#define IDC_BTN_REMOVE2 1043 -#define IDC_ED_MODULE 1044 -#define IDC_SPIN_VALUEINDENT 1044 -#define IDC_BTN_EDIT2 1044 -#define IDC_CHK_PROTOMOD 1045 -#define IDC_ED_INAVPADDING 1045 -#define IDC_BTN_SEPARATOR 1045 -#define IDC_ED_SETTING 1046 -#define IDC_SPIN_INAVPADDING 1046 -#define IDC_CMB_TRANSLATE 1047 -#define IDC_ED_LABEL 1048 -#define IDC_CHK_SBAR 1048 -#define IDC_ED_VALUE 1050 -#define IDC_CHK_LINEABOVE 1051 -#define IDC_CHK_VALNEWLINE 1052 -#define IDC_CMB_LV 1053 -#define IDC_CHK_PARSETIPPERFIRST 1053 -#define IDC_CMB_VV 1054 -#define IDC_CMB_LH 1055 -#define IDC_CMB_VH 1056 -#define IDC_CHK_DISABLEINVISIBLE 1059 -#define IDC_CHK_RETRIEVEXSTATUS 1060 -#define IDC_TREE_EXTRAICONS 1061 -#define IDC_CHK_ENABLESMILEYS 1062 -#define IDC_CHK_RESIZESMILEYS 1063 -#define IDC_CHK_GETSTATUSMSG 1064 -#define IDC_CHK_WAITFORCONTENT 1065 -#define IDC_STATIC_AVATARSIZE 1085 -#define IDC_CMB_EFFECT 1086 -#define IDC_TREE_FIRST_PROTOS 1087 -#define IDC_CHK_ENABLETRAYTIP 1088 -#define IDC_CHK_HANDLEBYTIPPER 1089 -#define IDC_TREE_SECOND_PROTOS 1090 -#define IDC_TREE_SECOND_ITEMS 1094 -#define IDC_TREE_FIRST_ITEMS 1095 -#define IDC_BTN_FAVCONTACTS 1096 -#define IDC_CHK_EXPAND 1097 -#define IDC_ED_EXPANDTIME 1098 -#define IDC_SPIN_EXPANDTIME 1099 -#define IDC_CLIST 1101 -#define IDC_BTN_OK 1102 -#define IDC_BTN_CANCEL 1103 -#define IDC_CHK_HIDEOFFLINE 1104 -#define IDC_CHK_APPENDPROTO 1105 -#define IDC_CHK_USEPROTOSMILEYS 1106 -#define IDC_CHK_ONLYISOLATED 1107 -#define IDC_CMB_PRESETITEMS 1111 -#define IDC_CHK_LIMITMSG 1113 -#define IDC_ED_CHARCOUNT 1114 -#define IDC_SPIN_CHARCOUNT 1115 -#define IDC_LB_SKINS 1116 -#define IDC_PIC_PREVIEW 1117 -#define IDC_ST_PREVIEW 1119 -#define IDC_CHK_LOADFONTS 1120 -#define IDC_CHK_ENABLECOLORING 1121 -#define IDC_CHK_LOADPROPORTIONS 1122 -#define IDC_BTN_RELOADLIST 1123 -#define IDC_BTN_APPLYSKIN 1124 -#define IDC_BTN_VARIABLE 1125 -#define IDC_BTN_GETSKINS 1125 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 118 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1127 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/plugins/TipperYM/resource.rc b/plugins/TipperYM/resource.rc deleted file mode 100644 index d289b911ba..0000000000 --- a/plugins/TipperYM/resource.rc +++ /dev/null @@ -1,386 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Czech (Czech Republic) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CSY) -LANGUAGE LANG_CZECH, SUBLANG_DEFAULT -#pragma code_page(1250) - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_OPT_APPEARANCE DIALOGEX 0, 0, 300, 230 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - EDITTEXT IDC_ED_WIDTH,249,17,36,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT - CONTROL "",IDC_SPIN_WIDTH,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,277,17,11,12 - EDITTEXT IDC_ED_MAXHEIGHT,249,45,36,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT - CONTROL "",IDC_SPIN_MAXHEIGHT,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,277,45,11,12 - GROUPBOX "Options",IDC_STATIC,159,142,135,78 - GROUPBOX "Layout",IDC_STATIC,5,6,150,165 - EDITTEXT IDC_ED_AVSIZE,249,73,36,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT - CONTROL "",IDC_SPIN_AVSIZE,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,277,73,11,12 - COMBOBOX IDC_CMB_ICON,14,31,133,69,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_CMB_AV,14,45,133,76,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - EDITTEXT IDC_ED_INDENT,117,65,30,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT - CONTROL "",IDC_SPIN_INDENT,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,135,65,11,12 - RTEXT "Text indent:",IDC_STATIC,9,68,104,8 - GROUPBOX "Window",IDC_STATIC,159,6,135,133 - RTEXT "Max width:",IDC_STATIC,165,20,80,8,0,WS_EX_RIGHT - RTEXT "Max height:",IDC_STATIC,165,48,80,8,0,WS_EX_RIGHT - RTEXT "Avatar size:",IDC_STATIC_AVATARSIZE,165,76,80,8,0,WS_EX_RIGHT - CONTROL "Show if list not focused",IDC_CHK_NOFOCUS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,166,122,125,11 - EDITTEXT IDC_ED_PADDING,117,107,30,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT - CONTROL "",IDC_SPIN_PADDING,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,135,107,11,12 - RTEXT "General padding:",IDC_STATIC,9,110,104,8 - EDITTEXT IDC_ED_HOVER,249,101,36,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT - CONTROL "",IDC_SPIN_HOVER,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,277,101,11,12 - RTEXT "Hover time:",IDC_STATIC,165,104,80,8,0,WS_EX_RIGHT - COMBOBOX IDC_CMB_POS,14,17,133,69,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - CONTROL "Status bar tips",IDC_CHK_SBAR,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,166,153,125,11 - GROUPBOX "Alignment",IDC_STATIC,5,175,150,45 - COMBOBOX IDC_CMB_LV,57,186,43,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_CMB_VV,57,202,43,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_CMB_LH,104,186,43,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_CMB_VH,104,202,43,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - RTEXT "Labels:",IDC_STATIC,10,188,44,8 - RTEXT "Values:",IDC_STATIC,10,204,44,8 - EDITTEXT IDC_ED_MINWIDTH,249,31,36,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT - CONTROL "",IDC_SPIN_MINWIDTH,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,277,31,11,12 - RTEXT "Min width:",IDC_STATIC,165,34,80,8,0,WS_EX_RIGHT - EDITTEXT IDC_ED_MINHEIGHT,249,59,36,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT - CONTROL "",IDC_SPIN_MINHEIGHT,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,277,59,11,12 - RTEXT "Min height:",IDC_STATIC,165,62,80,8,0,WS_EX_RIGHT - EDITTEXT IDC_ED_SBWIDTH,249,87,36,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT - CONTROL "",IDC_SPIN_SBWIDTH,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,277,87,11,12 - RTEXT "Sidebar width:",IDC_STATIC,165,90,80,8 - EDITTEXT IDC_ED_TEXTPADDING,117,121,30,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT - CONTROL "",IDC_SPIN_TEXTPADDING,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,135,121,11,12 - RTEXT "Text padding:",IDC_STATIC,9,124,104,8 - EDITTEXT IDC_ED_OUTAVPADDING,117,135,30,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT - CONTROL "",IDC_SPIN_OUTAVPADDING,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,135,135,11,12 - RTEXT "Outer avatar padding:",IDC_STATIC,9,138,104,8 - CONTROL "Round corners (avatar)",IDC_CHK_ROUNDCORNERSAV,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,166,187,125,11 - CONTROL "Keep original avatar size",IDC_CHK_ORIGINALAVSIZE, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,166,204,125,11 - CONTROL "Avatar border",IDC_CHK_AVBORDER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,166,170,125,11 - EDITTEXT IDC_ED_TITLEINDENT,117,79,30,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT - CONTROL "",IDC_SPIN_TITLEINDENT,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,135,79,11,12 - RTEXT "Title indent:",IDC_STATIC,9,82,104,8 - EDITTEXT IDC_ED_VALUEINDENT,117,94,30,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT - CONTROL "",IDC_SPIN_VALUEINDENT,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,135,94,11,12 - RTEXT "Value indent:",IDC_STATIC,9,97,104,8 - EDITTEXT IDC_ED_INAVPADDING,117,150,30,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT - CONTROL "",IDC_SPIN_INAVPADDING,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,135,150,11,12 - RTEXT "Inner avatar padding:",IDC_STATIC,9,153,104,8 -END - -IDD_SUBST DIALOGEX 0, 0, 225, 196 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Substitution" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - LTEXT "Label:",IDC_STATIC,14,10,198,8 - EDITTEXT IDC_ED_LABEL,13,23,198,13,ES_AUTOHSCROLL - CONTROL "Contact protocol module",IDC_CHK_PROTOMOD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,74,198,10 - LTEXT "Module:",IDC_STATIC,14,47,198,8 - EDITTEXT IDC_ED_MODULE,13,58,198,13,ES_AUTOHSCROLL - LTEXT "Setting or prefix:",IDC_STATIC,14,90,198,8 - EDITTEXT IDC_ED_SETTING,13,103,198,13,ES_AUTOHSCROLL - LTEXT "Translation:",IDC_STATIC,14,131,198,8 - COMBOBOX IDC_CMB_TRANSLATE,13,144,198,104,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP - DEFPUSHBUTTON "OK",IDOK,59,172,50,14 - PUSHBUTTON "Cancel",IDCANCEL,117,172,50,14 -END - -IDD_ITEM DIALOGEX 0, 0, 225, 207 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Item" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - LTEXT "Label:",IDC_STATIC,14,10,195,8 - LTEXT "Value:",IDC_STATIC,14,47,198,8 - EDITTEXT IDC_ED_LABEL,13,23,198,13,ES_AUTOHSCROLL - EDITTEXT IDC_ED_VALUE,13,58,198,45,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN - CONTROL "Draw a line above",IDC_CHK_LINEABOVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,110,173,10 - CONTROL "Value on a new line",IDC_CHK_VALNEWLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,122,198,10 - DEFPUSHBUTTON "OK",IDOK,58,185,50,14 - PUSHBUTTON "Cancel",IDCANCEL,116,185,50,14 - COMBOBOX IDC_CMB_PRESETITEMS,13,161,198,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP - LTEXT "Preset items:",IDC_STATIC,14,151,198,8 - CONTROL "Variables",IDC_BTN_VARIABLE,"MButtonClass",WS_TABSTOP,194,108,16,14 - CONTROL "Parse Tipper variables first",IDC_CHK_PARSETIPPERFIRST, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,134,198,10 -END - -IDD_OPT_CONTENT DIALOGEX 0, 0, 300, 230 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE | WS_SYSMENU -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - GROUPBOX "Items",IDC_STATIC,5,4,142,216 - GROUPBOX "Substitutions",IDC_STATIC,151,4,142,216 - LISTBOX IDC_LST_SUBST,158,17,128,180,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP - CONTROL "Add",IDC_BTN_ADD,"MButtonClass",WS_TABSTOP,12,201,16,14 - CONTROL "Remove",IDC_BTN_REMOVE,"MButtonClass",WS_TABSTOP,60,201,16,14 - CONTROL "Up",IDC_BTN_UP,"MButtonClass",WS_TABSTOP,108,201,16,14 - CONTROL "Down",IDC_BTN_DOWN,"MButtonClass",WS_TABSTOP,124,201,16,14 - CONTROL "Edit",IDC_BTN_EDIT,"MButtonClass",WS_TABSTOP,44,201,16,14 - CONTROL "Add",IDC_BTN_ADD2,"MButtonClass",WS_TABSTOP,158,201,16,14 - CONTROL "Remove",IDC_BTN_REMOVE2,"MButtonClass",WS_TABSTOP,173,201,16,14 - CONTROL "Edit",IDC_BTN_EDIT2,"MButtonClass",WS_TABSTOP,189,201,16,14 - CONTROL "",IDC_TREE_FIRST_ITEMS,"SysTreeView32",TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | TVS_FULLROWSELECT | TVS_NOHSCROLL | WS_BORDER | WS_TABSTOP,12,17,128,180 - CONTROL "Separator",IDC_BTN_SEPARATOR,"MButtonClass",WS_TABSTOP,28,201,16,14 -END - -IDD_OPT_EXTRA DIALOGEX 0, 0, 300, 230 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - GROUPBOX "Advanced options",IDC_STATIC,7,96,284,74 - CONTROL "Retrieve XStatus details if auto-retrieve is disabled",IDC_CHK_RETRIEVEXSTATUS, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,153,273,10 - CONTROL "",IDC_TREE_EXTRAICONS,"SysTreeView32",TVS_NOTOOLTIPS | TVS_NOSCROLL | TVS_FULLROWSELECT | WS_BORDER | WS_HSCROLL | WS_TABSTOP,15,18,98,66 - GROUPBOX "Extra icons",IDC_STATIC,7,7,114,84 - GROUPBOX "Smileys support",IDC_STATIC,127,7,164,84 - CONTROL "Enable SmileyAdd support",IDC_CHK_ENABLESMILEYS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,134,18,154,10 - CONTROL "Resize smileys",IDC_CHK_RESIZESMILEYS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,134,54,154,10 - CONTROL "Use protocol smileys",IDC_CHK_USEPROTOSMILEYS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,134,36,154,10 - CONTROL "Replace only isolated smileys",IDC_CHK_ONLYISOLATED, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,134,72,154,10 - CONTROL "Retrieve new status message",IDC_CHK_GETSTATUSMSG, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,123,273,10 - CONTROL "Show tooltip after all content is ready (avatar && status message)",IDC_CHK_WAITFORCONTENT, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,108,273,10 - GROUPBOX "Status bar and tray tooltip",IDC_STATIC,7,176,284,46 - CONTROL "Limit status messages in status bar and tray tooltips to:",IDC_CHK_LIMITMSG, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,189,273,10 - EDITTEXT IDC_ED_CHARCOUNT,26,203,36,12,ES_AUTOHSCROLL - CONTROL "",IDC_SPIN_CHARCOUNT,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,52,200,11,14 - LTEXT "characters",IDC_STATIC,69,205,218,8 - CONTROL "Disable in invisible status",IDC_CHK_DISABLEINVISIBLE, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,27,138,258,10 -END - -IDD_OPT_SKIN DIALOGEX 0, 0, 300, 230 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - GROUPBOX "Skins",IDC_STATIC,5,4,289,125 - EDITTEXT IDC_ED_TRANS,252,193,33,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT - CONTROL "",IDC_SPIN_TRANS,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,277,193,11,12 - RTEXT "Opacity(%):",IDC_STATIC,157,196,90,8,0,WS_EX_RIGHT - GROUPBOX "Transparency",IDC_STATIC,152,185,142,39 - GROUPBOX "Effects",IDC_STATIC,7,133,140,91 - CONTROL "Border",IDC_CHK_BORDER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,194,126,9,WS_EX_RIGHT - CONTROL "Shadow",IDC_CHK_SHADOW,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,181,126,9,WS_EX_RIGHT - CONTROL "Round corners (window)",IDC_CHK_ROUNDCORNERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,207,126,9,WS_EX_RIGHT - COMBOBOX IDC_CMB_EFFECT,16,145,122,69,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - CONTROL "Aero Glass (Vista+)",IDC_CHK_AEROGLASS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,155,211,129,9,WS_EX_RIGHT - RTEXT "Animation speed:",IDC_STATIC,11,164,90,8,0,WS_EX_RIGHT - EDITTEXT IDC_ED_SPEED,105,162,33,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT - CONTROL "",IDC_SPIN_SPEED,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,128,162,11,12 - LISTBOX IDC_LB_SKINS,16,16,87,91,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP - GROUPBOX "Preview",IDC_STATIC,112,12,174,110 - CONTROL "",IDC_PIC_PREVIEW,"Static",SS_OWNERDRAW,119,24,159,92 - CTEXT "No preview",IDC_ST_PREVIEW,172,63,56,8 - GROUPBOX "Skin option",IDC_STATIC,152,133,142,49 - CONTROL "Load fonts and colors",IDC_CHK_LOADFONTS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,168,130,10 - CONTROL "Enable skin coloring",IDC_CHK_ENABLECOLORING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,144,130,10 - CONTROL "Reload skin list",IDC_BTN_RELOADLIST,"MButtonClass",WS_TABSTOP,34,111,16,14 - CONTROL "Apply skin",IDC_BTN_APPLYSKIN,"MButtonClass",WS_TABSTOP,16,111,16,14 - CONTROL "Load tooltip proportions",IDC_CHK_LOADPROPORTIONS, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,156,130,10 - CONTROL "Get more skins",IDC_BTN_GETSKINS,"MButtonClass",WS_TABSTOP,87,111,16,14 -END - -IDD_OPT_TRAYTIP DIALOGEX 0, 0, 300, 230 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - CONTROL "",IDC_TREE_FIRST_PROTOS,"SysTreeView32",TVS_NOTOOLTIPS | TVS_NOHSCROLL | WS_BORDER | WS_TABSTOP,17,66,120,60 - CONTROL "Enable tray tooltips",IDC_CHK_ENABLETRAYTIP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,14,142,10 - CONTROL "Handle tray tooltips by Tipper",IDC_CHK_HANDLEBYTIPPER, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,25,142,10 - CONTROL "",IDC_TREE_SECOND_ITEMS,"SysTreeView32",TVS_NOTOOLTIPS | TVS_NOHSCROLL | WS_BORDER | WS_TABSTOP,161,133,120,72 - PUSHBUTTON "Favourite contacts",IDC_BTN_FAVCONTACTS,93,218,113,12 - CONTROL "Expand to second level after:",IDC_CHK_EXPAND,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,162,14,128,10 - EDITTEXT IDC_ED_EXPANDTIME,171,29,37,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT - CONTROL "",IDC_SPIN_EXPANDTIME,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,198,28,11,12 - LTEXT "ms",IDC_STATIC,214,31,53,8 - CONTROL "",IDC_TREE_SECOND_PROTOS,"SysTreeView32",TVS_NOTOOLTIPS | TVS_NOHSCROLL | WS_BORDER | WS_TABSTOP,161,66,120,60 - CONTROL "",IDC_TREE_FIRST_ITEMS,"SysTreeView32",TVS_NOTOOLTIPS | TVS_NOHSCROLL | WS_BORDER | WS_TABSTOP,17,133,120,72 - GROUPBOX "Options",IDC_STATIC,7,3,285,47 - GROUPBOX "First level tooltip",IDC_STATIC,7,52,140,161 - GROUPBOX "Second level tooltip",IDC_STATIC,152,52,140,161 - CONTROL "Hide offline protocols",IDC_CHK_HIDEOFFLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,36,142,10 -END - -IDD_FAVCONTACTS DIALOGEX 0, 0, 140, 213 -STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Favourite contacts" -FONT 8, "Tahoma", 400, 0, 0xEE -BEGIN - DEFPUSHBUTTON "OK",IDC_BTN_OK,74,192,50,14 - PUSHBUTTON "Cancel",IDC_BTN_CANCEL,15,192,50,14 - CONTROL "",IDC_CLIST,"CListControl",WS_TABSTOP | 0x68,5,7,128,152,WS_EX_CLIENTEDGE - CONTROL "Hide offline",IDC_CHK_HIDEOFFLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,164,124,10 - CONTROL "Append protocol name",IDC_CHK_APPENDPROTO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,176,124,10 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_OPT_APPEARANCE, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 293 - TOPMARGIN, 7 - BOTTOMMARGIN, 223 - END - - IDD_SUBST, DIALOG - BEGIN - LEFTMARGIN, 13 - RIGHTMARGIN, 212 - TOPMARGIN, 7 - BOTTOMMARGIN, 189 - END - - IDD_ITEM, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 218 - TOPMARGIN, 7 - BOTTOMMARGIN, 200 - END - - IDD_OPT_CONTENT, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 293 - TOPMARGIN, 7 - BOTTOMMARGIN, 223 - END - - IDD_OPT_EXTRA, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 293 - TOPMARGIN, 7 - BOTTOMMARGIN, 223 - END - - IDD_OPT_SKIN, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 293 - TOPMARGIN, 7 - BOTTOMMARGIN, 223 - END - - IDD_OPT_TRAYTIP, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 293 - TOPMARGIN, 7 - BOTTOMMARGIN, 223 - END - - IDD_FAVCONTACTS, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 133 - TOPMARGIN, 7 - BOTTOMMARGIN, 206 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_ITEM ICON "res\\copy_item.ico" -IDI_ITEM_ALL ICON "res\\copy_all_items.ico" -IDI_UP ICON "res\\arrow_up.ico" -IDI_DOWN ICON "res\\arrow_down.ico" -IDI_SEPARATOR ICON "res\\separator.ico" -IDI_RELOAD ICON "res\\reload.ico" -IDI_APPLY ICON "res\\apply.ico" -#endif // Czech (Czech Republic) resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// English (United States) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - -#endif // English (United States) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/plugins/TipperYM/skin_parser.cpp b/plugins/TipperYM/skin_parser.cpp deleted file mode 100644 index 3c851e0039..0000000000 --- a/plugins/TipperYM/skin_parser.cpp +++ /dev/null @@ -1,417 +0,0 @@ -/* -Copyright (C) 2006-2007 Scott Ellis -Copyright (C) 2007-2011 Jan Holub - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this file; see the file license.txt. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. -*/ - -#include "common.h" -#include "options.h" -#include "str_utils.h" - -extern TCHAR SKIN_FOLDER[256]; - -int RefreshSkinList(HWND hwndDlg) -{ - HWND hwndSkins = GetDlgItem(hwndDlg, IDC_LB_SKINS); - ListBox_ResetContent(hwndSkins); - ListBox_AddString(hwndSkins, TranslateT("# Solid color fill")); - - TCHAR szDirSave[1024]; - GetCurrentDirectory(1024, szDirSave); - SetCurrentDirectory(SKIN_FOLDER); - - WIN32_FIND_DATA ffd; - HANDLE hFind = FindFirstFile(_T("*.*"), &ffd); - while (hFind != INVALID_HANDLE_VALUE) - { - if ((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && _tcscmp(_T("."), ffd.cFileName) && _tcscmp(_T(".."), ffd.cFileName)) - { - SetCurrentDirectory(ffd.cFileName); - WIN32_FIND_DATA ffd2; - HANDLE hFindFile = FindFirstFile(_T("*.tsf"), &ffd2); - if (hFindFile != INVALID_HANDLE_VALUE) - ListBox_AddString(hwndSkins, ffd.cFileName); - - FindClose(hFindFile); - SetCurrentDirectory(_T("..")); - } - - if (!FindNextFile(hFind, &ffd)) - break; - } - - FindClose(hFind); - SetCurrentDirectory(szDirSave); - - return ListBox_SelectString(GetDlgItem(hwndDlg, IDC_LB_SKINS), -1, opt.szSkinName); -} - -bool FileExists(TCHAR *filename) -{ - HANDLE hFile = CreateFile(filename, 0, 0, 0, OPEN_EXISTING, 0, 0); - if (hFile != INVALID_HANDLE_VALUE) - { - CloseHandle(hFile); - return true; - } - - return false; -} - -void ParseAboutPart(FILE *fp, TCHAR *buff, TCHAR *szSkinName) -{ - myfgets(buff, 1024, fp); - while (buff[0] != '[') - { - if (buff[0] != ';') - { - TCHAR *pch = _tcschr(buff, '='); - if (pch++) - { - while (pch && (*pch == ' ' || *pch == '\t')) - pch++; - - if (pch) - { - if (_tcsstr(buff, _T("author"))) - {} - else if (_tcsstr(buff, _T("preview"))) - { - TCHAR szImgPath[1024]; - mir_sntprintf(szImgPath, SIZEOF(szImgPath), _T("%s\\%s\\%s"), SKIN_FOLDER, szSkinName, pch); - if (FileExists(szImgPath)) - _tcscpy(opt.szPreviewFile, szImgPath); - } - } - } - } - - if (feof(fp)) break; - myfgets(buff, 1024, fp); - } -} - -void ParseImagePart(FILE *fp, TCHAR *buff, int iPart) -{ - opt.szImgFile[iPart] = NULL; - opt.transfMode[iPart] = TM_NONE; - opt.margins[iPart].left = 0; - opt.margins[iPart].top = 0; - opt.margins[iPart].right = 0; - opt.margins[iPart].bottom = 0; - - myfgets(buff, 1024, fp); - while (buff[0] != '[') - { - if (buff[0] != ';') - { - TCHAR *pch = _tcschr(buff, '='); - if (pch++) - { - while (pch && (*pch == ' ' || *pch == '\t')) - pch++; - - if (pch) - { - if (_tcsstr(buff, _T("image"))) - { - TCHAR szImgPath[1024]; - mir_sntprintf(szImgPath, SIZEOF(szImgPath), _T("%s\\%s\\%s"), SKIN_FOLDER, opt.szSkinName, pch); - opt.szImgFile[iPart] = mir_tstrdup(szImgPath); - } - else if (_tcsstr(buff, _T("tm"))) - { - if (!lstrcmpi(pch, _T("TM_NONE"))) - opt.transfMode[iPart] = TM_NONE; - else if (!lstrcmpi(pch, _T("TM_CENTRE"))) - opt.transfMode[iPart] = TM_CENTRE; - else if (!lstrcmpi(pch, _T("TM_STRECH_ALL"))) - opt.transfMode[iPart] = TM_STRECH_ALL; - else if (!lstrcmpi(pch, _T("TM_STRECH_HORIZONTAL"))) - opt.transfMode[iPart] = TM_STRECH_HORIZONTAL; - else if (!lstrcmpi(pch, _T("TM_STRECH_VERTICAL"))) - opt.transfMode[iPart] = TM_STRECH_VERTICAL; - else if (!lstrcmpi(pch, _T("TM_TILE_ALL"))) - opt.transfMode[iPart] = TM_TILE_ALL; - else if (!lstrcmpi(pch, _T("TM_TILE_HORIZONTAL"))) - opt.transfMode[iPart] = TM_TILE_HORIZONTAL; - else if (!lstrcmpi(pch, _T("TM_TILE_VERTICAL"))) - opt.transfMode[iPart] = TM_TILE_VERTICAL; - else - opt.transfMode[iPart] = TM_NONE; - } - else if (_tcsstr(buff, _T("left"))) - opt.margins[iPart].left = _ttoi(pch); - else if (_tcsstr(buff, _T("top"))) - opt.margins[iPart].top = _ttoi(pch); - else if (_tcsstr(buff, _T("right"))) - opt.margins[iPart].right = _ttoi(pch); - else if (_tcsstr(buff, _T("bottom"))) - opt.margins[iPart].bottom = _ttoi(pch); - } - } - } - - if (feof(fp)) break; - myfgets(buff, 1024, fp); - } -} - -char *GetSettingName(TCHAR *szValue, char *szPostfix, char *buff) -{ - buff[0] = 0; - - if (_tcsstr(szValue, _T("traytitle"))) - mir_snprintf(buff, 64, "FontTrayTitle%s", szPostfix); - else if (_tcsstr(szValue, _T("title"))) - mir_snprintf(buff, 64, "FontFirst%s", szPostfix); - else if (_tcsstr(szValue, _T("label"))) - mir_snprintf(buff, 64, "FontLabels%s", szPostfix); - else if (_tcsstr(szValue, _T("value"))) - mir_snprintf(buff, 64, "FontValues%s", szPostfix); - else if (_tcsstr(szValue, _T("divider"))) - mir_snprintf(buff, 64, "Divider%s", szPostfix); - - if (buff[0]) return buff; - else return NULL; -} - -void ParseFontPart(FILE *fp, TCHAR *buff) -{ - char szSetting[64]; - - myfgets(buff, 1024, fp); - while (buff[0] != '[') - { - if (buff[0] != ';') - { - TCHAR *pch = _tcschr(buff, '='); - if (pch++) - { - while (pch && (*pch == ' ' || *pch == '\t')) - pch++; - - if (pch) - { - if (_tcsstr(buff, _T("face"))) - { - if (GetSettingName(buff, "", szSetting)) - { - if (_tcslen(pch) > 32) - pch[32] = 0; - - DBWriteContactSettingTString(0, MODULE, szSetting, pch); - } - } - else if (_tcsstr(buff, _T("color"))) - { - if (GetSettingName(buff, "Col", szSetting)) - { - BYTE r = _ttoi(pch); - pch = _tcschr(pch, ' '); - if (++pch) - { - BYTE g = _ttoi(pch); - pch = _tcschr(pch, ' '); - if (++pch) - { - BYTE b = _ttoi(pch); - COLORREF color = RGB(r, g ,b); - DBWriteContactSettingDword(0, MODULE, szSetting, color); - } - } - } - } - else if (_tcsstr(buff, _T("size"))) - { - if (GetSettingName(buff, "Size", szSetting)) - { - HDC hdc = GetDC(0); - int size = -MulDiv(_ttoi(pch), GetDeviceCaps(hdc, LOGPIXELSY), 72); - DBWriteContactSettingByte(0, MODULE, szSetting, (BYTE)size); - ReleaseDC(0, hdc); - } - } - else if (_tcsstr(buff, _T("effect"))) - { - if (GetSettingName(buff, "Sty", szSetting)) - { - BYTE effect = 0; - if (_tcsstr(pch, _T("font_bold"))) - effect |= DBFONTF_BOLD; - if (_tcsstr(pch, _T("font_italic"))) - effect |= DBFONTF_ITALIC; - if (_tcsstr(pch, _T("font_underline"))) - effect |= DBFONTF_UNDERLINE; - - DBWriteContactSettingByte(0, MODULE, szSetting, effect); - } - } - } - } - } - - if (feof(fp)) break; - myfgets(buff, 1024, fp); - } -} - -void ParseAppearancePart(FILE *fp, TCHAR *buff) -{ - myfgets(buff, 1024, fp); - while (buff[0] != '[') - { - if (buff[0] != ';') - { - TCHAR *pch = _tcschr(buff, '='); - if (pch++) - { - while (pch && (*pch == ' ' || *pch == '\t')) - pch++; - - if (pch) - { - if (_tcsstr(buff, _T("general-padding"))) - opt.iPadding = _ttoi(pch); - else if (_tcsstr(buff, _T("title-indent"))) - opt.iTitleIndent = _ttoi(pch); - else if (_tcsstr(buff, _T("text-indent"))) - opt.iTextIndent = _ttoi(pch); - else if (_tcsstr(buff, _T("value-indent"))) - opt.iValueIndent = _ttoi(pch); - else if (_tcsstr(buff, _T("text-padding"))) - opt.iTextPadding = _ttoi(pch); - else if (_tcsstr(buff, _T("outer-avatar-padding"))) - opt.iOuterAvatarPadding = _ttoi(pch); - else if (_tcsstr(buff, _T("inner-avatar-padding"))) - opt.iInnerAvatarPadding = _ttoi(pch); - else if (_tcsstr(buff, _T("sidebar-width"))) - opt.iSidebarWidth = _ttoi(pch); - else if (_tcsstr(buff, _T("opacity"))) - opt.iOpacity = _ttoi(pch); - } - } - } - - if (feof(fp)) break; - myfgets(buff, 1024, fp); - } -} - -void ParseOtherPart(FILE *fp, TCHAR *buff) -{ - myfgets(buff, 1024, fp); - while (buff[0] != '[') - { - if (buff[0] != ';') - { - TCHAR *pch = _tcschr(buff, '='); - if (pch++) - { - while (pch && (*pch == ' ' || *pch == '\t')) - pch++; - - if (pch) - { - if (_tcsstr(buff, _T("enable-coloring"))) - { - if (_tcsstr(pch, _T("false"))) - opt.iEnableColoring = -1; - } - } - } - } - - if (feof(fp)) break; - myfgets(buff, 1024, fp); - } -} - -void ParseSkinFile(TCHAR *szSkinName, bool bStartup, bool bOnlyPreview) -{ - TCHAR szDirSave[1024], buff[1024]; - - if (opt.skinMode == SM_OBSOLOTE && bStartup) - return; - - if (!bStartup) opt.iEnableColoring = 0; - opt.szPreviewFile[0] = 0; - - GetCurrentDirectory(1024, szDirSave); - SetCurrentDirectory(SKIN_FOLDER); - SetCurrentDirectory(szSkinName); - - WIN32_FIND_DATA ffd; - HANDLE hFind = FindFirstFile(_T("*.tsf"), &ffd); - if (hFind != INVALID_HANDLE_VALUE) - { - FILE *fp = _tfopen(ffd.cFileName, _T("r")); - if (fp) - { - myfgets(buff, 1024, fp); - while (!feof(fp)) - { - if (buff[0] == '[') - { - if (!_tcscmp(_T("[about]"), buff)) - { - ParseAboutPart(fp, buff, szSkinName); - continue; - } - else if (!_tcscmp(_T("[other]"), buff)) - { - ParseOtherPart(fp, buff); - continue; - } - else if (!bOnlyPreview) - { - if (!_tcscmp(_T("[background]"), buff)) - { - ParseImagePart(fp, buff, SKIN_ITEM_BG); - continue; - } - else if (!_tcscmp(_T("[sidebar]"), buff)) - { - ParseImagePart(fp, buff, SKIN_ITEM_SIDEBAR); - continue; - } - else if (!bStartup && opt.bLoadFonts && !_tcscmp(_T("[fonts]"), buff)) - { - ParseFontPart(fp, buff); - continue; - } - else if (!bStartup && opt.bLoadProportions && !_tcscmp(_T("[appearance]"), buff)) - { - ParseAppearancePart(fp, buff); - continue; - } - } - } - - myfgets(buff, 1024, fp); - } - fclose(fp); - } - } - else - { - opt.skinMode = SM_COLORFILL; - } - - FindClose(hFind); - SetCurrentDirectory(szDirSave); -} \ No newline at end of file diff --git a/plugins/TipperYM/skin_parser.h b/plugins/TipperYM/skin_parser.h deleted file mode 100644 index ca83f47915..0000000000 --- a/plugins/TipperYM/skin_parser.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -Copyright (C) 2006-2007 Scott Ellis -Copyright (C) 2007-2011 Jan Holub - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this file; see the file license.txt. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. -*/ - -#ifndef _SKIN_INC -#define _SKIN_INC - -typedef enum { - SM_COLORFILL = 0, SM_IMAGE = 1, SM_OBSOLOTE = 2 -} SkinMode; - -int RefreshSkinList(HWND hwndDlg); -void ParseSkinFile(TCHAR *szSkinName, bool bStartup, bool bOnlyPreview); -#endif \ No newline at end of file diff --git a/plugins/TipperYM/src/bitmap_func.cpp b/plugins/TipperYM/src/bitmap_func.cpp new file mode 100644 index 0000000000..0a33c7b1d8 --- /dev/null +++ b/plugins/TipperYM/src/bitmap_func.cpp @@ -0,0 +1,776 @@ +/* +Copyright (C) 2006-2007 Scott Ellis +Copyright (C) 2007-2011 Jan Holub + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#include "common.h" +#include "options.h" +#include "bitmap_func.h" +#include "message_pump.h" + +TOOLTIPSKIN skin = {0}; + +HBITMAP CreateBitmapPart(FIBITMAP *fibSrc, int iSrcWidth, int iSrcHeight, int iDesWidth, int iDesHeight, TransformationMode transfMode) +{ + FIBITMAP *fibMem = NULL; + HBITMAP hbmpDes = NULL; + + if (!fibSrc) + return NULL; + + switch (transfMode) + { + case TM_NONE: + case TM_CENTRE: + case TM_TILE_ALL: + { + hbmpDes = fii->FI_CreateHBITMAPFromDIB(fibSrc); + break; + } + case TM_STRECH_ALL: + { + fibMem = fii->FI_Rescale(fibSrc, iDesWidth, iDesHeight, FILTER_BILINEAR); + hbmpDes = fii->FI_CreateHBITMAPFromDIB(fibMem); + break; + } + case TM_STRECH_HORIZONTAL: + case TM_TILE_VERTICAL: + { + fibMem = fii->FI_Rescale(fibSrc, iDesWidth, iSrcHeight, FILTER_BILINEAR); + hbmpDes = fii->FI_CreateHBITMAPFromDIB(fibMem); + break; + } + case TM_STRECH_VERTICAL: + case TM_TILE_HORIZONTAL: + { + fibMem = fii->FI_Rescale(fibSrc, iSrcWidth, iSrcHeight, FILTER_BILINEAR); + hbmpDes = fii->FI_CreateHBITMAPFromDIB(fibMem); + break; + } + } + + if (fibMem) fii->FI_Unload(fibMem); + return hbmpDes; +} + +void DrawBitmapPart(HDC hdcMem, HBITMAP hbmpPart, RECT *rcDes, TransformationMode transfMode) +{ + if (!hbmpPart) + return; + + BLENDFUNCTION blend; + blend.BlendOp = AC_SRC_OVER; + blend.BlendFlags = 0; + blend.SourceConstantAlpha = 255; + blend.AlphaFormat = AC_SRC_ALPHA; + + BITMAP bitmap; + GetObject(hbmpPart, sizeof(bitmap), &bitmap); + int iBmpWidth = bitmap.bmWidth; + int iBmpHeight = bitmap.bmHeight; + + int iDesWidth = rcDes->right - rcDes->left; + int iDesHeight = rcDes->bottom - rcDes->top; + + SelectObject(hdcMem, hbmpPart); + + switch (transfMode) + { + case TM_NONE: + case TM_STRECH_ALL: + case TM_STRECH_HORIZONTAL: + case TM_STRECH_VERTICAL: + { + AlphaBlend(skin.hdc, rcDes->left, rcDes->top, iBmpWidth, iBmpHeight, hdcMem, 0, 0, iBmpWidth, iBmpHeight, blend); + break; + } + case TM_CENTRE: + { + int iPosX = rcDes->left + ((iDesWidth - iBmpWidth) / 2); + int iPosY = rcDes->top + ((iDesHeight - iBmpHeight) / 2); + AlphaBlend(skin.hdc, iPosX, iPosY, iBmpWidth, iBmpHeight, hdcMem, 0, 0, iBmpWidth, iBmpHeight, blend); + break; + } + case TM_TILE_ALL: + { + int iRepX = iDesWidth / iBmpWidth; + int iRepY = iDesHeight / iBmpHeight; + int iEndX = iDesWidth % iBmpWidth; + int iEndY = iDesHeight % iBmpHeight; + int x,y; + + for (y = 0; y < iRepY; y++) + { + for (x = 0; x < iRepX; x++) + { + AlphaBlend(skin.hdc, rcDes->left + (x * iBmpWidth), rcDes->top + (y * iBmpHeight), iBmpWidth, iBmpHeight, hdcMem, 0, 0, iBmpWidth, iBmpHeight, blend); + } + + AlphaBlend(skin.hdc, rcDes->left + (x * iBmpWidth), rcDes->top + (y * iBmpHeight), iEndX, iBmpHeight, hdcMem, 0, 0, iEndX, iBmpHeight, blend); + } + + for (x = 0; x < iRepX; x++) + { + AlphaBlend(skin.hdc, rcDes->left + (x * iBmpWidth), rcDes->top + (y * iBmpHeight), iBmpWidth, iEndY, hdcMem, 0, 0, iBmpWidth, iEndY, blend); + } + + AlphaBlend(skin.hdc, rcDes->left + (x * iBmpWidth), rcDes->top + (y * iBmpHeight), iEndX, iEndY, hdcMem, 0, 0, iEndX, iEndY, blend); + break; + } + case TM_TILE_HORIZONTAL: + { + int iRepX = iDesWidth / iBmpWidth; + int iEndX = iDesWidth % iBmpWidth; + int x; + + for (x = 0; x < iRepX; x++) + { + AlphaBlend(skin.hdc, rcDes->left + (x * iBmpWidth), rcDes->top, iBmpWidth, iDesHeight, hdcMem, 0, 0, iBmpWidth, iDesHeight, blend); + } + + AlphaBlend(skin.hdc, rcDes->left + (x * iBmpWidth), rcDes->top, iEndX, iDesHeight, hdcMem, 0, 0, iEndX, iDesHeight, blend); + break; + } + case TM_TILE_VERTICAL: + { + int iRepY = iDesHeight / iBmpHeight; + int iEndY = iDesHeight % iBmpHeight; + int y; + + for(y = 0; y < iRepY; y++) + { + AlphaBlend(skin.hdc, rcDes->left, rcDes->top + (y * iBmpHeight), iDesWidth, iBmpHeight, hdcMem, 0, 0, iDesWidth, iBmpHeight, blend); + } + + AlphaBlend(skin.hdc, rcDes->left, rcDes->top + (y * iBmpHeight), iDesWidth, iEndY, hdcMem, 0, 0, iDesWidth, iEndY, blend); + break; + } + } +} + +void CreateFromBitmaps(bool bServiceTip) +{ + int rcWidth, rcHeight; + int iCentWidth, iCentHeight; + int iBmpWidth, iBmpHeight; + int top, right, bottom, left; + + BLENDFUNCTION blend; + blend.BlendOp = AC_SRC_OVER; + blend.BlendFlags = 0; + blend.SourceConstantAlpha = 255; + blend.AlphaFormat = AC_SRC_ALPHA; + + for (int i = 0; i < SKIN_ITEMS_COUNT; i++) + { + if (i == SKIN_ITEM_SIDEBAR && (!opt.iSidebarWidth || bServiceTip)) + continue; + + TCHAR* tszFileName = opt.szImgFile[i]; + if (tszFileName && *tszFileName != 0) + { + FIBITMAP *fib = NULL; + if (!skin.bCached) + { + FIBITMAP *fibLoad = (FIBITMAP *)CallService(MS_IMG_LOAD, (WPARAM)tszFileName, (LPARAM)(IMGL_TCHAR | IMGL_RETURNDIB)); + if (!fibLoad) continue; + + if (fii->FI_GetBPP(fibLoad) != 32) + fib = fii->FI_ConvertTo32Bits(fibLoad); + else + fib = fibLoad; + + if (fib != fibLoad) + fii->FI_Unload(fibLoad); + + skin.fib[i] = fib; + } + else + { + fib = skin.fib[i]; + } + + // destination rectangle size + if (i == SKIN_ITEM_BG) + { + rcWidth = skin.iWidth; + rcHeight = skin.iHeight; + } + else if (i == SKIN_ITEM_SIDEBAR) + { + rcWidth = opt.iSidebarWidth; + rcHeight = skin.iHeight; + } + + // bitmap size + iBmpWidth = fii->FI_GetWidth(fib); + iBmpHeight = fii->FI_GetHeight(fib); + + // margins + top = opt.margins[i].top < iBmpHeight ? opt.margins[i].top : 0; + right = opt.margins[i].right < iBmpWidth ? opt.margins[i].right : 0; + bottom = opt.margins[i].bottom < iBmpHeight ? opt.margins[i].bottom : 0; + left = opt.margins[i].left < iBmpWidth ? opt.margins[i].left : 0; + + // centre area size + iCentWidth = max(rcWidth - left - right, 0); + iCentHeight = max(rcHeight - top - bottom, 0); + + FIBITMAP *fibCentre = NULL, *fibMem = NULL; + if (opt.margins[i].left || opt.margins[i].top || opt.margins[i].right || opt.margins[i].bottom) + { + // create corners bitmaps + if (!skin.bCached) + { + if (top > 0 && left > 0) // TL + { + fibMem = fii->FI_Copy(fib, 0, 0, left, top); + skin.hbmpSkinParts[i][SP_CORNER_TL] = fii->FI_CreateHBITMAPFromDIB(fibMem); + if (fibMem) fii->FI_Unload(fibMem); + } + if (top > 0 && right > 0) // TR + { + fibMem = fii->FI_Copy(fib, iBmpWidth - right, 0, iBmpWidth, top); + skin.hbmpSkinParts[i][SP_CORNER_TR] = fii->FI_CreateHBITMAPFromDIB(fibMem); + if (fibMem) fii->FI_Unload(fibMem); + } + if (bottom > 0 && right > 0) // BR + { + fibMem = fii->FI_Copy(fib, iBmpWidth - right, iBmpHeight - bottom, iBmpWidth, iBmpHeight); + skin.hbmpSkinParts[i][SP_CORNER_BR] = fii->FI_CreateHBITMAPFromDIB(fibMem); + if (fibMem) fii->FI_Unload(fibMem); + } + if (bottom > 0 && left > 0) // BL + { + fibMem = fii->FI_Copy(fib, 0, iBmpHeight - bottom, left, iBmpHeight); + skin.hbmpSkinParts[i][SP_CORNER_BL] = fii->FI_CreateHBITMAPFromDIB(fibMem); + if (fibMem) fii->FI_Unload(fibMem); + } + } + + // create edge parts bitmaps + if (top > 0 && iCentWidth > 0) // top + { + fibMem = fii->FI_Copy(fib, left, 0, iBmpWidth - right, top); + skin.hbmpSkinParts[i][SP_EDGE_TOP] = CreateBitmapPart(fibMem, iBmpWidth - left - right, top, iCentWidth, top, opt.transfMode[i]); + if (fibMem) fii->FI_Unload(fibMem); + } + if (right > 0 && iCentHeight > 0) // right + { + fibMem = fii->FI_Copy(fib, iBmpWidth - right, top, iBmpWidth, iBmpHeight - bottom); + skin.hbmpSkinParts[i][SP_EDGE_RIGHT] = CreateBitmapPart(fibMem, right, iBmpHeight - top - bottom, right, iCentHeight, opt.transfMode[i]); + if (fibMem) fii->FI_Unload(fibMem); + } + if (bottom > 0 && iCentWidth > 0) // bottom + { + fibMem = fii->FI_Copy(fib, left, iBmpHeight - bottom, iBmpWidth - right, iBmpHeight); + skin.hbmpSkinParts[i][SP_EDGE_BOTTOM] = CreateBitmapPart(fibMem, iBmpWidth - left - right, bottom, iCentWidth, bottom, opt.transfMode[i]); + if (fibMem) fii->FI_Unload(fibMem); + } + if (left > 0 && iCentHeight > 0) // left + { + fibMem = fii->FI_Copy(fib, 0, top, left, iBmpHeight - bottom); + skin.hbmpSkinParts[i][SP_EDGE_LEFT] = CreateBitmapPart(fibMem, left, iBmpHeight - top - bottom, left, iCentHeight, opt.transfMode[i]); + if (fibMem) fii->FI_Unload(fibMem); + } + + fibCentre = fii->FI_Copy(fib, left, top, iBmpWidth - right, iBmpHeight - bottom); + if (fibCentre) + { + fib = fibCentre; + iBmpWidth = fii->FI_GetWidth(fib); + iBmpHeight = fii->FI_GetHeight(fib); + } + } + + // create centre area bitmap + skin.hbmpSkinParts[i][SP_CENTRE_AREA] = CreateBitmapPart(fib, iBmpWidth, iBmpHeight, iCentWidth, iCentHeight, opt.transfMode[i]); + if (fibCentre) + fii->FI_Unload(fibCentre); + + if (i == SKIN_ITEM_SIDEBAR) + { + int limit = skin.bCached ? SP_CORNER_TL : SKIN_PARTS_COUNT; // don't premultiply corner bitmaps multiple times + for (int j = 0; j < limit; j++) + { + if (skin.hbmpSkinParts[i][j]) + fii->FI_Premultiply(skin.hbmpSkinParts[i][j]); + } + } + + HDC hdcMem = CreateCompatibleDC(0); + RECT rc = {0}; + + if (skin.hbmpSkinParts[i][SP_CENTRE_AREA]) + { + SetRect(&rc, left, top, rcWidth - right, rcHeight - bottom); + DrawBitmapPart(hdcMem, skin.hbmpSkinParts[i][SP_CENTRE_AREA], &rc, opt.transfMode[i]); + } + + if (opt.margins[i].left || opt.margins[i].top || opt.margins[i].right || opt.margins[i].bottom) + { + // draw edge parts + if (skin.hbmpSkinParts[i][SP_EDGE_TOP]) // top + { + SetRect(&rc, left, 0, rcWidth - right, top); + DrawBitmapPart(hdcMem, skin.hbmpSkinParts[i][SP_EDGE_TOP], &rc, opt.transfMode[i]); + } + if (skin.hbmpSkinParts[i][SP_EDGE_RIGHT]) // right + { + SetRect(&rc, rcWidth - right, top, rcWidth, rcHeight - bottom); + DrawBitmapPart(hdcMem, skin.hbmpSkinParts[i][SP_EDGE_RIGHT], &rc, opt.transfMode[i]); + } + if (skin.hbmpSkinParts[i][SP_EDGE_BOTTOM]) // bottom + { + SetRect(&rc, left, rcHeight - bottom, rcWidth - right, rcHeight); + DrawBitmapPart(hdcMem, skin.hbmpSkinParts[i][SP_EDGE_BOTTOM], &rc, opt.transfMode[i]); + } + if (skin.hbmpSkinParts[i][SP_EDGE_LEFT]) // left + { + SetRect(&rc, 0, top, left, rcHeight - bottom); + DrawBitmapPart(hdcMem, skin.hbmpSkinParts[i][SP_EDGE_LEFT], &rc, opt.transfMode[i]); + } + + // draw corners + if (skin.hbmpSkinParts[i][SP_CORNER_TL]) // TL + { + SelectObject(hdcMem, skin.hbmpSkinParts[i][SP_CORNER_TL]); + AlphaBlend(skin.hdc, 0, 0, left, top, hdcMem, 0, 0, left, top, blend); + } + if (skin.hbmpSkinParts[i][SP_CORNER_TR]) // TR + { + SelectObject(hdcMem, skin.hbmpSkinParts[i][SP_CORNER_TR]); + AlphaBlend(skin.hdc, rcWidth - right, 0, right, top, hdcMem, 0, 0, right, top, blend); + } + if (skin.hbmpSkinParts[i][SP_CORNER_BR]) // BR + { + SelectObject(hdcMem, skin.hbmpSkinParts[i][SP_CORNER_BR]); + AlphaBlend(skin.hdc, rcWidth - right, rcHeight - bottom, right, bottom, hdcMem, 0, 0, right, bottom, blend); + } + if (skin.hbmpSkinParts[i][SP_CORNER_BL]) // BL + { + SelectObject(hdcMem, skin.hbmpSkinParts[i][SP_CORNER_BL]); + AlphaBlend(skin.hdc, 0, rcHeight - bottom, left, bottom, hdcMem, 0, 0, left, bottom, blend); + } + } + + for (int j = 0; j < SP_CORNER_TL; j++) + { + if (skin.hbmpSkinParts[i][j]) + { + DeleteObject(skin.hbmpSkinParts[i][j]); + skin.hbmpSkinParts[i][j] = NULL; + } + } + + if (MyUpdateLayeredWindow) + skin.bNeedLayerUpdate = true; + + DeleteDC(hdcMem); + } + } + + skin.bCached = true; +} + +void SolidColorFill(bool bServiceTip) +{ + RECT rc = {0}; + rc.right = skin.iWidth; + rc.bottom = skin.iHeight; + HBRUSH hBrush = CreateSolidBrush(opt.colBg); + FillRect(skin.hdc, &rc, hBrush); + DeleteObject(hBrush); + + if (opt.iSidebarWidth > 0 && !bServiceTip) + { + rc.right = opt.iSidebarWidth; + hBrush = CreateSolidBrush(opt.colSidebar); + FillRect(skin.hdc, &rc, hBrush); + DeleteObject(hBrush); + } +} + +void CreateSkinBitmap(int iWidth, int iHeight, bool bServiceTip) +{ + if (skin.hBitmap) DeleteObject(skin.hBitmap); + if (skin.hdc) DeleteDC(skin.hdc); + skin.hBitmap = NULL; + skin.hdc = NULL; + + skin.iWidth = iWidth; + skin.iHeight = iHeight; + skin.bNeedLayerUpdate = false; + + BITMAPINFO bi; + bi.bmiHeader.biSize = sizeof(bi.bmiHeader); + bi.bmiHeader.biWidth = skin.iWidth; + bi.bmiHeader.biHeight = -skin.iHeight; + bi.bmiHeader.biPlanes = 1; + bi.bmiHeader.biBitCount = 32; + bi.bmiHeader.biCompression = BI_RGB; + skin.hBitmap = (HBITMAP)CreateDIBSection(0, &bi, DIB_RGB_COLORS, (void **)&skin.colBits, 0, 0); + + if (!skin.hBitmap) + return; + + skin.hdc = CreateCompatibleDC(0); + DeleteObject(SelectObject(skin.hdc, skin.hBitmap)); + + if (opt.skinMode == SM_COLORFILL) + { + SolidColorFill(bServiceTip); + } + else + { + CreateFromBitmaps(bServiceTip); + if (opt.iEnableColoring == 1) + ColorizeBitmap(); + } +} + +void DestroySkinBitmap() +{ + for (int i = 0; i < SKIN_ITEMS_COUNT; i++) + { + if (skin.fib[i]) + { + fii->FI_Unload(skin.fib[i]); + skin.fib[i] = NULL; + } + + for (int j = SP_CORNER_TL; j < SKIN_PARTS_COUNT; j++) + { + if (skin.hbmpSkinParts[i][j]) + { + DeleteObject(skin.hbmpSkinParts[i][j]); + skin.hbmpSkinParts[i][j] = NULL; + } + } + } + + skin.bCached = false; +} + +void SaveAlpha(LPRECT lpRect) +{ + if (skin.colSavedBits) + { + mir_free(skin.colSavedBits); + skin.colSavedBits = 0; + } + GdiFlush(); + + if (lpRect->left < 0) lpRect->left = 0; + if (lpRect->top < 0) lpRect->top = 0; + if (lpRect->right > skin.iWidth) lpRect->right = skin.iWidth; + if (lpRect->bottom > skin.iHeight) lpRect->bottom = skin.iHeight; + + int x = lpRect->left; + int y = lpRect->top; + int w = lpRect->right - lpRect->left; + int h = lpRect->bottom - lpRect->top; + + skin.colSavedBits = (COLOR32 *)mir_alloc(sizeof(COLOR32) * w * h); + COLOR32 *p1 = skin.colSavedBits; + + for (int i = 0; i < h; i++) + { + if (i+y < 0) continue; + if (i+y >= skin.iHeight) break; + COLOR32 *p2 = skin.colBits + (y+i)*skin.iWidth + x; + for (int j = 0; j < w; j++) + { + if (j+x < 0) continue; + if (j+x >= skin.iWidth) break; + *p1++ = *p2++; + } + } +} + +void RestoreAlpha(LPRECT lpRect, BYTE alpha) +{ + if (!skin.colSavedBits) + return; + + GdiFlush(); + + if (lpRect->left < 0) lpRect->left = 0; + if (lpRect->top < 0) lpRect->top = 0; + if (lpRect->right > skin.iWidth) lpRect->right = skin.iWidth; + if (lpRect->bottom > skin.iHeight) lpRect->bottom = skin.iHeight; + + int x = lpRect->left; + int y = lpRect->top; + int w = lpRect->right - lpRect->left; + int h = lpRect->bottom - lpRect->top; + + COLOR32 *p1 = skin.colSavedBits; + + for (int i = 0; i < h; i++) + { + if (i+y < 0) continue; + if (i+y >= skin.iHeight) break; + COLOR32 *p2 = skin.colBits + (y+i)*skin.iWidth + x; + for (int j = 0; j < w; j++) + { + if (j+x < 0) continue; + if (j+x >= skin.iWidth) break; + if ((*p1&0x00ffffff) != (*p2&0x00ffffff)) + { + *p2 |= (alpha << 24); + } + else + { + *p2 = (*p2&0x00ffffff) | (*p1&0xff000000); + } + ++p1; + ++p2; + } + } + + mir_free(skin.colSavedBits); + skin.colSavedBits = 0; +} + +BOOL IsAlphaTransparent(HBITMAP hBitmap) +{ + BITMAP bmp; + DWORD dwLen; + BYTE *p; + + GetObject(hBitmap, sizeof(bmp), &bmp); + + if (bmp.bmBitsPixel != 32) + return FALSE; + + dwLen = bmp.bmWidth * bmp.bmHeight * (bmp.bmBitsPixel / 8); + p = (BYTE *)mir_alloc(dwLen); + if (p == NULL) return FALSE; + memset(p, 0, dwLen); + + GetBitmapBits(hBitmap, dwLen, p); + + for (int y = 0; y < bmp.bmHeight; y++) + { + BYTE *px = p + bmp.bmWidth * 4 * y; + for (int x = 0; x < bmp.bmWidth; x++) + { + if (px[3] != 0) + { + mir_free(p); + return TRUE; + } + + px += 4; + } + } + + mir_free(p); + return FALSE; +} + +void DrawIconExAlpha(HDC hdc, int xLeft, int yTop, HICON hIcon, int cxWidth, int cyWidth, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags, bool bIsSmiley) +{ + bool restore = false; + + if (skin.bNeedLayerUpdate && !bIsSmiley) + { + ICONINFO icon; + if (GetIconInfo(hIcon, &icon)) + { + if (!IsAlphaTransparent(icon.hbmColor)) + { + RECT rc; + SetRect(&rc, xLeft, yTop, xLeft + cxWidth, yTop + cyWidth); + SaveAlpha(&rc); + restore = true; + } + + DeleteObject(icon.hbmColor); + DeleteObject(icon.hbmMask); + } + } + + DrawIconEx(hdc, xLeft, yTop, hIcon, cxWidth, cyWidth, istepIfAniCur, hbrFlickerFreeDraw, diFlags); + + if (skin.bNeedLayerUpdate && restore) + { + RECT rc; + SetRect(&rc, xLeft, yTop, xLeft + cxWidth, yTop + cyWidth); + RestoreAlpha(&rc); + } +} + +int DrawTextAlpha(HDC hdc, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat) +{ + RECT rc; + SetRect(&rc, lpRect->left - 1, lpRect->top - 1, lpRect->right + 1, lpRect->bottom + 1); + + if (skin.bNeedLayerUpdate) SaveAlpha(&rc); + int result = DrawText(hdc, lpString, nCount, lpRect, uFormat); + if (skin.bNeedLayerUpdate) RestoreAlpha(&rc); + + return result; +} + +static __forceinline COLOR32 rgba(COLOR32 r, COLOR32 g, COLOR32 b, COLOR32 a) +{ + return ((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); +} + +static __forceinline COLOR32 getr(COLOR32 c) +{ + return (c >> 16) & 0xff; +} + +static __forceinline COLOR32 getg(COLOR32 c) +{ + return (c >> 8) & 0xff; +} + +static __forceinline COLOR32 getb(COLOR32 c) +{ + return c & 0xff; +} + +static __forceinline COLOR32 geta(COLOR32 c) +{ + return (c >> 24) & 0xff; +} + +void PremultipleChannels() +{ + for (int i = 0; i < skin.iWidth * skin.iHeight; i++) + skin.colBits[i] = rgba( getr(skin.colBits[i])*geta(skin.colBits[i])/255, + getg(skin.colBits[i])*geta(skin.colBits[i])/255, + getb(skin.colBits[i])*geta(skin.colBits[i])/255, + geta(skin.colBits[i])); +} + +#define PU_DIV255(x) ((x)/255) + +void ColorizeBitmap() +{ + if (!skin.colBits) + return; + + GdiFlush(); + + int w = skin.iWidth; + int h = skin.iHeight; + + // we should swap B and R channels when working with win32 COLORREF + float koef1r = (255 - getb(opt.colBg)) / 128.0; + float koef1g = (255 - getg(opt.colBg)) / 128.0; + float koef1b = (255 - getr(opt.colBg)) / 128.0; + + int br = - 255 + 2 * getb(opt.colBg); + int bg = - 255 + 2 * getg(opt.colBg); + int bb = - 255 + 2 * getr(opt.colBg); + + float koef2r = (getb(opt.colBg)) / 128.0; + float koef2g = (getg(opt.colBg)) / 128.0; + float koef2b = (getr(opt.colBg)) / 128.0; + + for (int i = 0; i < w * h; i++) + { + long alpha = geta(skin.colBits[i]); + COLOR32 cl = alpha ? getr(skin.colBits[i])*255/alpha : 0; + + skin.colBits[i] = (cl > 128) ? + rgba( + PU_DIV255((koef1r * cl + br)*alpha), + PU_DIV255((koef1g * cl + bg)*alpha), + PU_DIV255((koef1b * cl + bb)*alpha), + alpha): + rgba( + PU_DIV255(koef2r * cl * alpha), + PU_DIV255(koef2g * cl * alpha), + PU_DIV255(koef2b * cl * alpha), + alpha); + } +} + +// code from Clist Modern by FYR +HRGN CreateOpaqueRgn(BYTE level, bool bOpaque) +{ + if (!skin.colBits) + return NULL; + + GdiFlush(); + + RGBQUAD *buff = (RGBQUAD *)skin.colBits; + + int x,y; + unsigned int cRect = 64; + PRGNDATA pRgnData = (PRGNDATA)malloc(sizeof(RGNDATAHEADER) + (cRect)*sizeof(RECT)); + memset(pRgnData, 0, sizeof(RGNDATAHEADER)); + pRgnData->rdh.dwSize = sizeof(RGNDATAHEADER); + pRgnData->rdh.iType = RDH_RECTANGLES; + + for (y = 0; y < skin.iHeight; ++y) + { + bool inside = false; + bool lastin = false; + unsigned int entry = 0; + + for (x = 0; x < skin.iWidth; ++x) + { + inside = bOpaque ? (buff->rgbReserved > level) : (buff->rgbReserved < level); + ++buff; + + if (inside != lastin) + { + if (inside) + { + lastin = true; + entry = x; + } + else + { + if (pRgnData->rdh.nCount == cRect) + { + cRect = cRect + 64; + pRgnData = (PRGNDATA)realloc(pRgnData, sizeof(RGNDATAHEADER) + (cRect)*sizeof(RECT)); + } + + SetRect(((LPRECT)pRgnData->Buffer) + pRgnData->rdh.nCount, entry, skin.iHeight - y, x, skin.iHeight - y + 1); + pRgnData->rdh.nCount++; + lastin = false; + } + } + } + + if (lastin) + { + if (pRgnData->rdh.nCount == cRect) + { + cRect = cRect + 64; + pRgnData = (PRGNDATA)realloc(pRgnData, sizeof(RGNDATAHEADER) + (cRect)*sizeof(RECT)); + } + + SetRect(((LPRECT)pRgnData->Buffer) + pRgnData->rdh.nCount, entry, skin.iHeight - y, x, skin.iHeight - y + 1); + pRgnData->rdh.nCount++; + } + } + + HRGN hRgn = ExtCreateRegion(NULL, sizeof(RGNDATAHEADER) + pRgnData->rdh.nCount*sizeof(RECT), (LPRGNDATA)pRgnData); + free(pRgnData); + return hRgn; +} \ No newline at end of file diff --git a/plugins/TipperYM/src/bitmap_func.h b/plugins/TipperYM/src/bitmap_func.h new file mode 100644 index 0000000000..e6ffbc4880 --- /dev/null +++ b/plugins/TipperYM/src/bitmap_func.h @@ -0,0 +1,71 @@ +/* +Copyright (C) 2006-2007 Scott Ellis +Copyright (C) 2007-2011 Jan Holub + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#ifndef _BITMAP_FUNC_INC +#define _BITMAP_FUNC_INC + +// tooltip skin +#define SKIN_ITEMS_COUNT 2 +#define SKIN_PARTS_COUNT 9 +#define SKIN_ITEM_BG 0 +#define SKIN_ITEM_SIDEBAR 1 + +// skin parts +#define SP_CENTRE_AREA 0 +#define SP_EDGE_TOP 1 +#define SP_EDGE_RIGHT 2 +#define SP_EDGE_BOTTOM 3 +#define SP_EDGE_LEFT 4 +#define SP_CORNER_TL 5 +#define SP_CORNER_TR 6 +#define SP_CORNER_BR 7 +#define SP_CORNER_BL 8 + +// image paint options +typedef enum { + TM_NONE = 0, TM_CENTRE = 1, TM_STRECH_ALL = 2, TM_STRECH_HORIZONTAL = 3, TM_STRECH_VERTICAL = 4, + TM_TILE_ALL = 5, TM_TILE_HORIZONTAL = 6, TM_TILE_VERTICAL = 7 +} TransformationMode; + +typedef unsigned long COLOR32; +typedef struct { + HDC hdc; + HBITMAP hBitmap; + HBITMAP hbmpSkinParts[SKIN_ITEMS_COUNT][SKIN_PARTS_COUNT]; + FIBITMAP *fib[SKIN_ITEMS_COUNT]; + COLOR32 *colBits; + COLOR32 *colSavedBits; + int iWidth; + int iHeight; + bool bNeedLayerUpdate; + bool bCached; +} TOOLTIPSKIN; + +void CreateSkinBitmap(int iWidth, int iHeight, bool bServiceTip); +void DestroySkinBitmap(); +int DrawTextAlpha(HDC hdc, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat); +void DrawIconExAlpha(HDC hdc, int xLeft, int yTop, HICON hIcon, int cxWidth, int cyWidth, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags, bool bIsSmiley); +void SaveAlpha(LPRECT lpRect); +void RestoreAlpha(LPRECT lpRect, BYTE alpha = 0xff); +void PremultipleChannels(); +void ColorizeBitmap(); +HRGN CreateOpaqueRgn(BYTE level, bool bOpaque); + +#endif diff --git a/plugins/TipperYM/src/common.h b/plugins/TipperYM/src/common.h new file mode 100644 index 0000000000..9098589d1c --- /dev/null +++ b/plugins/TipperYM/src/common.h @@ -0,0 +1,105 @@ +/* +Copyright (C) 2006-2007 Scott Ellis +Copyright (C) 2007-2011 Jan Holub + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#pragma once + +// Modify the following defines if you have to target a platform prior to the ones specified below. +// Refer to MSDN for the latest info on corresponding values for different platforms. +#ifndef WINVER // Allow use of features specific to Windows XP or later. +#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows. +#endif + +#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. +#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. +#endif + +#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. +#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. +#endif + +#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later. +#define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE. +#endif + +#define MIRANDA_VER 0x0A00 + +#define _CRT_SECURE_NO_WARNINGS + +#include + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +// Windows Header Files: +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "resource.h" +#include "m_tipper.h" +#include "m_fingerprint.h" +#include "m_flags.h" +#include "m_folders.h" +#include "m_metacontacts.h" +#include "m_variables.h" +#include "m_smileyadd.h" + +// {8392DF1D-9090-4f8e-9DF6-2FE058EDD800} +#define MIID_TIPPER { 0x8392df1d, 0x9090, 0x4f8e, { 0x9d, 0xf6, 0x2f, 0xe0, 0x58, 0xed, 0xd8, 0x00 } } + +#define MODULE "Tipper" +#define MODULE_ITEMS "Tipper_Items" +#define DEFAULT_SKIN_FOLDER "Skins\\Tipper" + +extern HMODULE hInst; + +extern HFONT hFontTitle, hFontLabels, hFontValues, hFontTrayTitle; +extern COLORREF colTitle, colLabels, colBg, colValues; + +extern int iCodePage; +extern char szMetaModuleName[256]; + +extern FI_INTERFACE *fii; \ No newline at end of file diff --git a/plugins/TipperYM/src/message_pump.cpp b/plugins/TipperYM/src/message_pump.cpp new file mode 100644 index 0000000000..7032ad84b2 --- /dev/null +++ b/plugins/TipperYM/src/message_pump.cpp @@ -0,0 +1,413 @@ +/* +Copyright (C) 2006-2007 Scott Ellis +Copyright (C) 2007-2011 Jan Holub + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#include "common.h" +#include "message_pump.h" +#include "popwin.h" +#include "options.h" +#include "str_utils.h" +#include "subst.h" + +BOOL (WINAPI *MySetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD) = 0; +BOOL (WINAPI *MyUpdateLayeredWindow)(HWND hwnd, HDC hdcDST, POINT *pptDst, SIZE *psize, HDC hdcSrc, POINT *pptSrc, COLORREF crKey, BLENDFUNCTION *pblend, DWORD dwFlags) = 0; +BOOL (WINAPI *MyAnimateWindow)(HWND hWnd,DWORD dwTime,DWORD dwFlags) = 0; +HMONITOR (WINAPI *MyMonitorFromPoint)(POINT, DWORD); +BOOL (WINAPI *MyGetMonitorInfo)(HMONITOR, LPMONITORINFO); +HRESULT (WINAPI *MyDwmEnableBlurBehindWindow)(HWND hWnd, DWM_BLURBEHIND *pBlurBehind) = 0; + +unsigned int uintMessagePumpThreadId = 0; +POINT pt = {-1}; +UINT WaitForContentTimerID = 0; +bool bAvatarReady = false; +bool bStatusMsgReady = false; + +__inline bool IsContactTooltip(CLCINFOTIPEX *clc) +{ + return (clc->szProto || clc->swzText) == false; +} + +void CALLBACK TimerProcWaitForContent(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) +{ + KillTimer(0, WaitForContentTimerID); + WaitForContentTimerID = 0; + bStatusMsgReady = true; + bAvatarReady = true; + PostMPMessage(MUM_CREATEPOPUP, 0, 0); +} + +bool NeedWaitForContent(CLCINFOTIPEX *clcitex) +{ + bool bNeedWait = false; + + if (opt.bWaitForContent && IsContactTooltip(clcitex)) + { + char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)clcitex->hItem, 0); + if (!szProto) return false; + + if (opt.bWaitForStatusMsg && !bStatusMsgReady) + { + DBDeleteContactSetting(clcitex->hItem, MODULE, "TempStatusMsg"); + if (CanRetrieveStatusMsg(clcitex->hItem, szProto) && + CallContactService(clcitex->hItem, PSS_GETAWAYMSG, 0, 0)) + { + if (WaitForContentTimerID) + KillTimer(0, WaitForContentTimerID); + + WaitForContentTimerID = SetTimer(NULL, 0, WAIT_TIMER_INTERVAL, TimerProcWaitForContent); + bNeedWait = true; + } + } + + if (opt.bWaitForAvatar && !bAvatarReady && + CallProtoService(szProto, PS_GETAVATARCAPS, AF_ENABLED, 0)) + { + DBVARIANT dbv; + if (!DBGetContactSettingString(clcitex->hItem, "ContactPhoto", "File", &dbv)) + { + if (!strstr(dbv.pszVal, ".xml")) + { + AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)clcitex->hItem, 0); + if (!ace) + { + if (WaitForContentTimerID) + KillTimer(0, WaitForContentTimerID); + + WaitForContentTimerID = SetTimer(NULL, 0, WAIT_TIMER_INTERVAL, TimerProcWaitForContent); + bNeedWait = true; + } + else + bAvatarReady = true; + } + else + bAvatarReady = true; + + DBFreeVariant(&dbv); + } + else + bAvatarReady = true; + } + + } + + return bNeedWait; +} + +unsigned int CALLBACK MessagePumpThread(void *param) +{ + HWND hwndTip = 0; + CLCINFOTIPEX *clcitex = 0; + + MSG hwndMsg = {0}; + while (GetMessage(&hwndMsg, 0, 0, 0) > 0 && !Miranda_Terminated()) + { + if (!IsDialogMessage(hwndMsg.hwnd, &hwndMsg)) + { + switch (hwndMsg.message) + { + case MUM_CREATEPOPUP: + { + if (!clcitex) + { + if (hwndMsg.lParam) clcitex = (CLCINFOTIPEX *)hwndMsg.lParam; + else break; + } + + if (!NeedWaitForContent(clcitex)) + { + if (hwndTip) MyDestroyWindow(hwndTip); + hwndTip = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, POP_WIN_CLASS, NULL, WS_POPUP, 0, 0, 0, 0, 0, 0, hInst, (LPVOID)clcitex); + + if (clcitex) + { + mir_free(clcitex); + clcitex = 0; + } + + bStatusMsgReady = false; + bAvatarReady = false; + } + break; + } + case MUM_DELETEPOPUP: + { + if (hwndTip) + { + MyDestroyWindow(hwndTip); + hwndTip = 0; + } + + if (clcitex) + { + mir_free(clcitex); + clcitex = 0; + } + + bStatusMsgReady = false; + bAvatarReady = false; + break; + } + case MUM_GOTSTATUS: + { + HANDLE hContact = (HANDLE)hwndMsg.wParam; + TCHAR *swzMsg = (TCHAR *)hwndMsg.lParam; + + if (opt.bWaitForContent && + bStatusMsgReady == false && + clcitex && + clcitex->hItem == hContact) + { + if (WaitForContentTimerID) + { + KillTimer(0, WaitForContentTimerID); + WaitForContentTimerID = 0; + } + + if (swzMsg) + { + DBWriteContactSettingTString(clcitex->hItem, MODULE, "TempStatusMsg", swzMsg); + mir_free(swzMsg); + } + + bStatusMsgReady = true; + PostMPMessage(MUM_CREATEPOPUP, 0, 0); + } + else if (!opt.bWaitForContent && hwndTip) + SendMessage(hwndTip, PUM_SETSTATUSTEXT, (WPARAM)hContact, (LPARAM)swzMsg); + else if (swzMsg) + mir_free(swzMsg); + + break; + } + case MUM_GOTXSTATUS: + { + if (hwndTip && !opt.bWaitForContent) + SendMessage(hwndTip, PUM_SHOWXSTATUS, hwndMsg.wParam, 0); + break; + } + case MUM_GOTAVATAR: + { + HANDLE hContact = (HANDLE)hwndMsg.wParam; + + if (opt.bWaitForContent && + bAvatarReady == false && + clcitex && + clcitex->hItem == hContact) + { + if (WaitForContentTimerID) + { + KillTimer(0, WaitForContentTimerID); + WaitForContentTimerID = 0; + } + + bAvatarReady = true; + PostMPMessage(MUM_CREATEPOPUP, 0, 0); + } + else if (!opt.bWaitForContent && hwndTip) + SendMessage(hwndTip, PUM_SETAVATAR, hwndMsg.wParam, 0); + + break; + } + default: + { + TranslateMessage(&hwndMsg); + DispatchMessage(&hwndMsg); + break; + } + } + } + } + + return 0; +} + +void PostMPMessage(UINT msg, WPARAM wParam, LPARAM lParam) +{ + PostThreadMessage(uintMessagePumpThreadId, msg, wParam, lParam); +} + +void InitMessagePump() +{ + WNDCLASSEX wcl = {0}; + wcl.cbSize = sizeof(wcl); + wcl.lpfnWndProc = PopupWindowProc; + wcl.hInstance = hInst; + wcl.hCursor = LoadCursor(NULL, IDC_ARROW); + wcl.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH); + wcl.lpszClassName = POP_WIN_CLASS; + RegisterClassEx(&wcl); + + HMODULE hUserDll = LoadLibrary(_T("user32.dll")); + if (hUserDll) + { + MySetLayeredWindowAttributes = (BOOL (WINAPI *)(HWND,COLORREF,BYTE,DWORD))GetProcAddress(hUserDll, "SetLayeredWindowAttributes"); + MyUpdateLayeredWindow = (BOOL (WINAPI *)(HWND hwnd, HDC hdcDST, POINT *pptDst, SIZE *psize, HDC hdcSrc, POINT *pptSrc, COLORREF crKey, BLENDFUNCTION *pblend, DWORD dwFlags))GetProcAddress(hUserDll, "UpdateLayeredWindow"); + MyAnimateWindow =(BOOL (WINAPI*)(HWND,DWORD,DWORD))GetProcAddress(hUserDll, "AnimateWindow"); + MyMonitorFromPoint = (HMONITOR (WINAPI*)(POINT, DWORD))GetProcAddress(hUserDll, "MonitorFromPoint"); + MyGetMonitorInfo = (BOOL (WINAPI*)(HMONITOR, LPMONITORINFO))GetProcAddress(hUserDll, "GetMonitorInfoW"); + + } + + HMODULE hDwmapiDll = LoadLibrary(_T("dwmapi.dll")); + if (hDwmapiDll) + MyDwmEnableBlurBehindWindow = (HRESULT (WINAPI *)(HWND, DWM_BLURBEHIND *))GetProcAddress(hDwmapiDll, "DwmEnableBlurBehindWindow"); + + CloseHandle(mir_forkthreadex(MessagePumpThread, NULL, &uintMessagePumpThreadId)); +} + +void DeinitMessagePump() +{ + PostMPMessage(WM_QUIT, 0, 0); + UnregisterClass(POP_WIN_CLASS, hInst); +} + +INT_PTR ShowTip(WPARAM wParam, LPARAM lParam) +{ + CLCINFOTIP *clcit = (CLCINFOTIP *)lParam; + HWND clist = (HWND)CallService(MS_CLUI_GETHWNDTREE, 0, 0); + + if (clcit->isGroup) return 0; // no group tips (since they're pretty useless) + if (clcit->isTreeFocused == 0 && opt.bShowNoFocus == false && clist == WindowFromPoint(clcit->ptCursor)) return 0; + if (clcit->ptCursor.x == pt.x && clcit->ptCursor.y == pt.y) return 0; + pt.x = pt.y = 0; + + CLCINFOTIPEX *clcit2 = (CLCINFOTIPEX *)mir_alloc(sizeof(CLCINFOTIPEX)); + memcpy(clcit2, clcit, sizeof(CLCINFOTIP)); + clcit2->cbSize = sizeof(CLCINFOTIPEX); + clcit2->szProto = NULL; + clcit2->swzText = NULL; + + if (wParam) // wParam is char pointer containing text - e.g. status bar tooltip + { + clcit2->swzText = a2t((char *)wParam); + GetCursorPos(&clcit2->ptCursor); + } + + PostMPMessage(MUM_CREATEPOPUP, 0, (LPARAM)clcit2); + return 1; +} + +int ShowTipHook(WPARAM wParam, LPARAM lParam) +{ + ShowTip(wParam, lParam); + return 0; +} + +INT_PTR ShowTipW(WPARAM wParam, LPARAM lParam) +{ + CLCINFOTIP *clcit = (CLCINFOTIP *)lParam; + HWND clist = (HWND)CallService(MS_CLUI_GETHWNDTREE, 0, 0); + + if (clcit->isGroup) return 0; // no group tips (since they're pretty useless) + if (clcit->isTreeFocused == 0 && opt.bShowNoFocus == false && clist == WindowFromPoint(clcit->ptCursor)) return 0; + if (clcit->ptCursor.x == pt.x && clcit->ptCursor.y == pt.y) return 0; + pt.x = pt.y = -1; + + CLCINFOTIPEX *clcit2 = (CLCINFOTIPEX *)mir_alloc(sizeof(CLCINFOTIPEX)); + memcpy(clcit2, clcit, sizeof(CLCINFOTIP)); + clcit2->cbSize = sizeof(CLCINFOTIPEX); + clcit2->szProto = NULL; + clcit2->swzText = NULL; + + if (wParam) // wParam is char pointer containing text - e.g. status bar tooltip + { + clcit2->swzText = mir_tstrdup((TCHAR *)wParam); + GetCursorPos(&clcit2->ptCursor); + } + + PostMPMessage(MUM_CREATEPOPUP, 0, (LPARAM)clcit2); + return 1; +} + +INT_PTR HideTip(WPARAM wParam, LPARAM lParam) +{ + //CLCINFOTIP *clcit = (CLCINFOTIP *)lParam; + if (GetAsyncKeyState(VK_CONTROL) & 0x8000) + return 0; + + GetCursorPos(&pt); + PostMPMessage(MUM_DELETEPOPUP, 0, 0); + return 1; +} + +int HideTipHook(WPARAM wParam, LPARAM lParam) +{ + HideTip(wParam, lParam); + return 0; +} + +int ProtoAck(WPARAM wParam, LPARAM lParam) +{ + ACKDATA *ack = (ACKDATA *)lParam; + if (ack->result != ACKRESULT_SUCCESS) + return 0; + + if (ack->type == ACKTYPE_AWAYMSG) { + TCHAR* tszMsg = ( TCHAR* )ack->lParam; + if ( lstrlen(tszMsg)) + PostMPMessage(MUM_GOTSTATUS, (WPARAM)ack->hContact, (LPARAM)mir_tstrdup(tszMsg)); + } + else if (ack->type == ICQACKTYPE_XSTATUS_RESPONSE) + { + PostMPMessage(MUM_GOTXSTATUS, (WPARAM)ack->hContact, 0); + } + + return 0; +} + +int AvatarChanged(WPARAM wParam, LPARAM lParam) +{ + HANDLE hContact = (HANDLE)wParam; + PostMPMessage(MUM_GOTAVATAR, (WPARAM)hContact, 0); + return 0; +} + +int FramesShowSBTip(WPARAM wParam, LPARAM lParam) +{ + if (opt.bStatusBarTips) + { + char *szProto = (char *)wParam; + + CLCINFOTIPEX *clcit2 = (CLCINFOTIPEX *)mir_alloc(sizeof(CLCINFOTIPEX)); + memset(clcit2, 0, sizeof(CLCINFOTIPEX)); + clcit2->cbSize = sizeof(CLCINFOTIPEX); + clcit2->szProto= szProto; // assume static string + GetCursorPos(&clcit2->ptCursor); + + PostMPMessage(MUM_CREATEPOPUP, 0, (LPARAM)clcit2); + return 1; + } + return 0; +} + +int FramesHideSBTip(WPARAM wParam, LPARAM lParam) +{ + if (opt.bStatusBarTips) + { + PostMPMessage(MUM_DELETEPOPUP, 0, 0); + return 1; + } + return 0; +} + +BOOL MyDestroyWindow(HWND hwnd) +{ + SendMessage(hwnd, PUM_FADEOUTWINDOW, 0, 0); + return DestroyWindow(hwnd); +} \ No newline at end of file diff --git a/plugins/TipperYM/src/message_pump.h b/plugins/TipperYM/src/message_pump.h new file mode 100644 index 0000000000..a8858e3865 --- /dev/null +++ b/plugins/TipperYM/src/message_pump.h @@ -0,0 +1,71 @@ +/* +Copyright (C) 2006-2007 Scott Ellis +Copyright (C) 2007-2011 Jan Holub + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#ifndef _MESSAGE_PUMP_INC +#define _MESSAGE_PUMP_INC + +#define WAIT_TIMER_INTERVAL 500 + +#define MUM_CREATEPOPUP (WM_USER + 0x011) +#define MUM_DELETEPOPUP (WM_USER + 0x012) +#define MUM_GOTSTATUS (WM_USER + 0x013) +#define MUM_GOTAVATAR (WM_USER + 0x014) +#define MUM_GOTXSTATUS (WM_USER + 0x015) + +extern BOOL (WINAPI *MySetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD); +extern BOOL (WINAPI *MyUpdateLayeredWindow)(HWND hwnd, HDC hdcDST, POINT *pptDst, SIZE *psize, HDC hdcSrc, POINT *pptSrc, COLORREF crKey, BLENDFUNCTION *pblend, DWORD dwFlags); +extern BOOL (WINAPI *MyAnimateWindow)(HWND hWnd,DWORD dwTime,DWORD dwFlags); +extern HMONITOR (WINAPI *MyMonitorFromPoint)(POINT, DWORD); +extern BOOL (WINAPI *MyGetMonitorInfo)(HMONITOR, LPMONITORINFO); + +#define DWM_BB_ENABLE 0x00000001 +#define DWM_BB_BLURREGION 0x00000002 +#define DWM_BB_TRANSITIONONMAXIMIZED 0x00000004 +struct DWM_BLURBEHIND +{ + DWORD dwFlags; + BOOL fEnable; + HRGN hRgnBlur; + BOOL fTransitionOnMaximized; +}; + +extern HRESULT (WINAPI *MyDwmEnableBlurBehindWindow)(HWND hWnd, DWM_BLURBEHIND *pBlurBehind); + +void InitMessagePump(); +void DeinitMessagePump(); + +INT_PTR ShowTip(WPARAM wParam, LPARAM lParam); +INT_PTR ShowTipW(WPARAM wParam, LPARAM lParam); +INT_PTR HideTip(WPARAM wParam, LPARAM lParam); + +int ShowTipHook(WPARAM wParam, LPARAM lParam); +int HideTipHook(WPARAM wParam, LPARAM lParam); + +int FramesShowSBTip(WPARAM wParam, LPARAM lParam); +int FramesHideSBTip(WPARAM wParam, LPARAM lParam); + +int ProtoAck(WPARAM wParam, LPARAM lParam); +int AvatarChanged(WPARAM wParam, LPARAM lParam); + +BOOL MyDestroyWindow(HWND hwnd); +void PostMPMessage(UINT msg, WPARAM, LPARAM); + + +#endif diff --git a/plugins/TipperYM/src/mir_smileys.cpp b/plugins/TipperYM/src/mir_smileys.cpp new file mode 100644 index 0000000000..5af05c4b22 --- /dev/null +++ b/plugins/TipperYM/src/mir_smileys.cpp @@ -0,0 +1,514 @@ +/* +Copyright (C) 2005 Ricardo Pescuma Domenecci +Copyright (C) 2007-2010 Jan Holub + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#include "common.h" +#include "options.h" +#include "mir_smileys.h" + + + +void *mir_alloc0(size_t size) +{ + void *ptr = mir_alloc(size); + if (ptr) memset(ptr, 0, size); + + return ptr; +} + +int InitTipperSmileys() +{ + // Register smiley category + if (ServiceExists(MS_SMILEYADD_REGISTERCATEGORY)) + { + SMADD_REGCAT rc; + rc.cbSize = sizeof(rc); + rc.name = "tipper"; + rc.dispname = Translate("Tipper smileys"); + CallService(MS_SMILEYADD_REGISTERCATEGORY, 0, (LPARAM)&rc); + } + + return 0; +} + +SMILEYPARSEINFO Smileys_PreParse(LPCTSTR lpString, int nCount, const char *protocol) +{ + if (!(opt.iSmileyAddFlags & SMILEYADD_ENABLE)) + return NULL; + + if (nCount == -1) + nCount = (int)lstrlen(lpString); + + SMILEYPARSEINFO info = (SMILEYPARSEINFO) mir_alloc0(sizeof(tagSMILEYPARSEINFO)); + info->pieces = ReplaceSmileys(lpString, nCount, protocol, &info->max_height); + + if (!info->pieces) + { + mir_free(info); + return NULL; + } + + return info; +} + +void Smileys_FreeParse(SMILEYPARSEINFO parseInfo) +{ + if (parseInfo != NULL) + { + if (parseInfo->pieces != NULL) + DestroySmileyList(parseInfo->pieces); + + mir_free(parseInfo); + } +} + +// Similar to DrawText win32 api function +// Pass uFormat | DT_CALCRECT to calc rectangle to be returned by lpRect +// parseInfo is optional (pass NULL and it will be calculated and deleted inside function +int Smileys_DrawText(HDC hDC, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat, const char *protocol, SMILEYPARSEINFO parseInfo) +{ + int result; + + if (nCount == -1) + nCount = (int)lstrlen(lpString); + + if (uFormat & DT_CALCRECT) + { + SIZE text_size = GetTextSize(hDC, lpString, parseInfo, uFormat, parseInfo->max_height, (lpRect->right - lpRect->left)); + lpRect->bottom = text_size.cy; + + if (text_size.cx < lpRect->right - lpRect->left) + { + if (uFormat & DT_RIGHT) + lpRect->left = lpRect->right - text_size.cx; + else + lpRect->right = lpRect->left + text_size.cx; + } + + result = text_size.cy; + } + else + { + // Draw + if (parseInfo->pieces == NULL) + { + result = DrawText(hDC, lpString, nCount, lpRect, uFormat); + } + else + { + RECT rc = *lpRect; + SIZE text_size = GetTextSize(hDC, lpString, parseInfo, uFormat, parseInfo->max_height, (lpRect->right - lpRect->left)); + + if (text_size.cx < rc.right - rc.left) + { + if (uFormat & DT_RIGHT) + rc.left = rc.right - text_size.cx; + else + rc.right = rc.left + text_size.cx; + } + + result = text_size.cy; + DrawTextSmiley(hDC, rc, lpString, nCount, parseInfo, uFormat, parseInfo->max_height); + } + } + + return result; +} + +SIZE GetTextSize(HDC hdcMem, const TCHAR *szText, SMILEYPARSEINFO info, UINT uTextFormat, int max_smiley_height, int max_width) +{ + SIZE text_size = {0}; + int text_height; + int row_count = 0, pos_x = 0; + + if (szText == NULL || _tcsclen(szText) == 0) + { + text_size.cy = 0; + text_size.cx = 0; + } + else + { + RECT text_rc = {0, 0, 2048, 2048}; + + if (info->pieces == NULL) + { + DrawText(hdcMem, szText, -1, &text_rc, DT_CALCRECT | uTextFormat); + text_size.cx = text_rc.right - text_rc.left; + text_size.cy = text_rc.bottom - text_rc.top; + } + else + { + // Get real height of the line + text_height = DrawText(hdcMem, _T("A"), 1, &text_rc, DT_CALCRECT | uTextFormat); + + // See each item of list + int i; + for (i = 0; i < info->pieces->realCount; i++) + { + TEXTPIECE *piece = (TEXTPIECE *) info->pieces->items[i]; + info->row_height[row_count] = max(info->row_height[row_count], text_height); + + if (piece->type == TEXT_PIECE_TYPE_TEXT) + { + RECT text_rc = {0, 0, 2048, 2048}; + + DrawText(hdcMem, szText + piece->start_pos, piece->len, &text_rc, DT_CALCRECT | uTextFormat); + pos_x += (text_rc.right - text_rc.left); + if (pos_x > max_width) + { + text_size.cx = max(text_size.cx, pos_x - (text_rc.right - text_rc.left)); + pos_x = text_rc.right - text_rc.left; + info->row_height[++row_count] = text_height; + } + + if (szText[piece->start_pos + piece->len - 1] == '\n') + { + text_size.cx = max(text_size.cx, pos_x); + pos_x = 0; + info->row_height[++row_count] = 0; + } + + } + else + { + double factor; + + if (uTextFormat & DT_RESIZE_SMILEYS && piece->smiley_height > text_height) + factor = text_height / (double) piece->smiley_height; + else + factor = 1; + + info->row_height[row_count] = max(info->row_height[row_count], piece->smiley_height * factor); + + pos_x += piece->smiley_width * factor; + if (pos_x > max_width) + { + text_size.cx = max(text_size.cx, pos_x - (piece->smiley_width * factor)); + pos_x = piece->smiley_width * factor; + info->row_height[++row_count] = piece->smiley_height * factor; + } + } + } + + text_size.cx = max(text_size.cx, pos_x); + for (i = 0; i < row_count + 1; i++) + text_size.cy += info->row_height[i]; + } + } + + return text_size; +} + +void DrawTextSmiley(HDC hdcMem, RECT free_rc, const TCHAR *szText, int len, SMILEYPARSEINFO info, UINT uTextFormat, int max_smiley_height) +{ + if (szText == NULL) + return; + + uTextFormat &= ~DT_RIGHT; + + // Draw list + int text_height, i, shift; + int row_count = 0, pos_x = 0; + + RECT tmp_rc = free_rc; + + if (uTextFormat & DT_RTLREADING) + i = info->pieces->realCount - 1; + else + i = 0; + + // Get real height of the line + text_height = DrawText(hdcMem, _T("A"), 1, &tmp_rc, DT_CALCRECT | uTextFormat); + + if (IsWinVer2000Plus()) + SaveAlpha(&free_rc); + + // Just draw ellipsis + if (free_rc.right <= free_rc.left) + { + DrawText(hdcMem, _T("..."), 3, &free_rc, uTextFormat & ~DT_END_ELLIPSIS); + } + else + { + // Draw text and smileys + RECT text_rc = free_rc; + for (; i < info->pieces->realCount && i >= 0 && len > 0; i += (uTextFormat & DT_RTLREADING ? -1 : 1)) + { + TEXTPIECE *piece = (TEXTPIECE *) info->pieces->items[i]; + + if (uTextFormat & DT_RTLREADING) + text_rc.right = free_rc.right - pos_x; + else + text_rc.left = free_rc.left + pos_x; + + if (piece->type == TEXT_PIECE_TYPE_TEXT) + { + tmp_rc = text_rc; + tmp_rc.right = 2048; + + DrawText(hdcMem, szText + piece->start_pos, min(len, piece->len), &tmp_rc, DT_CALCRECT | (uTextFormat & ~DT_END_ELLIPSIS)); + + pos_x += (tmp_rc.right - tmp_rc.left); + if (pos_x > (free_rc.right - free_rc.left)) + { + pos_x = tmp_rc.right - tmp_rc.left; + text_rc.left = free_rc.left; + text_rc.right = free_rc.right; + text_rc.top += info->row_height[row_count]; + row_count++; + } + + shift = (info->row_height[row_count] - text_height) >> 1; + text_rc.top += shift; + + if (uTextFormat & DT_RTLREADING) + text_rc.left = max(text_rc.left, text_rc.right - (tmp_rc.right - tmp_rc.left)); + + DrawText(hdcMem, szText + piece->start_pos, min(len, piece->len), &text_rc, uTextFormat); + len -= piece->len; + text_rc.top -= shift; + + if (szText[piece->start_pos + piece->len - 1] == '\n') + { + text_rc.left = free_rc.left; + text_rc.right = free_rc.right; + text_rc.top += info->row_height[row_count]; + pos_x = 0; + row_count++; + } + } + else + { + double factor; + + if (len < piece->len) + { + len = 0; + } + else + { + len -= piece->len; + + if (uTextFormat & DT_RESIZE_SMILEYS && piece->smiley_height > text_height) + factor = text_height / (double) piece->smiley_height; + else + factor = 1; + + if (uTextFormat & DT_RTLREADING) + text_rc.left = max(text_rc.right - (int)(piece->smiley_width * factor), text_rc.left); + + pos_x += piece->smiley_width * factor; + if (pos_x > (free_rc.right - free_rc.left)) + { + pos_x = piece->smiley_width * factor; + text_rc.left = free_rc.left; + text_rc.right = free_rc.right; + text_rc.top += info->row_height[row_count]; + row_count++; + } + + shift = (info->row_height[row_count] - (LONG)(piece->smiley_height * factor)) >> 1; + DrawIconExAlpha(hdcMem, text_rc.left, text_rc.top + shift, piece->smiley, piece->smiley_width * factor, piece->smiley_height * factor, 0, NULL, DI_NORMAL, true); + } + } + } + } + + if (IsWinVer2000Plus()) + RestoreAlpha(&free_rc); +} + +void DestroySmileyList(SortedList* p_list) +{ + if (p_list == NULL) + return; + + if (p_list->items != NULL) + { + int i; + for (i = 0 ; i < p_list->realCount ; i++) + { + TEXTPIECE *piece = (TEXTPIECE *)p_list->items[i]; + if (piece != NULL) + { + if (piece->type == TEXT_PIECE_TYPE_SMILEY) + DestroyIcon(piece->smiley); + + mir_free(piece); //this free the p_list->items[i] + } + } + } + List_Destroy(p_list); //this free the p_list->items member + mir_free(p_list); //this free the p_list itself (alloc by List_Create) +} + +// Generete the list of smileys / text to be drawn +SortedList *ReplaceSmileys(const TCHAR *text, int text_size, const char *protocol, int *max_smiley_height) +{ + SMADD_BATCHPARSE2 sp = {0}; + SMADD_BATCHPARSERES *spres; + char smileyProto[64]; + + *max_smiley_height = 0; + + if (!text || !text[0] || !ServiceExists(MS_SMILEYADD_BATCHPARSE)) + return NULL; + + if (protocol == NULL) + strcpy(smileyProto, "tipper"); + else if (strcmp(protocol, szMetaModuleName) == 0) + strcpy(smileyProto, "tipper"); + else + strcpy(smileyProto, protocol); + + // Parse it! + sp.cbSize = sizeof(sp); + sp.str = (TCHAR *)text; + sp.flag = SAFL_TCHAR; + sp.Protocolname = (opt.iSmileyAddFlags & SMILEYADD_USEPROTO) ? smileyProto : "tipper"; + spres = (SMADD_BATCHPARSERES *)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&sp); + + if (!spres) // Did not find a smiley + return NULL; + + // Lets add smileys + SortedList *plText = List_Create(0, 10); + + TCHAR *word_start, *word_end; + TCHAR *smiley_start, *smiley_end; + TCHAR *last_text_pos = _tcsninc(text, text_size); + + word_start = word_end = (TCHAR *)text; + + for (unsigned i = 0; i < sp.numSmileys; i++) + { + // Get smile position + smiley_start = _tcsninc(text, spres[i].startChar); + smiley_end = _tcsninc(smiley_start, spres[i].size); + + if (spres[i].hIcon) // For deffective smileypacks + { + if (opt.iSmileyAddFlags & SMILEYADD_ONLYISOLATED) + { + if ((smiley_start > text && *(smiley_start - 1) != ' ' && *(smiley_start - 1) != '\n' && *smiley_end != '\r') || + (*smiley_end != '\0' && *smiley_end != ' ' && *smiley_end != '\n' && *smiley_end != '\r')) + continue; + } + + // Add text + while (word_end != smiley_start) + { + while (word_end[0] != ' ' && word_end[0] != '\n') + word_end++; + + if (word_end > smiley_start) + word_end = smiley_start; + else + word_end++; + + if (word_end > word_start) + { + TEXTPIECE *piece = (TEXTPIECE *)mir_alloc0(sizeof(TEXTPIECE)); + piece->type = TEXT_PIECE_TYPE_TEXT; + piece->start_pos = word_start - text; + piece->len = word_end - word_start; + List_Insert(plText, piece, plText->realCount); + word_start = word_end; + } + } + + // Add smiley + { + BITMAP bm; + ICONINFO icon; + TEXTPIECE *piece = (TEXTPIECE *) mir_alloc0(sizeof(TEXTPIECE)); + + piece->type = TEXT_PIECE_TYPE_SMILEY; + piece->len = spres[i].size; + piece->smiley = spres[i].hIcon; + + piece->smiley_width = 16; + piece->smiley_height = 16; + if (GetIconInfo(piece->smiley, &icon)) + { + if (GetObject(icon.hbmColor, sizeof(BITMAP), &bm)) + { + piece->smiley_width = bm.bmWidth; + piece->smiley_height = bm.bmHeight; + } + + DeleteObject(icon.hbmMask); + DeleteObject(icon.hbmColor); + } + + *max_smiley_height = max(piece->smiley_height, *max_smiley_height); + List_Insert(plText, piece, plText->realCount); + } + + word_start = word_end = smiley_end; + } + } + + // Add rest of the text + while (word_end != last_text_pos) + { + while (word_end[0] && word_end[0] != ' ' && word_end[0] != '\n') + word_end++; + + if (word_end[0]) + word_end++; + + if (word_end > word_start) + { + TEXTPIECE *piece = (TEXTPIECE *)mir_alloc0(sizeof(TEXTPIECE)); + piece->type = TEXT_PIECE_TYPE_TEXT; + piece->start_pos = word_start - text; + piece->len = word_end - word_start; + List_Insert(plText, piece, plText->realCount); + word_start = word_end; + } + + } + + CallService(MS_SMILEYADD_BATCHFREE, 0, (LPARAM)spres); + + return plText; +} + +int DrawTextExt(HDC hdc, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat, LPCSTR lpProto, SMILEYPARSEINFO spi) +{ + if ((opt.iSmileyAddFlags & SMILEYADD_ENABLE) && spi != NULL) + { + if (opt.iSmileyAddFlags & SMILEYADD_RESIZE) + uFormat |= DT_RESIZE_SMILEYS; + + return Smileys_DrawText(hdc, lpString, nCount, lpRect, uFormat, lpProto, spi); + } + else + { + if (uFormat & DT_CALCRECT) + { + return DrawText(hdc, lpString, nCount, lpRect, uFormat); + } + else + { + return DrawTextAlpha(hdc, lpString, nCount, lpRect, uFormat); + } + } +} diff --git a/plugins/TipperYM/src/mir_smileys.h b/plugins/TipperYM/src/mir_smileys.h new file mode 100644 index 0000000000..5f78ac8f09 --- /dev/null +++ b/plugins/TipperYM/src/mir_smileys.h @@ -0,0 +1,70 @@ +/* +Copyright (C) 2005 Ricardo Pescuma Domenecci + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#ifndef __MIR_SMILEYS_H__ +#define __MIR_SMILEYS_H__ + +#define DT_RESIZE_SMILEYS 0x10000000 + +// smileyadd options +#define SMILEYADD_ENABLE 1 +#define SMILEYADD_USEPROTO 2 +#define SMILEYADD_ONLYISOLATED 4 +#define SMILEYADD_RESIZE 8 + +#define TEXT_PIECE_TYPE_TEXT 0 +#define TEXT_PIECE_TYPE_SMILEY 1 + +typedef struct { + int type; + int len; + union + { + struct + { + int start_pos; + }; + struct + { + HICON smiley; + int smiley_width; + int smiley_height; + }; + }; +} TEXTPIECE; + +typedef struct tagSMILEYPARSEINFO { + SortedList *pieces; + int row_height[512]; // max 512 rows + int max_height; +} *SMILEYPARSEINFO; + +int InitTipperSmileys(); +SMILEYPARSEINFO Smileys_PreParse(LPCTSTR lpString, int nCount, const char *protocol); +void Smileys_FreeParse(SMILEYPARSEINFO parseInfo); + +SortedList *ReplaceSmileys(const TCHAR *text, int text_size, const char *protocol, int *max_smiley_height); +SIZE GetTextSize(HDC hdcMem, const TCHAR *szText, SMILEYPARSEINFO info, UINT uTextFormat, int max_smiley_height, int max_width); +void DrawTextSmiley(HDC hdcMem, RECT free_rc, const TCHAR *szText, int len, SMILEYPARSEINFO info, UINT uTextFormat, int max_smiley_height); +void DestroySmileyList(SortedList* p_list); + +int Smileys_DrawText(HDC hDC, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat, const char *protocol, SMILEYPARSEINFO parseInfo); +int DrawTextExt(HDC hdc, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat, LPCSTR lpProto, SMILEYPARSEINFO spi); + +#endif // __MIR_SMILEYS_H__ diff --git a/plugins/TipperYM/src/options.cpp b/plugins/TipperYM/src/options.cpp new file mode 100644 index 0000000000..ceb4a223b5 --- /dev/null +++ b/plugins/TipperYM/src/options.cpp @@ -0,0 +1,2495 @@ +/* +Copyright (C) 2006-2007 Scott Ellis +Copyright (C) 2007-2011 Jan Holub + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#include "common.h" +#include "options.h" +#include "popwin.h" +#include "str_utils.h" +#include "message_pump.h" +#include "preset_items.h" +#include "skin_parser.h" + +OPTIONS opt; +ICONSTATE exIcons[EXICONS_COUNT]; + +extern TOOLTIPSKIN skin; +extern int ReloadFont(WPARAM wParam, LPARAM lParam); + + +extern int IsTrayProto(const TCHAR *swzProto, BOOL bExtendedTip) +{ + if (swzProto == NULL) + return 0; + + char szSetting[64]; + if (bExtendedTip) + strcpy(szSetting, "TrayProtocolsEx"); + else + strcpy(szSetting, "TrayProtocols"); + + DBVARIANT dbv; + int result = 1; + if (!DBGetContactSettingTString(NULL, MODULE, szSetting, &dbv)) + { + result = _tcsstr(dbv.ptszVal, swzProto) ? 1 : 0; + DBFreeVariant(&dbv); + } + + return result; +} + +void CreateDefaultItems() +{ + DSListNode *ds_node; + DIListNode *di_node; + + for (int i = 0; defaultItemList[i].szName; i++) + { + if (defaultItemList[i].szName[0] == '-') + { + di_node = (DIListNode *)mir_alloc(sizeof(DIListNode)); + _tcsncpy(di_node->di.swzLabel, _T(""), LABEL_LEN); + _tcsncpy(di_node->di.swzValue, _T(""), VALUE_LEN); + di_node->di.bLineAbove = true; + di_node->di.bIsVisible = true; + di_node->di.bParseTipperVarsFirst = false; + di_node->next = opt.diList; + opt.diList = di_node; + opt.iDiCount++; + } + else + { + PRESETITEM *item = GetPresetItemByName(defaultItemList[i].szName); + if (item == NULL) continue; + + for (int j = 0; j < MAX_PRESET_SUBST_COUNT; j++) + { + PRESETSUBST *subst = GetPresetSubstByName(item->szNeededSubst[j]); + if (subst == NULL) continue; + + ds_node = (DSListNode *)mir_alloc(sizeof(DSListNode)); + _tcsncpy(ds_node->ds.swzName, subst->swzName, LABEL_LEN); + ds_node->ds.type = subst->type; + strncpy(ds_node->ds.szSettingName, subst->szSettingName, SETTING_NAME_LEN); + ds_node->ds.iTranslateFuncId = subst->iTranslateFuncId; + ds_node->next = opt.dsList; + opt.dsList = ds_node; + opt.iDsCount++; + } + + di_node = (DIListNode *)mir_alloc(sizeof(DIListNode)); + _tcsncpy(di_node->di.swzLabel, TranslateTS(item->swzLabel), LABEL_LEN); + _tcsncpy(di_node->di.swzValue, item->swzValue, VALUE_LEN); + di_node->di.bLineAbove = false; + di_node->di.bValueNewline = defaultItemList[i].bValueNewline; + di_node->di.bIsVisible = true; + di_node->di.bParseTipperVarsFirst = false; + di_node->next = opt.diList; + opt.diList = di_node; + opt.iDiCount++; + } + } +} + + +bool LoadDS(DISPLAYSUBST *ds, int index) +{ + char setting[512]; + DBVARIANT dbv; + + mir_snprintf(setting, SIZEOF(setting), "Name%d", index); + ds->swzName[0] = 0; + if (!DBGetContactSettingTString(0, MODULE_ITEMS, setting, &dbv)) + { + _tcsncpy(ds->swzName, dbv.ptszVal, SIZEOF(ds->swzName)); + ds->swzName[SIZEOF(ds->swzName) - 1] = 0; + DBFreeVariant(&dbv); + } else + return false; + + mir_snprintf(setting, SIZEOF(setting), "Type%d", index); + ds->type = (DisplaySubstType)DBGetContactSettingByte(0, MODULE_ITEMS, setting, DVT_PROTODB); + + mir_snprintf(setting, SIZEOF(setting), "Module%d", index); + ds->szModuleName[0] = 0; + if (!DBGetContactSetting(0, MODULE_ITEMS, setting, &dbv)) + { + strncpy(ds->szModuleName, dbv.pszVal, MODULE_NAME_LEN); + ds->szModuleName[MODULE_NAME_LEN - 1] = 0; + DBFreeVariant(&dbv); + } + + mir_snprintf(setting, SIZEOF(setting), "Setting%d", index); + ds->szSettingName[0] = 0; + if (!DBGetContactSetting(0, MODULE_ITEMS, setting, &dbv)) + { + strncpy(ds->szSettingName, dbv.pszVal, SETTING_NAME_LEN); + ds->szSettingName[SETTING_NAME_LEN - 1] = 0; + DBFreeVariant(&dbv); + } + + mir_snprintf(setting, SIZEOF(setting), "TransFuncId%d", index); + ds->iTranslateFuncId = DBGetContactSettingDword(0, MODULE_ITEMS, setting, (DWORD)-1); + + // a little backward compatibility + if ((DWORD)ds->iTranslateFuncId == (DWORD)-1) + { + mir_snprintf(setting, SIZEOF(setting), "TransFunc%d", index); + ds->iTranslateFuncId = (DWORD)DBGetContactSettingWord(0, MODULE_ITEMS, setting, 0); + } + + return true; +} + + +void SaveDS(DISPLAYSUBST *ds, int index) +{ + char setting[512]; + + mir_snprintf(setting, SIZEOF(setting), "Name%d", index); + DBWriteContactSettingTString(0, MODULE_ITEMS, setting, ds->swzName); + mir_snprintf(setting, SIZEOF(setting), "Type%d", index); + DBWriteContactSettingByte(0, MODULE_ITEMS, setting, (BYTE)ds->type); + mir_snprintf(setting, SIZEOF(setting), "Module%d", index); + DBWriteContactSettingString(0, MODULE_ITEMS, setting, ds->szModuleName); + mir_snprintf(setting, SIZEOF(setting), "Setting%d", index); + DBWriteContactSettingString(0, MODULE_ITEMS, setting, ds->szSettingName); + mir_snprintf(setting, SIZEOF(setting), "TransFuncId%d", index); + DBWriteContactSettingDword(0, MODULE_ITEMS, setting, (WORD)ds->iTranslateFuncId); +} + + +bool LoadDI(DISPLAYITEM *di, int index) +{ + char setting[512]; + DBVARIANT dbv; + + mir_snprintf(setting, SIZEOF(setting), "DILabel%d", index); + di->swzLabel[0] = 0; + if (!DBGetContactSettingTString(0, MODULE_ITEMS, setting, &dbv)) + { + _tcsncpy( di->swzLabel, dbv.ptszVal, SIZEOF(di->swzLabel)); + di->swzLabel[SIZEOF(di->swzLabel) - 1] = 0; + DBFreeVariant(&dbv); + } else + return false; + + mir_snprintf(setting, SIZEOF(setting), "DIValue%d", index); + di->swzValue[0] = 0; + if (!DBGetContactSettingTString(0, MODULE_ITEMS, setting, &dbv)) + { + _tcsncpy(di->swzValue, dbv.ptszVal, SIZEOF(di->swzValue)); + di->swzValue[SIZEOF(di->swzValue) - 1] = 0; + DBFreeVariant(&dbv); + } + + mir_snprintf(setting, SIZEOF(setting), "DILineAbove%d", index); + di->bLineAbove = (DBGetContactSettingByte(0, MODULE_ITEMS, setting, 0) == 1); + mir_snprintf(setting, SIZEOF(setting), "DIValNewline%d", index); + di->bValueNewline = (DBGetContactSettingByte(0, MODULE_ITEMS, setting, 0) == 1); + mir_snprintf(setting, SIZEOF(setting), "DIVisible%d", index); + di->bIsVisible = (DBGetContactSettingByte(0, MODULE_ITEMS, setting, 1) == 1); + mir_snprintf(setting, SIZEOF(setting), "DITipperVarsFirst%d", index); + di->bParseTipperVarsFirst = (DBGetContactSettingByte(0, MODULE_ITEMS, setting, 0) == 1); + + return true; +} + + +void SaveDI(DISPLAYITEM *di, int index) +{ + char setting[512]; + + mir_snprintf(setting, SIZEOF(setting), "DILabel%d", index); + if (DBWriteContactSettingTString(0, MODULE_ITEMS, setting, di->swzLabel)) + { + char buff[LABEL_LEN]; + t2a(di->swzLabel, buff, LABEL_LEN); + DBWriteContactSettingString(0, MODULE_ITEMS, setting, buff); + } + + mir_snprintf(setting, SIZEOF(setting), "DIValue%d", index); + if (DBWriteContactSettingTString(0, MODULE_ITEMS, setting, di->swzValue)) + { + char buff[VALUE_LEN]; + t2a(di->swzValue, buff, VALUE_LEN); + DBWriteContactSettingString(0, MODULE_ITEMS, setting, buff); + } + + mir_snprintf(setting, SIZEOF(setting), "DILineAbove%d", index); + DBWriteContactSettingByte(0, MODULE_ITEMS, setting, di->bLineAbove ? 1 : 0); + mir_snprintf(setting, SIZEOF(setting), "DIValNewline%d", index); + DBWriteContactSettingByte(0, MODULE_ITEMS, setting, di->bValueNewline ? 1 : 0); + mir_snprintf(setting, SIZEOF(setting), "DIVisible%d", index); + DBWriteContactSettingByte(0, MODULE_ITEMS, setting, di->bIsVisible ? 1 : 0); + mir_snprintf(setting, SIZEOF(setting), "DITipperVarsFirst%d", index); + DBWriteContactSettingByte(0, MODULE_ITEMS, setting, di->bParseTipperVarsFirst ? 1 : 0); +} + + +void SaveOptions() +{ + DBWriteContactSettingDword(0, MODULE, "MaxWidth", opt.iWinWidth); + DBWriteContactSettingDword(0, MODULE, "MaxHeight", opt.iWinMaxHeight); + DBWriteContactSettingByte(0, MODULE, "AvatarOpacity", (BYTE)opt.iAvatarOpacity); + DBWriteContactSettingByte(0, MODULE, "AvatarRoundCorners", (opt.bAvatarRound ? 1 : 0)); + DBWriteContactSettingByte(0, MODULE, "TitleLayout", (BYTE)opt.titleLayout); + if (ServiceExists(MS_AV_DRAWAVATAR)) + DBWriteContactSettingByte(0, MODULE, "AVLayout", (BYTE)opt.avatarLayout); + opt.bWaitForAvatar = (opt.avatarLayout == PAV_NONE) ? false : true; + + DBWriteContactSettingDword(0, MODULE, "AVSize", opt.iAvatarSize); + DBWriteContactSettingDword(0, MODULE, "TextIndent", opt.iTextIndent); + DBWriteContactSettingDword(0, MODULE, "TitleIndent", opt.iTitleIndent); + DBWriteContactSettingDword(0, MODULE, "ValueIndent", opt.iValueIndent); + DBWriteContactSettingByte(0, MODULE, "ShowNoFocus", (opt.bShowNoFocus ? 1 : 0)); + + DBWriteContactSettingWord(0, MODULE, "TimeIn", opt.iTimeIn); + CallService(MS_CLC_SETINFOTIPHOVERTIME, opt.iTimeIn, 0); + + DBWriteContactSettingWord(0, MODULE, "Padding", opt.iPadding); + DBWriteContactSettingWord(0, MODULE, "OuterAvatarPadding", opt.iOuterAvatarPadding); + DBWriteContactSettingWord(0, MODULE, "InnerAvatarPadding", opt.iInnerAvatarPadding); + DBWriteContactSettingWord(0, MODULE, "TextPadding", opt.iTextPadding); + DBWriteContactSettingByte(0, MODULE, "Position", (BYTE)opt.pos); + DBWriteContactSettingDword(0, MODULE, "MinWidth", (DWORD)opt.iMinWidth); + DBWriteContactSettingDword(0, MODULE, "MinHeight", (DWORD)opt.iMinHeight); + DBWriteContactSettingDword(0, MODULE, "SidebarWidth", (DWORD)opt.iSidebarWidth); + DBWriteContactSettingByte(0, MODULE, "MouseTollerance", (BYTE)opt.iMouseTollerance); + DBWriteContactSettingByte(0, MODULE, "SBarTips", (opt.bStatusBarTips ? 1 : 0)); + + DBWriteContactSettingWord(0, MODULE, "LabelVAlign", opt.iLabelValign); + DBWriteContactSettingWord(0, MODULE, "LabelHAlign", opt.iLabelHalign); + DBWriteContactSettingWord(0, MODULE, "ValueVAlign", opt.iValueValign); + DBWriteContactSettingWord(0, MODULE, "ValueHAlign", opt.iValueHalign); + + DBWriteContactSettingByte(0, MODULE, "OriginalAvSize", (opt.bOriginalAvatarSize ? 1 : 0)); + DBWriteContactSettingByte(0, MODULE, "AvatarBorder", (opt.bAvatarBorder ? 1 : 0)); +} + +void SaveItems() +{ + int index = 0; + DSListNode *ds_node = opt.dsList; + while (ds_node) + { + SaveDS(&ds_node->ds, index); + ds_node = ds_node->next; + index++; + } + + DBWriteContactSettingWord(0, MODULE_ITEMS, "DSNumValues", index); + + index = 0; + DIListNode *di_node = opt.diList; + opt.bWaitForStatusMsg = false; + while (di_node) + { + SaveDI(&di_node->di, index); + if (di_node->di.bIsVisible && _tcsstr(di_node->di.swzValue, _T("sys:status_msg"))) + opt.bWaitForStatusMsg = true; + di_node = di_node->next; + index++; + } + + DBWriteContactSettingWord(0, MODULE_ITEMS, "DINumValues", index); +} + +void SaveSkinOptions() +{ + DBWriteContactSettingByte(0, MODULE, "Border", (opt.bBorder ? 1 : 0)); + DBWriteContactSettingByte(0, MODULE, "DropShadow", (opt.bDropShadow ? 1 : 0)); + DBWriteContactSettingByte(0, MODULE, "RoundCorners", (opt.bRound ? 1 : 0)); + DBWriteContactSettingByte(0, MODULE, "AeroGlass", (opt.bAeroGlass ? 1 : 0)); + DBWriteContactSettingByte(0, MODULE, "Opacity", (BYTE)opt.iOpacity); + DBWriteContactSettingByte(0, MODULE, "ShowEffect", (BYTE)opt.showEffect); + DBWriteContactSettingByte(0, MODULE, "ShowEffectSpeed", (BYTE)opt.iAnimateSpeed); + DBWriteContactSettingByte(0, MODULE, "LoadFonts", (opt.bLoadFonts ? 1 : 0)); + DBWriteContactSettingByte(0, MODULE, "LoadProportions", (opt.bLoadProportions ? 1 : 0)); + DBWriteContactSettingDword(0, MODULE, "EnableColoring", opt.iEnableColoring); +} + +void LoadObsoleteSkinSetting() +{ + char setting[128]; + DBVARIANT dbv; + + for (int i = 0; i < SKIN_ITEMS_COUNT; i++) + { + mir_snprintf(setting, 128, "SPaintMode%d", i); + opt.transfMode[i] = (TransformationMode)DBGetContactSettingByte(0, MODULE, setting, 0); + mir_snprintf(setting, 128, "SImgFile%d", i); + if (!DBGetContactSettingTString(NULL, MODULE, setting, &dbv)) + { + opt.szImgFile[i] = mir_tstrdup(dbv.ptszVal); + DBFreeVariant(&dbv); + } + + mir_snprintf(setting, 128, "SGlyphMargins%d", i); + DWORD margins = DBGetContactSettingDword(NULL, MODULE, setting, 0); + opt.margins[i].top = LOBYTE(LOWORD(margins)); + opt.margins[i].right = HIBYTE(LOWORD(margins)); + opt.margins[i].bottom = LOBYTE(HIWORD(margins)); + opt.margins[i].left = HIBYTE(HIWORD(margins)); + } +} + +void LoadOptions() +{ + opt.iWinWidth = DBGetContactSettingDword(0, MODULE, "MaxWidth", 420); + opt.iWinMaxHeight = DBGetContactSettingDword(0, MODULE, "MaxHeight", 400); + opt.iAvatarOpacity = DBGetContactSettingByte(0, MODULE, "AvatarOpacity", 100); + if (opt.iAvatarOpacity > 100) opt.iAvatarOpacity = 100; + opt.bAvatarRound = (DBGetContactSettingByte(0, MODULE, "AvatarRoundCorners", opt.bRound ? 1 : 0) == 1); + opt.titleLayout = (PopupTitleLayout)DBGetContactSettingByte(0, MODULE, "TitleLayout", (BYTE)PTL_LEFTICON); + if (ServiceExists(MS_AV_DRAWAVATAR)) + opt.avatarLayout = (PopupAvLayout)DBGetContactSettingByte(0, MODULE, "AVLayout", PAV_RIGHT); + else + opt.avatarLayout = PAV_NONE; + + opt.bWaitForAvatar = (opt.avatarLayout == PAV_NONE) ? false : true; + opt.iAvatarSize = DBGetContactSettingDword(0, MODULE, "AVSize", 60); //tweety + opt.iTextIndent = DBGetContactSettingDword(0, MODULE, "TextIndent", 22); + opt.iTitleIndent = DBGetContactSettingDword(0, MODULE, "TitleIndent", 22); + opt.iValueIndent = DBGetContactSettingDword(0, MODULE, "ValueIndent", 10); + opt.iSidebarWidth = DBGetContactSettingDword(0, MODULE, "SidebarWidth", 22); + opt.bShowNoFocus = (DBGetContactSettingByte(0, MODULE, "ShowNoFocus", 1) == 1); + + int i, real_count = 0; + opt.dsList = 0; + DSListNode *ds_node; + + opt.iDsCount = DBGetContactSettingWord(0, MODULE_ITEMS, "DSNumValues", 0); + for (i = opt.iDsCount - 1; i >= 0; i--) + { + ds_node = (DSListNode *)mir_alloc(sizeof(DSListNode)); + if (LoadDS(&ds_node->ds, i)) + { + ds_node->next = opt.dsList; + opt.dsList = ds_node; + real_count++; + } + else + { + mir_free(ds_node); + } + } + opt.iDsCount = real_count; + + real_count = 0; + opt.diList = 0; + DIListNode *di_node; + + opt.bWaitForStatusMsg = false; + opt.iDiCount = DBGetContactSettingWord(0, MODULE_ITEMS, "DINumValues", 0); + for (i = opt.iDiCount - 1; i >= 0; i--) + { + di_node = (DIListNode *)mir_alloc(sizeof(DIListNode)); + if (LoadDI(&di_node->di, i)) + { + di_node->next = opt.diList; + opt.diList = di_node; + real_count++; + if (di_node->di.bIsVisible && _tcsstr(di_node->di.swzValue, _T("sys:status_msg"))) + opt.bWaitForStatusMsg = true; + } + else + { + mir_free(di_node); + } + } + opt.iDiCount = real_count; + + opt.iTimeIn = DBGetContactSettingWord(0, MODULE, "TimeIn", 750); + opt.iPadding = DBGetContactSettingWord(0, MODULE, "Padding", 4); + opt.iOuterAvatarPadding = DBGetContactSettingWord(0, MODULE, "OuterAvatarPadding", 6); + opt.iInnerAvatarPadding = DBGetContactSettingWord(0, MODULE, "InnerAvatarPadding", 10); + opt.iTextPadding = DBGetContactSettingWord(0, MODULE, "TextPadding", 4); + opt.pos = (PopupPosition)DBGetContactSettingByte(0, MODULE, "Position", (BYTE)PP_BOTTOMRIGHT); + opt.iMinWidth = DBGetContactSettingDword(0, MODULE, "MinWidth", 0); + opt.iMinHeight = DBGetContactSettingDword(0, MODULE, "MinHeight", 0); + + opt.iMouseTollerance = DBGetContactSettingByte(0, MODULE, "MouseTollerance", (BYTE)GetSystemMetrics(SM_CXSMICON)); + opt.bStatusBarTips = (DBGetContactSettingByte(0, MODULE, "SBarTips", 1) == 1); + + // convert defunct last message and status message options to new 'sys' items, and remove the old settings + if (DBGetContactSettingByte(0, MODULE, "ShowLastMessage", 0)) + { + DBDeleteContactSetting(0, MODULE, "ShowLastMessage"); + + // find end of list + di_node = opt.diList; + while(di_node && di_node->next) + di_node = di_node->next; + + // last message item + if (di_node) + { + di_node->next = (DIListNode *)mir_alloc(sizeof(DIListNode)); + di_node = di_node->next; + } + else + { + opt.diList = (DIListNode *)mir_alloc(sizeof(DIListNode)); + di_node = opt.diList; + } + + _tcsncpy(di_node->di.swzLabel, _T("Last message: (%sys:last_msg_reltime% ago)"), LABEL_LEN); + _tcsncpy(di_node->di.swzValue, _T("%sys:last_msg%"), VALUE_LEN); + di_node->di.bLineAbove = di_node->di.bValueNewline = true; + di_node->next = 0; + opt.iDiCount++; + } + + if (DBGetContactSettingByte(0, MODULE, "ShowStatusMessage", 0)) + { + DBDeleteContactSetting(0, MODULE, "ShowStatusMessage"); + + // find end of list + di_node = opt.diList; + while(di_node && di_node->next) + di_node = di_node->next; + + // status message item + if (di_node) + { + di_node->next = (DIListNode *)mir_alloc(sizeof(DIListNode)); + di_node = di_node->next; + } + else + { + opt.diList = (DIListNode *)mir_alloc(sizeof(DIListNode)); + di_node = opt.diList; + } + + _tcsncpy(di_node->di.swzLabel, _T("Status message:"), LABEL_LEN); + _tcsncpy(di_node->di.swzValue, _T("%sys:status_msg%"), VALUE_LEN); + di_node->di.bLineAbove = di_node->di.bValueNewline = true; + di_node->next = 0; + opt.iDiCount++; + } + + opt.iLabelValign = DBGetContactSettingWord(0, MODULE, "LabelVAlign", DT_TOP /*DT_VCENTER*/); + opt.iLabelHalign = DBGetContactSettingWord(0, MODULE, "LabelHAlign", DT_LEFT); + opt.iValueValign = DBGetContactSettingWord(0, MODULE, "ValueVAlign", DT_TOP /*DT_VCENTER*/); + opt.iValueHalign = DBGetContactSettingWord(0, MODULE, "ValueHAlign", DT_LEFT); + + // tray tooltip + opt.bTraytip = DBGetContactSettingByte(0, MODULE, "TrayTip", 1) ? true : false; + opt.bHandleByTipper = DBGetContactSettingByte(0, MODULE, "ExtendedTrayTip", 1) ? true : false; + opt.bExpandTraytip = DBGetContactSettingByte(0, MODULE, "ExpandTrayTip", 1) ? true : false; + opt.bHideOffline = DBGetContactSettingByte(0, MODULE, "HideOffline", 0) ? true : false; + opt.iExpandTime = DBGetContactSettingDword(0, MODULE, "ExpandTime", 1000); + opt.iFirstItems = DBGetContactSettingDword(0, MODULE, "TrayTipItems", TRAYTIP_NUMCONTACTS | TRAYTIP_LOGON | TRAYTIP_STATUS | TRAYTIP_CLIST_EVENT); + opt.iSecondItems = DBGetContactSettingDword(0, MODULE, "TrayTipItemsEx", TRAYTIP_NUMCONTACTS | TRAYTIP_LOGON | TRAYTIP_STATUS | TRAYTIP_STATUS_MSG | TRAYTIP_EXTRA_STATUS | TRAYTIP_MIRANDA_UPTIME | TRAYTIP_CLIST_EVENT); + opt.iFavoriteContFlags = DBGetContactSettingDword(0, MODULE, "FavContFlags", FAVCONT_APPEND_PROTO); + + // extra setting + opt.bWaitForContent= DBGetContactSettingByte(0, MODULE, "WaitForContent", 0) ? true : false; + opt.bGetNewStatusMsg = DBGetContactSettingByte(0, MODULE, "GetNewStatusMsg", 0) ? true : false; + opt.bDisableIfInvisible = DBGetContactSettingByte(0, MODULE, "DisableInvisible", 1) ? true : false; + opt.bRetrieveXstatus = DBGetContactSettingByte(0, MODULE, "RetrieveXStatus", 0) ? true : false; + opt.bOriginalAvatarSize = DBGetContactSettingByte(0, MODULE, "OriginalAvSize", 0) ? true : false; + opt.bAvatarBorder = DBGetContactSettingByte(0, MODULE, "AvatarBorder", 0) ? true : false; + opt.bLimitMsg = DBGetContactSettingByte(0, MODULE, "LimitMsg", 0) ? true : false; + opt.iLimitCharCount = DBGetContactSettingByte(0, MODULE, "LimitCharCount", 64); + opt.iSmileyAddFlags = DBGetContactSettingDword(0, MODULE, "SmileyAddFlags", SMILEYADD_ENABLE); + + DBVARIANT dbv; + // Load the icons order + for(i = 0; i < EXICONS_COUNT; i++) + { + opt.exIconsOrder[i]=i; + opt.exIconsVis[i]=1; + } + + if (!DBGetContactSetting(NULL, MODULE, "IconOrder", &dbv)) + { + CopyMemory(opt.exIconsOrder,dbv.pbVal,dbv.cpbVal); + DBFreeVariant(&dbv); + } + + if (!DBGetContactSetting(NULL, MODULE, "icons_vis", &dbv)) + { + CopyMemory(opt.exIconsVis,dbv.pbVal,dbv.cpbVal); + DBFreeVariant(&dbv); + } + + for(i = 0; i < EXICONS_COUNT; i++) + { + exIcons[i].order = opt.exIconsOrder[i]; + exIcons[i].vis = opt.exIconsVis[i]; + } + + opt.iOpacity = DBGetContactSettingByte(0, MODULE, "Opacity", 75); + opt.bBorder = DBGetContactSettingByte(0, MODULE, "Border", 1) ? true : false; + opt.bDropShadow = DBGetContactSettingByte(0, MODULE, "DropShadow", 1) ? true : false; + opt.bRound = DBGetContactSettingByte(0, MODULE, "RoundCorners", 1) ? true : false; + opt.bAeroGlass = DBGetContactSettingByte(0, MODULE, "AeroGlass", 0) ? true : false; + opt.showEffect = (PopupShowEffect)DBGetContactSettingByte(0, MODULE, "ShowEffect", (BYTE)PSE_FADE); + opt.iAnimateSpeed = DBGetContactSettingByte(0, MODULE, "ShowEffectSpeed", 12); + + if (opt.iAnimateSpeed < 1) + opt.iAnimateSpeed = 1; + else if (opt.iAnimateSpeed > 20) + opt.iAnimateSpeed = 20; + + int iBgImg = DBGetContactSettingByte(0, MODULE, "SBgImage", 0); + opt.skinMode = (SkinMode)DBGetContactSettingByte(0, MODULE, "SkinEngine", iBgImg ? SM_OBSOLOTE : SM_COLORFILL); + opt.bLoadFonts = DBGetContactSettingByte(0, MODULE, "LoadFonts", 1) ? true : false; + opt.bLoadProportions= DBGetContactSettingByte(0, MODULE, "LoadProportions", 1) ? true : false; + opt.iEnableColoring = DBGetContactSettingDword(0, MODULE, "EnableColoring", 0); + opt.szSkinName[0] = 0; + + if (opt.skinMode == SM_OBSOLOTE) + { + LoadObsoleteSkinSetting(); + } + else if (opt.skinMode == SM_IMAGE) + { + if (!DBGetContactSettingTString(NULL, MODULE, "SkinName", &dbv)) + { + _tcscpy(opt.szSkinName, dbv.ptszVal); + DBFreeVariant(&dbv); + } + } + + if (opt.iDsCount == 0 && opt.iDiCount == 0) + { + // set up some reasonable defaults + CreateDefaultItems(); + SaveOptions(); + SaveItems(); + } +} + +INT_PTR CALLBACK DlgProcAddItem(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + DISPLAYITEM *di = (DISPLAYITEM *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + switch (msg) + { + case WM_INITDIALOG: + { + TranslateDialogDefault( hwndDlg ); + di = (DISPLAYITEM *)lParam; + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)di); + + SetDlgItemText(hwndDlg, IDC_ED_LABEL, di->swzLabel); + SetDlgItemText(hwndDlg, IDC_ED_VALUE, di->swzValue); + + CheckDlgButton(hwndDlg, IDC_CHK_LINEABOVE, di->bLineAbove ? TRUE : FALSE); + CheckDlgButton(hwndDlg, IDC_CHK_VALNEWLINE, di->bValueNewline ? TRUE : FALSE); + CheckDlgButton(hwndDlg, IDC_CHK_PARSETIPPERFIRST, di->bParseTipperVarsFirst ? TRUE : FALSE); + + int i; + for (i = 0; presetItems[i].szID; i++) + SendDlgItemMessage(hwndDlg, IDC_CMB_PRESETITEMS, CB_ADDSTRING, 0, (LPARAM)TranslateTS(presetItems[i].swzName)); + + variables_skin_helpbutton(hwndDlg, IDC_BTN_VARIABLE); + + SetFocus(GetDlgItem(hwndDlg, IDC_ED_LABEL)); + return TRUE; + } + case WM_COMMAND: + { + if (HIWORD(wParam) == BN_CLICKED) + { + switch(LOWORD(wParam)) + { + case IDOK: + { + int sel; + GetDlgItemText(hwndDlg, IDC_ED_LABEL, di->swzLabel, LABEL_LEN); + GetDlgItemText(hwndDlg, IDC_ED_VALUE, di->swzValue, VALUE_LEN); + + di->bLineAbove = (IsDlgButtonChecked(hwndDlg, IDC_CHK_LINEABOVE) ? true : false); + di->bValueNewline = (IsDlgButtonChecked(hwndDlg, IDC_CHK_VALNEWLINE) ? true : false); + di->bParseTipperVarsFirst = (IsDlgButtonChecked(hwndDlg, IDC_CHK_PARSETIPPERFIRST) ? true : false); + + sel = SendDlgItemMessage(hwndDlg, IDC_CMB_PRESETITEMS, CB_GETCURSEL, 0, 0); + if (sel != CB_ERR) + { + TCHAR buff[256]; int i; + SendDlgItemMessage(hwndDlg, IDC_CMB_PRESETITEMS, CB_GETLBTEXT, sel, (LPARAM)buff); + for (i = 0; presetItems[i].szID; i++) + { + if (_tcscmp(buff, TranslateTS(presetItems[i].swzName)) == 0) + break; + } + + if (presetItems[i].szNeededSubst[0]) + EndDialog(hwndDlg, IDPRESETITEM + i); + else + EndDialog(hwndDlg, IDOK); + } + else + { + EndDialog(hwndDlg, IDOK); + } + + return TRUE; + } + case IDCANCEL: + { + EndDialog(hwndDlg, IDCANCEL); + return TRUE; + } + case IDC_BTN_VARIABLE: + { + if (GetFocus() == GetDlgItem(hwndDlg, IDC_ED_LABEL)) + variables_showhelp(hwndDlg, IDC_ED_LABEL, VHF_FULLDLG, NULL, NULL); + else + variables_showhelp(hwndDlg, IDC_ED_VALUE, VHF_FULLDLG, NULL, NULL); + return TRUE; + } + } + } + else if (HIWORD(wParam) == CBN_SELCHANGE) + { + if (LOWORD(wParam) == IDC_CMB_PRESETITEMS) + { + int sel = SendDlgItemMessage(hwndDlg, IDC_CMB_PRESETITEMS, CB_GETCURSEL, 0, 0); + if (sel != CB_ERR) + { + TCHAR buff[256]; int i; + SendDlgItemMessage(hwndDlg, IDC_CMB_PRESETITEMS, CB_GETLBTEXT, sel, (LPARAM)buff); + for (i = 0; presetItems[i].szID; i++) + { + if (_tcscmp(buff, TranslateTS(presetItems[i].swzName)) == 0) + break; + } + + SetDlgItemText(hwndDlg, IDC_ED_LABEL, TranslateTS(presetItems[i].swzLabel)); + SetDlgItemText(hwndDlg, IDC_ED_VALUE, presetItems[i].swzValue); + } + } + } + break; + } + } + + return 0; +} + +INT_PTR CALLBACK DlgProcAddSubst(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + DISPLAYSUBST *ds = (DISPLAYSUBST *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + switch (msg) + { + case WM_INITDIALOG: + { + TranslateDialogDefault( hwndDlg ); + ds = (DISPLAYSUBST *)lParam; + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)ds); + + SetDlgItemText(hwndDlg, IDC_ED_LABEL, ds->swzName); + + switch(ds->type) + { + case DVT_PROTODB: + CheckDlgButton(hwndDlg, IDC_CHK_PROTOMOD, TRUE); + SetDlgItemTextA(hwndDlg, IDC_ED_SETTING, ds->szSettingName); + break; + case DVT_DB: + SetDlgItemTextA(hwndDlg, IDC_ED_MODULE, ds->szModuleName); + SetDlgItemTextA(hwndDlg, IDC_ED_SETTING, ds->szSettingName); + break; + } + + int index, id, i; + for (i = 0; i < iTransFuncsCount; i++) + { + index = SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_ADDSTRING, (WPARAM)-1, (LPARAM)TranslateTS(translations[i].swzName)); + SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_SETITEMDATA, index, (LPARAM)translations[i].id); + } + + for (i = 0; i < iTransFuncsCount; i++) + { + id = SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_GETITEMDATA, i, 0); + if (id == ds->iTranslateFuncId) + SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_SETCURSEL, i, 0); + } + + SendMessage(hwndDlg, WMU_ENABLE_MODULE_ENTRY, 0, 0); + SetFocus(GetDlgItem(hwndDlg, IDC_ED_LABEL)); + return TRUE; + } + case WMU_ENABLE_MODULE_ENTRY: + { + HWND hw = GetDlgItem(hwndDlg, IDC_CHK_PROTOMOD); + EnableWindow(hw, TRUE); + hw = GetDlgItem(hwndDlg, IDC_ED_MODULE); + EnableWindow(hw, !IsDlgButtonChecked(hwndDlg, IDC_CHK_PROTOMOD)); + hw = GetDlgItem(hwndDlg, IDC_ED_SETTING); + EnableWindow(hw, TRUE); + return TRUE; + } + case WM_COMMAND: + { + if (HIWORD(wParam) == BN_CLICKED) + { + switch(LOWORD(wParam)) + { + case IDC_CHK_PROTOMOD: + { + SendMessage(hwndDlg, WMU_ENABLE_MODULE_ENTRY, 0, 0); + break; + } + case IDOK: + { + GetDlgItemText(hwndDlg, IDC_ED_LABEL, ds->swzName, LABEL_LEN); + if (ds->swzName[0] == 0) + { + MessageBox(hwndDlg, TranslateT("You must enter a label"), TranslateT("Invalid Substitution"), MB_OK | MB_ICONWARNING); + return TRUE; + } + + if (IsDlgButtonChecked(hwndDlg, IDC_CHK_PROTOMOD)) + { + ds->type = DVT_PROTODB; + } + else + { + ds->type = DVT_DB; + GetDlgItemTextA(hwndDlg, IDC_ED_MODULE, ds->szModuleName, MODULE_NAME_LEN); + } + + GetDlgItemTextA(hwndDlg, IDC_ED_SETTING, ds->szSettingName, SETTING_NAME_LEN); + + int sel = SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_GETCURSEL, 0, 0); + ds->iTranslateFuncId = SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_GETITEMDATA, sel, 0); + + EndDialog(hwndDlg, IDOK); + return TRUE; + } + case IDCANCEL: + { + EndDialog(hwndDlg, IDCANCEL); + return TRUE; + } + } + } + else if (HIWORD(wParam) == CBN_SELCHANGE) + { + return TRUE; + } + + break; + } + } + + return 0; +} + +static void SetTreeItemText(DIListNode *node, TCHAR **pszText) +{ + if (node->di.swzLabel[0] == 0) + { + if (node->di.swzValue[0] == 0 && node->di.bLineAbove) + *pszText = _T("--------------------------------------"); + else + *pszText = TranslateT(""); + } + else + { + *pszText = node->di.swzLabel; + } +} + + +static OPTBUTTON btns[9] = +{ + IDC_BTN_ADD, SKINICON_OTHER_ADDCONTACT, 0, LPGENT("Add item"), + IDC_BTN_SEPARATOR, 0, IDI_SEPARATOR, LPGENT("Add separator"), + IDC_BTN_EDIT, SKINICON_OTHER_RENAME, 0, LPGENT("Edit"), + IDC_BTN_REMOVE, SKINICON_OTHER_DELETE, 0, LPGENT("Remove"), + IDC_BTN_UP, 0, IDI_UP, LPGENT("Move up"), + IDC_BTN_DOWN, 0, IDI_DOWN, LPGENT("Move down"), + IDC_BTN_ADD2, SKINICON_OTHER_ADDCONTACT, 0, LPGENT("Add"), + IDC_BTN_REMOVE2, SKINICON_OTHER_DELETE, 0, LPGENT("Remove"), + IDC_BTN_EDIT2, SKINICON_OTHER_RENAME, 0, LPGENT("Edit") +}; + +INT_PTR CALLBACK DlgProcOptsContent(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) + { + case WM_INITDIALOG: + { + TranslateDialogDefault(hwndDlg); + + for (int i = 0; i < SIZEOF(btns); i++) + { + SendDlgItemMessage(hwndDlg, btns[i].id, BUTTONSETASFLATBTN, TRUE, 0); + SendDlgItemMessage(hwndDlg, btns[i].id, BUTTONADDTOOLTIP, (WPARAM)TranslateTS(btns[i].swzTooltip), BATF_TCHAR); + if (btns[i].uintCoreIconId) + { + SendDlgItemMessage(hwndDlg, btns[i].id, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadSkinnedIcon(btns[i].uintCoreIconId)); + } + else + { + HICON hIcon = LoadIcon(hInst, MAKEINTRESOURCE(btns[i].uintResIconId)); + SendDlgItemMessage(hwndDlg, btns[i].id, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); + DestroyIcon(hIcon); + } + } + + HIMAGELIST himlStates = ImageList_Create(16, 16, IsWinVerXPPlus() ? ILC_COLOR32 | ILC_MASK : ILC_COLOR8 | ILC_MASK, 3, 0); + ImageList_AddIcon(himlStates, LoadSkinnedIcon(SKINICON_OTHER_NOTICK)); + ImageList_AddIcon(himlStates, LoadSkinnedIcon(SKINICON_OTHER_NOTICK)); + ImageList_AddIcon(himlStates, LoadSkinnedIcon(SKINICON_OTHER_TICK)); + TreeView_SetImageList(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), himlStates, TVSIL_STATE); + + TVINSERTSTRUCT tvi = {0}; + tvi.hInsertAfter = TVI_LAST; + tvi.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_STATE; + tvi.item.stateMask = TVIS_STATEIMAGEMASK; + + DIListNode *di_node = opt.diList, *di_value; + while (di_node) + { + di_value = (DIListNode *)mir_alloc(sizeof(DIListNode)); + *di_value = *di_node; + tvi.item.lParam = (LPARAM)di_value; + tvi.item.state = INDEXTOSTATEIMAGEMASK(di_value->di.bIsVisible ? 2 : 1); + SetTreeItemText(di_value, &tvi.item.pszText); + TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &tvi); + di_node = di_node->next; + } + + DSListNode *ds_node = opt.dsList, *ds_value; + while (ds_node) + { + ds_value = (DSListNode *)mir_alloc(sizeof(DSListNode)); + *ds_value = *ds_node; + int index = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_ADDSTRING, 0, (LPARAM)ds_value->ds.swzName); + SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_SETITEMDATA, index, (LPARAM)ds_value); + ds_node = ds_node->next; + } + + SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0); + return FALSE; + } + case WMU_ENABLE_LIST_BUTTONS: + { + HTREEITEM hItem = TreeView_GetSelection(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS)); + if (hItem) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_REMOVE), TRUE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_UP), TreeView_GetPrevSibling(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), hItem) ? TRUE : FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DOWN), TreeView_GetNextSibling(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), hItem) ? TRUE : FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_EDIT), TRUE); + } + else + { + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_REMOVE), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_UP), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DOWN), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_EDIT), FALSE); + } + + int sel = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETCURSEL, 0, 0); + if (sel == -1) + { + HWND hw = GetDlgItem(hwndDlg, IDC_BTN_REMOVE2); + EnableWindow(hw, FALSE); + hw = GetDlgItem(hwndDlg, IDC_BTN_EDIT2); + EnableWindow(hw, FALSE); + } + else + { + HWND hw = GetDlgItem(hwndDlg, IDC_BTN_REMOVE2); + EnableWindow(hw, TRUE); + hw = GetDlgItem(hwndDlg, IDC_BTN_EDIT2); + EnableWindow(hw, TRUE); + } + return TRUE; + } + case WM_COMMAND: + { + if (HIWORD(wParam) == LBN_SELCHANGE && LOWORD(wParam) == IDC_LST_SUBST) + { + SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0); + } + else if (HIWORD(wParam) == CBN_SELCHANGE) + { + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + else if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) + { + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + else if (HIWORD(wParam) == LBN_DBLCLK && LOWORD(wParam) == IDC_LST_SUBST) + { + int sel = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETCURSEL, 0, 0); + if (sel != CB_ERR) + { + DSListNode *ds_value = (DSListNode *)SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETITEMDATA, sel, 0); + if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SUBST), hwndDlg, DlgProcAddSubst, (LPARAM)&ds_value->ds) == IDOK) + { + SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_DELETESTRING, (WPARAM)sel, 0); + + sel = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_ADDSTRING, 0, (LPARAM)ds_value->ds.swzName); + SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_SETITEMDATA, sel, (LPARAM)ds_value); + + SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_SETCURSEL, sel, 0); + SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + } + } + else if (HIWORD(wParam) == BN_CLICKED) + { + switch(LOWORD(wParam)) + { + case IDC_BTN_ADD: + { + DIListNode *di_value = (DIListNode *)mir_alloc(sizeof(DIListNode)); + memset(di_value, 0, sizeof(DIListNode)); + di_value->di.bIsVisible = true; + + int result = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ITEM), hwndDlg, DlgProcAddItem, (LPARAM)&di_value->di); + if (result == IDOK || (result >= IDPRESETITEM && result < (IDPRESETITEM + 100))) + { + TVINSERTSTRUCT tvi = {0}; + tvi.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_STATE; + tvi.item.stateMask = TVIS_STATEIMAGEMASK; + tvi.item.lParam = (LPARAM)di_value; + tvi.item.state = INDEXTOSTATEIMAGEMASK(2); + SetTreeItemText(di_value, &tvi.item.pszText); + + HTREEITEM hItem = TreeView_GetSelection(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS)); + if (hItem) tvi.hInsertAfter = hItem; + else tvi.hInsertAfter = TVI_LAST; + TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &tvi); + + if (hItem) + { + HTREEITEM hNewItem = TreeView_GetNextSibling(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), hItem); + if (hNewItem) TreeView_SelectItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), hNewItem); + } + + if (result >= IDPRESETITEM) + { + for (int i = 0; i < MAX_PRESET_SUBST_COUNT; i++) + { + + PRESETSUBST *subst = GetPresetSubstByName(presetItems[result - IDPRESETITEM].szNeededSubst[i]); + if (subst == NULL) break; + if (SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_FINDSTRING, -1, (LPARAM)subst->swzName) == LB_ERR) + { + DSListNode *ds_value = (DSListNode *)mir_alloc(sizeof(DSListNode)); + memset(ds_value, 0, sizeof(DSListNode)); + ds_value->next = NULL; + ds_value->ds.type = subst->type; + _tcscpy(ds_value->ds.swzName, subst->swzName); + + if (ds_value->ds.type == DVT_DB && subst->szModuleName) + strcpy(ds_value->ds.szModuleName, subst->szModuleName); + + if (subst->szSettingName) + strcpy(ds_value->ds.szSettingName, subst->szSettingName); + + ds_value->ds.iTranslateFuncId = subst->iTranslateFuncId; + + int index = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_ADDSTRING, 0, (LPARAM)ds_value->ds.swzName); + SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_SETITEMDATA, index, (LPARAM)ds_value); + SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_SETCURSEL, index, 0); + } + } + } + + SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + + return TRUE; + } + case IDC_BTN_SEPARATOR: + { + DIListNode *di_value = (DIListNode *)mir_alloc(sizeof(DIListNode)); + memset(di_value, 0, sizeof(DIListNode)); + di_value->di.bIsVisible = true; + di_value->di.bLineAbove = true; + + TVINSERTSTRUCT tvi = {0}; + tvi.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_STATE; + tvi.item.stateMask = TVIS_STATEIMAGEMASK; + tvi.item.lParam = (LPARAM)di_value; + tvi.item.state = INDEXTOSTATEIMAGEMASK(2); + tvi.item.pszText = _T("---------------------------------"); + + HTREEITEM hItem = TreeView_GetSelection(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS)); + if (hItem) tvi.hInsertAfter = hItem; + else tvi.hInsertAfter = TVI_LAST; + TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &tvi); + + SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + return TRUE; + } + case IDC_BTN_REMOVE: + { + TVITEM item = {0}; + item.mask = TVIF_PARAM; + item.hItem = TreeView_GetSelection(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS)); + if (item.hItem) + { + if (TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &item)) + { + DIListNode *di_value = (DIListNode *)item.lParam; + mir_free(di_value); + TreeView_DeleteItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), item.hItem); + SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + } + return TRUE; + } + case IDC_BTN_UP: + case IDC_BTN_DOWN: + { + HTREEITEM hItem = TreeView_GetSelection(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS)); + if (hItem) + { + HTREEITEM hNewItem; + if (LOWORD(wParam) == IDC_BTN_UP) + hNewItem = TreeView_GetPrevSibling(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), hItem); + else + hNewItem = TreeView_GetNextSibling(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), hItem); + + if (hNewItem) + { + TCHAR buff[512], buff2[512]; + LPARAM tmpParam; + UINT tmpState; + + TVITEM item = {0}; + item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_STATE; + item.stateMask = TVIS_STATEIMAGEMASK; + item.hItem = hItem; + item.pszText = buff; + item.cchTextMax = 512; + if (TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &item)) + { + tmpParam = item.lParam; + tmpState = item.state; + item.hItem = hNewItem; + item.pszText = buff2; + if (TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &item)) + { + item.hItem = hItem; + TreeView_SetItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &item); + + item.hItem = hNewItem; + item.pszText = buff; + item.lParam = tmpParam; + item.state = tmpState; + TreeView_SetItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &item); + TreeView_SelectItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), hNewItem); + } + } + } + } + + SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + return TRUE; + } + case IDC_BTN_EDIT: + { + TVITEM item = {0}; + item.mask = TVIF_PARAM; + item.hItem = TreeView_GetSelection(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS)); + if (item.hItem ) + { + if (TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &item)) + { + DIListNode *di_value = (DIListNode *)item.lParam; + if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ITEM), hwndDlg, DlgProcAddItem, (LPARAM)&di_value->di) == IDOK) + { + item.mask = TVIF_TEXT; + SetTreeItemText(di_value, &item.pszText); + TreeView_SetItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &item); + SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + } + } + + return TRUE; + } + case IDC_BTN_ADD2: + { + DSListNode *ds_value = (DSListNode *)mir_alloc(sizeof(DSListNode)); + memset(ds_value, 0, sizeof(DSListNode)); + if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SUBST), hwndDlg, DlgProcAddSubst, (LPARAM)&ds_value->ds) == IDOK) + { + int index = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_ADDSTRING, 0, (LPARAM)ds_value->ds.swzName); + SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_SETITEMDATA, index, (LPARAM)ds_value); + SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_SETCURSEL, index, 0); + SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + + return TRUE; + } + case IDC_BTN_REMOVE2: + { + int sel = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETCURSEL, 0, 0); + if (sel != LB_ERR) + { + DSListNode *ds_value = (DSListNode *)SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETITEMDATA, sel, 0); + mir_free(ds_value); + + SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_DELETESTRING, (WPARAM)sel, 0); + SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + + return TRUE; + } + case IDC_BTN_EDIT2: + { + int sel = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETCURSEL, 0, 0); + if (sel != LB_ERR) + { + DSListNode *ds_value = (DSListNode *)SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETITEMDATA, sel, 0); + if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SUBST), hwndDlg, DlgProcAddSubst, (LPARAM)&ds_value->ds) == IDOK) + { + SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_DELETESTRING, (WPARAM)sel, 0); + + sel = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_ADDSTRING, 0, (LPARAM)ds_value->ds.swzName); + SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_SETITEMDATA, sel, (LPARAM)ds_value); + + SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_SETCURSEL, sel, 0); + SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + } + + return TRUE; + } + default: + { + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + return TRUE; + } + } + } + break; + } + case WM_NOTIFY: + { + switch (((LPNMHDR)lParam)->code) + { + case PSN_APPLY: + { + DIListNode *di_node; + while (opt.diList) + { + di_node = opt.diList; + opt.diList = opt.diList->next; + mir_free(di_node); + } + + DIListNode *di_value; + opt.iDiCount = TreeView_GetCount(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS)); + + TVITEM item = {0}; + item.mask = TVIF_PARAM; + item.hItem = TreeView_GetLastVisible(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS)); + while (item.hItem != NULL) + { + if (TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &item)) + { + di_node = (DIListNode *)item.lParam; + di_value = (DIListNode *)mir_alloc(sizeof(DIListNode)); + *di_value = *di_node; + di_value->next = opt.diList; + opt.diList = di_value; + } + item.hItem = TreeView_GetPrevSibling(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), item.hItem); + } + + DSListNode *ds_node; + while (opt.dsList) + { + ds_node = opt.dsList; + opt.dsList = opt.dsList->next; + mir_free(ds_node); + } + + DSListNode *ds_value; + opt.iDsCount = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETCOUNT, 0, 0); + for (int i = opt.iDsCount - 1; i >= 0; i--) + { + ds_node = (DSListNode *)SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETITEMDATA, i, 0); + ds_value = (DSListNode *)mir_alloc(sizeof(DSListNode)); + *ds_value = *ds_node; + ds_value->next = opt.dsList; + opt.dsList = ds_value; + } + + SaveItems(); + return TRUE; + } + case NM_DBLCLK: + { + TVITEM item = {0}; + item.mask = TVIF_PARAM; + item.hItem = TreeView_GetSelection(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS)); + if (item.hItem) + { + if (TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &item)) + { + DIListNode *di_value = (DIListNode *)item.lParam; + if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ITEM), hwndDlg, DlgProcAddItem, (LPARAM)&di_value->di) == IDOK) + { + item.mask = TVIF_TEXT; + SetTreeItemText(di_value, &item.pszText); + TreeView_SetItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &item); + SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + } + } + break; + } + case NM_CLICK: + { + TVHITTESTINFO hti; + hti.pt.x = (short)LOWORD(GetMessagePos()); + hti.pt.y = (short)HIWORD(GetMessagePos()); + ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt); + if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti)) + { + if (hti.flags & TVHT_ONITEMSTATEICON) + { + TVITEMA item = {0}; + item.hItem = hti.hItem; + item.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_STATE; + item.stateMask = TVIS_STATEIMAGEMASK; + TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item); + + if (((item.state & TVIS_STATEIMAGEMASK) >> 12) == 1) + { + item.state = INDEXTOSTATEIMAGEMASK(2); + ((DIListNode *)item.lParam)->di.bIsVisible = true; + } + else + { + item.state = INDEXTOSTATEIMAGEMASK(1); + ((DIListNode *)item.lParam)->di.bIsVisible = false; + } + + TreeView_SetItem(((LPNMHDR)lParam)->hwndFrom, &item); + SendMessage((GetParent(hwndDlg)), PSM_CHANGED, (WPARAM)hwndDlg, 0); + } + } + break; + } + case TVN_SELCHANGEDA: + case TVN_SELCHANGEDW: + { + SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0); + break; + } + } + break; + } + case WM_DESTROY: + { + DIListNode *di_value; + TVITEM tvi = {0}; + tvi.mask = TVIF_PARAM; + HTREEITEM hItem = TreeView_GetRoot(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS)); + + while (hItem != NULL) + { + tvi.hItem = hItem; + if (TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &tvi)) + { + di_value = (DIListNode *)tvi.lParam; + mir_free(di_value); + } + hItem = TreeView_GetNextSibling(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), hItem); + } + + DSListNode *ds_value; + int count = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETCOUNT, 0, 0); + for (int i = 0; i < count; i++) + { + ds_value = (DSListNode *)SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETITEMDATA, i, 0); + mir_free(ds_value); + } + + ImageList_Destroy(TreeView_GetImageList(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), TVSIL_STATE)); + break; + } + } + + return 0; +} + +INT_PTR CALLBACK DlgProcOptsAppearance(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) + { + case WM_INITDIALOG: + { + TranslateDialogDefault( hwndDlg ); + + CheckDlgButton(hwndDlg, IDC_CHK_NOFOCUS, opt.bShowNoFocus ? TRUE : FALSE); + CheckDlgButton(hwndDlg, IDC_CHK_SBAR, opt.bStatusBarTips ? TRUE : FALSE); + + SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("Icon on left")); + SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("Icon on right")); + SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("No icon")); + SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("No title")); + SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_SETCURSEL, (int)opt.titleLayout, 0); + + SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom right")); + SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom left")); + SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top right")); + SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top left")); + SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_SETCURSEL, (int)opt.pos, 0); + + SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top")); + SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Centre")); + SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom")); + switch (opt.iLabelValign) + { + case DT_TOP: SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_SETCURSEL, 0, 0); break; + case DT_VCENTER: SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_SETCURSEL, 1, 0); break; + case DT_BOTTOM: SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_SETCURSEL, 2, 0); break; + } + + SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top")); + SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Centre")); + SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom")); + switch (opt.iValueValign) + { + case DT_TOP: SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_SETCURSEL, 0, 0); break; + case DT_VCENTER: SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_SETCURSEL, 1, 0); break; + case DT_BOTTOM: SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_SETCURSEL, 2, 0); break; + } + + SendDlgItemMessage(hwndDlg, IDC_CMB_LH, CB_ADDSTRING, 0, (LPARAM)TranslateT("Left")); + SendDlgItemMessage(hwndDlg, IDC_CMB_LH, CB_ADDSTRING, 0, (LPARAM)TranslateT("Right")); + switch (opt.iLabelHalign) + { + case DT_LEFT: SendDlgItemMessage(hwndDlg, IDC_CMB_LH, CB_SETCURSEL, 0, 0); break; + case DT_RIGHT: SendDlgItemMessage(hwndDlg, IDC_CMB_LH, CB_SETCURSEL, 1, 0); break; + } + + SendDlgItemMessage(hwndDlg, IDC_CMB_VH, CB_ADDSTRING, 0, (LPARAM)TranslateT("Left")); + SendDlgItemMessage(hwndDlg, IDC_CMB_VH, CB_ADDSTRING, 0, (LPARAM)TranslateT("Right")); + switch (opt.iValueHalign) + { + case DT_LEFT: SendDlgItemMessage(hwndDlg, IDC_CMB_VH, CB_SETCURSEL, 0, 0); break; + case DT_RIGHT: SendDlgItemMessage(hwndDlg, IDC_CMB_VH, CB_SETCURSEL, 1, 0); break; + } + + SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("No avatar")); + if (ServiceExists(MS_AV_DRAWAVATAR)) + { + SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Left avatar")); + SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Right avatar")); + } + else + { + HWND hw = GetDlgItem(hwndDlg, IDC_CMB_AV); + EnableWindow(hw, FALSE); + hw = GetDlgItem(hwndDlg, IDC_SPIN_AVSIZE); + EnableWindow(hw, FALSE); + hw = GetDlgItem(hwndDlg, IDC_ED_AVSIZE); + EnableWindow(hw, FALSE); + } + SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_SETCURSEL, (int)opt.avatarLayout, 0); + + SendDlgItemMessage(hwndDlg, IDC_SPIN_WIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16)); + SendDlgItemMessage(hwndDlg, IDC_SPIN_MINWIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16)); + SendDlgItemMessage(hwndDlg, IDC_SPIN_MAXHEIGHT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16)); + SendDlgItemMessage(hwndDlg, IDC_SPIN_MINHEIGHT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16)); + SendDlgItemMessage(hwndDlg, IDC_SPIN_AVSIZE, UDM_SETRANGE, 0, (LPARAM)MAKELONG(100, 16)); + SendDlgItemMessage(hwndDlg, IDC_SPIN_INDENT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(400, 0)); + SendDlgItemMessage(hwndDlg, IDC_SPIN_TITLEINDENT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(400, 0)); + SendDlgItemMessage(hwndDlg, IDC_SPIN_VALUEINDENT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(400, 0)); + SendDlgItemMessage(hwndDlg, IDC_SPIN_PADDING, UDM_SETRANGE, 0, (LPARAM)MAKELONG(128, 0)); + SendDlgItemMessage(hwndDlg, IDC_SPIN_TEXTPADDING, UDM_SETRANGE, 0, (LPARAM)MAKELONG(128, 0)); + SendDlgItemMessage(hwndDlg, IDC_SPIN_OUTAVPADDING, UDM_SETRANGE, 0, (LPARAM)MAKELONG(128, 0)); + SendDlgItemMessage(hwndDlg, IDC_SPIN_INAVPADDING, UDM_SETRANGE, 0, (LPARAM)MAKELONG(128, 0)); + SendDlgItemMessage(hwndDlg, IDC_SPIN_HOVER, UDM_SETRANGE, 0, (LPARAM)MAKELONG(5000, 5)); + SendDlgItemMessage(hwndDlg, IDC_SPIN_SBWIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 0)); + + SetDlgItemInt(hwndDlg, IDC_ED_WIDTH, opt.iWinWidth, FALSE); + SetDlgItemInt(hwndDlg, IDC_ED_MAXHEIGHT, opt.iWinMaxHeight, FALSE); + SetDlgItemInt(hwndDlg, IDC_ED_MINWIDTH, opt.iMinWidth, FALSE); + SetDlgItemInt(hwndDlg, IDC_ED_MINHEIGHT, opt.iMinHeight, FALSE); + SetDlgItemInt(hwndDlg, IDC_ED_AVSIZE, opt.iAvatarSize, FALSE); + SetDlgItemInt(hwndDlg, IDC_ED_INDENT, opt.iTextIndent, FALSE); + SetDlgItemInt(hwndDlg, IDC_ED_TITLEINDENT, opt.iTitleIndent, FALSE); + SetDlgItemInt(hwndDlg, IDC_ED_VALUEINDENT, opt.iValueIndent, FALSE); + SetDlgItemInt(hwndDlg, IDC_ED_PADDING, opt.iPadding, FALSE); + SetDlgItemInt(hwndDlg, IDC_ED_TEXTPADDING, opt.iTextPadding, FALSE); + SetDlgItemInt(hwndDlg, IDC_ED_OUTAVPADDING, opt.iOuterAvatarPadding, FALSE); + SetDlgItemInt(hwndDlg, IDC_ED_INAVPADDING, opt.iInnerAvatarPadding, FALSE); + SetDlgItemInt(hwndDlg, IDC_ED_HOVER, opt.iTimeIn, FALSE); + SetDlgItemInt(hwndDlg, IDC_ED_SBWIDTH, opt.iSidebarWidth, FALSE); + + CheckDlgButton(hwndDlg, IDC_CHK_ROUNDCORNERSAV, opt.bAvatarRound); + CheckDlgButton(hwndDlg, IDC_CHK_AVBORDER, opt.bAvatarBorder); + CheckDlgButton(hwndDlg, IDC_CHK_ORIGINALAVSIZE, opt.bOriginalAvatarSize); + + if (opt.bOriginalAvatarSize) + SetDlgItemText(hwndDlg, IDC_STATIC_AVATARSIZE, TranslateT("Max avatar size:")); + + return FALSE; + } + case WM_COMMAND: + { + if (LOWORD(wParam) == IDC_CHK_ORIGINALAVSIZE) + { + if (IsDlgButtonChecked(hwndDlg, IDC_CHK_ORIGINALAVSIZE)) + SetDlgItemText(hwndDlg, IDC_STATIC_AVATARSIZE, TranslateT("Max avatar size:")); + else + SetDlgItemText(hwndDlg, IDC_STATIC_AVATARSIZE, TranslateT("Avatar size:")); + } + + if (HIWORD(wParam) == CBN_SELCHANGE) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + else if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + else if (HIWORD(wParam) == BN_CLICKED) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + + break; + } + case WM_NOTIFY: + { + if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY) + { + BOOL trans; + int new_val; + new_val = GetDlgItemInt(hwndDlg, IDC_ED_WIDTH, &trans, FALSE); + if (trans) opt.iWinWidth = new_val; + new_val = GetDlgItemInt(hwndDlg, IDC_ED_MINWIDTH, &trans, FALSE); + if (trans) opt.iMinWidth = new_val; + new_val = GetDlgItemInt(hwndDlg, IDC_ED_MAXHEIGHT, &trans, FALSE); + if (trans) opt.iWinMaxHeight = new_val; + new_val = GetDlgItemInt(hwndDlg, IDC_ED_MINHEIGHT, &trans, FALSE); + if (trans) opt.iMinHeight = new_val; + new_val = GetDlgItemInt(hwndDlg, IDC_ED_AVSIZE, &trans, FALSE); + if (trans) opt.iAvatarSize = new_val; + new_val = GetDlgItemInt(hwndDlg, IDC_ED_INDENT, &trans, FALSE); + if (trans) opt.iTextIndent = new_val; + new_val = GetDlgItemInt(hwndDlg, IDC_ED_TITLEINDENT, &trans, FALSE); + if (trans) opt.iTitleIndent = new_val; + new_val = GetDlgItemInt(hwndDlg, IDC_ED_VALUEINDENT, &trans, FALSE); + if (trans) opt.iValueIndent = new_val; + new_val = GetDlgItemInt(hwndDlg, IDC_ED_PADDING, &trans, FALSE); + if (trans) opt.iPadding = new_val; + new_val = GetDlgItemInt(hwndDlg, IDC_ED_TEXTPADDING, &trans, FALSE); + if (trans) opt.iTextPadding = new_val; + new_val = GetDlgItemInt(hwndDlg, IDC_ED_OUTAVPADDING, &trans, FALSE); + if (trans) opt.iOuterAvatarPadding = new_val; + new_val = GetDlgItemInt(hwndDlg, IDC_ED_INAVPADDING, &trans, FALSE); + if (trans) opt.iInnerAvatarPadding = new_val; + new_val = GetDlgItemInt(hwndDlg, IDC_ED_HOVER, &trans, FALSE); + if (trans) opt.iTimeIn = new_val; + new_val = GetDlgItemInt(hwndDlg, IDC_ED_SBWIDTH, &trans, FALSE); + if (trans) opt.iSidebarWidth = new_val; + + opt.titleLayout = (PopupTitleLayout)SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_GETCURSEL, 0, 0); + opt.avatarLayout = (PopupAvLayout)SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_GETCURSEL, 0, 0); + opt.pos = (PopupPosition)SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_GETCURSEL, 0, 0); + + opt.bAvatarBorder = IsDlgButtonChecked(hwndDlg, IDC_CHK_AVBORDER) ? true : false; + opt.bAvatarRound = IsDlgButtonChecked(hwndDlg, IDC_CHK_ROUNDCORNERSAV) && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHK_ROUNDCORNERSAV)) ? true : false; + opt.bOriginalAvatarSize = IsDlgButtonChecked(hwndDlg, IDC_CHK_ORIGINALAVSIZE) ? true : false; + + opt.bShowNoFocus = IsDlgButtonChecked(hwndDlg, IDC_CHK_NOFOCUS) ? true : false; + opt.bStatusBarTips = IsDlgButtonChecked(hwndDlg, IDC_CHK_SBAR) ? true : false; + + switch(SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_GETCURSEL, 0, 0)) + { + case 0: opt.iLabelValign = DT_TOP; break; + case 1: opt.iLabelValign = DT_VCENTER; break; + case 2: opt.iLabelValign = DT_BOTTOM; break; + } + + switch(SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_GETCURSEL, 0, 0)) + { + case 0: opt.iValueValign = DT_TOP; break; + case 1: opt.iValueValign = DT_VCENTER; break; + case 2: opt.iValueValign = DT_BOTTOM; break; + } + + switch(SendDlgItemMessage(hwndDlg, IDC_CMB_LH, CB_GETCURSEL, 0, 0)) + { + case 0: opt.iLabelHalign = DT_LEFT; break; + case 1: opt.iLabelHalign = DT_RIGHT; break; + } + + switch(SendDlgItemMessage(hwndDlg, IDC_CMB_VH, CB_GETCURSEL, 0, 0)) + { + case 0: opt.iValueHalign = DT_LEFT; break; + case 1: opt.iValueHalign = DT_RIGHT; break; + } + + SaveOptions(); + return TRUE; + } + break; + } + } + + return 0; +} + +INT_PTR CALLBACK DlgProcOptsExtra(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + EXTRAICONDATA *dat; + dat = (EXTRAICONDATA *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + switch (msg) + { + case WM_INITDIALOG: + { + TranslateDialogDefault(hwndDlg); + + CheckDlgButton(hwndDlg, IDC_CHK_WAITFORCONTENT, opt.bWaitForContent); + CheckDlgButton(hwndDlg, IDC_CHK_GETSTATUSMSG, opt.bGetNewStatusMsg); + CheckDlgButton(hwndDlg, IDC_CHK_DISABLEINVISIBLE, opt.bDisableIfInvisible); + CheckDlgButton(hwndDlg, IDC_CHK_RETRIEVEXSTATUS, opt.bRetrieveXstatus); + CheckDlgButton(hwndDlg, IDC_CHK_LIMITMSG, opt.bLimitMsg); + CheckDlgButton(hwndDlg, IDC_CHK_ENABLESMILEYS, opt.iSmileyAddFlags & SMILEYADD_ENABLE); + CheckDlgButton(hwndDlg, IDC_CHK_USEPROTOSMILEYS, opt.iSmileyAddFlags & SMILEYADD_USEPROTO); + CheckDlgButton(hwndDlg, IDC_CHK_ONLYISOLATED, opt.iSmileyAddFlags & SMILEYADD_ONLYISOLATED); + CheckDlgButton(hwndDlg, IDC_CHK_RESIZESMILEYS, opt.iSmileyAddFlags & SMILEYADD_RESIZE); + + EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DISABLEINVISIBLE), opt.bGetNewStatusMsg); + + BOOL bEnable = opt.iSmileyAddFlags & SMILEYADD_ENABLE; + EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_USEPROTOSMILEYS), bEnable); + EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_ONLYISOLATED), bEnable); + EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_RESIZESMILEYS), bEnable); + + SendDlgItemMessage(hwndDlg, IDC_SPIN_CHARCOUNT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(1024, 16)); + SetDlgItemInt(hwndDlg, IDC_ED_CHARCOUNT, opt.iLimitCharCount, FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_ED_CHARCOUNT), opt.bLimitMsg); + + HIMAGELIST himlStates = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 2, 2); + ImageList_AddIcon(himlStates, LoadSkinnedIcon(SKINICON_OTHER_NOTICK)); + ImageList_AddIcon(himlStates, LoadSkinnedIcon(SKINICON_OTHER_NOTICK)); + ImageList_AddIcon(himlStates, LoadSkinnedIcon(SKINICON_OTHER_TICK)); + TreeView_SetImageList(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), himlStates, TVSIL_STATE); + + int i; + for (i = 0; i < EXICONS_COUNT; i++) + { + exIcons[i].order = opt.exIconsOrder[i]; + exIcons[i].vis = opt.exIconsVis[i]; + } + + dat = (EXTRAICONDATA *)mir_alloc(sizeof(EXTRAICONDATA)); + dat->bDragging = false; + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); + SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), GWL_STYLE) | TVS_NOHSCROLL); + + TVINSERTSTRUCT tvi = {0}; + tvi.hParent = 0; + tvi.hInsertAfter = TVI_LAST; + tvi.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_STATE; + tvi.item.stateMask = TVIS_STATEIMAGEMASK; + for (i = 0; i < SIZEOF(extraIconName); i++ ) + { + tvi.item.lParam = (LPARAM)(&exIcons[i]); + tvi.item.pszText = TranslateTS(extraIconName[exIcons[i].order]); + tvi.item.state = INDEXTOSTATEIMAGEMASK(exIcons[i].vis ? 2 : 1); + TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &tvi); + } + + return TRUE; + } + case WM_COMMAND: + { + switch(LOWORD(wParam)) + { + case IDC_CHK_ENABLESMILEYS: + { + BOOL bEnable; + bEnable = IsDlgButtonChecked(hwndDlg, IDC_CHK_ENABLESMILEYS); + EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_RESIZESMILEYS), bEnable); + EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_USEPROTOSMILEYS), bEnable); + EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_ONLYISOLATED), bEnable); + EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_RESIZESMILEYS), bEnable); + break; + } + case IDC_CHK_LIMITMSG: + { + EnableWindow(GetDlgItem(hwndDlg, IDC_ED_CHARCOUNT), IsDlgButtonChecked(hwndDlg, IDC_CHK_LIMITMSG)); + break; + } + case IDC_CHK_GETSTATUSMSG: + { + EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DISABLEINVISIBLE), IsDlgButtonChecked(hwndDlg, IDC_CHK_GETSTATUSMSG)); + break; + } + } + + if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus()) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + + break; + } + case WM_NOTIFY: + { + switch (((LPNMHDR)lParam)->idFrom) + { + case 0: + { + if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY) + { + TVITEM item = {0}; + int i = 0; + DBCONTACTWRITESETTING cws; + cws.szModule = MODULE; + cws.szSetting = "IconOrder"; + cws.value.type = DBVT_BLOB; + cws.value.cpbVal = SIZEOF(extraIconName); + cws.value.pbVal = opt.exIconsOrder; + + item.hItem = TreeView_GetRoot(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS)); + while (item.hItem != NULL) + { + item.mask = TVIF_HANDLE | TVIF_PARAM; + TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &item); + opt.exIconsOrder[i++] = ((ICONSTATE *)item.lParam)->order; + item.hItem = TreeView_GetNextSibling(GetDlgItem(hwndDlg,IDC_TREE_EXTRAICONS), item.hItem); + } + CallService(MS_DB_CONTACT_WRITESETTING, 0,(LPARAM)&cws); + + i = 0; + cws.szModule = MODULE; + cws.szSetting = "icons_vis"; + cws.value.type = DBVT_BLOB; + cws.value.cpbVal = SIZEOF(extraIconName); + cws.value.pbVal = opt.exIconsVis; + item.hItem = TreeView_GetRoot(GetDlgItem(hwndDlg,IDC_TREE_EXTRAICONS)); + + while (item.hItem != NULL) + { + item.mask = TVIF_HANDLE | TVIF_PARAM; + TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &item); + opt.exIconsVis[i++] = ((ICONSTATE *)item.lParam)->vis; + item.hItem = TreeView_GetNextSibling(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), item.hItem); + } + CallService(MS_DB_CONTACT_WRITESETTING, 0, (LPARAM)&cws); + + opt.iSmileyAddFlags = 0; + opt.iSmileyAddFlags |= (IsDlgButtonChecked(hwndDlg, IDC_CHK_ENABLESMILEYS) ? SMILEYADD_ENABLE : 0) | + (IsDlgButtonChecked(hwndDlg, IDC_CHK_USEPROTOSMILEYS) ? SMILEYADD_USEPROTO : 0) | + (IsDlgButtonChecked(hwndDlg, IDC_CHK_ONLYISOLATED) ? SMILEYADD_ONLYISOLATED : 0) | + (IsDlgButtonChecked(hwndDlg, IDC_CHK_RESIZESMILEYS) ? SMILEYADD_RESIZE : 0); + + opt.bWaitForContent = IsDlgButtonChecked(hwndDlg, IDC_CHK_WAITFORCONTENT) ? true : false; + opt.bGetNewStatusMsg = IsDlgButtonChecked(hwndDlg, IDC_CHK_GETSTATUSMSG) ? true : false; + opt.bDisableIfInvisible = IsDlgButtonChecked(hwndDlg, IDC_CHK_DISABLEINVISIBLE) ? true : false; + opt.bRetrieveXstatus = IsDlgButtonChecked(hwndDlg, IDC_CHK_RETRIEVEXSTATUS) ? true : false; + opt.bLimitMsg = IsDlgButtonChecked(hwndDlg, IDC_CHK_LIMITMSG) ? true : false; + opt.iLimitCharCount = GetDlgItemInt(hwndDlg, IDC_ED_CHARCOUNT, 0, FALSE); + + DBWriteContactSettingDword(0, MODULE, "SmileyAddFlags", opt.iSmileyAddFlags); + DBWriteContactSettingByte(0, MODULE, "WaitForContent", opt.bWaitForContent ? 1 : 0); + DBWriteContactSettingByte(0, MODULE, "GetNewStatusMsg", opt.bGetNewStatusMsg ? 1 : 0); + DBWriteContactSettingByte(0, MODULE, "DisableInvisible", opt.bDisableIfInvisible ? 1 : 0); + DBWriteContactSettingByte(0, MODULE, "RetrieveXStatus", opt.bRetrieveXstatus ? 1 : 0); + DBWriteContactSettingByte(0, MODULE, "LimitMsg", opt.bLimitMsg ? 1 : 0); + DBWriteContactSettingByte(0, MODULE, "LimitCharCount", opt.iLimitCharCount); + + return TRUE; + } + break; + } + case IDC_TREE_EXTRAICONS: + { + switch (((LPNMHDR)lParam)->code) + { + case TVN_BEGINDRAGA: + case TVN_BEGINDRAGW: + { + SetCapture(hwndDlg); + dat->bDragging = true; + dat->hDragItem = ((LPNMTREEVIEW)lParam)->itemNew.hItem; + TreeView_SelectItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), dat->hDragItem); + break; + } + case NM_CLICK: + { + TVHITTESTINFO hti; + hti.pt.x = (short)LOWORD(GetMessagePos()); + hti.pt.y = (short)HIWORD(GetMessagePos()); + ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt); + if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti)) + { + if (hti.flags & TVHT_ONITEMSTATEICON) + { + TVITEMA item; + item.mask = TVIF_HANDLE | TVIF_STATE; + item.stateMask = TVIS_STATEIMAGEMASK; + item.hItem = hti.hItem; + TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item); + if (((item.state & TVIS_STATEIMAGEMASK) >> 12) == 1) + { + item.state = INDEXTOSTATEIMAGEMASK(2); + ((ICONSTATE *)item.lParam)->vis = 1; + } + else + { + item.state = INDEXTOSTATEIMAGEMASK(1); + ((ICONSTATE *)item.lParam)->vis = 0; + } + + TreeView_SetItem(((LPNMHDR)lParam)->hwndFrom, &item); + SendMessage((GetParent(hwndDlg)), PSM_CHANGED, (WPARAM)hwndDlg, 0); + } + } + break; + } + } + break; + } + } + break; + } + case WM_MOUSEMOVE: + { + if (!dat->bDragging) + break; + + TVHITTESTINFO hti; + hti.pt.x = (short)LOWORD(lParam); + hti.pt.y = (short)HIWORD(lParam); + ClientToScreen(hwndDlg, &hti.pt); + ScreenToClient(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &hti.pt); + TreeView_HitTest(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &hti); + if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) + { + HTREEITEM hItem = hti.hItem; + hti.pt.y -= TreeView_GetItemHeight(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS)) / 2; + TreeView_HitTest(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &hti); + if (!(hti.flags & TVHT_ABOVE)) + TreeView_SetInsertMark(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), hti.hItem, 1); + else + TreeView_SetInsertMark(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), hItem, 0); + } + else + { + if (hti.flags & TVHT_ABOVE) + SendDlgItemMessage(hwndDlg, IDC_TREE_EXTRAICONS, WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0); + if (hti.flags & TVHT_BELOW) + SendDlgItemMessage(hwndDlg, IDC_TREE_EXTRAICONS, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0); + + TreeView_SetInsertMark(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), 0, 0); + } + break; + } + case WM_LBUTTONUP: + { + if (!dat->bDragging) + break; + + TreeView_SetInsertMark(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), 0, 0); + dat->bDragging = false; + ReleaseCapture(); + + TVHITTESTINFO hti; + hti.pt.x = (short)LOWORD(lParam); + hti.pt.y = (short)HIWORD(lParam); + ClientToScreen(hwndDlg, &hti.pt); + ScreenToClient(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &hti.pt); + hti.pt.y -= TreeView_GetItemHeight(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS)) / 2; + TreeView_HitTest(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &hti); + if (dat->hDragItem == hti.hItem) + break; + + if (hti.flags & TVHT_ABOVE) + hti.hItem = TVI_FIRST; + + TVITEM item; + item.mask = TVIF_HANDLE | TVIF_PARAM; + item.hItem = dat->hDragItem; + TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &item); + if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT) || (hti.hItem == TVI_FIRST)) + { + TVINSERTSTRUCT tvis; + TCHAR swzName[256]; + tvis.item.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT | TVIF_STATE; + tvis.item.stateMask = TVIS_STATEIMAGEMASK; + tvis.item.pszText = swzName; + tvis.item.cchTextMax = 256; + tvis.item.hItem = dat->hDragItem; + tvis.item.state = INDEXTOSTATEIMAGEMASK(((ICONSTATE *)item.lParam)->vis ? 2 : 1); + TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &tvis.item); + TreeView_DeleteItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), dat->hDragItem); + tvis.hParent = NULL; + tvis.hInsertAfter = hti.hItem; + TreeView_SelectItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &tvis)); + SendMessage((GetParent(hwndDlg)), PSM_CHANGED, (WPARAM)hwndDlg, 0); + } + + break; + } + case WM_DESTROY: + { + ImageList_Destroy(TreeView_GetImageList(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), TVSIL_STATE)); + mir_free(dat); + break; + } + } + return 0; +} + +void EnableControls(HWND hwndDlg, BOOL bEnableSkin) +{ + ShowWindow(GetDlgItem(hwndDlg, IDC_ST_PREVIEW), (bEnableSkin && opt.szPreviewFile[0]) ? SW_HIDE : SW_SHOW); + ShowWindow(GetDlgItem(hwndDlg, IDC_PIC_PREVIEW), (bEnableSkin && opt.szPreviewFile[0]) ? SW_SHOW : SW_HIDE); + EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_SHADOW), !bEnableSkin); + EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_BORDER), !bEnableSkin); + EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_ROUNDCORNERS), !bEnableSkin); + EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_LOADFONTS), bEnableSkin); + EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_LOADPROPORTIONS), bEnableSkin); + EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_ENABLECOLORING), bEnableSkin && opt.iEnableColoring != -1); +} + +int iLastSel; +INT_PTR CALLBACK DlgProcOptsSkin(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) + { + case WM_INITDIALOG: + { + TranslateDialogDefault(hwndDlg); + iLastSel = RefreshSkinList(hwndDlg); + + SendDlgItemMessage(hwndDlg, IDC_BTN_RELOADLIST, BUTTONSETASFLATBTN, TRUE, 0); + SendDlgItemMessage(hwndDlg, IDC_BTN_RELOADLIST, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Reload skin list"), BATF_TCHAR); + HICON hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_RELOAD)); + SendDlgItemMessage(hwndDlg, IDC_BTN_RELOADLIST, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); + DestroyIcon(hIcon); + + SendDlgItemMessage(hwndDlg, IDC_BTN_APPLYSKIN, BUTTONSETASFLATBTN, TRUE, 0); + SendDlgItemMessage(hwndDlg, IDC_BTN_APPLYSKIN, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Apply skin"), BATF_TCHAR); + hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_APPLY)); + SendDlgItemMessage(hwndDlg, IDC_BTN_APPLYSKIN, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); + DestroyIcon(hIcon); + + SendDlgItemMessage(hwndDlg, IDC_BTN_GETSKINS, BUTTONSETASFLATBTN, TRUE, 0); + SendDlgItemMessage(hwndDlg, IDC_BTN_GETSKINS, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Get more skins"), BATF_TCHAR); + SendDlgItemMessage(hwndDlg, IDC_BTN_GETSKINS, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadSkinnedIcon(SKINICON_EVENT_URL)); + + + SendDlgItemMessage(hwndDlg, IDC_SPIN_TRANS, UDM_SETRANGE, 0, (LPARAM)MAKELONG(100, 0)); + SetDlgItemInt(hwndDlg, IDC_ED_TRANS, opt.iOpacity, FALSE); + + CheckDlgButton(hwndDlg, IDC_CHK_BORDER, opt.bBorder); + CheckDlgButton(hwndDlg, IDC_CHK_ROUNDCORNERS, opt.bRound); + CheckDlgButton(hwndDlg, IDC_CHK_SHADOW, opt.bDropShadow); + CheckDlgButton(hwndDlg, IDC_CHK_AEROGLASS, opt.bAeroGlass); + CheckDlgButton(hwndDlg, IDC_CHK_LOADFONTS, opt.bLoadFonts); + CheckDlgButton(hwndDlg, IDC_CHK_LOADPROPORTIONS, opt.bLoadProportions); + if (opt.iEnableColoring != -1) + CheckDlgButton(hwndDlg, IDC_CHK_ENABLECOLORING, opt.iEnableColoring ? 1 : 0); + + EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_AEROGLASS), MyDwmEnableBlurBehindWindow != 0); + + SendDlgItemMessage(hwndDlg, IDC_CMB_EFFECT, CB_ADDSTRING, 0, (LPARAM)TranslateT("None")); + SendDlgItemMessage(hwndDlg, IDC_CMB_EFFECT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Animation")); + SendDlgItemMessage(hwndDlg, IDC_CMB_EFFECT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Fade")); + SendDlgItemMessage(hwndDlg, IDC_CMB_EFFECT, CB_SETCURSEL, (int)opt.showEffect, 0); + + SendDlgItemMessage(hwndDlg, IDC_SPIN_SPEED, UDM_SETRANGE, 0, (LPARAM)MAKELONG(20, 1)); + SetDlgItemInt(hwndDlg, IDC_ED_SPEED, opt.iAnimateSpeed, FALSE); + + EnableControls(hwndDlg, opt.skinMode == SM_IMAGE); + return TRUE; + } + case WM_DRAWITEM: + { + if (wParam == IDC_PIC_PREVIEW) + { + DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)lParam; + HBRUSH hbr = GetSysColorBrush(COLOR_BTNFACE); + FillRect(dis->hDC, &dis->rcItem, hbr); + + if (opt.szPreviewFile[0]) + { + HDC hdcMem = CreateCompatibleDC(dis->hDC); + HBITMAP hbmpPreview = (HBITMAP)CallService(MS_IMG_LOAD, (WPARAM)opt.szPreviewFile, IMGL_TCHAR); + if (hbmpPreview) + { + int iWidth = dis->rcItem.right - dis->rcItem.left; + int iHeight = dis->rcItem.bottom - dis->rcItem.top; + + ResizeBitmap rb = {0}; + rb.size = sizeof(rb); + rb.hBmp = hbmpPreview; + rb.max_width = iWidth; + rb.max_height = iHeight; + rb.fit = RESIZEBITMAP_KEEP_PROPORTIONS; + HBITMAP hbmpRes = (HBITMAP)CallService(MS_IMG_RESIZE, (WPARAM)&rb, 0); + if (hbmpRes) + { + BITMAP bmp; + GetObject(hbmpRes, sizeof(bmp), &bmp); + SelectObject(hdcMem, hbmpRes); + BitBlt(dis->hDC, (iWidth - bmp.bmWidth) / 2, (iHeight - bmp.bmHeight) / 2, iWidth, iHeight, hdcMem, 0, 0, SRCCOPY); + if (hbmpPreview != hbmpRes) + DeleteBitmap(hbmpRes); + } + + DeleteBitmap(hbmpPreview); + } + + DeleteDC(hdcMem); + } + } + break; + } + case WM_COMMAND: + { + switch (HIWORD(wParam)) + { + case LBN_SELCHANGE: + { + if (LOWORD(wParam) == IDC_LB_SKINS) + { + HWND hwndList = GetDlgItem(hwndDlg, IDC_LB_SKINS); + int iSel = ListBox_GetCurSel(hwndList); + if (iSel != iLastSel) + { + if (iSel == 0) + { + opt.szPreviewFile[0] = 0; + EnableControls(hwndDlg, FALSE); + } + else if (iSel != LB_ERR) + { + TCHAR swzSkinName[256]; + if (ListBox_GetText(hwndList, iSel, swzSkinName) > 0) + ParseSkinFile(swzSkinName, false, true); + EnableControls(hwndDlg, TRUE); + if (opt.iEnableColoring != -1) + CheckDlgButton(hwndDlg, IDC_CHK_ENABLECOLORING, opt.iEnableColoring ? 1 : 0); + } + + InvalidateRect(GetDlgItem(hwndDlg, IDC_PIC_PREVIEW), 0, FALSE); + iLastSel = iSel; + } + } + else if (LOWORD(wParam) == IDC_CMB_EFFECT) + { + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + + break; + } + case BN_CLICKED: + { + if (LOWORD(wParam) == IDC_BTN_APPLYSKIN) + { + int iSel = ListBox_GetCurSel(GetDlgItem(hwndDlg, IDC_LB_SKINS)); + if (iSel == 0) + { + opt.skinMode = SM_COLORFILL; + opt.szSkinName[0] = 0; + } + else if (iSel != LB_ERR) + { + if (ListBox_GetText(GetDlgItem(hwndDlg, IDC_LB_SKINS), iSel, opt.szSkinName) > 0) + { + opt.skinMode = SM_IMAGE; + ParseSkinFile(opt.szSkinName, false, false); + ReloadFont(0, 0); + SaveOptions(); + } + } + + DBWriteContactSettingByte(0, MODULE, "SkinEngine", opt.skinMode); + DBWriteContactSettingTString(0, MODULE, "SkinName", opt.szSkinName); + + DestroySkinBitmap(); + SetDlgItemInt(hwndDlg, IDC_ED_TRANS, opt.iOpacity, FALSE); + } + else if (LOWORD(wParam) == IDC_BTN_RELOADLIST) + iLastSel = RefreshSkinList(hwndDlg); + else if (LOWORD(wParam) == IDC_CHK_LOADFONTS) + opt.bLoadFonts = IsDlgButtonChecked(hwndDlg, IDC_CHK_LOADFONTS) ? true : false; + else if (LOWORD(wParam) == IDC_CHK_LOADPROPORTIONS) + opt.bLoadProportions = IsDlgButtonChecked(hwndDlg, IDC_CHK_LOADPROPORTIONS) ? true : false; + else if (LOWORD(wParam) == IDC_BTN_GETSKINS) + CallService(MS_UTILS_OPENURL, 0, (LPARAM)"http://www.miranda-easy.net/tipper"); + + break; + } + } + + if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus()) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + + break; + } + case WM_NOTIFY: + { + if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY ) + { + opt.iOpacity = GetDlgItemInt(hwndDlg, IDC_ED_TRANS, 0, 0); + opt.bDropShadow = IsDlgButtonChecked(hwndDlg, IDC_CHK_SHADOW) ? true : false; + opt.bBorder = IsDlgButtonChecked(hwndDlg, IDC_CHK_BORDER) ? true : false; + opt.bRound = IsDlgButtonChecked(hwndDlg, IDC_CHK_ROUNDCORNERS) ? true : false; + opt.bAeroGlass = IsDlgButtonChecked(hwndDlg, IDC_CHK_AEROGLASS) ? true : false; + opt.showEffect = (PopupShowEffect)SendDlgItemMessage(hwndDlg, IDC_CMB_EFFECT, CB_GETCURSEL, 0, 0); + opt.iAnimateSpeed = GetDlgItemInt(hwndDlg, IDC_ED_SPEED, 0, 0); + opt.bLoadFonts = IsDlgButtonChecked(hwndDlg, IDC_CHK_LOADFONTS) ? true : false; + opt.bLoadProportions = IsDlgButtonChecked(hwndDlg, IDC_CHK_LOADPROPORTIONS) ? true : false; + + if (opt.iEnableColoring != -1) + opt.iEnableColoring = IsDlgButtonChecked(hwndDlg, IDC_CHK_ENABLECOLORING) ? true : false; + + SaveSkinOptions(); + return TRUE; + } + } + } + + return FALSE; +} + +INT_PTR CALLBACK DlgProcFavouriteContacts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) + { + case WM_INITDIALOG: + { + TranslateDialogDefault(hwndDlg); + + if (CallService(MS_CLUI_GETCAPS, 0, 0) & CLUIF_DISABLEGROUPS && !DBGetContactSettingByte(NULL, "CList", "UseGroups", SETTING_USEGROUPS_DEFAULT)) + SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETUSEGROUPS, (WPARAM) FALSE, 0); + else + SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETUSEGROUPS, (WPARAM) TRUE, 0); + + SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETHIDEEMPTYGROUPS, 1, 0); + SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETGREYOUTFLAGS, 0, 0); + SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETLEFTMARGIN, 2, 0); + + HANDLE hContact, hItem; + hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + while (hContact) + { + hItem = (HANDLE) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0); + if (hItem && DBGetContactSettingByte(hContact, MODULE, "FavouriteContact", 0)) + SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM)hItem, 1); + + hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0); + } + + CheckDlgButton(hwndDlg, IDC_CHK_HIDEOFFLINE, opt.iFavoriteContFlags & FAVCONT_HIDE_OFFLINE); + CheckDlgButton(hwndDlg, IDC_CHK_APPENDPROTO, opt.iFavoriteContFlags & FAVCONT_APPEND_PROTO); + + return TRUE; + } + case WM_COMMAND: + { + switch(LOWORD(wParam)) + { + case IDC_BTN_OK: + { + HANDLE hContact, hItem; + BYTE isChecked; + int count = 0; + + hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + while (hContact) + { + hItem = (HANDLE) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0); + if (hItem) + { + isChecked = (BYTE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM)hItem, 0); + DBWriteContactSettingByte(hContact, MODULE, "FavouriteContact", isChecked); + if (isChecked) count++; + } + + hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0); + } + DBWriteContactSettingDword(0, MODULE, "FavouriteContactsCount", count); + + opt.iFavoriteContFlags = 0; + opt.iFavoriteContFlags |= IsDlgButtonChecked(hwndDlg, IDC_CHK_HIDEOFFLINE) ? FAVCONT_HIDE_OFFLINE : 0 | + IsDlgButtonChecked(hwndDlg, IDC_CHK_APPENDPROTO) ? FAVCONT_APPEND_PROTO : 0; + + DBWriteContactSettingDword(0, MODULE, "FavContFlags", opt.iFavoriteContFlags); + } // fall through + case IDC_BTN_CANCEL: + { + DestroyWindow(hwndDlg); + break; + } + } + return TRUE; + } + case WM_CLOSE: + { + DestroyWindow(hwndDlg); + return TRUE; + } + } + + return FALSE; +} + +INT_PTR CALLBACK DlgProcOptsTraytip(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) + { + case WM_INITDIALOG: + { + TranslateDialogDefault(hwndDlg); + + CheckDlgButton(hwndDlg, IDC_CHK_ENABLETRAYTIP, opt.bTraytip); + CheckDlgButton(hwndDlg, IDC_CHK_HANDLEBYTIPPER, opt.bHandleByTipper); + CheckDlgButton(hwndDlg, IDC_CHK_EXPAND, opt.bExpandTraytip); + CheckDlgButton(hwndDlg, IDC_CHK_HIDEOFFLINE, opt.bHideOffline); + SendDlgItemMessage(hwndDlg, IDC_SPIN_EXPANDTIME, UDM_SETRANGE, 0, (LPARAM)MAKELONG(5000, 10)); + SetDlgItemInt(hwndDlg, IDC_ED_EXPANDTIME, opt.iExpandTime, FALSE); + SendMessage(hwndDlg, WM_COMMAND, MAKELONG(IDC_CHK_ENABLETRAYTIP, 0), 0); + + SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_FIRST_PROTOS), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_FIRST_PROTOS), GWL_STYLE) | TVS_NOHSCROLL); + SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_SECOND_PROTOS), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_SECOND_PROTOS), GWL_STYLE) | TVS_NOHSCROLL); + SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), GWL_STYLE) | TVS_NOHSCROLL); + SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_SECOND_ITEMS), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_SECOND_ITEMS), GWL_STYLE) | TVS_NOHSCROLL); + + HIMAGELIST himlCheckBoxes; + himlCheckBoxes = ImageList_Create(16, 16, IsWinVerXPPlus() ? ILC_COLOR32 | ILC_MASK : ILC_COLOR8 | ILC_MASK, 3, 0); + ImageList_AddIcon(himlCheckBoxes, LoadSkinnedIcon(SKINICON_OTHER_NOTICK)); + ImageList_AddIcon(himlCheckBoxes, LoadSkinnedIcon(SKINICON_OTHER_NOTICK)); + ImageList_AddIcon(himlCheckBoxes, LoadSkinnedIcon(SKINICON_OTHER_TICK)); + + TreeView_SetImageList(GetDlgItem(hwndDlg, IDC_TREE_FIRST_PROTOS), himlCheckBoxes, TVSIL_STATE); + TreeView_SetImageList(GetDlgItem(hwndDlg, IDC_TREE_SECOND_PROTOS), himlCheckBoxes, TVSIL_STATE); + TreeView_SetImageList(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), himlCheckBoxes, TVSIL_STATE); + TreeView_SetImageList(GetDlgItem(hwndDlg, IDC_TREE_SECOND_ITEMS), himlCheckBoxes, TVSIL_STATE); + + TVINSERTSTRUCT tvi = {0}; + tvi.hParent = 0; + tvi.hInsertAfter = TVI_LAST; + tvi.item.mask = TVIF_TEXT | TVIF_STATE; + + int i, count = 0; + PROTOACCOUNT **accs; + ProtoEnumAccounts(&count, &accs); + + for (i = 0; i < count; i++) + { + if (accs[i]->type == PROTOTYPE_PROTOCOL && CallProtoService(accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) != 0) + { + tvi.item.pszText = accs[i]->tszAccountName; + tvi.item.stateMask = TVIS_STATEIMAGEMASK; + tvi.item.state = INDEXTOSTATEIMAGEMASK(IsTrayProto(accs[i]->tszAccountName, false) ? 2 : 1); + TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_PROTOS), &tvi); + tvi.item.state = INDEXTOSTATEIMAGEMASK(IsTrayProto(accs[i]->tszAccountName, true) ? 2 : 1); + TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_TREE_SECOND_PROTOS), &tvi); + } + } + + for (i = 0; i < SIZEOF(trayTipItems); i++) + { + tvi.item.pszText = TranslateTS(trayTipItems[i]); + tvi.item.state = INDEXTOSTATEIMAGEMASK(opt.iFirstItems & (1 << i) ? 2 : 1); + TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &tvi); + tvi.item.state = INDEXTOSTATEIMAGEMASK(opt.iSecondItems & (1 << i) ? 2 : 1); + TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_TREE_SECOND_ITEMS), &tvi); + } + + return TRUE; + } + case WM_COMMAND: + { + switch(LOWORD(wParam)) + { + UINT state; + case IDC_CHK_ENABLETRAYTIP: + { + state = IsDlgButtonChecked(hwndDlg, IDC_CHK_ENABLETRAYTIP); + EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_HANDLEBYTIPPER), state); + } // fall through + case IDC_CHK_HANDLEBYTIPPER: + { + state = IsDlgButtonChecked(hwndDlg, IDC_CHK_HANDLEBYTIPPER) & + IsDlgButtonChecked(hwndDlg, IDC_CHK_ENABLETRAYTIP); + + EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_HIDEOFFLINE), state); + EnableWindow(GetDlgItem(hwndDlg, IDC_TREE_FIRST_PROTOS), state); + EnableWindow(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), state); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_FAVCONTACTS), state); + EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_EXPAND), state); + } // fall through + case IDC_CHK_EXPAND: + { + state = IsDlgButtonChecked(hwndDlg, IDC_CHK_HANDLEBYTIPPER) & + IsDlgButtonChecked(hwndDlg, IDC_CHK_ENABLETRAYTIP) & + IsDlgButtonChecked(hwndDlg, IDC_CHK_EXPAND); + EnableWindow(GetDlgItem(hwndDlg, IDC_TREE_SECOND_PROTOS), state); + EnableWindow(GetDlgItem(hwndDlg, IDC_TREE_SECOND_ITEMS), state); + EnableWindow(GetDlgItem(hwndDlg, IDC_ED_EXPANDTIME), state); + break; + } + case IDC_BTN_FAVCONTACTS: + { + CreateDialog(hInst, MAKEINTRESOURCE(IDD_FAVCONTACTS), 0, DlgProcFavouriteContacts); + break; + } + } + + if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus()) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + + break; + } + case WM_NOTIFY: + { + switch (((LPNMHDR)lParam)->idFrom) + { + case 0: + { + if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY) + { + TCHAR buff[256]; + TCHAR swzProtos[1024] = {0}; + + TVITEM item; + item.hItem = TreeView_GetRoot(GetDlgItem(hwndDlg,IDC_TREE_FIRST_PROTOS)); + item.pszText = buff; + item.cchTextMax = 256; + item.mask = TVIF_HANDLE | TVIF_TEXT | TVIF_STATE; + item.stateMask = TVIS_STATEIMAGEMASK; + while (item.hItem != NULL) + { + TreeView_GetItem(GetDlgItem(hwndDlg,IDC_TREE_FIRST_PROTOS), &item); + if (((item.state & TVIS_STATEIMAGEMASK) >> 12) == 2) + { + _tcscat(swzProtos, buff); + _tcscat(swzProtos, _T(" ")); + } + + item.hItem = TreeView_GetNextSibling(GetDlgItem(hwndDlg, IDC_TREE_FIRST_PROTOS), item.hItem); + } + + DBWriteContactSettingTString(0, MODULE, "TrayProtocols", swzProtos); + + swzProtos[0] = 0; + item.hItem = TreeView_GetRoot(GetDlgItem(hwndDlg,IDC_TREE_SECOND_PROTOS)); + item.pszText = buff; + while (item.hItem != NULL) + { + TreeView_GetItem(GetDlgItem(hwndDlg,IDC_TREE_SECOND_PROTOS), &item); + if (((item.state & TVIS_STATEIMAGEMASK) >> 12) == 2) + { + _tcscat(swzProtos, buff); + _tcscat(swzProtos, _T(" ")); + } + + item.hItem = TreeView_GetNextSibling(GetDlgItem(hwndDlg, IDC_TREE_SECOND_PROTOS), item.hItem); + } + + DBWriteContactSettingTString(0, MODULE, "TrayProtocolsEx", swzProtos); + + int count = 0; + opt.iFirstItems = 0; + item.hItem = TreeView_GetRoot(GetDlgItem(hwndDlg,IDC_TREE_FIRST_ITEMS)); + item.mask = TVIF_HANDLE | TVIF_STATE; + item.stateMask = TVIS_STATEIMAGEMASK; + while (item.hItem != NULL) + { + TreeView_GetItem(GetDlgItem(hwndDlg,IDC_TREE_FIRST_ITEMS), &item); + if (((item.state & TVIS_STATEIMAGEMASK) >> 12) == 2) + opt.iFirstItems |= (1 << count); + + item.hItem = TreeView_GetNextSibling(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), item.hItem); + count++; + } + + count = 0; + opt.iSecondItems = 0; + item.hItem = TreeView_GetRoot(GetDlgItem(hwndDlg,IDC_TREE_SECOND_ITEMS)); + while (item.hItem != NULL) + { + TreeView_GetItem(GetDlgItem(hwndDlg,IDC_TREE_SECOND_ITEMS), &item); + if (((item.state & TVIS_STATEIMAGEMASK) >> 12) == 2) + opt.iSecondItems |= (1 << count); + + item.hItem = TreeView_GetNextSibling(GetDlgItem(hwndDlg, IDC_TREE_SECOND_ITEMS), item.hItem); + count++; + } + + opt.bTraytip = IsDlgButtonChecked(hwndDlg, IDC_CHK_ENABLETRAYTIP) ? true : false; + opt.bHandleByTipper = IsDlgButtonChecked(hwndDlg, IDC_CHK_HANDLEBYTIPPER) ? true : false; + opt.bExpandTraytip = IsDlgButtonChecked(hwndDlg, IDC_CHK_EXPAND) ? true : false; + opt.bHideOffline = IsDlgButtonChecked(hwndDlg, IDC_CHK_HIDEOFFLINE) ? true : false; + opt.iExpandTime = max(min(GetDlgItemInt(hwndDlg, IDC_ED_EXPANDTIME, 0, FALSE), 5000), 10); + + DBWriteContactSettingByte(0, MODULE, "TrayTip", (opt.bTraytip ? 1 : 0)); + DBWriteContactSettingByte(0, MODULE, "ExtendedTrayTip", (opt.bHandleByTipper ? 1 : 0)); + DBWriteContactSettingByte(0, MODULE, "ExpandTrayTip", (opt.bExpandTraytip ? 1 : 0)); + DBWriteContactSettingByte(0, MODULE, "HideOffline", (opt.bHideOffline ? 1 : 0)); + DBWriteContactSettingDword(0, MODULE, "ExpandTime", opt.iExpandTime); + DBWriteContactSettingDword(0, MODULE, "TrayTipItems", opt.iFirstItems); + DBWriteContactSettingDword(0, MODULE, "TrayTipItemsEx", opt.iSecondItems); + return TRUE; + } + break; + } + case IDC_TREE_FIRST_PROTOS: + case IDC_TREE_SECOND_PROTOS: + case IDC_TREE_FIRST_ITEMS: + case IDC_TREE_SECOND_ITEMS: + { + if (((LPNMHDR)lParam)->code == NM_CLICK) + { + TVHITTESTINFO hti; + hti.pt.x = (short)LOWORD(GetMessagePos()); + hti.pt.y = (short)HIWORD(GetMessagePos()); + ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt); + if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti)) + { + if (hti.flags & TVHT_ONITEMSTATEICON) + { + TVITEMA item = {0}; + item.hItem = hti.hItem; + item.mask = TVIF_HANDLE | TVIF_STATE; + item.stateMask = TVIS_STATEIMAGEMASK; + TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item); + + if (((item.state & TVIS_STATEIMAGEMASK) >> 12) == 1) + item.state = INDEXTOSTATEIMAGEMASK(2); + else + item.state = INDEXTOSTATEIMAGEMASK(1); + + TreeView_SetItem(((LPNMHDR)lParam)->hwndFrom, &item); + SendMessage((GetParent(hwndDlg)), PSM_CHANGED, (WPARAM)hwndDlg, 0); + } + } + } + break; + } + } + break; + } + case WM_DESTROY: + { + ImageList_Destroy(TreeView_GetImageList(GetDlgItem(hwndDlg, IDC_TREE_FIRST_PROTOS), TVSIL_STATE)); + break; + } + } + + return FALSE; +} + +int OptInit(WPARAM wParam, LPARAM lParam) +{ + OPTIONSDIALOGPAGE odp = {0}; + odp.cbSize = sizeof(odp); + odp.flags = ODPF_BOLDGROUPS; + odp.position = -790000000; + odp.hInstance = hInst; + + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_APPEARANCE); + odp.pszTab = LPGEN("Appearance"); + odp.pszTitle = LPGEN("Tooltips"); + odp.pszGroup = LPGEN("Customize"); + odp.pfnDlgProc = DlgProcOptsAppearance; + Options_AddPage(wParam, &odp); + + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_SKIN); + odp.pszTab = LPGEN("Tooltips"); + odp.pszGroup = LPGEN("Skins"); + odp.pfnDlgProc = DlgProcOptsSkin; + Options_AddPage(wParam, &odp); + + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_CONTENT); + odp.pszTab = LPGEN("Content"); + odp.pszTitle = LPGEN("Tooltips"); + odp.pszGroup = LPGEN("Customize"); + odp.pfnDlgProc = DlgProcOptsContent; + Options_AddPage(wParam, &odp); + + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_TRAYTIP); + odp.pszTab = LPGEN("Tray tooltip"); + odp.pszTitle = LPGEN("Tooltips"); + odp.pszGroup = LPGEN("Customize"); + odp.pfnDlgProc = DlgProcOptsTraytip; + Options_AddPage(wParam, &odp); + + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_EXTRA); + odp.pszTab = LPGEN("Extra"); + odp.pszTitle = LPGEN("Tooltips"); + odp.pszGroup = LPGEN("Customize"); + odp.pfnDlgProc = DlgProcOptsExtra; + Options_AddPage(wParam, &odp); + + return 0; +} + +HANDLE hEventOptInit; + +void InitOptions() +{ + hEventOptInit = HookEvent(ME_OPT_INITIALISE, OptInit); +} + +void DeinitOptions() +{ + UnhookEvent(hEventOptInit); + + DIListNode *di_node = opt.diList; + while(opt.diList) + { + di_node = opt.diList; + opt.diList = opt.diList->next; + mir_free(di_node); + } + + DSListNode *ds_node = opt.dsList; + while(opt.dsList) + { + ds_node = opt.dsList; + opt.dsList = opt.dsList->next; + mir_free(ds_node); + } + + for (int i = 0; i < SKIN_ITEMS_COUNT; i++) + { + if (opt.szImgFile[i]) + mir_free(opt.szImgFile[i]); + } +} diff --git a/plugins/TipperYM/src/options.h b/plugins/TipperYM/src/options.h new file mode 100644 index 0000000000..52411110fb --- /dev/null +++ b/plugins/TipperYM/src/options.h @@ -0,0 +1,196 @@ +/* +Copyright (C) 2006-2007 Scott Ellis +Copyright (C) 2007-2011 Jan Holub + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#ifndef _OPTIONS_INC +#define _OPTIONS_INC + +#include "translations.h" +#include "popwin.h" +#include "bitmap_func.h" +#include "skin_parser.h" + +#define WMU_ENABLE_LIST_BUTTONS (WM_USER + 0x030) +#define WMU_ENABLE_MODULE_ENTRY (WM_USER + 0x031) + +#define LABEL_LEN 1024 +#define VALUE_LEN 8192 +#define MODULE_NAME_LEN 512 +#define SETTING_NAME_LEN 512 + +// chekcbox icons +#define IDI_NOTICK 205 +#define IDI_TICK 206 +#define IDPRESETITEM 1000 + +#define MS_TOOLTIP_SHOWTIP "mToolTip/ShowTip" + +typedef struct { + UINT id, uintCoreIconId, uintResIconId; + TCHAR *swzTooltip; +} OPTBUTTON; + +typedef struct { + TCHAR swzLabel[LABEL_LEN]; + TCHAR swzValue[VALUE_LEN]; + bool bLineAbove, bValueNewline; + bool bIsVisible; + bool bParseTipperVarsFirst; +} DISPLAYITEM; + +typedef enum {DVT_DB = 0, DVT_PROTODB = 1} DisplaySubstType; +typedef struct { + TCHAR swzName[LABEL_LEN]; + DisplaySubstType type; + char szModuleName[MODULE_NAME_LEN]; + char szSettingName[SETTING_NAME_LEN]; + int iTranslateFuncId; +} DISPLAYSUBST; + +struct DSListNode { + DISPLAYSUBST ds; + DSListNode *next; +}; + +struct DIListNode { + DISPLAYITEM di; + DIListNode *next; +}; + +typedef struct { + BYTE top; + BYTE right; + BYTE bottom; + BYTE left; +} MARGINS; + +// tray tooltip items +static TCHAR* trayTipItems[TRAYTIP_ITEMS_COUNT] = +{ + LPGENT("Number of contacts"), + LPGENT("Protocol lock status"), + LPGENT("Logon time"), + LPGENT("Unread emails"), + LPGENT("Status"), + LPGENT("Status message"), + LPGENT("Extra status"), + LPGENT("Listening to"), + LPGENT("Favourite contacts"), + LPGENT("Miranda uptime"), + LPGENT("Clist event") +}; + +// extra icons +static TCHAR* extraIconName[6] = +{ + LPGENT("Status"), + LPGENT("Extra status"), + LPGENT("Jabber activity"), + LPGENT("Gender"), + LPGENT("Country flag"), + LPGENT("Client") +}; + +typedef struct { + bool bDragging; + HTREEITEM hDragItem; +} EXTRAICONDATA; + +typedef struct { + BYTE order; + BYTE vis; +} ICONSTATE; + +typedef enum {PAV_NONE=0, PAV_LEFT=1, PAV_RIGHT=2} PopupAvLayout; +typedef enum {PTL_LEFTICON=0, PTL_RIGHTICON=1, PTL_NOICON=2, PTL_NOTITLE=3} PopupTitleLayout; +typedef enum {PP_BOTTOMRIGHT=0, PP_BOTTOMLEFT=1, PP_TOPRIGHT=2, PP_TOPLEFT=3} PopupPosition; +typedef enum {PSE_NONE=0, PSE_ANIMATE=1, PSE_FADE=2} PopupShowEffect; + +typedef struct { + int iWinWidth, iWinMaxHeight, iAvatarSize; //tweety + PopupTitleLayout titleLayout; + PopupAvLayout avatarLayout; + int iTextIndent, iTitleIndent, iValueIndent; + bool bShowNoFocus; + DSListNode *dsList; + int iDsCount; + DIListNode *diList; + int iDiCount; + int iTimeIn; + int iPadding, iOuterAvatarPadding, iInnerAvatarPadding, iTextPadding; + PopupPosition pos; + int iMinWidth, iMinHeight; // no UI for these + int iMouseTollerance; + bool bStatusBarTips; + int iSidebarWidth; + COLORREF colBg, colBorder, colAvatarBorder, colDivider, colBar, colTitle, colLabel, colValue, colTrayTitle, colSidebar; + int iLabelValign, iLabelHalign, iValueValign, iValueHalign; + bool bWaitForStatusMsg, bWaitForAvatar; + + // tooltip skin + SkinMode skinMode; + TCHAR szSkinName[256]; + TCHAR szPreviewFile[1024]; + TCHAR *szImgFile[SKIN_ITEMS_COUNT]; + MARGINS margins[SKIN_ITEMS_COUNT]; + TransformationMode transfMode[SKIN_ITEMS_COUNT]; + PopupShowEffect showEffect; + bool bLoadFonts; + bool bLoadProportions; + int iEnableColoring; + int iAnimateSpeed; + int iOpacity; + int iAvatarOpacity; + bool bBorder; + bool bRound, bAvatarRound; + bool bDropShadow; + bool bAeroGlass; + + // tray tooltip + bool bTraytip; + bool bHandleByTipper; + bool bExpandTraytip; + bool bHideOffline; + int iExpandTime; + int iFirstItems, iSecondItems; + int iFavoriteContFlags; + + // extra setting + bool bOriginalAvatarSize; + bool bAvatarBorder; + bool bWaitForContent; + bool bGetNewStatusMsg; + bool bDisableIfInvisible; + bool bRetrieveXstatus; + bool bLimitMsg; + int iLimitCharCount; + int iSmileyAddFlags; + BYTE exIconsOrder[EXICONS_COUNT]; + BYTE exIconsVis[EXICONS_COUNT]; +} OPTIONS; + + +extern OPTIONS opt; + +void InitOptions(); +void LoadOptions(); +void SaveOptions(); +void DeinitOptions(); + +#endif diff --git a/plugins/TipperYM/src/popwin.cpp b/plugins/TipperYM/src/popwin.cpp new file mode 100644 index 0000000000..964069ce2d --- /dev/null +++ b/plugins/TipperYM/src/popwin.cpp @@ -0,0 +1,2016 @@ +/* +Copyright (C) 2006-2007 Scott Ellis +Copyright (C) 2007-2011 Jan Holub + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#include "common.h" +#include "subst.h" +#include "popwin.h" +#include "message_pump.h" +#include "str_utils.h" +#include "bitmap_func.h" +#include "translations.h" +#include "m_gender.h" + +extern TOOLTIPSKIN skin; + +__inline void AddRow(PopupWindowData *pwd, TCHAR *swzLabel, TCHAR *swzValue, char *szProto, bool bParseSmileys, bool bNewline, bool bLineAbove, bool bIsTitle = false, HICON hIcon = NULL) +{ + pwd->rows = (RowData *)mir_realloc(pwd->rows, sizeof(RowData) * (pwd->iRowCount + 1)); + pwd->rows[pwd->iRowCount].swzLabel = swzLabel ? mir_tstrdup(swzLabel) : NULL; + pwd->rows[pwd->iRowCount].swzValue = swzValue ? mir_tstrdup(swzValue) : NULL; + pwd->rows[pwd->iRowCount].spi = bParseSmileys ? Smileys_PreParse(swzValue, (int)_tcslen(swzValue), szProto) : NULL; + pwd->rows[pwd->iRowCount].bValueNewline = bNewline; + pwd->rows[pwd->iRowCount].bLineAbove = bLineAbove; + pwd->rows[pwd->iRowCount].bIsTitle = bIsTitle; + pwd->rows[pwd->iRowCount].hIcon = hIcon; + pwd->iRowCount++; +} + +LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + PopupWindowData *pwd = (PopupWindowData *)GetWindowLongPtr(hwnd, GWLP_USERDATA); + + switch(uMsg) + { + case WM_CREATE: + { + CREATESTRUCT *cs = (CREATESTRUCT *)lParam; + pwd = (PopupWindowData *)mir_alloc(sizeof(PopupWindowData)); + memset(pwd, 0, sizeof(PopupWindowData)); + pwd->clcit = *(CLCINFOTIPEX *)cs->lpCreateParams; + pwd->iIconIndex = -1; + pwd->hpenBorder = CreatePen(PS_SOLID, 1, opt.bBorder ? opt.colBorder : opt.colBg); + pwd->hpenDivider = CreatePen(PS_SOLID, 1, opt.colDivider); + pwd->iTrans = (int)(opt.iOpacity / 100.0 * 255); + + // load icons order + for (int i = 0; i < EXICONS_COUNT; i++) + pwd->bIsIconVisible[opt.exIconsOrder[i]] = opt.exIconsVis[i] ? true : false; + + SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pwd); + + // work around bug hiding tips + GetCursorPos(&pwd->ptCursorStartPos); + SetTimer(hwnd, ID_TIMER_CHECKMOUSE, CHECKMOUSE_ELAPSE, 0); + + //Register copy menu hotkey (CTRL+C) + pwd->iHotkeyId = GlobalAddAtom(_T("Tipper")); + RegisterHotKey(hwnd, pwd->iHotkeyId, MOD_CONTROL, 0x43); + + if (pwd->clcit.szProto) + { + pwd->bIsTextTip= false; + pwd->iIndent = opt.iTextIndent; + pwd->iSidebarWidth= opt.iSidebarWidth; + + if (ServiceExists(MS_PROTO_GETACCOUNT)) + { + PROTOACCOUNT *pa = ProtoGetAccount(pwd->clcit.szProto); + if (pa) _tcscpy(pwd->swzTitle, pa->tszAccountName); + } + + if (_tcslen(pwd->swzTitle) == 0) + a2t(pwd->clcit.szProto, pwd->swzTitle, TITLE_TEXT_LEN); + + if (CallService(MS_PROTO_ISACCOUNTLOCKED,0,(LPARAM)pwd->clcit.szProto)) + mir_sntprintf(pwd->swzTitle, SIZEOF(pwd->swzTitle), TranslateT("%s (locked)"), pwd->swzTitle); + + // protocol status + WORD wStatus = (WORD)CallProtoService(pwd->clcit.szProto, PS_GETSTATUS, 0, 0); + + // get status icon + if (pwd->bIsIconVisible[0]) + { + pwd->extraIcons[0].hIcon = LoadSkinnedProtoIcon(pwd->clcit.szProto, wStatus); + pwd->extraIcons[0].bDestroy = false; + } + + // get activity icon + if (pwd->bIsIconVisible[2]) + { + pwd->extraIcons[2].hIcon = GetJabberActivityIcon(0, pwd->clcit.szProto); + pwd->extraIcons[2].bDestroy = false; + } + + // uid info + TCHAR swzUid[256], swzUidName[256]; + if (Uid(0, pwd->clcit.szProto, swzUid, 256) && UidName(pwd->clcit.szProto, swzUidName, 253)) + { + _tcscat(swzUidName, _T(": ")); + AddRow(pwd, swzUidName, swzUid, NULL, false, false, false); + } + + // logon info + TCHAR swzLogon[64]; + if (TimestampToTimeDifference(NULL, pwd->clcit.szProto, "LogonTS", swzLogon, 59)) + { + _tcscat(swzLogon, TranslateT(" ago")); + AddRow(pwd, TranslateT("Log on:"), swzLogon, NULL, false, false, false); + } + + // logoff info + TCHAR swzLogoff[64]; + if (TimestampToTimeDifference(NULL, pwd->clcit.szProto, "LogoffTS", swzLogoff, 59)) + { + _tcscat(swzLogoff, TranslateT(" ago")); + AddRow(pwd, TranslateT("Log off:"), swzLogoff, NULL, false, false, false); + } + + // number of unread emails + TCHAR swzEmailCount[64]; + if (ProtoServiceExists(pwd->clcit.szProto, "/GetUnreadEmailCount")) + { + int iCount = (int)CallProtoService(pwd->clcit.szProto, "/GetUnreadEmailCount", 0, 0); + if (iCount > 0) + { + _itot(iCount, swzEmailCount, 10); + AddRow(pwd, TranslateT("Unread emails:"), swzEmailCount, NULL, false, false, false); + } + } + + TCHAR *swzText = (TCHAR *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, wStatus, GSMDF_TCHAR); + if (swzText) + { + AddRow(pwd, TranslateT("Status:"), swzText, NULL, false, false, false); + } + + if (wStatus >= ID_STATUS_ONLINE && wStatus <= ID_STATUS_OUTTOLUNCH) + { + // status message + TCHAR *swzText = GetProtoStatusMessage(pwd->clcit.szProto, wStatus); + if (swzText) + { + StripBBCodesInPlace(swzText); + AddRow(pwd, TranslateT("Status message:"), swzText, pwd->clcit.szProto, true, true, true); + mir_free(swzText); + } + + // jabber mood or icq xstatus + TCHAR *swzAdvTitle = GetJabberAdvStatusText(pwd->clcit.szProto, "mood", "title"); + if (swzAdvTitle) + { + StripBBCodesInPlace(swzAdvTitle); + AddRow(pwd, TranslateT("Mood:"), swzAdvTitle, pwd->clcit.szProto, true, false, true); + + TCHAR *swzAdvText = GetJabberAdvStatusText(pwd->clcit.szProto, "mood", "text"); + if (swzAdvText) + { + StripBBCodesInPlace(swzAdvText); + AddRow(pwd, _T(""), swzAdvText, pwd->clcit.szProto, true, true, false); + mir_free(swzAdvText); + } + } + else + { + if (DBGetContactSettingByte(0, pwd->clcit.szProto, "XStatusId", 0)) + { + // xstatus title + swzAdvTitle = GetProtoExtraStatusTitle(pwd->clcit.szProto); + if (swzAdvTitle) + { + StripBBCodesInPlace(swzAdvTitle); + AddRow(pwd, TranslateT("XStatus:"), swzAdvTitle, pwd->clcit.szProto, true, false, true); + } + + // xstatus message + TCHAR *swzAdvText = GetProtoExtraStatusMessage(pwd->clcit.szProto); + if (swzAdvText) + { + StripBBCodesInPlace(swzAdvText); + AddRow(pwd, _T(""), swzAdvText, pwd->clcit.szProto, true, true, false); + mir_free(swzAdvText); + } + } + } + + if (swzAdvTitle) + { + mir_free(swzAdvTitle); + // get advanced status icon + if (pwd->bIsIconVisible[1]) + { + pwd->extraIcons[1].hIcon = (HICON)CallProtoService(pwd->clcit.szProto, PS_ICQ_GETCUSTOMSTATUSICON, 0, 0); + pwd->extraIcons[1].bDestroy = true; + } + } + + // jabber activity + TCHAR *swzActTitle = GetJabberAdvStatusText(pwd->clcit.szProto, "activity", "title"); + if (swzActTitle) + { + StripBBCodesInPlace(swzActTitle); + AddRow(pwd, TranslateT("Activity:"), swzActTitle, pwd->clcit.szProto, true, false, true); + mir_free(swzActTitle); + } + + TCHAR *swzActText = GetJabberAdvStatusText(pwd->clcit.szProto, "activity", "text"); + if (swzActText) + { + StripBBCodesInPlace(swzActText); + AddRow(pwd, _T(""), swzActText, pwd->clcit.szProto, true, true, false); + mir_free(swzActText); + } + + // listening to + TCHAR *swzListening = GetListeningTo(pwd->clcit.szProto); + if (swzListening) + { + StripBBCodesInPlace(swzListening); + AddRow(pwd, TranslateT("Listening to:"), swzListening, NULL, false, true, true); + mir_free(swzListening); + } + } + } + else if (pwd->clcit.swzText) + { + pwd->bIsTextTip = true; + pwd->iIndent = 0; + pwd->iSidebarWidth= 0; + + RECT rc = pwd->clcit.rcItem; + bool mirandaTrayTip = ((rc.right - rc.left) == 20) && ((rc.bottom - rc.top) == 20) ? true : false; + + if (mirandaTrayTip && !opt.bTraytip) + { + MyDestroyWindow(hwnd); + return 0; + } + + if (mirandaTrayTip && opt.bHandleByTipper) // extended tray tooltip + { + pwd->bIsTrayTip = true; + pwd->iIndent = opt.iTextIndent; + pwd->iSidebarWidth= opt.iSidebarWidth; + + SendMessage(hwnd, PUM_REFRESHTRAYTIP, 0, 0); + + if (opt.bExpandTraytip) + SetTimer(hwnd, ID_TIMER_TRAYTIP, opt.iExpandTime, 0); + } + else + { + + TCHAR buff[2048], *swzText = pwd->clcit.swzText; + size_t iBuffPos, i = 0, iSize = _tcslen(pwd->clcit.swzText); + bool bTopMessage = false; + + while (i < iSize && swzText[i] != _T('<')) + { + iBuffPos = 0; + while (swzText[i] != _T('\n') && swzText[i] != _T('\r') && i < iSize && iBuffPos < 2048) + { + if (swzText[i] != _T('\t')) + buff[iBuffPos++] = swzText[i]; + i++; + } + + buff[iBuffPos] = 0; + + if (iBuffPos) + { + AddRow(pwd, _T(""), buff, NULL, false, true, false); + bTopMessage = true; + } + + while (i < iSize && (swzText[i] == _T('\n') || swzText[i] == _T('\r'))) + i++; + } + + // parse bold bits into labels and the rest into items + while (i < iSize) + { + while (i + 2 < iSize + && (swzText[i] != _T('<') + || swzText[i + 1] != _T('b') + || swzText[i + 2] != _T('>'))) + { + i++; + } + + i += 3; + + iBuffPos = 0; + while (i + 3 < iSize + && iBuffPos < 2048 + && (swzText[i] != _T('<') + || swzText[i + 1] != _T('/') + || swzText[i + 2] != _T('b') + || swzText[i + 3] != _T('>'))) + { + if (swzText[i] != _T('\t')) + buff[iBuffPos++] = swzText[i]; + i++; + } + + i += 4; + + buff[iBuffPos] = 0; + + if (iBuffPos) + { + pwd->rows = (RowData *)mir_realloc(pwd->rows, sizeof(RowData) * (pwd->iRowCount + 1)); + pwd->rows[pwd->iRowCount].bValueNewline = false; + pwd->rows[pwd->iRowCount].swzLabel = mir_tstrdup(buff); + if (pwd->iRowCount == 1 && bTopMessage) + pwd->rows[pwd->iRowCount].bLineAbove = true; + else + pwd->rows[pwd->iRowCount].bLineAbove = false; + + iBuffPos = 0; + while (i < iSize + && iBuffPos < 2048 + && swzText[i] != _T('\n')) + { + if (swzText[i] != _T('\t') && swzText[i] != _T('\r')) + buff[iBuffPos++] = swzText[i]; + i++; + } + buff[iBuffPos] = 0; + + pwd->rows[pwd->iRowCount].swzValue = mir_tstrdup(buff); + pwd->rows[pwd->iRowCount].spi = NULL; + pwd->iRowCount++; + } + + i++; + } + + if (pwd->iRowCount == 0) + { + // single item + pwd->iRowCount = 1; + pwd->rows = (RowData *)mir_alloc(sizeof(RowData)); + pwd->rows[0].bLineAbove = pwd->rows[0].bValueNewline = false; + pwd->rows[0].swzLabel = 0; + pwd->rows[0].swzValue = swzText; + pwd->rows[0].spi = NULL; + } + } + } + else + { + pwd->bIsTextTip = false; + pwd->iIndent = opt.iTextIndent; + pwd->iSidebarWidth= opt.iSidebarWidth; + pwd->hContact = pwd->clcit.hItem; + pwd->iIconIndex = (int)CallService(MS_CLIST_GETCONTACTICON, (WPARAM)pwd->hContact, 0); + + // don't use stored status message + if (!opt.bWaitForContent) + DBDeleteContactSetting(pwd->hContact, MODULE, "TempStatusMsg"); + + TCHAR *swzNick = (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)pwd->hContact, GCDNF_TCHAR); + _tcsncpy(pwd->swzTitle, swzNick, TITLE_TEXT_LEN); + + char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)pwd->hContact, 0); + pwd->spiTitle = Smileys_PreParse(pwd->swzTitle, -1, szProto); + + // get extra icons + DBVARIANT dbv = {0}; + int i = 0; + + if (szProto) + { + // status icon + if (pwd->bIsIconVisible[0]) + { + for (i = 0; opt.exIconsOrder[i] != 0; i++); + pwd->extraIcons[i].hIcon = ImageList_GetIcon((HIMAGELIST)CallService(MS_CLIST_GETICONSIMAGELIST, 0, 0), pwd->iIconIndex, 0); + pwd->extraIcons[i].bDestroy = true; + } + + // xstatus icon + if (pwd->bIsIconVisible[1]) + { + for (i = 0; opt.exIconsOrder[i] != 1; i++); + int iXstatus = DBGetContactSettingByte(pwd->hContact, szProto, "XStatusId", 0); + if (iXstatus) + { + char szIconProto[64]; + if (strcmp(szProto, szMetaModuleName) != 0) + { + strcpy(szIconProto, szProto); + } + else if (!DBGetContactSettingString(pwd->hContact, szProto, "XStatusProto", &dbv)) + { + strcpy(szIconProto, dbv.pszVal); + DBFreeVariant(&dbv); + } + + pwd->extraIcons[i].hIcon = (HICON)CallProtoService(szIconProto, PS_ICQ_GETCUSTOMSTATUSICON, (WPARAM)iXstatus, LR_SHARED); + pwd->extraIcons[i].bDestroy = false; + } + } + + // activity icon + if (pwd->bIsIconVisible[2]) + { + for (i = 0; opt.exIconsOrder[i] != 2; i++); + pwd->extraIcons[i].hIcon = GetJabberActivityIcon(pwd->hContact, szProto); + pwd->extraIcons[i].bDestroy = false; + } + + // gender icon + if (pwd->bIsIconVisible[3]) + { + for (i = 0; opt.exIconsOrder[i] != 3; i++); + if (ServiceExists(MS_GENDER_GETICON)) + { + pwd->extraIcons[i].hIcon = (HICON)CallService(MS_GENDER_GETICON, (WPARAM)pwd->hContact, 0); + } + else + { + int iGender = DBGetContactSettingByte(pwd->hContact, "UserInfo", "Gender", 0); + if (iGender == 0) + iGender = DBGetContactSettingByte(pwd->hContact, szProto, "Gender", 0); + + if (iGender == GEN_FEMALE) + pwd->extraIcons[i].hIcon = (HICON)CallService(MS_SKIN2_GETICON, NULL, (LPARAM)"UserInfoEx_common_female"); + else if (iGender == GEN_MALE) + pwd->extraIcons[i].hIcon = (HICON)CallService(MS_SKIN2_GETICON, NULL, (LPARAM)"UserInfoEx_common_male"); + } + pwd->extraIcons[i].bDestroy = false; + } + + // flags icon + if (pwd->bIsIconVisible[4]) + { + for (i = 0; opt.exIconsOrder[i] != 4; i++); + + int iCountry = 0; + if (ServiceExists(MS_FLAGS_DETECTCONTACTORIGINCOUNTRY)) + iCountry = CallService(MS_FLAGS_DETECTCONTACTORIGINCOUNTRY, (WPARAM)pwd->hContact, 0); + else if (ServiceExists(MS_FLAGS_GETCONTACTORIGINCOUNTRY)) + iCountry = CallService(MS_FLAGS_GETCONTACTORIGINCOUNTRY, (WPARAM)pwd->hContact, 0); + + if (iCountry != 0 && iCountry != CTRY_UNKNOWN && iCountry != CTRY_ERROR) + { + pwd->extraIcons[i].hIcon = LoadFlagIcon(iCountry); + pwd->extraIcons[i].bDestroy = false; + } + } + + // fingerprint icon + if (pwd->bIsIconVisible[5]) + { + + if (ServiceExists(MS_FP_GETCLIENTICONT)) + { + for (i = 0; opt.exIconsOrder[i] != 5; i++); + if (!DBGetContactSettingTString(pwd->hContact, szProto, "MirVer", &dbv)) + { + pwd->extraIcons[i].hIcon = (HICON)CallService(MS_FP_GETCLIENTICONT, (WPARAM)dbv.ptszVal, 0); + pwd->extraIcons[i].bDestroy = true; + DBFreeVariant(&dbv); + } + } + else + + if (ServiceExists(MS_FP_GETCLIENTICON)) + { + for (i = 0; opt.exIconsOrder[i] != 5; i++); + if (!DBGetContactSettingString(pwd->hContact, szProto, "MirVer", &dbv)) + { + pwd->extraIcons[i].hIcon = (HICON)CallService(MS_FP_GETCLIENTICON, (WPARAM)dbv.pszVal, 0); + pwd->extraIcons[i].bDestroy = true; + DBFreeVariant(&dbv); + } + } + } + + //request xstatus details + if (opt.bRetrieveXstatus) + { + if (!DBGetContactSettingByte(0, szProto, "XStatusAuto", 1) && ProtoServiceExists(szProto, PS_ICQ_REQUESTCUSTOMSTATUS)) + CallProtoService(szProto, PS_ICQ_REQUESTCUSTOMSTATUS, (WPARAM)pwd->hContact, 0); + } + } + + SendMessage(hwnd, PUM_REFRESH_VALUES, FALSE, 0); + } + + SendMessage(hwnd, PUM_GETHEIGHT, 0, 0); + SendMessage(hwnd, PUM_CALCPOS, 0, 0); + + // transparency + SetWindowLongPtr(hwnd, GWL_EXSTYLE, GetWindowLongPtr(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED); + + if (opt.bDropShadow && opt.skinMode == SM_COLORFILL) + SetClassLongPtr(hwnd, GCL_STYLE, CS_DROPSHADOW); + else + SetClassLongPtr(hwnd, GCL_STYLE, 0); + + if (!skin.bNeedLayerUpdate && MySetLayeredWindowAttributes) + MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), 0, LWA_ALPHA); + + if (opt.showEffect) + SetTimer(hwnd, ID_TIMER_ANIMATE, ANIM_ELAPSE, 0); + + ShowWindow(hwnd, SW_SHOWNOACTIVATE); + InvalidateRect(hwnd, 0, FALSE); + + // since tipper win is topmost, this should put it at top of topmost windows + SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + return 0; + } + case WM_ERASEBKGND: + { + if (!skin.bNeedLayerUpdate) + { + HDC hdc = (HDC)wParam; + RECT rc; + GetClientRect(hwnd, &rc); + + BitBlt(hdc, 0, 0, skin.iWidth, skin.iHeight, skin.hdc, 0, 0, SRCCOPY); + + // border + if (opt.bBorder) + { + HBRUSH hOldBrush = (HBRUSH)SelectObject(hdc, GetStockObject(NULL_BRUSH)); + HPEN hOldPen = (HPEN)SelectObject(hdc, pwd->hpenBorder); + + int h = 0; + if (opt.bRound) + { + int v; + int w = 14; + h = (rc.right-rc.left) > (w*2) ? w : (rc.right-rc.left); + v = (rc.bottom-rc.top) > (w*2) ? w : (rc.bottom-rc.top); + h = (h < v) ? h : v; + } + + RoundRect(hdc, 0, 0, (rc.right - rc.left), (rc.bottom - rc.top), h, h); + + SelectObject(hdc, hOldBrush); + SelectObject(hdc, hOldPen); + } + } + return TRUE; + } + case WM_PAINT: + { + RECT r, r2; + PAINTSTRUCT ps; + BeginPaint(hwnd, &ps); + HDC hdc = skin.bNeedLayerUpdate ? skin.hdc : ps.hdc; + + GetClientRect(hwnd, &r); + r2 = r; + HFONT hOldFont = (HFONT)GetCurrentObject(hdc,OBJ_FONT); + + // text background + SetBkMode(hdc, TRANSPARENT); + + BLENDFUNCTION blend; + blend.BlendOp = AC_SRC_OVER; + blend.BlendFlags = 0; + blend.SourceConstantAlpha = 255; + blend.AlphaFormat = AC_SRC_ALPHA; + + // avatar + if (!pwd->bIsTextTip&& opt.avatarLayout != PAV_NONE && pwd->iAvatarHeight) + { + RECT rcAvatar; + rcAvatar.top = opt.iOuterAvatarPadding; + + if (opt.avatarLayout == PAV_LEFT) + { + rcAvatar.left = r.left + opt.iOuterAvatarPadding; + rcAvatar.right = rcAvatar.left + pwd->iRealAvatarWidth; + r2.left += pwd->iRealAvatarWidth + (opt.iOuterAvatarPadding + opt.iInnerAvatarPadding - opt.iPadding); // padding re-added for text + } + else if (opt.avatarLayout == PAV_RIGHT) + { + rcAvatar.right = r.right - opt.iOuterAvatarPadding; + rcAvatar.left = rcAvatar.right - pwd->iRealAvatarWidth; + r2.right -= pwd->iRealAvatarWidth + (opt.iOuterAvatarPadding + opt.iInnerAvatarPadding - opt.iPadding); + } + + rcAvatar.bottom = rcAvatar.top + pwd->iRealAvatarHeight; + + AVATARCACHEENTRY *ace = 0; + if (pwd->hContact) + ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)pwd->hContact, 0); + else + ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETMYAVATAR, 0, (LPARAM)pwd->clcit.szProto); + + if (ace && ace->hbmPic && (ace->dwFlags & AVS_BITMAP_VALID) && !(ace->dwFlags & AVS_HIDEONCLIST)) + { + ResizeBitmap rb = {0}; + rb.size = sizeof(rb); + rb.max_width = pwd->iRealAvatarWidth; + rb.max_height = pwd->iRealAvatarHeight; + rb.fit = RESIZEBITMAP_STRETCH | RESIZEBITMAP_KEEP_PROPORTIONS; + rb.hBmp = ace->hbmPic; + HBITMAP hbmpAvatar = (HBITMAP)CallService(MS_IMG_RESIZE, (WPARAM)&rb, 0); + + if (hbmpAvatar) + { + HRGN hrgnAvatar = 0; + if (opt.bAvatarRound) + { + hrgnAvatar = CreateRoundRectRgn(rcAvatar.left, rcAvatar.top, rcAvatar.right + 1, rcAvatar.bottom + 1, 9, 9); + SelectClipRgn(hdc, hrgnAvatar); + } + + BITMAP bm; + GetObject(hbmpAvatar, sizeof(bm), &bm); + HDC hdcMem = CreateCompatibleDC(hdc); + SelectObject(hdcMem, hbmpAvatar); + + blend.SourceConstantAlpha = (BYTE)(opt.iAvatarOpacity / 100.0 * 255); + AlphaBlend(hdc, rcAvatar.left, rcAvatar.top, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, bm.bmWidth, bm.bmHeight, blend); + blend.SourceConstantAlpha = 255; + + if (opt.bAvatarBorder) + { + SaveAlpha(&rcAvatar); + HBRUSH hbrBorder = CreateSolidBrush(opt.colAvatarBorder); + if (opt.bAvatarRound) + FrameRgn(hdc, hrgnAvatar, hbrBorder, 1, 1); + else + FrameRect(hdc, &rcAvatar, hbrBorder); + + DeleteObject(hbrBorder); + RestoreAlpha(&rcAvatar, (BYTE)(opt.iAvatarOpacity / 100.0 * 255)); + } + + if (hrgnAvatar) + { + SelectClipRgn(hdc, 0); + DeleteObject(hrgnAvatar); + } + + if (hbmpAvatar != ace->hbmPic) + DeleteObject(hbmpAvatar); + + DeleteDC(hdcMem); + } + } + } + + RECT tr; + tr.left = r2.left + opt.iPadding + opt.iTitleIndent; + tr.right = r2.right - opt.iPadding; + tr.top = 0; + tr.bottom = opt.iPadding; + + if (!pwd->bIsTextTip&& opt.titleLayout != PTL_NOTITLE) + { + if (opt.titleLayout != PTL_NOICON) + { + // draw icons + int iIconX, iIconY; + iIconY = opt.iPadding + opt.iTextPadding; + + if (opt.titleLayout == PTL_RIGHTICON) + iIconX = r2.right - 16 - opt.iPadding; + else + iIconX = r2.left + opt.iPadding; + + for (int i = 0; i < EXICONS_COUNT; i++) + { + if (pwd->extraIcons[i].hIcon) + { + DrawIconExAlpha(hdc, iIconX, iIconY, pwd->extraIcons[i].hIcon, 16, 16, 0, NULL, DI_NORMAL, false); + iIconY += 20; + } + } + } + + // title text + if (hFontTitle) SelectObject(hdc, (HGDIOBJ)hFontTitle); + SetTextColor(hdc, opt.colTitle); + tr.top = opt.iPadding; + tr.bottom = tr.top + pwd->iTitleHeight - opt.iPadding; + UINT uTextFormat = DT_TOP | DT_LEFT | DT_WORDBREAK | DT_WORD_ELLIPSIS | DT_END_ELLIPSIS | DT_NOPREFIX; + DrawTextExt(hdc, pwd->swzTitle, -1, &tr, uTextFormat, NULL, pwd->spiTitle); + } + + // values + pwd->iTextHeight = 0; + bool bIconPainted, bUseRect = true; + int iRowHeight; + for (int i = 0; i < pwd->iRowCount; i++) + { + tr.top = tr.bottom; + bUseRect = (tr.top + opt.iTextPadding >= pwd->iAvatarHeight); + bIconPainted = false; + if (bUseRect) + { + if (pwd->rows[i].bLineAbove) + { + HPEN hOldPen = (HPEN)SelectObject(hdc, pwd->hpenDivider); + tr.top += opt.iTextPadding; + RECT rec; + SetRect(&rec, r.left + opt.iPadding + pwd->iIndent, tr.top, r.right - opt.iPadding, tr.top + 1); + SaveAlpha(&rec); + Rectangle(hdc, rec.left, rec.top, rec.right, rec.bottom ); + RestoreAlpha(&rec); + SelectObject(hdc, hOldPen); + } + + tr.left = r.left + opt.iPadding + pwd->iIndent; + if (pwd->rows[i].bValueNewline) + tr.right = r.right - opt.iPadding; + else + tr.right = r.left + opt.iPadding + pwd->iIndent + pwd->iLabelWidth; + } + else + { + if (pwd->rows[i].bLineAbove) + { + HPEN hOldPen = (HPEN)SelectObject(hdc, pwd->hpenDivider); + tr.top += opt.iTextPadding; + RECT rec; + SetRect(&rec, r2.left + opt.iPadding + pwd->iIndent, tr.top, r2.right - opt.iPadding, tr.top + 1); + SaveAlpha(&rec); + Rectangle(hdc, rec.left, rec.top, rec.right, rec.bottom ); + RestoreAlpha(&rec); + SelectObject(hdc, hOldPen); + } + + tr.left = r2.left + opt.iPadding + pwd->iIndent; + if (pwd->rows[i].bValueNewline) + tr.right = r2.right - opt.iPadding; + else + tr.right = r2.left + opt.iPadding + pwd->iIndent + pwd->iLabelWidth; + } + + if (pwd->rows[i].bValueNewline) + iRowHeight = pwd->rows[i].iLabelHeight; + else + iRowHeight = max(pwd->rows[i].iLabelHeight, pwd->rows[i].iValueHeight); + + if (pwd->rows[i].iLabelHeight) + { + tr.top += opt.iTextPadding; + tr.bottom = tr.top + iRowHeight; + + if (pwd->bIsTrayTip && pwd->rows[i].bIsTitle) + { + if (hFontTrayTitle) SelectObject(hdc, (HGDIOBJ)hFontTrayTitle); + SetTextColor(hdc, opt.colTrayTitle); + } + else + { + if (hFontLabels) SelectObject(hdc, (HGDIOBJ)hFontLabels); + SetTextColor(hdc, opt.colLabel); + } + + // status icon in tray tooltip + if (opt.titleLayout != PTL_NOICON && pwd->bIsTrayTip && pwd->rows[i].hIcon) + { + DrawIconExAlpha(hdc, opt.iPadding, tr.top + (pwd->rows[i].iLabelHeight - 16) / 2, pwd->rows[i].hIcon, 16, 16, 0, NULL, DI_NORMAL, false); + bIconPainted = true; + } + + DrawTextAlpha(hdc, pwd->rows[i].swzLabel, -1, &tr, opt.iLabelValign | ((opt.iLabelHalign == DT_RIGHT && !pwd->rows[i].bValueNewline) ? DT_RIGHT : DT_LEFT) | DT_END_ELLIPSIS | DT_SINGLELINE | DT_NOPREFIX); + if (pwd->rows[i].bValueNewline) + tr.top = tr.bottom; + } + else + { + tr.bottom = tr.top; + } + + if (pwd->rows[i].bValueNewline) + iRowHeight = pwd->rows[i].iValueHeight; + + if (hFontValues) SelectObject(hdc, (HGDIOBJ)hFontValues); + SetTextColor(hdc, opt.colValue); + if (bUseRect) + { + tr.left = r.left + opt.iPadding + pwd->iIndent; + if (!pwd->rows[i].bValueNewline) + tr.left += pwd->iLabelWidth + opt.iValueIndent; + + tr.right = r.right - opt.iPadding; + } + else + { + tr.left = r2.left + opt.iPadding + pwd->iIndent; + if (!pwd->rows[i].bValueNewline) + tr.left += pwd->iLabelWidth + opt.iValueIndent; + + tr.right = r2.right - opt.iPadding; + } + + if (pwd->rows[i].iValueHeight) + { + if (pwd->rows[i].bValueNewline || !pwd->rows[i].iLabelHeight) tr.top += opt.iTextPadding; + if (pwd->rows[i].iLabelHeight > pwd->rows[i].iValueHeight && pwd->bIsTextTip&& pwd->rows[i].bIsTitle) + tr.top = tr.bottom - pwd->rows[i].iValueHeight - 2; + else + tr.bottom = tr.top + iRowHeight; + + if (opt.titleLayout != PTL_NOICON && pwd->bIsTrayTip && pwd->rows[i].hIcon && !bIconPainted) + DrawIconExAlpha(hdc, opt.iPadding, tr.top + (pwd->rows[i].iValueHeight - 16) / 2, pwd->rows[i].hIcon, 16, 16, 0, NULL, DI_NORMAL, false); + + UINT uFormat = opt.iValueValign | opt.iValueHalign | DT_WORDBREAK | DT_WORD_ELLIPSIS | DT_END_ELLIPSIS | DT_NOPREFIX; + DrawTextExt(hdc, pwd->rows[i].swzValue, -1, &tr, uFormat, NULL, pwd->rows[i].spi); + } + } + + PremultipleChannels(); + + if (opt.showEffect == PSE_NONE) + { + if (skin.bNeedLayerUpdate) + { + POINT ptSrc = {0, 0}; + SIZE szTip = {r.right - r.left, r.bottom - r.top}; + blend.SourceConstantAlpha = pwd->iTrans; + MyUpdateLayeredWindow(hwnd, NULL, NULL, &szTip, skin.hdc, &ptSrc, 0xffffffff, &blend, LWA_ALPHA); + + if (opt.bAeroGlass && MyDwmEnableBlurBehindWindow) + { + DWM_BLURBEHIND bb = {0}; + bb.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION; + bb.fEnable = TRUE; + bb.hRgnBlur = CreateOpaqueRgn(25, true); + MyDwmEnableBlurBehindWindow(hwnd, &bb); + } + } + else if (MySetLayeredWindowAttributes) + { + MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), pwd->iTrans, LWA_ALPHA); + } + } + + SelectObject(hdc, hOldFont); + EndPaint(hwnd, &ps); + pwd->bIsPainted = true; + return 0; + } + case WM_HOTKEY: + { + if (LOWORD(lParam) == MOD_CONTROL && HIWORD(lParam) == 0x43) // CTRL+C + { + ICONINFO iconInfo; + + if (pwd->iRowCount == 0) + return 0; + + ShowWindow(hwnd, SW_HIDE); + HMENU hMenu = CreatePopupMenu(); + if (!hMenu) return 0; + + HICON hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_ITEM_ALL), IMAGE_ICON, 0, 0, LR_LOADTRANSPARENT); + if (!hIcon) + { + DestroyMenu(hMenu); + return 0; + } + + GetIconInfo(hIcon, &iconInfo); + HBITMAP hbmpAllItems = iconInfo.hbmColor; + DestroyIcon(hIcon); + + AppendMenu(hMenu, MF_STRING, COPYMENU_ALLITEMS_LABELS, LPGENT("Copy all items with labels")); + AppendMenu(hMenu, MF_STRING, COPYMENU_ALLITEMS, LPGENT("Copy all items")); + if (pwd->clcit.szProto || pwd->hContact) + AppendMenu(hMenu, MF_STRING, COPYMENU_AVATAR, LPGENT("Copy avatar")); + AppendMenu(hMenu, MF_SEPARATOR, 2000, 0); + TranslateMenu(hMenu); + + SetMenuItemBitmaps(hMenu, COPYMENU_ALLITEMS_LABELS, MF_BYCOMMAND, hbmpAllItems, hbmpAllItems); + SetMenuItemBitmaps(hMenu, COPYMENU_ALLITEMS, MF_BYCOMMAND, hbmpAllItems, hbmpAllItems); + SetMenuItemBitmaps(hMenu, COPYMENU_AVATAR, MF_BYCOMMAND, hbmpAllItems, hbmpAllItems); + + hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_ITEM), IMAGE_ICON, 0, 0, LR_LOADTRANSPARENT); + if (!hIcon) + { + DeleteObject(hbmpAllItems); + DestroyMenu(hMenu); + return 0; + } + + GetIconInfo(hIcon, &iconInfo); + HBITMAP hbmpItem = iconInfo.hbmColor; + DestroyIcon(hIcon); + + for (int i = 0; i < pwd->iRowCount; i++) + { + if (pwd->rows[i].swzValue) + { + TCHAR buff[128]; + int iLen = (int)_tcslen(pwd->rows[i].swzValue); + if (iLen) + { + if (iLen > MAX_VALUE_LEN) + { + _tcsncpy(buff, pwd->rows[i].swzValue, MAX_VALUE_LEN); + buff[MAX_VALUE_LEN] = 0; + _tcscat(buff, _T("...")); + } + else + { + _tcscpy(buff, pwd->rows[i].swzValue); + } + + AppendMenu(hMenu, MF_STRING, i + 1, buff); // first id = 1, because no select have id = 0 + SetMenuItemBitmaps(hMenu, i + 1, MF_BYCOMMAND, hbmpItem, hbmpItem); + } + else + { + AppendMenu(hMenu, MF_SEPARATOR, 0, 0); + } + } + } + + POINT pt; + GetCursorPos(&pt); + SetForegroundWindow(hwnd); + int iSelItem = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, 0); + DeleteObject(hbmpAllItems); + DeleteObject(hbmpItem); + DestroyMenu(hMenu); + + if (iSelItem == 0) + return 0; // no item was selected + + if (OpenClipboard(NULL)) + { + EmptyClipboard(); + if (iSelItem == COPYMENU_AVATAR) // copy avatar + { + AVATARCACHEENTRY *ace = 0; + if (pwd->hContact) ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)pwd->hContact, 0); + else ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETMYAVATAR, 0, (LPARAM)pwd->clcit.szProto); + if (ace && ace->hbmPic && (ace->dwFlags & AVS_BITMAP_VALID) && !(ace->dwFlags & AVS_HIDEONCLIST)) + { + HDC hdc = GetDC(hwnd); + HDC hdcSrc = CreateCompatibleDC(hdc); + HDC hdcDes = CreateCompatibleDC(hdc); + HBITMAP hbmAvr = CreateCompatibleBitmap(hdc, ace->bmWidth, ace->bmHeight); + SelectObject(hdcSrc, ace->hbmPic); + SelectObject(hdcDes, hbmAvr); + BitBlt(hdcDes, 0, 0, ace->bmWidth, ace->bmHeight, hdcSrc, 0, 0, SRCCOPY); + SetClipboardData(CF_BITMAP, hbmAvr); + ReleaseDC(hwnd, hdc); + DeleteDC(hdcSrc); + DeleteDC(hdcDes); + } + } + else // copy text + { + HGLOBAL hClipboardData = GlobalAlloc(GMEM_DDESHARE, 4096); + TCHAR *pchData = (TCHAR *)GlobalLock(hClipboardData); + pchData[0] = 0; + if (iSelItem == COPYMENU_ALLITEMS_LABELS) // copy all items with labels + { + for (int i = 0; i < pwd->iRowCount; i++) + { + if ((pwd->rows[i].swzLabel && pwd->rows[i].swzLabel[0]) || + (pwd->rows[i].swzValue && pwd->rows[i].swzValue[0])) + { + if (pwd->rows[i].swzLabel && pwd->rows[i].swzLabel[0]) + { + _tcscat(pchData, pwd->rows[i].swzLabel); + _tcscat(pchData, _T(" ")); + } + else + { + _tcscat(pchData, TranslateT(": ")); + } + + if (pwd->rows[i].swzValue && pwd->rows[i].swzValue[0]) + _tcscat(pchData, pwd->rows[i].swzValue); + else + _tcscat(pchData, TranslateT("")); + + _tcscat(pchData, _T("\r\n")); + } + } + } + else if (iSelItem == COPYMENU_ALLITEMS) // copy all items + { + for (int i = 0; i < pwd->iRowCount; i++) + { + if (pwd->rows[i].swzValue && pwd->rows[i].swzValue[0]) + { + _tcscat(pchData, pwd->rows[i].swzValue); + _tcscat(pchData, _T("\r\n")); + } + } + } + else // single row + { + _tcscpy(pchData, pwd->rows[iSelItem - 1].swzValue); + } + + GlobalUnlock(hClipboardData); + + SetClipboardData(CF_UNICODETEXT, hClipboardData); + + } + + CloseClipboard(); + } + } + break; + } + case PUM_FADEOUTWINDOW: + { + // kill timers + KillTimer(hwnd, ID_TIMER_ANIMATE); + KillTimer(hwnd, ID_TIMER_CHECKMOUSE); + KillTimer(hwnd, ID_TIMER_TRAYTIP); + + if (opt.showEffect != PSE_NONE) + { + if (skin.bNeedLayerUpdate) + { + POINT ptSrc = {0, 0}; + SIZE sz = {pwd->rcWindow.right - pwd->rcWindow.left, pwd->rcWindow.bottom - pwd->rcWindow.top}; + + BLENDFUNCTION blend; + blend.BlendOp = AC_SRC_OVER; + blend.BlendFlags = 0; + blend.SourceConstantAlpha = pwd->iTrans; + blend.AlphaFormat = AC_SRC_ALPHA; + + while (blend.SourceConstantAlpha != 0) + { + MyUpdateLayeredWindow(hwnd, NULL, NULL, &sz, skin.hdc, &ptSrc, 0xffffffff, &blend, LWA_ALPHA); + blend.SourceConstantAlpha = max(blend.SourceConstantAlpha - opt.iAnimateSpeed, 0); + Sleep(ANIM_ELAPSE); + } + } + else if (MySetLayeredWindowAttributes) + { + int iTrans = pwd->iTrans; + while (iTrans != 0) + { + MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), iTrans, LWA_ALPHA); + iTrans = max(iTrans - opt.iAnimateSpeed, 0); + Sleep(ANIM_ELAPSE); + } + } + } + break; + } + case WM_DESTROY: + { + ShowWindow(hwnd, SW_HIDE); + + // unregister hotkey + UnregisterHotKey(hwnd, pwd->iHotkeyId); + + DeleteObject(pwd->hpenBorder); + DeleteObject(pwd->hpenDivider); + + if (pwd->hrgnAeroGlass) + DeleteObject(pwd->hrgnAeroGlass); + + Smileys_FreeParse(pwd->spiTitle); + + int i; + for (i = 0; i < pwd->iRowCount; i++) + { + mir_free(pwd->rows[i].swzLabel); + mir_free(pwd->rows[i].swzValue); + Smileys_FreeParse(pwd->rows[i].spi); + } + + if (pwd->rows) + mir_free(pwd->rows); + pwd->rows = NULL; + + // destroy icons + for (i = 0; i < EXICONS_COUNT; i++) + { + if (pwd->extraIcons[i].bDestroy) + DestroyIcon(pwd->extraIcons[i].hIcon); + } + + if (pwd->clcit.swzText) + { + mir_free(pwd->clcit.swzText); + pwd->clcit.swzText = NULL; + } + + mir_free(pwd); + pwd = NULL; + + if (skin.colSavedBits) mir_free(skin.colSavedBits); + if (skin.hBitmap)DeleteObject(skin.hBitmap); + if (skin.hdc) DeleteDC(skin.hdc); + skin.colSavedBits = NULL; + skin.hBitmap = NULL; + skin.hdc = NULL; + + SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); + break; + } + case WM_TIMER: + { + if (wParam == ID_TIMER_ANIMATE) + { + pwd->iAnimStep++; + if (pwd->iAnimStep == ANIM_STEPS) + KillTimer(hwnd, ID_TIMER_ANIMATE); + + SendMessage(hwnd, PUM_UPDATERGN, 1, 0); + } + else if (wParam == ID_TIMER_CHECKMOUSE) + { + // workaround for tips that just won't go away + POINT pt; + GetCursorPos(&pt); + + if (abs(pt.x - pwd->ptCursorStartPos.x) > opt.iMouseTollerance + || abs(pt.y - pwd->ptCursorStartPos.y) > opt.iMouseTollerance) // mouse has moved beyond tollerance + { + PostMPMessage(MUM_DELETEPOPUP, 0, 0); + } + } + else if (wParam == ID_TIMER_TRAYTIP) + { + KillTimer(hwnd, ID_TIMER_TRAYTIP); + SendMessage(hwnd, PUM_EXPANDTRAYTIP, 0, 0); + } + + break; + } + case PUM_SETSTATUSTEXT: + { + if (pwd && (HANDLE)wParam == pwd->hContact) + { + DBWriteContactSettingTString(pwd->hContact, MODULE, "TempStatusMsg", (TCHAR *)lParam); + pwd->bIsPainted = false; + pwd->bNeedRefresh = true; + SendMessage(hwnd, PUM_REFRESH_VALUES, TRUE, 0); + InvalidateRect(hwnd, 0, TRUE); + } + + if (lParam) mir_free((void *)lParam); + return TRUE; + } + case PUM_SHOWXSTATUS: + { + if (pwd && (HANDLE)wParam == pwd->hContact) + { + // in case we have retrieve xstatus + pwd->bIsPainted = false; + SendMessage(hwnd, PUM_REFRESH_VALUES, TRUE, 0); + InvalidateRect(hwnd, 0, TRUE); + } + return TRUE; + } + case PUM_SETAVATAR: + { + if (pwd && (HANDLE)wParam == pwd->hContact) + { + pwd->bIsPainted = false; + SendMessage(hwnd, PUM_GETHEIGHT, 0, 0); + SendMessage(hwnd, PUM_CALCPOS, 0, 0); + InvalidateRect(hwnd, 0, TRUE); + } + return TRUE; + } + case PUM_EXPANDTRAYTIP: + { + pwd->bIsPainted = false; + if (skin.bNeedLayerUpdate) + { + RECT r = pwd->rcWindow; + POINT ptSrc = {0, 0}; + SIZE sz = {r.right - r.left, r.bottom - r.top}; + + BLENDFUNCTION blend; + blend.BlendOp = AC_SRC_OVER; + blend.BlendFlags = 0; + blend.SourceConstantAlpha = 0; + blend.AlphaFormat = AC_SRC_ALPHA; + + MyUpdateLayeredWindow(hwnd, NULL, NULL, &sz, skin.hdc, &ptSrc, 0xffffffff, &blend, LWA_ALPHA); + } + else if (MySetLayeredWindowAttributes) + { + MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), 0, LWA_ALPHA); + } + + SendMessage(hwnd, PUM_REFRESHTRAYTIP, 1, 0); + SendMessage(hwnd, PUM_GETHEIGHT, 0, 0); + SendMessage(hwnd, PUM_CALCPOS, 0, 0); + InvalidateRect(hwnd, 0, TRUE); + + if (opt.showEffect) + { + KillTimer(hwnd, ID_TIMER_ANIMATE); + SetTimer(hwnd, ID_TIMER_ANIMATE, ANIM_ELAPSE, 0); + pwd->iAnimStep = 0; + pwd->iCurrentTrans = 0; + } + + return TRUE; + } + case PUM_REFRESH_VALUES: + { + if (pwd && pwd->clcit.szProto == 0 && !pwd->bIsTextTip) + { + for (int i = 0; i < pwd->iRowCount; i++) + { + mir_free(pwd->rows[i].swzLabel); + mir_free(pwd->rows[i].swzValue); + Smileys_FreeParse(pwd->rows[i].spi); + } + + if (pwd->rows) + { + mir_free(pwd->rows); + pwd->rows = 0; + } + pwd->iRowCount = 0; + + DIListNode *node = opt.diList; + TCHAR buff_label[LABEL_LEN], buff[VALUE_LEN]; + while (node) + { + if (node->di.bIsVisible) + { + if (GetLabelText(pwd->hContact, node->di, buff_label, LABEL_LEN) && GetValueText(pwd->hContact, node->di, buff, VALUE_LEN)) + { + if (node->di.bLineAbove // we have a line above + && pwd->iRowCount > 0 // and we're not the first row + && pwd->rows[pwd->iRowCount - 1].bLineAbove // and above us there's a line above + && pwd->rows[pwd->iRowCount - 1].swzLabel[0] == 0 // with no label + && pwd->rows[pwd->iRowCount - 1].swzValue[0] == 0) // and no value + { + // overwrite item above + pwd->iRowCount--; + mir_free(pwd->rows[pwd->iRowCount].swzLabel); + mir_free(pwd->rows[pwd->iRowCount].swzValue); + Smileys_FreeParse(pwd->rows[pwd->iRowCount].spi); //prevent possible mem leak + } + else + { + pwd->rows = (RowData *)mir_realloc(pwd->rows, sizeof(RowData) * (pwd->iRowCount + 1)); + } + + char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)pwd->hContact, 0); + + pwd->rows[pwd->iRowCount].swzLabel = mir_tstrdup(buff_label); + pwd->rows[pwd->iRowCount].swzValue = mir_tstrdup(buff); + pwd->rows[pwd->iRowCount].spi = Smileys_PreParse(buff, (int)_tcslen(buff), szProto); + pwd->rows[pwd->iRowCount].bValueNewline = node->di.bValueNewline; + pwd->rows[pwd->iRowCount].bLineAbove = node->di.bLineAbove; + pwd->iRowCount++; + } + } + node = node->next; + } + + // if the last item is just a divider, remove it + if (pwd->iRowCount > 0 + && pwd->rows[pwd->iRowCount - 1].bLineAbove // and above us there's a line above + && pwd->rows[pwd->iRowCount - 1].swzLabel[0] == 0 // with no label + && pwd->rows[pwd->iRowCount - 1].swzValue[0] == 0) // and no value + { + pwd->iRowCount--; + mir_free(pwd->rows[pwd->iRowCount].swzLabel); + mir_free(pwd->rows[pwd->iRowCount].swzValue); + Smileys_FreeParse(pwd->rows[pwd->iRowCount].spi); //prevent possible mem leak + + if (pwd->iRowCount == 0) + { + mir_free(pwd->rows); + pwd->rows = 0; + } + } + + if (wParam == TRUE) + { + SendMessage(hwnd, PUM_GETHEIGHT, 0, 0); + SendMessage(hwnd, PUM_CALCPOS, 0, 0); + } + } + return TRUE; + } + case PUM_GETHEIGHT: + { + int *pHeight = (int *)wParam; + HDC hdc = GetDC(hwnd); + SIZE sz; + RECT rc, smr; + rc.top = rc.left = 0; + rc.right = opt.iWinWidth; + int iWidth = opt.iPadding; + int iWinAvatarHeight = 0; + bool bStatusMsg = false; + HFONT hOldFont = (HFONT)GetCurrentObject(hdc,OBJ_FONT); + + // avatar height + pwd->iAvatarHeight = 0; + if (!pwd->bIsTextTip && opt.avatarLayout != PAV_NONE && ServiceExists(MS_AV_GETAVATARBITMAP)) + { + AVATARCACHEENTRY *ace = 0; + if (pwd->hContact) ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)pwd->hContact, 0); + else ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETMYAVATAR, 0, (LPARAM)pwd->clcit.szProto); + + if (ace && (ace->dwFlags & AVS_BITMAP_VALID) && !(ace->dwFlags & AVS_HIDEONCLIST)) + { + if (opt.bOriginalAvatarSize && max(ace->bmWidth, ace->bmHeight) <= opt.iAvatarSize) + { + pwd->iRealAvatarHeight = ace->bmHeight; + pwd->iRealAvatarWidth = ace->bmWidth; + } + else + { + if (ace->bmHeight >= ace->bmWidth) + { + pwd->iRealAvatarHeight = opt.iAvatarSize; + pwd->iRealAvatarWidth = (int)(opt.iAvatarSize * (ace->bmWidth / (double)ace->bmHeight)); + } + else + { + pwd->iRealAvatarHeight = (int)(opt.iAvatarSize * (ace->bmHeight / (double)ace->bmWidth)); + pwd->iRealAvatarWidth = opt.iAvatarSize; + } + } + + pwd->iAvatarHeight = opt.iOuterAvatarPadding + opt.iInnerAvatarPadding + pwd->iRealAvatarHeight; + iWinAvatarHeight = 2 * opt.iOuterAvatarPadding + pwd->iRealAvatarHeight; + iWidth += pwd->iRealAvatarWidth + (opt.iOuterAvatarPadding + opt.iInnerAvatarPadding - opt.iPadding); + } + } + + // titlebar height + if (!pwd->bIsTextTip && pwd->swzTitle && opt.titleLayout != PTL_NOTITLE) + { + smr.top = smr.bottom = 0; + smr.left = rc.left + opt.iPadding + pwd->iIndent; + smr.right = rc.right; + + if (pwd->iRealAvatarWidth > 0) + smr.right -= pwd->iRealAvatarWidth + opt.iOuterAvatarPadding + opt.iInnerAvatarPadding; + else + smr.right -= opt.iPadding; + + if (hFontTitle) SelectObject(hdc, (HGDIOBJ)hFontTitle); + DrawTextExt(hdc, pwd->swzTitle, -1, &smr, DT_CALCRECT | DT_LEFT | DT_WORDBREAK | DT_END_ELLIPSIS | DT_NOPREFIX, NULL, pwd->spiTitle); + + iWidth += opt.iPadding + opt.iTitleIndent + smr.right; + pwd->iTitleHeight = opt.iPadding + smr.bottom; + } + else + { + pwd->iTitleHeight = opt.iPadding; + } + + // icon height + int i, iCount = 0; + if (pwd->hContact || pwd->clcit.szProto) + { + for(i = 0; i < EXICONS_COUNT; i++) + { + if ((INT_PTR)pwd->extraIcons[i].hIcon == CALLSERVICE_NOTFOUND) + pwd->extraIcons[i].hIcon = 0; + + if (pwd->extraIcons[i].hIcon) + iCount++; + } + } + pwd->iIconsHeight = (iCount * 20) + 20; + + // text height + pwd->iTextHeight = pwd->iLabelWidth = 0; + // iterate once to find max label width for items with label and value on same line, but don't consider width of labels on a new line + for (i = 0; i < pwd->iRowCount; i++) + { + if (pwd->rows[i].swzLabel && !pwd->rows[i].bValueNewline) + { + if (pwd->bIsTrayTip && pwd->rows[i].bIsTitle) + { + if (hFontTrayTitle) + SelectObject(hdc, (HGDIOBJ)hFontTrayTitle); + } + else + { + if (hFontLabels) + SelectObject(hdc, (HGDIOBJ)hFontLabels); + } + + GetTextExtentPoint32(hdc, pwd->rows[i].swzLabel, (int)_tcslen(pwd->rows[i].swzLabel), &sz); + if (sz.cx > pwd->iLabelWidth) + pwd->iLabelWidth = sz.cx; + } + } + + for (i = 0; i < pwd->iRowCount; i++) + { + if (pwd->bIsTrayTip && pwd->rows[i].bIsTitle) + { + if (hFontTrayTitle) + SelectObject(hdc, (HGDIOBJ)hFontTrayTitle); + } + else + { + if (hFontLabels) + SelectObject(hdc, (HGDIOBJ)hFontLabels); + } + + if (pwd->rows[i].swzLabel && pwd->rows[i].swzLabel[0]) + GetTextExtentPoint32(hdc, pwd->rows[i].swzLabel, (int)_tcslen(pwd->rows[i].swzLabel), &sz); + else + sz.cy = sz.cx = 0; + + // save so we don't have to recalculate + pwd->rows[i].iLabelHeight = sz.cy; + + smr.top = smr.bottom = 0; + smr.left = rc.left + opt.iPadding + pwd->iIndent; + smr.right = rc.right; + if (hFontValues) SelectObject(hdc, (HGDIOBJ)hFontValues); + if (pwd->iTitleHeight + pwd->iTextHeight + opt.iTextPadding < pwd->iAvatarHeight) + smr.right -= pwd->iRealAvatarWidth + opt.iOuterAvatarPadding + opt.iInnerAvatarPadding; + else + smr.right -= opt.iPadding; + + if (!pwd->rows[i].bValueNewline) + smr.right -= pwd->iLabelWidth + opt.iValueIndent; + + if (pwd->rows[i].swzValue && pwd->rows[i].swzValue[0]) + { + if (!bStatusMsg && opt.bGetNewStatusMsg) + { + if (!_tcscmp(pwd->rows[i].swzValue, _T("%sys:status_msg%"))) + bStatusMsg = true; + } + + DrawTextExt(hdc, pwd->rows[i].swzValue, -1, &smr, DT_CALCRECT | DT_LEFT | DT_WORDBREAK | DT_END_ELLIPSIS | DT_NOPREFIX, NULL, pwd->rows[i].spi); + } + else + { + smr.left = smr.right = 0; + } + + // save so we don't have to recalculate + pwd->rows[i].iValueHeight = smr.bottom; + + pwd->rows[i].iTotalHeight = (pwd->rows[i].bLineAbove ? opt.iTextPadding : 0); + if (pwd->rows[i].bValueNewline) + { + if (sz.cy) pwd->rows[i].iTotalHeight += sz.cy + opt.iTextPadding; + if (smr.bottom) pwd->rows[i].iTotalHeight += smr.bottom + opt.iTextPadding; + } + else + { + int maxheight = max(sz.cy, smr.bottom); + if (maxheight) pwd->rows[i].iTotalHeight += maxheight + opt.iTextPadding; + } + + // only consider this item's width, and include it's height, if it doesn't make the window too big + if (max(pwd->iTitleHeight + pwd->iTextHeight + opt.iPadding + pwd->rows[i].iTotalHeight, pwd->iAvatarHeight) <= opt.iWinMaxHeight || pwd->bIsTrayTip) + { + if (iWidth < opt.iWinWidth) + { + int wid = opt.iPadding + pwd->iIndent + (pwd->rows[i].bValueNewline ? max(sz.cx, smr.right - smr.left) : pwd->iLabelWidth + opt.iValueIndent + (smr.right - smr.left)); + if (pwd->iTitleHeight + pwd->iTextHeight + opt.iTextPadding < pwd->iAvatarHeight) + iWidth = max(iWidth, wid + pwd->iRealAvatarWidth + opt.iOuterAvatarPadding + opt.iInnerAvatarPadding); + else + iWidth = max(iWidth, wid + opt.iPadding); + } + + pwd->iTextHeight += pwd->rows[i].iTotalHeight; + } + } + + SelectObject(hdc, hOldFont); + ReleaseDC(hwnd, hdc); + + int iHeight = max(pwd->iTitleHeight + pwd->iTextHeight + opt.iPadding, iWinAvatarHeight); + iHeight = max(pwd->iIconsHeight, iHeight); + if (bStatusMsg) iHeight += 50; + + if (iHeight < opt.iMinHeight) iHeight = opt.iMinHeight; + // ignore minwidth for text tips + if (!pwd->bIsTextTip && iWidth < opt.iMinWidth) iWidth = opt.iMinWidth; + + // ignore maxheight for tray tip + if (!pwd->bIsTrayTip && iHeight > opt.iWinMaxHeight) iHeight = opt.iWinMaxHeight; + if (iWidth > opt.iWinWidth) iWidth = opt.iWinWidth; + + CreateSkinBitmap(iWidth, iHeight, pwd->bIsTextTip && !pwd->bIsTrayTip); + + GetWindowRect(hwnd, &rc); + if (rc.right - rc.left != iWidth || rc.bottom - rc.top != iHeight) + { + SetWindowPos(hwnd, 0, 0, 0, iWidth, iHeight, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); + GetWindowRect(hwnd, &pwd->rcWindow); + SendMessage(hwnd, PUM_UPDATERGN, 0, 0); + InvalidateRect(hwnd, 0, TRUE); + } + + if (pHeight) + *pHeight = iHeight; + + return TRUE; + } + case PUM_UPDATERGN: + { + HRGN hRgn; + RECT r = pwd->rcWindow; + int v, h; + int w = 11; + + r.right -= r.left; + r.left = 0; + r.bottom -= r.top; + r.top = 0; + + if (opt.showEffect == PSE_FADE && wParam == 1) + { + if (skin.bNeedLayerUpdate) + { + POINT ptSrc = {0, 0}; + SIZE sz = {r.right - r.left, r.bottom - r.top}; + + BLENDFUNCTION blend; + blend.BlendOp = AC_SRC_OVER; + blend.BlendFlags = 0; + blend.SourceConstantAlpha = pwd->iCurrentTrans; + blend.AlphaFormat = AC_SRC_ALPHA; + + pwd->iCurrentTrans += opt.iAnimateSpeed; + if (pwd->iCurrentTrans > pwd->iTrans) + { + pwd->iCurrentTrans = pwd->iTrans; + pwd->iAnimStep = ANIM_STEPS; + } + + MyUpdateLayeredWindow(hwnd, NULL, NULL, &sz, skin.hdc, &ptSrc, 0xffffffff, &blend, LWA_ALPHA); + + } + else if (MySetLayeredWindowAttributes) + { + pwd->iCurrentTrans += opt.iAnimateSpeed; + if (pwd->iCurrentTrans > pwd->iTrans) + { + pwd->iCurrentTrans = pwd->iTrans; + pwd->iAnimStep = ANIM_STEPS; + } + + MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), pwd->iCurrentTrans, LWA_ALPHA); + } + + } + else if (opt.showEffect == PSE_ANIMATE && pwd->bIsPainted) + { + if (pwd->iAnimStep <= (ANIM_STEPS / opt.iAnimateSpeed)) + { + float frac = 1.0f - pwd->iAnimStep / ((float)ANIM_STEPS / opt.iAnimateSpeed); + int wi = r.right, hi = r.bottom; + + r.left += (int)(wi / 2.0f * frac + 0.5f); + r.right -= (int)(wi / 2.0f * frac + 0.5f); + r.top += (int)(hi / 2.0f * frac + 0.5f); + r.bottom -= (int)(hi / 2.0f * frac + 0.5f); + } + else + { + pwd->iAnimStep = ANIM_STEPS; + } + + if (skin.bNeedLayerUpdate) + { + RECT r2 = pwd->rcWindow; + POINT ptPos = {r.left + r2.left, r.top + r2.top}; + POINT ptSrc = {r.left, r.top}; + + SIZE sz = {r.right - r.left, r.bottom - r.top}; + + BLENDFUNCTION blend; + blend.BlendOp = AC_SRC_OVER; + blend.BlendFlags = 0; + blend.SourceConstantAlpha = pwd->iTrans; + blend.AlphaFormat = AC_SRC_ALPHA; + + MyUpdateLayeredWindow(hwnd, NULL, &ptPos, &sz, skin.hdc, &ptSrc, 0xffffffff, &blend, LWA_ALPHA); + } + } + + if (!skin.bNeedLayerUpdate) + { + // round corners + if (opt.bRound) + { + h = (r.right-r.left)>(w*2) ? w : (r.right-r.left); + v = (r.bottom-r.top)>(w*2) ? w : (r.bottom-r.top); + h = (hiAnimStep == 1) + { + if (MySetLayeredWindowAttributes) + MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), pwd->iTrans, LWA_ALPHA); + } + + } + else + { + // aero glass (vista+) + if (opt.bAeroGlass && MyDwmEnableBlurBehindWindow && pwd->iAnimStep > 5) + { + if (pwd->hrgnAeroGlass) + { + DeleteObject(pwd->hrgnAeroGlass); + pwd->hrgnAeroGlass = 0; + } + + pwd->hrgnAeroGlass = CreateOpaqueRgn(25, true); + + if (pwd->hrgnAeroGlass) + { + DWM_BLURBEHIND bb = {0}; + bb.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION; + bb.fEnable = TRUE; + bb.hRgnBlur = pwd->hrgnAeroGlass; + MyDwmEnableBlurBehindWindow(hwnd, &bb); + } + } + } + + return TRUE; + } + case PUM_CALCPOS: + { + RECT rcWork, rc; + + SystemParametersInfo(SPI_GETWORKAREA, 0, &rcWork, FALSE); + if (MyMonitorFromPoint) + { + HMONITOR hMon = MyMonitorFromPoint(pwd->clcit.ptCursor, MONITOR_DEFAULTTONEAREST); + MONITORINFO mi; + mi.cbSize = sizeof(mi); + if (MyGetMonitorInfo(hMon, &mi)) + rcWork = mi.rcWork; + } + + GetWindowRect(hwnd, &rc); + + int x = 0, y = 0, iWidth = (rc.right - rc.left), iHeight = (rc.bottom - rc.top); + + switch(opt.pos) + { + case PP_BOTTOMRIGHT: + x = pwd->clcit.ptCursor.x + GetSystemMetrics(SM_CXSMICON); // cursor size is too large - use small icon size + y = pwd->clcit.ptCursor.y + GetSystemMetrics(SM_CYSMICON); + break; + case PP_BOTTOMLEFT: + x = pwd->clcit.ptCursor.x - iWidth - GetSystemMetrics(SM_CXSMICON); + y = pwd->clcit.ptCursor.y + GetSystemMetrics(SM_CYSMICON); + break; + case PP_TOPRIGHT: + x = pwd->clcit.ptCursor.x + GetSystemMetrics(SM_CXSMICON); + y = pwd->clcit.ptCursor.y - iHeight - GetSystemMetrics(SM_CYSMICON); + break; + case PP_TOPLEFT: + x = pwd->clcit.ptCursor.x - iWidth - GetSystemMetrics(SM_CXSMICON); + y = pwd->clcit.ptCursor.y - iHeight - GetSystemMetrics(SM_CYSMICON); + break; + } + + + if (x + iWidth + 8 > rcWork.right) + x = rcWork.right - iWidth - 8; + if (x - 8 < rcWork.left) + x = rcWork.left + 8; + + if (pwd->bAllowReposition || !pwd->bNeedRefresh) + { + if (y + iHeight > rcWork.bottom) + { + y = pwd->clcit.ptCursor.y - iHeight - 8; + pwd->bAllowReposition = true; + } + + if (y - 8 < rcWork.top) + { + y = pwd->clcit.ptCursor.y + GetSystemMetrics(SM_CYSMICON); + pwd->bAllowReposition = true; + } + } + + SetWindowPos(hwnd, 0, x, y, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER); + GetWindowRect(hwnd, &pwd->rcWindow); + return TRUE; + } + case PUM_REFRESHTRAYTIP: + { + int i, j; + for (i = 0; i < pwd->iRowCount; i++) + { + mir_free(pwd->rows[i].swzLabel); + mir_free(pwd->rows[i].swzValue); + Smileys_FreeParse(pwd->rows[i].spi); + } + + if (pwd->rows) + { + mir_free(pwd->rows); + pwd->rows = NULL; + } + + pwd->iRowCount = 0; + + DWORD dwItems = (wParam == 0) ? opt.iFirstItems : opt.iSecondItems; + bool bFirstItem = true; + TCHAR buff[64]; + + int oldOrder = -1, iProtoCount = 0; + PROTOACCOUNT **accs; + ProtoEnumAccounts(&iProtoCount, &accs); + + for (j = 0; j < iProtoCount; j++) + { + PROTOACCOUNT *pa = NULL; + for (i = 0; i < iProtoCount; i++) + { + + if (accs[i]->iOrder > oldOrder && (pa == NULL || accs[i]->iOrder < pa->iOrder)) + pa = accs[i]; + } + + oldOrder = pa->iOrder; + + WORD wStatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0); + if (opt.bHideOffline && wStatus == ID_STATUS_OFFLINE) + continue; + + if (!IsAccountEnabled(pa) || !IsTrayProto(pa->tszAccountName, (BOOL)wParam)) + continue; + + if (dwItems & TRAYTIP_NUMCONTACTS) + { + int iCount = 0, iCountOnline = 0; + HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + while (hContact) + { + char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + if (proto && !strcmp(proto, pa->szModuleName)) + { + if (DBGetContactSettingWord(hContact, proto, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) + iCountOnline++; + iCount++; + } + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + } + mir_sntprintf(buff, 64, _T("(%d/%d)"), iCountOnline, iCount); + } + else + { + _tcscpy(buff, _T("")); + } + + TCHAR swzProto[256]; + _tcscpy(swzProto, pa->tszAccountName); + if (dwItems & TRAYTIP_LOCKSTATUS) + { + if (CallService(MS_PROTO_ISACCOUNTLOCKED,0,(LPARAM)pa->szModuleName)) + mir_sntprintf(swzProto, SIZEOF(swzProto), TranslateT("%s (locked)"), pa->tszAccountName); + } + + AddRow(pwd, swzProto, buff, NULL, false, false, !bFirstItem, true, LoadSkinnedProtoIcon(pa->szModuleName, wStatus)); + bFirstItem = false; + + if (dwItems & TRAYTIP_LOGON) + { + if (TimestampToTimeDifference(NULL, pa->szModuleName, "LogonTS", buff, 59)) + { + _tcscat(buff, TranslateT(" ago")); + AddRow(pwd, TranslateT("Log on:"), buff, NULL, false, false, false); + } + + if (TimestampToTimeDifference(NULL, pwd->clcit.szProto, "LogoffTS", buff, 59)) + { + _tcscat(buff, TranslateT(" ago")); + AddRow(pwd, TranslateT("Log off:"), buff, NULL, false, false, false); + } + } + + if (dwItems & TRAYTIP_UNREAD_EMAILS && ProtoServiceExists(pa->szModuleName, "/GetUnreadEmailCount")) + { + int iCount = (int)CallProtoService(pa->szModuleName, "/GetUnreadEmailCount", 0, 0); + if (iCount > 0) + { + _itot(iCount, buff, 10); + AddRow(pwd, TranslateT("Unread emails:"), buff, NULL, false, false, false); + } + } + + if (dwItems & TRAYTIP_STATUS) + { + TCHAR *swzText = (TCHAR *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, wStatus, GSMDF_TCHAR); + if (swzText) + { + AddRow(pwd, TranslateT("Status:"), swzText, NULL, false, false, false); + } + } + + if (wStatus >= ID_STATUS_ONLINE && wStatus <= ID_STATUS_OUTTOLUNCH) + { + if (dwItems & TRAYTIP_STATUS_MSG) + { + TCHAR *swzText = GetProtoStatusMessage(pa->szModuleName, wStatus); + if (swzText) + { + StripBBCodesInPlace(swzText); + AddRow(pwd, TranslateT("Status message:"), swzText, pa->szModuleName, true, true, false); + mir_free(swzText); + } + } + + if (dwItems & TRAYTIP_EXTRA_STATUS) + { + // jabber mood or icq xstatus + TCHAR *swzAdvTitle = GetJabberAdvStatusText(pa->szModuleName, "mood", "title"); + if (swzAdvTitle) + { + StripBBCodesInPlace(swzAdvTitle); + AddRow(pwd, TranslateT("Mood:"), swzAdvTitle, pa->szModuleName, true, false, false); + mir_free(swzAdvTitle); + + TCHAR *swzAdvText = GetJabberAdvStatusText(pa->szModuleName, "mood", "text"); + if (swzAdvText) + { + StripBBCodesInPlace(swzAdvText); + AddRow(pwd, _T(""), swzAdvText, pa->szModuleName, true, true, false); + mir_free(swzAdvText); + } + } + else + { + if (DBGetContactSettingByte(0, pa->szModuleName, "XStatusId", 0)) + { + // xstatus title + swzAdvTitle = GetProtoExtraStatusTitle(pa->szModuleName); + if (swzAdvTitle) + { + StripBBCodesInPlace(swzAdvTitle); + AddRow(pwd, TranslateT("XStatus:"), swzAdvTitle, pa->szModuleName, true, false, false); + mir_free(swzAdvTitle); + } + + // xstatus message + TCHAR *swzAdvText = GetProtoExtraStatusMessage(pa->szModuleName); + if (swzAdvText) + { + StripBBCodesInPlace(swzAdvText); + AddRow(pwd, _T(""), swzAdvText, pa->szModuleName, true, true, false); + mir_free(swzAdvText); + } + } + } + + TCHAR *swzActTitle = GetJabberAdvStatusText(pa->szModuleName, "activity", "title"); + if (swzActTitle) + { + StripBBCodesInPlace(swzActTitle); + AddRow(pwd, TranslateT("Activity:"), swzActTitle, pa->szModuleName, true, false, false); + mir_free(swzActTitle); + } + + TCHAR *swzActText = GetJabberAdvStatusText(pa->szModuleName, "activity", "text"); + if (swzActText) + { + StripBBCodesInPlace(swzActText); + AddRow(pwd, _T(""), swzActText, pa->szModuleName, true, true, false); + mir_free(swzActText); + } + } + + if (dwItems & TRAYTIP_LISTENINGTO) + { + TCHAR *swzListening = GetListeningTo(pa->szModuleName); + if (swzListening) + { + StripBBCodesInPlace(swzListening); + AddRow(pwd, TranslateT("Listening to:"), swzListening, NULL, false, true, false); + mir_free(swzListening); + } + } + } + } + + if (dwItems & TRAYTIP_FAVCONTACTS) + { + if (DBGetContactSettingDword(0, MODULE, "FavouriteContactsCount", 0)) + { + TCHAR swzName[256]; + TCHAR swzStatus[256]; + bool bTitlePainted = false; + int iCount = 0, iCountOnline = 0; + + HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + while (hContact) + { + if (DBGetContactSettingByte(hContact, MODULE, "FavouriteContact", 0)) + { + char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + if (proto) + { + WORD wStatus = DBGetContactSettingWord(hContact, proto, "Status", ID_STATUS_OFFLINE); + WordToStatusDesc(hContact, proto, "Status", swzStatus, 256); + + if (wStatus != ID_STATUS_OFFLINE) + iCountOnline++; + + iCount++; + + if (!(opt.iFavoriteContFlags & FAVCONT_HIDE_OFFLINE && wStatus == ID_STATUS_OFFLINE)) + { + if (!bTitlePainted) + { + AddRow(pwd, TranslateT("Fav. contacts"), NULL, NULL, false, false, !bFirstItem, true, NULL); + bFirstItem = false; + bTitlePainted = true; + } + + TCHAR *swzNick = (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR); + if (opt.iFavoriteContFlags & FAVCONT_APPEND_PROTO) + { + TCHAR *swzProto = a2t(proto); + mir_sntprintf(swzName, 256, _T("%s (%s)"), swzNick, swzProto); + mir_free(swzProto); + } + else + { + _tcscpy(swzName, swzNick); + } + + AddRow(pwd, swzName, swzStatus, NULL, false, false, false); + } + } + } + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0); + } + + int index = pwd->iRowCount - 1; + if (opt.iFavoriteContFlags & FAVCONT_HIDE_OFFLINE) + index -= iCountOnline; + else + index -= iCount; + + if (index >= 0 && (dwItems & TRAYTIP_NUMCONTACTS) && !((opt.iFavoriteContFlags & FAVCONT_HIDE_OFFLINE) && iCountOnline == 0)) + { + mir_sntprintf(buff, 64, _T("(%d/%d)"), iCountOnline, iCount); + pwd->rows[index].swzValue = mir_tstrdup(buff); + } + } + } + + if (dwItems & TRAYTIP_MIRANDA_UPTIME) + { + if (TimestampToTimeDifference(NULL, MODULE, "MirandaStartTS", buff, 64)) + { + AddRow(pwd, TranslateT("Other"), _T(""), NULL, false, false, !bFirstItem, true, NULL); + AddRow(pwd, TranslateT("Miranda uptime:"), buff, NULL, false, false, false); + } + } + + if (dwItems & TRAYTIP_CLIST_EVENT && pwd->clcit.swzText) + { + TCHAR *pchBr = _tcschr(pwd->clcit.swzText, '\n'); + TCHAR *pchBold = _tcsstr(pwd->clcit.swzText, _T("")); + + if (!pchBold || pchBold != pwd->clcit.swzText) + { + TCHAR swzText[256]; + _tcscpy(swzText, pwd->clcit.swzText); + if (pchBr) swzText[pchBr - pwd->clcit.swzText] = 0; + AddRow(pwd, swzText, _T(""), NULL, false, true, false, true, LoadSkinnedIcon(SKINICON_OTHER_FILLEDBLOB)); + } + } + + return TRUE; + } + } + + return DefWindowProc(hwnd, uMsg, wParam, lParam); +} \ No newline at end of file diff --git a/plugins/TipperYM/src/popwin.h b/plugins/TipperYM/src/popwin.h new file mode 100644 index 0000000000..b7ba674b08 --- /dev/null +++ b/plugins/TipperYM/src/popwin.h @@ -0,0 +1,140 @@ +/* +Copyright (C) 2006-2007 Scott Ellis +Copyright (C) 2007-2011 Jan Holub + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#ifndef _POPWIN_INC +#define _POPWIN_INC + +#include "mir_smileys.h" + +#define POP_WIN_CLASS _T(MODULE) _T("MimTTClass") + +#define PUM_GETHEIGHT (WM_USER + 0x020) +#define PUM_CALCPOS (WM_USER + 0x021) +#define PUM_SETSTATUSTEXT (WM_USER + 0x022) +#define PUM_UPDATERGN (WM_USER + 0x023) +#define PUM_SETAVATAR (WM_USER + 0x024) +#define PUM_REFRESH_VALUES (WM_USER + 0x025) +#define PUM_SHOWXSTATUS (WM_USER + 0x026) +#define PUM_EXPANDTRAYTIP (WM_USER + 0x027) +#define PUM_REFRESHTRAYTIP (WM_USER + 0x028) +#define PUM_FADEOUTWINDOW (WM_USER + 0x029) + +// extra icons +#define EXICONS_COUNT 6 +#define CTRY_ERROR 42 //Flags - some strange value ??? +#define GEN_FEMALE 70 +#define GEN_MALE 77 + +// copy menu +#define COPYMENU_ALLITEMS_LABELS 1000 +#define COPYMENU_ALLITEMS 1001 +#define COPYMENU_AVATAR 1002 + +// tray tooltip items +#define TRAYTIP_ITEMS_COUNT 11 + +#define TRAYTIP_NUMCONTACTS 1 +#define TRAYTIP_LOCKSTATUS 2 +#define TRAYTIP_LOGON 4 +#define TRAYTIP_UNREAD_EMAILS 8 +#define TRAYTIP_STATUS 16 +#define TRAYTIP_STATUS_MSG 32 +#define TRAYTIP_EXTRA_STATUS 64 +#define TRAYTIP_LISTENINGTO 128 +#define TRAYTIP_FAVCONTACTS 256 +#define TRAYTIP_MIRANDA_UPTIME 512 +#define TRAYTIP_CLIST_EVENT 1024 + +// favorite contacts options +#define FAVCONT_HIDE_OFFLINE 1 +#define FAVCONT_APPEND_PROTO 2 + +// other +#define TITLE_TEXT_LEN 512 +#define MAX_VALUE_LEN 64 + +#define ANIM_ELAPSE 10 +#define ANIM_STEPS 255 +#define CHECKMOUSE_ELAPSE 250 + +#define ID_TIMER_ANIMATE 0x0100 +#define ID_TIMER_CHECKMOUSE 0x0101 +#define ID_TIMER_TRAYTIP 0x0102 + + +typedef struct { + HICON hIcon; + bool bDestroy; +} ExtraIcons; + +typedef struct { + int cbSize; + int isTreeFocused; //so the plugin can provide an option + int isGroup; //0 if it's a contact, 1 if it's a group + HANDLE hItem; //handle to group or contact + POINT ptCursor; + RECT rcItem; + TCHAR *swzText; // for tips with specific text + char *szProto; // for proto tips +} CLCINFOTIPEX; + +typedef struct { + TCHAR *swzLabel, *swzValue; + HICON hIcon; + bool bValueNewline; + bool bLineAbove; + bool bIsTitle; + int iLabelHeight, iValueHeight, iTotalHeight; + SMILEYPARSEINFO spi; +} RowData; + +typedef struct { + HPEN hpenBorder, hpenDivider; + int iTitleHeight, iAvatarHeight, iIconsHeight, iTextHeight, iLabelWidth; + int iRealAvatarWidth, iRealAvatarHeight; + HANDLE hContact; + int iIconIndex; + CLCINFOTIPEX clcit; + TCHAR swzTitle[TITLE_TEXT_LEN]; + SMILEYPARSEINFO spiTitle; + RowData *rows; + int iRowCount; + int iAnimStep; + int iCurrentTrans; + bool bIsTextTip, bIsTrayTip; + int iIndent, iSidebarWidth; + POINT ptCursorStartPos; // work around bugs with hiding tips (timer check mouse position) + ExtraIcons extraIcons[EXICONS_COUNT]; + bool bIsIconVisible[EXICONS_COUNT]; + int iTrans; + int iHotkeyId; + bool bIsPainted; + bool bNeedRefresh; + bool bAllowReposition; + RECT rcWindow; + HRGN hrgnAeroGlass; +} PopupWindowData; + + +LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); +extern int IsTrayProto(const TCHAR *swzProto, BOOL bExtendedTip); + + +#endif diff --git a/plugins/TipperYM/src/preset_items.cpp b/plugins/TipperYM/src/preset_items.cpp new file mode 100644 index 0000000000..629a747a28 --- /dev/null +++ b/plugins/TipperYM/src/preset_items.cpp @@ -0,0 +1,131 @@ +/* +Copyright (C) 2006-2007 Scott Ellis +Copyright (C) 2007-2011 Jan Holub + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#include "common.h" +#include "preset_items.h" + +PRESETITEM presetItems[] = +{ + "birth", LPGENT("Birthday"), LPGENT("Birthday:"), _T("%birthday_date% (%birthday_age%) @ Next: %birthday_next%"), "birthdate", "birthage", "birthnext", + "client", LPGENT("Client"), LPGENT("Client:"), _T("%raw:/MirVer%"), 0, 0, 0, + "email", LPGENT("Email"), LPGENT("Email:"), _T("%raw:/e-mail%"), 0, 0, 0, + "gender", LPGENT("Gender"), LPGENT("Gender:"), _T("%gender%"), 0, 0, 0, + "homepage", LPGENT("Homepage"), LPGENT("Homepage:"), _T("%raw:/Homepage%"), 0, 0, 0, + "id", LPGENT("Identifier"), LPGENT("%sys:uidname|UID^!MetaContacts%:"), _T("%sys:uid%"), 0, 0, 0, + "idle", LPGENT("Idle"), LPGENT("Idle:"), _T("%idle% (%idle_diff% ago)"), "idle", "idlediff", 0, + "ip", LPGENT("IP"), LPGENT("IP:"), _T("%ip%"), "ip", 0, 0, + "ipint", LPGENT("IP internal"), LPGENT("IP internal:"), _T("%ip_internal%"), "ipint", 0, 0, + "lastmsg", LPGENT("Last message"), LPGENT("Last message: (%sys:last_msg_reltime% ago)"), _T("%sys:last_msg%"), 0, 0, 0, + "listening", LPGENT("Listening to"), LPGENT("Listening to:"), _T("%raw:/ListeningTo%"), 0, 0, 0, + "name", LPGENT("Name"), LPGENT("Name:"), _T("%raw:/FirstName|% %raw:/LastName%"), 0, 0, 0, + "received", LPGENT("Number of received messages"), LPGENT("Number of msg [IN]:"), _T("%sys:msg_count_in%"), 0, 0, 0, + "sended", LPGENT("Number of sended messages"), LPGENT("Number of msg [OUT]:"), _T("%sys:msg_count_out%"), 0, 0, 0, + "status", LPGENT("Status"), LPGENT("Status:"), _T("%Status%"), "status", 0, 0, + "statusmsg", LPGENT("Status message"), LPGENT("Status message:"), _T("%sys:status_msg%"), 0, 0, 0, + "time", LPGENT("Contact time"), LPGENT("Time:"), _T("%sys:time%"), 0, 0, 0, + "xtitle", LPGENT("XStatus title"), LPGENT("XStatus title:"), _T("%xsname%"), "xname", 0, 0, + "xtext", LPGENT("XStatus text"), LPGENT("XStatus text:"), _T("%raw:/XStatusMsg%"), 0, 0, 0, + "acttitle", LPGENT("[jabber.dll] Activity title"), LPGENT("Activity title:"), _T("%raw:AdvStatus/?dbsetting(%subject%,Protocol,p)/activity/title%"), 0, 0, 0, + "acttext", LPGENT("[jabber.dll] Activity text"), LPGENT("Activity text:"), _T("%raw:AdvStatus/?dbsetting(%subject%,Protocol,p)/activity/text%"), 0, 0, 0, + "logon", LPGENT("[menuex.dll] Logon time"), LPGENT("Logon time:"), _T("%logon_date% @ %logon_time% (%logon_ago%)"), "logondate", "logontime", "logonago", + "logoff", LPGENT("[menuex.dll] Logoff time"), LPGENT("Logoff time:"), _T("%logoff_date% @ %logoff_time% (%logoff_ago%)"), "logoffdate", "logofftime", "logoffago", + "lastseentime", LPGENT("[seenplugin.dll] Last seen time"), LPGENT("Last seen time:"), _T("%lastseen_date% @ %lastseen_time%"), "lsdate", "lstime", 0, + "lastseenstatus", LPGENT("[seenplugin.dll] Last seen status"), LPGENT("Last seen status:"), _T("%lastseen_status% (%lastseen_ago% ago)"), "lsstatus", "lsago", 0, + "cond", LPGENT("[weather.dll] Condition"), LPGENT("Condition:"), _T("%raw:Current/Condition%"), 0, 0, 0, + "humidity", LPGENT("[weather.dll] Humidity"), LPGENT("Humidity:"), _T("%raw:Current/Humidity%"), 0, 0, 0, + "minmaxtemp", LPGENT("[weather.dll] Max/Min temperature"), LPGENT("Max/Min:"), _T("%raw:Current/High%/%raw:Current/Low%"), 0, 0, 0, + "moon", LPGENT("[weather.dll] Moon"), LPGENT("Moon:"), _T("%raw:Current/Moon%"), 0, 0, 0, + "pressure", LPGENT("[weather.dll] Pressure"), LPGENT("Pressure:"), _T("%raw:Current/Pressure% (%raw:Current/Pressure Tendency%)"), 0, 0, 0, + "sunrise", LPGENT("[weather.dll] Sunrise"), LPGENT("Sunrise:"), _T("%raw:Current/Sunrise%"), 0, 0, 0, + "sunset", LPGENT("[weather.dll] Sunset"), LPGENT("Sunset:"), _T("%raw:Current/Sunset%"), 0, 0, 0, + "temp", LPGENT("[weather.dll] Temperature"), LPGENT("Temperature:"), _T("%raw:Current/Temperature%"), 0, 0, 0, + "uptime", LPGENT("[weather.dll] Update time"), LPGENT("Update time:"), _T("%raw:Current/Update%"), 0, 0, 0, + "uvindex", LPGENT("[weather.dll] UV Index"), LPGENT("UV Index:"), _T("%raw:Current/UV% - %raw:Current/UVI%"), 0, 0, 0, + "vis", LPGENT("[weather.dll] Visibility"), LPGENT("Visibility:"), _T("%raw:Current/Visibility%"), 0, 0, 0, + "wind", LPGENT("[weather.dll] Wind"), LPGENT("Wind:"), _T("%raw:Current/Wind Direction% (%raw:Current/Wind Direction DEG%)/%raw:Current/Wind Speed%"), 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0 +}; + +PRESETSUBST presetSubsts[] = +{ + "gender", _T("gender"), DVT_PROTODB, NULL, "Gender", 5, + "status", _T("Status"), DVT_PROTODB, NULL, "Status", 1, + "ip", _T("ip"), DVT_PROTODB, NULL, "IP", 7, + "ipint", _T("ip_internal"), DVT_PROTODB, NULL, "RealIP", 7, + "idle", _T("idle"), DVT_PROTODB, NULL, "IdleTS", 2, + "idlediff", _T("idle_diff"), DVT_PROTODB, NULL, "IdleTS", 3, + "xname", _T("xsname"), DVT_PROTODB, NULL, "XStatusName", 17, + "lsdate", _T("lastseen_date"), DVT_DB, "SeenModule", NULL, 8, + "lstime", _T("lastseen_time"), DVT_DB, "SeenModule", NULL, 10, + "lsstatus", _T("lastseen_status"), DVT_DB, "SeenModule", "OldStatus", 1, + "lsago", _T("lastseen_ago"), DVT_DB, "SeenModule", "seenTS", 3, + "birthdate", _T("birthday_date"), DVT_PROTODB, NULL, "Birth", 8, + "birthage", _T("birthday_age"), DVT_PROTODB, NULL, "Birth", 9, + "birthnext", _T("birthday_next"), DVT_PROTODB, NULL, "Birth", 12, + "logondate", _T("logon_date"), DVT_PROTODB, NULL, "LogonTS", 15, + "logontime", _T("logon_time"), DVT_PROTODB, NULL, "LogonTS", 13, + "logonago", _T("logon_ago"), DVT_PROTODB, NULL, "LogonTS", 3, + "logoffdate", _T("logoff_date"), DVT_PROTODB, NULL, "LogoffTS", 15, + "logofftime", _T("logoff_time"), DVT_PROTODB, NULL, "LogoffTS", 13, + "logoffago", _T("logoff_ago"), DVT_PROTODB, NULL, "LogoffTS", 3, + 0, 0, DVT_DB, 0, 0, 0 +}; + +DEFAULTITEM defaultItemList[] = +{ + "statusmsg", true, + "-", false, + "lastmsg", true , + "-", false, + "client", false, + "homepage", false, + "email", false, + "birth", false, + "name", false, + "-", false, + "time", false, + "id", false, + "status", false, + 0,0 +}; + +PRESETITEM *GetPresetItemByName(char *szName) +{ + for (int i = 0; presetItems[i].szID; i++) + { + if (strcmp(presetItems[i].szID, szName) == 0) + return &presetItems[i]; + } + + return NULL; +} + +PRESETSUBST *GetPresetSubstByName(char *szName) +{ + if (!szName) return NULL; + for (int i = 0; presetSubsts[i].szID; i++) + { + if (strcmp(presetSubsts[i].szID, szName) == 0) + return &presetSubsts[i]; + } + + return NULL; +} + diff --git a/plugins/TipperYM/src/preset_items.h b/plugins/TipperYM/src/preset_items.h new file mode 100644 index 0000000000..5055db3dee --- /dev/null +++ b/plugins/TipperYM/src/preset_items.h @@ -0,0 +1,57 @@ +/* +Copyright (C) 2006-2007 Scott Ellis +Copyright (C) 2007-2011 Jan Holub + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#ifndef _PRESETITEMS_INC +#define _PRESETITEMS_INC + +#include "options.h" + +#define MAX_PRESET_SUBST_COUNT 3 + +typedef struct { + char *szID; + TCHAR *swzName; + TCHAR *swzLabel; + TCHAR *swzValue; + char *szNeededSubst[MAX_PRESET_SUBST_COUNT]; +} PRESETITEM; + +typedef struct { + char *szID; + TCHAR *swzName; + DisplaySubstType type; + char *szModuleName; + char *szSettingName; + int iTranslateFuncId; +} PRESETSUBST; + +typedef struct { + char *szName; + bool bValueNewline; +} DEFAULTITEM; + +extern PRESETITEM presetItems[]; +extern PRESETSUBST presetSubsts[]; +extern DEFAULTITEM defaultItemList[]; + +PRESETITEM *GetPresetItemByName(char *szName); +PRESETSUBST *GetPresetSubstByName(char *szName); + +#endif \ No newline at end of file diff --git a/plugins/TipperYM/src/resource.h b/plugins/TipperYM/src/resource.h new file mode 100644 index 0000000000..0e850b25ea --- /dev/null +++ b/plugins/TipperYM/src/resource.h @@ -0,0 +1,137 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by resource.rc +// +#define IDD_OPT_APPEARANCE 101 +#define IDD_SUBST 103 +#define IDD_ITEM 104 +#define IDD_OPT_CONTENT 105 +#define IDD_OPT_SKIN 106 +#define IDI_ITEM 107 +#define IDI_ITEM_ALL 108 +#define IDD_OPT_EXTRA 109 +#define IDD_OPT_TRAYTIP 110 +#define IDD_FAVCONTACTS 111 +#define IDI_UP 112 +#define IDI_DOWN 113 +#define IDI_SEPARATOR 114 +#define IDI_RELOAD 116 +#define IDI_APPLY 117 +#define IDC_ED_WIDTH 1005 +#define IDC_ED_MAXHEIGHT 1006 +#define IDC_SPIN_WIDTH 1007 +#define IDC_SPIN_MAXHEIGHT 1008 +#define IDC_ED_INDENT 1009 +#define IDC_SPIN_INDENT 1010 +#define IDC_ED_PADDING 1011 +#define IDC_SPIN_PADDING 1012 +#define IDC_ED_TRANS 1013 +#define IDC_SPIN_TRANS 1014 +#define IDC_CHK_BORDER 1015 +#define IDC_CHK_ROUNDCORNERS 1016 +#define IDC_ED_MINWIDTH 1017 +#define IDC_ED_SPEED 1017 +#define IDC_CHK_AEROGLASS 1018 +#define IDC_SPIN_SPEED 1019 +#define IDC_CHK_SHADOW 1020 +#define IDC_SPIN_MINWIDTH 1021 +#define IDC_ED_MINHEIGHT 1022 +#define IDC_SPIN_MINHEIGHT 1023 +#define IDC_ED_SBWIDTH 1024 +#define IDC_SPIN_SBWIDTH 1025 +#define IDC_ED_TEXTPADDING 1026 +#define IDC_ED_AVSIZE 1027 +#define IDC_SPIN_AVSIZE 1028 +#define IDC_ED_HOVER 1029 +#define IDC_SPIN_HOVER 1030 +#define IDC_SPIN_TEXTPADDING 1031 +#define IDC_CMB_ICON 1032 +#define IDC_CMB_AV 1033 +#define IDC_CMB_POS 1034 +#define IDC_ED_OUTAVPADDING 1035 +#define IDC_BTN_ADD 1036 +#define IDC_SPIN_OUTAVPADDING 1036 +#define IDC_BTN_REMOVE 1037 +#define IDC_CHK_ROUNDCORNERSAV 1037 +#define IDC_BTN_UP 1038 +#define IDC_CHK_ORIGINALAVSIZE 1038 +#define IDC_BTN_DOWN 1039 +#define IDC_CHK_AVBORDER 1039 +#define IDC_CHK_NOFOCUS 1040 +#define IDC_BTN_ADD2 1040 +#define IDC_BTN_EDIT 1041 +#define IDC_ED_TITLEINDENT 1041 +#define IDC_LST_SUBST 1042 +#define IDC_SPIN_TITLEINDENT 1042 +#define IDC_ED_VALUEINDENT 1043 +#define IDC_BTN_REMOVE2 1043 +#define IDC_ED_MODULE 1044 +#define IDC_SPIN_VALUEINDENT 1044 +#define IDC_BTN_EDIT2 1044 +#define IDC_CHK_PROTOMOD 1045 +#define IDC_ED_INAVPADDING 1045 +#define IDC_BTN_SEPARATOR 1045 +#define IDC_ED_SETTING 1046 +#define IDC_SPIN_INAVPADDING 1046 +#define IDC_CMB_TRANSLATE 1047 +#define IDC_ED_LABEL 1048 +#define IDC_CHK_SBAR 1048 +#define IDC_ED_VALUE 1050 +#define IDC_CHK_LINEABOVE 1051 +#define IDC_CHK_VALNEWLINE 1052 +#define IDC_CMB_LV 1053 +#define IDC_CHK_PARSETIPPERFIRST 1053 +#define IDC_CMB_VV 1054 +#define IDC_CMB_LH 1055 +#define IDC_CMB_VH 1056 +#define IDC_CHK_DISABLEINVISIBLE 1059 +#define IDC_CHK_RETRIEVEXSTATUS 1060 +#define IDC_TREE_EXTRAICONS 1061 +#define IDC_CHK_ENABLESMILEYS 1062 +#define IDC_CHK_RESIZESMILEYS 1063 +#define IDC_CHK_GETSTATUSMSG 1064 +#define IDC_CHK_WAITFORCONTENT 1065 +#define IDC_STATIC_AVATARSIZE 1085 +#define IDC_CMB_EFFECT 1086 +#define IDC_TREE_FIRST_PROTOS 1087 +#define IDC_CHK_ENABLETRAYTIP 1088 +#define IDC_CHK_HANDLEBYTIPPER 1089 +#define IDC_TREE_SECOND_PROTOS 1090 +#define IDC_TREE_SECOND_ITEMS 1094 +#define IDC_TREE_FIRST_ITEMS 1095 +#define IDC_BTN_FAVCONTACTS 1096 +#define IDC_CHK_EXPAND 1097 +#define IDC_ED_EXPANDTIME 1098 +#define IDC_SPIN_EXPANDTIME 1099 +#define IDC_CLIST 1101 +#define IDC_BTN_OK 1102 +#define IDC_BTN_CANCEL 1103 +#define IDC_CHK_HIDEOFFLINE 1104 +#define IDC_CHK_APPENDPROTO 1105 +#define IDC_CHK_USEPROTOSMILEYS 1106 +#define IDC_CHK_ONLYISOLATED 1107 +#define IDC_CMB_PRESETITEMS 1111 +#define IDC_CHK_LIMITMSG 1113 +#define IDC_ED_CHARCOUNT 1114 +#define IDC_SPIN_CHARCOUNT 1115 +#define IDC_LB_SKINS 1116 +#define IDC_PIC_PREVIEW 1117 +#define IDC_ST_PREVIEW 1119 +#define IDC_CHK_LOADFONTS 1120 +#define IDC_CHK_ENABLECOLORING 1121 +#define IDC_CHK_LOADPROPORTIONS 1122 +#define IDC_BTN_RELOADLIST 1123 +#define IDC_BTN_APPLYSKIN 1124 +#define IDC_BTN_VARIABLE 1125 +#define IDC_BTN_GETSKINS 1125 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 118 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1127 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/plugins/TipperYM/src/skin_parser.cpp b/plugins/TipperYM/src/skin_parser.cpp new file mode 100644 index 0000000000..3c851e0039 --- /dev/null +++ b/plugins/TipperYM/src/skin_parser.cpp @@ -0,0 +1,417 @@ +/* +Copyright (C) 2006-2007 Scott Ellis +Copyright (C) 2007-2011 Jan Holub + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#include "common.h" +#include "options.h" +#include "str_utils.h" + +extern TCHAR SKIN_FOLDER[256]; + +int RefreshSkinList(HWND hwndDlg) +{ + HWND hwndSkins = GetDlgItem(hwndDlg, IDC_LB_SKINS); + ListBox_ResetContent(hwndSkins); + ListBox_AddString(hwndSkins, TranslateT("# Solid color fill")); + + TCHAR szDirSave[1024]; + GetCurrentDirectory(1024, szDirSave); + SetCurrentDirectory(SKIN_FOLDER); + + WIN32_FIND_DATA ffd; + HANDLE hFind = FindFirstFile(_T("*.*"), &ffd); + while (hFind != INVALID_HANDLE_VALUE) + { + if ((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && _tcscmp(_T("."), ffd.cFileName) && _tcscmp(_T(".."), ffd.cFileName)) + { + SetCurrentDirectory(ffd.cFileName); + WIN32_FIND_DATA ffd2; + HANDLE hFindFile = FindFirstFile(_T("*.tsf"), &ffd2); + if (hFindFile != INVALID_HANDLE_VALUE) + ListBox_AddString(hwndSkins, ffd.cFileName); + + FindClose(hFindFile); + SetCurrentDirectory(_T("..")); + } + + if (!FindNextFile(hFind, &ffd)) + break; + } + + FindClose(hFind); + SetCurrentDirectory(szDirSave); + + return ListBox_SelectString(GetDlgItem(hwndDlg, IDC_LB_SKINS), -1, opt.szSkinName); +} + +bool FileExists(TCHAR *filename) +{ + HANDLE hFile = CreateFile(filename, 0, 0, 0, OPEN_EXISTING, 0, 0); + if (hFile != INVALID_HANDLE_VALUE) + { + CloseHandle(hFile); + return true; + } + + return false; +} + +void ParseAboutPart(FILE *fp, TCHAR *buff, TCHAR *szSkinName) +{ + myfgets(buff, 1024, fp); + while (buff[0] != '[') + { + if (buff[0] != ';') + { + TCHAR *pch = _tcschr(buff, '='); + if (pch++) + { + while (pch && (*pch == ' ' || *pch == '\t')) + pch++; + + if (pch) + { + if (_tcsstr(buff, _T("author"))) + {} + else if (_tcsstr(buff, _T("preview"))) + { + TCHAR szImgPath[1024]; + mir_sntprintf(szImgPath, SIZEOF(szImgPath), _T("%s\\%s\\%s"), SKIN_FOLDER, szSkinName, pch); + if (FileExists(szImgPath)) + _tcscpy(opt.szPreviewFile, szImgPath); + } + } + } + } + + if (feof(fp)) break; + myfgets(buff, 1024, fp); + } +} + +void ParseImagePart(FILE *fp, TCHAR *buff, int iPart) +{ + opt.szImgFile[iPart] = NULL; + opt.transfMode[iPart] = TM_NONE; + opt.margins[iPart].left = 0; + opt.margins[iPart].top = 0; + opt.margins[iPart].right = 0; + opt.margins[iPart].bottom = 0; + + myfgets(buff, 1024, fp); + while (buff[0] != '[') + { + if (buff[0] != ';') + { + TCHAR *pch = _tcschr(buff, '='); + if (pch++) + { + while (pch && (*pch == ' ' || *pch == '\t')) + pch++; + + if (pch) + { + if (_tcsstr(buff, _T("image"))) + { + TCHAR szImgPath[1024]; + mir_sntprintf(szImgPath, SIZEOF(szImgPath), _T("%s\\%s\\%s"), SKIN_FOLDER, opt.szSkinName, pch); + opt.szImgFile[iPart] = mir_tstrdup(szImgPath); + } + else if (_tcsstr(buff, _T("tm"))) + { + if (!lstrcmpi(pch, _T("TM_NONE"))) + opt.transfMode[iPart] = TM_NONE; + else if (!lstrcmpi(pch, _T("TM_CENTRE"))) + opt.transfMode[iPart] = TM_CENTRE; + else if (!lstrcmpi(pch, _T("TM_STRECH_ALL"))) + opt.transfMode[iPart] = TM_STRECH_ALL; + else if (!lstrcmpi(pch, _T("TM_STRECH_HORIZONTAL"))) + opt.transfMode[iPart] = TM_STRECH_HORIZONTAL; + else if (!lstrcmpi(pch, _T("TM_STRECH_VERTICAL"))) + opt.transfMode[iPart] = TM_STRECH_VERTICAL; + else if (!lstrcmpi(pch, _T("TM_TILE_ALL"))) + opt.transfMode[iPart] = TM_TILE_ALL; + else if (!lstrcmpi(pch, _T("TM_TILE_HORIZONTAL"))) + opt.transfMode[iPart] = TM_TILE_HORIZONTAL; + else if (!lstrcmpi(pch, _T("TM_TILE_VERTICAL"))) + opt.transfMode[iPart] = TM_TILE_VERTICAL; + else + opt.transfMode[iPart] = TM_NONE; + } + else if (_tcsstr(buff, _T("left"))) + opt.margins[iPart].left = _ttoi(pch); + else if (_tcsstr(buff, _T("top"))) + opt.margins[iPart].top = _ttoi(pch); + else if (_tcsstr(buff, _T("right"))) + opt.margins[iPart].right = _ttoi(pch); + else if (_tcsstr(buff, _T("bottom"))) + opt.margins[iPart].bottom = _ttoi(pch); + } + } + } + + if (feof(fp)) break; + myfgets(buff, 1024, fp); + } +} + +char *GetSettingName(TCHAR *szValue, char *szPostfix, char *buff) +{ + buff[0] = 0; + + if (_tcsstr(szValue, _T("traytitle"))) + mir_snprintf(buff, 64, "FontTrayTitle%s", szPostfix); + else if (_tcsstr(szValue, _T("title"))) + mir_snprintf(buff, 64, "FontFirst%s", szPostfix); + else if (_tcsstr(szValue, _T("label"))) + mir_snprintf(buff, 64, "FontLabels%s", szPostfix); + else if (_tcsstr(szValue, _T("value"))) + mir_snprintf(buff, 64, "FontValues%s", szPostfix); + else if (_tcsstr(szValue, _T("divider"))) + mir_snprintf(buff, 64, "Divider%s", szPostfix); + + if (buff[0]) return buff; + else return NULL; +} + +void ParseFontPart(FILE *fp, TCHAR *buff) +{ + char szSetting[64]; + + myfgets(buff, 1024, fp); + while (buff[0] != '[') + { + if (buff[0] != ';') + { + TCHAR *pch = _tcschr(buff, '='); + if (pch++) + { + while (pch && (*pch == ' ' || *pch == '\t')) + pch++; + + if (pch) + { + if (_tcsstr(buff, _T("face"))) + { + if (GetSettingName(buff, "", szSetting)) + { + if (_tcslen(pch) > 32) + pch[32] = 0; + + DBWriteContactSettingTString(0, MODULE, szSetting, pch); + } + } + else if (_tcsstr(buff, _T("color"))) + { + if (GetSettingName(buff, "Col", szSetting)) + { + BYTE r = _ttoi(pch); + pch = _tcschr(pch, ' '); + if (++pch) + { + BYTE g = _ttoi(pch); + pch = _tcschr(pch, ' '); + if (++pch) + { + BYTE b = _ttoi(pch); + COLORREF color = RGB(r, g ,b); + DBWriteContactSettingDword(0, MODULE, szSetting, color); + } + } + } + } + else if (_tcsstr(buff, _T("size"))) + { + if (GetSettingName(buff, "Size", szSetting)) + { + HDC hdc = GetDC(0); + int size = -MulDiv(_ttoi(pch), GetDeviceCaps(hdc, LOGPIXELSY), 72); + DBWriteContactSettingByte(0, MODULE, szSetting, (BYTE)size); + ReleaseDC(0, hdc); + } + } + else if (_tcsstr(buff, _T("effect"))) + { + if (GetSettingName(buff, "Sty", szSetting)) + { + BYTE effect = 0; + if (_tcsstr(pch, _T("font_bold"))) + effect |= DBFONTF_BOLD; + if (_tcsstr(pch, _T("font_italic"))) + effect |= DBFONTF_ITALIC; + if (_tcsstr(pch, _T("font_underline"))) + effect |= DBFONTF_UNDERLINE; + + DBWriteContactSettingByte(0, MODULE, szSetting, effect); + } + } + } + } + } + + if (feof(fp)) break; + myfgets(buff, 1024, fp); + } +} + +void ParseAppearancePart(FILE *fp, TCHAR *buff) +{ + myfgets(buff, 1024, fp); + while (buff[0] != '[') + { + if (buff[0] != ';') + { + TCHAR *pch = _tcschr(buff, '='); + if (pch++) + { + while (pch && (*pch == ' ' || *pch == '\t')) + pch++; + + if (pch) + { + if (_tcsstr(buff, _T("general-padding"))) + opt.iPadding = _ttoi(pch); + else if (_tcsstr(buff, _T("title-indent"))) + opt.iTitleIndent = _ttoi(pch); + else if (_tcsstr(buff, _T("text-indent"))) + opt.iTextIndent = _ttoi(pch); + else if (_tcsstr(buff, _T("value-indent"))) + opt.iValueIndent = _ttoi(pch); + else if (_tcsstr(buff, _T("text-padding"))) + opt.iTextPadding = _ttoi(pch); + else if (_tcsstr(buff, _T("outer-avatar-padding"))) + opt.iOuterAvatarPadding = _ttoi(pch); + else if (_tcsstr(buff, _T("inner-avatar-padding"))) + opt.iInnerAvatarPadding = _ttoi(pch); + else if (_tcsstr(buff, _T("sidebar-width"))) + opt.iSidebarWidth = _ttoi(pch); + else if (_tcsstr(buff, _T("opacity"))) + opt.iOpacity = _ttoi(pch); + } + } + } + + if (feof(fp)) break; + myfgets(buff, 1024, fp); + } +} + +void ParseOtherPart(FILE *fp, TCHAR *buff) +{ + myfgets(buff, 1024, fp); + while (buff[0] != '[') + { + if (buff[0] != ';') + { + TCHAR *pch = _tcschr(buff, '='); + if (pch++) + { + while (pch && (*pch == ' ' || *pch == '\t')) + pch++; + + if (pch) + { + if (_tcsstr(buff, _T("enable-coloring"))) + { + if (_tcsstr(pch, _T("false"))) + opt.iEnableColoring = -1; + } + } + } + } + + if (feof(fp)) break; + myfgets(buff, 1024, fp); + } +} + +void ParseSkinFile(TCHAR *szSkinName, bool bStartup, bool bOnlyPreview) +{ + TCHAR szDirSave[1024], buff[1024]; + + if (opt.skinMode == SM_OBSOLOTE && bStartup) + return; + + if (!bStartup) opt.iEnableColoring = 0; + opt.szPreviewFile[0] = 0; + + GetCurrentDirectory(1024, szDirSave); + SetCurrentDirectory(SKIN_FOLDER); + SetCurrentDirectory(szSkinName); + + WIN32_FIND_DATA ffd; + HANDLE hFind = FindFirstFile(_T("*.tsf"), &ffd); + if (hFind != INVALID_HANDLE_VALUE) + { + FILE *fp = _tfopen(ffd.cFileName, _T("r")); + if (fp) + { + myfgets(buff, 1024, fp); + while (!feof(fp)) + { + if (buff[0] == '[') + { + if (!_tcscmp(_T("[about]"), buff)) + { + ParseAboutPart(fp, buff, szSkinName); + continue; + } + else if (!_tcscmp(_T("[other]"), buff)) + { + ParseOtherPart(fp, buff); + continue; + } + else if (!bOnlyPreview) + { + if (!_tcscmp(_T("[background]"), buff)) + { + ParseImagePart(fp, buff, SKIN_ITEM_BG); + continue; + } + else if (!_tcscmp(_T("[sidebar]"), buff)) + { + ParseImagePart(fp, buff, SKIN_ITEM_SIDEBAR); + continue; + } + else if (!bStartup && opt.bLoadFonts && !_tcscmp(_T("[fonts]"), buff)) + { + ParseFontPart(fp, buff); + continue; + } + else if (!bStartup && opt.bLoadProportions && !_tcscmp(_T("[appearance]"), buff)) + { + ParseAppearancePart(fp, buff); + continue; + } + } + } + + myfgets(buff, 1024, fp); + } + fclose(fp); + } + } + else + { + opt.skinMode = SM_COLORFILL; + } + + FindClose(hFind); + SetCurrentDirectory(szDirSave); +} \ No newline at end of file diff --git a/plugins/TipperYM/src/skin_parser.h b/plugins/TipperYM/src/skin_parser.h new file mode 100644 index 0000000000..ca83f47915 --- /dev/null +++ b/plugins/TipperYM/src/skin_parser.h @@ -0,0 +1,30 @@ +/* +Copyright (C) 2006-2007 Scott Ellis +Copyright (C) 2007-2011 Jan Holub + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#ifndef _SKIN_INC +#define _SKIN_INC + +typedef enum { + SM_COLORFILL = 0, SM_IMAGE = 1, SM_OBSOLOTE = 2 +} SkinMode; + +int RefreshSkinList(HWND hwndDlg); +void ParseSkinFile(TCHAR *szSkinName, bool bStartup, bool bOnlyPreview); +#endif \ No newline at end of file diff --git a/plugins/TipperYM/src/str_utils.cpp b/plugins/TipperYM/src/str_utils.cpp new file mode 100644 index 0000000000..112cc2678b --- /dev/null +++ b/plugins/TipperYM/src/str_utils.cpp @@ -0,0 +1,231 @@ +/* +Copyright (C) 2006-2007 Scott Ellis +Copyright (C) 2007-2011 Jan Holub + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#include "common.h" +#include "str_utils.h" + +int iCodePage = CP_ACP; + +bool a2w(const char *as, wchar_t *buff, int bufflen) +{ + if (as) MultiByteToWideChar(iCodePage, 0, as, -1, buff, bufflen); + return true; +} + +bool w2a(const wchar_t *ws, char *buff, int bufflen) +{ + if (ws) WideCharToMultiByte(iCodePage, 0, ws, -1, buff, bufflen, 0, 0); + return true; +} + +bool utf2w(const char *us, wchar_t *buff, int bufflen) +{ + if (us) MultiByteToWideChar(CP_UTF8, 0, us, -1, buff, bufflen); + return true; +} + +bool w2utf(const wchar_t *ws, char *buff, int bufflen) +{ + if (ws) WideCharToMultiByte(CP_UTF8, 0, ws, -1, buff, bufflen, 0, 0); + return true; +} + +bool a2utf(const char *as, char *buff, int bufflen) +{ + if (!as) return false; + + wchar_t *ws = a2w(as); + if (ws) WideCharToMultiByte(CP_UTF8, 0, ws, -1, buff, bufflen, 0, 0); + mir_free(ws); + return true; +} + +bool utf2a(const char *us, char *buff, int bufflen) +{ + if (!us) return false; + + wchar_t *ws = utf2w(us); + if (ws) WideCharToMultiByte(iCodePage, 0, ws, -1, buff, bufflen, 0, 0); + mir_free(ws); + return true; +} + + +bool t2w(const TCHAR *ts, wchar_t *buff, int bufflen) +{ + + wcsncpy(buff, ts, bufflen); + return true; + +} + +bool w2t(const wchar_t *ws, TCHAR *buff, int bufflen) +{ + + wcsncpy(buff, ws, bufflen); + return true; + +} + +bool t2a(const TCHAR *ts, char *buff, int bufflen) +{ + + return w2a(ts, buff, bufflen); + +} + +bool a2t(const char *as, TCHAR *buff, int bufflen) +{ + + return a2w(as, buff, bufflen); + +} + +bool t2utf(const TCHAR *ts, char *buff, int bufflen) +{ + + return w2utf(ts, buff, bufflen); + +} + +bool utf2t(const char *us, TCHAR *buff, int bufflen) +{ + + return utf2w(us, buff, bufflen); + +} + +wchar_t *utf2w(const char *us) +{ + if (us) + { + int size = MultiByteToWideChar(CP_UTF8, 0, us, -1, 0, 0); + wchar_t *buff = (wchar_t *)mir_alloc(size * sizeof(wchar_t)); + MultiByteToWideChar(CP_UTF8, 0, us, -1, buff, size); + return buff; + } + else + { + return 0; + } +} + +char *w2utf(const wchar_t *ws) +{ + if (ws) + { + int size = WideCharToMultiByte(CP_UTF8, 0, ws, -1, 0, 0, 0, 0); + char *buff = (char *)mir_alloc(size); + WideCharToMultiByte(CP_UTF8, 0, ws, -1, buff, size, 0, 0); + return buff; + } + else + { + return 0; + } +} + +wchar_t *a2w(const char *as) +{ + int size = MultiByteToWideChar(iCodePage, 0, as, -1, 0, 0); + wchar_t *buff = (wchar_t *)mir_alloc(size * sizeof(wchar_t)); + MultiByteToWideChar(iCodePage, 0, as, -1, buff, size); + return buff; +} + +char *w2a(const wchar_t *ws) +{ + int size = WideCharToMultiByte(iCodePage, 0, ws, -1, 0, 0, 0, 0); + char *buff = (char *)mir_alloc(size); + WideCharToMultiByte(iCodePage, 0, ws, -1, buff, size, 0, 0); + return buff; +} + +char *utf2a(const char *utfs) +{ + wchar_t *ws = utf2w(utfs); + char *ret = w2a(ws); + mir_free(ws); + return ret; +} + +char *a2utf(const char *as) +{ + wchar_t *ws = a2w(as); + char *ret = w2utf(ws); + mir_free(ws); + return ret; +} + +TCHAR *w2t(const wchar_t *ws) +{ + + return mir_wstrdup(ws); + +} + +wchar_t *t2w(const TCHAR *ts) +{ + + return mir_tstrdup(ts); + +} + + +char *t2a(const TCHAR *ts) +{ + + return w2a(ts); + +} + +TCHAR *a2t(const char *as) +{ + + return a2w(as); + +} + +TCHAR *utf2t(const char *utfs) +{ + + return utf2w(utfs); +} + +char *t2utf(const TCHAR *ts) +{ + + return w2utf(ts); +} + +TCHAR *myfgets(TCHAR *Buf, int MaxCount, FILE *File) +{ + _fgetts(Buf, MaxCount, File); + for (size_t i = _tcslen(Buf) - 1; i >= 0; i--) + { + if (Buf[i] == '\n' || Buf[i] == ' ') + Buf[i] = 0; + else + break; + } + + CharLower(Buf); + return Buf; +} \ No newline at end of file diff --git a/plugins/TipperYM/src/str_utils.h b/plugins/TipperYM/src/str_utils.h new file mode 100644 index 0000000000..26fbb613fa --- /dev/null +++ b/plugins/TipperYM/src/str_utils.h @@ -0,0 +1,66 @@ +/* +Copyright (C) 2006-2007 Scott Ellis +Copyright (C) 2007-2011 Jan Holub + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#ifndef _STR_UTILS_INC +#define _STR_UTILS_INC + +void set_codepage(); + +bool a2w(const char *as, wchar_t *buff, int bufflen); +bool w2a(const wchar_t *ws, char *buff, int bufflen); + +bool utf2w(const char *us, wchar_t *buff, int bufflen); +bool w2utf(const wchar_t *ws, char *buff, int bufflen); + +bool a2utf(const char *as, char *buff, int bufflen); +bool utf2a(const char *ws, char *buff, int bufflen); + +bool t2w(const TCHAR *ts, wchar_t *buff, int bufflen); +bool w2t(const wchar_t *ws, TCHAR *buff, int bufflen); + +bool t2a(const TCHAR *ts, char *buff, int bufflen); +bool a2t(const char *as, TCHAR *buff, int bufflen); + +bool t2utf(const TCHAR *ts, char *buff, int bufflen); +bool utf2t(const char *us, TCHAR *buff, int bufflen); + +// remember to free return value +wchar_t *a2w(const char *as); +char *w2a(const wchar_t *ws); + +wchar_t *utf2w(const char *us); +char *w2utf(const wchar_t *ws); + +char *utf2a(const char *us); +char *a2utf(const char *as); + +wchar_t *t2w(const TCHAR *ts); +TCHAR *w2t(const wchar_t *ws); + +TCHAR *utf2t(const char *us); +char *t2utf(const TCHAR *ts); + +char *t2a(const TCHAR *ts); +TCHAR *a2t(const char *as); + +TCHAR *myfgets(TCHAR *Buf, int MaxCount, FILE *File); + +#endif + diff --git a/plugins/TipperYM/src/subst.cpp b/plugins/TipperYM/src/subst.cpp new file mode 100644 index 0000000000..1d8c8837d9 --- /dev/null +++ b/plugins/TipperYM/src/subst.cpp @@ -0,0 +1,1011 @@ +/* +Copyright (C) 2006-2007 Scott Ellis +Copyright (C) 2007-2011 Jan Holub + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#include "common.h" +#include "subst.h" +#include "str_utils.h" +#include "popwin.h" + + +int ProtoServiceExists(const char *szModule, const char *szService) +{ + char str[MAXMODULELABELLENGTH]; + strcpy(str,szModule); + strcat(str,szService); + return ServiceExists(str); +} + +bool DBGetContactSettingAsString(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) +{ + DBVARIANT dbv; + buff[0] = 0; + + if (!szModuleName || !szSettingName) + return false; + + if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) + { + switch(dbv.type) + { + case DBVT_BYTE: + _itot(dbv.bVal, buff, 10); + break; + case DBVT_WORD: + _ltot(dbv.wVal, buff, 10); + break; + case DBVT_DWORD: + _ltot(dbv.dVal, buff, 10); + break; + case DBVT_ASCIIZ: + if (dbv.pszVal) a2t(dbv.pszVal, buff, bufflen); + buff[bufflen - 1] = 0; + break; + case DBVT_UTF8: + if (dbv.pszVal) utf2t(dbv.pszVal, buff, bufflen); + buff[bufflen - 1] = 0; + break; + + case DBVT_WCHAR: + if (dbv.pwszVal) wcsncpy(buff, dbv.pwszVal, bufflen); + buff[bufflen - 1] = 0; + break; + + } + + DBFreeVariant(&dbv); + } + + return buff[0] ? true : false; +} + +void StripBBCodesInPlace(TCHAR *swzText) +{ + if (!DBGetContactSettingByte(0, MODULE, "StripBBCodes", 1)) + return; + + if (swzText == 0) + return; + + size_t iRead = 0, iWrite = 0; + size_t iLen = _tcslen(swzText); + + while(iRead <= iLen) // copy terminating null too + { + while(iRead <= iLen && swzText[iRead] != '[') + { + if (swzText[iRead] != swzText[iWrite]) swzText[iWrite] = swzText[iRead]; + iRead++; iWrite++; + } + + if (iRead > iLen) + break; + + if (iLen - iRead >= 3 && (_tcsnicmp(swzText + iRead, _T("[b]"), 3) == 0 || _tcsnicmp(swzText + iRead, _T("[i]"), 3) == 0)) + iRead += 3; + else if (iLen - iRead >= 4 && (_tcsnicmp(swzText + iRead, _T("[/b]"), 4) == 0 || _tcsnicmp(swzText + iRead, _T("[/i]"), 4) == 0)) + iRead += 4; + else if (iLen - iRead >= 6 && (_tcsnicmp(swzText + iRead, _T("[color"), 6) == 0)) + { + while(iRead < iLen && swzText[iRead] != ']') iRead++; + iRead++;// skip the ']' + } + else if (iLen - iRead >= 8 && (_tcsnicmp(swzText + iRead, _T("[/color]"), 8) == 0)) + iRead += 8; + else if (iLen - iRead >= 5 && (_tcsnicmp(swzText + iRead, _T("[size"), 5) == 0)) + { + while(iRead < iLen && swzText[iRead] != ']') iRead++; + iRead++;// skip the ']' + } + else if (iLen - iRead >= 7 && (_tcsnicmp(swzText + iRead, _T("[/size]"), 7) == 0)) + iRead += 7; + else + { + if (swzText[iRead] != swzText[iWrite]) swzText[iWrite] = swzText[iRead]; + iRead++; iWrite++; + } + } +} + +DWORD LastMessageTimestamp(HANDLE hContact) +{ + DBEVENTINFO dbei = {0}; + dbei.cbSize = sizeof(dbei); + HANDLE hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hContact, 0); + while (hDbEvent) + { + dbei.cbBlob = 0; + CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei); + if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT)) + break; + + hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hDbEvent, 0); + } + + if (hDbEvent) + return dbei.timestamp; + + return 0; +} + +void FormatTimestamp(DWORD ts, char *szFormat, TCHAR *buff, int bufflen) +{ + TCHAR swzForm[16]; + DBTIMETOSTRINGT dbt = {0}; + dbt.cbDest = bufflen; + dbt.szDest = buff; + a2t(szFormat, swzForm, 16); + dbt.szFormat = swzForm; + CallService(MS_DB_TIME_TIMESTAMPTOSTRINGT, (WPARAM)ts, (LPARAM)&dbt); +} + +bool Uid(HANDLE hContact, char *szProto, TCHAR *buff, int bufflen) +{ + char *tmpProto = NULL; + + if (hContact) tmpProto = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact, 0); + else tmpProto = szProto; + + if (tmpProto) + { + char *szUid = ( char* )CallProtoService(tmpProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); + if (szUid && (INT_PTR)szUid != CALLSERVICE_NOTFOUND) + return DBGetContactSettingAsString(hContact, tmpProto, szUid, buff, bufflen); + } + + return false; +} + +bool UidName(char *szProto, TCHAR *buff, int bufflen) +{ + if (szProto) + { + char *szUidName = ( char* )CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDTEXT, 0); + if (szUidName && (INT_PTR)szUidName != CALLSERVICE_NOTFOUND) + { + a2t(szUidName, buff, bufflen); + return true; + } + } + return false; +} + +TCHAR *GetLastMessageText(HANDLE hContact) +{ + DBEVENTINFO dbei = {0}; + dbei.cbSize = sizeof(dbei); + + HANDLE hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hContact, 0); + while (hDbEvent) + { + dbei.cbBlob = 0; + CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei); + if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT)) + break; + + hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hDbEvent, 0); + } + + if (hDbEvent) + { + dbei.pBlob = (BYTE *)alloca(dbei.cbBlob); + CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei); + + if (dbei.cbBlob == 0 || dbei.pBlob == 0) + return 0; + + TCHAR *buff = DbGetEventTextT( &dbei, CP_ACP ); + TCHAR *swzMsg = mir_tstrdup(buff); + mir_free(buff); + + StripBBCodesInPlace(swzMsg); + return swzMsg; + } + + return 0; +} + +bool CanRetrieveStatusMsg(HANDLE hContact, char *szProto) +{ + if (opt.bGetNewStatusMsg) + { + int iFlags = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0); + WORD wStatus = DBGetContactSettingWord(hContact, szProto, "Status", ID_STATUS_OFFLINE); + if ((CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) && (iFlags & Proto_Status2Flag(wStatus))) + { + iFlags = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & (PF1_VISLIST | PF1_INVISLIST); + if (opt.bDisableIfInvisible && iFlags) + { + int iVisMode = DBGetContactSettingWord(hContact, szProto, "ApparentMode", 0); + int wProtoStatus = CallProtoService(szProto, PS_GETSTATUS, 0, 0); + if ((iVisMode == ID_STATUS_OFFLINE) || (wProtoStatus == ID_STATUS_INVISIBLE && iVisMode != ID_STATUS_ONLINE)) + return false; + else + return true; + } + else + { + return true; + } + } + else + { + return false; + } + } + + return false; +} + +TCHAR *GetStatusMessageText(HANDLE hContact) +{ + TCHAR *swzMsg = 0; + DBVARIANT dbv; + + char *szProto = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + if (szProto) + { + if (!strcmp(szProto, szMetaModuleName)) + { + hContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0); + } + else + { + WORD wStatus = (int)CallProtoService(szProto, PS_GETSTATUS, 0, 0); + if (wStatus == ID_STATUS_OFFLINE) + return NULL; + + if (!DBGetContactSettingTString(hContact, MODULE, "TempStatusMsg", &dbv)) + { + if (_tcslen(dbv.ptszVal) != 0) + swzMsg = mir_tstrdup(dbv.ptszVal); + DBFreeVariant(&dbv); + } + } + + if (!swzMsg) + { + if (CanRetrieveStatusMsg(hContact, szProto)) + { + if (CallContactService(hContact, PSS_GETAWAYMSG, 0, 0)) + return NULL; + } + + if (!DBGetContactSettingTString(hContact, "CList", "StatusMsg", &dbv)) + { + if (dbv.ptszVal && _tcslen(dbv.ptszVal) != 0) + swzMsg = mir_tstrdup(dbv.ptszVal); + DBFreeVariant(&dbv); + } + } + } + + if (swzMsg) + StripBBCodesInPlace(swzMsg); + + return swzMsg; +} + +bool GetSysSubstText(HANDLE hContact, TCHAR *swzRawSpec, TCHAR *buff, int bufflen) +{ + if (!_tcscmp(swzRawSpec, _T("uid"))) + { + return Uid(hContact, 0, buff, bufflen); + } + else if (!_tcscmp(swzRawSpec, _T("proto"))) + { + char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + if (szProto) + { + a2t(szProto, buff, bufflen); + return true; + } + } + else if (!_tcscmp(swzRawSpec, _T("account"))) + { + char *szProto = ( char* )CallService(MS_PROTO_GETCONTACTBASEACCOUNT, (WPARAM)hContact, 0); + if ((INT_PTR)szProto == CALLSERVICE_NOTFOUND) + { + return GetSysSubstText(hContact, _T("proto"), buff, bufflen); + } + else if (szProto) + { + PROTOACCOUNT *pa = ProtoGetAccount(szProto); + if (pa && pa->tszAccountName) + { + _tcsncpy(buff, pa->tszAccountName, bufflen); + return true; + } + else + return GetSysSubstText(hContact, _T("proto"), buff, bufflen); + } + } + else if (!_tcscmp(swzRawSpec, _T("time"))) + { + if (tmi.printDateTime && !tmi.printDateTimeByContact(hContact, _T("t"), buff, bufflen, TZF_KNOWNONLY)) + return true; + } + else if (!_tcscmp(swzRawSpec, _T("uidname"))) + { + char *szProto = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + return UidName(szProto, buff, bufflen); + } + else if (!_tcscmp(swzRawSpec, _T("status_msg"))) + { + TCHAR *swzMsg = GetStatusMessageText(hContact); + if (swzMsg) + { + _tcsncpy(buff, swzMsg, bufflen); + mir_free(swzMsg); + return true; + } + } + else if (!_tcscmp(swzRawSpec, _T("last_msg"))) + { + TCHAR *swzMsg = GetLastMessageText(hContact); + if (swzMsg) + { + _tcsncpy(buff, swzMsg, bufflen); + mir_free(swzMsg); + return true; + } + } + else if (!_tcscmp(swzRawSpec, _T("meta_subname"))) + { + // get contact list name of active subcontact + HANDLE hSubContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0); + if (!hSubContact || (INT_PTR)hSubContact == CALLSERVICE_NOTFOUND) return false; + TCHAR *swzNick = (TCHAR *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hSubContact, GCDNF_TCHAR); + if (swzNick) _tcsncpy(buff, swzNick, bufflen); + return true; + } + else if (!_tcscmp(swzRawSpec, _T("meta_subuid"))) + { + HANDLE hSubContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0); + if (!hSubContact || (INT_PTR)hSubContact == CALLSERVICE_NOTFOUND) return false; + return Uid(hSubContact, 0, buff, bufflen); + } + else if (!_tcscmp(swzRawSpec, _T("meta_subproto"))) + { + // get protocol of active subcontact + HANDLE hSubContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0); + if (!hSubContact || (INT_PTR)hSubContact == CALLSERVICE_NOTFOUND) + return false; + return GetSysSubstText(hSubContact, _T("account"), buff, bufflen); + } + else if (!_tcscmp(swzRawSpec, _T("last_msg_time"))) + { + DWORD ts = LastMessageTimestamp(hContact); + if (ts == 0) return false; + FormatTimestamp(ts, "t", buff, bufflen); + return true; + } + else if (!_tcscmp(swzRawSpec, _T("last_msg_date"))) + { + DWORD ts = LastMessageTimestamp(hContact); + if (ts == 0) return false; + FormatTimestamp(ts, "d", buff, bufflen); + return true; + } + else if (!_tcscmp(swzRawSpec, _T("last_msg_reltime"))) + { + DWORD ts = LastMessageTimestamp(hContact); + if (ts == 0) return false; + DWORD t = (DWORD)time(0); + DWORD diff = (t - ts); + int d = (diff / 60 / 60 / 24); + int h = (diff - d * 60 * 60 * 24) / 60 / 60; + int m = (diff - d * 60 * 60 * 24 - h * 60 * 60) / 60; + if (d > 0) mir_sntprintf(buff, bufflen, TranslateT("%dd %dh %dm"), d, h, m); + else if (h > 0) mir_sntprintf(buff, bufflen, TranslateT("%dh %dm"), h, m); + else mir_sntprintf(buff, bufflen, TranslateT("%dm"), m); + return true; + } + else if (!_tcscmp(swzRawSpec, _T("msg_count_all")) || !_tcscmp(swzRawSpec, _T("msg_count_out")) || !_tcscmp(swzRawSpec, _T("msg_count_in"))) + { + DWORD dwCountOut, dwCountIn; + DWORD dwMetaCountOut = 0, dwMetaCountIn = 0; + DWORD dwLastTs, dwNewTs, dwRecountTs; + DWORD dwTime, dwDiff; + int iNumber = 1; + HANDLE hTmpContact = hContact; + + char *szProto = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + if (szProto && !strcmp(szProto, szMetaModuleName)) + { + iNumber = CallService(MS_MC_GETNUMCONTACTS, (WPARAM)hContact, 0); + hTmpContact = (HANDLE)CallService(MS_MC_GETSUBCONTACT, (WPARAM)hContact, 0); + } + + for (int i = 0; i < iNumber; i++) + { + if (i > 0) hTmpContact = (HANDLE)CallService(MS_MC_GETSUBCONTACT, (WPARAM)hContact, i); + dwRecountTs = DBGetContactSettingDword(hTmpContact, MODULE, "LastCountTS", 0); + dwTime = (DWORD)time(0); + dwDiff = (dwTime - dwRecountTs); + if (dwDiff > (60 * 60 * 24 * 3)) + { + DBWriteContactSettingDword(hTmpContact, MODULE, "LastCountTS", dwTime); + dwCountOut = dwCountIn = dwLastTs = 0; + } + else + { + dwCountOut = DBGetContactSettingDword(hTmpContact, MODULE, "MsgCountOut", 0); + dwCountIn = DBGetContactSettingDword(hTmpContact, MODULE, "MsgCountIn", 0); + dwLastTs = DBGetContactSettingDword(hTmpContact, MODULE, "LastMsgTS", 0); + } + + dwNewTs = dwLastTs; + + HANDLE dbe = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hTmpContact, 0); + while (dbe != NULL) + { + DBEVENTINFO dbei = {0}; + dbei.cbSize = sizeof(dbei); + if (!CallService(MS_DB_EVENT_GET, (WPARAM)dbe, (LPARAM)&dbei)) + { + if (dbei.eventType == EVENTTYPE_MESSAGE) + { + dwNewTs = max(dwNewTs, dbei.timestamp); + if (dbei.timestamp > dwLastTs) + { + if (dbei.flags & DBEF_SENT) dwCountOut++; + else dwCountIn++; + } + else + break; + } + } + dbe = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)dbe, 0); + } + + if (dwNewTs > dwLastTs) + { + DBWriteContactSettingDword(hTmpContact, MODULE, "MsgCountOut", dwCountOut); + DBWriteContactSettingDword(hTmpContact, MODULE, "MsgCountIn", dwCountIn); + DBWriteContactSettingDword(hTmpContact, MODULE, "LastMsgTS", dwNewTs); + } + + dwMetaCountOut += dwCountOut; + dwMetaCountIn += dwCountIn; + } + + if (!_tcscmp(swzRawSpec, _T("msg_count_out"))) + mir_sntprintf(buff, bufflen, _T("%d"), dwMetaCountOut); + else if (!_tcscmp(swzRawSpec, _T("msg_count_in"))) + mir_sntprintf(buff, bufflen, _T("%d"), dwMetaCountIn); + else + mir_sntprintf(buff, bufflen, _T("%d"), dwMetaCountOut + dwMetaCountIn); + return true; + } + + return false; +} + +bool GetSubstText(HANDLE hContact, const DISPLAYSUBST &ds, TCHAR *buff, int bufflen) +{ + TranslateFunc *transFunc = 0; + for (int i = 0; i < iTransFuncsCount; i++) + { + if (translations[i].id == (DWORD)ds.iTranslateFuncId) + { + transFunc = translations[i].transFunc; + break; + } + } + + if (!transFunc) + return false; + + switch (ds.type) + { + case DVT_DB: + return transFunc(hContact, ds.szModuleName, ds.szSettingName, buff, bufflen) != 0; + case DVT_PROTODB: + { + char *szProto = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + if (szProto) + { + if (transFunc(hContact, szProto, ds.szSettingName, buff, bufflen) != 0) + return true; + else + return transFunc(hContact, "UserInfo", ds.szSettingName, buff, bufflen) != 0; + } + break; + } + } + return false; +} + +bool GetRawSubstText(HANDLE hContact, char *szRawSpec, TCHAR *buff, int bufflen) +{ + size_t lenght = strlen(szRawSpec); + for (size_t i = 0; i < lenght; i++) + { + if (szRawSpec[i] == '/') + { + szRawSpec[i] = 0; + if (strlen(szRawSpec) == 0) + { + char *szProto = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + if (szProto) + { + if (translations[0].transFunc(hContact, szProto, &szRawSpec[i + 1], buff, bufflen) != 0) + return true; + else + return translations[0].transFunc(hContact, "UserInfo", &szRawSpec[i + 1], buff, bufflen) != 0; + } + else + { + return false; + } + } + else + { + return translations[0].transFunc(hContact, szRawSpec, &szRawSpec[i + 1], buff, bufflen) != 0; + } + } + } + return false; +} + +bool ApplySubst(HANDLE hContact, const TCHAR *swzSource, bool parseTipperVarsFirst, TCHAR *swzDest, int iDestLen) +{ + // hack - allow empty strings before passing to variables (note - zero length strings return false after this) + if (swzDest && swzSource && _tcslen(swzSource) == 0) { + swzDest[0] = 0; + return true; + } + + // pass to variables plugin if available + TCHAR *swzVarSrc; + if (parseTipperVarsFirst == false) + swzVarSrc = variables_parsedup((TCHAR *)swzSource, 0, hContact); + else + swzVarSrc = mir_tstrdup(swzSource); + + size_t iSourceLen = _tcslen(swzVarSrc); + size_t si = 0, di = 0, v = 0; + + TCHAR swzVName[LABEL_LEN]; + TCHAR swzRep[VALUE_LEN], swzAlt[VALUE_LEN]; + while (si < iSourceLen && di < (size_t)iDestLen - 1) + { + if (swzVarSrc[si] == _T('%')) + { + si++; + v = 0; + while (si < iSourceLen && v < LABEL_LEN) + { + if (swzVarSrc[si] == _T('%')) + { + // two %'s in a row in variable name disabled: e.g. %a%%b% - this is atbbguous] + //if (si + 1 < iSourceLen && swzVarSrc[si + 1] == _T('%')) { + // si++; // skip first %, allow following code to add the second one to the variable name + //} else + break; + } + swzVName[v] = swzVarSrc[si]; + v++; si++; + } + + if (v == 0) // bSubst len is 0 - just a % symbol + { + swzDest[di] = _T('%'); + } + else if (si < iSourceLen) // we found end % + { + swzVName[v] = 0; + + bool bAltSubst = false; + bool bSubst = false; + + // apply only to specific protocols + TCHAR *p = _tcsrchr(swzVName, _T('^')); // use last '^', so if you want a ^ in swzAlt text, you can just put a '^' on the end + if (p) + { + *p = 0; + p++; + if (*p) + { + char *cp = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + if (cp != NULL) + { + PROTOACCOUNT *acc = ProtoGetAccount(cp); + if (acc != NULL) + { + cp = acc->szProtoName; + } + } + + if (cp == NULL) + goto empty; + + bool negate = false; + if (*p == _T('!')) + { + p++; + if (*p == 0) goto error; + negate = true; + } + + char sproto[256]; + bool spec = false; + int len; + + TCHAR *last = _tcsrchr(p, _T(',')); + if (!last) last = p; + + while (p <= last + 1) + { + len = (int)_tcscspn(p, _T(",")); + t2a(p, sproto, len); + sproto[len] = 0; + p += len + 1; + + if (_stricmp(cp, sproto) == 0) + { + spec = true; + break; + } + } + + if (negate ? spec : !spec) + goto empty; + } + } + + // get alternate text, if bSubst fails + swzAlt[0] = 0; + p = _tcschr(swzVName, _T('|')); // use first '|' - so you can use the '|' symbol in swzAlt text + if (p) + { + *p = 0; // clip swzAlt from swzVName + p++; + if (_tcslen(p) > 4 && _tcsncmp(p, _T("raw:"), 4) == 0) // raw db substitution + { + char raw_spec[LABEL_LEN]; + p += 4; + t2a(p, raw_spec, LABEL_LEN); + GetRawSubstText(hContact, raw_spec, swzAlt, VALUE_LEN); + } + else if (_tcslen(p) > 4 && _tcsncmp(p, _T("sys:"), 4) == 0) // 'system' substitution + { + p += 4; + GetSysSubstText(hContact, p, swzAlt, VALUE_LEN); + } + else + { + // see if we can find the bSubst + DSListNode *ds_node = opt.dsList; + while(ds_node) + { + if (_tcscmp(ds_node->ds.swzName, p) == 0) + break; + + ds_node = ds_node->next; + } + + if (ds_node) + { + GetSubstText(hContact, ds_node->ds, swzAlt, VALUE_LEN); + } + else + { + _tcsncpy(swzAlt, p, VALUE_LEN); + bAltSubst = true; + } + } + swzAlt[VALUE_LEN - 1] = 0; + if (_tcslen(swzAlt) != 0) + bAltSubst = true; + } + + // get bSubst text + if (v > 4 && _tcsncmp(swzVName, _T("raw:"), 4) == 0) // raw db substitution + { + char raw_spec[LABEL_LEN]; + t2a(&swzVName[4], raw_spec, LABEL_LEN); + bSubst = GetRawSubstText(hContact, raw_spec, swzRep, VALUE_LEN); + } + else if (v > 4 && _tcsncmp(swzVName, _T("sys:"), 4) == 0) // 'system' substitution + { + bSubst = GetSysSubstText(hContact, &swzVName[4], swzRep, VALUE_LEN); + } + else + { + // see if we can find the bSubst + DSListNode *ds_node = opt.dsList; + while(ds_node) + { + if (_tcscmp(ds_node->ds.swzName, swzVName) == 0) + break; + + ds_node = ds_node->next; + } + + if (!ds_node) + goto error; // no such bSubst + + bSubst = GetSubstText(hContact, ds_node->ds, swzRep, VALUE_LEN); + } + + if (bSubst) + { + size_t rep_len = _tcslen(swzRep); + _tcsncpy(&swzDest[di], swzRep, min(rep_len, iDestLen - di)); + di += rep_len - 1; // -1 because we inc at bottom of loop + } + else if (bAltSubst) + { + size_t alt_len = _tcslen(swzAlt); + _tcsncpy(&swzDest[di], swzAlt, min(alt_len, iDestLen - di)); + di += alt_len - 1; // -1 because we inc at bottom of loop + } + else + { + goto empty; // empty value + } + + } + else // no end % - error + { + goto error; + } + } + else + { + swzDest[di] = swzVarSrc[si]; + } + + si++; + di++; + } + + mir_free(swzVarSrc); + swzDest[di] = 0; + + if (parseTipperVarsFirst) + { + swzVarSrc = variables_parsedup((TCHAR *)swzDest, 0, hContact); + _tcscpy(swzDest, swzVarSrc); + mir_free(swzVarSrc); + } + + + // check for a 'blank' string - just spaces etc + for (si = 0; si <= di; si++) + { + if (swzDest[si] != 0 && swzDest[si] != _T(' ') && swzDest[si] != _T('\t') && swzDest[si] != _T('\r') && swzDest[si] != _T('\n')) + return true; + } + + return false; + +empty: + mir_free(swzVarSrc); + return false; + +error: + swzDest[0] = _T('*'); + swzDest[1] = 0; + mir_free(swzVarSrc); + return true; +} + +bool GetLabelText(HANDLE hContact, const DISPLAYITEM &di, TCHAR *buff, int bufflen) +{ + return ApplySubst(hContact, di.swzLabel, false, buff, bufflen); +} + +bool GetValueText(HANDLE hContact, const DISPLAYITEM &di, TCHAR *buff, int bufflen) +{ + return ApplySubst(hContact, di.swzValue, di.bParseTipperVarsFirst, buff, bufflen); +} + +void TruncateString(TCHAR *swzText) +{ + if (swzText && opt.iLimitCharCount > 3) + { + if ((int)_tcslen(swzText) > opt.iLimitCharCount) + { + swzText[opt.iLimitCharCount - 3] = 0; + _tcscat(swzText, _T("...")); + } + } +} + +TCHAR *GetProtoStatusMessage(char *szProto, WORD wStatus) +{ + if (!szProto || wStatus == ID_STATUS_OFFLINE) + return NULL; + + // check if protocol supports status message for status + int flags = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0); + if (!(flags & Proto_Status2Flag(wStatus))) + return NULL; + + TCHAR *swzText = (TCHAR *)CallProtoService(szProto, PS_GETMYAWAYMSG, 0, SGMA_TCHAR); + if ((INT_PTR)swzText == CALLSERVICE_NOTFOUND) + { + swzText = (TCHAR*)CallService(MS_AWAYMSG_GETSTATUSMSGT, wStatus, 0); + } + + else if (swzText == NULL) + { + // try to use service without SGMA_TCHAR + char *tmpMsg = (char *)CallProtoService(szProto, PS_GETMYAWAYMSG, 0, 0); + if (tmpMsg && (INT_PTR)tmpMsg != CALLSERVICE_NOTFOUND) + { + swzText = mir_a2t(tmpMsg); + mir_free(tmpMsg); + } + } + + + if (swzText && !swzText[0]) + { + mir_free(swzText); + swzText = NULL; + } + + if (swzText && opt.bLimitMsg) + TruncateString(swzText); + + return swzText; +} + +TCHAR *GetProtoExtraStatusTitle(char *szProto) +{ + DBVARIANT dbv; + TCHAR *swzText = NULL; + + if (!szProto) + return NULL; + + if (!DBGetContactSettingTString(0, szProto, "XStatusName", &dbv)) + { + if (_tcslen(dbv.ptszVal) != 0) + swzText = mir_tstrdup(dbv.ptszVal); + DBFreeVariant(&dbv); + } + + if (!swzText) + { + TCHAR buff[256]; + if (EmptyXStatusToDefaultName(0, szProto, 0, buff, 256)) + swzText = mir_tstrdup(buff); + } + + if (opt.bLimitMsg) + TruncateString(swzText); + + return swzText; +} + +TCHAR *GetProtoExtraStatusMessage(char *szProto) +{ + DBVARIANT dbv; + TCHAR *swzText = NULL; + + if (!szProto) + return NULL; + + if (!DBGetContactSettingTString(0, szProto, "XStatusMsg", &dbv)) + { + if (_tcslen(dbv.ptszVal) != 0) + swzText = mir_tstrdup(dbv.ptszVal); + DBFreeVariant(&dbv); + + if (ServiceExists(MS_VARS_FORMATSTRING)) + { + HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + char *proto = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + while(!proto) + { + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + if (hContact) + { + proto = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + } + else + { + hContact = NULL; + break; + } + } + + TCHAR *tszParsed = (TCHAR *)variables_parse(swzText, NULL, hContact); + if (tszParsed) + { + mir_free(swzText); + swzText = mir_tstrdup(tszParsed); + variables_free(tszParsed); + } + } + } + + if (opt.bLimitMsg) + TruncateString(swzText); + + return swzText; +} + +TCHAR *GetListeningTo(char *szProto) +{ + DBVARIANT dbv; + TCHAR *swzText = NULL; + + if (!szProto) + return NULL; + + if (!DBGetContactSettingTString(0, szProto, "ListeningTo", &dbv)) + { + if (_tcslen(dbv.ptszVal) != 0) + swzText = mir_tstrdup(dbv.ptszVal); + DBFreeVariant(&dbv); + } + + if (opt.bLimitMsg) + TruncateString(swzText); + + return swzText; +} + +TCHAR *GetJabberAdvStatusText(char *szProto, const char *szSlot, const char *szValue) +{ + DBVARIANT dbv; + TCHAR *swzText = NULL; + char szSetting[128]; + + if (!szProto) + return NULL; + + mir_snprintf(szSetting, SIZEOF(szSetting), "%s/%s/%s", szProto, szSlot, szValue); + if (!DBGetContactSettingTString(0, "AdvStatus", szSetting, &dbv)) + { + if (_tcslen(dbv.ptszVal) != 0) + swzText = mir_tstrdup(dbv.ptszVal); + DBFreeVariant(&dbv); + } + + if (opt.bLimitMsg) + TruncateString(swzText); + + return swzText; +} + +HICON GetJabberActivityIcon(HANDLE hContact, char *szProto) +{ + DBVARIANT dbv; + HICON hIcon = NULL; + char szSetting[128]; + + if (!szProto) + return NULL; + + mir_snprintf(szSetting, SIZEOF(szSetting), "%s/%s/%s", szProto, "activity", "icon"); + if (!DBGetContactSettingString(hContact, "AdvStatus", szSetting, &dbv)) + { + hIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)dbv.pszVal); + DBFreeVariant(&dbv); + } + + return hIcon; +} \ No newline at end of file diff --git a/plugins/TipperYM/src/subst.h b/plugins/TipperYM/src/subst.h new file mode 100644 index 0000000000..41f66f871a --- /dev/null +++ b/plugins/TipperYM/src/subst.h @@ -0,0 +1,47 @@ +/* +Copyright (C) 2006-2007 Scott Ellis +Copyright (C) 2007-2011 Jan Holub + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#ifndef _SUBST_INC +#define _SUBST_INC + +#include "options.h" +#include "translations.h" + +bool GetLabelText(HANDLE hContact, const DISPLAYITEM &di, TCHAR *buff, int iBufflen); +bool GetValueText(HANDLE hContact, const DISPLAYITEM &di, TCHAR *buff, int iBufflen); + +void StripBBCodesInPlace(TCHAR *text); +int ProtoServiceExists(const char *szModule, const char *szService); + +// can be used with hContact == 0 to get uid for a given proto +bool UidName(char *szProto, TCHAR *buff, int bufflen); +bool Uid(HANDLE hContact, char *szProto, TCHAR *buff, int bufflen); + +// get info for status and tray tooltip +bool DBGetContactSettingAsString(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen); +bool CanRetrieveStatusMsg(HANDLE hContact, char *szProto); +TCHAR *GetProtoStatusMessage(char *szProto, WORD status); +TCHAR *GetProtoExtraStatusTitle(char *szProto); +TCHAR *GetProtoExtraStatusMessage(char *szProto); +TCHAR *GetListeningTo(char *szProto); +TCHAR *GetJabberAdvStatusText(char *szProto, const char *szSlot, const char *szValue); +HICON GetJabberActivityIcon(HANDLE hContact, char *szProto); + +#endif diff --git a/plugins/TipperYM/src/tipper.cpp b/plugins/TipperYM/src/tipper.cpp new file mode 100644 index 0000000000..8c0f5575de --- /dev/null +++ b/plugins/TipperYM/src/tipper.cpp @@ -0,0 +1,362 @@ +/* +Copyright (C) 2006-2007 Scott Ellis +Copyright (C) 2007-2011 Jan Holub + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#include "common.h" +#include "version.h" +#include "message_pump.h" +#include "options.h" +#include "popwin.h" +#include "skin_parser.h" +#include "str_utils.h" + +HMODULE hInst; + +char szMetaModuleName[256] = {0}; + +FontIDT fontTitle, fontLabels, fontValues, fontTrayTitle; +ColourIDT colourBg, colourBorder, colourAvatarBorder, colourDivider, colourSidebar; +HFONT hFontTitle, hFontLabels, hFontValues, hFontTrayTitle; + +// hooked here so it's in the main thread +HANDLE hAvChangeEvent, hShowTipEvent, hHideTipEvent, hAckEvent, hFramesSBShow, hFramesSBHide; +HANDLE hSettingChangedEvent, hEventDeleted; +HANDLE hShowTipService, hShowTipWService, hHideTipService; +HANDLE hReloadFonts = NULL; + +HANDLE hFolderChanged, hSkinFolder; +TCHAR SKIN_FOLDER[256]; + +FI_INTERFACE *fii = NULL; +TIME_API tmi; +int hLangpack; + +PLUGININFOEX pluginInfoEx = +{ + sizeof(PLUGININFOEX), + "Tipper YM", + __VERSION_DWORD, + "Tool Tip notification windows.", + "Scott Ellis, yaho", + "yaho@miranda-easy.net", + "© 2005-2007 Scott Ellis, 2007-2011 Jan Holub", + "http://miranda-easy.net/mods.php", + UNICODE_AWARE, //doesn't replace anything built-in + MIID_TIPPER +}; + +extern "C" bool WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + hInst = hinstDLL; + DisableThreadLibraryCalls(hInst); + return TRUE; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfoEx; +} + +extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_TOOLTIPS, MIID_LAST}; + +int ReloadFont(WPARAM wParam, LPARAM lParam) +{ + LOGFONT logFont; + if (hFontTitle) DeleteObject(hFontTitle); + opt.colTitle = CallService(MS_FONT_GETT, (WPARAM)&fontTitle, (LPARAM)&logFont); + hFontTitle = CreateFontIndirect(&logFont); + if (hFontLabels) DeleteObject(hFontLabels); + opt.colLabel = CallService(MS_FONT_GETT, (WPARAM)&fontLabels, (LPARAM)&logFont); + hFontLabels = CreateFontIndirect(&logFont); + if (hFontValues) DeleteObject(hFontValues); + opt.colValue = CallService(MS_FONT_GETT, (WPARAM)&fontValues, (LPARAM)&logFont); + hFontValues = CreateFontIndirect(&logFont); + if (hFontTrayTitle) DeleteObject(hFontTrayTitle); + opt.colTrayTitle = CallService(MS_FONT_GETT, (WPARAM)&fontTrayTitle, (LPARAM)&logFont); + hFontTrayTitle = CreateFontIndirect(&logFont); + + opt.colBg = CallService(MS_COLOUR_GETT, (WPARAM)&colourBg, 0); + opt.colBorder = CallService(MS_COLOUR_GETT, (WPARAM)&colourBorder, 0); + opt.colAvatarBorder = CallService(MS_COLOUR_GETT, (WPARAM)&colourAvatarBorder, 0); + opt.colSidebar = CallService(MS_COLOUR_GETT, (WPARAM)&colourSidebar, 0); + opt.colDivider = CallService(MS_COLOUR_GETT, (WPARAM)&colourDivider, 0); + + return 0; +} + + +// hack to hide tip when clist hides from timeout +int SettingChanged(WPARAM wParam, LPARAM lParam) +{ + DBCONTACTWRITESETTING *dcws = (DBCONTACTWRITESETTING *)lParam; + if (strcmp(dcws->szModule, "CList") != 0 || strcmp(dcws->szSetting, "State") != 0) + return 0; + + // clist hiding + if (dcws->value.type == DBVT_BYTE && dcws->value.bVal == 0) + HideTip(0, 0); + + return 0; +} + +// needed for msg_count_xxx substitutions +int EventDeleted(WPARAM wParam, LPARAM lParam) +{ + DBEVENTINFO dbei = {0}; + dbei.cbSize = sizeof(dbei); + if (!CallService(MS_DB_EVENT_GET, lParam, (LPARAM)&dbei)) + { + if (dbei.eventType == EVENTTYPE_MESSAGE) + DBDeleteContactSetting((HANDLE)wParam, MODULE, "LastCountTS"); + } + + return 0; +} + +int ReloadSkinFolder(WPARAM wParam, LPARAM lParam) +{ + FoldersGetCustomPathT(hSkinFolder, SKIN_FOLDER, SIZEOF(SKIN_FOLDER), _T(DEFAULT_SKIN_FOLDER)); + return 0; +} + +void InitFonts() +{ + colourBg.cbSize = sizeof(ColourIDT); + _tcscpy(colourBg.group, LPGENT("Tooltips")); + _tcscpy(colourBg.name, LPGENT("Background")); + strcpy(colourBg.dbSettingsGroup, MODULE); + strcpy(colourBg.setting, "ColourBg"); + colourBg.defcolour = RGB(219, 219, 219); + colourBg.order = 0; + ColourRegisterT(&colourBg); + + colourBorder.cbSize = sizeof(ColourIDT); + _tcscpy(colourBorder.group, LPGENT("Tooltips")); + _tcscpy(colourBorder.name, LPGENT("Border")); + strcpy(colourBorder.dbSettingsGroup, MODULE); + strcpy(colourBorder.setting, "BorderCol"); + colourBorder.defcolour = 0; + colourBorder.order = 0; + ColourRegisterT(&colourBorder); + + colourAvatarBorder.cbSize = sizeof(ColourIDT); + _tcscpy(colourAvatarBorder.group, LPGENT("Tooltips")); + _tcscpy(colourAvatarBorder.name, LPGENT("Avatar border")); + strcpy(colourAvatarBorder.dbSettingsGroup, MODULE); + strcpy(colourAvatarBorder.setting, "AvBorderCol"); + colourAvatarBorder.defcolour = 0; + colourAvatarBorder.order = 0; + ColourRegisterT(&colourAvatarBorder); + + colourDivider.cbSize = sizeof(ColourIDT); + _tcscpy(colourDivider.group, LPGENT("Tooltips")); + _tcscpy(colourDivider.name, LPGENT("Dividers")); + strcpy(colourDivider.dbSettingsGroup, MODULE); + strcpy(colourDivider.setting, "DividerCol"); + colourDivider.defcolour = 0; + colourDivider.order = 0; + ColourRegisterT(&colourDivider); + + colourSidebar.cbSize = sizeof(ColourIDT); + _tcscpy(colourSidebar.group, LPGENT("Tooltips")); + _tcscpy(colourSidebar.name, LPGENT("Sidebar")); + strcpy(colourSidebar.dbSettingsGroup, MODULE); + strcpy(colourSidebar.setting, "SidebarCol"); + colourSidebar.defcolour = RGB(192, 192, 192); + colourSidebar.order = 0; + ColourRegisterT(&colourSidebar); + + fontTitle.cbSize = sizeof(FontIDT); + fontTitle.flags = FIDF_ALLOWEFFECTS; + _tcscpy(fontTitle.group, LPGENT("Tooltips")); + _tcscpy(fontTitle.name, LPGENT("Title")); + strcpy(fontTitle.dbSettingsGroup, MODULE); + strcpy(fontTitle.prefix, "FontFirst"); + _tcscpy(fontTitle.backgroundGroup, LPGENT("Tooltips")); + _tcscpy(fontTitle.backgroundName, LPGENT("Background")); + fontTitle.order = 0; + + fontTitle.deffontsettings.charset = DEFAULT_CHARSET; + fontTitle.deffontsettings.size = -14; + fontTitle.deffontsettings.style = DBFONTF_BOLD; + fontTitle.deffontsettings.colour = RGB(255, 0, 0); + fontTitle.flags |= FIDF_DEFAULTVALID; + + fontLabels.cbSize = sizeof(FontIDT); + fontLabels.flags = FIDF_ALLOWEFFECTS; + _tcscpy(fontLabels.group, LPGENT("Tooltips")); + _tcscpy(fontLabels.name, LPGENT("Labels")); + strcpy(fontLabels.dbSettingsGroup, MODULE); + strcpy(fontLabels.prefix, "FontLabels"); + _tcscpy(fontLabels.backgroundGroup, LPGENT("Tooltips")); + _tcscpy(fontLabels.backgroundName, LPGENT("Background")); + fontLabels.order = 1; + + fontLabels.deffontsettings.charset = DEFAULT_CHARSET; + fontLabels.deffontsettings.size = -12; + fontLabels.deffontsettings.style = DBFONTF_ITALIC; + fontLabels.deffontsettings.colour = RGB(128, 128, 128); + fontLabels.flags |= FIDF_DEFAULTVALID; + + fontValues.cbSize = sizeof(FontIDT); + fontValues.flags = FIDF_ALLOWEFFECTS; + _tcscpy(fontValues.group, LPGENT("Tooltips")); + _tcscpy(fontValues.name, LPGENT("Values")); + strcpy(fontValues.dbSettingsGroup, MODULE); + strcpy(fontValues.prefix, "FontValues"); + _tcscpy(fontValues.backgroundGroup, LPGENT("Tooltips")); + _tcscpy(fontValues.backgroundName, LPGENT("Background")); + fontValues.order = 2; + + fontValues.deffontsettings.charset = DEFAULT_CHARSET; + fontValues.deffontsettings.size = -12; + fontValues.deffontsettings.style = 0; + fontValues.deffontsettings.colour = RGB(0, 0, 0); + fontValues.flags |= FIDF_DEFAULTVALID; + + fontTrayTitle.cbSize = sizeof(FontIDT); + fontTrayTitle.flags = FIDF_ALLOWEFFECTS; + _tcscpy(fontTrayTitle.group, LPGENT("Tooltips")); + _tcscpy(fontTrayTitle.name, LPGENT("Tray title")); + strcpy(fontTrayTitle.dbSettingsGroup, MODULE); + strcpy(fontTrayTitle.prefix, "FontTrayTitle"); + _tcscpy(fontTrayTitle.backgroundGroup, LPGENT("Tooltips")); + _tcscpy(fontTrayTitle.backgroundName, LPGENT("Background")); + fontTrayTitle.order = 0; + + fontTrayTitle.deffontsettings.charset = DEFAULT_CHARSET; + fontTrayTitle.deffontsettings.size = -14; + fontTrayTitle.deffontsettings.style = DBFONTF_BOLD; + fontTrayTitle.deffontsettings.colour = RGB(0, 0, 0); + fontTrayTitle.flags |= FIDF_DEFAULTVALID; + + FontRegisterT(&fontTitle); + FontRegisterT(&fontLabels); + FontRegisterT(&fontValues); + FontRegisterT(&fontTrayTitle); + + hReloadFonts = HookEvent(ME_FONT_RELOAD, ReloadFont); +} + +int ModulesLoaded(WPARAM wParam, LPARAM lParam) +{ + InitFonts(); + + hAvChangeEvent = HookEvent(ME_AV_AVATARCHANGED, AvatarChanged); + hShowTipEvent = HookEvent(ME_CLC_SHOWINFOTIP, ShowTipHook); + hHideTipEvent = HookEvent(ME_CLC_HIDEINFOTIP, HideTipHook); + hAckEvent = HookEvent(ME_PROTO_ACK, ProtoAck); + + hFramesSBShow = HookEvent(ME_CLIST_FRAMES_SB_SHOW_TOOLTIP, FramesShowSBTip); + hFramesSBHide = HookEvent(ME_CLIST_FRAMES_SB_HIDE_TOOLTIP, FramesHideSBTip); + + hFolderChanged = HookEvent(ME_FOLDERS_PATH_CHANGED, ReloadSkinFolder); + + hSkinFolder = FoldersRegisterCustomPathT(MODULE, "Tipper skins", MIRANDA_PATHT _T("\\") _T(DEFAULT_SKIN_FOLDER)); + FoldersGetCustomPathT(hSkinFolder, SKIN_FOLDER, SIZEOF(SKIN_FOLDER), _T(DEFAULT_SKIN_FOLDER)); + + InitTipperSmileys(); + LoadOptions(); + ReloadFont(0, 0); + ParseSkinFile(opt.szSkinName, true, false); + + // set 'time-in' + CallService(MS_CLC_SETINFOTIPHOVERTIME, opt.iTimeIn, 0); + + // set Miranda start timestamp + DBWriteContactSettingDword(0, MODULE, "MirandaStartTS", (DWORD)time(0)); + + // get MetaContacts module name + if (ServiceExists(MS_MC_GETPROTOCOLNAME)) + strcpy(szMetaModuleName, (char *)CallService(MS_MC_GETPROTOCOLNAME, 0, 0)); + + return 0; +} + +int Shutdown(WPARAM wParam, LPARAM lParam) +{ + if (hFramesSBShow) UnhookEvent(hFramesSBShow); + if (hFramesSBHide) UnhookEvent(hFramesSBHide); + if (hAvChangeEvent) UnhookEvent(hAvChangeEvent); + if (hShowTipEvent) UnhookEvent(hShowTipEvent); + if (hHideTipEvent) UnhookEvent(hHideTipEvent); + if (hAckEvent) UnhookEvent(hAckEvent); + + if (hShowTipService) DestroyServiceFunction(hShowTipService); + if (hShowTipWService) DestroyServiceFunction(hShowTipWService); + if (hHideTipService) DestroyServiceFunction(hHideTipService); + + if (hFolderChanged) UnhookEvent(hFolderChanged); + + DeinitMessagePump(); + DestroySkinBitmap(); + + return 0; +} + +HANDLE hEventPreShutdown, hEventModulesLoaded; + +extern "C" int __declspec(dllexport) Load(void) +{ + + + CallService(MS_IMG_GETINTERFACE, FI_IF_VERSION, (LPARAM)&fii); + mir_getTMI(&tmi); + mir_getLP(&pluginInfoEx); + + if (ServiceExists(MS_LANGPACK_GETCODEPAGE)) + iCodePage = CallService(MS_LANGPACK_GETCODEPAGE, 0, 0); + + InitTranslations(); + InitMessagePump(); + InitOptions(); + + // for compatibility with mToolTip status tooltips + hShowTipService = CreateServiceFunction("mToolTip/ShowTip", ShowTip); + + hShowTipWService = CreateServiceFunction("mToolTip/ShowTipW", ShowTipW); + + hHideTipService = CreateServiceFunction("mToolTip/HideTip", HideTip); + + hEventPreShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, Shutdown); + hEventModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded); + + hSettingChangedEvent = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, SettingChanged); + hEventDeleted = HookEvent(ME_DB_EVENT_DELETED, EventDeleted); + + return 0; +} + +extern "C" int __declspec(dllexport) Unload() +{ + UnhookEvent(hSettingChangedEvent); + UnhookEvent(hEventDeleted); + UnhookEvent(hEventPreShutdown); + UnhookEvent(hEventModulesLoaded); + UnhookEvent(hReloadFonts); + + DeinitOptions(); + DeleteObject(hFontTitle); + DeleteObject(hFontLabels); + DeleteObject(hFontValues); + DeleteObject(hFontTrayTitle); + + DeinitTranslations(); + return 0; +} diff --git a/plugins/TipperYM/src/translations.cpp b/plugins/TipperYM/src/translations.cpp new file mode 100644 index 0000000000..1fd6e67c39 --- /dev/null +++ b/plugins/TipperYM/src/translations.cpp @@ -0,0 +1,744 @@ +/* +Copyright (C) 2006-2007 Scott Ellis +Copyright (C) 2007-2011 Jan Holub + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#include "common.h" +#include "translations.h" +#include "subst.h" +#include "str_utils.h" + +int iTransFuncsCount = 0; +DBVTranslation *translations = 0; + +DWORD dwNextFuncId; +HANDLE hServiceAdd; + + +void AddTranslation(DBVTranslation *newTrans) +{ + iTransFuncsCount++; + + translations = (DBVTranslation *)mir_realloc(translations, sizeof(DBVTranslation) * iTransFuncsCount); + translations[iTransFuncsCount - 1] = *newTrans; + + char *szName = mir_t2a(newTrans->swzName); + char szSetting[256] = "Trans_"; + strcat(szSetting, szName); + + if (_tcscmp(newTrans->swzName, _T("[No translation]")) == 0) + { + translations[iTransFuncsCount - 1].id = 0; + } + else + { + DWORD id = DBGetContactSettingDword(0, MODULE_ITEMS, szSetting, 0); + if (id != 0) + { + translations[iTransFuncsCount - 1].id = id; + if (dwNextFuncId <= id) dwNextFuncId = id + 1; + } + else + { + translations[iTransFuncsCount - 1].id = dwNextFuncId++; + DBWriteContactSettingDword(0, MODULE_ITEMS, szSetting, translations[iTransFuncsCount - 1].id); + } + + DBWriteContactSettingDword(0, MODULE_ITEMS, "NextFuncId", dwNextFuncId); + } + + mir_free(szName); +} + +TCHAR *NullTranslation(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) +{ + if (DBGetContactSettingAsString(hContact, szModuleName, szSettingName, buff, bufflen)) + return buff; + return NULL; +} + +TCHAR *TimestampToShortDate(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) +{ + DWORD ts = DBGetContactSettingDword(hContact, szModuleName, szSettingName, 0); + if (ts == 0) return 0; + + DBTIMETOSTRINGT dbt = {0}; + dbt.cbDest = bufflen; + dbt.szDest = buff; + dbt.szFormat = _T("d"); + CallService(MS_DB_TIME_TIMESTAMPTOSTRINGT, (WPARAM)ts, (LPARAM)&dbt); + return buff; +} + +TCHAR *TimestampToLongDate(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) +{ + DWORD ts = DBGetContactSettingDword(hContact, szModuleName, szSettingName, 0); + if (ts == 0) return 0; + + DBTIMETOSTRINGT dbt = {0}; + dbt.cbDest = bufflen; + dbt.szDest = buff; + dbt.szFormat = _T("D"); + CallService(MS_DB_TIME_TIMESTAMPTOSTRINGT, (WPARAM)ts, (LPARAM)&dbt); + return buff; +} + +TCHAR *TimestampToTime(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) +{ + DWORD ts = DBGetContactSettingDword(hContact, szModuleName, szSettingName, 0); + if (ts == 0) return 0; + + DBTIMETOSTRINGT dbt = {0}; + dbt.cbDest = bufflen; + dbt.szDest = buff; + dbt.szFormat = _T("s"); + CallService(MS_DB_TIME_TIMESTAMPTOSTRINGT, (WPARAM)ts, (LPARAM)&dbt); + return buff; +} + +TCHAR *TimestampToTimeNoSecs(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) +{ + DWORD ts = DBGetContactSettingDword(hContact, szModuleName, szSettingName, 0); + if (ts == 0) return 0; + + DBTIMETOSTRINGT dbt = {0}; + dbt.cbDest = bufflen; + dbt.szDest = buff; + dbt.szFormat = _T("t"); + CallService(MS_DB_TIME_TIMESTAMPTOSTRINGT, (WPARAM)ts, (LPARAM)&dbt); + return buff; +} + +TCHAR *TimestampToTimeDifference(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) +{ + DWORD ts = DBGetContactSettingDword(hContact, szModuleName, szSettingName, 0); + DWORD t = (DWORD)time(0); + if (ts == 0) return 0; + + DWORD diff = (ts > t) ? 0 : (t - ts); + int d = (diff / 60 / 60 / 24); + int h = (diff - d * 60 * 60 * 24) / 60 / 60; + int m = (diff - d * 60 * 60 * 24 - h * 60 * 60) / 60; + if (d > 0) + mir_sntprintf(buff, bufflen, TranslateT("%dd %dh %dm"), d, h, m); + else if (h > 0) + mir_sntprintf(buff, bufflen, TranslateT("%dh %dm"), h, m); + else + mir_sntprintf(buff, bufflen, TranslateT("%dm"), m); + + return buff; +} + +TCHAR *SecondsToTimeDifference(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) +{ + DWORD diff = DBGetContactSettingDword(hContact, szModuleName, szSettingName, 0); + int d = (diff / 60 / 60 / 24); + int h = (diff - d * 60 * 60 * 24) / 60 / 60; + int m = (diff - d * 60 * 60 * 24 - h * 60 * 60) / 60; + if (d > 0) + mir_sntprintf(buff, bufflen, TranslateT("%dd %dh %dm"), d, h, m); + else if (h > 0) + mir_sntprintf(buff, bufflen, TranslateT("%dh %dm"), h, m); + else + mir_sntprintf(buff, bufflen, TranslateT("%dm"), m); + + return buff; +} + +TCHAR *WordToStatusDesc(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) +{ + WORD wStatus = DBGetContactSettingWord(hContact, szModuleName, szSettingName, ID_STATUS_OFFLINE); + TCHAR *szStatus = (TCHAR *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)wStatus, GSMDF_TCHAR); + _tcsncpy(buff,szStatus, bufflen); + buff[bufflen - 1] = 0; + return buff; +} + +TCHAR *ByteToYesNo(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) +{ + DBVARIANT dbv; + if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) + { + if (dbv.type == DBVT_BYTE) + { + if (dbv.bVal != 0) + _tcsncpy(buff, _T("Yes"), bufflen); + else + _tcsncpy(buff, _T("No"), bufflen); + buff[bufflen - 1] = 0; + DBFreeVariant(&dbv); + return buff; + } + DBFreeVariant(&dbv); + } + return 0; +} + +TCHAR *ByteToGender(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) +{ + BYTE val = (BYTE)DBGetContactSettingByte(hContact, szModuleName, szSettingName, 0); + if (val == 'F') + _tcsncpy(buff, TranslateT("Female"), bufflen); + else if (val == 'M') + _tcsncpy(buff, TranslateT("Male"), bufflen); + else + return 0; + + buff[bufflen - 1] = 0; + return buff; +} + +TCHAR *WordToCountry(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) +{ + char *szCountryName = 0; + WORD cid = (WORD)DBGetContactSettingWord(hContact, szModuleName, szSettingName, (WORD)-1); + if (cid != (WORD)-1 && ServiceExists(MS_UTILS_GETCOUNTRYBYNUMBER) && (szCountryName = (char *)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, cid, 0)) != 0) + { + if (strcmp(szCountryName, "Unknown") == 0) + return 0; + a2t(szCountryName, buff, bufflen); + buff[bufflen - 1] = 0; + return buff; + } + return 0; +} + +TCHAR *DwordToIp(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) +{ + DWORD ip = DBGetContactSettingDword(hContact, szModuleName, szSettingName, 0); + if (ip) { + unsigned char *ipc = (unsigned char*)&ip; + mir_sntprintf(buff, bufflen, _T("%u.%u.%u.%u"), ipc[3], ipc[2], ipc[1], ipc[0]); + return buff; + } + return 0; +} + +bool GetInt(const DBVARIANT &dbv, int *iVal) +{ + if (!iVal) return false; + + switch(dbv.type) + { + case DBVT_BYTE: + if (iVal) *iVal = (int)dbv.bVal; + return true; + case DBVT_WORD: + if (iVal) *iVal = (int)dbv.wVal; + return true; + case DBVT_DWORD: + if (iVal) *iVal = (int)dbv.dVal; + return true; + } + return false; +} + +TCHAR *DayMonthYearToDate(HANDLE hContact, const char *szModuleName, const char *prefix, TCHAR *buff, int bufflen) +{ + DBVARIANT dbv; + char szSettingName[256]; + mir_snprintf(szSettingName, 256, "%sDay", prefix); + if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) + { + int day = 0; + if (GetInt(dbv, &day)) + { + DBFreeVariant(&dbv); + mir_snprintf(szSettingName, 256, "%sMonth", prefix); + int month = 0; + if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) + { + if (GetInt(dbv, &month)) + { + DBFreeVariant(&dbv); + mir_snprintf(szSettingName, 256, "%sYear", prefix); + int year = 0; + if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) + { + if (GetInt(dbv, &year)) + { + DBFreeVariant(&dbv); + + SYSTEMTIME st = {0}; + st.wDay = day; + st.wMonth = month; + st.wYear = year; + + GetDateFormat(LOCALE_USER_DEFAULT, 0, &st, 0, buff, bufflen); + return buff; + } + else + DBFreeVariant(&dbv); + } + } + else + DBFreeVariant(&dbv); + } + } + else + DBFreeVariant(&dbv); + } + return 0; +} + +TCHAR *DayMonthYearToAge(HANDLE hContact, const char *szModuleName, const char *szPrefix, TCHAR *buff, int bufflen) +{ + DBVARIANT dbv; + char szSettingName[256]; + mir_snprintf(szSettingName, 256, "%sDay", szPrefix); + if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) + { + int day = 0; + if (GetInt(dbv, &day)) + { + DBFreeVariant(&dbv); + mir_snprintf(szSettingName, 256, "%sMonth", szPrefix); + int month = 0; + if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) + { + if (GetInt(dbv, &month)) + { + DBFreeVariant(&dbv); + mir_snprintf(szSettingName, 256, "%sYear", szPrefix); + int year = 0; + if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) + { + if (GetInt(dbv, &year)) + { + DBFreeVariant(&dbv); + + SYSTEMTIME now; + GetLocalTime(&now); + + int age = now.wYear - year; + if (now.wMonth < month || (now.wMonth == month && now.wDay < day)) + age--; + mir_sntprintf(buff, bufflen, _T("%d"), age); + return buff; + } + else + DBFreeVariant(&dbv); + } + } + else + DBFreeVariant(&dbv); + } + } + else + DBFreeVariant(&dbv); + } + return 0; +} + +TCHAR *HoursMinutesSecondsToTime(HANDLE hContact, const char *szModuleName, const char *szPrefix, TCHAR *buff, int bufflen) +{ + DBVARIANT dbv; + char szSettingName[256]; + mir_snprintf(szSettingName, 256, "%sHours", szPrefix); + if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) + { + int hours = 0; + if (GetInt(dbv, &hours)) + { + DBFreeVariant(&dbv); + mir_snprintf(szSettingName, 256, "%sMinutes", szPrefix); + int minutes = 0; + if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) + { + if (GetInt(dbv, &minutes)) + { + DBFreeVariant(&dbv); + mir_snprintf(szSettingName, 256, "%sSeconds", szPrefix); + int seconds = 0; + if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) + { + GetInt(dbv, &seconds); + DBFreeVariant(&dbv); + } + + SYSTEMTIME st = {0}; + st.wHour = hours; + st.wMinute = minutes; + st.wSecond = seconds; + + GetTimeFormat(LOCALE_USER_DEFAULT, 0, &st, 0, buff, bufflen); + return buff; + } + else + DBFreeVariant(&dbv); + } + } + else + DBFreeVariant(&dbv); + } + return 0; +} + +TCHAR *HoursMinutesToTime(HANDLE hContact, const char *szModuleName, const char *szPrefix, TCHAR *buff, int bufflen) +{ + DBVARIANT dbv; + char szSettingName[256]; + mir_snprintf(szSettingName, 256, "%sHours", szPrefix); + if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) + { + int hours = 0; + if (GetInt(dbv, &hours)) + { + DBFreeVariant(&dbv); + mir_snprintf(szSettingName, 256, "%sMinutes", szPrefix); + int minutes = 0; + if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) + { + if (GetInt(dbv, &minutes)) + { + DBFreeVariant(&dbv); + + SYSTEMTIME st = {0}; + st.wHour = hours; + st.wMinute = minutes; + + GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, 0, buff, bufflen); + return buff; + } + else + DBFreeVariant(&dbv); + } + } + else + DBFreeVariant(&dbv); + } + return 0; +} + +TCHAR *DmyToTimeDifference(HANDLE hContact, const char *szModuleName, const char *szPrefix, TCHAR *buff, int bufflen) +{ + DBVARIANT dbv; + char szSettingName[256]; + mir_snprintf(szSettingName, 256, "%sDay", szPrefix); + if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) + { + int day = 0; + if (GetInt(dbv, &day)) + { + DBFreeVariant(&dbv); + mir_snprintf(szSettingName, 256, "%sMonth", szPrefix); + int month = 0; + if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) + { + if (GetInt(dbv, &month)) + { + DBFreeVariant(&dbv); + mir_snprintf(szSettingName, 256, "%sYear", szPrefix); + int year = 0; + if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) + { + if (GetInt(dbv, &year)) + { + DBFreeVariant(&dbv); + mir_snprintf(szSettingName, 256, "%sHours", szPrefix); + if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) + { + int hours = 0; + if (GetInt(dbv, &hours)) + { + DBFreeVariant(&dbv); + mir_snprintf(szSettingName, 256, "%sMinutes", szPrefix); + int minutes = 0; + if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) + { + if (GetInt(dbv, &minutes)) + { + DBFreeVariant(&dbv); + mir_snprintf(szSettingName, 256, "%sSeconds", szPrefix); + int seconds = 0; + if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) + { + GetInt(dbv, &seconds); + DBFreeVariant(&dbv); + } + + SYSTEMTIME st = {0}, st_now; + st.wDay = day; + st.wMonth = month; + st.wYear = year; + st.wHour = hours; + st.wMinute = minutes; + st.wSecond = seconds; + GetLocalTime(&st_now); + + FILETIME ft, ft_now; + SystemTimeToFileTime(&st, &ft); + SystemTimeToFileTime(&st_now, &ft_now); + + LARGE_INTEGER li, li_now; + li.HighPart = ft.dwHighDateTime; li.LowPart = ft.dwLowDateTime; + li_now.HighPart = ft_now.dwHighDateTime; li_now.LowPart = ft_now.dwLowDateTime; + + long diff = (long)((li_now.QuadPart - li.QuadPart) / (LONGLONG)10000000L); + int y = diff / 60 / 60 / 24 / 365; + int d = (diff - y * 60 * 60 * 24 * 365) / 60 / 60 / 24; + int h = (diff - y * 60 * 60 * 24 * 365 - d * 60 * 60 * 24) / 60 / 60; + int m = (diff - y * 60 * 60 * 24 * 365 - d * 60 * 60 * 24 - h * 60 * 60) / 60; + if (y != 0) + mir_sntprintf(buff, bufflen, TranslateT("%dy %dd %dh %dm"), y, d, h, m); + else if (d != 0) + mir_sntprintf(buff, bufflen, TranslateT("%dd %dh %dm"), d, h, m); + else if (h != 0) + mir_sntprintf(buff, bufflen, TranslateT("%dh %dm"), h, m); + else + mir_sntprintf(buff, bufflen, TranslateT("%dm"), m); + + return buff; + } + else + DBFreeVariant(&dbv); + } + } + else + DBFreeVariant(&dbv); + } + } + else + DBFreeVariant(&dbv); + } + } + else + DBFreeVariant(&dbv); + } + } + else + DBFreeVariant(&dbv); + } + return 0; +} + +TCHAR *DayMonthToDaysToNextBirthday(HANDLE hContact, const char *szModuleName, const char *szPrefix, TCHAR *buff, int bufflen) +{ + DBVARIANT dbv; + char szSettingName[256]; + mir_snprintf(szSettingName, 256, "%sDay", szPrefix); + if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) + { + int day = 0; + if (GetInt(dbv, &day)) + { + DBFreeVariant(&dbv); + mir_snprintf(szSettingName, 256, "%sMonth", szPrefix); + int month = 0; + if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) + { + if (GetInt(dbv, &month)) + { + DBFreeVariant(&dbv); + time_t now = time(NULL); + struct tm *ti = localtime(&now); + int yday_now = ti->tm_yday; + + ti->tm_mday = day; + ti->tm_mon = month - 1; + mktime(ti); + + int yday_birth = ti->tm_yday; + if (yday_birth < yday_now) + { + yday_now -= 365; + yday_now -= (ti->tm_year % 4) ? 0 : 1; + } + + int diff = yday_birth - yday_now; + mir_sntprintf(buff, bufflen, TranslateT("%dd"), diff); + + return buff; + } + else + { + DBFreeVariant(&dbv); + } + } + } + else + { + DBFreeVariant(&dbv); + } + } + return 0; +} + + +TCHAR *EmptyXStatusToDefaultName(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) +{ + TCHAR szDefaultName[1024]; + ICQ_CUSTOM_STATUS xstatus = {0}; + DBVARIANT dbv; + + // translate jabber mood + if (ProtoServiceExists(szModuleName, "/SendXML")) // jabber protocol? + { + if (!DBGetContactSettingTString(hContact, szModuleName, szSettingName, &dbv)) + { + _tcsncpy(buff, TranslateTS(dbv.ptszVal), bufflen); + buff[bufflen - 1] = 0; + return buff; + } + } + + if (NullTranslation(hContact, szModuleName, szSettingName, buff, bufflen)) + return buff; + + int status = DBGetContactSettingByte(hContact, szModuleName, "XStatusId", 0); + if (!status) return 0; + + if (ProtoServiceExists(szModuleName, PS_ICQ_GETCUSTOMSTATUSEX)) + { + xstatus.cbSize = sizeof(ICQ_CUSTOM_STATUS); + xstatus.flags = CSSF_MASK_NAME | CSSF_DEFAULT_NAME | CSSF_TCHAR; + xstatus.ptszName = szDefaultName; + xstatus.wParam = (WPARAM *)&status; + if (CallProtoService(szModuleName, PS_ICQ_GETCUSTOMSTATUSEX, 0, (LPARAM)&xstatus)) + return 0; + + _tcsncpy(buff, TranslateTS(szDefaultName), bufflen); + buff[bufflen - 1] = 0; + return buff; + } + + return 0; +} + +TCHAR *TimezoneToTime(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) +{ + int timezone = DBGetContactSettingByte(hContact,szModuleName,szSettingName,256); + if (timezone==256 || (char)timezone==-100) + return 0; + + TIME_ZONE_INFORMATION tzi; + FILETIME ft; + LARGE_INTEGER lift; + SYSTEMTIME st; + + timezone=(char)timezone; + GetSystemTimeAsFileTime(&ft); + if (GetTimeZoneInformation(&tzi) == TIME_ZONE_ID_DAYLIGHT) + timezone += tzi.DaylightBias / 30; + + lift.QuadPart = *(__int64*)&ft; + lift.QuadPart -= (__int64)timezone * BIGI(30) * BIGI(60) * BIGI(10000000); + *(__int64*)&ft = lift.QuadPart; + FileTimeToSystemTime(&ft, &st); + GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, buff, bufflen); + + return buff; +} + +TCHAR *ByteToDay(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) +{ + int iDay = DBGetContactSettingWord(hContact, szModuleName, szSettingName, -1); + if (iDay > -1 && iDay < 7) + { + a2t(Translate(days[iDay]), buff, bufflen); + buff[bufflen - 1] = 0; + return buff; + } + + return 0; +} + +TCHAR *ByteToMonth(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) +{ + int iMonth = DBGetContactSettingWord(hContact, szModuleName, szSettingName, 0); + if (iMonth > 0 && iMonth < 13) + { + a2t(Translate(months[iMonth - 1]), buff, bufflen); + buff[bufflen - 1] = 0; + return buff; + } + + return 0; +} + +TCHAR *ByteToLanguage(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) +{ + int iLang = DBGetContactSettingByte(hContact, szModuleName, szSettingName, 0); + if (iLang) + { + for (int i = 0; i < SIZEOF(languages); i++) + { + if (iLang == languages[i].id) + { + a2t(Translate(languages[i].szValue), buff, bufflen); + buff[bufflen - 1] = 0; + return buff; + } + } + } + + return 0; +} + +INT_PTR ServiceAddTranslation(WPARAM wParam, LPARAM lParam) +{ + if (!lParam) return 1; + + DBVTranslation *trans = (DBVTranslation *)lParam; + AddTranslation(trans); + + return 0; +} + +static DBVTranslation internalTranslations[] = +{ + { NullTranslation, _T("[No translation]") }, + { WordToStatusDesc, _T("WORD to status description") }, + { TimestampToTime, _T("DWORD timestamp to time") }, + { TimestampToTimeDifference, _T("DWORD timestamp to time difference") }, + { ByteToYesNo, _T("BYTE to Yes/No") }, + { ByteToGender, _T("BYTE to Male/Female (ICQ)") }, + { WordToCountry, _T("WORD to country name") }, + { DwordToIp, _T("DWORD to ip address") }, + { DayMonthYearToDate, _T("Day|Month|Year to date") }, + { DayMonthYearToAge, _T("Day|Month|Year to age") }, + { HoursMinutesSecondsToTime, _T("Hours|Minutes|Seconds to time") }, + { DmyToTimeDifference, _T("Day|Month|Year|Hours|Minutes|Seconds to time difference") }, + { DayMonthToDaysToNextBirthday, _T("Day|Month to days to next birthday") }, + { TimestampToTimeNoSecs, _T("DWORD timestamp to time (no seconds)") }, + { HoursMinutesToTime, _T("Hours|Minutes to time") }, + { TimestampToShortDate, _T("DWORD timestamp to date (short)") }, + { TimestampToLongDate, _T("DWORD timestamp to date (long)") }, + { EmptyXStatusToDefaultName, _T("xStatus: empty xStatus name to default name") }, + { SecondsToTimeDifference, _T("DWORD seconds to time difference") }, + { TimezoneToTime, _T("BYTE timezone to time") }, + { ByteToDay, _T("WORD to name of a day (0..6, 0 is Sunday)") }, + { ByteToMonth, _T("WORD to name of a month (1..12, 1 is January)") }, + { ByteToLanguage, _T("BYTE to language (ICQ)") }, +}; + +void InitTranslations() +{ + dwNextFuncId = DBGetContactSettingDword(0, MODULE_ITEMS, "NextFuncId", 1); + for (int i = 0; i < SIZEOF(internalTranslations); i++) + AddTranslation( &internalTranslations[i] ); + + hServiceAdd = CreateServiceFunction(MS_TIPPER_ADDTRANSLATION, ServiceAddTranslation); +} + +void DeinitTranslations() +{ + DestroyServiceFunction(hServiceAdd); + mir_free(translations); +} + diff --git a/plugins/TipperYM/src/translations.h b/plugins/TipperYM/src/translations.h new file mode 100644 index 0000000000..985920054e --- /dev/null +++ b/plugins/TipperYM/src/translations.h @@ -0,0 +1,125 @@ +/* +Copyright (C) 2006-2007 Scott Ellis +Copyright (C) 2007-2011 Jan Holub + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + +#ifndef _TRANSLATIONS_INC +#define _TRANSLATIONS_INC + +extern int iTransFuncsCount; +extern DBVTranslation *translations; + +typedef struct { + int id; + char *szValue; +} LISTTYPEDATAITEM; + +static LISTTYPEDATAITEM languages[] = { + {0, LPGEN("None")}, + {55,LPGEN("Afrikaans")}, + {58,LPGEN("Albanian")}, + {1, LPGEN("Arabic")}, + {59,LPGEN("Armenian")}, + {68,LPGEN("Azerbaijani")}, + {72,LPGEN("Belorussian")}, + {2, LPGEN("Bhojpuri")}, + {56,LPGEN("Bosnian")}, + {3, LPGEN("Bulgarian")}, + {4, LPGEN("Burmese")}, + {5, LPGEN("Cantonese")}, + {6, LPGEN("Catalan")}, + {61,LPGEN("Chamorro")}, + {7, LPGEN("Chinese")}, + {8, LPGEN("Croatian")}, + {9, LPGEN("Czech")}, + {10,LPGEN("Danish")}, + {11,LPGEN("Dutch")}, + {12,LPGEN("English")}, + {13,LPGEN("Esperanto")}, + {14,LPGEN("Estonian")}, + {15,LPGEN("Farsi")}, + {16,LPGEN("Finnish")}, + {17,LPGEN("French")}, + {18,LPGEN("Gaelic")}, + {19,LPGEN("German")}, + {20,LPGEN("Greek")}, + {70,LPGEN("Gujarati")}, + {21,LPGEN("Hebrew")}, + {22,LPGEN("Hindi")}, + {23,LPGEN("Hungarian")}, + {24,LPGEN("Icelandic")}, + {25,LPGEN("Indonesian")}, + {26,LPGEN("Italian")}, + {27,LPGEN("Japanese")}, + {28,LPGEN("Khmer")}, + {29,LPGEN("Korean")}, + {69,LPGEN("Kurdish")}, + {30,LPGEN("Lao")}, + {31,LPGEN("Latvian")}, + {32,LPGEN("Lithuanian")}, + {65,LPGEN("Macedonian")}, + {33,LPGEN("Malay")}, + {63,LPGEN("Mandarin")}, + {62,LPGEN("Mongolian")}, + {34,LPGEN("Norwegian")}, + {57,LPGEN("Persian")}, + {35,LPGEN("Polish")}, + {36,LPGEN("Portuguese")}, + {60,LPGEN("Punjabi")}, + {37,LPGEN("Romanian")}, + {38,LPGEN("Russian")}, + {39,LPGEN("Serbo-Croatian")}, + {66,LPGEN("Sindhi")}, + {40,LPGEN("Slovak")}, + {41,LPGEN("Slovenian")}, + {42,LPGEN("Somali")}, + {43,LPGEN("Spanish")}, + {44,LPGEN("Swahili")}, + {45,LPGEN("Swedish")}, + {46,LPGEN("Tagalog")}, + {64,LPGEN("Taiwanese")}, + {71,LPGEN("Tamil")}, + {47,LPGEN("Tatar")}, + {48,LPGEN("Thai")}, + {49,LPGEN("Turkish")}, + {50,LPGEN("Ukrainian")}, + {51,LPGEN("Urdu")}, + {52,LPGEN("Vietnamese")}, + {67,LPGEN("Welsh")}, + {53,LPGEN("Yiddish")}, + {54,LPGEN("Yoruba")}, +}; + +static char *days[7] = { + LPGEN("Sunday"), LPGEN("Monday"), LPGEN("Tuesday"), LPGEN("Wednesday"), LPGEN("Thursday"), LPGEN("Friday"), LPGEN("Saturday") +}; + +static char *months[12] = { + LPGEN("January"), LPGEN("February"), LPGEN("March"), LPGEN("April"), LPGEN("May"), LPGEN("June"), + LPGEN("July"), LPGEN("August"), LPGEN("September"), LPGEN("October"), LPGEN("November"), LPGEN("December") +}; + +void InitTranslations(); +void DeinitTranslations(); + +TCHAR *TimestampToTimeDifference(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen); +TCHAR *EmptyXStatusToDefaultName(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen); +TCHAR *WordToStatusDesc(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen); + + +#endif diff --git a/plugins/TipperYM/src/version.h b/plugins/TipperYM/src/version.h new file mode 100644 index 0000000000..c71b187bc0 --- /dev/null +++ b/plugins/TipperYM/src/version.h @@ -0,0 +1,4 @@ +#define __FILEVERSION_STRING 2,1,0,4 +#define __VERSION_STRING "2.1.0.4" +#define __VERSION_DWORD PLUGIN_MAKE_VERSION(2, 1, 0, 4) + diff --git a/plugins/TipperYM/str_utils.cpp b/plugins/TipperYM/str_utils.cpp deleted file mode 100644 index 112cc2678b..0000000000 --- a/plugins/TipperYM/str_utils.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/* -Copyright (C) 2006-2007 Scott Ellis -Copyright (C) 2007-2011 Jan Holub - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this file; see the file license.txt. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. -*/ - -#include "common.h" -#include "str_utils.h" - -int iCodePage = CP_ACP; - -bool a2w(const char *as, wchar_t *buff, int bufflen) -{ - if (as) MultiByteToWideChar(iCodePage, 0, as, -1, buff, bufflen); - return true; -} - -bool w2a(const wchar_t *ws, char *buff, int bufflen) -{ - if (ws) WideCharToMultiByte(iCodePage, 0, ws, -1, buff, bufflen, 0, 0); - return true; -} - -bool utf2w(const char *us, wchar_t *buff, int bufflen) -{ - if (us) MultiByteToWideChar(CP_UTF8, 0, us, -1, buff, bufflen); - return true; -} - -bool w2utf(const wchar_t *ws, char *buff, int bufflen) -{ - if (ws) WideCharToMultiByte(CP_UTF8, 0, ws, -1, buff, bufflen, 0, 0); - return true; -} - -bool a2utf(const char *as, char *buff, int bufflen) -{ - if (!as) return false; - - wchar_t *ws = a2w(as); - if (ws) WideCharToMultiByte(CP_UTF8, 0, ws, -1, buff, bufflen, 0, 0); - mir_free(ws); - return true; -} - -bool utf2a(const char *us, char *buff, int bufflen) -{ - if (!us) return false; - - wchar_t *ws = utf2w(us); - if (ws) WideCharToMultiByte(iCodePage, 0, ws, -1, buff, bufflen, 0, 0); - mir_free(ws); - return true; -} - - -bool t2w(const TCHAR *ts, wchar_t *buff, int bufflen) -{ - - wcsncpy(buff, ts, bufflen); - return true; - -} - -bool w2t(const wchar_t *ws, TCHAR *buff, int bufflen) -{ - - wcsncpy(buff, ws, bufflen); - return true; - -} - -bool t2a(const TCHAR *ts, char *buff, int bufflen) -{ - - return w2a(ts, buff, bufflen); - -} - -bool a2t(const char *as, TCHAR *buff, int bufflen) -{ - - return a2w(as, buff, bufflen); - -} - -bool t2utf(const TCHAR *ts, char *buff, int bufflen) -{ - - return w2utf(ts, buff, bufflen); - -} - -bool utf2t(const char *us, TCHAR *buff, int bufflen) -{ - - return utf2w(us, buff, bufflen); - -} - -wchar_t *utf2w(const char *us) -{ - if (us) - { - int size = MultiByteToWideChar(CP_UTF8, 0, us, -1, 0, 0); - wchar_t *buff = (wchar_t *)mir_alloc(size * sizeof(wchar_t)); - MultiByteToWideChar(CP_UTF8, 0, us, -1, buff, size); - return buff; - } - else - { - return 0; - } -} - -char *w2utf(const wchar_t *ws) -{ - if (ws) - { - int size = WideCharToMultiByte(CP_UTF8, 0, ws, -1, 0, 0, 0, 0); - char *buff = (char *)mir_alloc(size); - WideCharToMultiByte(CP_UTF8, 0, ws, -1, buff, size, 0, 0); - return buff; - } - else - { - return 0; - } -} - -wchar_t *a2w(const char *as) -{ - int size = MultiByteToWideChar(iCodePage, 0, as, -1, 0, 0); - wchar_t *buff = (wchar_t *)mir_alloc(size * sizeof(wchar_t)); - MultiByteToWideChar(iCodePage, 0, as, -1, buff, size); - return buff; -} - -char *w2a(const wchar_t *ws) -{ - int size = WideCharToMultiByte(iCodePage, 0, ws, -1, 0, 0, 0, 0); - char *buff = (char *)mir_alloc(size); - WideCharToMultiByte(iCodePage, 0, ws, -1, buff, size, 0, 0); - return buff; -} - -char *utf2a(const char *utfs) -{ - wchar_t *ws = utf2w(utfs); - char *ret = w2a(ws); - mir_free(ws); - return ret; -} - -char *a2utf(const char *as) -{ - wchar_t *ws = a2w(as); - char *ret = w2utf(ws); - mir_free(ws); - return ret; -} - -TCHAR *w2t(const wchar_t *ws) -{ - - return mir_wstrdup(ws); - -} - -wchar_t *t2w(const TCHAR *ts) -{ - - return mir_tstrdup(ts); - -} - - -char *t2a(const TCHAR *ts) -{ - - return w2a(ts); - -} - -TCHAR *a2t(const char *as) -{ - - return a2w(as); - -} - -TCHAR *utf2t(const char *utfs) -{ - - return utf2w(utfs); -} - -char *t2utf(const TCHAR *ts) -{ - - return w2utf(ts); -} - -TCHAR *myfgets(TCHAR *Buf, int MaxCount, FILE *File) -{ - _fgetts(Buf, MaxCount, File); - for (size_t i = _tcslen(Buf) - 1; i >= 0; i--) - { - if (Buf[i] == '\n' || Buf[i] == ' ') - Buf[i] = 0; - else - break; - } - - CharLower(Buf); - return Buf; -} \ No newline at end of file diff --git a/plugins/TipperYM/str_utils.h b/plugins/TipperYM/str_utils.h deleted file mode 100644 index 26fbb613fa..0000000000 --- a/plugins/TipperYM/str_utils.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -Copyright (C) 2006-2007 Scott Ellis -Copyright (C) 2007-2011 Jan Holub - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this file; see the file license.txt. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. -*/ - -#ifndef _STR_UTILS_INC -#define _STR_UTILS_INC - -void set_codepage(); - -bool a2w(const char *as, wchar_t *buff, int bufflen); -bool w2a(const wchar_t *ws, char *buff, int bufflen); - -bool utf2w(const char *us, wchar_t *buff, int bufflen); -bool w2utf(const wchar_t *ws, char *buff, int bufflen); - -bool a2utf(const char *as, char *buff, int bufflen); -bool utf2a(const char *ws, char *buff, int bufflen); - -bool t2w(const TCHAR *ts, wchar_t *buff, int bufflen); -bool w2t(const wchar_t *ws, TCHAR *buff, int bufflen); - -bool t2a(const TCHAR *ts, char *buff, int bufflen); -bool a2t(const char *as, TCHAR *buff, int bufflen); - -bool t2utf(const TCHAR *ts, char *buff, int bufflen); -bool utf2t(const char *us, TCHAR *buff, int bufflen); - -// remember to free return value -wchar_t *a2w(const char *as); -char *w2a(const wchar_t *ws); - -wchar_t *utf2w(const char *us); -char *w2utf(const wchar_t *ws); - -char *utf2a(const char *us); -char *a2utf(const char *as); - -wchar_t *t2w(const TCHAR *ts); -TCHAR *w2t(const wchar_t *ws); - -TCHAR *utf2t(const char *us); -char *t2utf(const TCHAR *ts); - -char *t2a(const TCHAR *ts); -TCHAR *a2t(const char *as); - -TCHAR *myfgets(TCHAR *Buf, int MaxCount, FILE *File); - -#endif - diff --git a/plugins/TipperYM/subst.cpp b/plugins/TipperYM/subst.cpp deleted file mode 100644 index 1d8c8837d9..0000000000 --- a/plugins/TipperYM/subst.cpp +++ /dev/null @@ -1,1011 +0,0 @@ -/* -Copyright (C) 2006-2007 Scott Ellis -Copyright (C) 2007-2011 Jan Holub - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this file; see the file license.txt. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. -*/ - -#include "common.h" -#include "subst.h" -#include "str_utils.h" -#include "popwin.h" - - -int ProtoServiceExists(const char *szModule, const char *szService) -{ - char str[MAXMODULELABELLENGTH]; - strcpy(str,szModule); - strcat(str,szService); - return ServiceExists(str); -} - -bool DBGetContactSettingAsString(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) -{ - DBVARIANT dbv; - buff[0] = 0; - - if (!szModuleName || !szSettingName) - return false; - - if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) - { - switch(dbv.type) - { - case DBVT_BYTE: - _itot(dbv.bVal, buff, 10); - break; - case DBVT_WORD: - _ltot(dbv.wVal, buff, 10); - break; - case DBVT_DWORD: - _ltot(dbv.dVal, buff, 10); - break; - case DBVT_ASCIIZ: - if (dbv.pszVal) a2t(dbv.pszVal, buff, bufflen); - buff[bufflen - 1] = 0; - break; - case DBVT_UTF8: - if (dbv.pszVal) utf2t(dbv.pszVal, buff, bufflen); - buff[bufflen - 1] = 0; - break; - - case DBVT_WCHAR: - if (dbv.pwszVal) wcsncpy(buff, dbv.pwszVal, bufflen); - buff[bufflen - 1] = 0; - break; - - } - - DBFreeVariant(&dbv); - } - - return buff[0] ? true : false; -} - -void StripBBCodesInPlace(TCHAR *swzText) -{ - if (!DBGetContactSettingByte(0, MODULE, "StripBBCodes", 1)) - return; - - if (swzText == 0) - return; - - size_t iRead = 0, iWrite = 0; - size_t iLen = _tcslen(swzText); - - while(iRead <= iLen) // copy terminating null too - { - while(iRead <= iLen && swzText[iRead] != '[') - { - if (swzText[iRead] != swzText[iWrite]) swzText[iWrite] = swzText[iRead]; - iRead++; iWrite++; - } - - if (iRead > iLen) - break; - - if (iLen - iRead >= 3 && (_tcsnicmp(swzText + iRead, _T("[b]"), 3) == 0 || _tcsnicmp(swzText + iRead, _T("[i]"), 3) == 0)) - iRead += 3; - else if (iLen - iRead >= 4 && (_tcsnicmp(swzText + iRead, _T("[/b]"), 4) == 0 || _tcsnicmp(swzText + iRead, _T("[/i]"), 4) == 0)) - iRead += 4; - else if (iLen - iRead >= 6 && (_tcsnicmp(swzText + iRead, _T("[color"), 6) == 0)) - { - while(iRead < iLen && swzText[iRead] != ']') iRead++; - iRead++;// skip the ']' - } - else if (iLen - iRead >= 8 && (_tcsnicmp(swzText + iRead, _T("[/color]"), 8) == 0)) - iRead += 8; - else if (iLen - iRead >= 5 && (_tcsnicmp(swzText + iRead, _T("[size"), 5) == 0)) - { - while(iRead < iLen && swzText[iRead] != ']') iRead++; - iRead++;// skip the ']' - } - else if (iLen - iRead >= 7 && (_tcsnicmp(swzText + iRead, _T("[/size]"), 7) == 0)) - iRead += 7; - else - { - if (swzText[iRead] != swzText[iWrite]) swzText[iWrite] = swzText[iRead]; - iRead++; iWrite++; - } - } -} - -DWORD LastMessageTimestamp(HANDLE hContact) -{ - DBEVENTINFO dbei = {0}; - dbei.cbSize = sizeof(dbei); - HANDLE hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hContact, 0); - while (hDbEvent) - { - dbei.cbBlob = 0; - CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei); - if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT)) - break; - - hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hDbEvent, 0); - } - - if (hDbEvent) - return dbei.timestamp; - - return 0; -} - -void FormatTimestamp(DWORD ts, char *szFormat, TCHAR *buff, int bufflen) -{ - TCHAR swzForm[16]; - DBTIMETOSTRINGT dbt = {0}; - dbt.cbDest = bufflen; - dbt.szDest = buff; - a2t(szFormat, swzForm, 16); - dbt.szFormat = swzForm; - CallService(MS_DB_TIME_TIMESTAMPTOSTRINGT, (WPARAM)ts, (LPARAM)&dbt); -} - -bool Uid(HANDLE hContact, char *szProto, TCHAR *buff, int bufflen) -{ - char *tmpProto = NULL; - - if (hContact) tmpProto = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact, 0); - else tmpProto = szProto; - - if (tmpProto) - { - char *szUid = ( char* )CallProtoService(tmpProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); - if (szUid && (INT_PTR)szUid != CALLSERVICE_NOTFOUND) - return DBGetContactSettingAsString(hContact, tmpProto, szUid, buff, bufflen); - } - - return false; -} - -bool UidName(char *szProto, TCHAR *buff, int bufflen) -{ - if (szProto) - { - char *szUidName = ( char* )CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDTEXT, 0); - if (szUidName && (INT_PTR)szUidName != CALLSERVICE_NOTFOUND) - { - a2t(szUidName, buff, bufflen); - return true; - } - } - return false; -} - -TCHAR *GetLastMessageText(HANDLE hContact) -{ - DBEVENTINFO dbei = {0}; - dbei.cbSize = sizeof(dbei); - - HANDLE hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hContact, 0); - while (hDbEvent) - { - dbei.cbBlob = 0; - CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei); - if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT)) - break; - - hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hDbEvent, 0); - } - - if (hDbEvent) - { - dbei.pBlob = (BYTE *)alloca(dbei.cbBlob); - CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei); - - if (dbei.cbBlob == 0 || dbei.pBlob == 0) - return 0; - - TCHAR *buff = DbGetEventTextT( &dbei, CP_ACP ); - TCHAR *swzMsg = mir_tstrdup(buff); - mir_free(buff); - - StripBBCodesInPlace(swzMsg); - return swzMsg; - } - - return 0; -} - -bool CanRetrieveStatusMsg(HANDLE hContact, char *szProto) -{ - if (opt.bGetNewStatusMsg) - { - int iFlags = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0); - WORD wStatus = DBGetContactSettingWord(hContact, szProto, "Status", ID_STATUS_OFFLINE); - if ((CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) && (iFlags & Proto_Status2Flag(wStatus))) - { - iFlags = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & (PF1_VISLIST | PF1_INVISLIST); - if (opt.bDisableIfInvisible && iFlags) - { - int iVisMode = DBGetContactSettingWord(hContact, szProto, "ApparentMode", 0); - int wProtoStatus = CallProtoService(szProto, PS_GETSTATUS, 0, 0); - if ((iVisMode == ID_STATUS_OFFLINE) || (wProtoStatus == ID_STATUS_INVISIBLE && iVisMode != ID_STATUS_ONLINE)) - return false; - else - return true; - } - else - { - return true; - } - } - else - { - return false; - } - } - - return false; -} - -TCHAR *GetStatusMessageText(HANDLE hContact) -{ - TCHAR *swzMsg = 0; - DBVARIANT dbv; - - char *szProto = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if (szProto) - { - if (!strcmp(szProto, szMetaModuleName)) - { - hContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0); - } - else - { - WORD wStatus = (int)CallProtoService(szProto, PS_GETSTATUS, 0, 0); - if (wStatus == ID_STATUS_OFFLINE) - return NULL; - - if (!DBGetContactSettingTString(hContact, MODULE, "TempStatusMsg", &dbv)) - { - if (_tcslen(dbv.ptszVal) != 0) - swzMsg = mir_tstrdup(dbv.ptszVal); - DBFreeVariant(&dbv); - } - } - - if (!swzMsg) - { - if (CanRetrieveStatusMsg(hContact, szProto)) - { - if (CallContactService(hContact, PSS_GETAWAYMSG, 0, 0)) - return NULL; - } - - if (!DBGetContactSettingTString(hContact, "CList", "StatusMsg", &dbv)) - { - if (dbv.ptszVal && _tcslen(dbv.ptszVal) != 0) - swzMsg = mir_tstrdup(dbv.ptszVal); - DBFreeVariant(&dbv); - } - } - } - - if (swzMsg) - StripBBCodesInPlace(swzMsg); - - return swzMsg; -} - -bool GetSysSubstText(HANDLE hContact, TCHAR *swzRawSpec, TCHAR *buff, int bufflen) -{ - if (!_tcscmp(swzRawSpec, _T("uid"))) - { - return Uid(hContact, 0, buff, bufflen); - } - else if (!_tcscmp(swzRawSpec, _T("proto"))) - { - char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if (szProto) - { - a2t(szProto, buff, bufflen); - return true; - } - } - else if (!_tcscmp(swzRawSpec, _T("account"))) - { - char *szProto = ( char* )CallService(MS_PROTO_GETCONTACTBASEACCOUNT, (WPARAM)hContact, 0); - if ((INT_PTR)szProto == CALLSERVICE_NOTFOUND) - { - return GetSysSubstText(hContact, _T("proto"), buff, bufflen); - } - else if (szProto) - { - PROTOACCOUNT *pa = ProtoGetAccount(szProto); - if (pa && pa->tszAccountName) - { - _tcsncpy(buff, pa->tszAccountName, bufflen); - return true; - } - else - return GetSysSubstText(hContact, _T("proto"), buff, bufflen); - } - } - else if (!_tcscmp(swzRawSpec, _T("time"))) - { - if (tmi.printDateTime && !tmi.printDateTimeByContact(hContact, _T("t"), buff, bufflen, TZF_KNOWNONLY)) - return true; - } - else if (!_tcscmp(swzRawSpec, _T("uidname"))) - { - char *szProto = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - return UidName(szProto, buff, bufflen); - } - else if (!_tcscmp(swzRawSpec, _T("status_msg"))) - { - TCHAR *swzMsg = GetStatusMessageText(hContact); - if (swzMsg) - { - _tcsncpy(buff, swzMsg, bufflen); - mir_free(swzMsg); - return true; - } - } - else if (!_tcscmp(swzRawSpec, _T("last_msg"))) - { - TCHAR *swzMsg = GetLastMessageText(hContact); - if (swzMsg) - { - _tcsncpy(buff, swzMsg, bufflen); - mir_free(swzMsg); - return true; - } - } - else if (!_tcscmp(swzRawSpec, _T("meta_subname"))) - { - // get contact list name of active subcontact - HANDLE hSubContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0); - if (!hSubContact || (INT_PTR)hSubContact == CALLSERVICE_NOTFOUND) return false; - TCHAR *swzNick = (TCHAR *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hSubContact, GCDNF_TCHAR); - if (swzNick) _tcsncpy(buff, swzNick, bufflen); - return true; - } - else if (!_tcscmp(swzRawSpec, _T("meta_subuid"))) - { - HANDLE hSubContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0); - if (!hSubContact || (INT_PTR)hSubContact == CALLSERVICE_NOTFOUND) return false; - return Uid(hSubContact, 0, buff, bufflen); - } - else if (!_tcscmp(swzRawSpec, _T("meta_subproto"))) - { - // get protocol of active subcontact - HANDLE hSubContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0); - if (!hSubContact || (INT_PTR)hSubContact == CALLSERVICE_NOTFOUND) - return false; - return GetSysSubstText(hSubContact, _T("account"), buff, bufflen); - } - else if (!_tcscmp(swzRawSpec, _T("last_msg_time"))) - { - DWORD ts = LastMessageTimestamp(hContact); - if (ts == 0) return false; - FormatTimestamp(ts, "t", buff, bufflen); - return true; - } - else if (!_tcscmp(swzRawSpec, _T("last_msg_date"))) - { - DWORD ts = LastMessageTimestamp(hContact); - if (ts == 0) return false; - FormatTimestamp(ts, "d", buff, bufflen); - return true; - } - else if (!_tcscmp(swzRawSpec, _T("last_msg_reltime"))) - { - DWORD ts = LastMessageTimestamp(hContact); - if (ts == 0) return false; - DWORD t = (DWORD)time(0); - DWORD diff = (t - ts); - int d = (diff / 60 / 60 / 24); - int h = (diff - d * 60 * 60 * 24) / 60 / 60; - int m = (diff - d * 60 * 60 * 24 - h * 60 * 60) / 60; - if (d > 0) mir_sntprintf(buff, bufflen, TranslateT("%dd %dh %dm"), d, h, m); - else if (h > 0) mir_sntprintf(buff, bufflen, TranslateT("%dh %dm"), h, m); - else mir_sntprintf(buff, bufflen, TranslateT("%dm"), m); - return true; - } - else if (!_tcscmp(swzRawSpec, _T("msg_count_all")) || !_tcscmp(swzRawSpec, _T("msg_count_out")) || !_tcscmp(swzRawSpec, _T("msg_count_in"))) - { - DWORD dwCountOut, dwCountIn; - DWORD dwMetaCountOut = 0, dwMetaCountIn = 0; - DWORD dwLastTs, dwNewTs, dwRecountTs; - DWORD dwTime, dwDiff; - int iNumber = 1; - HANDLE hTmpContact = hContact; - - char *szProto = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if (szProto && !strcmp(szProto, szMetaModuleName)) - { - iNumber = CallService(MS_MC_GETNUMCONTACTS, (WPARAM)hContact, 0); - hTmpContact = (HANDLE)CallService(MS_MC_GETSUBCONTACT, (WPARAM)hContact, 0); - } - - for (int i = 0; i < iNumber; i++) - { - if (i > 0) hTmpContact = (HANDLE)CallService(MS_MC_GETSUBCONTACT, (WPARAM)hContact, i); - dwRecountTs = DBGetContactSettingDword(hTmpContact, MODULE, "LastCountTS", 0); - dwTime = (DWORD)time(0); - dwDiff = (dwTime - dwRecountTs); - if (dwDiff > (60 * 60 * 24 * 3)) - { - DBWriteContactSettingDword(hTmpContact, MODULE, "LastCountTS", dwTime); - dwCountOut = dwCountIn = dwLastTs = 0; - } - else - { - dwCountOut = DBGetContactSettingDword(hTmpContact, MODULE, "MsgCountOut", 0); - dwCountIn = DBGetContactSettingDword(hTmpContact, MODULE, "MsgCountIn", 0); - dwLastTs = DBGetContactSettingDword(hTmpContact, MODULE, "LastMsgTS", 0); - } - - dwNewTs = dwLastTs; - - HANDLE dbe = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hTmpContact, 0); - while (dbe != NULL) - { - DBEVENTINFO dbei = {0}; - dbei.cbSize = sizeof(dbei); - if (!CallService(MS_DB_EVENT_GET, (WPARAM)dbe, (LPARAM)&dbei)) - { - if (dbei.eventType == EVENTTYPE_MESSAGE) - { - dwNewTs = max(dwNewTs, dbei.timestamp); - if (dbei.timestamp > dwLastTs) - { - if (dbei.flags & DBEF_SENT) dwCountOut++; - else dwCountIn++; - } - else - break; - } - } - dbe = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)dbe, 0); - } - - if (dwNewTs > dwLastTs) - { - DBWriteContactSettingDword(hTmpContact, MODULE, "MsgCountOut", dwCountOut); - DBWriteContactSettingDword(hTmpContact, MODULE, "MsgCountIn", dwCountIn); - DBWriteContactSettingDword(hTmpContact, MODULE, "LastMsgTS", dwNewTs); - } - - dwMetaCountOut += dwCountOut; - dwMetaCountIn += dwCountIn; - } - - if (!_tcscmp(swzRawSpec, _T("msg_count_out"))) - mir_sntprintf(buff, bufflen, _T("%d"), dwMetaCountOut); - else if (!_tcscmp(swzRawSpec, _T("msg_count_in"))) - mir_sntprintf(buff, bufflen, _T("%d"), dwMetaCountIn); - else - mir_sntprintf(buff, bufflen, _T("%d"), dwMetaCountOut + dwMetaCountIn); - return true; - } - - return false; -} - -bool GetSubstText(HANDLE hContact, const DISPLAYSUBST &ds, TCHAR *buff, int bufflen) -{ - TranslateFunc *transFunc = 0; - for (int i = 0; i < iTransFuncsCount; i++) - { - if (translations[i].id == (DWORD)ds.iTranslateFuncId) - { - transFunc = translations[i].transFunc; - break; - } - } - - if (!transFunc) - return false; - - switch (ds.type) - { - case DVT_DB: - return transFunc(hContact, ds.szModuleName, ds.szSettingName, buff, bufflen) != 0; - case DVT_PROTODB: - { - char *szProto = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if (szProto) - { - if (transFunc(hContact, szProto, ds.szSettingName, buff, bufflen) != 0) - return true; - else - return transFunc(hContact, "UserInfo", ds.szSettingName, buff, bufflen) != 0; - } - break; - } - } - return false; -} - -bool GetRawSubstText(HANDLE hContact, char *szRawSpec, TCHAR *buff, int bufflen) -{ - size_t lenght = strlen(szRawSpec); - for (size_t i = 0; i < lenght; i++) - { - if (szRawSpec[i] == '/') - { - szRawSpec[i] = 0; - if (strlen(szRawSpec) == 0) - { - char *szProto = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if (szProto) - { - if (translations[0].transFunc(hContact, szProto, &szRawSpec[i + 1], buff, bufflen) != 0) - return true; - else - return translations[0].transFunc(hContact, "UserInfo", &szRawSpec[i + 1], buff, bufflen) != 0; - } - else - { - return false; - } - } - else - { - return translations[0].transFunc(hContact, szRawSpec, &szRawSpec[i + 1], buff, bufflen) != 0; - } - } - } - return false; -} - -bool ApplySubst(HANDLE hContact, const TCHAR *swzSource, bool parseTipperVarsFirst, TCHAR *swzDest, int iDestLen) -{ - // hack - allow empty strings before passing to variables (note - zero length strings return false after this) - if (swzDest && swzSource && _tcslen(swzSource) == 0) { - swzDest[0] = 0; - return true; - } - - // pass to variables plugin if available - TCHAR *swzVarSrc; - if (parseTipperVarsFirst == false) - swzVarSrc = variables_parsedup((TCHAR *)swzSource, 0, hContact); - else - swzVarSrc = mir_tstrdup(swzSource); - - size_t iSourceLen = _tcslen(swzVarSrc); - size_t si = 0, di = 0, v = 0; - - TCHAR swzVName[LABEL_LEN]; - TCHAR swzRep[VALUE_LEN], swzAlt[VALUE_LEN]; - while (si < iSourceLen && di < (size_t)iDestLen - 1) - { - if (swzVarSrc[si] == _T('%')) - { - si++; - v = 0; - while (si < iSourceLen && v < LABEL_LEN) - { - if (swzVarSrc[si] == _T('%')) - { - // two %'s in a row in variable name disabled: e.g. %a%%b% - this is atbbguous] - //if (si + 1 < iSourceLen && swzVarSrc[si + 1] == _T('%')) { - // si++; // skip first %, allow following code to add the second one to the variable name - //} else - break; - } - swzVName[v] = swzVarSrc[si]; - v++; si++; - } - - if (v == 0) // bSubst len is 0 - just a % symbol - { - swzDest[di] = _T('%'); - } - else if (si < iSourceLen) // we found end % - { - swzVName[v] = 0; - - bool bAltSubst = false; - bool bSubst = false; - - // apply only to specific protocols - TCHAR *p = _tcsrchr(swzVName, _T('^')); // use last '^', so if you want a ^ in swzAlt text, you can just put a '^' on the end - if (p) - { - *p = 0; - p++; - if (*p) - { - char *cp = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if (cp != NULL) - { - PROTOACCOUNT *acc = ProtoGetAccount(cp); - if (acc != NULL) - { - cp = acc->szProtoName; - } - } - - if (cp == NULL) - goto empty; - - bool negate = false; - if (*p == _T('!')) - { - p++; - if (*p == 0) goto error; - negate = true; - } - - char sproto[256]; - bool spec = false; - int len; - - TCHAR *last = _tcsrchr(p, _T(',')); - if (!last) last = p; - - while (p <= last + 1) - { - len = (int)_tcscspn(p, _T(",")); - t2a(p, sproto, len); - sproto[len] = 0; - p += len + 1; - - if (_stricmp(cp, sproto) == 0) - { - spec = true; - break; - } - } - - if (negate ? spec : !spec) - goto empty; - } - } - - // get alternate text, if bSubst fails - swzAlt[0] = 0; - p = _tcschr(swzVName, _T('|')); // use first '|' - so you can use the '|' symbol in swzAlt text - if (p) - { - *p = 0; // clip swzAlt from swzVName - p++; - if (_tcslen(p) > 4 && _tcsncmp(p, _T("raw:"), 4) == 0) // raw db substitution - { - char raw_spec[LABEL_LEN]; - p += 4; - t2a(p, raw_spec, LABEL_LEN); - GetRawSubstText(hContact, raw_spec, swzAlt, VALUE_LEN); - } - else if (_tcslen(p) > 4 && _tcsncmp(p, _T("sys:"), 4) == 0) // 'system' substitution - { - p += 4; - GetSysSubstText(hContact, p, swzAlt, VALUE_LEN); - } - else - { - // see if we can find the bSubst - DSListNode *ds_node = opt.dsList; - while(ds_node) - { - if (_tcscmp(ds_node->ds.swzName, p) == 0) - break; - - ds_node = ds_node->next; - } - - if (ds_node) - { - GetSubstText(hContact, ds_node->ds, swzAlt, VALUE_LEN); - } - else - { - _tcsncpy(swzAlt, p, VALUE_LEN); - bAltSubst = true; - } - } - swzAlt[VALUE_LEN - 1] = 0; - if (_tcslen(swzAlt) != 0) - bAltSubst = true; - } - - // get bSubst text - if (v > 4 && _tcsncmp(swzVName, _T("raw:"), 4) == 0) // raw db substitution - { - char raw_spec[LABEL_LEN]; - t2a(&swzVName[4], raw_spec, LABEL_LEN); - bSubst = GetRawSubstText(hContact, raw_spec, swzRep, VALUE_LEN); - } - else if (v > 4 && _tcsncmp(swzVName, _T("sys:"), 4) == 0) // 'system' substitution - { - bSubst = GetSysSubstText(hContact, &swzVName[4], swzRep, VALUE_LEN); - } - else - { - // see if we can find the bSubst - DSListNode *ds_node = opt.dsList; - while(ds_node) - { - if (_tcscmp(ds_node->ds.swzName, swzVName) == 0) - break; - - ds_node = ds_node->next; - } - - if (!ds_node) - goto error; // no such bSubst - - bSubst = GetSubstText(hContact, ds_node->ds, swzRep, VALUE_LEN); - } - - if (bSubst) - { - size_t rep_len = _tcslen(swzRep); - _tcsncpy(&swzDest[di], swzRep, min(rep_len, iDestLen - di)); - di += rep_len - 1; // -1 because we inc at bottom of loop - } - else if (bAltSubst) - { - size_t alt_len = _tcslen(swzAlt); - _tcsncpy(&swzDest[di], swzAlt, min(alt_len, iDestLen - di)); - di += alt_len - 1; // -1 because we inc at bottom of loop - } - else - { - goto empty; // empty value - } - - } - else // no end % - error - { - goto error; - } - } - else - { - swzDest[di] = swzVarSrc[si]; - } - - si++; - di++; - } - - mir_free(swzVarSrc); - swzDest[di] = 0; - - if (parseTipperVarsFirst) - { - swzVarSrc = variables_parsedup((TCHAR *)swzDest, 0, hContact); - _tcscpy(swzDest, swzVarSrc); - mir_free(swzVarSrc); - } - - - // check for a 'blank' string - just spaces etc - for (si = 0; si <= di; si++) - { - if (swzDest[si] != 0 && swzDest[si] != _T(' ') && swzDest[si] != _T('\t') && swzDest[si] != _T('\r') && swzDest[si] != _T('\n')) - return true; - } - - return false; - -empty: - mir_free(swzVarSrc); - return false; - -error: - swzDest[0] = _T('*'); - swzDest[1] = 0; - mir_free(swzVarSrc); - return true; -} - -bool GetLabelText(HANDLE hContact, const DISPLAYITEM &di, TCHAR *buff, int bufflen) -{ - return ApplySubst(hContact, di.swzLabel, false, buff, bufflen); -} - -bool GetValueText(HANDLE hContact, const DISPLAYITEM &di, TCHAR *buff, int bufflen) -{ - return ApplySubst(hContact, di.swzValue, di.bParseTipperVarsFirst, buff, bufflen); -} - -void TruncateString(TCHAR *swzText) -{ - if (swzText && opt.iLimitCharCount > 3) - { - if ((int)_tcslen(swzText) > opt.iLimitCharCount) - { - swzText[opt.iLimitCharCount - 3] = 0; - _tcscat(swzText, _T("...")); - } - } -} - -TCHAR *GetProtoStatusMessage(char *szProto, WORD wStatus) -{ - if (!szProto || wStatus == ID_STATUS_OFFLINE) - return NULL; - - // check if protocol supports status message for status - int flags = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0); - if (!(flags & Proto_Status2Flag(wStatus))) - return NULL; - - TCHAR *swzText = (TCHAR *)CallProtoService(szProto, PS_GETMYAWAYMSG, 0, SGMA_TCHAR); - if ((INT_PTR)swzText == CALLSERVICE_NOTFOUND) - { - swzText = (TCHAR*)CallService(MS_AWAYMSG_GETSTATUSMSGT, wStatus, 0); - } - - else if (swzText == NULL) - { - // try to use service without SGMA_TCHAR - char *tmpMsg = (char *)CallProtoService(szProto, PS_GETMYAWAYMSG, 0, 0); - if (tmpMsg && (INT_PTR)tmpMsg != CALLSERVICE_NOTFOUND) - { - swzText = mir_a2t(tmpMsg); - mir_free(tmpMsg); - } - } - - - if (swzText && !swzText[0]) - { - mir_free(swzText); - swzText = NULL; - } - - if (swzText && opt.bLimitMsg) - TruncateString(swzText); - - return swzText; -} - -TCHAR *GetProtoExtraStatusTitle(char *szProto) -{ - DBVARIANT dbv; - TCHAR *swzText = NULL; - - if (!szProto) - return NULL; - - if (!DBGetContactSettingTString(0, szProto, "XStatusName", &dbv)) - { - if (_tcslen(dbv.ptszVal) != 0) - swzText = mir_tstrdup(dbv.ptszVal); - DBFreeVariant(&dbv); - } - - if (!swzText) - { - TCHAR buff[256]; - if (EmptyXStatusToDefaultName(0, szProto, 0, buff, 256)) - swzText = mir_tstrdup(buff); - } - - if (opt.bLimitMsg) - TruncateString(swzText); - - return swzText; -} - -TCHAR *GetProtoExtraStatusMessage(char *szProto) -{ - DBVARIANT dbv; - TCHAR *swzText = NULL; - - if (!szProto) - return NULL; - - if (!DBGetContactSettingTString(0, szProto, "XStatusMsg", &dbv)) - { - if (_tcslen(dbv.ptszVal) != 0) - swzText = mir_tstrdup(dbv.ptszVal); - DBFreeVariant(&dbv); - - if (ServiceExists(MS_VARS_FORMATSTRING)) - { - HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - char *proto = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - while(!proto) - { - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); - if (hContact) - { - proto = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - } - else - { - hContact = NULL; - break; - } - } - - TCHAR *tszParsed = (TCHAR *)variables_parse(swzText, NULL, hContact); - if (tszParsed) - { - mir_free(swzText); - swzText = mir_tstrdup(tszParsed); - variables_free(tszParsed); - } - } - } - - if (opt.bLimitMsg) - TruncateString(swzText); - - return swzText; -} - -TCHAR *GetListeningTo(char *szProto) -{ - DBVARIANT dbv; - TCHAR *swzText = NULL; - - if (!szProto) - return NULL; - - if (!DBGetContactSettingTString(0, szProto, "ListeningTo", &dbv)) - { - if (_tcslen(dbv.ptszVal) != 0) - swzText = mir_tstrdup(dbv.ptszVal); - DBFreeVariant(&dbv); - } - - if (opt.bLimitMsg) - TruncateString(swzText); - - return swzText; -} - -TCHAR *GetJabberAdvStatusText(char *szProto, const char *szSlot, const char *szValue) -{ - DBVARIANT dbv; - TCHAR *swzText = NULL; - char szSetting[128]; - - if (!szProto) - return NULL; - - mir_snprintf(szSetting, SIZEOF(szSetting), "%s/%s/%s", szProto, szSlot, szValue); - if (!DBGetContactSettingTString(0, "AdvStatus", szSetting, &dbv)) - { - if (_tcslen(dbv.ptszVal) != 0) - swzText = mir_tstrdup(dbv.ptszVal); - DBFreeVariant(&dbv); - } - - if (opt.bLimitMsg) - TruncateString(swzText); - - return swzText; -} - -HICON GetJabberActivityIcon(HANDLE hContact, char *szProto) -{ - DBVARIANT dbv; - HICON hIcon = NULL; - char szSetting[128]; - - if (!szProto) - return NULL; - - mir_snprintf(szSetting, SIZEOF(szSetting), "%s/%s/%s", szProto, "activity", "icon"); - if (!DBGetContactSettingString(hContact, "AdvStatus", szSetting, &dbv)) - { - hIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)dbv.pszVal); - DBFreeVariant(&dbv); - } - - return hIcon; -} \ No newline at end of file diff --git a/plugins/TipperYM/subst.h b/plugins/TipperYM/subst.h deleted file mode 100644 index 41f66f871a..0000000000 --- a/plugins/TipperYM/subst.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -Copyright (C) 2006-2007 Scott Ellis -Copyright (C) 2007-2011 Jan Holub - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this file; see the file license.txt. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. -*/ - -#ifndef _SUBST_INC -#define _SUBST_INC - -#include "options.h" -#include "translations.h" - -bool GetLabelText(HANDLE hContact, const DISPLAYITEM &di, TCHAR *buff, int iBufflen); -bool GetValueText(HANDLE hContact, const DISPLAYITEM &di, TCHAR *buff, int iBufflen); - -void StripBBCodesInPlace(TCHAR *text); -int ProtoServiceExists(const char *szModule, const char *szService); - -// can be used with hContact == 0 to get uid for a given proto -bool UidName(char *szProto, TCHAR *buff, int bufflen); -bool Uid(HANDLE hContact, char *szProto, TCHAR *buff, int bufflen); - -// get info for status and tray tooltip -bool DBGetContactSettingAsString(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen); -bool CanRetrieveStatusMsg(HANDLE hContact, char *szProto); -TCHAR *GetProtoStatusMessage(char *szProto, WORD status); -TCHAR *GetProtoExtraStatusTitle(char *szProto); -TCHAR *GetProtoExtraStatusMessage(char *szProto); -TCHAR *GetListeningTo(char *szProto); -TCHAR *GetJabberAdvStatusText(char *szProto, const char *szSlot, const char *szValue); -HICON GetJabberActivityIcon(HANDLE hContact, char *szProto); - -#endif diff --git a/plugins/TipperYM/tipper.cpp b/plugins/TipperYM/tipper.cpp deleted file mode 100644 index 8c0f5575de..0000000000 --- a/plugins/TipperYM/tipper.cpp +++ /dev/null @@ -1,362 +0,0 @@ -/* -Copyright (C) 2006-2007 Scott Ellis -Copyright (C) 2007-2011 Jan Holub - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this file; see the file license.txt. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. -*/ - -#include "common.h" -#include "version.h" -#include "message_pump.h" -#include "options.h" -#include "popwin.h" -#include "skin_parser.h" -#include "str_utils.h" - -HMODULE hInst; - -char szMetaModuleName[256] = {0}; - -FontIDT fontTitle, fontLabels, fontValues, fontTrayTitle; -ColourIDT colourBg, colourBorder, colourAvatarBorder, colourDivider, colourSidebar; -HFONT hFontTitle, hFontLabels, hFontValues, hFontTrayTitle; - -// hooked here so it's in the main thread -HANDLE hAvChangeEvent, hShowTipEvent, hHideTipEvent, hAckEvent, hFramesSBShow, hFramesSBHide; -HANDLE hSettingChangedEvent, hEventDeleted; -HANDLE hShowTipService, hShowTipWService, hHideTipService; -HANDLE hReloadFonts = NULL; - -HANDLE hFolderChanged, hSkinFolder; -TCHAR SKIN_FOLDER[256]; - -FI_INTERFACE *fii = NULL; -TIME_API tmi; -int hLangpack; - -PLUGININFOEX pluginInfoEx = -{ - sizeof(PLUGININFOEX), - "Tipper YM", - __VERSION_DWORD, - "Tool Tip notification windows.", - "Scott Ellis, yaho", - "yaho@miranda-easy.net", - "© 2005-2007 Scott Ellis, 2007-2011 Jan Holub", - "http://miranda-easy.net/mods.php", - UNICODE_AWARE, //doesn't replace anything built-in - MIID_TIPPER -}; - -extern "C" bool WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - hInst = hinstDLL; - DisableThreadLibraryCalls(hInst); - return TRUE; -} - -extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) -{ - return &pluginInfoEx; -} - -extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_TOOLTIPS, MIID_LAST}; - -int ReloadFont(WPARAM wParam, LPARAM lParam) -{ - LOGFONT logFont; - if (hFontTitle) DeleteObject(hFontTitle); - opt.colTitle = CallService(MS_FONT_GETT, (WPARAM)&fontTitle, (LPARAM)&logFont); - hFontTitle = CreateFontIndirect(&logFont); - if (hFontLabels) DeleteObject(hFontLabels); - opt.colLabel = CallService(MS_FONT_GETT, (WPARAM)&fontLabels, (LPARAM)&logFont); - hFontLabels = CreateFontIndirect(&logFont); - if (hFontValues) DeleteObject(hFontValues); - opt.colValue = CallService(MS_FONT_GETT, (WPARAM)&fontValues, (LPARAM)&logFont); - hFontValues = CreateFontIndirect(&logFont); - if (hFontTrayTitle) DeleteObject(hFontTrayTitle); - opt.colTrayTitle = CallService(MS_FONT_GETT, (WPARAM)&fontTrayTitle, (LPARAM)&logFont); - hFontTrayTitle = CreateFontIndirect(&logFont); - - opt.colBg = CallService(MS_COLOUR_GETT, (WPARAM)&colourBg, 0); - opt.colBorder = CallService(MS_COLOUR_GETT, (WPARAM)&colourBorder, 0); - opt.colAvatarBorder = CallService(MS_COLOUR_GETT, (WPARAM)&colourAvatarBorder, 0); - opt.colSidebar = CallService(MS_COLOUR_GETT, (WPARAM)&colourSidebar, 0); - opt.colDivider = CallService(MS_COLOUR_GETT, (WPARAM)&colourDivider, 0); - - return 0; -} - - -// hack to hide tip when clist hides from timeout -int SettingChanged(WPARAM wParam, LPARAM lParam) -{ - DBCONTACTWRITESETTING *dcws = (DBCONTACTWRITESETTING *)lParam; - if (strcmp(dcws->szModule, "CList") != 0 || strcmp(dcws->szSetting, "State") != 0) - return 0; - - // clist hiding - if (dcws->value.type == DBVT_BYTE && dcws->value.bVal == 0) - HideTip(0, 0); - - return 0; -} - -// needed for msg_count_xxx substitutions -int EventDeleted(WPARAM wParam, LPARAM lParam) -{ - DBEVENTINFO dbei = {0}; - dbei.cbSize = sizeof(dbei); - if (!CallService(MS_DB_EVENT_GET, lParam, (LPARAM)&dbei)) - { - if (dbei.eventType == EVENTTYPE_MESSAGE) - DBDeleteContactSetting((HANDLE)wParam, MODULE, "LastCountTS"); - } - - return 0; -} - -int ReloadSkinFolder(WPARAM wParam, LPARAM lParam) -{ - FoldersGetCustomPathT(hSkinFolder, SKIN_FOLDER, SIZEOF(SKIN_FOLDER), _T(DEFAULT_SKIN_FOLDER)); - return 0; -} - -void InitFonts() -{ - colourBg.cbSize = sizeof(ColourIDT); - _tcscpy(colourBg.group, LPGENT("Tooltips")); - _tcscpy(colourBg.name, LPGENT("Background")); - strcpy(colourBg.dbSettingsGroup, MODULE); - strcpy(colourBg.setting, "ColourBg"); - colourBg.defcolour = RGB(219, 219, 219); - colourBg.order = 0; - ColourRegisterT(&colourBg); - - colourBorder.cbSize = sizeof(ColourIDT); - _tcscpy(colourBorder.group, LPGENT("Tooltips")); - _tcscpy(colourBorder.name, LPGENT("Border")); - strcpy(colourBorder.dbSettingsGroup, MODULE); - strcpy(colourBorder.setting, "BorderCol"); - colourBorder.defcolour = 0; - colourBorder.order = 0; - ColourRegisterT(&colourBorder); - - colourAvatarBorder.cbSize = sizeof(ColourIDT); - _tcscpy(colourAvatarBorder.group, LPGENT("Tooltips")); - _tcscpy(colourAvatarBorder.name, LPGENT("Avatar border")); - strcpy(colourAvatarBorder.dbSettingsGroup, MODULE); - strcpy(colourAvatarBorder.setting, "AvBorderCol"); - colourAvatarBorder.defcolour = 0; - colourAvatarBorder.order = 0; - ColourRegisterT(&colourAvatarBorder); - - colourDivider.cbSize = sizeof(ColourIDT); - _tcscpy(colourDivider.group, LPGENT("Tooltips")); - _tcscpy(colourDivider.name, LPGENT("Dividers")); - strcpy(colourDivider.dbSettingsGroup, MODULE); - strcpy(colourDivider.setting, "DividerCol"); - colourDivider.defcolour = 0; - colourDivider.order = 0; - ColourRegisterT(&colourDivider); - - colourSidebar.cbSize = sizeof(ColourIDT); - _tcscpy(colourSidebar.group, LPGENT("Tooltips")); - _tcscpy(colourSidebar.name, LPGENT("Sidebar")); - strcpy(colourSidebar.dbSettingsGroup, MODULE); - strcpy(colourSidebar.setting, "SidebarCol"); - colourSidebar.defcolour = RGB(192, 192, 192); - colourSidebar.order = 0; - ColourRegisterT(&colourSidebar); - - fontTitle.cbSize = sizeof(FontIDT); - fontTitle.flags = FIDF_ALLOWEFFECTS; - _tcscpy(fontTitle.group, LPGENT("Tooltips")); - _tcscpy(fontTitle.name, LPGENT("Title")); - strcpy(fontTitle.dbSettingsGroup, MODULE); - strcpy(fontTitle.prefix, "FontFirst"); - _tcscpy(fontTitle.backgroundGroup, LPGENT("Tooltips")); - _tcscpy(fontTitle.backgroundName, LPGENT("Background")); - fontTitle.order = 0; - - fontTitle.deffontsettings.charset = DEFAULT_CHARSET; - fontTitle.deffontsettings.size = -14; - fontTitle.deffontsettings.style = DBFONTF_BOLD; - fontTitle.deffontsettings.colour = RGB(255, 0, 0); - fontTitle.flags |= FIDF_DEFAULTVALID; - - fontLabels.cbSize = sizeof(FontIDT); - fontLabels.flags = FIDF_ALLOWEFFECTS; - _tcscpy(fontLabels.group, LPGENT("Tooltips")); - _tcscpy(fontLabels.name, LPGENT("Labels")); - strcpy(fontLabels.dbSettingsGroup, MODULE); - strcpy(fontLabels.prefix, "FontLabels"); - _tcscpy(fontLabels.backgroundGroup, LPGENT("Tooltips")); - _tcscpy(fontLabels.backgroundName, LPGENT("Background")); - fontLabels.order = 1; - - fontLabels.deffontsettings.charset = DEFAULT_CHARSET; - fontLabels.deffontsettings.size = -12; - fontLabels.deffontsettings.style = DBFONTF_ITALIC; - fontLabels.deffontsettings.colour = RGB(128, 128, 128); - fontLabels.flags |= FIDF_DEFAULTVALID; - - fontValues.cbSize = sizeof(FontIDT); - fontValues.flags = FIDF_ALLOWEFFECTS; - _tcscpy(fontValues.group, LPGENT("Tooltips")); - _tcscpy(fontValues.name, LPGENT("Values")); - strcpy(fontValues.dbSettingsGroup, MODULE); - strcpy(fontValues.prefix, "FontValues"); - _tcscpy(fontValues.backgroundGroup, LPGENT("Tooltips")); - _tcscpy(fontValues.backgroundName, LPGENT("Background")); - fontValues.order = 2; - - fontValues.deffontsettings.charset = DEFAULT_CHARSET; - fontValues.deffontsettings.size = -12; - fontValues.deffontsettings.style = 0; - fontValues.deffontsettings.colour = RGB(0, 0, 0); - fontValues.flags |= FIDF_DEFAULTVALID; - - fontTrayTitle.cbSize = sizeof(FontIDT); - fontTrayTitle.flags = FIDF_ALLOWEFFECTS; - _tcscpy(fontTrayTitle.group, LPGENT("Tooltips")); - _tcscpy(fontTrayTitle.name, LPGENT("Tray title")); - strcpy(fontTrayTitle.dbSettingsGroup, MODULE); - strcpy(fontTrayTitle.prefix, "FontTrayTitle"); - _tcscpy(fontTrayTitle.backgroundGroup, LPGENT("Tooltips")); - _tcscpy(fontTrayTitle.backgroundName, LPGENT("Background")); - fontTrayTitle.order = 0; - - fontTrayTitle.deffontsettings.charset = DEFAULT_CHARSET; - fontTrayTitle.deffontsettings.size = -14; - fontTrayTitle.deffontsettings.style = DBFONTF_BOLD; - fontTrayTitle.deffontsettings.colour = RGB(0, 0, 0); - fontTrayTitle.flags |= FIDF_DEFAULTVALID; - - FontRegisterT(&fontTitle); - FontRegisterT(&fontLabels); - FontRegisterT(&fontValues); - FontRegisterT(&fontTrayTitle); - - hReloadFonts = HookEvent(ME_FONT_RELOAD, ReloadFont); -} - -int ModulesLoaded(WPARAM wParam, LPARAM lParam) -{ - InitFonts(); - - hAvChangeEvent = HookEvent(ME_AV_AVATARCHANGED, AvatarChanged); - hShowTipEvent = HookEvent(ME_CLC_SHOWINFOTIP, ShowTipHook); - hHideTipEvent = HookEvent(ME_CLC_HIDEINFOTIP, HideTipHook); - hAckEvent = HookEvent(ME_PROTO_ACK, ProtoAck); - - hFramesSBShow = HookEvent(ME_CLIST_FRAMES_SB_SHOW_TOOLTIP, FramesShowSBTip); - hFramesSBHide = HookEvent(ME_CLIST_FRAMES_SB_HIDE_TOOLTIP, FramesHideSBTip); - - hFolderChanged = HookEvent(ME_FOLDERS_PATH_CHANGED, ReloadSkinFolder); - - hSkinFolder = FoldersRegisterCustomPathT(MODULE, "Tipper skins", MIRANDA_PATHT _T("\\") _T(DEFAULT_SKIN_FOLDER)); - FoldersGetCustomPathT(hSkinFolder, SKIN_FOLDER, SIZEOF(SKIN_FOLDER), _T(DEFAULT_SKIN_FOLDER)); - - InitTipperSmileys(); - LoadOptions(); - ReloadFont(0, 0); - ParseSkinFile(opt.szSkinName, true, false); - - // set 'time-in' - CallService(MS_CLC_SETINFOTIPHOVERTIME, opt.iTimeIn, 0); - - // set Miranda start timestamp - DBWriteContactSettingDword(0, MODULE, "MirandaStartTS", (DWORD)time(0)); - - // get MetaContacts module name - if (ServiceExists(MS_MC_GETPROTOCOLNAME)) - strcpy(szMetaModuleName, (char *)CallService(MS_MC_GETPROTOCOLNAME, 0, 0)); - - return 0; -} - -int Shutdown(WPARAM wParam, LPARAM lParam) -{ - if (hFramesSBShow) UnhookEvent(hFramesSBShow); - if (hFramesSBHide) UnhookEvent(hFramesSBHide); - if (hAvChangeEvent) UnhookEvent(hAvChangeEvent); - if (hShowTipEvent) UnhookEvent(hShowTipEvent); - if (hHideTipEvent) UnhookEvent(hHideTipEvent); - if (hAckEvent) UnhookEvent(hAckEvent); - - if (hShowTipService) DestroyServiceFunction(hShowTipService); - if (hShowTipWService) DestroyServiceFunction(hShowTipWService); - if (hHideTipService) DestroyServiceFunction(hHideTipService); - - if (hFolderChanged) UnhookEvent(hFolderChanged); - - DeinitMessagePump(); - DestroySkinBitmap(); - - return 0; -} - -HANDLE hEventPreShutdown, hEventModulesLoaded; - -extern "C" int __declspec(dllexport) Load(void) -{ - - - CallService(MS_IMG_GETINTERFACE, FI_IF_VERSION, (LPARAM)&fii); - mir_getTMI(&tmi); - mir_getLP(&pluginInfoEx); - - if (ServiceExists(MS_LANGPACK_GETCODEPAGE)) - iCodePage = CallService(MS_LANGPACK_GETCODEPAGE, 0, 0); - - InitTranslations(); - InitMessagePump(); - InitOptions(); - - // for compatibility with mToolTip status tooltips - hShowTipService = CreateServiceFunction("mToolTip/ShowTip", ShowTip); - - hShowTipWService = CreateServiceFunction("mToolTip/ShowTipW", ShowTipW); - - hHideTipService = CreateServiceFunction("mToolTip/HideTip", HideTip); - - hEventPreShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, Shutdown); - hEventModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded); - - hSettingChangedEvent = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, SettingChanged); - hEventDeleted = HookEvent(ME_DB_EVENT_DELETED, EventDeleted); - - return 0; -} - -extern "C" int __declspec(dllexport) Unload() -{ - UnhookEvent(hSettingChangedEvent); - UnhookEvent(hEventDeleted); - UnhookEvent(hEventPreShutdown); - UnhookEvent(hEventModulesLoaded); - UnhookEvent(hReloadFonts); - - DeinitOptions(); - DeleteObject(hFontTitle); - DeleteObject(hFontLabels); - DeleteObject(hFontValues); - DeleteObject(hFontTrayTitle); - - DeinitTranslations(); - return 0; -} diff --git a/plugins/TipperYM/tipper_ym_10.vcxproj b/plugins/TipperYM/tipper_ym_10.vcxproj index 9f1780e597..4cea23b995 100644 --- a/plugins/TipperYM/tipper_ym_10.vcxproj +++ b/plugins/TipperYM/tipper_ym_10.vcxproj @@ -73,14 +73,13 @@ Disabled ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;TIPPER_EXPORTS;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL Use common.h EditAndContinue - 4996;%(DisableSpecificWarnings) Level3 @@ -100,14 +99,13 @@ Disabled ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN64;_DEBUG;_WINDOWS;_USRDLL;TIPPER_EXPORTS;%(PreprocessorDefinitions) + WIN64;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL Use common.h Level3 - 4996;%(DisableSpecificWarnings) comctl32.lib;msimg32.lib;%(AdditionalDependencies) @@ -130,11 +128,10 @@ Full Size ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;TIPPER_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true Use common.h - 4996;%(DisableSpecificWarnings) Level3 @@ -157,12 +154,11 @@ Full Size ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN64;NDEBUG;_WINDOWS;_USRDLL;TIPPER_EXPORTS;%(PreprocessorDefinitions) + WIN64;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true Use common.h Level3 - 4996;%(DisableSpecificWarnings) comctl32.lib;msimg32.lib;%(AdditionalDependencies) @@ -180,47 +176,38 @@ - - - - - - - - - - + + + + + + + + + + Create - + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - + + diff --git a/plugins/TipperYM/tipper_ym_10.vcxproj.filters b/plugins/TipperYM/tipper_ym_10.vcxproj.filters index 508c94cb08..9cd122d83e 100644 --- a/plugins/TipperYM/tipper_ym_10.vcxproj.filters +++ b/plugins/TipperYM/tipper_ym_10.vcxproj.filters @@ -15,109 +15,86 @@ - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - - + Resource Files - + Resource Files diff --git a/plugins/TipperYM/tipperym-translation.txt b/plugins/TipperYM/tipperym-translation.txt deleted file mode 100644 index f13fb40443..0000000000 --- a/plugins/TipperYM/tipperym-translation.txt +++ /dev/null @@ -1,352 +0,0 @@ -; Common strings that belong to many files -;[%dd %dh %dm] -;[%dh %dm] -;[%dm] -;[Add] -;[Apply skin] -;[Avatar border] -;[Avatar size:] -;[Border] -;[Client] -;[Edit] -;[Favourite contacts] -;[Gender] -;[Get more skins] -;[Listening to] -;[Listening to:] -;[None] -;[Reload skin list] -;[Remove] -;[Skins] -;[Status] -;[Status message] -;[Status message:] -;[Status:] -;[Tooltips] - -; ../../plugins/TipperYM/mir_smileys.cpp -;[Tipper smileys] - -; ../../plugins/TipperYM/options.cpp -;[] -;[Add item] -;[Add separator] -;[Animation] -;[Appearance] -;[Bottom] -;[Bottom left] -;[Bottom right] -;[Centre] -;[Content] -;[Customize] -;[Extra] -;[Fade] -;[Icon on left] -;[Icon on right] -;[Invalid Substitution] -;[Left] -;[Left avatar] -;[Max avatar size:] -;[Move down] -;[Move up] -;[No avatar] -;[No icon] -;[No title] -;[Right] -;[Right avatar] -;[Top] -;[Top left] -;[Top right] -;[Tray tooltip] -;[You must enter a label] - -; ../../plugins/TipperYM/options.h -;[Clist event] -;[Country flag] -;[Extra status] -;[Jabber activity] -;[Logon time] -;[Miranda uptime] -;[Number of contacts] -;[Protocol lock status] -;[Unread emails] - -; ../../plugins/TipperYM/popwin.cpp -;[ ago] -;[%s (locked)] -;[: ] -;[] -;[Activity:] -;[Copy all items] -;[Copy all items with labels] -;[Copy avatar] -;[Fav. contacts] -;[Log off:] -;[Log on:] -;[Miranda uptime:] -;[Mood:] -;[Other] -;[Unread emails:] -;[XStatus:] - -; ../../plugins/TipperYM/preset_items.cpp -;[%sys:uidname|UID^!MetaContacts%:] -;[Activity text:] -;[Activity title:] -;[Birthday] -;[Birthday:] -;[Client:] -;[Condition:] -;[Contact time] -;[Email] -;[Email:] -;[Gender:] -;[Homepage] -;[Homepage:] -;[Humidity:] -;[IP] -;[IP internal] -;[IP internal:] -;[IP:] -;[Identifier] -;[Idle] -;[Idle:] -;[Last message] -;[Last message: (%sys:last_msg_reltime% ago)] -;[Last seen status:] -;[Last seen time:] -;[Logoff time:] -;[Logon time:] -;[Max/Min:] -;[Moon:] -;[Name] -;[Name:] -;[Number of msg [IN]:] -;[Number of msg [OUT]:] -;[Number of received messages] -;[Number of sended messages] -;[Pressure:] -;[Sunrise:] -;[Sunset:] -;[Temperature:] -;[Time:] -;[UV Index:] -;[Update time:] -;[Visibility:] -;[Wind:] -;[XStatus text] -;[XStatus text:] -;[XStatus title] -;[XStatus title:] -;[[jabber.dll] Activity text] -;[[jabber.dll] Activity title] -;[[menuex.dll] Logoff time] -;[[menuex.dll] Logon time] -;[[seenplugin.dll] Last seen status] -;[[seenplugin.dll] Last seen time] -;[[weather.dll] Condition] -;[[weather.dll] Humidity] -;[[weather.dll] Max/Min temperature] -;[[weather.dll] Moon] -;[[weather.dll] Pressure] -;[[weather.dll] Sunrise] -;[[weather.dll] Sunset] -;[[weather.dll] Temperature] -;[[weather.dll] UV Index] -;[[weather.dll] Update time] -;[[weather.dll] Visibility] -;[[weather.dll] Wind] - -; ../../plugins/TipperYM/resource.rc -;[Advanced options] -;[Aero Glass (Vista+)] -;[Alignment] -;[Animation speed:] -;[Append protocol name] -;[Cancel] -;[Contact protocol module] -;[Disable in invisible status] -;[Down] -;[Draw a line above] -;[Effects] -;[Enable SmileyAdd support] -;[Enable skin coloring] -;[Enable tray tooltips] -;[Expand to second level after:] -;[Extra icons] -;[First level tooltip] -;[General padding:] -;[Handle tray tooltips by Tipper] -;[Hide offline] -;[Hide offline protocols] -;[Hover time:] -;[Inner avatar padding:] -;[Item] -;[Items] -;[Keep original avatar size] -;[Label:] -;[Labels:] -;[Layout] -;[Limit status messages in status bar and tray tooltips to:] -;[Load fonts and colors] -;[Load tooltip proportions] -;[Max height:] -;[Max width:] -;[Min height:] -;[Min width:] -;[Module:] -;[No preview] -;[OK] -;[Opacity(%):] -;[Options] -;[Outer avatar padding:] -;[Parse Tipper variables first] -;[Preset items:] -;[Preview] -;[Replace only isolated smileys] -;[Resize smileys] -;[Retrieve XStatus details if auto-retrieve is disabled] -;[Retrieve new status message] -;[Round corners (avatar)] -;[Round corners (window)] -;[Second level tooltip] -;[Separator] -;[Setting or prefix:] -;[Shadow] -;[Show if list not focused] -;[Show tooltip after all content is ready (avatar && status message)] -;[Sidebar width:] -;[Skin option] -;[Smileys support] -;[Status bar and tray tooltip] -;[Status bar tips] -;[Substitution] -;[Substitutions] -;[Text indent:] -;[Text padding:] -;[Title indent:] -;[Translation:] -;[Transparency] -;[Up] -;[Use protocol smileys] -;[Value indent:] -;[Value on a new line] -;[Value:] -;[Values:] -;[Variables] -;[Window] -;[characters] -;[ms] - -; ../../plugins/TipperYM/skin_parser.cpp -;[# Solid color fill] - -; ../../plugins/TipperYM/tipper.cpp -;[Background] -;[Cannot obtain required interfaces!\nTooltips will not be available until you upgrade Miranda IM to the newest version.] -;[Dividers] -;[Labels] -;[Sidebar] -;[Tipper error] -;[Title] -;[Tray title] -;[Values] - -; ../../plugins/TipperYM/translations.cpp -;[%dd] -;[%dy %dd %dh %dm] -;[Female] -;[Male] - -; ../../plugins/TipperYM/translations.h -;[Afrikaans] -;[Albanian] -;[April] -;[Arabic] -;[Armenian] -;[August] -;[Azerbaijani] -;[Belorussian] -;[Bhojpuri] -;[Bosnian] -;[Bulgarian] -;[Burmese] -;[Cantonese] -;[Catalan] -;[Chamorro] -;[Chinese] -;[Croatian] -;[Czech] -;[Danish] -;[December] -;[Dutch] -;[English] -;[Esperanto] -;[Estonian] -;[Farsi] -;[February] -;[Finnish] -;[French] -;[Friday] -;[Gaelic] -;[German] -;[Greek] -;[Gujarati] -;[Hebrew] -;[Hindi] -;[Hungarian] -;[Icelandic] -;[Indonesian] -;[Italian] -;[January] -;[Japanese] -;[July] -;[June] -;[Khmer] -;[Korean] -;[Kurdish] -;[Lao] -;[Latvian] -;[Lithuanian] -;[Macedonian] -;[Malay] -;[Mandarin] -;[March] -;[May] -;[Monday] -;[Mongolian] -;[Norwegian] -;[November] -;[October] -;[Persian] -;[Polish] -;[Portuguese] -;[Punjabi] -;[Romanian] -;[Russian] -;[Saturday] -;[September] -;[Serbo-Croatian] -;[Sindhi] -;[Slovak] -;[Slovenian] -;[Somali] -;[Spanish] -;[Sunday] -;[Swahili] -;[Swedish] -;[Tagalog] -;[Taiwanese] -;[Tamil] -;[Tatar] -;[Thai] -;[Thursday] -;[Tuesday] -;[Turkish] -;[Ukrainian] -;[Urdu] -;[Vietnamese] -;[Wednesday] -;[Welsh] -;[Yiddish] -;[Yoruba] diff --git a/plugins/TipperYM/translations.cpp b/plugins/TipperYM/translations.cpp deleted file mode 100644 index 1fd6e67c39..0000000000 --- a/plugins/TipperYM/translations.cpp +++ /dev/null @@ -1,744 +0,0 @@ -/* -Copyright (C) 2006-2007 Scott Ellis -Copyright (C) 2007-2011 Jan Holub - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this file; see the file license.txt. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. -*/ - -#include "common.h" -#include "translations.h" -#include "subst.h" -#include "str_utils.h" - -int iTransFuncsCount = 0; -DBVTranslation *translations = 0; - -DWORD dwNextFuncId; -HANDLE hServiceAdd; - - -void AddTranslation(DBVTranslation *newTrans) -{ - iTransFuncsCount++; - - translations = (DBVTranslation *)mir_realloc(translations, sizeof(DBVTranslation) * iTransFuncsCount); - translations[iTransFuncsCount - 1] = *newTrans; - - char *szName = mir_t2a(newTrans->swzName); - char szSetting[256] = "Trans_"; - strcat(szSetting, szName); - - if (_tcscmp(newTrans->swzName, _T("[No translation]")) == 0) - { - translations[iTransFuncsCount - 1].id = 0; - } - else - { - DWORD id = DBGetContactSettingDword(0, MODULE_ITEMS, szSetting, 0); - if (id != 0) - { - translations[iTransFuncsCount - 1].id = id; - if (dwNextFuncId <= id) dwNextFuncId = id + 1; - } - else - { - translations[iTransFuncsCount - 1].id = dwNextFuncId++; - DBWriteContactSettingDword(0, MODULE_ITEMS, szSetting, translations[iTransFuncsCount - 1].id); - } - - DBWriteContactSettingDword(0, MODULE_ITEMS, "NextFuncId", dwNextFuncId); - } - - mir_free(szName); -} - -TCHAR *NullTranslation(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) -{ - if (DBGetContactSettingAsString(hContact, szModuleName, szSettingName, buff, bufflen)) - return buff; - return NULL; -} - -TCHAR *TimestampToShortDate(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) -{ - DWORD ts = DBGetContactSettingDword(hContact, szModuleName, szSettingName, 0); - if (ts == 0) return 0; - - DBTIMETOSTRINGT dbt = {0}; - dbt.cbDest = bufflen; - dbt.szDest = buff; - dbt.szFormat = _T("d"); - CallService(MS_DB_TIME_TIMESTAMPTOSTRINGT, (WPARAM)ts, (LPARAM)&dbt); - return buff; -} - -TCHAR *TimestampToLongDate(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) -{ - DWORD ts = DBGetContactSettingDword(hContact, szModuleName, szSettingName, 0); - if (ts == 0) return 0; - - DBTIMETOSTRINGT dbt = {0}; - dbt.cbDest = bufflen; - dbt.szDest = buff; - dbt.szFormat = _T("D"); - CallService(MS_DB_TIME_TIMESTAMPTOSTRINGT, (WPARAM)ts, (LPARAM)&dbt); - return buff; -} - -TCHAR *TimestampToTime(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) -{ - DWORD ts = DBGetContactSettingDword(hContact, szModuleName, szSettingName, 0); - if (ts == 0) return 0; - - DBTIMETOSTRINGT dbt = {0}; - dbt.cbDest = bufflen; - dbt.szDest = buff; - dbt.szFormat = _T("s"); - CallService(MS_DB_TIME_TIMESTAMPTOSTRINGT, (WPARAM)ts, (LPARAM)&dbt); - return buff; -} - -TCHAR *TimestampToTimeNoSecs(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) -{ - DWORD ts = DBGetContactSettingDword(hContact, szModuleName, szSettingName, 0); - if (ts == 0) return 0; - - DBTIMETOSTRINGT dbt = {0}; - dbt.cbDest = bufflen; - dbt.szDest = buff; - dbt.szFormat = _T("t"); - CallService(MS_DB_TIME_TIMESTAMPTOSTRINGT, (WPARAM)ts, (LPARAM)&dbt); - return buff; -} - -TCHAR *TimestampToTimeDifference(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) -{ - DWORD ts = DBGetContactSettingDword(hContact, szModuleName, szSettingName, 0); - DWORD t = (DWORD)time(0); - if (ts == 0) return 0; - - DWORD diff = (ts > t) ? 0 : (t - ts); - int d = (diff / 60 / 60 / 24); - int h = (diff - d * 60 * 60 * 24) / 60 / 60; - int m = (diff - d * 60 * 60 * 24 - h * 60 * 60) / 60; - if (d > 0) - mir_sntprintf(buff, bufflen, TranslateT("%dd %dh %dm"), d, h, m); - else if (h > 0) - mir_sntprintf(buff, bufflen, TranslateT("%dh %dm"), h, m); - else - mir_sntprintf(buff, bufflen, TranslateT("%dm"), m); - - return buff; -} - -TCHAR *SecondsToTimeDifference(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) -{ - DWORD diff = DBGetContactSettingDword(hContact, szModuleName, szSettingName, 0); - int d = (diff / 60 / 60 / 24); - int h = (diff - d * 60 * 60 * 24) / 60 / 60; - int m = (diff - d * 60 * 60 * 24 - h * 60 * 60) / 60; - if (d > 0) - mir_sntprintf(buff, bufflen, TranslateT("%dd %dh %dm"), d, h, m); - else if (h > 0) - mir_sntprintf(buff, bufflen, TranslateT("%dh %dm"), h, m); - else - mir_sntprintf(buff, bufflen, TranslateT("%dm"), m); - - return buff; -} - -TCHAR *WordToStatusDesc(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) -{ - WORD wStatus = DBGetContactSettingWord(hContact, szModuleName, szSettingName, ID_STATUS_OFFLINE); - TCHAR *szStatus = (TCHAR *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)wStatus, GSMDF_TCHAR); - _tcsncpy(buff,szStatus, bufflen); - buff[bufflen - 1] = 0; - return buff; -} - -TCHAR *ByteToYesNo(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) -{ - DBVARIANT dbv; - if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) - { - if (dbv.type == DBVT_BYTE) - { - if (dbv.bVal != 0) - _tcsncpy(buff, _T("Yes"), bufflen); - else - _tcsncpy(buff, _T("No"), bufflen); - buff[bufflen - 1] = 0; - DBFreeVariant(&dbv); - return buff; - } - DBFreeVariant(&dbv); - } - return 0; -} - -TCHAR *ByteToGender(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) -{ - BYTE val = (BYTE)DBGetContactSettingByte(hContact, szModuleName, szSettingName, 0); - if (val == 'F') - _tcsncpy(buff, TranslateT("Female"), bufflen); - else if (val == 'M') - _tcsncpy(buff, TranslateT("Male"), bufflen); - else - return 0; - - buff[bufflen - 1] = 0; - return buff; -} - -TCHAR *WordToCountry(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) -{ - char *szCountryName = 0; - WORD cid = (WORD)DBGetContactSettingWord(hContact, szModuleName, szSettingName, (WORD)-1); - if (cid != (WORD)-1 && ServiceExists(MS_UTILS_GETCOUNTRYBYNUMBER) && (szCountryName = (char *)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, cid, 0)) != 0) - { - if (strcmp(szCountryName, "Unknown") == 0) - return 0; - a2t(szCountryName, buff, bufflen); - buff[bufflen - 1] = 0; - return buff; - } - return 0; -} - -TCHAR *DwordToIp(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) -{ - DWORD ip = DBGetContactSettingDword(hContact, szModuleName, szSettingName, 0); - if (ip) { - unsigned char *ipc = (unsigned char*)&ip; - mir_sntprintf(buff, bufflen, _T("%u.%u.%u.%u"), ipc[3], ipc[2], ipc[1], ipc[0]); - return buff; - } - return 0; -} - -bool GetInt(const DBVARIANT &dbv, int *iVal) -{ - if (!iVal) return false; - - switch(dbv.type) - { - case DBVT_BYTE: - if (iVal) *iVal = (int)dbv.bVal; - return true; - case DBVT_WORD: - if (iVal) *iVal = (int)dbv.wVal; - return true; - case DBVT_DWORD: - if (iVal) *iVal = (int)dbv.dVal; - return true; - } - return false; -} - -TCHAR *DayMonthYearToDate(HANDLE hContact, const char *szModuleName, const char *prefix, TCHAR *buff, int bufflen) -{ - DBVARIANT dbv; - char szSettingName[256]; - mir_snprintf(szSettingName, 256, "%sDay", prefix); - if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) - { - int day = 0; - if (GetInt(dbv, &day)) - { - DBFreeVariant(&dbv); - mir_snprintf(szSettingName, 256, "%sMonth", prefix); - int month = 0; - if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) - { - if (GetInt(dbv, &month)) - { - DBFreeVariant(&dbv); - mir_snprintf(szSettingName, 256, "%sYear", prefix); - int year = 0; - if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) - { - if (GetInt(dbv, &year)) - { - DBFreeVariant(&dbv); - - SYSTEMTIME st = {0}; - st.wDay = day; - st.wMonth = month; - st.wYear = year; - - GetDateFormat(LOCALE_USER_DEFAULT, 0, &st, 0, buff, bufflen); - return buff; - } - else - DBFreeVariant(&dbv); - } - } - else - DBFreeVariant(&dbv); - } - } - else - DBFreeVariant(&dbv); - } - return 0; -} - -TCHAR *DayMonthYearToAge(HANDLE hContact, const char *szModuleName, const char *szPrefix, TCHAR *buff, int bufflen) -{ - DBVARIANT dbv; - char szSettingName[256]; - mir_snprintf(szSettingName, 256, "%sDay", szPrefix); - if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) - { - int day = 0; - if (GetInt(dbv, &day)) - { - DBFreeVariant(&dbv); - mir_snprintf(szSettingName, 256, "%sMonth", szPrefix); - int month = 0; - if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) - { - if (GetInt(dbv, &month)) - { - DBFreeVariant(&dbv); - mir_snprintf(szSettingName, 256, "%sYear", szPrefix); - int year = 0; - if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) - { - if (GetInt(dbv, &year)) - { - DBFreeVariant(&dbv); - - SYSTEMTIME now; - GetLocalTime(&now); - - int age = now.wYear - year; - if (now.wMonth < month || (now.wMonth == month && now.wDay < day)) - age--; - mir_sntprintf(buff, bufflen, _T("%d"), age); - return buff; - } - else - DBFreeVariant(&dbv); - } - } - else - DBFreeVariant(&dbv); - } - } - else - DBFreeVariant(&dbv); - } - return 0; -} - -TCHAR *HoursMinutesSecondsToTime(HANDLE hContact, const char *szModuleName, const char *szPrefix, TCHAR *buff, int bufflen) -{ - DBVARIANT dbv; - char szSettingName[256]; - mir_snprintf(szSettingName, 256, "%sHours", szPrefix); - if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) - { - int hours = 0; - if (GetInt(dbv, &hours)) - { - DBFreeVariant(&dbv); - mir_snprintf(szSettingName, 256, "%sMinutes", szPrefix); - int minutes = 0; - if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) - { - if (GetInt(dbv, &minutes)) - { - DBFreeVariant(&dbv); - mir_snprintf(szSettingName, 256, "%sSeconds", szPrefix); - int seconds = 0; - if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) - { - GetInt(dbv, &seconds); - DBFreeVariant(&dbv); - } - - SYSTEMTIME st = {0}; - st.wHour = hours; - st.wMinute = minutes; - st.wSecond = seconds; - - GetTimeFormat(LOCALE_USER_DEFAULT, 0, &st, 0, buff, bufflen); - return buff; - } - else - DBFreeVariant(&dbv); - } - } - else - DBFreeVariant(&dbv); - } - return 0; -} - -TCHAR *HoursMinutesToTime(HANDLE hContact, const char *szModuleName, const char *szPrefix, TCHAR *buff, int bufflen) -{ - DBVARIANT dbv; - char szSettingName[256]; - mir_snprintf(szSettingName, 256, "%sHours", szPrefix); - if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) - { - int hours = 0; - if (GetInt(dbv, &hours)) - { - DBFreeVariant(&dbv); - mir_snprintf(szSettingName, 256, "%sMinutes", szPrefix); - int minutes = 0; - if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) - { - if (GetInt(dbv, &minutes)) - { - DBFreeVariant(&dbv); - - SYSTEMTIME st = {0}; - st.wHour = hours; - st.wMinute = minutes; - - GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, 0, buff, bufflen); - return buff; - } - else - DBFreeVariant(&dbv); - } - } - else - DBFreeVariant(&dbv); - } - return 0; -} - -TCHAR *DmyToTimeDifference(HANDLE hContact, const char *szModuleName, const char *szPrefix, TCHAR *buff, int bufflen) -{ - DBVARIANT dbv; - char szSettingName[256]; - mir_snprintf(szSettingName, 256, "%sDay", szPrefix); - if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) - { - int day = 0; - if (GetInt(dbv, &day)) - { - DBFreeVariant(&dbv); - mir_snprintf(szSettingName, 256, "%sMonth", szPrefix); - int month = 0; - if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) - { - if (GetInt(dbv, &month)) - { - DBFreeVariant(&dbv); - mir_snprintf(szSettingName, 256, "%sYear", szPrefix); - int year = 0; - if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) - { - if (GetInt(dbv, &year)) - { - DBFreeVariant(&dbv); - mir_snprintf(szSettingName, 256, "%sHours", szPrefix); - if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) - { - int hours = 0; - if (GetInt(dbv, &hours)) - { - DBFreeVariant(&dbv); - mir_snprintf(szSettingName, 256, "%sMinutes", szPrefix); - int minutes = 0; - if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) - { - if (GetInt(dbv, &minutes)) - { - DBFreeVariant(&dbv); - mir_snprintf(szSettingName, 256, "%sSeconds", szPrefix); - int seconds = 0; - if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) - { - GetInt(dbv, &seconds); - DBFreeVariant(&dbv); - } - - SYSTEMTIME st = {0}, st_now; - st.wDay = day; - st.wMonth = month; - st.wYear = year; - st.wHour = hours; - st.wMinute = minutes; - st.wSecond = seconds; - GetLocalTime(&st_now); - - FILETIME ft, ft_now; - SystemTimeToFileTime(&st, &ft); - SystemTimeToFileTime(&st_now, &ft_now); - - LARGE_INTEGER li, li_now; - li.HighPart = ft.dwHighDateTime; li.LowPart = ft.dwLowDateTime; - li_now.HighPart = ft_now.dwHighDateTime; li_now.LowPart = ft_now.dwLowDateTime; - - long diff = (long)((li_now.QuadPart - li.QuadPart) / (LONGLONG)10000000L); - int y = diff / 60 / 60 / 24 / 365; - int d = (diff - y * 60 * 60 * 24 * 365) / 60 / 60 / 24; - int h = (diff - y * 60 * 60 * 24 * 365 - d * 60 * 60 * 24) / 60 / 60; - int m = (diff - y * 60 * 60 * 24 * 365 - d * 60 * 60 * 24 - h * 60 * 60) / 60; - if (y != 0) - mir_sntprintf(buff, bufflen, TranslateT("%dy %dd %dh %dm"), y, d, h, m); - else if (d != 0) - mir_sntprintf(buff, bufflen, TranslateT("%dd %dh %dm"), d, h, m); - else if (h != 0) - mir_sntprintf(buff, bufflen, TranslateT("%dh %dm"), h, m); - else - mir_sntprintf(buff, bufflen, TranslateT("%dm"), m); - - return buff; - } - else - DBFreeVariant(&dbv); - } - } - else - DBFreeVariant(&dbv); - } - } - else - DBFreeVariant(&dbv); - } - } - else - DBFreeVariant(&dbv); - } - } - else - DBFreeVariant(&dbv); - } - return 0; -} - -TCHAR *DayMonthToDaysToNextBirthday(HANDLE hContact, const char *szModuleName, const char *szPrefix, TCHAR *buff, int bufflen) -{ - DBVARIANT dbv; - char szSettingName[256]; - mir_snprintf(szSettingName, 256, "%sDay", szPrefix); - if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) - { - int day = 0; - if (GetInt(dbv, &day)) - { - DBFreeVariant(&dbv); - mir_snprintf(szSettingName, 256, "%sMonth", szPrefix); - int month = 0; - if (!DBGetContactSetting(hContact, szModuleName, szSettingName, &dbv)) - { - if (GetInt(dbv, &month)) - { - DBFreeVariant(&dbv); - time_t now = time(NULL); - struct tm *ti = localtime(&now); - int yday_now = ti->tm_yday; - - ti->tm_mday = day; - ti->tm_mon = month - 1; - mktime(ti); - - int yday_birth = ti->tm_yday; - if (yday_birth < yday_now) - { - yday_now -= 365; - yday_now -= (ti->tm_year % 4) ? 0 : 1; - } - - int diff = yday_birth - yday_now; - mir_sntprintf(buff, bufflen, TranslateT("%dd"), diff); - - return buff; - } - else - { - DBFreeVariant(&dbv); - } - } - } - else - { - DBFreeVariant(&dbv); - } - } - return 0; -} - - -TCHAR *EmptyXStatusToDefaultName(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) -{ - TCHAR szDefaultName[1024]; - ICQ_CUSTOM_STATUS xstatus = {0}; - DBVARIANT dbv; - - // translate jabber mood - if (ProtoServiceExists(szModuleName, "/SendXML")) // jabber protocol? - { - if (!DBGetContactSettingTString(hContact, szModuleName, szSettingName, &dbv)) - { - _tcsncpy(buff, TranslateTS(dbv.ptszVal), bufflen); - buff[bufflen - 1] = 0; - return buff; - } - } - - if (NullTranslation(hContact, szModuleName, szSettingName, buff, bufflen)) - return buff; - - int status = DBGetContactSettingByte(hContact, szModuleName, "XStatusId", 0); - if (!status) return 0; - - if (ProtoServiceExists(szModuleName, PS_ICQ_GETCUSTOMSTATUSEX)) - { - xstatus.cbSize = sizeof(ICQ_CUSTOM_STATUS); - xstatus.flags = CSSF_MASK_NAME | CSSF_DEFAULT_NAME | CSSF_TCHAR; - xstatus.ptszName = szDefaultName; - xstatus.wParam = (WPARAM *)&status; - if (CallProtoService(szModuleName, PS_ICQ_GETCUSTOMSTATUSEX, 0, (LPARAM)&xstatus)) - return 0; - - _tcsncpy(buff, TranslateTS(szDefaultName), bufflen); - buff[bufflen - 1] = 0; - return buff; - } - - return 0; -} - -TCHAR *TimezoneToTime(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) -{ - int timezone = DBGetContactSettingByte(hContact,szModuleName,szSettingName,256); - if (timezone==256 || (char)timezone==-100) - return 0; - - TIME_ZONE_INFORMATION tzi; - FILETIME ft; - LARGE_INTEGER lift; - SYSTEMTIME st; - - timezone=(char)timezone; - GetSystemTimeAsFileTime(&ft); - if (GetTimeZoneInformation(&tzi) == TIME_ZONE_ID_DAYLIGHT) - timezone += tzi.DaylightBias / 30; - - lift.QuadPart = *(__int64*)&ft; - lift.QuadPart -= (__int64)timezone * BIGI(30) * BIGI(60) * BIGI(10000000); - *(__int64*)&ft = lift.QuadPart; - FileTimeToSystemTime(&ft, &st); - GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, buff, bufflen); - - return buff; -} - -TCHAR *ByteToDay(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) -{ - int iDay = DBGetContactSettingWord(hContact, szModuleName, szSettingName, -1); - if (iDay > -1 && iDay < 7) - { - a2t(Translate(days[iDay]), buff, bufflen); - buff[bufflen - 1] = 0; - return buff; - } - - return 0; -} - -TCHAR *ByteToMonth(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) -{ - int iMonth = DBGetContactSettingWord(hContact, szModuleName, szSettingName, 0); - if (iMonth > 0 && iMonth < 13) - { - a2t(Translate(months[iMonth - 1]), buff, bufflen); - buff[bufflen - 1] = 0; - return buff; - } - - return 0; -} - -TCHAR *ByteToLanguage(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen) -{ - int iLang = DBGetContactSettingByte(hContact, szModuleName, szSettingName, 0); - if (iLang) - { - for (int i = 0; i < SIZEOF(languages); i++) - { - if (iLang == languages[i].id) - { - a2t(Translate(languages[i].szValue), buff, bufflen); - buff[bufflen - 1] = 0; - return buff; - } - } - } - - return 0; -} - -INT_PTR ServiceAddTranslation(WPARAM wParam, LPARAM lParam) -{ - if (!lParam) return 1; - - DBVTranslation *trans = (DBVTranslation *)lParam; - AddTranslation(trans); - - return 0; -} - -static DBVTranslation internalTranslations[] = -{ - { NullTranslation, _T("[No translation]") }, - { WordToStatusDesc, _T("WORD to status description") }, - { TimestampToTime, _T("DWORD timestamp to time") }, - { TimestampToTimeDifference, _T("DWORD timestamp to time difference") }, - { ByteToYesNo, _T("BYTE to Yes/No") }, - { ByteToGender, _T("BYTE to Male/Female (ICQ)") }, - { WordToCountry, _T("WORD to country name") }, - { DwordToIp, _T("DWORD to ip address") }, - { DayMonthYearToDate, _T("Day|Month|Year to date") }, - { DayMonthYearToAge, _T("Day|Month|Year to age") }, - { HoursMinutesSecondsToTime, _T("Hours|Minutes|Seconds to time") }, - { DmyToTimeDifference, _T("Day|Month|Year|Hours|Minutes|Seconds to time difference") }, - { DayMonthToDaysToNextBirthday, _T("Day|Month to days to next birthday") }, - { TimestampToTimeNoSecs, _T("DWORD timestamp to time (no seconds)") }, - { HoursMinutesToTime, _T("Hours|Minutes to time") }, - { TimestampToShortDate, _T("DWORD timestamp to date (short)") }, - { TimestampToLongDate, _T("DWORD timestamp to date (long)") }, - { EmptyXStatusToDefaultName, _T("xStatus: empty xStatus name to default name") }, - { SecondsToTimeDifference, _T("DWORD seconds to time difference") }, - { TimezoneToTime, _T("BYTE timezone to time") }, - { ByteToDay, _T("WORD to name of a day (0..6, 0 is Sunday)") }, - { ByteToMonth, _T("WORD to name of a month (1..12, 1 is January)") }, - { ByteToLanguage, _T("BYTE to language (ICQ)") }, -}; - -void InitTranslations() -{ - dwNextFuncId = DBGetContactSettingDword(0, MODULE_ITEMS, "NextFuncId", 1); - for (int i = 0; i < SIZEOF(internalTranslations); i++) - AddTranslation( &internalTranslations[i] ); - - hServiceAdd = CreateServiceFunction(MS_TIPPER_ADDTRANSLATION, ServiceAddTranslation); -} - -void DeinitTranslations() -{ - DestroyServiceFunction(hServiceAdd); - mir_free(translations); -} - diff --git a/plugins/TipperYM/translations.h b/plugins/TipperYM/translations.h deleted file mode 100644 index 985920054e..0000000000 --- a/plugins/TipperYM/translations.h +++ /dev/null @@ -1,125 +0,0 @@ -/* -Copyright (C) 2006-2007 Scott Ellis -Copyright (C) 2007-2011 Jan Holub - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this file; see the file license.txt. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. -*/ - -#ifndef _TRANSLATIONS_INC -#define _TRANSLATIONS_INC - -extern int iTransFuncsCount; -extern DBVTranslation *translations; - -typedef struct { - int id; - char *szValue; -} LISTTYPEDATAITEM; - -static LISTTYPEDATAITEM languages[] = { - {0, LPGEN("None")}, - {55,LPGEN("Afrikaans")}, - {58,LPGEN("Albanian")}, - {1, LPGEN("Arabic")}, - {59,LPGEN("Armenian")}, - {68,LPGEN("Azerbaijani")}, - {72,LPGEN("Belorussian")}, - {2, LPGEN("Bhojpuri")}, - {56,LPGEN("Bosnian")}, - {3, LPGEN("Bulgarian")}, - {4, LPGEN("Burmese")}, - {5, LPGEN("Cantonese")}, - {6, LPGEN("Catalan")}, - {61,LPGEN("Chamorro")}, - {7, LPGEN("Chinese")}, - {8, LPGEN("Croatian")}, - {9, LPGEN("Czech")}, - {10,LPGEN("Danish")}, - {11,LPGEN("Dutch")}, - {12,LPGEN("English")}, - {13,LPGEN("Esperanto")}, - {14,LPGEN("Estonian")}, - {15,LPGEN("Farsi")}, - {16,LPGEN("Finnish")}, - {17,LPGEN("French")}, - {18,LPGEN("Gaelic")}, - {19,LPGEN("German")}, - {20,LPGEN("Greek")}, - {70,LPGEN("Gujarati")}, - {21,LPGEN("Hebrew")}, - {22,LPGEN("Hindi")}, - {23,LPGEN("Hungarian")}, - {24,LPGEN("Icelandic")}, - {25,LPGEN("Indonesian")}, - {26,LPGEN("Italian")}, - {27,LPGEN("Japanese")}, - {28,LPGEN("Khmer")}, - {29,LPGEN("Korean")}, - {69,LPGEN("Kurdish")}, - {30,LPGEN("Lao")}, - {31,LPGEN("Latvian")}, - {32,LPGEN("Lithuanian")}, - {65,LPGEN("Macedonian")}, - {33,LPGEN("Malay")}, - {63,LPGEN("Mandarin")}, - {62,LPGEN("Mongolian")}, - {34,LPGEN("Norwegian")}, - {57,LPGEN("Persian")}, - {35,LPGEN("Polish")}, - {36,LPGEN("Portuguese")}, - {60,LPGEN("Punjabi")}, - {37,LPGEN("Romanian")}, - {38,LPGEN("Russian")}, - {39,LPGEN("Serbo-Croatian")}, - {66,LPGEN("Sindhi")}, - {40,LPGEN("Slovak")}, - {41,LPGEN("Slovenian")}, - {42,LPGEN("Somali")}, - {43,LPGEN("Spanish")}, - {44,LPGEN("Swahili")}, - {45,LPGEN("Swedish")}, - {46,LPGEN("Tagalog")}, - {64,LPGEN("Taiwanese")}, - {71,LPGEN("Tamil")}, - {47,LPGEN("Tatar")}, - {48,LPGEN("Thai")}, - {49,LPGEN("Turkish")}, - {50,LPGEN("Ukrainian")}, - {51,LPGEN("Urdu")}, - {52,LPGEN("Vietnamese")}, - {67,LPGEN("Welsh")}, - {53,LPGEN("Yiddish")}, - {54,LPGEN("Yoruba")}, -}; - -static char *days[7] = { - LPGEN("Sunday"), LPGEN("Monday"), LPGEN("Tuesday"), LPGEN("Wednesday"), LPGEN("Thursday"), LPGEN("Friday"), LPGEN("Saturday") -}; - -static char *months[12] = { - LPGEN("January"), LPGEN("February"), LPGEN("March"), LPGEN("April"), LPGEN("May"), LPGEN("June"), - LPGEN("July"), LPGEN("August"), LPGEN("September"), LPGEN("October"), LPGEN("November"), LPGEN("December") -}; - -void InitTranslations(); -void DeinitTranslations(); - -TCHAR *TimestampToTimeDifference(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen); -TCHAR *EmptyXStatusToDefaultName(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen); -TCHAR *WordToStatusDesc(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen); - - -#endif diff --git a/plugins/TipperYM/version.h b/plugins/TipperYM/version.h deleted file mode 100644 index c71b187bc0..0000000000 --- a/plugins/TipperYM/version.h +++ /dev/null @@ -1,4 +0,0 @@ -#define __FILEVERSION_STRING 2,1,0,4 -#define __VERSION_STRING "2.1.0.4" -#define __VERSION_DWORD PLUGIN_MAKE_VERSION(2, 1, 0, 4) - diff --git a/plugins/TipperYM/version.rc b/plugins/TipperYM/version.rc deleted file mode 100644 index cb8ea0cd97..0000000000 --- a/plugins/TipperYM/version.rc +++ /dev/null @@ -1,40 +0,0 @@ -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - -#include -#include "version.h" - -VS_VERSION_INFO VERSIONINFO - FILEVERSION __FILEVERSION_STRING - PRODUCTVERSION __FILEVERSION_STRING - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "Author", "Scott Ellis, yaho" - VALUE "CompanyName", "yaho" - VALUE "FileDescription", "Tool Tip notification windows" - VALUE "FileVersion", __VERSION_STRING - VALUE "InternalName", "Tipper YM" - VALUE "LegalCopyright", "(c) 2005-2007 Scott Ellis, 2007-2011 Jan Holub" - VALUE "OriginalFilename", "tipper.dll" - VALUE "ProductName", "Tipper YM" - VALUE "ProductVersion", __VERSION_STRING - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END diff --git a/plugins/TooltipNotify/doc/todo.txt b/plugins/TooltipNotify/doc/todo.txt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/plugins/TooltipNotify/doc/tt_wnd_def_style.txt b/plugins/TooltipNotify/doc/tt_wnd_def_style.txt deleted file mode 100644 index c47a6a363f..0000000000 --- a/plugins/TooltipNotify/doc/tt_wnd_def_style.txt +++ /dev/null @@ -1,9 +0,0 @@ -ws_popup -ws_visible -ws_clipsiblings -ws_border - -ws_ex_left -ws_ex_ltrreading -ws_ex_rightscrollbar -ws_ex_topmost \ No newline at end of file diff --git a/plugins/TooltipNotify/doc/ttnotify-readme.txt b/plugins/TooltipNotify/doc/ttnotify-readme.txt deleted file mode 100644 index 1d2e816390..0000000000 --- a/plugins/TooltipNotify/doc/ttnotify-readme.txt +++ /dev/null @@ -1,128 +0,0 @@ - - - Tooltip notify plugin for Miranda IM - ____________________________________ - - Version 0.6.0.45 - - -About -_____ - -This Miranda IM plugin popups a small tooltip above system tray area -when a contact changes his status. It's intended for and tested with ICQ -protocol mainly, so it can miswork with other protocols. - - - -Changelog -_________ - -Version 0.6.0.45 - - Individual font settings for events - -Version 0.5.0.42 - - Added idle notifications - - Using font services - -Version 0.4.0.36 - - Fixed crash with too long contact names - -Version 0.4.0.32 - - Next generation plugin interface support - - Correct unicode/ansi flag in plugin description - -Version 0.4.0.29 - - per-contact notifications ability - - ansi/unicode module check on corresponding os - - more unicode support - - internal module name changed from 'ttntfmod' to 'Tooltip Notify' - (all settings migrate automatically) - - fixed potential crash while reading font settings - - fixed memory leak - -Version 0.3.0.15 - - fixed one major unexpected crash - -Version 0.3.0.14 - - unicode support - - fixed minor bug related to settings reading - - fixed potential crash with the tooltip moving - - other minor fixes - -Version 0.2.0.2 - - obey 'suppress online notification' setting - - sound plays only if the event notification is checked - - minor stability fixes - - translation file update - -Version 0.2.0.1 - - stability fixes - -Version 0.2.0.0 - - some controls' text fields are enlarged (translators requests) - - win9x misworking fixed (not tested) - - new abilities: - - proto name prefixing - - enabled back - - work in conjunction with 'suppress online notification' - -Version 0.1.0.0 - - the whole code rewritten in cpp - - new abilities: - - suppress notifications upon connect - - typing notification - - disabled - - work in conjunction with 'suppress online notification' - -Version 0.0.6.0 - - rewritten code of the tooltip window - - tooltip dragging behavior changed (now with usual left-click) - - new options: - - double click on tooltip action - - font and color customization - - some minor fixes/changes - -Version 0.0.5.0 - - sound support for the contact events - - added a button to run the tooltip within the options dialog to test it - - some minor changes - -Version 0.0.4.3 - - protocols selection bug fixed - -Version 0.0.4.2 - - translucency options - - translation support - -Version 0.0.4.0 - - ability to select protocols to react to - - ability of custom tooltip placement - -Version 0.0.3.1 - - a little translations added - -Version 0.0.3.0 - - options moved to events->tooltip notify - - options added: - - allow tooltip duration adjusting - - conjunctive work with 'Suppress online notification' - - fixed showing a tooltip when protocol goes offline - - plugin size reduced - -Version 0.0.2.4 - - some internal fixes - - -Copyright -_________ - -Copyright (C) 2004-2008 Gneedah software (perf@mail333.com) - - - -DISCLAIMER OF WARRANTY --------------------------------------------------------------------- - -This software is distributed "AS IS" without any warranties. -USE IT AT YOU OWN RISK. diff --git a/plugins/TooltipNotify/doc/ttnotify_translation.txt b/plugins/TooltipNotify/doc/ttnotify_translation.txt deleted file mode 100644 index 2c7d965d67..0000000000 --- a/plugins/TooltipNotify/doc/ttnotify_translation.txt +++ /dev/null @@ -1,47 +0,0 @@ -; This is a template for Tooltip Notify translation. - - -; ******** Plugin info ******** -;[Tooltip Notify] -;[Shows a small tooltip above system tray area when a contact status is changed] - - -; ******** Options and tooltip text ******** - -;[Notify upon the following contact status changes] -;[Online] -;[Offline] -;[Away] -;[N/A] -;[Occupied] -;[DND] -;[Free for chat] -;[Invisible] -;[All other] -;[Unknown] -;[Typing] -;[Idle] -;[Suppress notifications upon connection for] -;[sec] -;[Prefix proto name] -;[Protocols] -;[is] - -;[Duration] -;[Show tooltip for] -;[ms] -;[Duration x2 upon online event] - -;[Double click on tooltip] -;[Shows/Hides CList] -;[Opens message dialog] - -;[Misc] -;[Obey 'Suppress online notification' settings] -;[Auto positioning] -;[Transparent input] - -;[Preview] - -;[Translucency options (Windows 2000/XP only)] -;[Transparent tooltip] diff --git a/plugins/TooltipNotify/docs/todo.txt b/plugins/TooltipNotify/docs/todo.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/TooltipNotify/docs/tooltipnotify-translation.txt b/plugins/TooltipNotify/docs/tooltipnotify-translation.txt new file mode 100644 index 0000000000..44862c316f --- /dev/null +++ b/plugins/TooltipNotify/docs/tooltipnotify-translation.txt @@ -0,0 +1,55 @@ +; Common strings that belong to many files +;[Idle] +;[Offline] +;[Online] +;[Typing] + +; ../../plugins/TooltipNotify/src/TooltipNotify.cpp +;[** New contacts **] +;[** Unknown contacts **] +;[Appearance] +;[Away] +;[DND] +;[Free for chat] +;[Invisible] +;[N/A] +;[Not Idle] +;[Occupied] +;[Tooltip Notify] +;[Tooltip Notify: Offline] +;[Tooltip Notify: Online] +;[Tooltip Notify: Other] +;[Tooltip Notify: Typing] +;[Unknown] +;[is] + +; ../../plugins/TooltipNotify/src/main.rc +;[All other] +;[Allow tooltip notifications for the following users:] +;[Auto positioning] +;[Behavior] +;[Cancel] +;[Choose contacts...] +;[Contacts] +;[Double click on tooltip] +;[Duration] +;[Duration x2 upon online event] +;[Misc] +;[Notify upon the following events] +;[OK] +;[Obey 'Suppress online notification' settings] +;[Opens message dialog] +;[Prefix proto name] +;[Preview] +;[Protocols] +;[Select protocols] +;[Show tooltip for] +;[Shows/Hides CList] +;[Slider1] +;[Spin1] +;[Suppress notifications upon connection for] +;[Translucency options (Windows 2000/XP only)] +;[Transparent input] +;[Transparent tooltip] +;[ms] +;[sec] diff --git a/plugins/TooltipNotify/docs/tt_wnd_def_style.txt b/plugins/TooltipNotify/docs/tt_wnd_def_style.txt new file mode 100644 index 0000000000..c47a6a363f --- /dev/null +++ b/plugins/TooltipNotify/docs/tt_wnd_def_style.txt @@ -0,0 +1,9 @@ +ws_popup +ws_visible +ws_clipsiblings +ws_border + +ws_ex_left +ws_ex_ltrreading +ws_ex_rightscrollbar +ws_ex_topmost \ No newline at end of file diff --git a/plugins/TooltipNotify/docs/ttnotify-readme.txt b/plugins/TooltipNotify/docs/ttnotify-readme.txt new file mode 100644 index 0000000000..1d2e816390 --- /dev/null +++ b/plugins/TooltipNotify/docs/ttnotify-readme.txt @@ -0,0 +1,128 @@ + + + Tooltip notify plugin for Miranda IM + ____________________________________ + + Version 0.6.0.45 + + +About +_____ + +This Miranda IM plugin popups a small tooltip above system tray area +when a contact changes his status. It's intended for and tested with ICQ +protocol mainly, so it can miswork with other protocols. + + + +Changelog +_________ + +Version 0.6.0.45 + - Individual font settings for events + +Version 0.5.0.42 + - Added idle notifications + - Using font services + +Version 0.4.0.36 + - Fixed crash with too long contact names + +Version 0.4.0.32 + - Next generation plugin interface support + - Correct unicode/ansi flag in plugin description + +Version 0.4.0.29 + - per-contact notifications ability + - ansi/unicode module check on corresponding os + - more unicode support + - internal module name changed from 'ttntfmod' to 'Tooltip Notify' + (all settings migrate automatically) + - fixed potential crash while reading font settings + - fixed memory leak + +Version 0.3.0.15 + - fixed one major unexpected crash + +Version 0.3.0.14 + - unicode support + - fixed minor bug related to settings reading + - fixed potential crash with the tooltip moving + - other minor fixes + +Version 0.2.0.2 + - obey 'suppress online notification' setting + - sound plays only if the event notification is checked + - minor stability fixes + - translation file update + +Version 0.2.0.1 + - stability fixes + +Version 0.2.0.0 + - some controls' text fields are enlarged (translators requests) + - win9x misworking fixed (not tested) + - new abilities: + - proto name prefixing + - enabled back + - work in conjunction with 'suppress online notification' + +Version 0.1.0.0 + - the whole code rewritten in cpp + - new abilities: + - suppress notifications upon connect + - typing notification + - disabled + - work in conjunction with 'suppress online notification' + +Version 0.0.6.0 + - rewritten code of the tooltip window + - tooltip dragging behavior changed (now with usual left-click) + - new options: + - double click on tooltip action + - font and color customization + - some minor fixes/changes + +Version 0.0.5.0 + - sound support for the contact events + - added a button to run the tooltip within the options dialog to test it + - some minor changes + +Version 0.0.4.3 + - protocols selection bug fixed + +Version 0.0.4.2 + - translucency options + - translation support + +Version 0.0.4.0 + - ability to select protocols to react to + - ability of custom tooltip placement + +Version 0.0.3.1 + - a little translations added + +Version 0.0.3.0 + - options moved to events->tooltip notify + - options added: + - allow tooltip duration adjusting + - conjunctive work with 'Suppress online notification' + - fixed showing a tooltip when protocol goes offline + - plugin size reduced + +Version 0.0.2.4 + - some internal fixes + + +Copyright +_________ + +Copyright (C) 2004-2008 Gneedah software (perf@mail333.com) + + + +DISCLAIMER OF WARRANTY +-------------------------------------------------------------------- + +This software is distributed "AS IS" without any warranties. +USE IT AT YOU OWN RISK. diff --git a/plugins/TooltipNotify/docs/ttnotify_translation.txt b/plugins/TooltipNotify/docs/ttnotify_translation.txt new file mode 100644 index 0000000000..2c7d965d67 --- /dev/null +++ b/plugins/TooltipNotify/docs/ttnotify_translation.txt @@ -0,0 +1,47 @@ +; This is a template for Tooltip Notify translation. + + +; ******** Plugin info ******** +;[Tooltip Notify] +;[Shows a small tooltip above system tray area when a contact status is changed] + + +; ******** Options and tooltip text ******** + +;[Notify upon the following contact status changes] +;[Online] +;[Offline] +;[Away] +;[N/A] +;[Occupied] +;[DND] +;[Free for chat] +;[Invisible] +;[All other] +;[Unknown] +;[Typing] +;[Idle] +;[Suppress notifications upon connection for] +;[sec] +;[Prefix proto name] +;[Protocols] +;[is] + +;[Duration] +;[Show tooltip for] +;[ms] +;[Duration x2 upon online event] + +;[Double click on tooltip] +;[Shows/Hides CList] +;[Opens message dialog] + +;[Misc] +;[Obey 'Suppress online notification' settings] +;[Auto positioning] +;[Transparent input] + +;[Preview] + +;[Translucency options (Windows 2000/XP only)] +;[Transparent tooltip] diff --git a/plugins/TooltipNotify/res/main.rc b/plugins/TooltipNotify/res/main.rc new file mode 100644 index 0000000000..74f0c4221b --- /dev/null +++ b/plugins/TooltipNotify/res/main.rc @@ -0,0 +1,204 @@ +// Microsoft Visual C++ generated resource script. +// +#include "..\src\resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#define APSTUDIO_HIDDEN_SYMBOLS +#include "windows.h" +#undef APSTUDIO_HIDDEN_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Russian resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) +#ifdef _WIN32 +LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT +#pragma code_page(1251) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\\src\\resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" + "#include ""windows.h""\r\n" + "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "#include ""version.rc2""\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // Russian resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_PROTOS DIALOGEX 0, 0, 106, 138 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | + WS_CAPTION | WS_SYSMENU +CAPTION "Select protocols" +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + DEFPUSHBUTTON "OK",IDOK,28,117,50,14 + CONTROL "List1",IDC_PROTOS,"SysListView32",LVS_LIST | + LVS_SINGLESEL | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | + WS_BORDER | WS_TABSTOP,7,7,91,103 +END + +IDD_CONTACTS DIALOGEX 0, 0, 284, 234 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | + WS_CAPTION | WS_SYSMENU +CAPTION "Choose contacts..." +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + LTEXT "Allow tooltip notifications for the following users:", + IDC_STATIC,8,9,268,9 + CONTROL "",IDC_CLIST,"CListControl",WS_TABSTOP | 0x3da,7,23,270, + 180,WS_EX_CLIENTEDGE + DEFPUSHBUTTON "OK",IDOK,171,213,50,14 + PUSHBUTTON "Cancel",IDCANCEL,227,213,50,14 +END + +IDD_OPTIONS DIALOGEX 0, 0, 316, 250 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + GROUPBOX "Notify upon the following events",IDC_STATIC,5,7,304,32, + WS_GROUP + CONTROL "Online",IDC_ONLINE,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,15,17,46,14 + CONTROL "Offline",IDC_OFFLINE,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,66,17,46,14 + CONTROL "All other",IDC_OTHER,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,117,17,52,14 + CONTROL "Typing",IDC_TYPING,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,174,17,51,14 + PUSHBUTTON "Protocols",IDC_SEL_PROTO,254,162,46,14 + LTEXT "Suppress notifications upon connection for",IDC_STATIC, + 120,93,137,9 + EDITTEXT IDC_DELAYONCONN,259,91,27,12,ES_RIGHT | ES_NUMBER + CONTROL "Spin1",IDC_DELAYONCONNSPIN,"msctls_updown32", + UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | + UDS_ARROWKEYS | UDS_NOTHOUSANDS,280,86,11,14 + LTEXT "sec",IDC_STATIC,290,93,12,10 + CONTROL "Prefix proto name",IDC_PREFIX_PROTO,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,15,163,70,11 + GROUPBOX "Duration",IDC_GB_DURATION,5,43,304,30 + LTEXT "Show tooltip for",IDC_STATIC,15,55,51,10 + EDITTEXT IDC_DURATION,69,53,36,12,ES_RIGHT | ES_NUMBER + CONTROL "Spin1",IDC_DURATIONSPIN,"msctls_updown32", + UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | + UDS_ARROWKEYS | UDS_NOTHOUSANDS,100,47,10,14 + LTEXT "ms",IDC_STATIC,109,55,14,10 + CONTROL "Duration x2 upon online event",IDC_X2,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,159,55,137,10 + GROUPBOX "Double click on tooltip",IDC_GB_DBLCLICK,5,78,103,54 + CONTROL "Shows/Hides CList",IDC_RB_CLIST,"Button", + BS_AUTORADIOBUTTON | WS_TABSTOP,15,93,83,11 + CONTROL "Opens message dialog",IDC_RB_MSGDLG,"Button", + BS_AUTORADIOBUTTON | WS_TABSTOP,15,112,88,11 + GROUPBOX "Behavior",IDC_STATIC,113,78,196,54 + GROUPBOX "Misc",IDC_STATIC,5,136,304,44 + CONTROL "Obey 'Suppress online notification' settings", + IDC_CONJSOLN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,119, + 112,164,11 + CONTROL "Auto positioning",IDC_AUTOPOS,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,15,147,75,11 + CONTROL "Transparent input",IDC_TRANSP_INPUT,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,96,147,81,11 + PUSHBUTTON "Preview",IDC_PREVIEW,201,162,46,14 + GROUPBOX "Translucency options (Windows 2000/XP only)", + IDC_GB_TRANSP,5,185,304,34 + CONTROL "Transparent tooltip",IDC_TRANSPARENCY,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,15,200,73,9 + CONTROL "Slider1",IDC_TRANSPARENCY_SLIDER,"msctls_trackbar32", + TBS_TOP | TBS_NOTICKS | WS_TABSTOP,94,199,170,11 + LTEXT "000%",IDC_TRANSPERC,273,201,22,9 + PUSHBUTTON "Contacts",IDC_IGNORE,254,144,46,14 + CONTROL "Idle",IDC_IDLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, + 227,17,51,14 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_PROTOS, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 99 + TOPMARGIN, 7 + BOTTOMMARGIN, 131 + END + + IDD_CONTACTS, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 277 + TOPMARGIN, 7 + BOTTOMMARGIN, 227 + END + + IDD_OPTIONS, DIALOG + BEGIN + VERTGUIDE, 5 + VERTGUIDE, 309 + HORZGUIDE, 246 + END +END +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/TooltipNotify/res/version.rc b/plugins/TooltipNotify/res/version.rc new file mode 100644 index 0000000000..e8bd32c519 --- /dev/null +++ b/plugins/TooltipNotify/res/version.rc @@ -0,0 +1,53 @@ +// +// version.rc2 - resources Microsoft Visual C++ does not edit directly +// + +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#include "afxres.h" +#include "..\src\version.h" + +VS_VERSION_INFO VERSIONINFO + FILEVERSION MAJOR,MINOR,BUILD,REVISION + PRODUCTVERSION MAJOR,MINOR,BUILD,REVISION + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "Shows a small tooltip above system tray area when a contact status is changed." + VALUE "CompanyName", "Gneedah software" + VALUE "FileDescription", "Tooltip Notify plugin for Miranda IM." + VALUE "FileVersion", "*,*,*,*" + VALUE "InternalName", "ttnotify.dll" + VALUE "LegalCopyright", "© 2004-2008 Gneedah software" + VALUE "OriginalFilename", "ttnotify.dll" + VALUE "ProductName", "Tooltip Notify" + VALUE "ProductVersion", "*,*,*,*" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + + +///////////////////////////////////////////////////////////////////////////// diff --git a/plugins/TooltipNotify/src/main.rc b/plugins/TooltipNotify/src/main.rc deleted file mode 100644 index fe1fbad85f..0000000000 --- a/plugins/TooltipNotify/src/main.rc +++ /dev/null @@ -1,204 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#define APSTUDIO_HIDDEN_SYMBOLS -#include "windows.h" -#undef APSTUDIO_HIDDEN_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Russian resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) -#ifdef _WIN32 -LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT -#pragma code_page(1251) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" - "#include ""windows.h""\r\n" - "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "#include ""version.rc2""\0" -END - -#endif // APSTUDIO_INVOKED - -#endif // Russian resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_PROTOS DIALOGEX 0, 0, 106, 138 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | - WS_CAPTION | WS_SYSMENU -CAPTION "Select protocols" -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - DEFPUSHBUTTON "OK",IDOK,28,117,50,14 - CONTROL "List1",IDC_PROTOS,"SysListView32",LVS_LIST | - LVS_SINGLESEL | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | - WS_BORDER | WS_TABSTOP,7,7,91,103 -END - -IDD_CONTACTS DIALOGEX 0, 0, 284, 234 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | - WS_CAPTION | WS_SYSMENU -CAPTION "Choose contacts..." -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - LTEXT "Allow tooltip notifications for the following users:", - IDC_STATIC,8,9,268,9 - CONTROL "",IDC_CLIST,"CListControl",WS_TABSTOP | 0x3da,7,23,270, - 180,WS_EX_CLIENTEDGE - DEFPUSHBUTTON "OK",IDOK,171,213,50,14 - PUSHBUTTON "Cancel",IDCANCEL,227,213,50,14 -END - -IDD_OPTIONS DIALOGEX 0, 0, 316, 250 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - GROUPBOX "Notify upon the following events",IDC_STATIC,5,7,304,32, - WS_GROUP - CONTROL "Online",IDC_ONLINE,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,15,17,46,14 - CONTROL "Offline",IDC_OFFLINE,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,66,17,46,14 - CONTROL "All other",IDC_OTHER,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,117,17,52,14 - CONTROL "Typing",IDC_TYPING,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,174,17,51,14 - PUSHBUTTON "Protocols",IDC_SEL_PROTO,254,162,46,14 - LTEXT "Suppress notifications upon connection for",IDC_STATIC, - 120,93,137,9 - EDITTEXT IDC_DELAYONCONN,259,91,27,12,ES_RIGHT | ES_NUMBER - CONTROL "Spin1",IDC_DELAYONCONNSPIN,"msctls_updown32", - UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | - UDS_ARROWKEYS | UDS_NOTHOUSANDS,280,86,11,14 - LTEXT "sec",IDC_STATIC,290,93,12,10 - CONTROL "Prefix proto name",IDC_PREFIX_PROTO,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,15,163,70,11 - GROUPBOX "Duration",IDC_GB_DURATION,5,43,304,30 - LTEXT "Show tooltip for",IDC_STATIC,15,55,51,10 - EDITTEXT IDC_DURATION,69,53,36,12,ES_RIGHT | ES_NUMBER - CONTROL "Spin1",IDC_DURATIONSPIN,"msctls_updown32", - UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | - UDS_ARROWKEYS | UDS_NOTHOUSANDS,100,47,10,14 - LTEXT "ms",IDC_STATIC,109,55,14,10 - CONTROL "Duration x2 upon online event",IDC_X2,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,159,55,137,10 - GROUPBOX "Double click on tooltip",IDC_GB_DBLCLICK,5,78,103,54 - CONTROL "Shows/Hides CList",IDC_RB_CLIST,"Button", - BS_AUTORADIOBUTTON | WS_TABSTOP,15,93,83,11 - CONTROL "Opens message dialog",IDC_RB_MSGDLG,"Button", - BS_AUTORADIOBUTTON | WS_TABSTOP,15,112,88,11 - GROUPBOX "Behavior",IDC_STATIC,113,78,196,54 - GROUPBOX "Misc",IDC_STATIC,5,136,304,44 - CONTROL "Obey 'Suppress online notification' settings", - IDC_CONJSOLN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,119, - 112,164,11 - CONTROL "Auto positioning",IDC_AUTOPOS,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,15,147,75,11 - CONTROL "Transparent input",IDC_TRANSP_INPUT,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,96,147,81,11 - PUSHBUTTON "Preview",IDC_PREVIEW,201,162,46,14 - GROUPBOX "Translucency options (Windows 2000/XP only)", - IDC_GB_TRANSP,5,185,304,34 - CONTROL "Transparent tooltip",IDC_TRANSPARENCY,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,15,200,73,9 - CONTROL "Slider1",IDC_TRANSPARENCY_SLIDER,"msctls_trackbar32", - TBS_TOP | TBS_NOTICKS | WS_TABSTOP,94,199,170,11 - LTEXT "000%",IDC_TRANSPERC,273,201,22,9 - PUSHBUTTON "Contacts",IDC_IGNORE,254,144,46,14 - CONTROL "Idle",IDC_IDLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, - 227,17,51,14 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_PROTOS, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 99 - TOPMARGIN, 7 - BOTTOMMARGIN, 131 - END - - IDD_CONTACTS, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 277 - TOPMARGIN, 7 - BOTTOMMARGIN, 227 - END - - IDD_OPTIONS, DIALOG - BEGIN - VERTGUIDE, 5 - VERTGUIDE, 309 - HORZGUIDE, 246 - END -END -#endif // APSTUDIO_INVOKED - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#include "version.rc" -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/plugins/TooltipNotify/src/version.rc b/plugins/TooltipNotify/src/version.rc deleted file mode 100644 index da191b4d06..0000000000 --- a/plugins/TooltipNotify/src/version.rc +++ /dev/null @@ -1,52 +0,0 @@ -// -// version.rc2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -#include "version.h" - -VS_VERSION_INFO VERSIONINFO - FILEVERSION MAJOR,MINOR,BUILD,REVISION - PRODUCTVERSION MAJOR,MINOR,BUILD,REVISION - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "Comments", "Shows a small tooltip above system tray area when a contact status is changed." - VALUE "CompanyName", "Gneedah software" - VALUE "FileDescription", "Tooltip Notify plugin for Miranda IM." - VALUE "FileVersion", "*,*,*,*" - VALUE "InternalName", "ttnotify.dll" - VALUE "LegalCopyright", "© 2004-2008 Gneedah software" - VALUE "OriginalFilename", "ttnotify.dll" - VALUE "ProductName", "Tooltip Notify" - VALUE "ProductVersion", "*,*,*,*" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - - -///////////////////////////////////////////////////////////////////////////// diff --git a/plugins/TooltipNotify/tooltipnotify-translation.txt b/plugins/TooltipNotify/tooltipnotify-translation.txt deleted file mode 100644 index 44862c316f..0000000000 --- a/plugins/TooltipNotify/tooltipnotify-translation.txt +++ /dev/null @@ -1,55 +0,0 @@ -; Common strings that belong to many files -;[Idle] -;[Offline] -;[Online] -;[Typing] - -; ../../plugins/TooltipNotify/src/TooltipNotify.cpp -;[** New contacts **] -;[** Unknown contacts **] -;[Appearance] -;[Away] -;[DND] -;[Free for chat] -;[Invisible] -;[N/A] -;[Not Idle] -;[Occupied] -;[Tooltip Notify] -;[Tooltip Notify: Offline] -;[Tooltip Notify: Online] -;[Tooltip Notify: Other] -;[Tooltip Notify: Typing] -;[Unknown] -;[is] - -; ../../plugins/TooltipNotify/src/main.rc -;[All other] -;[Allow tooltip notifications for the following users:] -;[Auto positioning] -;[Behavior] -;[Cancel] -;[Choose contacts...] -;[Contacts] -;[Double click on tooltip] -;[Duration] -;[Duration x2 upon online event] -;[Misc] -;[Notify upon the following events] -;[OK] -;[Obey 'Suppress online notification' settings] -;[Opens message dialog] -;[Prefix proto name] -;[Preview] -;[Protocols] -;[Select protocols] -;[Show tooltip for] -;[Shows/Hides CList] -;[Slider1] -;[Spin1] -;[Suppress notifications upon connection for] -;[Translucency options (Windows 2000/XP only)] -;[Transparent input] -;[Transparent tooltip] -;[ms] -;[sec] diff --git a/plugins/TooltipNotify/ttnotify_10.vcxproj b/plugins/TooltipNotify/ttnotify_10.vcxproj index 462b200e03..87907f9dca 100644 --- a/plugins/TooltipNotify/ttnotify_10.vcxproj +++ b/plugins/TooltipNotify/ttnotify_10.vcxproj @@ -73,7 +73,7 @@ Disabled ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;TTNOTIFY_EXPORTS;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL @@ -96,7 +96,7 @@ Disabled ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN64;_DEBUG;_WINDOWS;_USRDLL;TTNOTIFY_EXPORTS;%(PreprocessorDefinitions) + WIN64;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL Level3 @@ -119,7 +119,7 @@ OnlyExplicitInline Size ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;TTNOTIFY_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) Fast Level3 true @@ -144,7 +144,7 @@ OnlyExplicitInline Size ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN64;NDEBUG;_WINDOWS;_USRDLL;TTNOTIFY_EXPORTS;%(PreprocessorDefinitions) + WIN64;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) Fast Level3 true @@ -181,13 +181,8 @@ - - - - - - - + + diff --git a/plugins/TooltipNotify/ttnotify_10.vcxproj.filters b/plugins/TooltipNotify/ttnotify_10.vcxproj.filters index d35110bfa0..dbbaafbbf1 100644 --- a/plugins/TooltipNotify/ttnotify_10.vcxproj.filters +++ b/plugins/TooltipNotify/ttnotify_10.vcxproj.filters @@ -1,73 +1,68 @@ п»ї - - {c12316ee-1d9e-470b-a9d4-2f96e30ea10d} + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - {9fe30d32-97fa-41fc-8586-9f52a8580112} + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - src + Source Files - src + Source Files - src + Source Files - src + Source Files - src + Source Files - src + Source Files - src + Header Files - src + Header Files - src + Header Files - src + Header Files - src + Header Files - src + Header Files - src + Header Files - - src + + Resource Files + + + Resource Files - - - - doc - - - doc - - - doc - - - doc - \ No newline at end of file diff --git a/plugins/TopToolBar/BkgrCfg.h b/plugins/TopToolBar/BkgrCfg.h deleted file mode 100644 index 4533267fcb..0000000000 --- a/plugins/TopToolBar/BkgrCfg.h +++ /dev/null @@ -1,18 +0,0 @@ -// -// Register of plugin's user -// -// wParam = (WPARAM)szSetting - string that describes a user -// format: Category/ModuleName, -// eg: "Contact list background/CLUI", -// "Status bar background/StatusBar" -// lParam = (LPARAM)dwFlags -// -#define MS_BACKGROUNDCONFIG_REGISTER "BkgrCfg/Register" - -// -// Notification about changed background -// wParam = ModuleName -// lParam = 0 -#define ME_BACKGROUNDCONFIG_CHANGED "BkgrCfg/Changed" - -#define CLBF_TILEVTOROWHEIGHT 0x0100 diff --git a/plugins/TopToolBar/InternalButtons.cpp b/plugins/TopToolBar/InternalButtons.cpp deleted file mode 100644 index 7fcdc1cef8..0000000000 --- a/plugins/TopToolBar/InternalButtons.cpp +++ /dev/null @@ -1,121 +0,0 @@ - -#include "common.h" - -#define TTBI_GROUPSHOWHIDE "TTBInternal/GroupShowHide" -#define TTBI_SOUNDSONOFF "TTBInternal/SoundsOnOFF" -#define TTBI_MAINMENUBUTT "TTBInternal/MainMenuBUTT" - -extern HINSTANCE hInst; - -static HWND hwndContactTree; - -struct -{ - char *name, *pszService; - int iconidUp, iconidDn; - char *tooltipUp, *tooltipDn; - HANDLE hButton; -} -static stdButtons[] = -{ - { "Show only Online Users", MS_CLIST_SETHIDEOFFLINE, IDI_SHOWONLINEUP, IDI_SHOWONLINEDN, "Hide Offline Users", "Show All Users" }, - { "Groups On/Off", TTBI_GROUPSHOWHIDE, IDI_GROUPSUP, IDI_GROUPSDN, "Hide Groups", "Show Groups" }, - { "Sounds Enable/Disable", TTBI_SOUNDSONOFF, IDI_SOUNDUP, IDI_SOUNDDN, "Disable Sounds", "Enable Sounds" }, - - { "Show Options Page", "Options/OptionsCommand", IDI_OPTIONSUP, 0, "Show Options" }, - { "Minimize Button", MS_CLIST_SHOWHIDE, IDI_MINIMIZEUP, 0, NULL }, - { "Find/Add Contacts", MS_FINDADD_FINDADD, IDI_FINDADDUP, 0, NULL }, - { "Show Main Menu", TTBI_MAINMENUBUTT, IDI_MIRANDAUP, 0, "Show Main Menu" } -}; - -/////////////////////////////////////////////////////////////////////////////// - -int OnSettingChanging(WPARAM wParam, LPARAM lParam) -{ - DBCONTACTWRITESETTING *dbcws = (DBCONTACTWRITESETTING *)lParam; - if (wParam != 0 || dbcws == NULL) - return 0; - - if ( !strcmp(dbcws->szModule, "CList")) { - if ( !strcmp(dbcws->szSetting, "HideOffline")) - CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[0].hButton, (dbcws->value.bVal) ? TTBST_PUSHED : TTBST_RELEASED); - - else if (!strcmp(dbcws->szSetting, "UseGroups")) - CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[1].hButton, (dbcws->value.bVal) ? TTBST_PUSHED : TTBST_RELEASED); - } - - else if (!strcmp(dbcws->szModule, "Skin")) { - if (!strcmp(dbcws->szSetting, "UseSound")) - CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[2].hButton, (dbcws->value.bVal) ? TTBST_RELEASED : TTBST_PUSHED); - } - - return 0; -} - -INT_PTR TTBInternalMainMenuButt(WPARAM wParam, LPARAM lParam) -{ - HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUGETMAIN, 0, 0); - - POINT pt; - GetCursorPos(&pt); - TrackPopupMenu(hMenu, TPM_TOPALIGN|TPM_LEFTALIGN|TPM_RIGHTBUTTON, pt.x, pt.y, 0, (HWND)CallService(MS_CLUI_GETHWND, 0, 0), NULL); - return 0; -} - -INT_PTR TTBInternalGroupShowHide(WPARAM wParam, LPARAM lParam) -{ - int newVal = !(GetWindowLongPtr(hwndContactTree, GWL_STYLE)&CLS_USEGROUPS); - db_set_b(NULL, "CList", "UseGroups", (BYTE)newVal); - SendMessage(hwndContactTree, CLM_SETUSEGROUPS, newVal, 0); - return 0; -} - -INT_PTR TTBInternalSoundsOnOff(WPARAM wParam, LPARAM lParam) -{ - int newVal = !(db_get_b(NULL, "Skin", "UseSound", 1)); - db_set_b(NULL, "Skin", "UseSound", (BYTE)newVal); - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// - -int InitInternalButtons(WPARAM, LPARAM) -{ - hwndContactTree = (HWND)CallService(MS_CLUI_GETHWNDTREE, 0, 0); - - CreateServiceFunction(TTBI_GROUPSHOWHIDE, TTBInternalGroupShowHide); - CreateServiceFunction(TTBI_SOUNDSONOFF, TTBInternalSoundsOnOff); - CreateServiceFunction(TTBI_MAINMENUBUTT, TTBInternalMainMenuButt); - - TTBButton ttb = { 0 }; - ttb.cbSize = sizeof(ttb); - - for (int i=0; i < SIZEOF(stdButtons); i++) { - ttb.name = stdButtons[i].name; - ttb.pszService = stdButtons[i].pszService; - ttb.dwFlags = TTBBF_VISIBLE | TTBBF_INTERNAL; - if ((ttb.pszTooltipDn = stdButtons[i].tooltipDn) != NULL) - ttb.dwFlags |= TTBBF_SHOWTOOLTIP; - ttb.pszTooltipUp = stdButtons[i].tooltipUp; - ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(stdButtons[i].iconidUp), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); - if (stdButtons[i].iconidDn) { - ttb.dwFlags |= TTBBF_ASPUSHBUTTON; - ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(stdButtons[i].iconidDn), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); - } - else ttb.hIconDn = NULL; - - stdButtons[i].hButton = (HANDLE)TTBAddButton((WPARAM)&ttb, 0); - } - - CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[0].hButton, - db_get_b(NULL, "CList", "HideOffline", 0) ? TTBST_PUSHED : TTBST_RELEASED); - - CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[1].hButton, - db_get_b(NULL, "CList", "UseGroups", 1) ? TTBST_PUSHED : TTBST_RELEASED); - - CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[2].hButton, - db_get_b(NULL, "Skin", "UseSound", 1) ? TTBST_RELEASED : TTBST_PUSHED); - - HookEvent(ME_DB_CONTACT_SETTINGCHANGED, OnSettingChanging); - return 0; -} diff --git a/plugins/TopToolBar/TopToolBar.vcxproj b/plugins/TopToolBar/TopToolBar.vcxproj index 312bf92d2c..72061381ba 100644 --- a/plugins/TopToolBar/TopToolBar.vcxproj +++ b/plugins/TopToolBar/TopToolBar.vcxproj @@ -76,22 +76,13 @@ true - - _DEBUG;%(PreprocessorDefinitions) - true - true - Win32 - .\Debug/TopToolBar.tlb - - - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;TOPTOOLBAR_EXPORTS;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true EnableFastChecks - true EditAndContinue + Level3 ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) MultiThreadedDebug Use @@ -99,37 +90,22 @@ _DEBUG;%(PreprocessorDefinitions) - 0x0419 ..\..\include\msapi comctl32.lib;%(AdditionalDependencies) - true true 0x1b200000 $(IntDir)$(TargetName).lib - MachineX86 $(SolutionDir)\lib - - true - - - _DEBUG;%(PreprocessorDefinitions) - true - true - .\Debug/TopToolBar.tlb - - - Disabled - WIN64;_DEBUG;_WINDOWS;_USRDLL;TOPTOOLBAR_EXPORTS;%(PreprocessorDefinitions) + WIN64;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) EnableFastChecks - true - ProgramDatabase + Level3 ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) MultiThreadedDebug Use @@ -137,39 +113,24 @@ _DEBUG;%(PreprocessorDefinitions) - 0x0419 ..\..\include\msapi comctl32.lib;%(AdditionalDependencies) - true true 0x1b200000 $(IntDir)$(TargetName).lib $(SolutionDir)\lib - - true - - - NDEBUG;%(PreprocessorDefinitions) - true - true - Win32 - .\Release/TopToolBar.tlb - - - Full OnlyExplicitInline - WIN32;NDEBUG;_WINDOWS;_USRDLL;TOPTOOLBAR_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true true Level3 - true ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) Size Use @@ -177,41 +138,26 @@ NDEBUG;%(PreprocessorDefinitions) - 0x0409 ..\..\include\msapi comctl32.lib;%(AdditionalDependencies) - true 0x1b200000 $(IntDir)$(TargetName).lib - MachineX86 true true true $(SolutionDir)\lib - - true - - - NDEBUG;%(PreprocessorDefinitions) - true - true - .\Release/TopToolBar.tlb - - - Full OnlyExplicitInline - WIN64;NDEBUG;_WINDOWS;_USRDLL;TOPTOOLBAR_EXPORTS;%(PreprocessorDefinitions) + WIN64;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true true Level3 - true ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) Size Use @@ -219,12 +165,10 @@ NDEBUG;%(PreprocessorDefinitions) - 0x0409 ..\..\include\msapi comctl32.lib;%(AdditionalDependencies) - true 0x1b200000 $(IntDir)$(TargetName).lib true @@ -232,48 +176,26 @@ true $(SolutionDir)\lib - - true - - - - - - - - - - - - - - - - - - - + + + + - - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - %(PreprocessorDefinitions) - - + + - - + + Create - - - - + + + + diff --git a/plugins/TopToolBar/TopToolBar.vcxproj.filters b/plugins/TopToolBar/TopToolBar.vcxproj.filters index 500784079b..bd1465a04d 100644 --- a/plugins/TopToolBar/TopToolBar.vcxproj.filters +++ b/plugins/TopToolBar/TopToolBar.vcxproj.filters @@ -15,82 +15,44 @@ - + Header Files - + Header Files - + Header Files - + Header Files - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - - + Resource Files - + Resource Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files diff --git a/plugins/TopToolBar/bmp/sep.bmp b/plugins/TopToolBar/bmp/sep.bmp deleted file mode 100644 index 1665285275..0000000000 Binary files a/plugins/TopToolBar/bmp/sep.bmp and /dev/null differ diff --git a/plugins/TopToolBar/common.h b/plugins/TopToolBar/common.h deleted file mode 100644 index 0840111f2f..0000000000 --- a/plugins/TopToolBar/common.h +++ /dev/null @@ -1,157 +0,0 @@ -#ifndef TTB_COMMON_H -#define TTB_COMMON_H - - -#define _CRT_SECURE_NO_WARNINGS - -#include -#include -#include -#include -#include -#include -#include - -#include "win2k.h" -#include "newpluginapi.h" -#include "m_system.h" -#include "m_system_cpp.h" -#include "m_database.h" -#include "m_clist.h" -#include "m_skin.h" -#include "m_utils.h" -#include "m_cluiframes.h" -#include "m_clui.h" -#include "m_clc.h" -#include "m_findadd.h" -#include "m_langpack.h" -#include "m_options.h" -#include "resource.h" -#include "m_protocols.h" -#include "m_protosvc.h" -#include "m_toptoolbar.h" -#include "m_button.h" -#include "m_icolib.h" -#include "BkgrCfg.h" - -#define TTB_BUTTON_CLASS _T("TopToolbarButtonClass") - -#define TTB_REPOSBUTTONS (WM_USER+10) -#define TTB_UPDATEFRAMEVISIBILITY (WM_USER+11) - -#define TTBDEFAULT_BKBMPUSE CLB_STRETCH -#define TTBDEFAULT_BKCOLOUR GetSysColor(COLOR_3DFACE) -#define TTBDEFAULT_USEBITMAP 0 -#define TTBDEFAULT_SELBKCOLOUR GetSysColor(COLOR_HIGHLIGHT) - -#define TTBBF_INTERNAL 0x1000000 -#define TTBBF_OPTIONAL 0x2000000 - -/////////////////////////////////////////////////////////////////////////////// -// TopButtonInt class - -struct TopButtonInt : public MZeroedObject -{ - ~TopButtonInt(); - - DWORD CheckFlags(DWORD Flags); - void CreateWnd(void); - void LoadSettings(void); - void SaveSettings(int *SepCnt, int *LaunchCnt); - void SetBitmap(void); - - __inline bool isSep() const - { return (dwFlags & TTBBF_ISSEPARATOR) != 0; - } - - __inline bool isVisible() const - { return (dwFlags & TTBBF_VISIBLE) != 0; - } - - HWND hwnd; - int id; - BOOL bPushed; - int dwFlags; - int x, y, arrangedpos; - HICON hIconUp, hIconDn; - HANDLE hIconHandleUp, hIconHandleDn; - - char *pszService; - TCHAR *ptszProgram; - char *pszName; - TCHAR *ptszTooltip; - - LPARAM lParamUp; - WPARAM wParamUp; - LPARAM lParamDown; - WPARAM wParamDown; - - int hLangpack; - TCHAR *ptszTooltipUp, *ptszTooltipDn; -}; - -/////////////////////////////////////////////////////////////////////////////// - -int TTBOptInit(WPARAM wParam, LPARAM lParam); -//append string -char __inline *AS(char *str, const char *setting, char *addstr); - -TopButtonInt* CreateButton(TTBButton* but); - -int LoadBackgroundOptions(); - -int ArrangeButtons(); - -#define DEFBUTTWIDTH 20 -#define DEFBUTTHEIGHT 20 -#define DEFBUTTGAP 1 - -#define SEPWIDTH 3 - -extern TTBCtrl* g_ctrl; - -extern LIST Buttons; -extern HINSTANCE hInst; -extern HBITMAP hBmpBackground, hBmpSeparator; -extern CRITICAL_SECTION csButtonsHook; -extern pfnCustomProc g_CustomProc; -extern LPARAM g_CustomProcParam; -extern HANDLE hTTBModuleLoaded, hTTBInitButtons; - -void AddToOptions(TopButtonInt* b); -void RemoveFromOptions(int id); - -//append string -char *AS(char *str, const char *setting, char *addstr) -{ - if (str != NULL) { - strcpy(str, setting); - strcat(str, addstr); - } - return str; -} - -#define TTB_LAUNCHSERVICE "TTB/LaunchService" - -TopButtonInt* idtopos(int id, int* pPos=NULL); - -INT_PTR TTBAddButton(WPARAM, LPARAM); -INT_PTR TTBRemoveButton(WPARAM, LPARAM); - -int InitInternalButtons(WPARAM, LPARAM); - -int LoadToolbarModule( void ); -int UnloadToolbarModule( void ); - -void SetAllBitmaps( void ); -int SaveAllLButs( void ); -int SaveAllButtonsOptions( void ); - -void InsertSeparator( int i ); -void DeleteSeparator(int i); -void DeleteLBut(int i); -void InsertLBut(int i); - -int OnModulesLoad(WPARAM, LPARAM); - -#endif \ No newline at end of file diff --git a/plugins/TopToolBar/docs/toptoolbar-translation.txt b/plugins/TopToolBar/docs/toptoolbar-translation.txt new file mode 100644 index 0000000000..fcc295b539 --- /dev/null +++ b/plugins/TopToolBar/docs/toptoolbar-translation.txt @@ -0,0 +1,40 @@ +; Common strings that belong to many files +;[Default] + +; ../../plugins/TopToolBar/InternalButtons.cpp +;[Disable Sounds] +;[Enable Sounds] +;[Hide Offline Users] +;[Show All Users] + +; ../../plugins/TopToolBar/main.rc +;[Add Launch] +;[Add Separator] +;[Background colour:] +;[Button Gap ] +;[Button Height] +;[Button Width ] +;[Buttons Order && Visibility] +;[Buttons order:] +;[Del Sep/Launch Button] +;[Name: ] +;[Path:] +;[Scroll with text] +;[Selection colour:] +;[Set] +;[Stretch proportionally] +;[Stretch to height] +;[Stretch to width] +;[Tile horizontally] +;[Tile vertically] +;[TopToolBar Background] +;[Use Flat Mode] +;[Use background bitmap] + +; ../../plugins/TopToolBar/toolbar.cpp +;[Frames Services not found - plugin disabled.You need MultiWindow plugin.] + +; ../../plugins/TopToolBar/ttbopt.cpp +;[Buttons] +;[TTBBackground] +;[TopToolBar] diff --git a/plugins/TopToolBar/docs/ttb-readme.txt b/plugins/TopToolBar/docs/ttb-readme.txt new file mode 100644 index 0000000000..9c127d5c71 --- /dev/null +++ b/plugins/TopToolBar/docs/ttb-readme.txt @@ -0,0 +1,160 @@ +About +----- + +TopToolBar +Version 0.7.3.1 +by +Bethoven (bethoven@mailgate.ru) + +Note: This plugin required MultiWindow or clist_mw plugin. + +Description +----------- +TopToolBar adds buttons in top frame for fast access +to miranda/plugins functions. + +Features +-------- + +-Predefined buttons(Hide/Show OfflineUsers,Hide/Show Groups,On/Off Sounds) +-Services for plugins to add/remove/modify new buttons. + + +WhatsNew +-------- +11-04-2008 v0.7.3.1 + - ??? +17-09-2005 v0.7.3.0 + -Fixed "new separator" bug. + -Less flicks on resize. + -Removed default bitmaps. + +11-09-2005 v0.7.2.0 + -Removed default bitmaps. + +11-09-2005 v0.7.1.0 + -Fixed drawing of buttons when Themes enabled. + -New TTBButtonV2 struct for adding buttons (icon member) + +26-06-2005 v0.7.0.0 + -Supporting for miranda buton class + -Supporting for icolib(use with miranda buton class) + -Moved background options to Customize + +26-05-2005 v0.6.0.12 + -Fixed show online users button. + +16-12-2004 v0.6.0.11 + -User defined width and height of buttons + -Support loading of icons. + +23-09-2003 v0.6.0.9 + -Set all bitmaps by selecting directory. + +09-09-2003 v0.6.0.7 + -Fixed some bugs that may cause crash. + +05-05-2003 v0.6 + -Added 2 new internal buttons Minimize and Find/Add contacts. + -Autowraping mode. + -Added separators. + -Added Launch buttons. + +31-03-2003 v0.5.0.1 + -Added background configuration + -Added Button enable/ordering. + -You may change button bitmaps. + -Added two new internal buttons (MainMenu and Options). + +22-03-2003 v0.4.0.1 + -Fixed runtime button removing. + -Fixed ownerdraw borders for buttons. + +11-01-2003 v0.4 + -(dev) Changed service names to sandart look MS_ (thanks hrk). + -(dev) Added border drawing. + -Added tooltips for buttons. + + +13-12-2002 v0.3 + -Added services for add/remove additional buttons from plugins. + (see m_toptoolbar.h for description) + -Added button to quick enable/disable sounds. + -All buttons are synchronized. So if you check hide groups + from menu, button track this. + + +Bitmap Names +---------- +TopToolBar search for bitmaps in this pattern. +Selecteddir/ButtonName_DN.bmp +Selecteddir/ButtonName_UP.bmp +Where ButtonName is non localised name of button. +This chars in name '/','\','*','?','<','>',':','|','"' replaced with '_' + + +Names for standart buttons: + +"Find_Add Contacts_DN.bmp" +"Find_Add Contacts_UP.bmp" +"Groups On_Off_DN.bmp" +"Groups On_Off_UP.bmp" +"Minimize Button_DN.bmp" +"Minimize Button_UP.bmp" +"Show Main Menu_DN.bmp" +"Show Main Menu_UP.bmp" +"Show only Online Users_DN.bmp" +"Show only Online Users_UP.bmp" +"Show Options Page_DN.bmp" +"Show Options Page_UP.bmp" +"Sounds Enable_Disable_DN.bmp" +"Sounds Enable_Disable_UP.bmp" + + +Installation +------------ + +Copy the TopToolBar.dll into Miranda's plugin subdirectory. + + +Translation +----------- +[Hide Offline Users] +[Show All Users] +[Show Groups] +[Hide Groups] +[Disable Sounds] +[Enable Sounds] + + + + +Development +----------- +My radix 27d,0x1B (BET) +My base 0x1b000000 + +Quicksearch base 0x1b000000 +MultiWindow base 0x1b100000 +TopToolBar base 0x1b200000 +SystemStatus base 0x1b300000 + + +License +------- + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + diff --git a/plugins/TopToolBar/icos/Find_Add Contacts_UP.ico b/plugins/TopToolBar/icos/Find_Add Contacts_UP.ico deleted file mode 100644 index 452f2efc98..0000000000 Binary files a/plugins/TopToolBar/icos/Find_Add Contacts_UP.ico and /dev/null differ diff --git a/plugins/TopToolBar/icos/Groups On_Off_DN.ico b/plugins/TopToolBar/icos/Groups On_Off_DN.ico deleted file mode 100644 index 99b7dddd38..0000000000 Binary files a/plugins/TopToolBar/icos/Groups On_Off_DN.ico and /dev/null differ diff --git a/plugins/TopToolBar/icos/Groups On_Off_UP.ico b/plugins/TopToolBar/icos/Groups On_Off_UP.ico deleted file mode 100644 index fffe8e32c4..0000000000 Binary files a/plugins/TopToolBar/icos/Groups On_Off_UP.ico and /dev/null differ diff --git a/plugins/TopToolBar/icos/Minimize Button_UP.ico b/plugins/TopToolBar/icos/Minimize Button_UP.ico deleted file mode 100644 index dd9a8451d7..0000000000 Binary files a/plugins/TopToolBar/icos/Minimize Button_UP.ico and /dev/null differ diff --git a/plugins/TopToolBar/icos/Run.ico b/plugins/TopToolBar/icos/Run.ico deleted file mode 100644 index 7a87fadc82..0000000000 Binary files a/plugins/TopToolBar/icos/Run.ico and /dev/null differ diff --git a/plugins/TopToolBar/icos/Show Main Menu_UP.ico b/plugins/TopToolBar/icos/Show Main Menu_UP.ico deleted file mode 100644 index 8602e4cf3e..0000000000 Binary files a/plugins/TopToolBar/icos/Show Main Menu_UP.ico and /dev/null differ diff --git a/plugins/TopToolBar/icos/Show Options Page_UP.ico b/plugins/TopToolBar/icos/Show Options Page_UP.ico deleted file mode 100644 index d6945d94f5..0000000000 Binary files a/plugins/TopToolBar/icos/Show Options Page_UP.ico and /dev/null differ diff --git a/plugins/TopToolBar/icos/Show only Online Users_DN.ico b/plugins/TopToolBar/icos/Show only Online Users_DN.ico deleted file mode 100644 index 87ef1abbb5..0000000000 Binary files a/plugins/TopToolBar/icos/Show only Online Users_DN.ico and /dev/null differ diff --git a/plugins/TopToolBar/icos/Show only Online Users_UP.ico b/plugins/TopToolBar/icos/Show only Online Users_UP.ico deleted file mode 100644 index e35e015123..0000000000 Binary files a/plugins/TopToolBar/icos/Show only Online Users_UP.ico and /dev/null differ diff --git a/plugins/TopToolBar/icos/Sounds Enable_Disable_DN.ico b/plugins/TopToolBar/icos/Sounds Enable_Disable_DN.ico deleted file mode 100644 index a52dd8a8fe..0000000000 Binary files a/plugins/TopToolBar/icos/Sounds Enable_Disable_DN.ico and /dev/null differ diff --git a/plugins/TopToolBar/icos/Sounds Enable_Disable_UP.ico b/plugins/TopToolBar/icos/Sounds Enable_Disable_UP.ico deleted file mode 100644 index 31342f4ef5..0000000000 Binary files a/plugins/TopToolBar/icos/Sounds Enable_Disable_UP.ico and /dev/null differ diff --git a/plugins/TopToolBar/main.cpp b/plugins/TopToolBar/main.cpp deleted file mode 100644 index 601de36408..0000000000 --- a/plugins/TopToolBar/main.cpp +++ /dev/null @@ -1,51 +0,0 @@ - -#include "common.h" -#include "version.h" - -HINSTANCE hInst; -int hLangpack; - -PLUGININFOEX pluginInfo = -{ - sizeof(PLUGININFOEX), - __PLUGIN_NAME, - PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), - __PLUGIN_DESC, - __PLUGIN_AUTHOR, - __PLUGIN_EMAIL, - __PLUGIN_RIGHTS, - __PLUGIN_AUTHORWEB, - UNICODE_AWARE, - {0xf593c752, 0x51d8, 0x4d46, {0xba, 0x27, 0x37, 0x57, 0x79, 0x53, 0xf5, 0x5c}} -}; - -extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) -{ - return &pluginInfo; -} - -///////////////////////////////////////////////////////////////////////////////////////// - -extern "C" int __declspec(dllexport) Load(void) -{ - mir_getLP(&pluginInfo); - - LoadToolbarModule(); - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// - -extern "C" int __declspec(dllexport) Unload(void) -{ - UnloadToolbarModule(); - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// - -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - hInst = hinstDLL; - return TRUE; -} diff --git a/plugins/TopToolBar/main.rc b/plugins/TopToolBar/main.rc deleted file mode 100644 index f6efd9369b..0000000000 --- a/plugins/TopToolBar/main.rc +++ /dev/null @@ -1,147 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "winres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Neutral resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) -LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -#pragma code_page(1251) - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_OPT_BUTORDER DIALOGEX 0, 0, 300, 231 -STYLE DS_SETFONT | WS_CHILD -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - GROUPBOX "Buttons Order && Visibility",IDC_STATIC,10,0,150,229 - CONTROL "Tree1",IDC_BUTTONORDERTREE,"SysTreeView32",TVS_NOTOOLTIPS | TVS_CHECKBOXES | WS_BORDER | WS_HSCROLL | WS_TABSTOP,18,25,134,197 - LTEXT "Button height",IDC_STATIC,169,134,100,8 - EDITTEXT IDC_BUTTHEIGHT,272,132,27,12,ES_NUMBER - CONTROL "",IDC_SPIN_HEIGHT,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,289,132,8,12 - LTEXT "Button width",IDC_STATIC,169,150,100,8 - EDITTEXT IDC_BUTTWIDTH,272,148,27,12,ES_NUMBER - CONTROL "",IDC_SPIN_WIDTH,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,289,148,8,12 - LTEXT "Interval between buttons",IDC_STATIC,169,166,100,8 - EDITTEXT IDC_BUTTGAP,272,164,27,12,ES_NUMBER - CONTROL "",IDC_SPIN_GAP,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,289,164,8,12 - CONTROL "Use flat mode",IDC_USEFLAT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,167,185,130,10 - CONTROL "Auto resize",IDC_AUTORESIZE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,167,197,130,10 - CONTROL "Single line",IDC_SINGLELINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,167,209,130,10 - LTEXT "Buttons order:",IDC_STATIC,18,15,132,8 - PUSHBUTTON "Add Separator",IDC_ADDSEP,165,5,130,14 - PUSHBUTTON "Add Launch",IDC_ADDLBUTTON,165,25,130,14 - PUSHBUTTON "Del Sep/Launch Button",IDC_REMOVEBUTTON,165,109,130,14 - EDITTEXT IDC_ENAME,200,45,95,14,ES_AUTOHSCROLL - LTEXT "Name: ",IDC_LBUTTONNAME,165,45,30,14,SS_CENTERIMAGE - EDITTEXT IDC_EPATH,165,72,112,14,ES_AUTOHSCROLL - PUSHBUTTON "...",IDC_BROWSE,280,73,15,11 - LTEXT "Path:",IDC_LBUTTONPATH,165,62,30,8 - PUSHBUTTON "Set",IDC_LBUTTONSET,205,90,50,14 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_OPT_BUTORDER, DIALOG - BEGIN - VERTGUIDE, 8 - VERTGUIDE, 140 - VERTGUIDE, 158 - VERTGUIDE, 290 - VERTGUIDE, 297 - BOTTOMMARGIN, 229 - HORZGUIDE, 17 - HORZGUIDE, 38 - HORZGUIDE, 123 - HORZGUIDE, 136 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDB_SEP BITMAP "bmp\\sep.bmp" - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""winres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_SHOWONLINEUP ICON "icos\\Show only Online Users_UP.ico" -IDI_RUN ICON "icos\\run.ico" -IDI_SHOWONLINEDN ICON "icos\\Show only Online Users_DN.ico" -IDI_GROUPSUP ICON "icos\\Groups On_Off_UP.ico" -IDI_GROUPSDN ICON "icos\\Groups On_Off_DN.ico" -IDI_SOUNDDN ICON "icos\\Sounds Enable_Disable_DN.ico" -IDI_SOUNDUP ICON "icos\\Sounds Enable_Disable_UP.ico" -IDI_OPTIONSUP ICON "icos\\Show Options Page_UP.ico" -IDI_MINIMIZEUP ICON "icos\\Minimize Button_UP.ico" -IDI_FINDADDUP ICON "icos\\Find_Add Contacts_UP.ico" -IDI_MIRANDAUP ICON "icos\\Show Main Menu_UP.ico" -#endif // Neutral resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED diff --git a/plugins/TopToolBar/res/Find_Add Contacts_UP.ico b/plugins/TopToolBar/res/Find_Add Contacts_UP.ico new file mode 100644 index 0000000000..452f2efc98 Binary files /dev/null and b/plugins/TopToolBar/res/Find_Add Contacts_UP.ico differ diff --git a/plugins/TopToolBar/res/Groups On_Off_DN.ico b/plugins/TopToolBar/res/Groups On_Off_DN.ico new file mode 100644 index 0000000000..99b7dddd38 Binary files /dev/null and b/plugins/TopToolBar/res/Groups On_Off_DN.ico differ diff --git a/plugins/TopToolBar/res/Groups On_Off_UP.ico b/plugins/TopToolBar/res/Groups On_Off_UP.ico new file mode 100644 index 0000000000..fffe8e32c4 Binary files /dev/null and b/plugins/TopToolBar/res/Groups On_Off_UP.ico differ diff --git a/plugins/TopToolBar/res/Minimize Button_UP.ico b/plugins/TopToolBar/res/Minimize Button_UP.ico new file mode 100644 index 0000000000..dd9a8451d7 Binary files /dev/null and b/plugins/TopToolBar/res/Minimize Button_UP.ico differ diff --git a/plugins/TopToolBar/res/Run.ico b/plugins/TopToolBar/res/Run.ico new file mode 100644 index 0000000000..7a87fadc82 Binary files /dev/null and b/plugins/TopToolBar/res/Run.ico differ diff --git a/plugins/TopToolBar/res/Show Main Menu_UP.ico b/plugins/TopToolBar/res/Show Main Menu_UP.ico new file mode 100644 index 0000000000..8602e4cf3e Binary files /dev/null and b/plugins/TopToolBar/res/Show Main Menu_UP.ico differ diff --git a/plugins/TopToolBar/res/Show Options Page_UP.ico b/plugins/TopToolBar/res/Show Options Page_UP.ico new file mode 100644 index 0000000000..d6945d94f5 Binary files /dev/null and b/plugins/TopToolBar/res/Show Options Page_UP.ico differ diff --git a/plugins/TopToolBar/res/Show only Online Users_DN.ico b/plugins/TopToolBar/res/Show only Online Users_DN.ico new file mode 100644 index 0000000000..87ef1abbb5 Binary files /dev/null and b/plugins/TopToolBar/res/Show only Online Users_DN.ico differ diff --git a/plugins/TopToolBar/res/Show only Online Users_UP.ico b/plugins/TopToolBar/res/Show only Online Users_UP.ico new file mode 100644 index 0000000000..e35e015123 Binary files /dev/null and b/plugins/TopToolBar/res/Show only Online Users_UP.ico differ diff --git a/plugins/TopToolBar/res/Sounds Enable_Disable_DN.ico b/plugins/TopToolBar/res/Sounds Enable_Disable_DN.ico new file mode 100644 index 0000000000..a52dd8a8fe Binary files /dev/null and b/plugins/TopToolBar/res/Sounds Enable_Disable_DN.ico differ diff --git a/plugins/TopToolBar/res/Sounds Enable_Disable_UP.ico b/plugins/TopToolBar/res/Sounds Enable_Disable_UP.ico new file mode 100644 index 0000000000..31342f4ef5 Binary files /dev/null and b/plugins/TopToolBar/res/Sounds Enable_Disable_UP.ico differ diff --git a/plugins/TopToolBar/res/main.rc b/plugins/TopToolBar/res/main.rc new file mode 100644 index 0000000000..025246ebfc --- /dev/null +++ b/plugins/TopToolBar/res/main.rc @@ -0,0 +1,147 @@ +// Microsoft Visual C++ generated resource script. +// +#include "..\src\resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Neutral resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +#pragma code_page(1251) + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_OPT_BUTORDER DIALOGEX 0, 0, 300, 231 +STYLE DS_SETFONT | WS_CHILD +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + GROUPBOX "Buttons Order && Visibility",IDC_STATIC,10,0,150,229 + CONTROL "Tree1",IDC_BUTTONORDERTREE,"SysTreeView32",TVS_NOTOOLTIPS | TVS_CHECKBOXES | WS_BORDER | WS_HSCROLL | WS_TABSTOP,18,25,134,197 + LTEXT "Button height",IDC_STATIC,169,134,100,8 + EDITTEXT IDC_BUTTHEIGHT,272,132,27,12,ES_NUMBER + CONTROL "",IDC_SPIN_HEIGHT,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,289,132,8,12 + LTEXT "Button width",IDC_STATIC,169,150,100,8 + EDITTEXT IDC_BUTTWIDTH,272,148,27,12,ES_NUMBER + CONTROL "",IDC_SPIN_WIDTH,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,289,148,8,12 + LTEXT "Interval between buttons",IDC_STATIC,169,166,100,8 + EDITTEXT IDC_BUTTGAP,272,164,27,12,ES_NUMBER + CONTROL "",IDC_SPIN_GAP,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,289,164,8,12 + CONTROL "Use flat mode",IDC_USEFLAT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,167,185,130,10 + CONTROL "Auto resize",IDC_AUTORESIZE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,167,197,130,10 + CONTROL "Single line",IDC_SINGLELINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,167,209,130,10 + LTEXT "Buttons order:",IDC_STATIC,18,15,132,8 + PUSHBUTTON "Add Separator",IDC_ADDSEP,165,5,130,14 + PUSHBUTTON "Add Launch",IDC_ADDLBUTTON,165,25,130,14 + PUSHBUTTON "Del Sep/Launch Button",IDC_REMOVEBUTTON,165,109,130,14 + EDITTEXT IDC_ENAME,200,45,95,14,ES_AUTOHSCROLL + LTEXT "Name: ",IDC_LBUTTONNAME,165,45,30,14,SS_CENTERIMAGE + EDITTEXT IDC_EPATH,165,72,112,14,ES_AUTOHSCROLL + PUSHBUTTON "...",IDC_BROWSE,280,73,15,11 + LTEXT "Path:",IDC_LBUTTONPATH,165,62,30,8 + PUSHBUTTON "Set",IDC_LBUTTONSET,205,90,50,14 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_OPT_BUTORDER, DIALOG + BEGIN + VERTGUIDE, 8 + VERTGUIDE, 140 + VERTGUIDE, 158 + VERTGUIDE, 290 + VERTGUIDE, 297 + BOTTOMMARGIN, 229 + HORZGUIDE, 17 + HORZGUIDE, 38 + HORZGUIDE, 123 + HORZGUIDE, 136 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +IDB_SEP BITMAP "sep.bmp" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\\src\\resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_SHOWONLINEUP ICON "Show only Online Users_UP.ico" +IDI_RUN ICON "run.ico" +IDI_SHOWONLINEDN ICON "Show only Online Users_DN.ico" +IDI_GROUPSUP ICON "Groups On_Off_UP.ico" +IDI_GROUPSDN ICON "Groups On_Off_DN.ico" +IDI_SOUNDDN ICON "Sounds Enable_Disable_DN.ico" +IDI_SOUNDUP ICON "Sounds Enable_Disable_UP.ico" +IDI_OPTIONSUP ICON "Show Options Page_UP.ico" +IDI_MINIMIZEUP ICON "Minimize Button_UP.ico" +IDI_FINDADDUP ICON "Find_Add Contacts_UP.ico" +IDI_MIRANDAUP ICON "Show Main Menu_UP.ico" +#endif // Neutral resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/plugins/TopToolBar/res/sep.bmp b/plugins/TopToolBar/res/sep.bmp new file mode 100644 index 0000000000..1665285275 Binary files /dev/null and b/plugins/TopToolBar/res/sep.bmp differ diff --git a/plugins/TopToolBar/res/version.rc b/plugins/TopToolBar/res/version.rc new file mode 100644 index 0000000000..2c82256ade --- /dev/null +++ b/plugins/TopToolBar/res/version.rc @@ -0,0 +1,64 @@ +// Microsoft Visual C++ generated resource script. +// +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + +#include "..\src\version.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __FILEVERSION_STRING + PRODUCTVERSION __FILEVERSION_STRING + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "FileDescription", __PLUGIN_DESC + VALUE "FileVersion", __VERSION_STRING + VALUE "InternalName", __PLUGIN_SHORTNAME + VALUE "LegalCopyright", __PLUGIN_RIGHTS + VALUE "OriginalFilename", __PLUGIN_FILE + VALUE "ProductName", __PLUGIN_SHORTNAME + VALUE "ProductVersion", __VERSION_STRING + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END + +#endif diff --git a/plugins/TopToolBar/resource.h b/plugins/TopToolBar/resource.h deleted file mode 100644 index 498762de51..0000000000 --- a/plugins/TopToolBar/resource.h +++ /dev/null @@ -1,66 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by main.rc -// -#define IDB_SEP 118 -#define IDI_SHOWONLINEUP 125 -#define IDI_SHOWONLINEDN 126 -#define IDI_GROUPSUP 127 -#define IDI_GROUPSDN 128 -#define IDI_SOUNDDN 129 -#define IDI_SOUNDUP 130 -#define IDI_OPTIONSUP 131 -#define IDI_MINIMIZEUP 133 -#define IDI_FINDADDUP 135 -#define IDI_MIRANDAUP 137 -#define IDI_RUN 140 -#define IDD_OPT_TTBBKG 230 -#define IDD_OPT_INTERNALORDER 262 -#define IDD_OPT_BUTORDER 262 -#define IDD_FRAMEPLUG2 265 -#define IDC_BUTTON1 1002 -#define IDC_ADDSEP 1003 -#define IDC_REMOVEBUTTON 1004 -#define IDC_ADDLBUTTON 1005 -#define IDC_DELLBUTTON 1006 -#define IDC_ENAME 1007 -#define IDC_LBUTTONNAME 1008 -#define IDC_EPATH 1009 -#define IDC_AUTOSIZE 1010 -#define IDC_LBUTTONPATH 1011 -#define IDC_LBUTTONSET 1012 -#define IDC_BUTTHEIGHT 1015 -#define IDC_EDIT2 1016 -#define IDC_BUTTWIDTH 1016 -#define IDC_BUTTGAP 1017 -#define IDC_USEFLAT 1018 -#define IDC_AUTORESIZE 1019 -#define IDC_SINGLELINE 1020 -#define IDC_SPIN_HEIGHT 1024 -#define IDC_SPIN_WIDTH 1025 -#define IDC_SPIN_GAP 1026 -#define IDC_BROWSE 1184 -#define IDC_BKGCOLOUR 1269 -#define IDC_FILENAME 1271 -#define IDC_SCROLL 1277 -#define IDC_PROPORTIONAL 1278 -#define IDC_SELCOLOUR 1281 -#define IDC_STRETCHH 1298 -#define IDC_STRETCHV 1299 -#define IDC_TILEH 1300 -#define IDC_TILEV 1301 -#define IDC_BITMAP 1363 -#define IDC_P2ONLINEBUTT 1562 -#define IDC_P2GROUPBUTT 1564 -#define IDC_BUTTONORDERTREE 1591 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 139 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1025 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/plugins/TopToolBar/src/BkgrCfg.h b/plugins/TopToolBar/src/BkgrCfg.h new file mode 100644 index 0000000000..4533267fcb --- /dev/null +++ b/plugins/TopToolBar/src/BkgrCfg.h @@ -0,0 +1,18 @@ +// +// Register of plugin's user +// +// wParam = (WPARAM)szSetting - string that describes a user +// format: Category/ModuleName, +// eg: "Contact list background/CLUI", +// "Status bar background/StatusBar" +// lParam = (LPARAM)dwFlags +// +#define MS_BACKGROUNDCONFIG_REGISTER "BkgrCfg/Register" + +// +// Notification about changed background +// wParam = ModuleName +// lParam = 0 +#define ME_BACKGROUNDCONFIG_CHANGED "BkgrCfg/Changed" + +#define CLBF_TILEVTOROWHEIGHT 0x0100 diff --git a/plugins/TopToolBar/src/InternalButtons.cpp b/plugins/TopToolBar/src/InternalButtons.cpp new file mode 100644 index 0000000000..7fcdc1cef8 --- /dev/null +++ b/plugins/TopToolBar/src/InternalButtons.cpp @@ -0,0 +1,121 @@ + +#include "common.h" + +#define TTBI_GROUPSHOWHIDE "TTBInternal/GroupShowHide" +#define TTBI_SOUNDSONOFF "TTBInternal/SoundsOnOFF" +#define TTBI_MAINMENUBUTT "TTBInternal/MainMenuBUTT" + +extern HINSTANCE hInst; + +static HWND hwndContactTree; + +struct +{ + char *name, *pszService; + int iconidUp, iconidDn; + char *tooltipUp, *tooltipDn; + HANDLE hButton; +} +static stdButtons[] = +{ + { "Show only Online Users", MS_CLIST_SETHIDEOFFLINE, IDI_SHOWONLINEUP, IDI_SHOWONLINEDN, "Hide Offline Users", "Show All Users" }, + { "Groups On/Off", TTBI_GROUPSHOWHIDE, IDI_GROUPSUP, IDI_GROUPSDN, "Hide Groups", "Show Groups" }, + { "Sounds Enable/Disable", TTBI_SOUNDSONOFF, IDI_SOUNDUP, IDI_SOUNDDN, "Disable Sounds", "Enable Sounds" }, + + { "Show Options Page", "Options/OptionsCommand", IDI_OPTIONSUP, 0, "Show Options" }, + { "Minimize Button", MS_CLIST_SHOWHIDE, IDI_MINIMIZEUP, 0, NULL }, + { "Find/Add Contacts", MS_FINDADD_FINDADD, IDI_FINDADDUP, 0, NULL }, + { "Show Main Menu", TTBI_MAINMENUBUTT, IDI_MIRANDAUP, 0, "Show Main Menu" } +}; + +/////////////////////////////////////////////////////////////////////////////// + +int OnSettingChanging(WPARAM wParam, LPARAM lParam) +{ + DBCONTACTWRITESETTING *dbcws = (DBCONTACTWRITESETTING *)lParam; + if (wParam != 0 || dbcws == NULL) + return 0; + + if ( !strcmp(dbcws->szModule, "CList")) { + if ( !strcmp(dbcws->szSetting, "HideOffline")) + CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[0].hButton, (dbcws->value.bVal) ? TTBST_PUSHED : TTBST_RELEASED); + + else if (!strcmp(dbcws->szSetting, "UseGroups")) + CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[1].hButton, (dbcws->value.bVal) ? TTBST_PUSHED : TTBST_RELEASED); + } + + else if (!strcmp(dbcws->szModule, "Skin")) { + if (!strcmp(dbcws->szSetting, "UseSound")) + CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[2].hButton, (dbcws->value.bVal) ? TTBST_RELEASED : TTBST_PUSHED); + } + + return 0; +} + +INT_PTR TTBInternalMainMenuButt(WPARAM wParam, LPARAM lParam) +{ + HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUGETMAIN, 0, 0); + + POINT pt; + GetCursorPos(&pt); + TrackPopupMenu(hMenu, TPM_TOPALIGN|TPM_LEFTALIGN|TPM_RIGHTBUTTON, pt.x, pt.y, 0, (HWND)CallService(MS_CLUI_GETHWND, 0, 0), NULL); + return 0; +} + +INT_PTR TTBInternalGroupShowHide(WPARAM wParam, LPARAM lParam) +{ + int newVal = !(GetWindowLongPtr(hwndContactTree, GWL_STYLE)&CLS_USEGROUPS); + db_set_b(NULL, "CList", "UseGroups", (BYTE)newVal); + SendMessage(hwndContactTree, CLM_SETUSEGROUPS, newVal, 0); + return 0; +} + +INT_PTR TTBInternalSoundsOnOff(WPARAM wParam, LPARAM lParam) +{ + int newVal = !(db_get_b(NULL, "Skin", "UseSound", 1)); + db_set_b(NULL, "Skin", "UseSound", (BYTE)newVal); + return 0; +} + +/////////////////////////////////////////////////////////////////////////////// + +int InitInternalButtons(WPARAM, LPARAM) +{ + hwndContactTree = (HWND)CallService(MS_CLUI_GETHWNDTREE, 0, 0); + + CreateServiceFunction(TTBI_GROUPSHOWHIDE, TTBInternalGroupShowHide); + CreateServiceFunction(TTBI_SOUNDSONOFF, TTBInternalSoundsOnOff); + CreateServiceFunction(TTBI_MAINMENUBUTT, TTBInternalMainMenuButt); + + TTBButton ttb = { 0 }; + ttb.cbSize = sizeof(ttb); + + for (int i=0; i < SIZEOF(stdButtons); i++) { + ttb.name = stdButtons[i].name; + ttb.pszService = stdButtons[i].pszService; + ttb.dwFlags = TTBBF_VISIBLE | TTBBF_INTERNAL; + if ((ttb.pszTooltipDn = stdButtons[i].tooltipDn) != NULL) + ttb.dwFlags |= TTBBF_SHOWTOOLTIP; + ttb.pszTooltipUp = stdButtons[i].tooltipUp; + ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(stdButtons[i].iconidUp), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); + if (stdButtons[i].iconidDn) { + ttb.dwFlags |= TTBBF_ASPUSHBUTTON; + ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(stdButtons[i].iconidDn), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); + } + else ttb.hIconDn = NULL; + + stdButtons[i].hButton = (HANDLE)TTBAddButton((WPARAM)&ttb, 0); + } + + CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[0].hButton, + db_get_b(NULL, "CList", "HideOffline", 0) ? TTBST_PUSHED : TTBST_RELEASED); + + CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[1].hButton, + db_get_b(NULL, "CList", "UseGroups", 1) ? TTBST_PUSHED : TTBST_RELEASED); + + CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)stdButtons[2].hButton, + db_get_b(NULL, "Skin", "UseSound", 1) ? TTBST_RELEASED : TTBST_PUSHED); + + HookEvent(ME_DB_CONTACT_SETTINGCHANGED, OnSettingChanging); + return 0; +} diff --git a/plugins/TopToolBar/src/common.h b/plugins/TopToolBar/src/common.h new file mode 100644 index 0000000000..0840111f2f --- /dev/null +++ b/plugins/TopToolBar/src/common.h @@ -0,0 +1,157 @@ +#ifndef TTB_COMMON_H +#define TTB_COMMON_H + + +#define _CRT_SECURE_NO_WARNINGS + +#include +#include +#include +#include +#include +#include +#include + +#include "win2k.h" +#include "newpluginapi.h" +#include "m_system.h" +#include "m_system_cpp.h" +#include "m_database.h" +#include "m_clist.h" +#include "m_skin.h" +#include "m_utils.h" +#include "m_cluiframes.h" +#include "m_clui.h" +#include "m_clc.h" +#include "m_findadd.h" +#include "m_langpack.h" +#include "m_options.h" +#include "resource.h" +#include "m_protocols.h" +#include "m_protosvc.h" +#include "m_toptoolbar.h" +#include "m_button.h" +#include "m_icolib.h" +#include "BkgrCfg.h" + +#define TTB_BUTTON_CLASS _T("TopToolbarButtonClass") + +#define TTB_REPOSBUTTONS (WM_USER+10) +#define TTB_UPDATEFRAMEVISIBILITY (WM_USER+11) + +#define TTBDEFAULT_BKBMPUSE CLB_STRETCH +#define TTBDEFAULT_BKCOLOUR GetSysColor(COLOR_3DFACE) +#define TTBDEFAULT_USEBITMAP 0 +#define TTBDEFAULT_SELBKCOLOUR GetSysColor(COLOR_HIGHLIGHT) + +#define TTBBF_INTERNAL 0x1000000 +#define TTBBF_OPTIONAL 0x2000000 + +/////////////////////////////////////////////////////////////////////////////// +// TopButtonInt class + +struct TopButtonInt : public MZeroedObject +{ + ~TopButtonInt(); + + DWORD CheckFlags(DWORD Flags); + void CreateWnd(void); + void LoadSettings(void); + void SaveSettings(int *SepCnt, int *LaunchCnt); + void SetBitmap(void); + + __inline bool isSep() const + { return (dwFlags & TTBBF_ISSEPARATOR) != 0; + } + + __inline bool isVisible() const + { return (dwFlags & TTBBF_VISIBLE) != 0; + } + + HWND hwnd; + int id; + BOOL bPushed; + int dwFlags; + int x, y, arrangedpos; + HICON hIconUp, hIconDn; + HANDLE hIconHandleUp, hIconHandleDn; + + char *pszService; + TCHAR *ptszProgram; + char *pszName; + TCHAR *ptszTooltip; + + LPARAM lParamUp; + WPARAM wParamUp; + LPARAM lParamDown; + WPARAM wParamDown; + + int hLangpack; + TCHAR *ptszTooltipUp, *ptszTooltipDn; +}; + +/////////////////////////////////////////////////////////////////////////////// + +int TTBOptInit(WPARAM wParam, LPARAM lParam); +//append string +char __inline *AS(char *str, const char *setting, char *addstr); + +TopButtonInt* CreateButton(TTBButton* but); + +int LoadBackgroundOptions(); + +int ArrangeButtons(); + +#define DEFBUTTWIDTH 20 +#define DEFBUTTHEIGHT 20 +#define DEFBUTTGAP 1 + +#define SEPWIDTH 3 + +extern TTBCtrl* g_ctrl; + +extern LIST Buttons; +extern HINSTANCE hInst; +extern HBITMAP hBmpBackground, hBmpSeparator; +extern CRITICAL_SECTION csButtonsHook; +extern pfnCustomProc g_CustomProc; +extern LPARAM g_CustomProcParam; +extern HANDLE hTTBModuleLoaded, hTTBInitButtons; + +void AddToOptions(TopButtonInt* b); +void RemoveFromOptions(int id); + +//append string +char *AS(char *str, const char *setting, char *addstr) +{ + if (str != NULL) { + strcpy(str, setting); + strcat(str, addstr); + } + return str; +} + +#define TTB_LAUNCHSERVICE "TTB/LaunchService" + +TopButtonInt* idtopos(int id, int* pPos=NULL); + +INT_PTR TTBAddButton(WPARAM, LPARAM); +INT_PTR TTBRemoveButton(WPARAM, LPARAM); + +int InitInternalButtons(WPARAM, LPARAM); + +int LoadToolbarModule( void ); +int UnloadToolbarModule( void ); + +void SetAllBitmaps( void ); +int SaveAllLButs( void ); +int SaveAllButtonsOptions( void ); + +void InsertSeparator( int i ); +void DeleteSeparator(int i); +void DeleteLBut(int i); +void InsertLBut(int i); + +int OnModulesLoad(WPARAM, LPARAM); + +#endif \ No newline at end of file diff --git a/plugins/TopToolBar/src/main.cpp b/plugins/TopToolBar/src/main.cpp new file mode 100644 index 0000000000..601de36408 --- /dev/null +++ b/plugins/TopToolBar/src/main.cpp @@ -0,0 +1,51 @@ + +#include "common.h" +#include "version.h" + +HINSTANCE hInst; +int hLangpack; + +PLUGININFOEX pluginInfo = +{ + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), + __PLUGIN_DESC, + __PLUGIN_AUTHOR, + __PLUGIN_EMAIL, + __PLUGIN_RIGHTS, + __PLUGIN_AUTHORWEB, + UNICODE_AWARE, + {0xf593c752, 0x51d8, 0x4d46, {0xba, 0x27, 0x37, 0x57, 0x79, 0x53, 0xf5, 0x5c}} +}; + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +extern "C" int __declspec(dllexport) Load(void) +{ + mir_getLP(&pluginInfo); + + LoadToolbarModule(); + return 0; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +extern "C" int __declspec(dllexport) Unload(void) +{ + UnloadToolbarModule(); + return 0; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + hInst = hinstDLL; + return TRUE; +} diff --git a/plugins/TopToolBar/src/resource.h b/plugins/TopToolBar/src/resource.h new file mode 100644 index 0000000000..498762de51 --- /dev/null +++ b/plugins/TopToolBar/src/resource.h @@ -0,0 +1,66 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by main.rc +// +#define IDB_SEP 118 +#define IDI_SHOWONLINEUP 125 +#define IDI_SHOWONLINEDN 126 +#define IDI_GROUPSUP 127 +#define IDI_GROUPSDN 128 +#define IDI_SOUNDDN 129 +#define IDI_SOUNDUP 130 +#define IDI_OPTIONSUP 131 +#define IDI_MINIMIZEUP 133 +#define IDI_FINDADDUP 135 +#define IDI_MIRANDAUP 137 +#define IDI_RUN 140 +#define IDD_OPT_TTBBKG 230 +#define IDD_OPT_INTERNALORDER 262 +#define IDD_OPT_BUTORDER 262 +#define IDD_FRAMEPLUG2 265 +#define IDC_BUTTON1 1002 +#define IDC_ADDSEP 1003 +#define IDC_REMOVEBUTTON 1004 +#define IDC_ADDLBUTTON 1005 +#define IDC_DELLBUTTON 1006 +#define IDC_ENAME 1007 +#define IDC_LBUTTONNAME 1008 +#define IDC_EPATH 1009 +#define IDC_AUTOSIZE 1010 +#define IDC_LBUTTONPATH 1011 +#define IDC_LBUTTONSET 1012 +#define IDC_BUTTHEIGHT 1015 +#define IDC_EDIT2 1016 +#define IDC_BUTTWIDTH 1016 +#define IDC_BUTTGAP 1017 +#define IDC_USEFLAT 1018 +#define IDC_AUTORESIZE 1019 +#define IDC_SINGLELINE 1020 +#define IDC_SPIN_HEIGHT 1024 +#define IDC_SPIN_WIDTH 1025 +#define IDC_SPIN_GAP 1026 +#define IDC_BROWSE 1184 +#define IDC_BKGCOLOUR 1269 +#define IDC_FILENAME 1271 +#define IDC_SCROLL 1277 +#define IDC_PROPORTIONAL 1278 +#define IDC_SELCOLOUR 1281 +#define IDC_STRETCHH 1298 +#define IDC_STRETCHV 1299 +#define IDC_TILEH 1300 +#define IDC_TILEV 1301 +#define IDC_BITMAP 1363 +#define IDC_P2ONLINEBUTT 1562 +#define IDC_P2GROUPBUTT 1564 +#define IDC_BUTTONORDERTREE 1591 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 139 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1025 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/plugins/TopToolBar/src/toolbar.cpp b/plugins/TopToolBar/src/toolbar.cpp new file mode 100644 index 0000000000..156b83dbb7 --- /dev/null +++ b/plugins/TopToolBar/src/toolbar.cpp @@ -0,0 +1,707 @@ + +#include "common.h" + +#define OLD_TBBUTTON_SIZE (offsetof(TTBButton, pszTooltipUp)) + +pfnCustomProc g_CustomProc = NULL; +LPARAM g_CustomProcParam = 0; +TTBCtrl *g_ctrl = NULL; + +INT_PTR OnEventFire(WPARAM wParam, LPARAM lParam); + +HWND hwndContactList = 0; + +int nextButtonId = 200; + +HANDLE hTTBModuleLoaded, hTTBInitButtons; +static WNDPROC buttonWndProc; + +CRITICAL_SECTION csButtonsHook; + +int sortfunc(const TopButtonInt* a, const TopButtonInt* b) +{ + return a->arrangedpos - b->arrangedpos; +} + +LIST Buttons(8, sortfunc); + +TopButtonInt* idtopos(int id, int* pPos) +{ + for ( int i = 0; i < Buttons.getCount(); i++) + if (Buttons[i]->id == id) { + if (pPos) *pPos = i; + return Buttons[i]; + } + + if (pPos) *pPos = -1; + return NULL; +} + +//----- Service buttons ----- +void InsertSBut(int i) +{ + TTBButton ttb = { 0 }; + ttb.cbSize = sizeof(ttb); + ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); + ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); + ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISSBUTTON | TTBBF_INTERNAL; + ttb.wParamDown = i; + TTBAddButton(( WPARAM )&ttb, 0); +} + +void LoadAllSButs() +{ + //must be locked + int cnt = db_get_b(0, TTB_OPTDIR, "ServiceCnt", 0); + if (cnt > 0) { + for (int i = 1; i<=cnt; i++) + InsertSBut(i); + } +} + +//----- Launch buttons ----- +INT_PTR LaunchService(WPARAM wParam, LPARAM lParam) +{ + PROCESS_INFORMATION pi; + STARTUPINFO si = {0}; + si.cb = sizeof(si); + + if ( CreateProcess(NULL, Buttons[lParam]->ptszProgram, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); + } + + return 0; +} + +void InsertLBut(int i) +{ + TTBButton ttb = { 0 }; + ttb.cbSize = sizeof(ttb); + ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); + ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISLBUTTON | TTBBF_INTERNAL; + ttb.name = LPGEN("Default"); + ttb.program = _T("Execute Path"); + ttb.wParamDown = i; + TTBAddButton(( WPARAM )&ttb, 0); +} + +void LoadAllLButs() +{ + //must be locked + int cnt = db_get_b(0, TTB_OPTDIR, "LaunchCnt", 0); + for (int i = 0; i < cnt; i++) + InsertLBut(i); +} + +//----- Separators ----- + +void InsertSeparator(int i) +{ + TTBButton ttb = { 0 }; + ttb.cbSize = sizeof(ttb); + ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISSEPARATOR | TTBBF_INTERNAL; + ttb.wParamDown = i; + TTBAddButton((WPARAM)&ttb, 0); +} + +void LoadAllSeparators() +{ + //must be locked + int cnt = db_get_b(0, TTB_OPTDIR, "SepCnt", 0); + for (int i = 0; i < cnt; i++) + InsertSeparator(i); +} + +int SaveAllButtonsOptions() +{ + int SeparatorCnt = 0; + int LaunchCnt = 0; + { + mir_cslock lck(csButtonsHook); + for (int i = 0; i < Buttons.getCount(); i++) + Buttons[i]->SaveSettings(&SeparatorCnt, &LaunchCnt); + } + db_set_b(0, TTB_OPTDIR, "SepCnt", SeparatorCnt); + db_set_b(0, TTB_OPTDIR, "LaunchCnt", LaunchCnt); + return 0; +} + +static bool nameexists(const char *name) +{ + if (name == NULL) + return false; + + for (int i = 0; i < Buttons.getCount(); i++) + if ( !lstrcmpA(Buttons[i]->pszName, name)) + return true; + + return false; +} + +static void Icon2button(TTBButton* but, HANDLE& hIcoLib, HICON& hIcon, bool bIsUp) +{ + HANDLE hSrc = bIsUp ? but->hIconHandleUp : but->hIconHandleDn; + if (hSrc == NULL) { + hIcoLib = NULL, hIcon = NULL; + return; + } + + hIcoLib = (HANDLE)CallService(MS_SKIN2_ISMANAGEDICON, WPARAM(hSrc), 0); + if (!hIcoLib) { + char buf[256]; + mir_snprintf(buf, SIZEOF(buf), "toptoolbar_%s%s", but->name, (bIsUp) ? (but->hIconDn ? "%s_up" : "%s") : "%s_dn"); + SKINICONDESC sid = {0}; + sid.cbSize = sizeof(sid); + sid.pszSection = "Toolbar"; + sid.pszName = buf; + sid.pszDefaultFile = NULL; + sid.pszDescription = but->name; + sid.hDefaultIcon = (bIsUp) ? but->hIconUp : but->hIconDn; + hIcoLib = Skin_AddIcon(&sid); + } + + hIcon = Skin_GetIconByHandle(hIcoLib); +} + +TopButtonInt* CreateButton(TTBButton* but) +{ + TopButtonInt* b = new TopButtonInt; + b->id = nextButtonId++; + + b->dwFlags = but->dwFlags; + + b->wParamUp = but->wParamUp; + b->lParamUp = but->lParamUp; + b->wParamDown = but->wParamDown; + b->lParamDown = but->lParamDown; + + if ( !(b->dwFlags & TTBBF_ISSEPARATOR)) { + b->bPushed = (but->dwFlags & TTBBF_PUSHED) ? TRUE : FALSE; + + if (but->dwFlags & TTBBF_ISLBUTTON) { + b->ptszProgram = mir_tstrdup(but->program); + b->pszService = mir_strdup(TTB_LAUNCHSERVICE); + } + else { + b->ptszProgram = NULL; + b->pszService = mir_strdup(but->pszService); + } + + b->pszName = mir_strdup(but->name); + + Icon2button(but, b->hIconHandleUp, b->hIconUp, true); + Icon2button(but, b->hIconHandleDn, b->hIconDn, false); + + if (but->cbSize > OLD_TBBUTTON_SIZE) { + b->ptszTooltipUp = mir_a2t(but->pszTooltipUp); + b->ptszTooltipDn = mir_a2t(but->pszTooltipDn); + } + } + return b; +} + +int ArrangeButtons() +{ + mir_cslock lck(csButtonsHook); + + RECT rcClient; + GetClientRect(g_ctrl->hWnd, &rcClient); + int nBarSize = rcClient.right - rcClient.left; + if (nBarSize == 0) + return 0; + + int nLineCount = 0; + int i, ypos = 1, xpos = g_ctrl->nButtonSpace, nextX = 0, y = 0; + int newheight = g_ctrl->nButtonHeight+1, nButtonCount=0; + + for (i=0; i < Buttons.getCount(); i++) + if (Buttons[i]->hwnd) + nButtonCount++; + + if (nButtonCount == 0) + return 0; + + HDWP hdwp = BeginDeferWindowPos(nButtonCount); + + bool bWasButttonBefore; + int nUsedWidth, iFirstButtonId = 0, iLastButtonId = 0; + + do + { + nLineCount++; + bWasButttonBefore = false; + nUsedWidth = 0; + + for (i=iFirstButtonId; i < Buttons.getCount(); i++) { + TopButtonInt *b = Buttons[i]; + if (b->hwnd == NULL) + continue; + + int width = 0; + if ( b->isVisible()) + width = (b->isSep()) ? SEPWIDTH+2 : g_ctrl->nButtonWidth + ((bWasButttonBefore) ? g_ctrl->nButtonSpace : 0); + if (nUsedWidth + width > nBarSize) + break; + + nUsedWidth += width; + iLastButtonId = i+1; + bWasButttonBefore = !b->isSep(); + } + + int nFreeSpace = nBarSize - nUsedWidth; + + for (i=iFirstButtonId; i < iLastButtonId; i++) { + TopButtonInt *b = Buttons[i]; + if (b->hwnd == NULL) + continue; + + bool bOldVisible = IsWindowVisible(b->hwnd) != 0; + if (bOldVisible != b->isVisible()) + g_ctrl->bOrderChanged = TRUE; + + if ( b->isVisible()) { + hdwp = DeferWindowPos(hdwp, b->hwnd, NULL, nextX, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW); + if ( b->isSep()) + nextX += SEPWIDTH+2; + else + nextX += g_ctrl->nButtonWidth + g_ctrl->nButtonSpace; + } + else hdwp = DeferWindowPos(hdwp, Buttons[i]->hwnd, NULL, nextX, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_HIDEWINDOW); + } + + if (iFirstButtonId == iLastButtonId) + break; + + iFirstButtonId = iLastButtonId; + y += g_ctrl->nButtonHeight + g_ctrl->nButtonSpace; + nextX = 0; + if (g_ctrl->bSingleLine) + break; + } + while (iFirstButtonId < Buttons.getCount() && y >= 0 && (g_ctrl->bAutoSize || (y + g_ctrl->nButtonHeight <= rcClient.bottom - rcClient.top))); + + if (hdwp) + EndDeferWindowPos(hdwp); + + return (g_ctrl->nButtonHeight + g_ctrl->nButtonSpace)*nLineCount - g_ctrl->nButtonSpace; +} + +///////////////////////////////////////////////////////////////////////////////////////// +// Toolbar services + +// wparam = (TTBButton*)lpTTBButton +// lparam = hLangpack +INT_PTR TTBAddButton(WPARAM wParam, LPARAM lParam) +{ + if (wParam == 0) + return -1; + + TTBButton *but = (TTBButton*)wParam; + if (but->cbSize != sizeof(TTBButton) && but->cbSize != OLD_TBBUTTON_SIZE) + return -1; + + if ( !(but->dwFlags && TTBBF_ISLBUTTON) && nameexists(but->name)) + return -1; + + TopButtonInt* b = CreateButton(but); + b->hLangpack = (int)lParam; + b->LoadSettings(); + b->CreateWnd(); + if (b->hwnd == NULL) { + delete b; + return -1; + } + { + mir_cslock lck(csButtonsHook); + Buttons.insert(b); + } + + g_ctrl->bOrderChanged = TRUE; + ArrangeButtons(); + AddToOptions(b); + return b->id; +} + +// wparam = (HANDLE)hTTButton +// lparam = 0 +INT_PTR TTBRemoveButton(WPARAM wParam, LPARAM lParam) +{ + mir_cslock lck(csButtonsHook); + + int idx; + TopButtonInt* b = idtopos(wParam, &idx); + if (b == NULL) + return -1; + + RemoveFromOptions(b->id); + + Buttons.remove(idx); + delete b; + + g_ctrl->bOrderChanged = TRUE; + ArrangeButtons(); + return 0; +} + +// wparam = hTTBButton +// lparam = state +INT_PTR TTBSetState(WPARAM wParam, LPARAM lParam) +{ + mir_cslock lck(csButtonsHook); + + TopButtonInt* b = idtopos(wParam); + if (b == NULL) + return -1; + + b->bPushed = (lParam & TTBST_PUSHED)?TRUE:FALSE; + b->bPushed = (lParam & TTBST_RELEASED)?FALSE:TRUE; + b->SetBitmap(); + return 0; +} + +// wparam = hTTBButton +// lparam = 0 +//return = state +INT_PTR TTBGetState(WPARAM wParam, LPARAM lParam) +{ + mir_cslock lck(csButtonsHook); + TopButtonInt* b = idtopos(wParam); + if (b == NULL) + return -1; + + int retval = (b->bPushed == TRUE) ? TTBST_PUSHED : TTBST_RELEASED; + return retval; +} + +INT_PTR TTBGetOptions(WPARAM wParam, LPARAM lParam) +{ + INT_PTR retval; + + mir_cslock lck(csButtonsHook); + TopButtonInt* b = idtopos(wParam); + if (b == NULL) + return -1; + + switch(LOWORD(wParam)) { + case TTBO_FLAGS: + retval = b->dwFlags & (~TTBBF_PUSHED); + if (b->bPushed) + retval |= TTBBF_PUSHED; + break; + + case TTBO_TIPNAME: + retval = (INT_PTR)b->ptszTooltip; + break; + + case TTBO_ALLDATA: + if (lParam) { + lpTTBButton lpTTB = (lpTTBButton)lParam; + if (lpTTB->cbSize != sizeof(TTBButton)) + break; + + lpTTB->dwFlags = b->dwFlags & (~TTBBF_PUSHED); + if (b->bPushed) + lpTTB->dwFlags |= TTBBF_PUSHED; + + lpTTB->hIconDn = b->hIconDn; + lpTTB->hIconUp = b->hIconUp; + + lpTTB->lParamUp = b->lParamUp; + lpTTB->wParamUp = b->wParamUp; + lpTTB->lParamDown = b->lParamDown; + lpTTB->wParamDown = b->wParamDown; + + if (b->dwFlags & TTBBF_ISLBUTTON) + replaceStrT(lpTTB->program, b->ptszProgram); + else + replaceStr(lpTTB->pszService, b->pszService); + + retval = ( INT_PTR )lpTTB; + } + break; + + default: + retval = -1; + break; + } + + return retval; +} + +INT_PTR TTBSetOptions(WPARAM wParam, LPARAM lParam) +{ + int retval; + + mir_cslock lck(csButtonsHook); + TopButtonInt* b = idtopos(HIWORD(wParam)); + if (b == NULL) + return -1; + + switch(LOWORD(wParam)) { + case TTBO_FLAGS: + if (b->dwFlags == lParam) + break; + + retval = b->CheckFlags(lParam); + + if (retval & TTBBF_PUSHED) + b->SetBitmap(); + if (retval & TTBBF_VISIBLE) { + ArrangeButtons(); + b->SaveSettings(0,0); + } + + retval = 1; + break; + + case TTBO_TIPNAME: + if (lParam == 0) + break; + + replaceStrT(b->ptszTooltip, TranslateTS( _A2T((LPCSTR)lParam))); + SendMessage(b->hwnd,BUTTONADDTOOLTIP,(WPARAM)b->ptszTooltip,BATF_UNICODE); + retval = 1; + break; + + case TTBO_ALLDATA: + if (lParam) { + lpTTBButton lpTTB = (lpTTBButton)lParam; + if (lpTTB->cbSize != sizeof(TTBButton)) + break; + + retval = b->CheckFlags(lpTTB->dwFlags); + + int changed = 0; + if (b->hIconUp != lpTTB->hIconUp) { + b->hIconUp = lpTTB->hIconUp; + changed = 1; + } + if (b->hIconDn != lpTTB->hIconDn) { + b->hIconDn = lpTTB->hIconDn; + changed = 1; + } + if (changed) + b->SetBitmap(); + + if (retval & TTBBF_VISIBLE) { + ArrangeButtons(); + b->SaveSettings(0,0); + } + + if (b->dwFlags & TTBBF_ISLBUTTON) + replaceStrT(b->ptszProgram, lpTTB->program); + else + replaceStr(b->pszService, lpTTB->pszService); + + b->lParamUp = lpTTB->lParamUp; + b->wParamUp = lpTTB->wParamUp; + b->lParamDown = lpTTB->lParamDown; + b->wParamDown = lpTTB->wParamDown; + + retval = 1; + } + break; + + default: + retval = -1; + break; + } + + return retval; +} + +///////////////////////////////////////////////////////////////////////////////////////// +// Reload all icons from their icolib handles + +int OnIconChange(WPARAM wParam, LPARAM lParam) +{ + mir_cslock lck(csButtonsHook); + for (int i = 0; i < Buttons.getCount(); i++) { + TopButtonInt* b = Buttons[i]; + if ( !b->hIconHandleUp && !b->hIconHandleDn) + continue; + + if (b->hIconHandleUp) { + Skin_ReleaseIcon(b->hIconUp); + b->hIconUp = Skin_GetIconByHandle(b->hIconHandleUp); + } + if (b->hIconHandleDn) { + Skin_ReleaseIcon(b->hIconDn); + b->hIconDn = Skin_GetIconByHandle(b->hIconHandleDn); + } + DestroyWindow(b->hwnd); + b->CreateWnd(); + } + + if (g_ctrl->hWnd) { + g_ctrl->bOrderChanged = true; + PostMessage(g_ctrl->hWnd, TTB_UPDATEFRAMEVISIBILITY, TRUE, 0); + } + + return 0; +} + +static int OnBGChange(WPARAM wParam, LPARAM lParam) +{ + LoadBackgroundOptions(); + return 0; +} + +static INT_PTR TTBSetCustomProc(WPARAM wParam, LPARAM lParam) +{ + g_CustomProc = (pfnCustomProc)wParam; + g_CustomProcParam = lParam; + return 0; +} + +///////////////////////////////////////////////////////////////////////////////////////// +// Adds buttons of plugins being loaded. lParam = HINSTANCE + +int OnPluginLoad(WPARAM wParam, LPARAM lParam) +{ + CallPluginEventHook((HINSTANCE)lParam, hTTBModuleLoaded, 0, 0); + if (g_ctrl->hWnd && g_ctrl->bOrderChanged) + PostMessage(g_ctrl->hWnd, TTB_UPDATEFRAMEVISIBILITY, TRUE, 0); + return 0; +} + +///////////////////////////////////////////////////////////////////////////////////////// +// Removes buttons of plugins being unloaded. lParam = HINSTANCE + +int OnPluginUnload(WPARAM wParam, LPARAM lParam) +{ + int hLangpack = CallService(MS_LANGPACK_LOOKUPHANDLE, 0, lParam); + if (hLangpack) { + bool bNeedUpdate = false; + mir_cslock lck(csButtonsHook); + + for (int i=Buttons.getCount()-1; i >= 0; i--) + if (Buttons[i]->hLangpack == hLangpack) { + TTBRemoveButton(Buttons[i]->id, 0); + bNeedUpdate = true; + } + + if (bNeedUpdate) { + ArrangeButtons(); + if (g_ctrl->hWnd) + PostMessage(g_ctrl->hWnd, TTB_UPDATEFRAMEVISIBILITY, TRUE, 0); + } + } + return 0; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +int OnModulesLoad(WPARAM wParam, LPARAM lParam) +{ + LoadAllSeparators(); + LoadAllLButs(); + + ArrangeButtons(); + + HANDLE hEvent = CreateEvent(NULL, TRUE, TRUE, NULL);//anonymous event + if (hEvent != 0) + CallService(MS_SYSTEM_WAITONHANDLE, (WPARAM)hEvent, (LPARAM)"TTB_ONSTARTUPFIRE"); + + if ( HookEvent(ME_BACKGROUNDCONFIG_CHANGED, OnBGChange)) { + char buf[256]; + sprintf(buf, "TopToolBar Background/%s", TTB_OPTDIR); + CallService(MS_BACKGROUNDCONFIG_REGISTER, (WPARAM)buf, 0); + } + return 0; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +static LRESULT CALLBACK TTBButtonWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + LRESULT lResult = buttonWndProc(hwnd, msg, wParam, lParam); + + if (msg == WM_NCCREATE) { + TopButtonInt* p = (TopButtonInt*)((CREATESTRUCT*)lParam)->lpCreateParams; + if (g_CustomProc) + g_CustomProc((HANDLE)p->id, hwnd, g_CustomProcParam); + } + + return lResult; +} + +int LoadToolbarModule() +{ + if ( !ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) { + if ( !db_get_b(NULL, TTB_OPTDIR, "WarningDone", 0)) + MessageBox(0, TranslateT("Frames Services not found - plugin disabled.You need MultiWindow plugin."), _T("TopToolBar"), 0); + db_set_b(NULL, TTB_OPTDIR, "WarningDone", 1); + return 1; + } + + g_ctrl = (TTBCtrl*)mir_calloc( sizeof(TTBCtrl)); + g_ctrl->nButtonHeight = db_get_dw(0, TTB_OPTDIR, "BUTTHEIGHT", DEFBUTTHEIGHT); + g_ctrl->nButtonWidth = db_get_dw(0, TTB_OPTDIR, "BUTTWIDTH", DEFBUTTWIDTH); + g_ctrl->nButtonSpace = db_get_dw(0, TTB_OPTDIR, "BUTTGAP", DEFBUTTGAP); + g_ctrl->nLastHeight = db_get_dw(0, TTB_OPTDIR, "LastHeight", DEFBUTTHEIGHT); + + g_ctrl->bFlatButtons = db_get_b(0, TTB_OPTDIR, "UseFlatButton", true); + g_ctrl->bSingleLine = db_get_b(0, TTB_OPTDIR, "SingleLine", false); + g_ctrl->bAutoSize = db_get_b(0, TTB_OPTDIR, "AutoSize", true); + + db_unset(NULL, TTB_OPTDIR, "WarningDone"); + + InitializeCriticalSection(&csButtonsHook); + hBmpSeparator = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_SEP)); + + HookEvent(ME_SYSTEM_MODULELOAD, OnPluginLoad); + HookEvent(ME_SYSTEM_MODULEUNLOAD, OnPluginUnload); + HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoad); + HookEvent(ME_SKIN2_ICONSCHANGED, OnIconChange); + HookEvent(ME_OPT_INITIALISE, TTBOptInit); + + hTTBModuleLoaded = CreateHookableEvent(ME_TTB_MODULELOADED); + hTTBInitButtons = CreateHookableEvent(ME_TTB_INITBUTTONS); + SetHookDefaultForHookableEvent(hTTBInitButtons, InitInternalButtons); + + CreateServiceFunction("TopToolBar/AddButton", TTBAddButton); + CreateServiceFunction(MS_TTB_REMOVEBUTTON, TTBRemoveButton); + + CreateServiceFunction(MS_TTB_SETBUTTONSTATE, TTBSetState); + CreateServiceFunction(MS_TTB_GETBUTTONSTATE, TTBGetState); + + CreateServiceFunction(MS_TTB_GETBUTTONOPTIONS, TTBGetOptions); + CreateServiceFunction(MS_TTB_SETBUTTONOPTIONS, TTBSetOptions); + + CreateServiceFunction(TTB_LAUNCHSERVICE, LaunchService); + + CreateServiceFunction("TopToolBar/SetCustomProc", TTBSetCustomProc); + CreateServiceFunction("TTB_ONSTARTUPFIRE", OnEventFire); + + buttonWndProc = (WNDPROC)CallService("Button/GetWindowProc",0,0); + WNDCLASSEX wc = {0}; + wc.cbSize = sizeof(wc); + wc.lpszClassName = TTB_BUTTON_CLASS; + wc.lpfnWndProc = TTBButtonWndProc; + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.cbWndExtra = sizeof(void*); + wc.hbrBackground = 0; + wc.style = CS_GLOBALCLASS; + RegisterClassEx(&wc); + return 0; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +int UnloadToolbarModule() +{ + DestroyHookableEvent(hTTBModuleLoaded); + DestroyHookableEvent(hTTBInitButtons); + + DeleteObject(hBmpSeparator); + DeleteCriticalSection(&csButtonsHook); + + for (int i=0; i < Buttons.getCount(); i++) + delete Buttons[i]; + Buttons.destroy(); + + mir_free(g_ctrl); + return 0; +} diff --git a/plugins/TopToolBar/src/toolbarwnd.cpp b/plugins/TopToolBar/src/toolbarwnd.cpp new file mode 100644 index 0000000000..e3f19f693b --- /dev/null +++ b/plugins/TopToolBar/src/toolbarwnd.cpp @@ -0,0 +1,330 @@ + +#include "common.h" + +COLORREF bkColour; +HBITMAP hBmpBackground, hBmpSeparator; +int backgroundBmpUse; + +static TCHAR pluginname[] = _T("TopToolBar"); + +///////////////////////////////////////////////////////////////////////////////////////// +// Toolbar window procedure + +static void PaintToolbar(HWND hwnd) +{ + InvalidateRect(hwnd, 0, FALSE); + + PAINTSTRUCT paintst; + HDC hdc = BeginPaint(hwnd, &paintst); + RECT *rcPaint = &paintst.rcPaint; + + RECT clRect; + GetClientRect(hwnd, &clRect); + if (rcPaint == NULL) rcPaint = &clRect; + + int yScroll = 0; + int y = -yScroll; + + HDC hdcMem = CreateCompatibleDC(hdc); + HBITMAP hBmpOsb = CreateBitmap(clRect.right, clRect.bottom, 1, GetDeviceCaps(hdc, BITSPIXEL), NULL); + HBITMAP hOldBmp = (HBITMAP)SelectObject(hdcMem, hBmpOsb); + SetBkMode(hdcMem, TRANSPARENT); + + HBRUSH hBrush = CreateSolidBrush(bkColour); + HBRUSH hoBrush = (HBRUSH)SelectObject(hdcMem, hBrush); + FillRect(hdcMem, rcPaint, hBrush); + SelectObject(hdcMem, hoBrush); + DeleteObject(hBrush); + if (hBmpBackground) { + BITMAP bmp; + GetObject(hBmpBackground, sizeof(bmp), &bmp); + + HDC hdcBmp = CreateCompatibleDC(hdcMem); + SelectObject(hdcBmp, hBmpBackground); + int y = backgroundBmpUse & CLBF_SCROLL ? -yScroll : 0; + int maxx = backgroundBmpUse & CLBF_TILEH ? clRect.right : 1; + int maxy = backgroundBmpUse & CLBF_TILEV ? maxy = rcPaint->bottom : y+1; + + int destw, desth; + switch(backgroundBmpUse & CLBM_TYPE) { + case CLB_STRETCH: + if (backgroundBmpUse&CLBF_PROPORTIONAL) { + if (clRect.right * bmp.bmHeight < clRect.bottom * bmp.bmWidth) { + desth = clRect.bottom; + destw = desth * bmp.bmWidth/bmp.bmHeight; + } + else { + destw = clRect.right; + desth = destw * bmp.bmHeight/bmp.bmWidth; + } + } + else { + destw = clRect.right; + desth = clRect.bottom; + } + break; + case CLB_STRETCHH: + if (backgroundBmpUse & CLBF_PROPORTIONAL) { + destw = clRect.right; + desth = destw * bmp.bmHeight/bmp.bmWidth; + if (backgroundBmpUse & CLBF_TILEVTOROWHEIGHT) + desth = g_ctrl->nButtonHeight+2; + } + else { + destw = clRect.right; + desth = bmp.bmHeight; + } + break; + case CLB_STRETCHV: + if (backgroundBmpUse & CLBF_PROPORTIONAL) { + desth = clRect.bottom; + destw = desth*bmp.bmWidth/bmp.bmHeight; + } + else { + destw = bmp.bmWidth; + desth = clRect.bottom; + } + break; + default: //clb_topleft + destw = bmp.bmWidth; + desth = bmp.bmHeight; + if (backgroundBmpUse & CLBF_TILEVTOROWHEIGHT) + desth = g_ctrl->nButtonHeight+2; + break; + } + + for (; y < maxy; y += desth) { + if (y < rcPaint->top - desth) + continue; + + for (int x = 0; x < maxx; x += destw) + StretchBlt(hdcMem, x, y, destw, desth, hdcBmp, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY); + } + DeleteDC(hdcBmp); + } + BitBlt(hdc, rcPaint->left, rcPaint->top, rcPaint->right-rcPaint->left, rcPaint->bottom-rcPaint->top, hdcMem, rcPaint->left, rcPaint->top, SRCCOPY); + SelectObject(hdcMem, hOldBmp); + DeleteDC(hdcMem); + DeleteObject(hBmpOsb); + + paintst.fErase = FALSE; + EndPaint(hwnd, &paintst); +} + +///////////////////////////////////////////////////////////////////////////////////////// + +LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + static bool supressRepos = false; + + if (g_ctrl->fnWindowProc != NULL) + if ( g_ctrl->fnWindowProc(hwnd, msg, wParam, lParam)) + return g_ctrl->lResult; + + switch(msg) { + case WM_CREATE: + g_ctrl->hWnd = hwnd; + PostMessage(hwnd, TTB_UPDATEFRAMEVISIBILITY, 1, 0); + return FALSE; + + case WM_MOVE: + return 0; + + case WM_WINDOWPOSCHANGING: + case WM_SIZE: + if (g_ctrl->nLastHeight != HIWORD(lParam)) { + db_set_dw(0, TTB_OPTDIR, "LastHeight", g_ctrl->nLastHeight = HIWORD(lParam)); + ArrangeButtons(); + } + if (supressRepos) { + supressRepos = false; + break; + } + // fall through + + case TTB_REPOSBUTTONS: + if (g_ctrl->hWnd == hwnd) { + int iHeight = ArrangeButtons(); + if ( g_ctrl->bAutoSize) { + RECT rcClient; + GetClientRect(g_ctrl->hWnd, &rcClient); + if (rcClient.bottom - rcClient.top != iHeight && iHeight) { + supressRepos = true; + PostMessage(hwnd, TTB_UPDATEFRAMEVISIBILITY, -1, 0); + } + } + return 0; + } + break; + + case WM_NCPAINT: + case WM_PAINT: + PaintToolbar(hwnd); + return 0; + + case WM_LBUTTONDOWN: + if (db_get_b(NULL, "CLUI", "ClientAreaDrag", 0)) { + POINT pt; + GetCursorPos(&pt); + return SendMessage(GetParent(hwnd), WM_SYSCOMMAND, SC_MOVE|HTCAPTION, MAKELPARAM(pt.x, pt.y)); + } + return 0; + + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + case BN_DOUBLECLICKED: + { + int id = GetWindowLongPtr((HWND)lParam, GWLP_USERDATA); + if (id != 0) { + mir_cslock lck(csButtonsHook); + TopButtonInt* b = idtopos(id); + if (b == NULL || b->isSep()) + return 0; + + if (b->dwFlags & TTBBF_ASPUSHBUTTON) + b->bPushed = !b->bPushed; + + if (b->bPushed) { //Dn -> Up + if (!(b->dwFlags & TTBBF_ISLBUTTON)) // must be always true + if (b->pszService != NULL) + CallService(b->pszService, b->wParamUp, b->lParamUp); + } + else { //Up -> Dn + if (b->pszService != NULL) + CallService(b->pszService, b->wParamDown, b->lParamDown); + } + + b->SetBitmap(); + } + } + break; + } + break; + + case TTB_UPDATEFRAMEVISIBILITY: + { + BOOL vis=(BOOL)wParam; + BOOL curvis = IsWindowVisible(hwnd); + bool bResize = false; + int Height = ArrangeButtons(); + + if (g_ctrl->bAutoSize) { + INT_PTR frameopt = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, g_ctrl->hFrame), 0); + if (Height != frameopt) { + CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, g_ctrl->hFrame), Height); + bResize = TRUE; + } + } + + if (g_ctrl->bOrderChanged) + bResize = TRUE, g_ctrl->bOrderChanged = FALSE; + + if ((curvis != vis || bResize) && vis != -1) { + INT_PTR frameopt = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, g_ctrl->hFrame), 0); + frameopt &= ~F_VISIBLE; + frameopt |= vis ? F_VISIBLE : 0; + CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, g_ctrl->hFrame), frameopt); + } + } + break; + + case TTB_SETCUSTOM: + { + TTBCtrlCustomize *pCustom = (TTBCtrlCustomize*)lParam; + if (pCustom == NULL || g_ctrl->fnWindowProc) + break; + + g_ctrl = (TTBCtrl*)mir_realloc(g_ctrl, pCustom->cbLen); + if (pCustom->cbLen > sizeof(TTBCtrl)) + memset(g_ctrl+1, 0, pCustom->cbLen - sizeof(TTBCtrl)); + + g_ctrl->fnWindowProc = pCustom->fnWindowProc; + SetWindowLongPtr(hwnd, 0, (LONG_PTR)g_ctrl); + } + break; + + default: + return DefWindowProc(hwnd, msg, wParam, lParam); + } + return(TRUE); +} + +///////////////////////////////////////////////////////////////////////////////////////// + +INT_PTR OnEventFire(WPARAM wParam, LPARAM lParam) +{ + CallService(MS_SYSTEM_REMOVEWAIT, wParam, 0); + CloseHandle((HANDLE)wParam); + + HWND parent = (HWND)CallService(MS_CLUI_GETHWND, 0, 0); + if (parent == NULL) // no clist, no buttons + return -1; + + WNDCLASS wndclass = { 0 }; + wndclass.lpfnWndProc = TopToolBarProc; + wndclass.cbWndExtra = sizeof(void*); + wndclass.hInstance = hInst; + wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); + wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); + wndclass.lpszClassName = pluginname; + RegisterClass(&wndclass); + + g_ctrl->pButtonList = (SortedList*)&Buttons; + g_ctrl->hWnd = CreateWindow(pluginname, _T("Toolbar"), + WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, + 0, 0, 0, g_ctrl->nLastHeight, parent, NULL, hInst, NULL); + SetWindowLongPtr(g_ctrl->hWnd, 0, (LPARAM)g_ctrl); + + LoadBackgroundOptions(); + + // if we're working in skinned clist, receive the standard buttons & customizations + if (g_CustomProc && g_ctrl->hWnd) + g_CustomProc(TTB_WINDOW_HANDLE, g_ctrl->hWnd, g_CustomProcParam); + + // if there's no customized frames, create our own + if (g_ctrl->hFrame == NULL) { + CLISTFrame Frame = { 0 }; + Frame.cbSize = sizeof(Frame); + Frame.tname = _T("Toolbar"); + Frame.hWnd = g_ctrl->hWnd; + Frame.align = alTop; + Frame.Flags = F_VISIBLE | F_NOBORDER | F_LOCKED | F_TCHAR; + Frame.height = g_ctrl->nLastHeight; + g_ctrl->hFrame = (HANDLE)CallService(MS_CLIST_FRAMES_ADDFRAME, (WPARAM)&Frame, 0); + } + + // receive all buttons + NotifyEventHooks(hTTBInitButtons, 0, 0); + NotifyEventHooks(hTTBModuleLoaded, 0, 0); + + return 0; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +int LoadBackgroundOptions() +{ + //load options + bkColour = DBGetContactSettingDword(NULL, TTB_OPTDIR, "BkColour", TTBDEFAULT_BKCOLOUR); + if (hBmpBackground) { + DeleteObject(hBmpBackground); + hBmpBackground = NULL; + } + + if (db_get_b(NULL, TTB_OPTDIR, "UseBitmap", TTBDEFAULT_USEBITMAP)) { + DBVARIANT dbv; + if (!DBGetContactSetting(NULL, TTB_OPTDIR, "BkBitmap", &dbv)) { + hBmpBackground = (HBITMAP)CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM)dbv.pszVal); + DBFreeVariant(&dbv); + } + } + backgroundBmpUse = DBGetContactSettingWord(NULL, TTB_OPTDIR, "BkBmpUse", TTBDEFAULT_BKBMPUSE); + + RECT rc; + GetClientRect(g_ctrl->hWnd, &rc); + InvalidateRect(g_ctrl->hWnd, &rc, TRUE); + UpdateWindow(g_ctrl->hWnd); + + return 0; +} diff --git a/plugins/TopToolBar/src/topbutton.cpp b/plugins/TopToolBar/src/topbutton.cpp new file mode 100644 index 0000000000..8e2f8a1cfd --- /dev/null +++ b/plugins/TopToolBar/src/topbutton.cpp @@ -0,0 +1,178 @@ + +#include "common.h" + +#define BitChanged(c) (dwFlags ^ Flags) & c + +static int maxid = 10000; + +TopButtonInt::~TopButtonInt() +{ + if (hwnd) + DestroyWindow(hwnd); + + if (dwFlags & TTBBF_ISLBUTTON) { + mir_free(ptszProgram); + } + else if (pszService != NULL) + mir_free(pszService); + + mir_free(pszName); + mir_free(ptszTooltip); + mir_free(ptszTooltipDn); + mir_free(ptszTooltipUp); +} + +DWORD TopButtonInt::CheckFlags(DWORD Flags) +{ + int res = 0; + if ( BitChanged(TTBBF_DISABLED)) { + dwFlags ^= TTBBF_DISABLED; + EnableWindow(hwnd,(dwFlags & TTBBF_DISABLED)?FALSE:TRUE); + } + if ( BitChanged(TTBBF_ASPUSHBUTTON)) { + dwFlags ^= TTBBF_ASPUSHBUTTON; + SendMessage(hwnd, BUTTONSETASPUSHBTN, (dwFlags & TTBBF_ASPUSHBUTTON)?1:0, 0); + } + if ( BitChanged(TTBBF_SHOWTOOLTIP)) { + dwFlags ^= TTBBF_SHOWTOOLTIP; + SendMessage(hwnd,BUTTONADDTOOLTIP, + (WPARAM)((dwFlags & TTBBF_SHOWTOOLTIP) ? ptszTooltip : _T("")), BATF_TCHAR); + } + // next settings changing visual side, requires additional actions + if ( BitChanged(TTBBF_VISIBLE)) { + dwFlags ^= TTBBF_VISIBLE; + res |= TTBBF_VISIBLE; + } + if ( BitChanged(TTBBF_PUSHED)) { + dwFlags ^= TTBBF_PUSHED; + res |= TTBBF_PUSHED; + bPushed = (dwFlags & TTBBF_PUSHED) ? TRUE : FALSE; + } + return res; +} + +void TopButtonInt::CreateWnd() +{ + if ( !(dwFlags & TTBBF_ISSEPARATOR)) { + hwnd = CreateWindow(TTB_BUTTON_CLASS, _T(""), BS_PUSHBUTTON|WS_CHILD|WS_TABSTOP|SS_NOTIFY, 0, 0, g_ctrl->nButtonWidth, g_ctrl->nButtonHeight, g_ctrl->hWnd, NULL, hInst, this); + + if (dwFlags & TTBBF_ASPUSHBUTTON) + SendMessage(hwnd, BUTTONSETASPUSHBTN, 1, 0); + + if (db_get_b(0, TTB_OPTDIR, "UseFlatButton", 1)) + SendMessage(hwnd, BUTTONSETASFLATBTN, TRUE, 0); + + EnableWindow(hwnd,(dwFlags & TTBBF_DISABLED)?FALSE:TRUE); + } + // maybe SEPWIDTH, not g_ctrl->nButtonWidth? + else + hwnd = CreateWindow( _T("STATIC"), _T(""), WS_CHILD|SS_NOTIFY, 0, 0, g_ctrl->nButtonWidth, g_ctrl->nButtonHeight, g_ctrl->hWnd, NULL, hInst, 0); + + SetWindowLongPtr(hwnd, GWLP_USERDATA, id); + SetBitmap(); +} + +void TopButtonInt::LoadSettings() +{ + char buf[255]; + + BYTE oldv = isVisible(); + dwFlags = dwFlags & (~TTBBF_VISIBLE); + + if (dwFlags & TTBBF_ISSEPARATOR) { + char buf1[10]; + _itoa(wParamDown, buf1, 10); + char buf2[20]; + AS(buf2, "Sep", buf1); + + arrangedpos = db_get_b(0, TTB_OPTDIR, AS(buf, buf2, "_Position"), Buttons.getCount()); + if ( db_get_b(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"), oldv) > 0 ) + dwFlags |= TTBBF_VISIBLE; + } + else if ((dwFlags & TTBBF_ISLBUTTON ) && (dwFlags & TTBBF_INTERNAL)) { + char buf1[10]; + _itoa(wParamDown, buf1, 10); + char buf2[20]; + AS(buf2, "Launch", buf1); + + mir_free(pszName); + pszName = DBGetString(0, TTB_OPTDIR, AS(buf, buf2, "_name")); + + mir_free(ptszProgram); + ptszProgram = DBGetStringT(0, TTB_OPTDIR, AS(buf, buf2, "_lpath")); + + arrangedpos = db_get_b(0, TTB_OPTDIR, AS(buf, buf2, "_Position"), Buttons.getCount()); + if ( db_get_b(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"), oldv) > 0 ) + dwFlags |= TTBBF_VISIBLE; + } + else { + arrangedpos = db_get_b(0, TTB_OPTDIR, AS(buf, pszName, "_Position"), Buttons.getCount()); + if ( db_get_b(0, TTB_OPTDIR, AS(buf, pszName, "_Visible"), oldv) > 0 ) + dwFlags |= TTBBF_VISIBLE; + } + + if (Buttons.getIndex(this) != -1) + arrangedpos = maxid++; +} + +void TopButtonInt::SaveSettings(int *SepCnt, int *LaunchCnt) +{ + char buf[255]; + + if (SepCnt && (dwFlags & TTBBF_ISSEPARATOR) && (dwFlags & TTBBF_INTERNAL)) { + char buf1[10]; + _itoa(SepCnt[0]++, buf1, 10); + char buf2[20]; + AS(buf2, "Sep", buf1); + + db_set_b(0, TTB_OPTDIR, AS(buf, buf2, "_Position"), arrangedpos); + db_set_b(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"), isVisible()); + } + else if (LaunchCnt && (dwFlags & TTBBF_ISLBUTTON ) && (dwFlags & TTBBF_INTERNAL)) { + char buf1[10]; + _itoa(LaunchCnt[0]++, buf1, 10); + char buf2[20]; + AS(buf2, "Launch", buf1); + + DBWriteContactSettingString(0, TTB_OPTDIR, AS(buf, buf2, "_name"), pszName); + DBWriteContactSettingTString(0, TTB_OPTDIR, AS(buf, buf2, "_lpath"), ptszProgram); + db_set_b(0, TTB_OPTDIR, AS(buf, buf2, "_Position"), arrangedpos); + db_set_b(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"), isVisible()); + } + else { + db_set_b(0, TTB_OPTDIR, AS(buf, pszName, "_Position"), arrangedpos); + db_set_b(0, TTB_OPTDIR, AS(buf, pszName, "_Visible"), isVisible()); + } +} + +void TopButtonInt::SetBitmap() +{ + int curstyle = GetWindowLongPtr(hwnd, GWL_STYLE); + curstyle &= (~SS_BITMAP); + curstyle &= (~SS_ICON); + + if (dwFlags & TTBBF_ISSEPARATOR) { + SetWindowLongPtr(hwnd, GWL_STYLE, curstyle | SS_BITMAP); + SendMessage(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBmpSeparator); + SendMessage(hwnd, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBmpSeparator); + } + else { + if (GetWindowLongPtr(hwnd, GWL_STYLE) & SS_ICON) + SetWindowLongPtr(hwnd, GWL_STYLE, curstyle | SS_ICON); + + TCHAR* pTooltip; + if (bPushed) { + SendMessage(hwnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)((hIconDn) ? hIconDn : hIconUp)); + SendMessage(hwnd, BM_SETCHECK, BST_CHECKED, 0); + + pTooltip = (ptszTooltipDn) ? ptszTooltipDn : ptszTooltipUp; + } + else { + SendMessage(hwnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIconUp); + SendMessage(hwnd, BM_SETCHECK, BST_UNCHECKED, 0); + pTooltip = ptszTooltipUp; + } + if (pTooltip) + SendMessage(hwnd, BUTTONADDTOOLTIP, (WPARAM)TranslateTH(hLangpack, pTooltip), BATF_TCHAR); + } +} diff --git a/plugins/TopToolBar/src/ttbopt.cpp b/plugins/TopToolBar/src/ttbopt.cpp new file mode 100644 index 0000000000..db7d78dcb5 --- /dev/null +++ b/plugins/TopToolBar/src/ttbopt.cpp @@ -0,0 +1,559 @@ +#include "common.h" + +static HWND OptionshWnd; + +struct OrderData +{ + int dragging; + HTREEITEM hDragItem; + HIMAGELIST himlButtonIcons; +}; + +///////////////////////////////////////////////////////////////////////////////////////// + +static HTREEITEM AddLine(HWND hTree,TopButtonInt *b, HTREEITEM hItem, HIMAGELIST il) +{ + TVINSERTSTRUCT tvis = { 0 }; + tvis.hInsertAfter = hItem; + tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE; + + int index; + TCHAR* tmp; + + if (b->dwFlags & TTBBF_ISSEPARATOR) { + tvis.item.pszText = _T("------------------"); + index = -1; + } + else { + if (b->hIconHandleUp) { + HICON hIcon = Skin_GetIconByHandle(b->hIconHandleUp); + index = ImageList_AddIcon(il, hIcon); + Skin_ReleaseIcon(hIcon); + } + else index = ImageList_AddIcon(il, b->hIconUp); + + tmp = mir_a2t( b->pszName ); + tvis.item.pszText = TranslateTS(tmp); + } + tvis.item.iImage = tvis.item.iSelectedImage = index; + + tvis.item.lParam = (LPARAM)b; + HTREEITEM hti = TreeView_InsertItem(hTree, &tvis); + + if (!(b->dwFlags & TTBBF_ISSEPARATOR)) + mir_free(tmp); + + TreeView_SetCheckState(hTree, hti, b->isVisible()); + return hti; +} + +static int BuildTree(HWND hwndDlg) +{ + HWND hTree = GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE); + OrderData *dat = (OrderData*)GetWindowLongPtr(hTree, GWLP_USERDATA); + + dat->himlButtonIcons = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 2, 2); + TreeView_SetImageList(hTree, dat->himlButtonIcons, TVSIL_NORMAL); + SetWindowLongPtr(hTree, GWL_STYLE, GetWindowLongPtr(hTree,GWL_STYLE)|TVS_NOHSCROLL); + TreeView_DeleteAllItems(hTree); + + if (Buttons.getCount() == 0) + return FALSE; + + for (int i = 0; i < Buttons.getCount(); i++) + AddLine(hTree, Buttons[i], TVI_LAST, dat->himlButtonIcons); + return TRUE; +} + +static void SaveTree(HWND hwndDlg) +{ + HWND hTree = GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE); + + TVITEM tvi = { 0 }; + tvi.hItem = TreeView_GetRoot(hTree); + tvi.stateMask = TVIS_STATEIMAGEMASK; + tvi.mask = TVIF_PARAM | TVIF_HANDLE | TVIF_STATE; + + LIST tmpList(8); + + while(tvi.hItem != NULL) { + TreeView_GetItem(hTree, &tvi); + + TopButtonInt* btn = (TopButtonInt*)tvi.lParam; + Buttons.remove(btn); + + if (TreeView_GetCheckState(hTree,tvi.hItem)) + btn->dwFlags |= TTBBF_VISIBLE; + else + btn->dwFlags &= ~TTBBF_VISIBLE; + btn->dwFlags &= ~TTBBF_OPTIONAL; + btn->arrangedpos = tmpList.getCount(); + + tmpList.insert(btn); + tvi.hItem = TreeView_GetNextSibling(hTree, tvi.hItem); + } + { + mir_cslock lck(csButtonsHook); + for (int i=0; i < Buttons.getCount(); i++) + delete Buttons[i]; + + Buttons = tmpList; + tmpList.destroy(); + } + SaveAllButtonsOptions(); +} + +void CancelProcess(HWND hwndDlg) +{ + HWND hTree = GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE); + + TVITEM tvi = { 0 }; + tvi.hItem = TreeView_GetRoot(hTree); + + while(tvi.hItem != NULL) { + tvi.stateMask = TVIS_STATEIMAGEMASK; + tvi.mask = TVIF_PARAM | TVIF_HANDLE | TVIF_STATE; + TreeView_GetItem(hTree, &tvi); + + TopButtonInt* btn = (TopButtonInt*)tvi.lParam; + + if (btn ->dwFlags & TTBBF_OPTIONAL) + delete btn; + + tvi.hItem = TreeView_GetNextSibling(hTree, tvi.hItem); + } +} + +static void RecreateWindows() +{ + { + mir_cslock lck(csButtonsHook); + for (int i = 0; i < Buttons.getCount(); i++) { + TopButtonInt *b = Buttons[i]; + if (b->hwnd) { + DestroyWindow(b->hwnd); + b->CreateWnd(); + } + } + } + + if (g_ctrl->hWnd) + PostMessage(g_ctrl->hWnd, TTB_UPDATEFRAMEVISIBILITY, TRUE, 0); +} + +///////////////////////////////////////////////////////////////////////////////////////// +// external functions + +void AddToOptions(TopButtonInt* b) +{ + if (OptionshWnd) { + HWND hTree = GetDlgItem(OptionshWnd, IDC_BUTTONORDERTREE); + OrderData *dat = (OrderData*)GetWindowLongPtr(hTree, GWLP_USERDATA); + AddLine(hTree, b, TVI_LAST, dat->himlButtonIcons); + } +} + +void RemoveFromOptions(int id) +{ + if (OptionshWnd) { + HWND hTree = GetDlgItem(OptionshWnd, IDC_BUTTONORDERTREE); + TVITEM tvi = { 0 }; + tvi.hItem = TreeView_GetRoot(hTree); + tvi.mask = TVIF_PARAM | TVIF_HANDLE; + + TopButtonInt* btn; + while(tvi.hItem != NULL) { + TreeView_GetItem(hTree, &tvi); + btn = (TopButtonInt*)tvi.lParam; + if (btn->id == id) { + // delete if was changed + if (btn->dwFlags & TTBBF_OPTIONAL) + delete btn; + TreeView_DeleteItem(hTree,tvi.hItem); + break; + } + + tvi.hItem = TreeView_GetNextSibling(hTree, tvi.hItem); + } + } +} + +///////////////////////////////////////////////////////////////////////////////////////// +// Options window: main + +static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + HWND hTree = GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE); + OrderData *dat = (OrderData*)GetWindowLongPtr(hTree, GWLP_USERDATA); + + switch (msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + dat = (OrderData*)malloc( sizeof(OrderData)); + SetWindowLongPtr(hTree, GWLP_USERDATA, (LONG)dat); + dat->dragging = 0; + + SetWindowLongPtr(hTree, GWL_STYLE, GetWindowLongPtr(hTree, GWL_STYLE)|TVS_NOHSCROLL); + + SetDlgItemInt(hwndDlg, IDC_BUTTHEIGHT, g_ctrl->nButtonHeight, FALSE); + SendDlgItemMessage(hwndDlg, IDC_SPIN_HEIGHT, UDM_SETRANGE, 0, MAKELONG(50,10)); + SendDlgItemMessage(hwndDlg, IDC_SPIN_HEIGHT, UDM_SETPOS, 0, MAKELONG(g_ctrl->nButtonHeight,0)); + + SetDlgItemInt(hwndDlg, IDC_BUTTWIDTH, g_ctrl->nButtonWidth, FALSE); + SendDlgItemMessage(hwndDlg, IDC_SPIN_WIDTH, UDM_SETRANGE, 0, MAKELONG(50,10)); + SendDlgItemMessage(hwndDlg, IDC_SPIN_WIDTH, UDM_SETPOS, 0, MAKELONG(g_ctrl->nButtonWidth,0)); + + SetDlgItemInt(hwndDlg, IDC_BUTTGAP, g_ctrl->nButtonSpace, FALSE); + SendDlgItemMessage(hwndDlg, IDC_SPIN_GAP, UDM_SETRANGE, 0, MAKELONG(20,0)); + SendDlgItemMessage(hwndDlg, IDC_SPIN_GAP, UDM_SETPOS, 0, MAKELONG(g_ctrl->nButtonSpace,0)); + + CheckDlgButton(hwndDlg, IDC_USEFLAT, g_ctrl->bFlatButtons); + CheckDlgButton(hwndDlg, IDC_AUTORESIZE, g_ctrl->bAutoSize); + CheckDlgButton(hwndDlg, IDC_SINGLELINE, g_ctrl->bSingleLine); + + BuildTree(hwndDlg); + EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_DELLBUTTON), FALSE); + + OptionshWnd = hwndDlg; + return TRUE; + + case WM_COMMAND: + if (HIWORD(wParam) == EN_CHANGE && OptionshWnd) { + switch(LOWORD(wParam)) { + case IDC_ENAME: case IDC_EPATH: + break; + default: + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + break; + } + + if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DBLCLK)) { + int ctrlid = LOWORD(wParam); + + //----- Launch buttons ----- + + if (ctrlid == IDC_BROWSE) { + TCHAR str[MAX_PATH]; + OPENFILENAME ofn = {0}; + + GetDlgItemText(hwndDlg, IDC_EPATH, str, sizeof(str)); + ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; + ofn.hwndOwner = hwndDlg; + ofn.hInstance = NULL; + ofn.lpstrFilter = NULL; + ofn.lpstrFile = str; + ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_EXPLORER; + ofn.nMaxFile = sizeof(str); + ofn.nMaxFileTitle = MAX_PATH; + ofn.lpstrDefExt = _T("exe"); + if (!GetOpenFileName(&ofn)) + break; + + SetDlgItemText(hwndDlg, IDC_EPATH, str); + + break; + } + + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + + if (ctrlid == IDC_LBUTTONSET) { + TVITEM tvi ={0}; + tvi.hItem = TreeView_GetSelection(hTree); + if (tvi.hItem == NULL) + break; + + tvi.mask = TVIF_PARAM; + TreeView_GetItem(hTree, &tvi); + + TopButtonInt* btn = (TopButtonInt*)tvi.lParam; + TCHAR buf [256]; + // probably, condition not needs + if (btn->dwFlags & TTBBF_ISLBUTTON) { + if (!(btn->dwFlags & TTBBF_OPTIONAL)) { + // create button + TTBButton ttb = { 0 }; + ttb.cbSize = sizeof(ttb); + ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); + ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISLBUTTON | TTBBF_INTERNAL | TTBBF_OPTIONAL; + ttb.name = NULL; + ttb.program = NULL; + int id = btn->id; + btn = CreateButton(&ttb); + btn->id = id; + + tvi.lParam = (LPARAM)btn; + TreeView_SetItem(hTree, &tvi); + } + + GetDlgItemText(hwndDlg, IDC_ENAME, buf, 255); + replaceStr(btn->pszName, _T2A(buf)); + + tvi.mask = TVIF_TEXT; + tvi.pszText = buf; + TreeView_SetItem(hTree, &tvi); + + GetDlgItemText(hwndDlg, IDC_EPATH, buf, 255); + replaceStrT(btn->ptszProgram, buf); + } + break; + } + + if (ctrlid == IDC_ADDLBUTTON) { + // create button + TTBButton ttb = { 0 }; + ttb.cbSize = sizeof(ttb); + ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); + ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISLBUTTON | TTBBF_INTERNAL | TTBBF_OPTIONAL; + ttb.name = LPGEN("Default"); + ttb.program = _T("Execute Path"); + TopButtonInt* b = CreateButton(&ttb); + + // get selection for insert + TVITEM tvi = {0}; + tvi.hItem = TreeView_GetSelection(hTree); + + // insert item + AddLine(hTree, b, tvi.hItem, dat->himlButtonIcons); + + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + } + + //----- Separators ----- + + if (ctrlid == IDC_ADDSEP) { + // create button + TTBButton ttb = { 0 }; + ttb.cbSize = sizeof(ttb); + ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISSEPARATOR | TTBBF_INTERNAL | TTBBF_OPTIONAL; + TopButtonInt* b = CreateButton(&ttb); + + // get selection for insert + TVITEM tvi = {0}; + tvi.hItem = TreeView_GetSelection(hTree); + + // insert item + AddLine(hTree, b, tvi.hItem, dat->himlButtonIcons); + + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + } + + if (ctrlid == IDC_REMOVEBUTTON) { + TVITEM tvi = {0}; + tvi.hItem = TreeView_GetSelection(hTree); + if (tvi.hItem == NULL) + break; + + tvi.mask = TVIF_PARAM; + TreeView_GetItem(hTree, &tvi); + + TopButtonInt* btn = (TopButtonInt*)tvi.lParam; + // if button enabled for separator and launch only, no need condition + // except possible service button introducing + if (btn->dwFlags & (TTBBF_ISSEPARATOR | TTBBF_ISLBUTTON)) { + // delete if was added in options + if (btn->dwFlags & TTBBF_OPTIONAL) + delete btn; + + TreeView_DeleteItem(hTree,tvi.hItem); + + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + break; + } + } + break; + + case WM_NOTIFY: + switch(((LPNMHDR)lParam)->idFrom) { + case 0: + switch (((LPNMHDR)lParam)->code) { + case PSN_APPLY: + g_ctrl->nButtonHeight = GetDlgItemInt(hwndDlg, IDC_BUTTHEIGHT, NULL, FALSE); + g_ctrl->nButtonWidth = GetDlgItemInt(hwndDlg, IDC_BUTTWIDTH, NULL, FALSE); + g_ctrl->nButtonSpace = GetDlgItemInt(hwndDlg, IDC_BUTTGAP, NULL, FALSE); + + g_ctrl->bFlatButtons = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_USEFLAT); + g_ctrl->bAutoSize = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTORESIZE); + g_ctrl->bSingleLine = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SINGLELINE); + + db_set_dw(0, TTB_OPTDIR, "BUTTHEIGHT", g_ctrl->nButtonHeight); + db_set_dw(0, TTB_OPTDIR, "BUTTWIDTH", g_ctrl->nButtonWidth); + db_set_dw(0, TTB_OPTDIR, "BUTTGAP", g_ctrl->nButtonSpace); + + db_set_b(0, TTB_OPTDIR, "UseFlatButton", g_ctrl->bFlatButtons); + db_set_b(0, TTB_OPTDIR, "SingleLine", g_ctrl->bSingleLine); + db_set_b(0, TTB_OPTDIR, "AutoSize", g_ctrl->bAutoSize); + + SaveTree(hwndDlg); + RecreateWindows(); + ArrangeButtons(); + } + break; + + case IDC_BUTTONORDERTREE: + switch (((LPNMHDR)lParam)->code) { + case TVN_BEGINDRAGA: + case TVN_BEGINDRAGW: + SetCapture(hwndDlg); + dat->dragging = 1; + dat->hDragItem = ((LPNMTREEVIEW)lParam)->itemNew.hItem; + TreeView_SelectItem(hTree, dat->hDragItem); + break; + + case NM_CLICK: + { + TVHITTESTINFO hti; + hti.pt.x = (short)LOWORD(GetMessagePos()); + hti.pt.y = (short)HIWORD(GetMessagePos()); + ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt); + if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti)) + if (hti.flags & TVHT_ONITEMSTATEICON) { + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + TreeView_SelectItem(hTree, hti.hItem); + } + } + break; + + case TVN_SELCHANGEDA: + case TVN_SELCHANGEDW: + { + HTREEITEM hti = TreeView_GetSelection(hTree); + if (hti == NULL) + break; + + TopButtonInt *btn = (TopButtonInt*)((LPNMTREEVIEW)lParam)->itemNew.lParam; + + mir_cslock lck(csButtonsHook); + + if (btn->dwFlags & TTBBF_ISLBUTTON) { + bool enable = (btn->dwFlags & TTBBF_INTERNAL) !=0; + EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), enable); + EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), enable); + EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVEBUTTON), enable); + EnableWindow(GetDlgItem(hwndDlg, IDC_LBUTTONSET), enable); + if (btn->pszName != NULL) + SetDlgItemTextA(hwndDlg, IDC_ENAME, btn->pszName); + else + SetDlgItemTextA(hwndDlg, IDC_ENAME, ""); + + if (btn->ptszProgram != NULL) + SetDlgItemText(hwndDlg, IDC_EPATH, btn->ptszProgram); + else + SetDlgItemTextA(hwndDlg, IDC_EPATH, ""); + } + else { + EnableWindow(GetDlgItem(hwndDlg,IDC_REMOVEBUTTON), + (btn->dwFlags & TTBBF_ISSEPARATOR)?TRUE:FALSE); + + EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_LBUTTONSET), FALSE); + SetDlgItemTextA(hwndDlg, IDC_ENAME, ""); + SetDlgItemTextA(hwndDlg, IDC_EPATH, ""); + } + } + } + break; + } + break; + + case WM_MOUSEMOVE: + if (dat->dragging) { + TVHITTESTINFO hti; + hti.pt.x = (short)LOWORD(lParam); + hti.pt.y = (short)HIWORD(lParam); + ClientToScreen(hwndDlg, &hti.pt); + ScreenToClient(hTree, &hti.pt); + TreeView_HitTest(hTree, &hti); + if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) { + HTREEITEM it=hti.hItem; + hti.pt.y -= TreeView_GetItemHeight(hTree)/2; + TreeView_HitTest(hTree, &hti); + if (!(hti.flags&TVHT_ABOVE)) + TreeView_SetInsertMark(hTree,hti.hItem,1); + else + TreeView_SetInsertMark(hTree,it,0); + } + else { + if (hti.flags & TVHT_ABOVE) SendMessage(hTree, WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0); + if (hti.flags & TVHT_BELOW) SendMessage(hTree, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0); + TreeView_SetInsertMark(hTree, NULL, 0); + } + } + break; + + case WM_LBUTTONUP: + if (dat->dragging) { + TreeView_SetInsertMark(hTree, NULL, 0); + dat->dragging = 0; + ReleaseCapture(); + + TVHITTESTINFO hti; + hti.pt.x = (short)LOWORD(lParam); + hti.pt.y = (short)HIWORD(lParam); + ClientToScreen(hwndDlg, &hti.pt); + ScreenToClient(hTree, &hti.pt); + hti.pt.y -= TreeView_GetItemHeight(hTree)/2; + TreeView_HitTest(hTree, &hti); + if (dat->hDragItem == hti.hItem) + break; + if (hti.flags&TVHT_ABOVE) + hti.hItem=TVI_FIRST; + + TVITEM tvi; + tvi.mask = TVIF_HANDLE|TVIF_PARAM; + tvi.hItem = (HTREEITEM) dat->hDragItem; + TreeView_GetItem(hTree, &tvi); + if ( (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) || (hti.hItem==TVI_FIRST)) { + TVINSERTSTRUCT tvis; + TCHAR name[128]; + tvis.item.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_STATE; + tvis.item.stateMask = 0xFFFFFFFF; + tvis.item.pszText = name; + tvis.item.cchTextMax = SIZEOF(name); + tvis.item.hItem = dat->hDragItem; + TreeView_GetItem(hTree, &tvis.item); + + TreeView_DeleteItem(hTree, dat->hDragItem); + tvis.hParent = NULL; + tvis.hInsertAfter = hti.hItem; + TreeView_SelectItem(hTree, TreeView_InsertItem(hTree, &tvis)); + + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + } + break; + + case WM_DESTROY: + if (dat) { + ImageList_Destroy(dat->himlButtonIcons); + free(dat); + } + OptionshWnd = NULL; + break; + } + return FALSE; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +int TTBOptInit(WPARAM wParam, LPARAM lParam) +{ + OPTIONSDIALOGPAGE odp = { 0 }; + odp.cbSize = sizeof(odp); + odp.hInstance = hInst; + odp.pszGroup = LPGEN("Contact List"); + + odp.position = -1000000000; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_BUTORDER); + odp.pszTitle = LPGEN("Toolbar"); + odp.pfnDlgProc = ButOrderOpts; + odp.flags = ODPF_BOLDGROUPS | ODPF_EXPERTONLY; + Options_AddPage(wParam, &odp); + return 0; +} diff --git a/plugins/TopToolBar/src/version.h b/plugins/TopToolBar/src/version.h new file mode 100644 index 0000000000..9a489eebee --- /dev/null +++ b/plugins/TopToolBar/src/version.h @@ -0,0 +1,46 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2008 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 8 +#define __RELEASE_NUM 0 +#define __BUILD_NUM 1 + +// other stuff for Version resource +#define __STRINGIFY_IMPL(x) #x +#define __STRINGIFY(x) __STRINGIFY_IMPL(x) + +#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM +#define __FILEVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM +#define __VERSION_STRING __STRINGIFY(__FILEVERSION_STRING_DOTS) + +#define __PLUGIN_DESC "ToptoolBar adds buttons in top frame for fast access." +#define __PLUGIN_LONGDESC __PLUGIN_DESC +#define __PLUGIN_AUTHOR "Bethoven" +#define __PLUGIN_AUTHORWEB "http://nightly.miranda.im/" +#define __PLUGIN_EMAIL "Bethoven@mailgate.ru" +#define __PLUGIN_RIGHTS "© 2003-2008 Bethoven" +#define __PLUGIN_FILE "TopToolbar.dll" +#define __PLUGIN_SHORTNAME "TopToolBar" + +#define __PLUGIN_NAME __PLUGIN_SHORTNAME diff --git a/plugins/TopToolBar/toolbar.cpp b/plugins/TopToolBar/toolbar.cpp deleted file mode 100644 index 156b83dbb7..0000000000 --- a/plugins/TopToolBar/toolbar.cpp +++ /dev/null @@ -1,707 +0,0 @@ - -#include "common.h" - -#define OLD_TBBUTTON_SIZE (offsetof(TTBButton, pszTooltipUp)) - -pfnCustomProc g_CustomProc = NULL; -LPARAM g_CustomProcParam = 0; -TTBCtrl *g_ctrl = NULL; - -INT_PTR OnEventFire(WPARAM wParam, LPARAM lParam); - -HWND hwndContactList = 0; - -int nextButtonId = 200; - -HANDLE hTTBModuleLoaded, hTTBInitButtons; -static WNDPROC buttonWndProc; - -CRITICAL_SECTION csButtonsHook; - -int sortfunc(const TopButtonInt* a, const TopButtonInt* b) -{ - return a->arrangedpos - b->arrangedpos; -} - -LIST Buttons(8, sortfunc); - -TopButtonInt* idtopos(int id, int* pPos) -{ - for ( int i = 0; i < Buttons.getCount(); i++) - if (Buttons[i]->id == id) { - if (pPos) *pPos = i; - return Buttons[i]; - } - - if (pPos) *pPos = -1; - return NULL; -} - -//----- Service buttons ----- -void InsertSBut(int i) -{ - TTBButton ttb = { 0 }; - ttb.cbSize = sizeof(ttb); - ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); - ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); - ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISSBUTTON | TTBBF_INTERNAL; - ttb.wParamDown = i; - TTBAddButton(( WPARAM )&ttb, 0); -} - -void LoadAllSButs() -{ - //must be locked - int cnt = db_get_b(0, TTB_OPTDIR, "ServiceCnt", 0); - if (cnt > 0) { - for (int i = 1; i<=cnt; i++) - InsertSBut(i); - } -} - -//----- Launch buttons ----- -INT_PTR LaunchService(WPARAM wParam, LPARAM lParam) -{ - PROCESS_INFORMATION pi; - STARTUPINFO si = {0}; - si.cb = sizeof(si); - - if ( CreateProcess(NULL, Buttons[lParam]->ptszProgram, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); - } - - return 0; -} - -void InsertLBut(int i) -{ - TTBButton ttb = { 0 }; - ttb.cbSize = sizeof(ttb); - ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); - ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISLBUTTON | TTBBF_INTERNAL; - ttb.name = LPGEN("Default"); - ttb.program = _T("Execute Path"); - ttb.wParamDown = i; - TTBAddButton(( WPARAM )&ttb, 0); -} - -void LoadAllLButs() -{ - //must be locked - int cnt = db_get_b(0, TTB_OPTDIR, "LaunchCnt", 0); - for (int i = 0; i < cnt; i++) - InsertLBut(i); -} - -//----- Separators ----- - -void InsertSeparator(int i) -{ - TTBButton ttb = { 0 }; - ttb.cbSize = sizeof(ttb); - ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISSEPARATOR | TTBBF_INTERNAL; - ttb.wParamDown = i; - TTBAddButton((WPARAM)&ttb, 0); -} - -void LoadAllSeparators() -{ - //must be locked - int cnt = db_get_b(0, TTB_OPTDIR, "SepCnt", 0); - for (int i = 0; i < cnt; i++) - InsertSeparator(i); -} - -int SaveAllButtonsOptions() -{ - int SeparatorCnt = 0; - int LaunchCnt = 0; - { - mir_cslock lck(csButtonsHook); - for (int i = 0; i < Buttons.getCount(); i++) - Buttons[i]->SaveSettings(&SeparatorCnt, &LaunchCnt); - } - db_set_b(0, TTB_OPTDIR, "SepCnt", SeparatorCnt); - db_set_b(0, TTB_OPTDIR, "LaunchCnt", LaunchCnt); - return 0; -} - -static bool nameexists(const char *name) -{ - if (name == NULL) - return false; - - for (int i = 0; i < Buttons.getCount(); i++) - if ( !lstrcmpA(Buttons[i]->pszName, name)) - return true; - - return false; -} - -static void Icon2button(TTBButton* but, HANDLE& hIcoLib, HICON& hIcon, bool bIsUp) -{ - HANDLE hSrc = bIsUp ? but->hIconHandleUp : but->hIconHandleDn; - if (hSrc == NULL) { - hIcoLib = NULL, hIcon = NULL; - return; - } - - hIcoLib = (HANDLE)CallService(MS_SKIN2_ISMANAGEDICON, WPARAM(hSrc), 0); - if (!hIcoLib) { - char buf[256]; - mir_snprintf(buf, SIZEOF(buf), "toptoolbar_%s%s", but->name, (bIsUp) ? (but->hIconDn ? "%s_up" : "%s") : "%s_dn"); - SKINICONDESC sid = {0}; - sid.cbSize = sizeof(sid); - sid.pszSection = "Toolbar"; - sid.pszName = buf; - sid.pszDefaultFile = NULL; - sid.pszDescription = but->name; - sid.hDefaultIcon = (bIsUp) ? but->hIconUp : but->hIconDn; - hIcoLib = Skin_AddIcon(&sid); - } - - hIcon = Skin_GetIconByHandle(hIcoLib); -} - -TopButtonInt* CreateButton(TTBButton* but) -{ - TopButtonInt* b = new TopButtonInt; - b->id = nextButtonId++; - - b->dwFlags = but->dwFlags; - - b->wParamUp = but->wParamUp; - b->lParamUp = but->lParamUp; - b->wParamDown = but->wParamDown; - b->lParamDown = but->lParamDown; - - if ( !(b->dwFlags & TTBBF_ISSEPARATOR)) { - b->bPushed = (but->dwFlags & TTBBF_PUSHED) ? TRUE : FALSE; - - if (but->dwFlags & TTBBF_ISLBUTTON) { - b->ptszProgram = mir_tstrdup(but->program); - b->pszService = mir_strdup(TTB_LAUNCHSERVICE); - } - else { - b->ptszProgram = NULL; - b->pszService = mir_strdup(but->pszService); - } - - b->pszName = mir_strdup(but->name); - - Icon2button(but, b->hIconHandleUp, b->hIconUp, true); - Icon2button(but, b->hIconHandleDn, b->hIconDn, false); - - if (but->cbSize > OLD_TBBUTTON_SIZE) { - b->ptszTooltipUp = mir_a2t(but->pszTooltipUp); - b->ptszTooltipDn = mir_a2t(but->pszTooltipDn); - } - } - return b; -} - -int ArrangeButtons() -{ - mir_cslock lck(csButtonsHook); - - RECT rcClient; - GetClientRect(g_ctrl->hWnd, &rcClient); - int nBarSize = rcClient.right - rcClient.left; - if (nBarSize == 0) - return 0; - - int nLineCount = 0; - int i, ypos = 1, xpos = g_ctrl->nButtonSpace, nextX = 0, y = 0; - int newheight = g_ctrl->nButtonHeight+1, nButtonCount=0; - - for (i=0; i < Buttons.getCount(); i++) - if (Buttons[i]->hwnd) - nButtonCount++; - - if (nButtonCount == 0) - return 0; - - HDWP hdwp = BeginDeferWindowPos(nButtonCount); - - bool bWasButttonBefore; - int nUsedWidth, iFirstButtonId = 0, iLastButtonId = 0; - - do - { - nLineCount++; - bWasButttonBefore = false; - nUsedWidth = 0; - - for (i=iFirstButtonId; i < Buttons.getCount(); i++) { - TopButtonInt *b = Buttons[i]; - if (b->hwnd == NULL) - continue; - - int width = 0; - if ( b->isVisible()) - width = (b->isSep()) ? SEPWIDTH+2 : g_ctrl->nButtonWidth + ((bWasButttonBefore) ? g_ctrl->nButtonSpace : 0); - if (nUsedWidth + width > nBarSize) - break; - - nUsedWidth += width; - iLastButtonId = i+1; - bWasButttonBefore = !b->isSep(); - } - - int nFreeSpace = nBarSize - nUsedWidth; - - for (i=iFirstButtonId; i < iLastButtonId; i++) { - TopButtonInt *b = Buttons[i]; - if (b->hwnd == NULL) - continue; - - bool bOldVisible = IsWindowVisible(b->hwnd) != 0; - if (bOldVisible != b->isVisible()) - g_ctrl->bOrderChanged = TRUE; - - if ( b->isVisible()) { - hdwp = DeferWindowPos(hdwp, b->hwnd, NULL, nextX, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW); - if ( b->isSep()) - nextX += SEPWIDTH+2; - else - nextX += g_ctrl->nButtonWidth + g_ctrl->nButtonSpace; - } - else hdwp = DeferWindowPos(hdwp, Buttons[i]->hwnd, NULL, nextX, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_HIDEWINDOW); - } - - if (iFirstButtonId == iLastButtonId) - break; - - iFirstButtonId = iLastButtonId; - y += g_ctrl->nButtonHeight + g_ctrl->nButtonSpace; - nextX = 0; - if (g_ctrl->bSingleLine) - break; - } - while (iFirstButtonId < Buttons.getCount() && y >= 0 && (g_ctrl->bAutoSize || (y + g_ctrl->nButtonHeight <= rcClient.bottom - rcClient.top))); - - if (hdwp) - EndDeferWindowPos(hdwp); - - return (g_ctrl->nButtonHeight + g_ctrl->nButtonSpace)*nLineCount - g_ctrl->nButtonSpace; -} - -///////////////////////////////////////////////////////////////////////////////////////// -// Toolbar services - -// wparam = (TTBButton*)lpTTBButton -// lparam = hLangpack -INT_PTR TTBAddButton(WPARAM wParam, LPARAM lParam) -{ - if (wParam == 0) - return -1; - - TTBButton *but = (TTBButton*)wParam; - if (but->cbSize != sizeof(TTBButton) && but->cbSize != OLD_TBBUTTON_SIZE) - return -1; - - if ( !(but->dwFlags && TTBBF_ISLBUTTON) && nameexists(but->name)) - return -1; - - TopButtonInt* b = CreateButton(but); - b->hLangpack = (int)lParam; - b->LoadSettings(); - b->CreateWnd(); - if (b->hwnd == NULL) { - delete b; - return -1; - } - { - mir_cslock lck(csButtonsHook); - Buttons.insert(b); - } - - g_ctrl->bOrderChanged = TRUE; - ArrangeButtons(); - AddToOptions(b); - return b->id; -} - -// wparam = (HANDLE)hTTButton -// lparam = 0 -INT_PTR TTBRemoveButton(WPARAM wParam, LPARAM lParam) -{ - mir_cslock lck(csButtonsHook); - - int idx; - TopButtonInt* b = idtopos(wParam, &idx); - if (b == NULL) - return -1; - - RemoveFromOptions(b->id); - - Buttons.remove(idx); - delete b; - - g_ctrl->bOrderChanged = TRUE; - ArrangeButtons(); - return 0; -} - -// wparam = hTTBButton -// lparam = state -INT_PTR TTBSetState(WPARAM wParam, LPARAM lParam) -{ - mir_cslock lck(csButtonsHook); - - TopButtonInt* b = idtopos(wParam); - if (b == NULL) - return -1; - - b->bPushed = (lParam & TTBST_PUSHED)?TRUE:FALSE; - b->bPushed = (lParam & TTBST_RELEASED)?FALSE:TRUE; - b->SetBitmap(); - return 0; -} - -// wparam = hTTBButton -// lparam = 0 -//return = state -INT_PTR TTBGetState(WPARAM wParam, LPARAM lParam) -{ - mir_cslock lck(csButtonsHook); - TopButtonInt* b = idtopos(wParam); - if (b == NULL) - return -1; - - int retval = (b->bPushed == TRUE) ? TTBST_PUSHED : TTBST_RELEASED; - return retval; -} - -INT_PTR TTBGetOptions(WPARAM wParam, LPARAM lParam) -{ - INT_PTR retval; - - mir_cslock lck(csButtonsHook); - TopButtonInt* b = idtopos(wParam); - if (b == NULL) - return -1; - - switch(LOWORD(wParam)) { - case TTBO_FLAGS: - retval = b->dwFlags & (~TTBBF_PUSHED); - if (b->bPushed) - retval |= TTBBF_PUSHED; - break; - - case TTBO_TIPNAME: - retval = (INT_PTR)b->ptszTooltip; - break; - - case TTBO_ALLDATA: - if (lParam) { - lpTTBButton lpTTB = (lpTTBButton)lParam; - if (lpTTB->cbSize != sizeof(TTBButton)) - break; - - lpTTB->dwFlags = b->dwFlags & (~TTBBF_PUSHED); - if (b->bPushed) - lpTTB->dwFlags |= TTBBF_PUSHED; - - lpTTB->hIconDn = b->hIconDn; - lpTTB->hIconUp = b->hIconUp; - - lpTTB->lParamUp = b->lParamUp; - lpTTB->wParamUp = b->wParamUp; - lpTTB->lParamDown = b->lParamDown; - lpTTB->wParamDown = b->wParamDown; - - if (b->dwFlags & TTBBF_ISLBUTTON) - replaceStrT(lpTTB->program, b->ptszProgram); - else - replaceStr(lpTTB->pszService, b->pszService); - - retval = ( INT_PTR )lpTTB; - } - break; - - default: - retval = -1; - break; - } - - return retval; -} - -INT_PTR TTBSetOptions(WPARAM wParam, LPARAM lParam) -{ - int retval; - - mir_cslock lck(csButtonsHook); - TopButtonInt* b = idtopos(HIWORD(wParam)); - if (b == NULL) - return -1; - - switch(LOWORD(wParam)) { - case TTBO_FLAGS: - if (b->dwFlags == lParam) - break; - - retval = b->CheckFlags(lParam); - - if (retval & TTBBF_PUSHED) - b->SetBitmap(); - if (retval & TTBBF_VISIBLE) { - ArrangeButtons(); - b->SaveSettings(0,0); - } - - retval = 1; - break; - - case TTBO_TIPNAME: - if (lParam == 0) - break; - - replaceStrT(b->ptszTooltip, TranslateTS( _A2T((LPCSTR)lParam))); - SendMessage(b->hwnd,BUTTONADDTOOLTIP,(WPARAM)b->ptszTooltip,BATF_UNICODE); - retval = 1; - break; - - case TTBO_ALLDATA: - if (lParam) { - lpTTBButton lpTTB = (lpTTBButton)lParam; - if (lpTTB->cbSize != sizeof(TTBButton)) - break; - - retval = b->CheckFlags(lpTTB->dwFlags); - - int changed = 0; - if (b->hIconUp != lpTTB->hIconUp) { - b->hIconUp = lpTTB->hIconUp; - changed = 1; - } - if (b->hIconDn != lpTTB->hIconDn) { - b->hIconDn = lpTTB->hIconDn; - changed = 1; - } - if (changed) - b->SetBitmap(); - - if (retval & TTBBF_VISIBLE) { - ArrangeButtons(); - b->SaveSettings(0,0); - } - - if (b->dwFlags & TTBBF_ISLBUTTON) - replaceStrT(b->ptszProgram, lpTTB->program); - else - replaceStr(b->pszService, lpTTB->pszService); - - b->lParamUp = lpTTB->lParamUp; - b->wParamUp = lpTTB->wParamUp; - b->lParamDown = lpTTB->lParamDown; - b->wParamDown = lpTTB->wParamDown; - - retval = 1; - } - break; - - default: - retval = -1; - break; - } - - return retval; -} - -///////////////////////////////////////////////////////////////////////////////////////// -// Reload all icons from their icolib handles - -int OnIconChange(WPARAM wParam, LPARAM lParam) -{ - mir_cslock lck(csButtonsHook); - for (int i = 0; i < Buttons.getCount(); i++) { - TopButtonInt* b = Buttons[i]; - if ( !b->hIconHandleUp && !b->hIconHandleDn) - continue; - - if (b->hIconHandleUp) { - Skin_ReleaseIcon(b->hIconUp); - b->hIconUp = Skin_GetIconByHandle(b->hIconHandleUp); - } - if (b->hIconHandleDn) { - Skin_ReleaseIcon(b->hIconDn); - b->hIconDn = Skin_GetIconByHandle(b->hIconHandleDn); - } - DestroyWindow(b->hwnd); - b->CreateWnd(); - } - - if (g_ctrl->hWnd) { - g_ctrl->bOrderChanged = true; - PostMessage(g_ctrl->hWnd, TTB_UPDATEFRAMEVISIBILITY, TRUE, 0); - } - - return 0; -} - -static int OnBGChange(WPARAM wParam, LPARAM lParam) -{ - LoadBackgroundOptions(); - return 0; -} - -static INT_PTR TTBSetCustomProc(WPARAM wParam, LPARAM lParam) -{ - g_CustomProc = (pfnCustomProc)wParam; - g_CustomProcParam = lParam; - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// -// Adds buttons of plugins being loaded. lParam = HINSTANCE - -int OnPluginLoad(WPARAM wParam, LPARAM lParam) -{ - CallPluginEventHook((HINSTANCE)lParam, hTTBModuleLoaded, 0, 0); - if (g_ctrl->hWnd && g_ctrl->bOrderChanged) - PostMessage(g_ctrl->hWnd, TTB_UPDATEFRAMEVISIBILITY, TRUE, 0); - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// -// Removes buttons of plugins being unloaded. lParam = HINSTANCE - -int OnPluginUnload(WPARAM wParam, LPARAM lParam) -{ - int hLangpack = CallService(MS_LANGPACK_LOOKUPHANDLE, 0, lParam); - if (hLangpack) { - bool bNeedUpdate = false; - mir_cslock lck(csButtonsHook); - - for (int i=Buttons.getCount()-1; i >= 0; i--) - if (Buttons[i]->hLangpack == hLangpack) { - TTBRemoveButton(Buttons[i]->id, 0); - bNeedUpdate = true; - } - - if (bNeedUpdate) { - ArrangeButtons(); - if (g_ctrl->hWnd) - PostMessage(g_ctrl->hWnd, TTB_UPDATEFRAMEVISIBILITY, TRUE, 0); - } - } - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// - -int OnModulesLoad(WPARAM wParam, LPARAM lParam) -{ - LoadAllSeparators(); - LoadAllLButs(); - - ArrangeButtons(); - - HANDLE hEvent = CreateEvent(NULL, TRUE, TRUE, NULL);//anonymous event - if (hEvent != 0) - CallService(MS_SYSTEM_WAITONHANDLE, (WPARAM)hEvent, (LPARAM)"TTB_ONSTARTUPFIRE"); - - if ( HookEvent(ME_BACKGROUNDCONFIG_CHANGED, OnBGChange)) { - char buf[256]; - sprintf(buf, "TopToolBar Background/%s", TTB_OPTDIR); - CallService(MS_BACKGROUNDCONFIG_REGISTER, (WPARAM)buf, 0); - } - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// - -static LRESULT CALLBACK TTBButtonWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - LRESULT lResult = buttonWndProc(hwnd, msg, wParam, lParam); - - if (msg == WM_NCCREATE) { - TopButtonInt* p = (TopButtonInt*)((CREATESTRUCT*)lParam)->lpCreateParams; - if (g_CustomProc) - g_CustomProc((HANDLE)p->id, hwnd, g_CustomProcParam); - } - - return lResult; -} - -int LoadToolbarModule() -{ - if ( !ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) { - if ( !db_get_b(NULL, TTB_OPTDIR, "WarningDone", 0)) - MessageBox(0, TranslateT("Frames Services not found - plugin disabled.You need MultiWindow plugin."), _T("TopToolBar"), 0); - db_set_b(NULL, TTB_OPTDIR, "WarningDone", 1); - return 1; - } - - g_ctrl = (TTBCtrl*)mir_calloc( sizeof(TTBCtrl)); - g_ctrl->nButtonHeight = db_get_dw(0, TTB_OPTDIR, "BUTTHEIGHT", DEFBUTTHEIGHT); - g_ctrl->nButtonWidth = db_get_dw(0, TTB_OPTDIR, "BUTTWIDTH", DEFBUTTWIDTH); - g_ctrl->nButtonSpace = db_get_dw(0, TTB_OPTDIR, "BUTTGAP", DEFBUTTGAP); - g_ctrl->nLastHeight = db_get_dw(0, TTB_OPTDIR, "LastHeight", DEFBUTTHEIGHT); - - g_ctrl->bFlatButtons = db_get_b(0, TTB_OPTDIR, "UseFlatButton", true); - g_ctrl->bSingleLine = db_get_b(0, TTB_OPTDIR, "SingleLine", false); - g_ctrl->bAutoSize = db_get_b(0, TTB_OPTDIR, "AutoSize", true); - - db_unset(NULL, TTB_OPTDIR, "WarningDone"); - - InitializeCriticalSection(&csButtonsHook); - hBmpSeparator = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_SEP)); - - HookEvent(ME_SYSTEM_MODULELOAD, OnPluginLoad); - HookEvent(ME_SYSTEM_MODULEUNLOAD, OnPluginUnload); - HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoad); - HookEvent(ME_SKIN2_ICONSCHANGED, OnIconChange); - HookEvent(ME_OPT_INITIALISE, TTBOptInit); - - hTTBModuleLoaded = CreateHookableEvent(ME_TTB_MODULELOADED); - hTTBInitButtons = CreateHookableEvent(ME_TTB_INITBUTTONS); - SetHookDefaultForHookableEvent(hTTBInitButtons, InitInternalButtons); - - CreateServiceFunction("TopToolBar/AddButton", TTBAddButton); - CreateServiceFunction(MS_TTB_REMOVEBUTTON, TTBRemoveButton); - - CreateServiceFunction(MS_TTB_SETBUTTONSTATE, TTBSetState); - CreateServiceFunction(MS_TTB_GETBUTTONSTATE, TTBGetState); - - CreateServiceFunction(MS_TTB_GETBUTTONOPTIONS, TTBGetOptions); - CreateServiceFunction(MS_TTB_SETBUTTONOPTIONS, TTBSetOptions); - - CreateServiceFunction(TTB_LAUNCHSERVICE, LaunchService); - - CreateServiceFunction("TopToolBar/SetCustomProc", TTBSetCustomProc); - CreateServiceFunction("TTB_ONSTARTUPFIRE", OnEventFire); - - buttonWndProc = (WNDPROC)CallService("Button/GetWindowProc",0,0); - WNDCLASSEX wc = {0}; - wc.cbSize = sizeof(wc); - wc.lpszClassName = TTB_BUTTON_CLASS; - wc.lpfnWndProc = TTBButtonWndProc; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.cbWndExtra = sizeof(void*); - wc.hbrBackground = 0; - wc.style = CS_GLOBALCLASS; - RegisterClassEx(&wc); - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// - -int UnloadToolbarModule() -{ - DestroyHookableEvent(hTTBModuleLoaded); - DestroyHookableEvent(hTTBInitButtons); - - DeleteObject(hBmpSeparator); - DeleteCriticalSection(&csButtonsHook); - - for (int i=0; i < Buttons.getCount(); i++) - delete Buttons[i]; - Buttons.destroy(); - - mir_free(g_ctrl); - return 0; -} diff --git a/plugins/TopToolBar/toolbarwnd.cpp b/plugins/TopToolBar/toolbarwnd.cpp deleted file mode 100644 index e3f19f693b..0000000000 --- a/plugins/TopToolBar/toolbarwnd.cpp +++ /dev/null @@ -1,330 +0,0 @@ - -#include "common.h" - -COLORREF bkColour; -HBITMAP hBmpBackground, hBmpSeparator; -int backgroundBmpUse; - -static TCHAR pluginname[] = _T("TopToolBar"); - -///////////////////////////////////////////////////////////////////////////////////////// -// Toolbar window procedure - -static void PaintToolbar(HWND hwnd) -{ - InvalidateRect(hwnd, 0, FALSE); - - PAINTSTRUCT paintst; - HDC hdc = BeginPaint(hwnd, &paintst); - RECT *rcPaint = &paintst.rcPaint; - - RECT clRect; - GetClientRect(hwnd, &clRect); - if (rcPaint == NULL) rcPaint = &clRect; - - int yScroll = 0; - int y = -yScroll; - - HDC hdcMem = CreateCompatibleDC(hdc); - HBITMAP hBmpOsb = CreateBitmap(clRect.right, clRect.bottom, 1, GetDeviceCaps(hdc, BITSPIXEL), NULL); - HBITMAP hOldBmp = (HBITMAP)SelectObject(hdcMem, hBmpOsb); - SetBkMode(hdcMem, TRANSPARENT); - - HBRUSH hBrush = CreateSolidBrush(bkColour); - HBRUSH hoBrush = (HBRUSH)SelectObject(hdcMem, hBrush); - FillRect(hdcMem, rcPaint, hBrush); - SelectObject(hdcMem, hoBrush); - DeleteObject(hBrush); - if (hBmpBackground) { - BITMAP bmp; - GetObject(hBmpBackground, sizeof(bmp), &bmp); - - HDC hdcBmp = CreateCompatibleDC(hdcMem); - SelectObject(hdcBmp, hBmpBackground); - int y = backgroundBmpUse & CLBF_SCROLL ? -yScroll : 0; - int maxx = backgroundBmpUse & CLBF_TILEH ? clRect.right : 1; - int maxy = backgroundBmpUse & CLBF_TILEV ? maxy = rcPaint->bottom : y+1; - - int destw, desth; - switch(backgroundBmpUse & CLBM_TYPE) { - case CLB_STRETCH: - if (backgroundBmpUse&CLBF_PROPORTIONAL) { - if (clRect.right * bmp.bmHeight < clRect.bottom * bmp.bmWidth) { - desth = clRect.bottom; - destw = desth * bmp.bmWidth/bmp.bmHeight; - } - else { - destw = clRect.right; - desth = destw * bmp.bmHeight/bmp.bmWidth; - } - } - else { - destw = clRect.right; - desth = clRect.bottom; - } - break; - case CLB_STRETCHH: - if (backgroundBmpUse & CLBF_PROPORTIONAL) { - destw = clRect.right; - desth = destw * bmp.bmHeight/bmp.bmWidth; - if (backgroundBmpUse & CLBF_TILEVTOROWHEIGHT) - desth = g_ctrl->nButtonHeight+2; - } - else { - destw = clRect.right; - desth = bmp.bmHeight; - } - break; - case CLB_STRETCHV: - if (backgroundBmpUse & CLBF_PROPORTIONAL) { - desth = clRect.bottom; - destw = desth*bmp.bmWidth/bmp.bmHeight; - } - else { - destw = bmp.bmWidth; - desth = clRect.bottom; - } - break; - default: //clb_topleft - destw = bmp.bmWidth; - desth = bmp.bmHeight; - if (backgroundBmpUse & CLBF_TILEVTOROWHEIGHT) - desth = g_ctrl->nButtonHeight+2; - break; - } - - for (; y < maxy; y += desth) { - if (y < rcPaint->top - desth) - continue; - - for (int x = 0; x < maxx; x += destw) - StretchBlt(hdcMem, x, y, destw, desth, hdcBmp, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY); - } - DeleteDC(hdcBmp); - } - BitBlt(hdc, rcPaint->left, rcPaint->top, rcPaint->right-rcPaint->left, rcPaint->bottom-rcPaint->top, hdcMem, rcPaint->left, rcPaint->top, SRCCOPY); - SelectObject(hdcMem, hOldBmp); - DeleteDC(hdcMem); - DeleteObject(hBmpOsb); - - paintst.fErase = FALSE; - EndPaint(hwnd, &paintst); -} - -///////////////////////////////////////////////////////////////////////////////////////// - -LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - static bool supressRepos = false; - - if (g_ctrl->fnWindowProc != NULL) - if ( g_ctrl->fnWindowProc(hwnd, msg, wParam, lParam)) - return g_ctrl->lResult; - - switch(msg) { - case WM_CREATE: - g_ctrl->hWnd = hwnd; - PostMessage(hwnd, TTB_UPDATEFRAMEVISIBILITY, 1, 0); - return FALSE; - - case WM_MOVE: - return 0; - - case WM_WINDOWPOSCHANGING: - case WM_SIZE: - if (g_ctrl->nLastHeight != HIWORD(lParam)) { - db_set_dw(0, TTB_OPTDIR, "LastHeight", g_ctrl->nLastHeight = HIWORD(lParam)); - ArrangeButtons(); - } - if (supressRepos) { - supressRepos = false; - break; - } - // fall through - - case TTB_REPOSBUTTONS: - if (g_ctrl->hWnd == hwnd) { - int iHeight = ArrangeButtons(); - if ( g_ctrl->bAutoSize) { - RECT rcClient; - GetClientRect(g_ctrl->hWnd, &rcClient); - if (rcClient.bottom - rcClient.top != iHeight && iHeight) { - supressRepos = true; - PostMessage(hwnd, TTB_UPDATEFRAMEVISIBILITY, -1, 0); - } - } - return 0; - } - break; - - case WM_NCPAINT: - case WM_PAINT: - PaintToolbar(hwnd); - return 0; - - case WM_LBUTTONDOWN: - if (db_get_b(NULL, "CLUI", "ClientAreaDrag", 0)) { - POINT pt; - GetCursorPos(&pt); - return SendMessage(GetParent(hwnd), WM_SYSCOMMAND, SC_MOVE|HTCAPTION, MAKELPARAM(pt.x, pt.y)); - } - return 0; - - case WM_COMMAND: - switch (HIWORD(wParam)) { - case BN_CLICKED: - case BN_DOUBLECLICKED: - { - int id = GetWindowLongPtr((HWND)lParam, GWLP_USERDATA); - if (id != 0) { - mir_cslock lck(csButtonsHook); - TopButtonInt* b = idtopos(id); - if (b == NULL || b->isSep()) - return 0; - - if (b->dwFlags & TTBBF_ASPUSHBUTTON) - b->bPushed = !b->bPushed; - - if (b->bPushed) { //Dn -> Up - if (!(b->dwFlags & TTBBF_ISLBUTTON)) // must be always true - if (b->pszService != NULL) - CallService(b->pszService, b->wParamUp, b->lParamUp); - } - else { //Up -> Dn - if (b->pszService != NULL) - CallService(b->pszService, b->wParamDown, b->lParamDown); - } - - b->SetBitmap(); - } - } - break; - } - break; - - case TTB_UPDATEFRAMEVISIBILITY: - { - BOOL vis=(BOOL)wParam; - BOOL curvis = IsWindowVisible(hwnd); - bool bResize = false; - int Height = ArrangeButtons(); - - if (g_ctrl->bAutoSize) { - INT_PTR frameopt = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, g_ctrl->hFrame), 0); - if (Height != frameopt) { - CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, g_ctrl->hFrame), Height); - bResize = TRUE; - } - } - - if (g_ctrl->bOrderChanged) - bResize = TRUE, g_ctrl->bOrderChanged = FALSE; - - if ((curvis != vis || bResize) && vis != -1) { - INT_PTR frameopt = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, g_ctrl->hFrame), 0); - frameopt &= ~F_VISIBLE; - frameopt |= vis ? F_VISIBLE : 0; - CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, g_ctrl->hFrame), frameopt); - } - } - break; - - case TTB_SETCUSTOM: - { - TTBCtrlCustomize *pCustom = (TTBCtrlCustomize*)lParam; - if (pCustom == NULL || g_ctrl->fnWindowProc) - break; - - g_ctrl = (TTBCtrl*)mir_realloc(g_ctrl, pCustom->cbLen); - if (pCustom->cbLen > sizeof(TTBCtrl)) - memset(g_ctrl+1, 0, pCustom->cbLen - sizeof(TTBCtrl)); - - g_ctrl->fnWindowProc = pCustom->fnWindowProc; - SetWindowLongPtr(hwnd, 0, (LONG_PTR)g_ctrl); - } - break; - - default: - return DefWindowProc(hwnd, msg, wParam, lParam); - } - return(TRUE); -} - -///////////////////////////////////////////////////////////////////////////////////////// - -INT_PTR OnEventFire(WPARAM wParam, LPARAM lParam) -{ - CallService(MS_SYSTEM_REMOVEWAIT, wParam, 0); - CloseHandle((HANDLE)wParam); - - HWND parent = (HWND)CallService(MS_CLUI_GETHWND, 0, 0); - if (parent == NULL) // no clist, no buttons - return -1; - - WNDCLASS wndclass = { 0 }; - wndclass.lpfnWndProc = TopToolBarProc; - wndclass.cbWndExtra = sizeof(void*); - wndclass.hInstance = hInst; - wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); - wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); - wndclass.lpszClassName = pluginname; - RegisterClass(&wndclass); - - g_ctrl->pButtonList = (SortedList*)&Buttons; - g_ctrl->hWnd = CreateWindow(pluginname, _T("Toolbar"), - WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, - 0, 0, 0, g_ctrl->nLastHeight, parent, NULL, hInst, NULL); - SetWindowLongPtr(g_ctrl->hWnd, 0, (LPARAM)g_ctrl); - - LoadBackgroundOptions(); - - // if we're working in skinned clist, receive the standard buttons & customizations - if (g_CustomProc && g_ctrl->hWnd) - g_CustomProc(TTB_WINDOW_HANDLE, g_ctrl->hWnd, g_CustomProcParam); - - // if there's no customized frames, create our own - if (g_ctrl->hFrame == NULL) { - CLISTFrame Frame = { 0 }; - Frame.cbSize = sizeof(Frame); - Frame.tname = _T("Toolbar"); - Frame.hWnd = g_ctrl->hWnd; - Frame.align = alTop; - Frame.Flags = F_VISIBLE | F_NOBORDER | F_LOCKED | F_TCHAR; - Frame.height = g_ctrl->nLastHeight; - g_ctrl->hFrame = (HANDLE)CallService(MS_CLIST_FRAMES_ADDFRAME, (WPARAM)&Frame, 0); - } - - // receive all buttons - NotifyEventHooks(hTTBInitButtons, 0, 0); - NotifyEventHooks(hTTBModuleLoaded, 0, 0); - - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// - -int LoadBackgroundOptions() -{ - //load options - bkColour = DBGetContactSettingDword(NULL, TTB_OPTDIR, "BkColour", TTBDEFAULT_BKCOLOUR); - if (hBmpBackground) { - DeleteObject(hBmpBackground); - hBmpBackground = NULL; - } - - if (db_get_b(NULL, TTB_OPTDIR, "UseBitmap", TTBDEFAULT_USEBITMAP)) { - DBVARIANT dbv; - if (!DBGetContactSetting(NULL, TTB_OPTDIR, "BkBitmap", &dbv)) { - hBmpBackground = (HBITMAP)CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM)dbv.pszVal); - DBFreeVariant(&dbv); - } - } - backgroundBmpUse = DBGetContactSettingWord(NULL, TTB_OPTDIR, "BkBmpUse", TTBDEFAULT_BKBMPUSE); - - RECT rc; - GetClientRect(g_ctrl->hWnd, &rc); - InvalidateRect(g_ctrl->hWnd, &rc, TRUE); - UpdateWindow(g_ctrl->hWnd); - - return 0; -} diff --git a/plugins/TopToolBar/topbutton.cpp b/plugins/TopToolBar/topbutton.cpp deleted file mode 100644 index 8e2f8a1cfd..0000000000 --- a/plugins/TopToolBar/topbutton.cpp +++ /dev/null @@ -1,178 +0,0 @@ - -#include "common.h" - -#define BitChanged(c) (dwFlags ^ Flags) & c - -static int maxid = 10000; - -TopButtonInt::~TopButtonInt() -{ - if (hwnd) - DestroyWindow(hwnd); - - if (dwFlags & TTBBF_ISLBUTTON) { - mir_free(ptszProgram); - } - else if (pszService != NULL) - mir_free(pszService); - - mir_free(pszName); - mir_free(ptszTooltip); - mir_free(ptszTooltipDn); - mir_free(ptszTooltipUp); -} - -DWORD TopButtonInt::CheckFlags(DWORD Flags) -{ - int res = 0; - if ( BitChanged(TTBBF_DISABLED)) { - dwFlags ^= TTBBF_DISABLED; - EnableWindow(hwnd,(dwFlags & TTBBF_DISABLED)?FALSE:TRUE); - } - if ( BitChanged(TTBBF_ASPUSHBUTTON)) { - dwFlags ^= TTBBF_ASPUSHBUTTON; - SendMessage(hwnd, BUTTONSETASPUSHBTN, (dwFlags & TTBBF_ASPUSHBUTTON)?1:0, 0); - } - if ( BitChanged(TTBBF_SHOWTOOLTIP)) { - dwFlags ^= TTBBF_SHOWTOOLTIP; - SendMessage(hwnd,BUTTONADDTOOLTIP, - (WPARAM)((dwFlags & TTBBF_SHOWTOOLTIP) ? ptszTooltip : _T("")), BATF_TCHAR); - } - // next settings changing visual side, requires additional actions - if ( BitChanged(TTBBF_VISIBLE)) { - dwFlags ^= TTBBF_VISIBLE; - res |= TTBBF_VISIBLE; - } - if ( BitChanged(TTBBF_PUSHED)) { - dwFlags ^= TTBBF_PUSHED; - res |= TTBBF_PUSHED; - bPushed = (dwFlags & TTBBF_PUSHED) ? TRUE : FALSE; - } - return res; -} - -void TopButtonInt::CreateWnd() -{ - if ( !(dwFlags & TTBBF_ISSEPARATOR)) { - hwnd = CreateWindow(TTB_BUTTON_CLASS, _T(""), BS_PUSHBUTTON|WS_CHILD|WS_TABSTOP|SS_NOTIFY, 0, 0, g_ctrl->nButtonWidth, g_ctrl->nButtonHeight, g_ctrl->hWnd, NULL, hInst, this); - - if (dwFlags & TTBBF_ASPUSHBUTTON) - SendMessage(hwnd, BUTTONSETASPUSHBTN, 1, 0); - - if (db_get_b(0, TTB_OPTDIR, "UseFlatButton", 1)) - SendMessage(hwnd, BUTTONSETASFLATBTN, TRUE, 0); - - EnableWindow(hwnd,(dwFlags & TTBBF_DISABLED)?FALSE:TRUE); - } - // maybe SEPWIDTH, not g_ctrl->nButtonWidth? - else - hwnd = CreateWindow( _T("STATIC"), _T(""), WS_CHILD|SS_NOTIFY, 0, 0, g_ctrl->nButtonWidth, g_ctrl->nButtonHeight, g_ctrl->hWnd, NULL, hInst, 0); - - SetWindowLongPtr(hwnd, GWLP_USERDATA, id); - SetBitmap(); -} - -void TopButtonInt::LoadSettings() -{ - char buf[255]; - - BYTE oldv = isVisible(); - dwFlags = dwFlags & (~TTBBF_VISIBLE); - - if (dwFlags & TTBBF_ISSEPARATOR) { - char buf1[10]; - _itoa(wParamDown, buf1, 10); - char buf2[20]; - AS(buf2, "Sep", buf1); - - arrangedpos = db_get_b(0, TTB_OPTDIR, AS(buf, buf2, "_Position"), Buttons.getCount()); - if ( db_get_b(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"), oldv) > 0 ) - dwFlags |= TTBBF_VISIBLE; - } - else if ((dwFlags & TTBBF_ISLBUTTON ) && (dwFlags & TTBBF_INTERNAL)) { - char buf1[10]; - _itoa(wParamDown, buf1, 10); - char buf2[20]; - AS(buf2, "Launch", buf1); - - mir_free(pszName); - pszName = DBGetString(0, TTB_OPTDIR, AS(buf, buf2, "_name")); - - mir_free(ptszProgram); - ptszProgram = DBGetStringT(0, TTB_OPTDIR, AS(buf, buf2, "_lpath")); - - arrangedpos = db_get_b(0, TTB_OPTDIR, AS(buf, buf2, "_Position"), Buttons.getCount()); - if ( db_get_b(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"), oldv) > 0 ) - dwFlags |= TTBBF_VISIBLE; - } - else { - arrangedpos = db_get_b(0, TTB_OPTDIR, AS(buf, pszName, "_Position"), Buttons.getCount()); - if ( db_get_b(0, TTB_OPTDIR, AS(buf, pszName, "_Visible"), oldv) > 0 ) - dwFlags |= TTBBF_VISIBLE; - } - - if (Buttons.getIndex(this) != -1) - arrangedpos = maxid++; -} - -void TopButtonInt::SaveSettings(int *SepCnt, int *LaunchCnt) -{ - char buf[255]; - - if (SepCnt && (dwFlags & TTBBF_ISSEPARATOR) && (dwFlags & TTBBF_INTERNAL)) { - char buf1[10]; - _itoa(SepCnt[0]++, buf1, 10); - char buf2[20]; - AS(buf2, "Sep", buf1); - - db_set_b(0, TTB_OPTDIR, AS(buf, buf2, "_Position"), arrangedpos); - db_set_b(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"), isVisible()); - } - else if (LaunchCnt && (dwFlags & TTBBF_ISLBUTTON ) && (dwFlags & TTBBF_INTERNAL)) { - char buf1[10]; - _itoa(LaunchCnt[0]++, buf1, 10); - char buf2[20]; - AS(buf2, "Launch", buf1); - - DBWriteContactSettingString(0, TTB_OPTDIR, AS(buf, buf2, "_name"), pszName); - DBWriteContactSettingTString(0, TTB_OPTDIR, AS(buf, buf2, "_lpath"), ptszProgram); - db_set_b(0, TTB_OPTDIR, AS(buf, buf2, "_Position"), arrangedpos); - db_set_b(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"), isVisible()); - } - else { - db_set_b(0, TTB_OPTDIR, AS(buf, pszName, "_Position"), arrangedpos); - db_set_b(0, TTB_OPTDIR, AS(buf, pszName, "_Visible"), isVisible()); - } -} - -void TopButtonInt::SetBitmap() -{ - int curstyle = GetWindowLongPtr(hwnd, GWL_STYLE); - curstyle &= (~SS_BITMAP); - curstyle &= (~SS_ICON); - - if (dwFlags & TTBBF_ISSEPARATOR) { - SetWindowLongPtr(hwnd, GWL_STYLE, curstyle | SS_BITMAP); - SendMessage(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBmpSeparator); - SendMessage(hwnd, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBmpSeparator); - } - else { - if (GetWindowLongPtr(hwnd, GWL_STYLE) & SS_ICON) - SetWindowLongPtr(hwnd, GWL_STYLE, curstyle | SS_ICON); - - TCHAR* pTooltip; - if (bPushed) { - SendMessage(hwnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)((hIconDn) ? hIconDn : hIconUp)); - SendMessage(hwnd, BM_SETCHECK, BST_CHECKED, 0); - - pTooltip = (ptszTooltipDn) ? ptszTooltipDn : ptszTooltipUp; - } - else { - SendMessage(hwnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIconUp); - SendMessage(hwnd, BM_SETCHECK, BST_UNCHECKED, 0); - pTooltip = ptszTooltipUp; - } - if (pTooltip) - SendMessage(hwnd, BUTTONADDTOOLTIP, (WPARAM)TranslateTH(hLangpack, pTooltip), BATF_TCHAR); - } -} diff --git a/plugins/TopToolBar/toptoolbar-translation.txt b/plugins/TopToolBar/toptoolbar-translation.txt deleted file mode 100644 index fcc295b539..0000000000 --- a/plugins/TopToolBar/toptoolbar-translation.txt +++ /dev/null @@ -1,40 +0,0 @@ -; Common strings that belong to many files -;[Default] - -; ../../plugins/TopToolBar/InternalButtons.cpp -;[Disable Sounds] -;[Enable Sounds] -;[Hide Offline Users] -;[Show All Users] - -; ../../plugins/TopToolBar/main.rc -;[Add Launch] -;[Add Separator] -;[Background colour:] -;[Button Gap ] -;[Button Height] -;[Button Width ] -;[Buttons Order && Visibility] -;[Buttons order:] -;[Del Sep/Launch Button] -;[Name: ] -;[Path:] -;[Scroll with text] -;[Selection colour:] -;[Set] -;[Stretch proportionally] -;[Stretch to height] -;[Stretch to width] -;[Tile horizontally] -;[Tile vertically] -;[TopToolBar Background] -;[Use Flat Mode] -;[Use background bitmap] - -; ../../plugins/TopToolBar/toolbar.cpp -;[Frames Services not found - plugin disabled.You need MultiWindow plugin.] - -; ../../plugins/TopToolBar/ttbopt.cpp -;[Buttons] -;[TTBBackground] -;[TopToolBar] diff --git a/plugins/TopToolBar/ttb-readme.txt b/plugins/TopToolBar/ttb-readme.txt deleted file mode 100644 index 9c127d5c71..0000000000 --- a/plugins/TopToolBar/ttb-readme.txt +++ /dev/null @@ -1,160 +0,0 @@ -About ------ - -TopToolBar -Version 0.7.3.1 -by -Bethoven (bethoven@mailgate.ru) - -Note: This plugin required MultiWindow or clist_mw plugin. - -Description ------------ -TopToolBar adds buttons in top frame for fast access -to miranda/plugins functions. - -Features --------- - --Predefined buttons(Hide/Show OfflineUsers,Hide/Show Groups,On/Off Sounds) --Services for plugins to add/remove/modify new buttons. - - -WhatsNew --------- -11-04-2008 v0.7.3.1 - - ??? -17-09-2005 v0.7.3.0 - -Fixed "new separator" bug. - -Less flicks on resize. - -Removed default bitmaps. - -11-09-2005 v0.7.2.0 - -Removed default bitmaps. - -11-09-2005 v0.7.1.0 - -Fixed drawing of buttons when Themes enabled. - -New TTBButtonV2 struct for adding buttons (icon member) - -26-06-2005 v0.7.0.0 - -Supporting for miranda buton class - -Supporting for icolib(use with miranda buton class) - -Moved background options to Customize - -26-05-2005 v0.6.0.12 - -Fixed show online users button. - -16-12-2004 v0.6.0.11 - -User defined width and height of buttons - -Support loading of icons. - -23-09-2003 v0.6.0.9 - -Set all bitmaps by selecting directory. - -09-09-2003 v0.6.0.7 - -Fixed some bugs that may cause crash. - -05-05-2003 v0.6 - -Added 2 new internal buttons Minimize and Find/Add contacts. - -Autowraping mode. - -Added separators. - -Added Launch buttons. - -31-03-2003 v0.5.0.1 - -Added background configuration - -Added Button enable/ordering. - -You may change button bitmaps. - -Added two new internal buttons (MainMenu and Options). - -22-03-2003 v0.4.0.1 - -Fixed runtime button removing. - -Fixed ownerdraw borders for buttons. - -11-01-2003 v0.4 - -(dev) Changed service names to sandart look MS_ (thanks hrk). - -(dev) Added border drawing. - -Added tooltips for buttons. - - -13-12-2002 v0.3 - -Added services for add/remove additional buttons from plugins. - (see m_toptoolbar.h for description) - -Added button to quick enable/disable sounds. - -All buttons are synchronized. So if you check hide groups - from menu, button track this. - - -Bitmap Names ----------- -TopToolBar search for bitmaps in this pattern. -Selecteddir/ButtonName_DN.bmp -Selecteddir/ButtonName_UP.bmp -Where ButtonName is non localised name of button. -This chars in name '/','\','*','?','<','>',':','|','"' replaced with '_' - - -Names for standart buttons: - -"Find_Add Contacts_DN.bmp" -"Find_Add Contacts_UP.bmp" -"Groups On_Off_DN.bmp" -"Groups On_Off_UP.bmp" -"Minimize Button_DN.bmp" -"Minimize Button_UP.bmp" -"Show Main Menu_DN.bmp" -"Show Main Menu_UP.bmp" -"Show only Online Users_DN.bmp" -"Show only Online Users_UP.bmp" -"Show Options Page_DN.bmp" -"Show Options Page_UP.bmp" -"Sounds Enable_Disable_DN.bmp" -"Sounds Enable_Disable_UP.bmp" - - -Installation ------------- - -Copy the TopToolBar.dll into Miranda's plugin subdirectory. - - -Translation ------------ -[Hide Offline Users] -[Show All Users] -[Show Groups] -[Hide Groups] -[Disable Sounds] -[Enable Sounds] - - - - -Development ------------ -My radix 27d,0x1B (BET) -My base 0x1b000000 - -Quicksearch base 0x1b000000 -MultiWindow base 0x1b100000 -TopToolBar base 0x1b200000 -SystemStatus base 0x1b300000 - - -License -------- - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - diff --git a/plugins/TopToolBar/ttbopt.cpp b/plugins/TopToolBar/ttbopt.cpp deleted file mode 100644 index db7d78dcb5..0000000000 --- a/plugins/TopToolBar/ttbopt.cpp +++ /dev/null @@ -1,559 +0,0 @@ -#include "common.h" - -static HWND OptionshWnd; - -struct OrderData -{ - int dragging; - HTREEITEM hDragItem; - HIMAGELIST himlButtonIcons; -}; - -///////////////////////////////////////////////////////////////////////////////////////// - -static HTREEITEM AddLine(HWND hTree,TopButtonInt *b, HTREEITEM hItem, HIMAGELIST il) -{ - TVINSERTSTRUCT tvis = { 0 }; - tvis.hInsertAfter = hItem; - tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE; - - int index; - TCHAR* tmp; - - if (b->dwFlags & TTBBF_ISSEPARATOR) { - tvis.item.pszText = _T("------------------"); - index = -1; - } - else { - if (b->hIconHandleUp) { - HICON hIcon = Skin_GetIconByHandle(b->hIconHandleUp); - index = ImageList_AddIcon(il, hIcon); - Skin_ReleaseIcon(hIcon); - } - else index = ImageList_AddIcon(il, b->hIconUp); - - tmp = mir_a2t( b->pszName ); - tvis.item.pszText = TranslateTS(tmp); - } - tvis.item.iImage = tvis.item.iSelectedImage = index; - - tvis.item.lParam = (LPARAM)b; - HTREEITEM hti = TreeView_InsertItem(hTree, &tvis); - - if (!(b->dwFlags & TTBBF_ISSEPARATOR)) - mir_free(tmp); - - TreeView_SetCheckState(hTree, hti, b->isVisible()); - return hti; -} - -static int BuildTree(HWND hwndDlg) -{ - HWND hTree = GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE); - OrderData *dat = (OrderData*)GetWindowLongPtr(hTree, GWLP_USERDATA); - - dat->himlButtonIcons = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 2, 2); - TreeView_SetImageList(hTree, dat->himlButtonIcons, TVSIL_NORMAL); - SetWindowLongPtr(hTree, GWL_STYLE, GetWindowLongPtr(hTree,GWL_STYLE)|TVS_NOHSCROLL); - TreeView_DeleteAllItems(hTree); - - if (Buttons.getCount() == 0) - return FALSE; - - for (int i = 0; i < Buttons.getCount(); i++) - AddLine(hTree, Buttons[i], TVI_LAST, dat->himlButtonIcons); - return TRUE; -} - -static void SaveTree(HWND hwndDlg) -{ - HWND hTree = GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE); - - TVITEM tvi = { 0 }; - tvi.hItem = TreeView_GetRoot(hTree); - tvi.stateMask = TVIS_STATEIMAGEMASK; - tvi.mask = TVIF_PARAM | TVIF_HANDLE | TVIF_STATE; - - LIST tmpList(8); - - while(tvi.hItem != NULL) { - TreeView_GetItem(hTree, &tvi); - - TopButtonInt* btn = (TopButtonInt*)tvi.lParam; - Buttons.remove(btn); - - if (TreeView_GetCheckState(hTree,tvi.hItem)) - btn->dwFlags |= TTBBF_VISIBLE; - else - btn->dwFlags &= ~TTBBF_VISIBLE; - btn->dwFlags &= ~TTBBF_OPTIONAL; - btn->arrangedpos = tmpList.getCount(); - - tmpList.insert(btn); - tvi.hItem = TreeView_GetNextSibling(hTree, tvi.hItem); - } - { - mir_cslock lck(csButtonsHook); - for (int i=0; i < Buttons.getCount(); i++) - delete Buttons[i]; - - Buttons = tmpList; - tmpList.destroy(); - } - SaveAllButtonsOptions(); -} - -void CancelProcess(HWND hwndDlg) -{ - HWND hTree = GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE); - - TVITEM tvi = { 0 }; - tvi.hItem = TreeView_GetRoot(hTree); - - while(tvi.hItem != NULL) { - tvi.stateMask = TVIS_STATEIMAGEMASK; - tvi.mask = TVIF_PARAM | TVIF_HANDLE | TVIF_STATE; - TreeView_GetItem(hTree, &tvi); - - TopButtonInt* btn = (TopButtonInt*)tvi.lParam; - - if (btn ->dwFlags & TTBBF_OPTIONAL) - delete btn; - - tvi.hItem = TreeView_GetNextSibling(hTree, tvi.hItem); - } -} - -static void RecreateWindows() -{ - { - mir_cslock lck(csButtonsHook); - for (int i = 0; i < Buttons.getCount(); i++) { - TopButtonInt *b = Buttons[i]; - if (b->hwnd) { - DestroyWindow(b->hwnd); - b->CreateWnd(); - } - } - } - - if (g_ctrl->hWnd) - PostMessage(g_ctrl->hWnd, TTB_UPDATEFRAMEVISIBILITY, TRUE, 0); -} - -///////////////////////////////////////////////////////////////////////////////////////// -// external functions - -void AddToOptions(TopButtonInt* b) -{ - if (OptionshWnd) { - HWND hTree = GetDlgItem(OptionshWnd, IDC_BUTTONORDERTREE); - OrderData *dat = (OrderData*)GetWindowLongPtr(hTree, GWLP_USERDATA); - AddLine(hTree, b, TVI_LAST, dat->himlButtonIcons); - } -} - -void RemoveFromOptions(int id) -{ - if (OptionshWnd) { - HWND hTree = GetDlgItem(OptionshWnd, IDC_BUTTONORDERTREE); - TVITEM tvi = { 0 }; - tvi.hItem = TreeView_GetRoot(hTree); - tvi.mask = TVIF_PARAM | TVIF_HANDLE; - - TopButtonInt* btn; - while(tvi.hItem != NULL) { - TreeView_GetItem(hTree, &tvi); - btn = (TopButtonInt*)tvi.lParam; - if (btn->id == id) { - // delete if was changed - if (btn->dwFlags & TTBBF_OPTIONAL) - delete btn; - TreeView_DeleteItem(hTree,tvi.hItem); - break; - } - - tvi.hItem = TreeView_GetNextSibling(hTree, tvi.hItem); - } - } -} - -///////////////////////////////////////////////////////////////////////////////////////// -// Options window: main - -static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - HWND hTree = GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE); - OrderData *dat = (OrderData*)GetWindowLongPtr(hTree, GWLP_USERDATA); - - switch (msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - dat = (OrderData*)malloc( sizeof(OrderData)); - SetWindowLongPtr(hTree, GWLP_USERDATA, (LONG)dat); - dat->dragging = 0; - - SetWindowLongPtr(hTree, GWL_STYLE, GetWindowLongPtr(hTree, GWL_STYLE)|TVS_NOHSCROLL); - - SetDlgItemInt(hwndDlg, IDC_BUTTHEIGHT, g_ctrl->nButtonHeight, FALSE); - SendDlgItemMessage(hwndDlg, IDC_SPIN_HEIGHT, UDM_SETRANGE, 0, MAKELONG(50,10)); - SendDlgItemMessage(hwndDlg, IDC_SPIN_HEIGHT, UDM_SETPOS, 0, MAKELONG(g_ctrl->nButtonHeight,0)); - - SetDlgItemInt(hwndDlg, IDC_BUTTWIDTH, g_ctrl->nButtonWidth, FALSE); - SendDlgItemMessage(hwndDlg, IDC_SPIN_WIDTH, UDM_SETRANGE, 0, MAKELONG(50,10)); - SendDlgItemMessage(hwndDlg, IDC_SPIN_WIDTH, UDM_SETPOS, 0, MAKELONG(g_ctrl->nButtonWidth,0)); - - SetDlgItemInt(hwndDlg, IDC_BUTTGAP, g_ctrl->nButtonSpace, FALSE); - SendDlgItemMessage(hwndDlg, IDC_SPIN_GAP, UDM_SETRANGE, 0, MAKELONG(20,0)); - SendDlgItemMessage(hwndDlg, IDC_SPIN_GAP, UDM_SETPOS, 0, MAKELONG(g_ctrl->nButtonSpace,0)); - - CheckDlgButton(hwndDlg, IDC_USEFLAT, g_ctrl->bFlatButtons); - CheckDlgButton(hwndDlg, IDC_AUTORESIZE, g_ctrl->bAutoSize); - CheckDlgButton(hwndDlg, IDC_SINGLELINE, g_ctrl->bSingleLine); - - BuildTree(hwndDlg); - EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_DELLBUTTON), FALSE); - - OptionshWnd = hwndDlg; - return TRUE; - - case WM_COMMAND: - if (HIWORD(wParam) == EN_CHANGE && OptionshWnd) { - switch(LOWORD(wParam)) { - case IDC_ENAME: case IDC_EPATH: - break; - default: - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - break; - } - - if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DBLCLK)) { - int ctrlid = LOWORD(wParam); - - //----- Launch buttons ----- - - if (ctrlid == IDC_BROWSE) { - TCHAR str[MAX_PATH]; - OPENFILENAME ofn = {0}; - - GetDlgItemText(hwndDlg, IDC_EPATH, str, sizeof(str)); - ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; - ofn.hwndOwner = hwndDlg; - ofn.hInstance = NULL; - ofn.lpstrFilter = NULL; - ofn.lpstrFile = str; - ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_EXPLORER; - ofn.nMaxFile = sizeof(str); - ofn.nMaxFileTitle = MAX_PATH; - ofn.lpstrDefExt = _T("exe"); - if (!GetOpenFileName(&ofn)) - break; - - SetDlgItemText(hwndDlg, IDC_EPATH, str); - - break; - } - - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - - if (ctrlid == IDC_LBUTTONSET) { - TVITEM tvi ={0}; - tvi.hItem = TreeView_GetSelection(hTree); - if (tvi.hItem == NULL) - break; - - tvi.mask = TVIF_PARAM; - TreeView_GetItem(hTree, &tvi); - - TopButtonInt* btn = (TopButtonInt*)tvi.lParam; - TCHAR buf [256]; - // probably, condition not needs - if (btn->dwFlags & TTBBF_ISLBUTTON) { - if (!(btn->dwFlags & TTBBF_OPTIONAL)) { - // create button - TTBButton ttb = { 0 }; - ttb.cbSize = sizeof(ttb); - ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); - ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISLBUTTON | TTBBF_INTERNAL | TTBBF_OPTIONAL; - ttb.name = NULL; - ttb.program = NULL; - int id = btn->id; - btn = CreateButton(&ttb); - btn->id = id; - - tvi.lParam = (LPARAM)btn; - TreeView_SetItem(hTree, &tvi); - } - - GetDlgItemText(hwndDlg, IDC_ENAME, buf, 255); - replaceStr(btn->pszName, _T2A(buf)); - - tvi.mask = TVIF_TEXT; - tvi.pszText = buf; - TreeView_SetItem(hTree, &tvi); - - GetDlgItemText(hwndDlg, IDC_EPATH, buf, 255); - replaceStrT(btn->ptszProgram, buf); - } - break; - } - - if (ctrlid == IDC_ADDLBUTTON) { - // create button - TTBButton ttb = { 0 }; - ttb.cbSize = sizeof(ttb); - ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); - ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISLBUTTON | TTBBF_INTERNAL | TTBBF_OPTIONAL; - ttb.name = LPGEN("Default"); - ttb.program = _T("Execute Path"); - TopButtonInt* b = CreateButton(&ttb); - - // get selection for insert - TVITEM tvi = {0}; - tvi.hItem = TreeView_GetSelection(hTree); - - // insert item - AddLine(hTree, b, tvi.hItem, dat->himlButtonIcons); - - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - } - - //----- Separators ----- - - if (ctrlid == IDC_ADDSEP) { - // create button - TTBButton ttb = { 0 }; - ttb.cbSize = sizeof(ttb); - ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISSEPARATOR | TTBBF_INTERNAL | TTBBF_OPTIONAL; - TopButtonInt* b = CreateButton(&ttb); - - // get selection for insert - TVITEM tvi = {0}; - tvi.hItem = TreeView_GetSelection(hTree); - - // insert item - AddLine(hTree, b, tvi.hItem, dat->himlButtonIcons); - - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - } - - if (ctrlid == IDC_REMOVEBUTTON) { - TVITEM tvi = {0}; - tvi.hItem = TreeView_GetSelection(hTree); - if (tvi.hItem == NULL) - break; - - tvi.mask = TVIF_PARAM; - TreeView_GetItem(hTree, &tvi); - - TopButtonInt* btn = (TopButtonInt*)tvi.lParam; - // if button enabled for separator and launch only, no need condition - // except possible service button introducing - if (btn->dwFlags & (TTBBF_ISSEPARATOR | TTBBF_ISLBUTTON)) { - // delete if was added in options - if (btn->dwFlags & TTBBF_OPTIONAL) - delete btn; - - TreeView_DeleteItem(hTree,tvi.hItem); - - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - break; - } - } - break; - - case WM_NOTIFY: - switch(((LPNMHDR)lParam)->idFrom) { - case 0: - switch (((LPNMHDR)lParam)->code) { - case PSN_APPLY: - g_ctrl->nButtonHeight = GetDlgItemInt(hwndDlg, IDC_BUTTHEIGHT, NULL, FALSE); - g_ctrl->nButtonWidth = GetDlgItemInt(hwndDlg, IDC_BUTTWIDTH, NULL, FALSE); - g_ctrl->nButtonSpace = GetDlgItemInt(hwndDlg, IDC_BUTTGAP, NULL, FALSE); - - g_ctrl->bFlatButtons = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_USEFLAT); - g_ctrl->bAutoSize = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTORESIZE); - g_ctrl->bSingleLine = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SINGLELINE); - - db_set_dw(0, TTB_OPTDIR, "BUTTHEIGHT", g_ctrl->nButtonHeight); - db_set_dw(0, TTB_OPTDIR, "BUTTWIDTH", g_ctrl->nButtonWidth); - db_set_dw(0, TTB_OPTDIR, "BUTTGAP", g_ctrl->nButtonSpace); - - db_set_b(0, TTB_OPTDIR, "UseFlatButton", g_ctrl->bFlatButtons); - db_set_b(0, TTB_OPTDIR, "SingleLine", g_ctrl->bSingleLine); - db_set_b(0, TTB_OPTDIR, "AutoSize", g_ctrl->bAutoSize); - - SaveTree(hwndDlg); - RecreateWindows(); - ArrangeButtons(); - } - break; - - case IDC_BUTTONORDERTREE: - switch (((LPNMHDR)lParam)->code) { - case TVN_BEGINDRAGA: - case TVN_BEGINDRAGW: - SetCapture(hwndDlg); - dat->dragging = 1; - dat->hDragItem = ((LPNMTREEVIEW)lParam)->itemNew.hItem; - TreeView_SelectItem(hTree, dat->hDragItem); - break; - - case NM_CLICK: - { - TVHITTESTINFO hti; - hti.pt.x = (short)LOWORD(GetMessagePos()); - hti.pt.y = (short)HIWORD(GetMessagePos()); - ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt); - if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti)) - if (hti.flags & TVHT_ONITEMSTATEICON) { - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - TreeView_SelectItem(hTree, hti.hItem); - } - } - break; - - case TVN_SELCHANGEDA: - case TVN_SELCHANGEDW: - { - HTREEITEM hti = TreeView_GetSelection(hTree); - if (hti == NULL) - break; - - TopButtonInt *btn = (TopButtonInt*)((LPNMTREEVIEW)lParam)->itemNew.lParam; - - mir_cslock lck(csButtonsHook); - - if (btn->dwFlags & TTBBF_ISLBUTTON) { - bool enable = (btn->dwFlags & TTBBF_INTERNAL) !=0; - EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), enable); - EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), enable); - EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVEBUTTON), enable); - EnableWindow(GetDlgItem(hwndDlg, IDC_LBUTTONSET), enable); - if (btn->pszName != NULL) - SetDlgItemTextA(hwndDlg, IDC_ENAME, btn->pszName); - else - SetDlgItemTextA(hwndDlg, IDC_ENAME, ""); - - if (btn->ptszProgram != NULL) - SetDlgItemText(hwndDlg, IDC_EPATH, btn->ptszProgram); - else - SetDlgItemTextA(hwndDlg, IDC_EPATH, ""); - } - else { - EnableWindow(GetDlgItem(hwndDlg,IDC_REMOVEBUTTON), - (btn->dwFlags & TTBBF_ISSEPARATOR)?TRUE:FALSE); - - EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_LBUTTONSET), FALSE); - SetDlgItemTextA(hwndDlg, IDC_ENAME, ""); - SetDlgItemTextA(hwndDlg, IDC_EPATH, ""); - } - } - } - break; - } - break; - - case WM_MOUSEMOVE: - if (dat->dragging) { - TVHITTESTINFO hti; - hti.pt.x = (short)LOWORD(lParam); - hti.pt.y = (short)HIWORD(lParam); - ClientToScreen(hwndDlg, &hti.pt); - ScreenToClient(hTree, &hti.pt); - TreeView_HitTest(hTree, &hti); - if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) { - HTREEITEM it=hti.hItem; - hti.pt.y -= TreeView_GetItemHeight(hTree)/2; - TreeView_HitTest(hTree, &hti); - if (!(hti.flags&TVHT_ABOVE)) - TreeView_SetInsertMark(hTree,hti.hItem,1); - else - TreeView_SetInsertMark(hTree,it,0); - } - else { - if (hti.flags & TVHT_ABOVE) SendMessage(hTree, WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0); - if (hti.flags & TVHT_BELOW) SendMessage(hTree, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0); - TreeView_SetInsertMark(hTree, NULL, 0); - } - } - break; - - case WM_LBUTTONUP: - if (dat->dragging) { - TreeView_SetInsertMark(hTree, NULL, 0); - dat->dragging = 0; - ReleaseCapture(); - - TVHITTESTINFO hti; - hti.pt.x = (short)LOWORD(lParam); - hti.pt.y = (short)HIWORD(lParam); - ClientToScreen(hwndDlg, &hti.pt); - ScreenToClient(hTree, &hti.pt); - hti.pt.y -= TreeView_GetItemHeight(hTree)/2; - TreeView_HitTest(hTree, &hti); - if (dat->hDragItem == hti.hItem) - break; - if (hti.flags&TVHT_ABOVE) - hti.hItem=TVI_FIRST; - - TVITEM tvi; - tvi.mask = TVIF_HANDLE|TVIF_PARAM; - tvi.hItem = (HTREEITEM) dat->hDragItem; - TreeView_GetItem(hTree, &tvi); - if ( (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) || (hti.hItem==TVI_FIRST)) { - TVINSERTSTRUCT tvis; - TCHAR name[128]; - tvis.item.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_STATE; - tvis.item.stateMask = 0xFFFFFFFF; - tvis.item.pszText = name; - tvis.item.cchTextMax = SIZEOF(name); - tvis.item.hItem = dat->hDragItem; - TreeView_GetItem(hTree, &tvis.item); - - TreeView_DeleteItem(hTree, dat->hDragItem); - tvis.hParent = NULL; - tvis.hInsertAfter = hti.hItem; - TreeView_SelectItem(hTree, TreeView_InsertItem(hTree, &tvis)); - - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - } - break; - - case WM_DESTROY: - if (dat) { - ImageList_Destroy(dat->himlButtonIcons); - free(dat); - } - OptionshWnd = NULL; - break; - } - return FALSE; -} - -///////////////////////////////////////////////////////////////////////////////////////// - -int TTBOptInit(WPARAM wParam, LPARAM lParam) -{ - OPTIONSDIALOGPAGE odp = { 0 }; - odp.cbSize = sizeof(odp); - odp.hInstance = hInst; - odp.pszGroup = LPGEN("Contact List"); - - odp.position = -1000000000; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_BUTORDER); - odp.pszTitle = LPGEN("Toolbar"); - odp.pfnDlgProc = ButOrderOpts; - odp.flags = ODPF_BOLDGROUPS | ODPF_EXPERTONLY; - Options_AddPage(wParam, &odp); - return 0; -} diff --git a/plugins/TopToolBar/version.h b/plugins/TopToolBar/version.h deleted file mode 100644 index 9a489eebee..0000000000 --- a/plugins/TopToolBar/version.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2008 Miranda ICQ/IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#define __MAJOR_VERSION 0 -#define __MINOR_VERSION 8 -#define __RELEASE_NUM 0 -#define __BUILD_NUM 1 - -// other stuff for Version resource -#define __STRINGIFY_IMPL(x) #x -#define __STRINGIFY(x) __STRINGIFY_IMPL(x) - -#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM -#define __FILEVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM -#define __VERSION_STRING __STRINGIFY(__FILEVERSION_STRING_DOTS) - -#define __PLUGIN_DESC "ToptoolBar adds buttons in top frame for fast access." -#define __PLUGIN_LONGDESC __PLUGIN_DESC -#define __PLUGIN_AUTHOR "Bethoven" -#define __PLUGIN_AUTHORWEB "http://nightly.miranda.im/" -#define __PLUGIN_EMAIL "Bethoven@mailgate.ru" -#define __PLUGIN_RIGHTS "© 2003-2008 Bethoven" -#define __PLUGIN_FILE "TopToolbar.dll" -#define __PLUGIN_SHORTNAME "TopToolBar" - -#define __PLUGIN_NAME __PLUGIN_SHORTNAME diff --git a/plugins/TopToolBar/version.rc b/plugins/TopToolBar/version.rc deleted file mode 100644 index 9981077b9f..0000000000 --- a/plugins/TopToolBar/version.rc +++ /dev/null @@ -1,65 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include -#include -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION __FILEVERSION_STRING - PRODUCTVERSION __FILEVERSION_STRING - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "FileDescription", __PLUGIN_DESC - VALUE "FileVersion", __VERSION_STRING - VALUE "InternalName", __PLUGIN_SHORTNAME - VALUE "LegalCopyright", __PLUGIN_RIGHTS - VALUE "OriginalFilename", __PLUGIN_FILE - VALUE "ProductName", __PLUGIN_SHORTNAME - VALUE "ProductVersion", __VERSION_STRING - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END - -#endif diff --git a/plugins/TranslitSwitcher/Docs/translitswitcher-translation.txt b/plugins/TranslitSwitcher/Docs/translitswitcher-translation.txt new file mode 100644 index 0000000000..a505626cde --- /dev/null +++ b/plugins/TranslitSwitcher/Docs/translitswitcher-translation.txt @@ -0,0 +1,10 @@ +; Common strings that belong to many files +;[] + +; ../../plugins/TranslitSwitcher/Src/Layoutproc.cpp +;[TranslitSwitcher] + +; ../../plugins/TranslitSwitcher/Src/TranslitSwitcher.cpp +;[Invert Case and Send] +;[SwitchLayout and Send] +;[Translit and Send] diff --git a/plugins/TranslitSwitcher/Res/Resource.rc b/plugins/TranslitSwitcher/Res/Resource.rc new file mode 100644 index 0000000000..3019bbb1f4 --- /dev/null +++ b/plugins/TranslitSwitcher/Res/Resource.rc @@ -0,0 +1,48 @@ +// Microsoft Visual C++ generated resource script. +// +#include "..\src\resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Русский (Россия) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) +LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT +#pragma code_page(1251) + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_SWITCHSEND ICON "SwitchSend.ico" +IDI_TRANSLITSEND ICON "TranslitSend.ico" +IDI_INVERTSEND ICON "InvertSend.ico" + + +#endif // Русский (Россия) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/TranslitSwitcher/Res/Version.rc b/plugins/TranslitSwitcher/Res/Version.rc new file mode 100644 index 0000000000..472bfbfe38 --- /dev/null +++ b/plugins/TranslitSwitcher/Res/Version.rc @@ -0,0 +1,42 @@ +// Microsoft Visual C++ generated resource script. +// +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + +#include "afxres.h" +#include "..\src\version.h" + +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +#endif //_WIN32 + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __FILEVERSION_STRING + PRODUCTVERSION __FILEVERSION_STRING + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x0L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "FileDescription", __DESCRIPTION + VALUE "InternalName", __PLUGIN_NAME + VALUE "LegalCopyright", __COPYRIGHT + VALUE "OriginalFilename", __FILENAME + VALUE "ProductName", __PLUGIN_NAME + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END \ No newline at end of file diff --git a/plugins/TranslitSwitcher/Resource.h b/plugins/TranslitSwitcher/Resource.h deleted file mode 100644 index b98a6590c2..0000000000 --- a/plugins/TranslitSwitcher/Resource.h +++ /dev/null @@ -1,18 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by resources.rc -// -#define IDI_SWITCHSEND 101 -#define IDI_TRANSLITSEND 102 -#define IDI_INVERTSEND 103 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 104 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/plugins/TranslitSwitcher/Resource.rc b/plugins/TranslitSwitcher/Resource.rc deleted file mode 100644 index b405fa8e86..0000000000 --- a/plugins/TranslitSwitcher/Resource.rc +++ /dev/null @@ -1,48 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Русский (Россия) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) -LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT -#pragma code_page(1251) - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_SWITCHSEND ICON "res/SwitchSend.ico" -IDI_TRANSLITSEND ICON "res/TranslitSend.ico" -IDI_INVERTSEND ICON "res/InvertSend.ico" - - -#endif // Русский (Россия) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/plugins/TranslitSwitcher/Src/Resource.h b/plugins/TranslitSwitcher/Src/Resource.h new file mode 100644 index 0000000000..b98a6590c2 --- /dev/null +++ b/plugins/TranslitSwitcher/Src/Resource.h @@ -0,0 +1,18 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by resources.rc +// +#define IDI_SWITCHSEND 101 +#define IDI_TRANSLITSEND 102 +#define IDI_INVERTSEND 103 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 104 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/plugins/TranslitSwitcher/Src/TranslitSwitcher.h b/plugins/TranslitSwitcher/Src/TranslitSwitcher.h index 540a0cd1bd..ea29c2c7bf 100644 --- a/plugins/TranslitSwitcher/Src/TranslitSwitcher.h +++ b/plugins/TranslitSwitcher/Src/TranslitSwitcher.h @@ -38,8 +38,8 @@ Boston, MA 02111-1307, USA. #include "m_msg_buttonsbar.h" #include "m_popup.h" -#include "..\version.h" -#include "..\resource.h" +#include "version.h" +#include "resource.h" #include "m_smileyadd.h" #include "m_ieview.h" #include "m_popup2.h" diff --git a/plugins/TranslitSwitcher/Src/Version.h b/plugins/TranslitSwitcher/Src/Version.h new file mode 100644 index 0000000000..c186a42101 --- /dev/null +++ b/plugins/TranslitSwitcher/Src/Version.h @@ -0,0 +1,20 @@ +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 0 +#define __RELEASE_NUM 1 +#define __BUILD_NUM 0 + +#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM +#define __FILEVERSION_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM + +#define __STRINGIFY_IMPL(x) #x +#define __STRINGIFY(x) __STRINGIFY_IMPL(x) +#define __VERSION_STRING __STRINGIFY(__FILEVERSION_DOTS) + +#define __PLUGIN_NAME "Switch Layout or Transliterate" +#define __INTERNAL_NAME "TranslitSwitcher" +#define __FILENAME "TranslitSwitcher.dll" +#define __DESCRIPTION "Allows to switch a layout or transliterate or invert case of the entered text in the message window with SmileyAdd support." +#define __AUTHOR "Mataes, tico-tico, Tim" +#define __AUTHOREMAIL "mataes2007@gmail.com" +#define __AUTHORWEB "http://nightly.miranda.im/" +#define __COPYRIGHT "© 2011-2010 Mataes, tico-tico © 2007 Dmitry Titkov" diff --git a/plugins/TranslitSwitcher/TranslitSwitcher_10.vcxproj b/plugins/TranslitSwitcher/TranslitSwitcher_10.vcxproj index 3a775cda5c..905ac38d84 100644 --- a/plugins/TranslitSwitcher/TranslitSwitcher_10.vcxproj +++ b/plugins/TranslitSwitcher/TranslitSwitcher_10.vcxproj @@ -73,13 +73,12 @@ Disabled ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;TRANSLITSWIITCHER_EXPORTS;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL Level3 EditAndContinue - 4996 true @@ -97,11 +96,10 @@ Disabled ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN64;_DEBUG;_WINDOWS;_USRDLL;TRANSLITSWIITCHER_EXPORTS;%(PreprocessorDefinitions) + WIN64;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL Level3 - 4996 true @@ -121,13 +119,12 @@ OnlyExplicitInline Size ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;TRANSLITSWIITCHER_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true false true Fast Level3 - 4996 Windows @@ -149,13 +146,12 @@ OnlyExplicitInline Size ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN64;NDEBUG;_WINDOWS;_USRDLL;TRANSLITSWIITCHER_EXPORTS;%(PreprocessorDefinitions) + WIN64;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true false true Fast Level3 - 4996 Windows @@ -172,17 +168,17 @@ - + - + - - + + diff --git a/plugins/TranslitSwitcher/TranslitSwitcher_10.vcxproj.filters b/plugins/TranslitSwitcher/TranslitSwitcher_10.vcxproj.filters index 409eda7983..4b7b7aa2a6 100644 --- a/plugins/TranslitSwitcher/TranslitSwitcher_10.vcxproj.filters +++ b/plugins/TranslitSwitcher/TranslitSwitcher_10.vcxproj.filters @@ -15,13 +15,13 @@ - + Header Files Header Files - + Header Files @@ -34,10 +34,10 @@ - + Resource Files - + Resource Files diff --git a/plugins/TranslitSwitcher/Version.h b/plugins/TranslitSwitcher/Version.h deleted file mode 100644 index c186a42101..0000000000 --- a/plugins/TranslitSwitcher/Version.h +++ /dev/null @@ -1,20 +0,0 @@ -#define __MAJOR_VERSION 0 -#define __MINOR_VERSION 0 -#define __RELEASE_NUM 1 -#define __BUILD_NUM 0 - -#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM -#define __FILEVERSION_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM - -#define __STRINGIFY_IMPL(x) #x -#define __STRINGIFY(x) __STRINGIFY_IMPL(x) -#define __VERSION_STRING __STRINGIFY(__FILEVERSION_DOTS) - -#define __PLUGIN_NAME "Switch Layout or Transliterate" -#define __INTERNAL_NAME "TranslitSwitcher" -#define __FILENAME "TranslitSwitcher.dll" -#define __DESCRIPTION "Allows to switch a layout or transliterate or invert case of the entered text in the message window with SmileyAdd support." -#define __AUTHOR "Mataes, tico-tico, Tim" -#define __AUTHOREMAIL "mataes2007@gmail.com" -#define __AUTHORWEB "http://nightly.miranda.im/" -#define __COPYRIGHT "© 2011-2010 Mataes, tico-tico © 2007 Dmitry Titkov" diff --git a/plugins/TranslitSwitcher/Version.rc b/plugins/TranslitSwitcher/Version.rc deleted file mode 100644 index f331bd1100..0000000000 --- a/plugins/TranslitSwitcher/Version.rc +++ /dev/null @@ -1,42 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - -#include "afxres.h" -#include "version.h" - -#ifdef _WIN32 -LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -#endif //_WIN32 - -VS_VERSION_INFO VERSIONINFO - FILEVERSION __FILEVERSION_STRING - PRODUCTVERSION __FILEVERSION_STRING - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x0L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "FileDescription", __DESCRIPTION - VALUE "InternalName", __PLUGIN_NAME - VALUE "LegalCopyright", __COPYRIGHT - VALUE "OriginalFilename", __FILENAME - VALUE "ProductName", __PLUGIN_NAME - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END \ No newline at end of file diff --git a/plugins/TranslitSwitcher/translitswitcher-translation.txt b/plugins/TranslitSwitcher/translitswitcher-translation.txt deleted file mode 100644 index a505626cde..0000000000 --- a/plugins/TranslitSwitcher/translitswitcher-translation.txt +++ /dev/null @@ -1,10 +0,0 @@ -; Common strings that belong to many files -;[] - -; ../../plugins/TranslitSwitcher/Src/Layoutproc.cpp -;[TranslitSwitcher] - -; ../../plugins/TranslitSwitcher/Src/TranslitSwitcher.cpp -;[Invert Case and Send] -;[SwitchLayout and Send] -;[Translit and Send] diff --git a/plugins/UserGuide/UserGuide_10.vcxproj b/plugins/UserGuide/UserGuide_10.vcxproj index a04c09b0e4..375843b925 100644 --- a/plugins/UserGuide/UserGuide_10.vcxproj +++ b/plugins/UserGuide/UserGuide_10.vcxproj @@ -75,7 +75,7 @@ AnySuitable Size ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;UserGuide_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true true Level3 @@ -96,7 +96,7 @@ AnySuitable Size ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN64;NDEBUG;_WINDOWS;_USRDLL;UserGuide_EXPORTS;%(PreprocessorDefinitions) + WIN64;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true true Level3 @@ -115,7 +115,7 @@ Disabled ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;UserGuide_EXPORTS;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL @@ -134,7 +134,7 @@ Disabled ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN64;_DEBUG;_WINDOWS;_USRDLL;UserGuide_EXPORTS;%(PreprocessorDefinitions) + WIN64;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL Level3 @@ -148,10 +148,10 @@ - + - + diff --git a/plugins/UserGuide/UserGuide_10.vcxproj.filters b/plugins/UserGuide/UserGuide_10.vcxproj.filters index 711c4c9dc2..c40fe0a474 100644 --- a/plugins/UserGuide/UserGuide_10.vcxproj.filters +++ b/plugins/UserGuide/UserGuide_10.vcxproj.filters @@ -9,18 +9,14 @@ {72da96a4-67f9-49cc-94d3-6730544c949f} h;hpp;hxx;hm;inl - - {34beb523-18cd-4f3d-85db-ec309fbf1d1a} - ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - + Source Files - + Header Files diff --git a/plugins/UserGuide/commonheaders.h b/plugins/UserGuide/commonheaders.h deleted file mode 100644 index 498dbb5b13..0000000000 --- a/plugins/UserGuide/commonheaders.h +++ /dev/null @@ -1,14 +0,0 @@ -#define _CRT_SECURE_NO_WARNINGS - -#define MIRANDA_VER 0x0A00 - -#include -#include -#include -#include -#include -#include -#include -#include - -#define MIID_USERGUIDE {0x297ec1e7, 0x41b7, 0x41f9, { 0xbb, 0x91, 0xef, 0xa9, 0x50, 0x28, 0xf1, 0x6c }} //297ec1e7-41b7-41f9-bb91-efa95028f16c diff --git a/plugins/UserGuide/docs/userguide-translation.txt b/plugins/UserGuide/docs/userguide-translation.txt new file mode 100644 index 0000000000..73bd66f0ac --- /dev/null +++ b/plugins/UserGuide/docs/userguide-translation.txt @@ -0,0 +1,5 @@ +; Common strings that belong to many files +;[] + +; ../../plugins/UserGuide/main.cpp +;[User Guide] diff --git a/plugins/UserGuide/main.cpp b/plugins/UserGuide/main.cpp deleted file mode 100644 index 2f0f53f02f..0000000000 --- a/plugins/UserGuide/main.cpp +++ /dev/null @@ -1,122 +0,0 @@ -#include "commonheaders.h" - -HINSTANCE hInst; - -HANDLE hModulesLoaded, hShowGuide; -int hLangpack; - -PLUGININFOEX pluginInfo={ - sizeof(PLUGININFOEX), - "User Guide Plugin", - PLUGIN_MAKE_VERSION(0,0,0,1), - "This plug-in adds the main menu item used to view miranda-im pack user guide.", - "Yasnovidyashii", - "yasnovidyashii@gmail.com", - "© 2009 Mikhail Yuriev", - "http://nightly.miranda.im/", - UNICODE_AWARE, - MIID_USERGUIDE -}; - -static INT_PTR ShowGuideFile(WPARAM wParam,LPARAM lParam) -{ - DBVARIANT dbv = {0}; - int iRes; - - LPCTSTR pszEmptySting = _T(""); - LPTSTR pszDirName, pszDirNameEx, pszFileName,pszDivider; - - REPLACEVARSDATA dat = {0}; - dat.cbSize = sizeof( dat ); - dat.dwFlags = RVF_TCHAR; - - pszDirName = (LPTSTR)mir_alloc(250*sizeof(TCHAR)); - pszFileName = (LPTSTR)mir_alloc(250*sizeof(TCHAR)); - - iRes = DBGetContactSettingTString(NULL, "UserGuide", "PathToHelpFile", &dbv); - - if (iRes!=0) - { - _tcscpy(pszDirName, _T("%miranda_path%\\Plugins")); - _tcscpy(pszFileName, _T("UserGuide.chm")); - } - else - { - if(!_tcscmp((dbv.ptszVal), pszEmptySting)) - { - _tcscpy(pszDirName, _T("%miranda_path%\\Plugins")); - _tcscpy(pszFileName, _T("UserGuide.chm")); - } - else - { - pszDivider = _tcsrchr(dbv.ptszVal, '\\'); - if (pszDivider == NULL) - { - pszDirName = _T(""); - _tcsncpy(pszFileName, dbv.ptszVal, _tcslen(dbv.ptszVal)); - } - else - { - _tcsncpy(pszFileName, pszDivider + 1, _tcslen(dbv.ptszVal) - _tcslen(pszDivider) - 1); - pszFileName[_tcslen(dbv.ptszVal) - _tcslen(pszDivider) - 1] = 0; - _tcsncpy(pszDirName, dbv.ptszVal, pszDivider - dbv.ptszVal); - pszDirName[pszDivider - dbv.ptszVal] = 0; - } - } - DBFreeVariant(&dbv); - } - if (ServiceExists(MS_UTILS_REPLACEVARS)) - pszDirNameEx = (TCHAR *) CallService(MS_UTILS_REPLACEVARS, (WPARAM)pszDirName, (LPARAM)&dat); - else - pszDirNameEx = mir_tstrdup(pszDirName); - - ShellExecute(NULL, _T("open"), pszFileName, NULL, pszDirNameEx, SW_SHOW); - mir_free(pszDirName); - mir_free(pszFileName); - mir_free(pszDirNameEx); - return 0; -} - -int ModulesLoaded(WPARAM wParam,LPARAM lParam) -{ - CLISTMENUITEM mi; - - hShowGuide = CreateServiceFunction("UserGuide/ShowGuide", ShowGuideFile); - ZeroMemory(&mi, sizeof(mi)); - mi.cbSize = sizeof(mi); - mi.position = 500000; - mi.flags = CMIF_TCHAR; - mi.hIcon = LoadSkinnedIcon(SKINICON_OTHER_HELP); - mi.ptszName = LPGENT("User Guide"); - mi.pszService = "UserGuide/ShowGuide"; - Menu_AddMainMenuItem(&mi); - - return 0; -} - -BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) -{ - hInst = hinstDLL; - return TRUE; -} - - -extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) -{ - return &pluginInfo; -} - -extern "C" __declspec(dllexport) int Load(void) -{ - - mir_getLP(&pluginInfo); - hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED,ModulesLoaded); - return 0; -} - -extern "C" __declspec(dllexport) int Unload(void) -{ - UnhookEvent(hModulesLoaded); - DestroyServiceFunction(hShowGuide); - return 0; -} \ No newline at end of file diff --git a/plugins/UserGuide/src/commonheaders.h b/plugins/UserGuide/src/commonheaders.h new file mode 100644 index 0000000000..498dbb5b13 --- /dev/null +++ b/plugins/UserGuide/src/commonheaders.h @@ -0,0 +1,14 @@ +#define _CRT_SECURE_NO_WARNINGS + +#define MIRANDA_VER 0x0A00 + +#include +#include +#include +#include +#include +#include +#include +#include + +#define MIID_USERGUIDE {0x297ec1e7, 0x41b7, 0x41f9, { 0xbb, 0x91, 0xef, 0xa9, 0x50, 0x28, 0xf1, 0x6c }} //297ec1e7-41b7-41f9-bb91-efa95028f16c diff --git a/plugins/UserGuide/src/main.cpp b/plugins/UserGuide/src/main.cpp new file mode 100644 index 0000000000..2f0f53f02f --- /dev/null +++ b/plugins/UserGuide/src/main.cpp @@ -0,0 +1,122 @@ +#include "commonheaders.h" + +HINSTANCE hInst; + +HANDLE hModulesLoaded, hShowGuide; +int hLangpack; + +PLUGININFOEX pluginInfo={ + sizeof(PLUGININFOEX), + "User Guide Plugin", + PLUGIN_MAKE_VERSION(0,0,0,1), + "This plug-in adds the main menu item used to view miranda-im pack user guide.", + "Yasnovidyashii", + "yasnovidyashii@gmail.com", + "© 2009 Mikhail Yuriev", + "http://nightly.miranda.im/", + UNICODE_AWARE, + MIID_USERGUIDE +}; + +static INT_PTR ShowGuideFile(WPARAM wParam,LPARAM lParam) +{ + DBVARIANT dbv = {0}; + int iRes; + + LPCTSTR pszEmptySting = _T(""); + LPTSTR pszDirName, pszDirNameEx, pszFileName,pszDivider; + + REPLACEVARSDATA dat = {0}; + dat.cbSize = sizeof( dat ); + dat.dwFlags = RVF_TCHAR; + + pszDirName = (LPTSTR)mir_alloc(250*sizeof(TCHAR)); + pszFileName = (LPTSTR)mir_alloc(250*sizeof(TCHAR)); + + iRes = DBGetContactSettingTString(NULL, "UserGuide", "PathToHelpFile", &dbv); + + if (iRes!=0) + { + _tcscpy(pszDirName, _T("%miranda_path%\\Plugins")); + _tcscpy(pszFileName, _T("UserGuide.chm")); + } + else + { + if(!_tcscmp((dbv.ptszVal), pszEmptySting)) + { + _tcscpy(pszDirName, _T("%miranda_path%\\Plugins")); + _tcscpy(pszFileName, _T("UserGuide.chm")); + } + else + { + pszDivider = _tcsrchr(dbv.ptszVal, '\\'); + if (pszDivider == NULL) + { + pszDirName = _T(""); + _tcsncpy(pszFileName, dbv.ptszVal, _tcslen(dbv.ptszVal)); + } + else + { + _tcsncpy(pszFileName, pszDivider + 1, _tcslen(dbv.ptszVal) - _tcslen(pszDivider) - 1); + pszFileName[_tcslen(dbv.ptszVal) - _tcslen(pszDivider) - 1] = 0; + _tcsncpy(pszDirName, dbv.ptszVal, pszDivider - dbv.ptszVal); + pszDirName[pszDivider - dbv.ptszVal] = 0; + } + } + DBFreeVariant(&dbv); + } + if (ServiceExists(MS_UTILS_REPLACEVARS)) + pszDirNameEx = (TCHAR *) CallService(MS_UTILS_REPLACEVARS, (WPARAM)pszDirName, (LPARAM)&dat); + else + pszDirNameEx = mir_tstrdup(pszDirName); + + ShellExecute(NULL, _T("open"), pszFileName, NULL, pszDirNameEx, SW_SHOW); + mir_free(pszDirName); + mir_free(pszFileName); + mir_free(pszDirNameEx); + return 0; +} + +int ModulesLoaded(WPARAM wParam,LPARAM lParam) +{ + CLISTMENUITEM mi; + + hShowGuide = CreateServiceFunction("UserGuide/ShowGuide", ShowGuideFile); + ZeroMemory(&mi, sizeof(mi)); + mi.cbSize = sizeof(mi); + mi.position = 500000; + mi.flags = CMIF_TCHAR; + mi.hIcon = LoadSkinnedIcon(SKINICON_OTHER_HELP); + mi.ptszName = LPGENT("User Guide"); + mi.pszService = "UserGuide/ShowGuide"; + Menu_AddMainMenuItem(&mi); + + return 0; +} + +BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) +{ + hInst = hinstDLL; + return TRUE; +} + + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +extern "C" __declspec(dllexport) int Load(void) +{ + + mir_getLP(&pluginInfo); + hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED,ModulesLoaded); + return 0; +} + +extern "C" __declspec(dllexport) int Unload(void) +{ + UnhookEvent(hModulesLoaded); + DestroyServiceFunction(hShowGuide); + return 0; +} \ No newline at end of file diff --git a/plugins/UserGuide/userguide-translation.txt b/plugins/UserGuide/userguide-translation.txt deleted file mode 100644 index 73bd66f0ac..0000000000 --- a/plugins/UserGuide/userguide-translation.txt +++ /dev/null @@ -1,5 +0,0 @@ -; Common strings that belong to many files -;[] - -; ../../plugins/UserGuide/main.cpp -;[User Guide] -- cgit v1.2.3