From 47739a02585405a13b81123da3a9f3ff97cea0b9 Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Fri, 8 Jun 2012 13:55:50 +0000 Subject: TopToolBar added git-svn-id: http://svn.miranda-ng.org/main/trunk@360 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- bin10/mir_full.sln | 9 + plugins/TopToolBar/BkgrCfg.h | 18 + plugins/TopToolBar/CLCButton.c | 624 ++++++++ plugins/TopToolBar/ClassDiagram1.cd | 1 + plugins/TopToolBar/InternalButtons.c | 436 ++++++ plugins/TopToolBar/TopToolBar.sln | 26 + plugins/TopToolBar/TopToolBar.vcxproj | 335 +++++ plugins/TopToolBar/TopToolBar.vcxproj.filters | 184 +++ plugins/TopToolBar/_button.c | 515 +++++++ plugins/TopToolBar/afxres.h | 2 + plugins/TopToolBar/bmp/bitmap1.bmp | Bin 0 -> 1398 bytes plugins/TopToolBar/bmp/bmp00001.bmp | Bin 0 -> 1398 bytes plugins/TopToolBar/bmp/bmp00002.bmp | Bin 0 -> 1270 bytes plugins/TopToolBar/bmp/borderup.bmp | Bin 0 -> 1398 bytes plugins/TopToolBar/bmp/borederdn.bmp | Bin 0 -> 1398 bytes plugins/TopToolBar/bmp/cpaneldn.bmp | Bin 0 -> 1398 bytes plugins/TopToolBar/bmp/cpanelup.bmp | Bin 0 -> 1398 bytes plugins/TopToolBar/bmp/findusedn.bmp | Bin 0 -> 1398 bytes plugins/TopToolBar/bmp/finduser.bmp | Bin 0 -> 1398 bytes plugins/TopToolBar/bmp/finduserdn.bmp | Bin 0 -> 1398 bytes plugins/TopToolBar/bmp/groupdn.bmp | Bin 0 -> 1398 bytes plugins/TopToolBar/bmp/groupup.bmp | Bin 0 -> 1398 bytes plugins/TopToolBar/bmp/launch.bmp | Bin 0 -> 1244 bytes plugins/TopToolBar/bmp/launchdn.bmp | Bin 0 -> 1398 bytes plugins/TopToolBar/bmp/launchup.bmp | Bin 0 -> 1398 bytes plugins/TopToolBar/bmp/menudn.bmp | Bin 0 -> 1398 bytes plugins/TopToolBar/bmp/menuup.bmp | Bin 0 -> 1398 bytes plugins/TopToolBar/bmp/minimize.bmp | Bin 0 -> 1252 bytes plugins/TopToolBar/bmp/minimizedn.bmp | Bin 0 -> 1232 bytes plugins/TopToolBar/bmp/options.bmp | Bin 0 -> 1398 bytes plugins/TopToolBar/bmp/searchtest.bmp | Bin 0 -> 1370 bytes plugins/TopToolBar/bmp/sep.bmp | Bin 0 -> 1194 bytes plugins/TopToolBar/bmp/separator.bmp | Bin 0 -> 512 bytes plugins/TopToolBar/bmp/soundsdn.bmp | Bin 0 -> 1398 bytes plugins/TopToolBar/bmp/soundsup.bmp | Bin 0 -> 1398 bytes plugins/TopToolBar/bmp/test.bmp | Bin 0 -> 1270 bytes plugins/TopToolBar/button.c | 541 +++++++ plugins/TopToolBar/buttonopt.c | 340 +++++ plugins/TopToolBar/common.h | 150 ++ plugins/TopToolBar/find.ico | Bin 0 -> 1406 bytes plugins/TopToolBar/icos/Find_Add Contacts_DN.ico | Bin 0 -> 2038 bytes plugins/TopToolBar/icos/Find_Add Contacts_UP.ico | Bin 0 -> 2038 bytes plugins/TopToolBar/icos/Groups On_Off_DN.ico | Bin 0 -> 2038 bytes plugins/TopToolBar/icos/Groups On_Off_UP.ico | Bin 0 -> 2038 bytes plugins/TopToolBar/icos/Minimize Button_DN.ico | Bin 0 -> 2038 bytes plugins/TopToolBar/icos/Minimize Button_UP.ico | Bin 0 -> 2038 bytes plugins/TopToolBar/icos/Run.ico | Bin 0 -> 1406 bytes plugins/TopToolBar/icos/Show Main Menu_DN.ico | Bin 0 -> 2038 bytes plugins/TopToolBar/icos/Show Main Menu_UP.ico | Bin 0 -> 2038 bytes plugins/TopToolBar/icos/Show Options Page_DN.ico | Bin 0 -> 2038 bytes plugins/TopToolBar/icos/Show Options Page_UP.ico | Bin 0 -> 2038 bytes .../TopToolBar/icos/Show only Online Users_DN.ico | Bin 0 -> 2038 bytes .../TopToolBar/icos/Show only Online Users_UP.ico | Bin 0 -> 2038 bytes .../TopToolBar/icos/Sounds Enable_Disable_DN.ico | Bin 0 -> 2038 bytes .../TopToolBar/icos/Sounds Enable_Disable_UP.ico | Bin 0 -> 2038 bytes plugins/TopToolBar/icos/icon1.ico | Bin 0 -> 2038 bytes plugins/TopToolBar/icos/mirandad.ico | Bin 0 -> 2294 bytes plugins/TopToolBar/icos/mirandau.ico | Bin 0 -> 2294 bytes plugins/TopToolBar/icos/notick.ico | Bin 0 -> 318 bytes plugins/TopToolBar/icos/notick1.ico | Bin 0 -> 318 bytes plugins/TopToolBar/launchbt.c | 211 +++ plugins/TopToolBar/main.c | 1515 ++++++++++++++++++++ plugins/TopToolBar/main.rc | 331 +++++ plugins/TopToolBar/resource.h | 95 ++ plugins/TopToolBar/separators.c | 111 ++ plugins/TopToolBar/ttb-readme.txt | 160 +++ plugins/TopToolBar/ttbopt.c | 970 +++++++++++++ 67 files changed, 6574 insertions(+) create mode 100644 plugins/TopToolBar/BkgrCfg.h create mode 100644 plugins/TopToolBar/CLCButton.c create mode 100644 plugins/TopToolBar/ClassDiagram1.cd create mode 100644 plugins/TopToolBar/InternalButtons.c create mode 100644 plugins/TopToolBar/TopToolBar.sln create mode 100644 plugins/TopToolBar/TopToolBar.vcxproj create mode 100644 plugins/TopToolBar/TopToolBar.vcxproj.filters create mode 100644 plugins/TopToolBar/_button.c create mode 100644 plugins/TopToolBar/afxres.h create mode 100644 plugins/TopToolBar/bmp/bitmap1.bmp create mode 100644 plugins/TopToolBar/bmp/bmp00001.bmp create mode 100644 plugins/TopToolBar/bmp/bmp00002.bmp create mode 100644 plugins/TopToolBar/bmp/borderup.bmp create mode 100644 plugins/TopToolBar/bmp/borederdn.bmp create mode 100644 plugins/TopToolBar/bmp/cpaneldn.bmp create mode 100644 plugins/TopToolBar/bmp/cpanelup.bmp create mode 100644 plugins/TopToolBar/bmp/findusedn.bmp create mode 100644 plugins/TopToolBar/bmp/finduser.bmp create mode 100644 plugins/TopToolBar/bmp/finduserdn.bmp create mode 100644 plugins/TopToolBar/bmp/groupdn.bmp create mode 100644 plugins/TopToolBar/bmp/groupup.bmp create mode 100644 plugins/TopToolBar/bmp/launch.bmp create mode 100644 plugins/TopToolBar/bmp/launchdn.bmp create mode 100644 plugins/TopToolBar/bmp/launchup.bmp create mode 100644 plugins/TopToolBar/bmp/menudn.bmp create mode 100644 plugins/TopToolBar/bmp/menuup.bmp create mode 100644 plugins/TopToolBar/bmp/minimize.bmp create mode 100644 plugins/TopToolBar/bmp/minimizedn.bmp create mode 100644 plugins/TopToolBar/bmp/options.bmp create mode 100644 plugins/TopToolBar/bmp/searchtest.bmp create mode 100644 plugins/TopToolBar/bmp/sep.bmp create mode 100644 plugins/TopToolBar/bmp/separator.bmp create mode 100644 plugins/TopToolBar/bmp/soundsdn.bmp create mode 100644 plugins/TopToolBar/bmp/soundsup.bmp create mode 100644 plugins/TopToolBar/bmp/test.bmp create mode 100644 plugins/TopToolBar/button.c create mode 100644 plugins/TopToolBar/buttonopt.c create mode 100644 plugins/TopToolBar/common.h create mode 100644 plugins/TopToolBar/find.ico create mode 100644 plugins/TopToolBar/icos/Find_Add Contacts_DN.ico create mode 100644 plugins/TopToolBar/icos/Find_Add Contacts_UP.ico create mode 100644 plugins/TopToolBar/icos/Groups On_Off_DN.ico create mode 100644 plugins/TopToolBar/icos/Groups On_Off_UP.ico create mode 100644 plugins/TopToolBar/icos/Minimize Button_DN.ico create mode 100644 plugins/TopToolBar/icos/Minimize Button_UP.ico create mode 100644 plugins/TopToolBar/icos/Run.ico create mode 100644 plugins/TopToolBar/icos/Show Main Menu_DN.ico create mode 100644 plugins/TopToolBar/icos/Show Main Menu_UP.ico create mode 100644 plugins/TopToolBar/icos/Show Options Page_DN.ico create mode 100644 plugins/TopToolBar/icos/Show Options Page_UP.ico create mode 100644 plugins/TopToolBar/icos/Show only Online Users_DN.ico create mode 100644 plugins/TopToolBar/icos/Show only Online Users_UP.ico create mode 100644 plugins/TopToolBar/icos/Sounds Enable_Disable_DN.ico create mode 100644 plugins/TopToolBar/icos/Sounds Enable_Disable_UP.ico create mode 100644 plugins/TopToolBar/icos/icon1.ico create mode 100644 plugins/TopToolBar/icos/mirandad.ico create mode 100644 plugins/TopToolBar/icos/mirandau.ico create mode 100644 plugins/TopToolBar/icos/notick.ico create mode 100644 plugins/TopToolBar/icos/notick1.ico create mode 100644 plugins/TopToolBar/launchbt.c create mode 100644 plugins/TopToolBar/main.c create mode 100644 plugins/TopToolBar/main.rc create mode 100644 plugins/TopToolBar/resource.h create mode 100644 plugins/TopToolBar/separators.c create mode 100644 plugins/TopToolBar/ttb-readme.txt create mode 100644 plugins/TopToolBar/ttbopt.c diff --git a/bin10/mir_full.sln b/bin10/mir_full.sln index 9cfe5b7a9d..71b9dfd0ae 100644 --- a/bin10/mir_full.sln +++ b/bin10/mir_full.sln @@ -298,6 +298,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Twitter", "..\protocols\Twi EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ChangeKeyboardLayout", "..\plugins\ChangeKeyboardLayout\ChangeKeyboardLayout.vcxproj", "{D85D47E7-EAD3-71E0-EE3A-49A7821D4DE4}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TopToolBar", "..\plugins\TopToolBar\TopToolBar.vcxproj", "{ECE691D0-BFB3-483B-A699-084269EFCE89}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -1494,6 +1496,13 @@ Global {D85D47E7-EAD3-71E0-EE3A-49A7821D4DE4}.Release|Win32.Build.0 = Release|Win32 {D85D47E7-EAD3-71E0-EE3A-49A7821D4DE4}.Release|x64.ActiveCfg = Release|x64 {D85D47E7-EAD3-71E0-EE3A-49A7821D4DE4}.Release|x64.Build.0 = Release|x64 + {ECE691D0-BFB3-483B-A699-084269EFCE89}.Debug|Win32.ActiveCfg = Debug|Win32 + {ECE691D0-BFB3-483B-A699-084269EFCE89}.Debug|Win32.Build.0 = Debug|Win32 + {ECE691D0-BFB3-483B-A699-084269EFCE89}.Debug|x64.ActiveCfg = Debug|x64 + {ECE691D0-BFB3-483B-A699-084269EFCE89}.Debug|x64.Build.0 = Debug|x64 + {ECE691D0-BFB3-483B-A699-084269EFCE89}.Release|Win32.ActiveCfg = Release|Win32 + {ECE691D0-BFB3-483B-A699-084269EFCE89}.Release|Win32.Build.0 = Release|Win32 + {ECE691D0-BFB3-483B-A699-084269EFCE89}.Release|x64.ActiveCfg = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/plugins/TopToolBar/BkgrCfg.h b/plugins/TopToolBar/BkgrCfg.h new file mode 100644 index 0000000000..a47b53a603 --- /dev/null +++ b/plugins/TopToolBar/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/CLCButton.c b/plugins/TopToolBar/CLCButton.c new file mode 100644 index 0000000000..597bb67cc2 --- /dev/null +++ b/plugins/TopToolBar/CLCButton.c @@ -0,0 +1,624 @@ +/* +Miranda IM +Copyright (C) 2002 Robert Rainwater + +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. +*/ +#include "common.h" + +// TODO: +// - Support for bitmap buttons (simple call to DrawIconEx()) +extern HINSTANCE hInst; +LONG g_cxsmIcon, g_cysmIcon; + +static LRESULT CALLBACK TSButtonWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); + +typedef struct { + HWND hwnd; + int stateId; // button state + int focus; // has focus (1 or 0) + HFONT hFont; // font + HICON arrow; // uses down arrow + int defbutton; // default button + HICON hIcon, hIconPrivate; + HBITMAP hBitmap; + int pushBtn; + int pbState; + HANDLE hThemeButton; + HANDLE hThemeToolbar; + BOOL bThemed; + char cHot; + int flatBtn; + char szText[128]; + SIZE sLabel; + HIMAGELIST hIml; + int iIcon; +} MButtonCtrl; + +// External theme methods and properties +static HMODULE themeAPIHandle = NULL; // handle to uxtheme.dll +static HANDLE (WINAPI *MyOpenThemeData)(HWND, LPCWSTR); +static HRESULT (WINAPI *MyCloseThemeData)(HANDLE); +static BOOL (WINAPI *MyIsThemeBackgroundPartiallyTransparent)(HANDLE, int, + int); +static HRESULT (WINAPI *MyDrawThemeParentBackground)(HWND, HDC, RECT *); +static HRESULT (WINAPI *MyDrawThemeBackground)(HANDLE, HDC, int, int, + const RECT *, const RECT *); +static HRESULT (WINAPI *MyDrawThemeText)(HANDLE, HDC, int, int, LPCWSTR, int, + DWORD, DWORD, const RECT *); + +static CRITICAL_SECTION csTips; +static HWND hwndToolTips = NULL; + +int UnloadTSButtonModule(WPARAM wParam, LPARAM lParam) +{ + DeleteCriticalSection(&csTips); + return 0; +} + +int LoadCLCButtonModule(void) +{ + WNDCLASSEXA wc; + + g_cxsmIcon=GetSystemMetrics(SM_CXSMICON); + g_cysmIcon=GetSystemMetrics(SM_CYSMICON); + + ZeroMemory(&wc, sizeof(wc)); + wc.cbSize = sizeof(wc); + wc.lpszClassName = "CLCButtonClass"; + wc.lpfnWndProc = TSButtonWndProc; + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.cbWndExtra = sizeof(MButtonCtrl *); + wc.hbrBackground = 0; + wc.style = CS_GLOBALCLASS; + RegisterClassExA(&wc); + InitializeCriticalSection(&csTips); + return 0; +} + +// Used for our own cheap TrackMouseEvent +#define BUTTON_POLLID 100 +#define BUTTON_POLLDELAY 50 + +#define MGPROC(x) GetProcAddress(themeAPIHandle,x) +static int ThemeSupport() +{ + if (IsWinVerXPPlus()) { + if (!themeAPIHandle) { + themeAPIHandle = GetModuleHandleA("uxtheme"); + if (themeAPIHandle) { + MyOpenThemeData = (HANDLE(WINAPI *)(HWND, LPCWSTR))MGPROC("OpenThemeData"); + MyCloseThemeData = (HRESULT(WINAPI *)(HANDLE))MGPROC("CloseThemeData"); + MyIsThemeBackgroundPartiallyTransparent = (BOOL(WINAPI *)(HANDLE, int, int))MGPROC("IsThemeBackgroundPartiallyTransparent"); + MyDrawThemeParentBackground = (HRESULT(WINAPI *)(HWND, HDC, RECT *))MGPROC("DrawThemeParentBackground"); + MyDrawThemeBackground = (HRESULT(WINAPI *)(HANDLE, HDC, int, int, const RECT *, const RECT *))MGPROC("DrawThemeBackground"); + MyDrawThemeText = (HRESULT(WINAPI *)(HANDLE, HDC, int, int, LPCWSTR, int, DWORD, DWORD, const RECT *))MGPROC("DrawThemeText"); + } + } + // Make sure all of these methods are valid (i would hope either all or none work) + if (MyOpenThemeData && MyCloseThemeData && MyIsThemeBackgroundPartiallyTransparent && MyDrawThemeParentBackground && MyDrawThemeBackground && MyDrawThemeText) { + return 1; + } + } + return 0; +} + +static void DestroyTheme(MButtonCtrl *ctl) +{ + if (ThemeSupport()) { + if (ctl->hThemeButton) { + MyCloseThemeData(ctl->hThemeButton); + ctl->hThemeButton = NULL; + } + if (ctl->hThemeToolbar) { + MyCloseThemeData(ctl->hThemeToolbar); + ctl->hThemeToolbar = NULL; + } + } +} + +static void LoadTheme(MButtonCtrl *ctl) +{ + if (ThemeSupport()) { + DestroyTheme(ctl); + ctl->hThemeButton = MyOpenThemeData(ctl->hwnd, L"BUTTON"); + ctl->hThemeToolbar = MyOpenThemeData(ctl->hwnd, L"TOOLBAR"); + ctl->bThemed = TRUE; + } +} + +static TBStateConvert2Flat(int state) +{ + switch (state) { + case PBS_NORMAL: + return TS_NORMAL; + case PBS_HOT: + return TS_HOT; + case PBS_PRESSED: + return TS_PRESSED; + case PBS_DISABLED: + return TS_DISABLED; + case PBS_DEFAULTED: + return TS_NORMAL; + } + return TS_NORMAL; +} + +static void PaintWorker(MButtonCtrl *ctl, HDC hdcPaint) +{ + if (hdcPaint) { + HDC hdcMem; + HBITMAP hbmMem; + HDC hOld; + RECT rcClient; + HFONT hOldFont = 0; + + GetClientRect(ctl->hwnd, &rcClient); + hdcMem = CreateCompatibleDC(hdcPaint); + hbmMem = CreateCompatibleBitmap(hdcPaint, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top); + hOld = SelectObject(hdcMem, hbmMem); + + // If its a push button, check to see if it should stay pressed + if (ctl->pushBtn && ctl->pbState) + ctl->stateId = PBS_PRESSED; + + // Draw the flat button + if (ctl->flatBtn) { + if (ctl->hThemeToolbar && ctl->bThemed) { + RECT rc = rcClient; + int state = IsWindowEnabled(ctl->hwnd) ? (ctl->stateId == PBS_NORMAL && ctl->defbutton ? PBS_DEFAULTED : ctl->stateId) : PBS_DISABLED; + if (MyIsThemeBackgroundPartiallyTransparent(ctl->hThemeToolbar, TP_BUTTON, TBStateConvert2Flat(state))) { + MyDrawThemeParentBackground(ctl->hwnd, hdcMem, &rc); + } + MyDrawThemeBackground(ctl->hThemeToolbar, hdcMem, TP_BUTTON, TBStateConvert2Flat(state), &rc, &rc); + } else { + HBRUSH hbr; + RECT rc = rcClient; + + if (ctl->stateId == PBS_PRESSED || ctl->stateId == PBS_HOT) + hbr = GetSysColorBrush(COLOR_3DFACE); + else { + HDC dc; + HWND hwndParent; + + hwndParent = GetParent(ctl->hwnd); + dc = GetDC(hwndParent); + hbr = (HBRUSH) SendMessage(hwndParent, WM_CTLCOLORDLG, (WPARAM) dc, (LPARAM) hwndParent); + ReleaseDC(hwndParent, dc); + } + if (hbr) { + FillRect(hdcMem, &rc, hbr); + DeleteObject(hbr); + } + if (ctl->stateId == PBS_HOT || ctl->focus) { + if (ctl->pbState) + DrawEdge(hdcMem, &rc, EDGE_ETCHED, BF_RECT | BF_SOFT); + else + DrawEdge(hdcMem, &rc, BDR_RAISEDOUTER, BF_RECT | BF_SOFT); + } else if (ctl->stateId == PBS_PRESSED) + DrawEdge(hdcMem, &rc, BDR_SUNKENOUTER, BF_RECT | BF_SOFT); + } + } else { + // Draw background/border + if (ctl->hThemeButton && ctl->bThemed) { + int state = IsWindowEnabled(ctl->hwnd) ? (ctl->stateId == PBS_NORMAL && ctl->defbutton ? PBS_DEFAULTED : ctl->stateId) : PBS_DISABLED; + if (MyIsThemeBackgroundPartiallyTransparent(ctl->hThemeButton, BP_PUSHBUTTON, state)) { + MyDrawThemeParentBackground(ctl->hwnd, hdcMem, &rcClient); + } + MyDrawThemeBackground(ctl->hThemeButton, hdcMem, BP_PUSHBUTTON, state, &rcClient, &rcClient); + } else { + UINT uState = DFCS_BUTTONPUSH | ((ctl->stateId == PBS_HOT) ? DFCS_HOT : 0) | ((ctl->stateId == PBS_PRESSED) ? DFCS_PUSHED : 0); + if (ctl->defbutton && ctl->stateId == PBS_NORMAL) + uState |= DLGC_DEFPUSHBUTTON; + DrawFrameControl(hdcMem, &rcClient, DFC_BUTTON, uState); + } + + // Draw focus rectangle if button has focus + if (ctl->focus) { + RECT focusRect = rcClient; + InflateRect(&focusRect, -3, -3); + DrawFocusRect(hdcMem, &focusRect); + } + } + + // If we have an icon or a bitmap, ignore text and only draw the image on the button + if (ctl->hIcon || ctl->hIconPrivate || ctl->iIcon) { + int ix = (rcClient.right - rcClient.left) / 2 - (g_cxsmIcon / 2); + int iy = (rcClient.bottom - rcClient.top) / 2 - (g_cxsmIcon / 2); + HICON hIconNew = ctl->hIconPrivate != 0 ? ctl->hIconPrivate : ctl->hIcon; + if (lstrlenA(ctl->szText) == 0) { + if (ctl->iIcon) + ImageList_DrawEx(ctl->hIml, ctl->iIcon, hdcMem, ix, iy, g_cxsmIcon, g_cysmIcon, CLR_NONE, CLR_NONE, ILD_NORMAL); + else + DrawState(hdcMem, NULL, NULL, (LPARAM) hIconNew, 0, ix, iy, g_cxsmIcon, g_cysmIcon, IsWindowEnabled(ctl->hwnd) ? DST_ICON | DSS_NORMAL : DST_ICON | DSS_DISABLED); + ctl->sLabel.cx = ctl->sLabel.cy = 0; + } else { + hOldFont = SelectObject(hdcMem, ctl->hFont); + GetTextExtentPoint32A(hdcMem, ctl->szText, lstrlenA(ctl->szText), &ctl->sLabel); + ix = (rcClient.right - rcClient.left) / 2 - ((g_cxsmIcon + ctl->sLabel.cx + 4) / 2); + if (ctl->iIcon) + ImageList_DrawEx(ctl->hIml, ctl->iIcon, hdcMem, ix, iy, g_cxsmIcon, g_cysmIcon, CLR_NONE, CLR_NONE, ILD_NORMAL); + else + DrawState(hdcMem, NULL, NULL, (LPARAM) hIconNew, 0, ix, iy, g_cxsmIcon, g_cysmIcon, IsWindowEnabled(ctl->hwnd) ? DST_ICON | DSS_NORMAL : DST_ICON | DSS_DISABLED); + ctl->sLabel.cx += (g_cxsmIcon + 4); + } + } else if (ctl->hBitmap) { + BITMAP bminfo; + int ix, iy; + + GetObject(ctl->hBitmap, sizeof(bminfo), &bminfo); + ix = (rcClient.right - rcClient.left) / 2 - (bminfo.bmWidth / 2); + iy = (rcClient.bottom - rcClient.top) / 2 - (bminfo.bmHeight / 2); + if (ctl->stateId == PBS_PRESSED) { + ix++; + iy++; + } + DrawState(hdcMem, NULL, NULL, (LPARAM) ctl->hBitmap, 0, ix, iy, bminfo.bmWidth, bminfo.bmHeight, IsWindowEnabled(ctl->hwnd) ? DST_BITMAP : DST_BITMAP | DSS_DISABLED); + } + if (GetWindowTextLengthA(ctl->hwnd)) { + // Draw the text and optinally the arrow + RECT rcText; + + CopyRect(&rcText, &rcClient); + SetBkMode(hdcMem, TRANSPARENT); + // XP w/themes doesn't used the glossy disabled text. Is it always using COLOR_GRAYTEXT? Seems so. + SetTextColor(hdcMem, IsWindowEnabled(ctl->hwnd) || !ctl->hThemeButton ? GetSysColor(COLOR_BTNTEXT) : GetSysColor(COLOR_GRAYTEXT)); + if (ctl->arrow) + DrawState(hdcMem, NULL, NULL, (LPARAM) ctl->arrow, 0, rcClient.right - rcClient.left - 5 - g_cxsmIcon + (!ctl->hThemeButton && ctl->stateId == PBS_PRESSED ? 1 : 0), (rcClient.bottom - rcClient.top) / 2 - g_cysmIcon / 2 + (!ctl->hThemeButton && ctl->stateId == PBS_PRESSED ? 1 : 0), g_cxsmIcon, g_cysmIcon, IsWindowEnabled(ctl->hwnd) ? DST_ICON : DST_ICON | DSS_DISABLED); + SelectObject(hdcMem, ctl->hFont); + DrawStateA(hdcMem, NULL, NULL, (LPARAM) ctl->szText, 0, (rcText.right - rcText.left - ctl->sLabel.cx) / 2 + (!ctl->hThemeButton && ctl->stateId == PBS_PRESSED ? 1 : 0) + g_cxsmIcon + 4, ctl->hThemeButton ? (rcText.bottom - rcText.top - ctl->sLabel.cy) / 2 + 1 : (rcText.bottom - rcText.top - ctl->sLabel.cy) / 2 + (ctl->stateId == PBS_PRESSED ? 1 : 0), ctl->sLabel.cx, ctl->sLabel.cy, IsWindowEnabled(ctl->hwnd) || ctl->hThemeButton ? DST_PREFIXTEXT | DSS_NORMAL : DST_PREFIXTEXT | DSS_DISABLED); + } + if (hOldFont) + SelectObject(hdcMem, hOldFont); + BitBlt(hdcPaint, 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top, hdcMem, 0, 0, SRCCOPY); + SelectObject(hdcMem, hOld); + DeleteObject(hbmMem); + DeleteDC(hdcMem); + } +} + +static LRESULT CALLBACK TSButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + MButtonCtrl *bct = (MButtonCtrl *) GetWindowLong(hwndDlg, 0); + switch (msg) { + case WM_NCCREATE: + { + SetWindowLong(hwndDlg, GWL_STYLE, GetWindowLong(hwndDlg, GWL_STYLE) | BS_OWNERDRAW); + bct = malloc(sizeof(MButtonCtrl)); + if (bct == NULL) + return FALSE; + bct->hwnd = hwndDlg; + bct->stateId = PBS_NORMAL; + bct->focus = 0; + bct->hFont = GetStockObject(DEFAULT_GUI_FONT); + bct->arrow = NULL; + bct->defbutton = 0; + bct->hIcon = bct->hIconPrivate = 0; + bct->iIcon = 0; + bct->hIml = 0; + bct->hBitmap = NULL; + bct->pushBtn = 0; + bct->pbState = 0; + bct->hThemeButton = NULL; + bct->hThemeToolbar = NULL; + bct->cHot = 0; + bct->flatBtn = 0; + bct->bThemed = FALSE; + LoadTheme(bct); + SetWindowLong(hwndDlg, 0, (LONG) bct); + if (((CREATESTRUCTA *) lParam)->lpszName) + SetWindowTextA(hwndDlg, ((CREATESTRUCTA *) lParam)->lpszName); + return TRUE; + } + case WM_DESTROY: + { + if (bct) { + EnterCriticalSection(&csTips); + if (hwndToolTips) { + TOOLINFO ti; + + ZeroMemory(&ti, sizeof(ti)); + ti.cbSize = sizeof(ti); + ti.uFlags = TTF_IDISHWND; + ti.hwnd = bct->hwnd; + ti.uId = (UINT) bct->hwnd; + if (SendMessage(hwndToolTips, TTM_GETTOOLINFO, 0, (LPARAM) &ti)) { + SendMessage(hwndToolTips, TTM_DELTOOL, 0, (LPARAM) &ti); + } + if (SendMessage(hwndToolTips, TTM_GETTOOLCOUNT, 0, (LPARAM) &ti) == 0) { + DestroyWindow(hwndToolTips); + hwndToolTips = NULL; + } + } + if (bct->hIconPrivate) + DestroyIcon(bct->hIconPrivate); + LeaveCriticalSection(&csTips); + DestroyTheme(bct); + free(bct); + } + SetWindowLong(hwndDlg, 0, (LONG) NULL); + break; // DONT! fall thru + } + case WM_SETTEXT: + { + bct->cHot = 0; + if ((char*) lParam) { + char *tmp = (char *) lParam; + while (*tmp) { + if (*tmp == '&' && *(tmp + 1)) { + bct->cHot = tolower(*(tmp + 1)); + break; + } + tmp++; + } + InvalidateRect(bct->hwnd, NULL, TRUE); + strncpy(bct->szText, (char*) lParam, 127); + bct->szText[127] = 0; + } + break; + } + case WM_SYSKEYUP: + if (bct->stateId != PBS_DISABLED && bct->cHot && bct->cHot == tolower((int) wParam)) { + if (bct->pushBtn) { + if (bct->pbState) + bct->pbState = 0; + else + bct->pbState = 1; + InvalidateRect(bct->hwnd, NULL, TRUE); + } + SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM) hwndDlg); + return 0; + } + break; + case WM_THEMECHANGED: + { + // themed changed, reload theme object + if (bct->bThemed) + LoadTheme(bct); + InvalidateRect(bct->hwnd, NULL, TRUE); // repaint it + break; + } + case WM_SETFONT: + // remember the font so we can use it later + { + bct->hFont = (HFONT) wParam; // maybe we should redraw? + break; + } + case WM_NCPAINT: + case WM_PAINT: + { + PAINTSTRUCT ps; + HDC hdcPaint; + + hdcPaint = BeginPaint(hwndDlg, &ps); + if (hdcPaint) { + PaintWorker(bct, hdcPaint); + EndPaint(hwndDlg, &ps); + } + break; + } + case BM_SETIMAGE: + bct->hIml = 0; + bct->iIcon = 0; + if (wParam == IMAGE_ICON) { + ICONINFO ii; + BITMAP bm; + + if (bct->hIconPrivate) + DestroyIcon(bct->hIconPrivate); + + GetIconInfo((HICON) lParam, &ii); + GetObject(ii.hbmColor, sizeof(bm), &bm); + if (bm.bmWidth > g_cxsmIcon || bm.bmHeight > g_cysmIcon) { + HIMAGELIST hImageList; + hImageList = ImageList_Create(g_cxsmIcon, g_cysmIcon, IsWinVerXPPlus() ? ILC_COLOR32 | ILC_MASK : ILC_COLOR16 | ILC_MASK, 1, 0); + ImageList_AddIcon(hImageList, (HICON) lParam); + bct->hIconPrivate = ImageList_GetIcon(hImageList, 0, ILD_NORMAL); + ImageList_RemoveAll(hImageList); + ImageList_Destroy(hImageList); + bct->hIcon = 0; + } else { + bct->hIcon = (HICON) lParam; + bct->hIconPrivate = 0; + } + + DeleteObject(ii.hbmMask); + DeleteObject(ii.hbmColor); + bct->hBitmap = NULL; + InvalidateRect(bct->hwnd, NULL, TRUE); + } else if (wParam == IMAGE_BITMAP) { + bct->hBitmap = (HBITMAP) lParam; + if (bct->hIconPrivate) + DestroyIcon(bct->hIconPrivate); + bct->hIcon = bct->hIconPrivate = NULL; + InvalidateRect(bct->hwnd, NULL, TRUE); + } + break; + case BM_SETPRIVATEICON: + bct->hIml = 0; + bct->iIcon = 0; { + if (bct->hIconPrivate) + DestroyIcon(bct->hIconPrivate); + bct->hIconPrivate = DuplicateIcon(hInst, (HICON) lParam); + bct->hIcon = 0; + break; + } + case BM_SETIMLICON: + { + if (bct->hIconPrivate) + DestroyIcon(bct->hIconPrivate); + bct->hIml = (HIMAGELIST) wParam; + bct->iIcon = (int) lParam; + bct->hIcon = bct->hIconPrivate = 0; + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + } + case BM_SETCHECK: + if (!bct->pushBtn) + break; + if (wParam == BST_CHECKED) { + bct->pbState = 1; + bct->stateId = PBS_PRESSED; + } else if (wParam == BST_UNCHECKED) { + bct->pbState = 0; + bct->stateId = PBS_NORMAL; + } + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case BM_GETCHECK: + if (bct->pushBtn) { + return bct->pbState ? BST_CHECKED : BST_UNCHECKED; + } + return 0; + case BUTTONSETARROW: + // turn arrow on/off + if (wParam) { + //if (!bct->arrow) bct->arrow = (HICON) LoadImage(g_hInst, MAKEINTRESOURCE(IDI_MINIMIZE), IMAGE_ICON, g_cxsmIcon, g_cysmIcon, 0); + } else { + if (bct->arrow) { + DestroyIcon(bct->arrow); + bct->arrow = NULL; + } + } + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case BUTTONSETDEFAULT: + bct->defbutton = wParam ? 1 : 0; + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case BUTTONSETASPUSHBTN: + bct->pushBtn = 1; + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case BUTTONSETASFLATBTN: + bct->flatBtn = lParam == 0 ? 1 : 0; + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case BUTTONSETASFLATBTN + 10: + bct->bThemed = lParam ? TRUE : FALSE; + break; + case BUTTONADDTOOLTIP: + { + TOOLINFOA ti; + + if (!(char*) wParam) + break; + EnterCriticalSection(&csTips); + if (!hwndToolTips) { + hwndToolTips = CreateWindowExA(WS_EX_TOPMOST, TOOLTIPS_CLASSA, "", WS_POPUP, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(NULL), NULL); + } + ZeroMemory(&ti, sizeof(ti)); + ti.cbSize = sizeof(ti); + ti.uFlags = TTF_IDISHWND; + ti.hwnd = bct->hwnd; + ti.uId = (UINT) bct->hwnd; + if (SendMessage(hwndToolTips, TTM_GETTOOLINFO, 0, (LPARAM) &ti)) { + SendMessage(hwndToolTips, TTM_DELTOOL, 0, (LPARAM) &ti); + } + ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS; + ti.uId = (UINT) bct->hwnd; + ti.lpszText = (char*) wParam; + SendMessageA(hwndToolTips, TTM_ADDTOOLA, 0, (LPARAM) &ti); + LeaveCriticalSection(&csTips); + break; + } + case WM_SETFOCUS: + // set keybord focus and redraw + bct->focus = 1; + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case WM_KILLFOCUS: + // kill focus and redraw + bct->focus = 0; + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case WM_WINDOWPOSCHANGED: + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case WM_ENABLE: + // windows tells us to enable/disable + { + bct->stateId = wParam ? PBS_NORMAL : PBS_DISABLED; + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + } + case WM_MOUSELEAVE: + // faked by the WM_TIMER + { + if (bct->stateId != PBS_DISABLED) { + // don't change states if disabled + bct->stateId = PBS_NORMAL; + InvalidateRect(bct->hwnd, NULL, TRUE); + } + break; + } + case WM_LBUTTONDOWN: + { + if (bct->stateId != PBS_DISABLED) { + // don't change states if disabled + bct->stateId = PBS_PRESSED; + InvalidateRect(bct->hwnd, NULL, TRUE); + } + break; + } + case WM_LBUTTONUP: + { + if (bct->pushBtn) { + if (bct->pbState) + bct->pbState = 0; + else + bct->pbState = 1; + } + if (bct->stateId != PBS_DISABLED) { + // don't change states if disabled + if (msg == WM_LBUTTONUP) + bct->stateId = PBS_HOT; + else + bct->stateId = PBS_NORMAL; + InvalidateRect(bct->hwnd, NULL, TRUE); + } + // Tell your daddy you got clicked. + SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM) hwndDlg); + break; + } + case WM_MOUSEMOVE: + if (bct->stateId == PBS_NORMAL) { + bct->stateId = PBS_HOT; + InvalidateRect(bct->hwnd, NULL, TRUE); + } + // Call timer, used to start cheesy TrackMouseEvent faker + SetTimer(hwndDlg, BUTTON_POLLID, BUTTON_POLLDELAY, NULL); + break; + case WM_TIMER: + // use a timer to check if they have did a mouseout + { + if (wParam == BUTTON_POLLID) { + RECT rc; + POINT pt; + GetWindowRect(hwndDlg, &rc); + GetCursorPos(&pt); + if (!PtInRect(&rc, pt)) { + // mouse must be gone, trigger mouse leave + PostMessage(hwndDlg, WM_MOUSELEAVE, 0, 0L); + KillTimer(hwndDlg, BUTTON_POLLID); + } + } + break; + } + case WM_ERASEBKGND: + return 1; + } + return DefWindowProc(hwndDlg, msg, wParam, lParam); +} diff --git a/plugins/TopToolBar/ClassDiagram1.cd b/plugins/TopToolBar/ClassDiagram1.cd new file mode 100644 index 0000000000..0519ecba6e --- /dev/null +++ b/plugins/TopToolBar/ClassDiagram1.cd @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/plugins/TopToolBar/InternalButtons.c b/plugins/TopToolBar/InternalButtons.c new file mode 100644 index 0000000000..320e8e1d59 --- /dev/null +++ b/plugins/TopToolBar/InternalButtons.c @@ -0,0 +1,436 @@ + +#include "common.h" +#pragma hdrstop + +#define TTBI_GROUPSHOWHIDE "TTBInternal/GroupShowHide" +#define TTBI_SOUNDSONOFF "TTBInternal/SoundsOnOFF" +#define TTBI_OPTIONSBUTT "TTBInternal/OptionsBUTT" +#define TTBI_MAINMENUBUTT "TTBInternal/MainMenuBUTT" +#define TTBI_MINIMIZEBUTT "TTBInternal/MinimizeBUTT" +#define TTBI_FINDADDBUTT "TTBInternal/FindAddBUTT" + +int LoadInternalButtons(); +int UnLoadInternalButtons(); +extern HINSTANCE hInst; + +HANDLE hSettingChangedHook; + +static HBITMAP OnlineUp,OnlineDn,GroupsUp,GroupsDn,SoundsUp; +static HBITMAP SoundsDn,hbOptUp,hbOptDn,testsearch; +static HBITMAP MainMenuUp,MainMenuDn; +static HBITMAP MinimizeUp,MinimizeDn; +static HBITMAP FindUserUp,FindUserDn; + +static int ShowOnline,ShowGroups,SoundsEnabled; +static HANDLE hOnlineBut,hGroupBut,hSoundsBut,hOptionsBut,hMainMenuBut; +static HANDLE hMinimizeBut; +static HANDLE hFindUsers; + +static HANDLE OnSettingChg; + +static HWND hwndContactTree; + +int OnSettingChanging(WPARAM wParam,LPARAM lParam) +{ + if (wParam!=0){return(0);}; + { + DBCONTACTWRITESETTING *dbcws=(DBCONTACTWRITESETTING *)lParam; + if (dbcws==NULL){return(0);}; + + if (!strcmp(dbcws->szModule,"CList")) + { + + if (!strcmp(dbcws->szSetting,"HideOffline")) + { + int val=dbcws->value.bVal; + + //OutputDebugStr("==>TopToolBar HideOffline set it\r\n"); + + CallService(MS_TTB_SETBUTTONSTATE,(WPARAM)hOnlineBut,(LPARAM)(val)?TTBST_PUSHED:TTBST_RELEASED); + + CallService(MS_TTB_SETBUTTONOPTIONS,MAKEWPARAM(TTBO_TIPNAME,hOnlineBut), + (LPARAM)((!val)?Translate("Hide Offline Users"):Translate("Show All Users"))); + + return(0); + }; + + if (!strcmp(dbcws->szSetting,"UseGroups")) + { + int val=dbcws->value.bVal; + //int val=GetWindowLong(hwndContactTree,GWL_STYLE)&CLS_USEGROUPS; + + CallService(MS_TTB_SETBUTTONSTATE,(WPARAM)hGroupBut,(LPARAM)((val)?TTBST_PUSHED:TTBST_RELEASED)); + + return(0); + }; + }; + if (!strcmp(dbcws->szModule,"Skin")) + { + if (!strcmp(dbcws->szSetting,"UseSound")) + { + int val=dbcws->value.bVal; + + CallService(MS_TTB_SETBUTTONSTATE,(WPARAM)hSoundsBut,(LPARAM)(val)?TTBST_PUSHED:TTBST_RELEASED); + + return(0); + }; + + }; + } + return(0); +}; +INT_PTR TTBInternalFindAddButt(WPARAM wParam,LPARAM lParam) +{ + //Sleep(100); + + CallService("FindAdd/FindAddCommand",0,0); + CallService(MS_TTB_SETBUTTONSTATE,(WPARAM)hFindUsers,TTBST_RELEASED); + return(0); +}; + + +INT_PTR TTBInternalMinimizeButt(WPARAM wParam,LPARAM lParam) +{ + Sleep(30); + CallService(MS_TTB_SETBUTTONSTATE,(WPARAM)hMinimizeBut,TTBST_RELEASED); + Sleep(30); + CallService(MS_CLIST_SHOWHIDE,0,0); + return(0); +}; + +INT_PTR TTBInternalMainMenuButt(WPARAM wParam,LPARAM lParam) +{ + POINT pt; + //CallService("Options/OptionsCommand",0,0); + HMENU hMenu=(HMENU)CallService(MS_CLIST_MENUGETMAIN,0,0); +// hMenu=(HMENU)CallService(MS_CLIST_MENUGETSTATUS,0,0); + + GetCursorPos(&pt); + TrackPopupMenu(hMenu,TPM_TOPALIGN|TPM_LEFTALIGN|TPM_RIGHTBUTTON,pt.x,pt.y,0,(HWND)CallService(MS_CLUI_GETHWND,0,0),NULL); + + Sleep(100); + CallService(MS_TTB_SETBUTTONSTATE,(WPARAM)hMainMenuBut,TTBST_RELEASED); + return(0); +}; + +INT_PTR TTBInternalOptionsButt(WPARAM wParam,LPARAM lParam) +{ + CallService("Options/OptionsCommand",0,0); + Sleep(100); + CallService(MS_TTB_SETBUTTONSTATE,(WPARAM)hOptionsBut,TTBST_RELEASED); + return(0); +}; +INT_PTR TTBInternalGroupShowHide(WPARAM wParam,LPARAM lParam) +{ + int newVal=!(GetWindowLong(hwndContactTree,GWL_STYLE)&CLS_USEGROUPS); + DBWriteContactSettingByte(NULL,"CList","UseGroups",(BYTE)newVal); + SendMessage(hwndContactTree,CLM_SETUSEGROUPS,newVal,0); + + /* + CallService(MS_TTB_SETBUTTONOPTIONS,MAKEWPARAM(TTBO_TIPNAME,hGroupBut), + (!newVal)?Translate("Show Groups"):Translate("Hide Groups")); + */ + return(0); +}; +//DBGetContactSettingByte(NULL,"Skin","UseSound",1) + +INT_PTR TTBInternalSoundsOnOff(WPARAM wParam,LPARAM lParam) +{ + int newVal=!(DBGetContactSettingByte(NULL,"Skin","UseSound",1)); + DBWriteContactSettingByte(NULL,"Skin","UseSound",(BYTE)newVal); + CallService(MS_TTB_SETBUTTONOPTIONS,MAKEWPARAM(TTBO_TIPNAME,hSoundsBut), + (LPARAM)((newVal)?Translate("Disable Sounds"):Translate("Enable Sounds"))); + return(0); +}; +int UnLoadInternalButtons() +{ + if (hSettingChangedHook){UnhookEvent(hSettingChangedHook);}; + return(0); +}; + +boolean framesexists=FALSE; +int windhandle; + +LRESULT CALLBACK TestProczzz(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) { + case WM_CREATE: + SetTimer(hwnd,0,100,0); + return 0; + case WM_TIMER: + InvalidateRect(hwnd,NULL,TRUE); + RedrawWindow(hwnd,NULL,NULL,0); + break; + case WM_PAINT: + { + PAINTSTRUCT lp; + HDC hdc; + hdc=BeginPaint(hwnd,&lp); + if (hdc) + { + char buf[255]; + wsprintf((LPSTR)&buf,"%d",GetTickCount()); + TextOut(hdc,4,4,(LPCTSTR)&buf,strlen(buf)); + EndPaint(hwnd,&lp); + } + return(0); + } + + } + + + return(DefWindowProc(hwnd, msg, wParam, lParam)); +}; + +boolean first=TRUE; +char pluginname[]="SimpleClassName"; + +INT_PTR test(WPARAM wParam,LPARAM lParam) +{ +if (first) +{ + WNDCLASS wndclass; + int r; + + wndclass.style = 0; + wndclass.lpfnWndProc = TestProczzz; + wndclass.cbClsExtra = 0; + wndclass.cbWndExtra = 0; + wndclass.hInstance = hInst; + wndclass.hIcon = NULL; + wndclass.hCursor = LoadCursor (NULL, IDC_ARROW); + wndclass.hbrBackground = (HBRUSH)(COLOR_3DFACE+1);//NULL;//(HBRUSH)(COLOR_3DFACE+1); + wndclass.lpszMenuName = NULL; + wndclass.lpszClassName = pluginname; + r=RegisterClass(&wndclass); + first=FALSE; +}; + +if (framesexists) +{ + CallService(MS_CLIST_FRAMES_REMOVEFRAME,(WPARAM)windhandle,0); + windhandle=0; + framesexists=FALSE; +}else +{ + CLISTFrame Frame; + //int font; + + HWND pluginwind; + pluginwind=CreateWindow(pluginname,pluginname, + WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN, + 0,0,0,0,(HWND)CallService(MS_CLUI_GETHWND,0,0),NULL,hInst,NULL); + + //font=SendMessage(parent,WM_GETFONT,0,0); + //SendMessage(pluginwind,WM_SETFONT,font,0); + + // + memset(&Frame,0,sizeof(Frame)); + Frame.name=(char *)malloc(255); + memset(Frame.name,0,255); + memcpy(Frame.name,pluginname,sizeof(pluginname)); + Frame.cbSize=sizeof(Frame); + Frame.hWnd=pluginwind; + Frame.align=alTop; + Frame.Flags=F_VISIBLE; + Frame.height=18; + + windhandle=CallService(MS_CLIST_FRAMES_ADDFRAME,(WPARAM)&Frame,0); + framesexists=TRUE; + //free(Frame.name); +}; +return(0); +}; + +int LoadInternalButtons(HWND hwnd) +{ + TTBButtonV2 ttb; + + hwndContactTree=hwnd; + hSettingChangedHook=0; + CreateServiceFunction(TTBI_GROUPSHOWHIDE,TTBInternalGroupShowHide); + CreateServiceFunction(TTBI_SOUNDSONOFF,TTBInternalSoundsOnOff); + + CreateServiceFunction(TTBI_OPTIONSBUTT,TTBInternalOptionsButt); + CreateServiceFunction(TTBI_MAINMENUBUTT,TTBInternalMainMenuButt); + + CreateServiceFunction(TTBI_MINIMIZEBUTT,TTBInternalMinimizeButt); + CreateServiceFunction(TTBI_FINDADDBUTT,TTBInternalFindAddButt); + + CreateServiceFunction("TEST1",test); + + + //ShowOnline=(GetWindowLong(hwndContactTree,GWL_STYLE)&CLS_HIDEOFFLINE); + ShowOnline=DBGetContactSettingByte(NULL,"CList","HideOffline",0); + //ShowGroups=(GetWindowLong(hwndContactTree,GWL_STYLE)&CLS_USEGROUPS); + ShowGroups=DBGetContactSettingByte(NULL,"CList","UseGroups",2); + SoundsEnabled=DBGetContactSettingByte(NULL,"Skin","UseSound",1); + +/* + OnlineDn=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_ONLINEDN)); + OnlineUp=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_ONLINEUP)); + + hbOptUp=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_CPANELUP)); + hbOptDn=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_CPANELDN)); + + MainMenuUp=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_MENUUP)); + MainMenuDn=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_MENUDN)); + //MainMenuDn=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_SEP)); + + MinimizeUp=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_MINIMIZEUP)); + MinimizeDn=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_MINIMIZEDN)); + + FindUserUp=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_FINDUSERUP)); + FindUserDn=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_FINDUSERDN)); + + + //OnlineDn=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_TESTBITMAP)); + //OnlineUp=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_TESTBITMAP)); +// testsearch=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_SEARCHTEST)); + + GroupsDn=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_GROUPDN)); + GroupsUp=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_GROUPUP)); + SoundsDn=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_SOUNDSDN)); + SoundsUp=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_SOUNDSUP)); +*/ + //hbOptions=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_OPTIONS)); + + memset(&ttb,0,sizeof(ttb)); + ttb.cbSize=sizeof(ttb); + //ttb.hbBitmapDown=OnlineDn; + //ttb.hbBitmapUp=OnlineUp; + ttb.hIconUp=LoadImage(hInst,MAKEINTRESOURCE(IDI_SHOWONLINEUP),IMAGE_ICON,16,16,LR_DEFAULTCOLOR); + ttb.hIconDn=LoadImage(hInst,MAKEINTRESOURCE(IDI_SHOWONLINEDN),IMAGE_ICON,16,16,LR_DEFAULTCOLOR); + + + + ttb.dwFlags=(ShowOnline?TTBBF_PUSHED:0)|TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP; + ttb.pszServiceDown=MS_CLIST_SETHIDEOFFLINE; + ttb.pszServiceUp=MS_CLIST_SETHIDEOFFLINE; + //ttb.lParam=0; + ttb.wParamUp=-1; + ttb.wParamDown=-1; + ttb.name="Show only Online Users"; + hOnlineBut=(HANDLE)TTBAddButton(&ttb,0); + + memset(&ttb,0,sizeof(ttb)); + ttb.cbSize=sizeof(ttb); + //ttb.hbBitmapDown=GroupsDn; + //ttb.hbBitmapUp=GroupsUp; + + ttb.hIconUp=LoadImage(hInst,MAKEINTRESOURCE(IDI_GROUPSUP),IMAGE_ICON,16,16,LR_DEFAULTCOLOR); + ttb.hIconDn=LoadImage(hInst,MAKEINTRESOURCE(IDI_GROUPSDN),IMAGE_ICON,16,16,LR_DEFAULTCOLOR); + + ttb.dwFlags=(ShowGroups?TTBBF_PUSHED:0)|TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP; + ttb.pszServiceDown=TTBI_GROUPSHOWHIDE; + ttb.pszServiceUp=TTBI_GROUPSHOWHIDE; + ttb.name="Groups On/Off"; + hGroupBut=(HANDLE)TTBAddButton(&ttb,0); + + memset(&ttb,0,sizeof(ttb)); + ttb.cbSize=sizeof(ttb); + //ttb.hbBitmapDown=SoundsDn; + //ttb.hbBitmapUp=SoundsUp; + ttb.hIconUp=LoadImage(hInst,MAKEINTRESOURCE(IDI_SOUNDUP),IMAGE_ICON,16,16,LR_DEFAULTCOLOR); + ttb.hIconDn=LoadImage(hInst,MAKEINTRESOURCE(IDI_SOUNDDN),IMAGE_ICON,16,16,LR_DEFAULTCOLOR); + + ttb.dwFlags=(SoundsEnabled?TTBBF_PUSHED:0)|TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP; + ttb.pszServiceDown=TTBI_SOUNDSONOFF; + ttb.pszServiceUp=TTBI_SOUNDSONOFF; + ttb.name="Sounds Enable/Disable"; + hSoundsBut=(HANDLE)TTBAddButton(&ttb,0); +/* + memset(&ttb,0,sizeof(ttb)); + ttb.hbBitmapDown=hbOptions; + ttb.hbBitmapUp=hbOptions; + ttb.dwFlags=TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP|TTBBF_DRAWBORDER; + ttb.pszServiceDown="Options/OptionsCommand"; + ttb.pszServiceUp="Options/OptionsCommand"; + ttb.lParam=0; + ttb.wParam=0; +// hOptionsBut=TTBAddButton(&ttb,0); +*/ + memset(&ttb,0,sizeof(ttb)); + ttb.cbSize=sizeof(ttb); + //ttb.hbBitmapDown=hbOptDn; + //ttb.hbBitmapUp=hbOptUp; + ttb.hIconUp=LoadImage(hInst,MAKEINTRESOURCE(IDI_OPTIONSUP),IMAGE_ICON,16,16,LR_DEFAULTCOLOR); + ttb.hIconDn=LoadImage(hInst,MAKEINTRESOURCE(IDI_OPTIONSDN),IMAGE_ICON,16,16,LR_DEFAULTCOLOR); + + ttb.dwFlags=TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP; + ttb.pszServiceDown=TTBI_OPTIONSBUTT; + ttb.pszServiceUp=TTBI_OPTIONSBUTT; + ttb.name="Show Options Page"; + hOptionsBut=(HANDLE)TTBAddButton(&ttb,0); + + memset(&ttb,0,sizeof(ttb)); + ttb.cbSize=sizeof(ttb); + //ttb.hbBitmapDown=MinimizeDn; + //ttb.hbBitmapUp=MinimizeUp; + ttb.hIconUp=LoadImage(hInst,MAKEINTRESOURCE(IDI_MINIMIZEUP),IMAGE_ICON,16,16,LR_DEFAULTCOLOR); + ttb.hIconDn=LoadImage(hInst,MAKEINTRESOURCE(IDI_MINIMIZEDN),IMAGE_ICON,16,16,LR_DEFAULTCOLOR); + + ttb.dwFlags=TTBBF_VISIBLE; + ttb.pszServiceDown=TTBI_MINIMIZEBUTT; + ttb.pszServiceUp=TTBI_MINIMIZEBUTT; + ttb.name="Minimize Button"; + hMinimizeBut=(HANDLE)TTBAddButton(&ttb,0); + + memset(&ttb,0,sizeof(ttb)); + ttb.cbSize=sizeof(ttb); + //ttb.hbBitmapDown=FindUserDn; + //ttb.hbBitmapUp=FindUserUp; + ttb.hIconUp=LoadImage(hInst,MAKEINTRESOURCE(IDI_FINDADDUP),IMAGE_ICON,16,16,LR_DEFAULTCOLOR); + ttb.hIconDn=LoadImage(hInst,MAKEINTRESOURCE(IDI_FINDADDDN),IMAGE_ICON,16,16,LR_DEFAULTCOLOR); + + ttb.dwFlags=TTBBF_VISIBLE; + ttb.pszServiceDown=TTBI_FINDADDBUTT; + ttb.pszServiceUp=TTBI_FINDADDBUTT; + ttb.name="Find/Add Contacts"; + hFindUsers=(HANDLE)TTBAddButton(&ttb,0); + + + + memset(&ttb,0,sizeof(ttb)); + ttb.cbSize=sizeof(ttb); + //ttb.hbBitmapUp=MainMenuUp; + //ttb.hbBitmapDown=MainMenuDn; + ttb.hIconUp=LoadImage(hInst,MAKEINTRESOURCE(IDI_MIRANDAUP),IMAGE_ICON,16,16,LR_DEFAULTCOLOR); + ttb.hIconDn=LoadImage(hInst,MAKEINTRESOURCE(IDI_MIRANDADN),IMAGE_ICON,16,16,LR_DEFAULTCOLOR); + + ttb.dwFlags=TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP; + ttb.pszServiceDown=TTBI_MAINMENUBUTT; + ttb.pszServiceUp=TTBI_MAINMENUBUTT; + ttb.name="Show Main Menu"; + hMainMenuBut=(HANDLE)TTBAddButton(&ttb,0); + + + memset(&ttb,0,sizeof(ttb)); + ttb.cbSize=sizeof(ttb); + //ttb.hbBitmapUp=MainMenuUp; + //ttb.hbBitmapDown=MainMenuDn; + ttb.dwFlags=TTBBF_VISIBLE; + ttb.pszServiceDown="TEST1"; + ttb.pszServiceUp="TEST1"; + ttb.name="Test"; + //TTBAddButton(&ttb,0); + + CallService(MS_TTB_SETBUTTONOPTIONS,MAKEWPARAM(TTBO_TIPNAME,hOnlineBut), + (LPARAM)((ShowOnline)?Translate("Hide Offline Users"):Translate("Show All Users"))); + + CallService(MS_TTB_SETBUTTONOPTIONS,MAKEWPARAM(TTBO_TIPNAME,hGroupBut), + (LPARAM)((ShowGroups)?Translate("Hide Groups"):Translate("Show Groups"))); + + CallService(MS_TTB_SETBUTTONOPTIONS,MAKEWPARAM(TTBO_TIPNAME,hSoundsBut), + (LPARAM)((SoundsEnabled)?Translate("Disable Sounds"):Translate("Enable Sounds"))); + + CallService(MS_TTB_SETBUTTONOPTIONS,MAKEWPARAM(TTBO_TIPNAME,hOptionsBut), + (LPARAM)Translate("Show Options")); + + //OutputDebugStr("==>TopToolBar setted Hook for ME_DB_CONTACT_SETTINGCHANGED\r\n"); + //hSettingChangedHook=HookEvent(ME_DB_CONTACT_SETTINGCHANGED,OnSettingChanging); + //OutputDebugStr("==>TopToolBar setted Hook for ME_DB_CONTACT_SETTINGCHANGED Done\r\n"); + + return(0); + +}; \ No newline at end of file diff --git a/plugins/TopToolBar/TopToolBar.sln b/plugins/TopToolBar/TopToolBar.sln new file mode 100644 index 0000000000..4d6ba7100e --- /dev/null +++ b/plugins/TopToolBar/TopToolBar.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TopToolBar", "TopToolBar.vcxproj", "{ECE691D0-BFB3-483B-A699-084269EFCE89}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {ECE691D0-BFB3-483B-A699-084269EFCE89}.Debug|Win32.ActiveCfg = Debug|Win32 + {ECE691D0-BFB3-483B-A699-084269EFCE89}.Debug|Win32.Build.0 = Debug|Win32 + {ECE691D0-BFB3-483B-A699-084269EFCE89}.Debug|x64.ActiveCfg = Debug|x64 + {ECE691D0-BFB3-483B-A699-084269EFCE89}.Debug|x64.Build.0 = Debug|x64 + {ECE691D0-BFB3-483B-A699-084269EFCE89}.Release|Win32.ActiveCfg = Release|Win32 + {ECE691D0-BFB3-483B-A699-084269EFCE89}.Release|Win32.Build.0 = Release|Win32 + {ECE691D0-BFB3-483B-A699-084269EFCE89}.Release|x64.ActiveCfg = Release|x64 + {ECE691D0-BFB3-483B-A699-084269EFCE89}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/plugins/TopToolBar/TopToolBar.vcxproj b/plugins/TopToolBar/TopToolBar.vcxproj new file mode 100644 index 0000000000..0609a5725d --- /dev/null +++ b/plugins/TopToolBar/TopToolBar.vcxproj @@ -0,0 +1,335 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {ECE691D0-BFB3-483B-A699-084269EFCE89} + + + + DynamicLibrary + false + MultiByte + true + + + DynamicLibrary + false + MultiByte + true + + + DynamicLibrary + false + MultiByte + + + DynamicLibrary + false + MultiByte + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)64\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)64\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + false + false + true + true + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Win32 + .\Debug/TopToolBar.tlb + + + + + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;TOPTOOLBAR_EXPORTS;%(PreprocessorDefinitions) + true + EnableFastChecks + true + EditAndContinue + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + MultiThreadedDebug + + + _DEBUG;%(PreprocessorDefinitions) + 0x0419 + ..\..\include\msapi + + + comctl32.lib;%(AdditionalDependencies) + true + true + 0x1b200000 + $(IntDir)$(TargetName).lib + MachineX86 + + + true + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + .\Debug/TopToolBar.tlb + + + + + Disabled + WIN64;_DEBUG;_WINDOWS;_USRDLL;TOPTOOLBAR_EXPORTS;%(PreprocessorDefinitions) + EnableFastChecks + true + ProgramDatabase + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + MultiThreadedDebug + + + _DEBUG;%(PreprocessorDefinitions) + 0x0419 + ..\..\include\msapi + + + comctl32.lib;%(AdditionalDependencies) + true + true + 0x1b200000 + $(IntDir)$(TargetName).lib + + + true + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + .\Release/TopToolBar.tlb + + + + + Full + OnlyExplicitInline + WIN32;NDEBUG;_WINDOWS;_USRDLL;TOPTOOLBAR_EXPORTS;%(PreprocessorDefinitions) + true + true + Level3 + true + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + Size + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + ..\..\include\msapi + + + comctl32.lib;%(AdditionalDependencies) + true + 0x1b200000 + $(IntDir)$(TargetName).lib + MachineX86 + true + true + true + + + true + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + .\Release/TopToolBar.tlb + + + + + Full + OnlyExplicitInline + WIN64;NDEBUG;_WINDOWS;_USRDLL;TOPTOOLBAR_EXPORTS;%(PreprocessorDefinitions) + true + true + Level3 + true + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + Size + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + ..\..\include\msapi + + + comctl32.lib;%(AdditionalDependencies) + true + 0x1b200000 + $(IntDir)$(TargetName).lib + true + true + true + + + true + + + + + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + + + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + + + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + + + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + + + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + + + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + + + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + + + + + + \ No newline at end of file diff --git a/plugins/TopToolBar/TopToolBar.vcxproj.filters b/plugins/TopToolBar/TopToolBar.vcxproj.filters new file mode 100644 index 0000000000..f70b2e4a25 --- /dev/null +++ b/plugins/TopToolBar/TopToolBar.vcxproj.filters @@ -0,0 +1,184 @@ + + + + + {7706e6ca-cf12-4f40-8864-82916b4669c8} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {872b8e16-3822-4f40-8957-4daf9343eb99} + h;hpp;hxx;hm;inl + + + {fbadd592-e14c-4abf-bf9e-5f2b3b808d64} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source 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 + + + 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 + + + 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 + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/plugins/TopToolBar/_button.c b/plugins/TopToolBar/_button.c new file mode 100644 index 0000000000..6998efb409 --- /dev/null +++ b/plugins/TopToolBar/_button.c @@ -0,0 +1,515 @@ +/* +Miranda IM +Copyright (C) 2002 Robert Rainwater + +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. +*/ +#include "common.h" + +// TODO: +// - Support for bitmap buttons (simple call to DrawIconEx()) + +static LRESULT CALLBACK MButtonWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); + +typedef struct { + HWND hwnd; + int stateId; // button state + int focus; // has focus (1 or 0) + HFONT hFont; // font + HICON arrow; // uses down arrow + int defbutton; // default button + HICON hIcon; + HBITMAP hBitmap; + int pushBtn; + int pbState; + HANDLE hThemeButton; + HANDLE hThemeToolbar; + char cHot; + int flatBtn; +} MButtonCtrl; + + +// External theme methods and properties +static HMODULE themeAPIHandle = NULL; // handle to uxtheme.dll +static HANDLE (WINAPI *MyOpenThemeData)(HWND,LPCWSTR); +static HRESULT (WINAPI *MyCloseThemeData)(HANDLE); +static BOOL (WINAPI *MyIsThemeBackgroundPartiallyTransparent)(HANDLE,int,int); +static HRESULT (WINAPI *MyDrawThemeParentBackground)(HWND,HDC,RECT *); +static HRESULT (WINAPI *MyDrawThemeBackground)(HANDLE,HDC,int,int,const RECT *,const RECT *); +static HRESULT (WINAPI *MyDrawThemeText)(HANDLE,HDC,int,int,LPCWSTR,int,DWORD,DWORD,const RECT *); + +static CRITICAL_SECTION csTips; +static HWND hwndToolTips = NULL; + +int UnloadButtonModule(WPARAM wParam, LPARAM lParam) { + DeleteCriticalSection(&csTips); + return 0; +} + +int LoadButtonModule(void) { + WNDCLASSEX wc; + + ZeroMemory(&wc, sizeof(wc)); + wc.cbSize = sizeof(wc); + wc.lpszClassName = MYMIRANDABUTTONCLASS; + wc.lpfnWndProc = MButtonWndProc; + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.cbWndExtra = sizeof(MButtonCtrl*); + wc.hbrBackground = 0; + wc.style = CS_GLOBALCLASS; + RegisterClassEx(&wc); + InitializeCriticalSection(&csTips); + HookEvent(ME_SYSTEM_SHUTDOWN, UnloadButtonModule); + return 0; +} + +// Used for our own cheap TrackMouseEvent +#define BUTTON_POLLID 100 +#define BUTTON_POLLDELAY 50 + +#define MGPROC(x) GetProcAddress(themeAPIHandle,x) +static int ThemeSupport() { + if (IsWinVerXPPlus()) { + if (!themeAPIHandle) { + themeAPIHandle = GetModuleHandle("uxtheme"); + if (themeAPIHandle) { + MyOpenThemeData = (HANDLE (WINAPI *)(HWND,LPCWSTR))MGPROC("OpenThemeData"); + MyCloseThemeData = (HRESULT (WINAPI *)(HANDLE))MGPROC("CloseThemeData"); + MyIsThemeBackgroundPartiallyTransparent = (BOOL (WINAPI *)(HANDLE,int,int))MGPROC("IsThemeBackgroundPartiallyTransparent"); + MyDrawThemeParentBackground = (HRESULT (WINAPI *)(HWND,HDC,RECT *))MGPROC("DrawThemeParentBackground"); + MyDrawThemeBackground = (HRESULT (WINAPI *)(HANDLE,HDC,int,int,const RECT *,const RECT *))MGPROC("DrawThemeBackground"); + MyDrawThemeText = (HRESULT (WINAPI *)(HANDLE,HDC,int,int,LPCWSTR,int,DWORD,DWORD,const RECT *))MGPROC("DrawThemeText"); + } + } + // Make sure all of these methods are valid (i would hope either all or none work) + if (MyOpenThemeData + &&MyCloseThemeData + &&MyIsThemeBackgroundPartiallyTransparent + &&MyDrawThemeParentBackground + &&MyDrawThemeBackground + &&MyDrawThemeText) { + return 1; + } + } + return 0; +} + +static void DestroyTheme(MButtonCtrl *ctl) { + if (ThemeSupport()) { + if (ctl->hThemeButton) { + MyCloseThemeData(ctl->hThemeButton); + ctl->hThemeButton = NULL; + } + if (ctl->hThemeToolbar) { + MyCloseThemeData(ctl->hThemeToolbar); + ctl->hThemeToolbar = NULL; + } + } +} + +static void LoadTheme(MButtonCtrl *ctl) { + if (ThemeSupport()) { + DestroyTheme(ctl); + ctl->hThemeButton = MyOpenThemeData(ctl->hwnd,L"BUTTON"); + ctl->hThemeToolbar = MyOpenThemeData(ctl->hwnd,L"TOOLBAR"); + } +} + +static TBStateConvert2Flat(int state) { + switch(state) { + case PBS_NORMAL: return TS_NORMAL; + case PBS_HOT: return TS_HOT; + case PBS_PRESSED: return TS_PRESSED; + case PBS_DISABLED: return TS_DISABLED; + case PBS_DEFAULTED: return TS_NORMAL; + } + return TS_NORMAL; +} + +static void PaintWorker(MButtonCtrl *ctl, HDC hdcPaint) { + if (hdcPaint) { + RECT rcClient; + GetClientRect(ctl->hwnd, &rcClient); + + // If its a push button, check to see if it should stay pressed + if (ctl->pushBtn && ctl->pbState) ctl->stateId = PBS_PRESSED; + + // Draw the flat button + if (ctl->flatBtn) { + if (ctl->hThemeToolbar) { + int state = IsWindowEnabled(ctl->hwnd)?(ctl->stateId==PBS_NORMAL&&ctl->defbutton?PBS_DEFAULTED:ctl->stateId):PBS_DISABLED; + if (MyIsThemeBackgroundPartiallyTransparent(ctl->hThemeToolbar, TP_BUTTON, TBStateConvert2Flat(state))) { + MyDrawThemeParentBackground(ctl->hwnd, hdcPaint, &rcClient); + } + MyDrawThemeBackground(ctl->hThemeToolbar, hdcPaint, TP_BUTTON, TBStateConvert2Flat(state), &rcClient, &rcClient); + } + else { + HBRUSH hbr; + + if (ctl->stateId==PBS_PRESSED||ctl->stateId==PBS_HOT) + hbr = GetSysColorBrush(COLOR_3DLIGHT); + else { + HDC dc; + HWND hwndParent; + + hwndParent = GetParent(ctl->hwnd); + dc=GetDC(hwndParent); + hbr = (HBRUSH)SendMessage(hwndParent, WM_CTLCOLORDLG, (WPARAM)dc, (LPARAM)hwndParent); + ReleaseDC(hwndParent,dc); + } + if (hbr) { + FillRect(hdcPaint, &rcClient, hbr); + DeleteObject(hbr); + } + if (ctl->stateId==PBS_HOT||ctl->focus) { + if (ctl->pbState) + DrawEdge(hdcPaint,&rcClient, EDGE_ETCHED,BF_RECT|BF_SOFT); + else DrawEdge(hdcPaint,&rcClient, BDR_RAISEDOUTER,BF_RECT|BF_SOFT|BF_FLAT); + } + else if (ctl->stateId==PBS_PRESSED) + DrawEdge(hdcPaint, &rcClient, BDR_SUNKENOUTER,BF_RECT|BF_SOFT); + } + } + else { + // Draw background/border + if (ctl->hThemeButton) { + int state = IsWindowEnabled(ctl->hwnd)?(ctl->stateId==PBS_NORMAL&&ctl->defbutton?PBS_DEFAULTED:ctl->stateId):PBS_DISABLED; + if (MyIsThemeBackgroundPartiallyTransparent(ctl->hThemeButton, BP_PUSHBUTTON, state)) { + MyDrawThemeParentBackground(ctl->hwnd, hdcPaint, &rcClient); + } + MyDrawThemeBackground(ctl->hThemeButton, hdcPaint, BP_PUSHBUTTON, state, &rcClient, &rcClient); + } + else { + UINT uState = DFCS_BUTTONPUSH|((ctl->stateId==PBS_HOT)?DFCS_HOT:0)|((ctl->stateId == PBS_PRESSED)?DFCS_PUSHED:0); + if (ctl->defbutton&&ctl->stateId==PBS_NORMAL) uState |= DLGC_DEFPUSHBUTTON; + DrawFrameControl(hdcPaint, &rcClient, DFC_BUTTON, uState); + } + + // Draw focus rectangle if button has focus + if (ctl->focus) { + RECT focusRect = rcClient; + InflateRect(&focusRect, -3, -3); + DrawFocusRect(hdcPaint, &focusRect); + } + } + + // If we have an icon or a bitmap, ignore text and only draw the image on the button + if (ctl->hIcon) { + int ix = (rcClient.right-rcClient.left)/2 - (GetSystemMetrics(SM_CXSMICON)/2); + int iy = (rcClient.bottom-rcClient.top)/2 - (GetSystemMetrics(SM_CYSMICON)/2); + if (ctl->stateId == PBS_PRESSED) { + ix++; + iy++; + } + DrawState(hdcPaint,NULL,NULL,(LPARAM)ctl->hIcon,0,ix,iy,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),IsWindowEnabled(ctl->hwnd)?DST_ICON:DST_ICON|DSS_DISABLED); + } + else if (ctl->hBitmap) { + BITMAP bminfo; + int ix,iy; + + GetObject(ctl->hBitmap, sizeof(bminfo), &bminfo); + ix = (rcClient.right-rcClient.left)/2 - (bminfo.bmWidth/2); + iy = (rcClient.bottom-rcClient.top)/2 - (bminfo.bmHeight/2); + if (ctl->stateId == PBS_PRESSED) { + ix++; + iy++; + } + DrawState(hdcPaint,NULL,NULL,(LPARAM)ctl->hBitmap,0,ix,iy,bminfo.bmWidth,bminfo.bmHeight,IsWindowEnabled(ctl->hwnd)?DST_BITMAP:DST_BITMAP|DSS_DISABLED); + } + else if (GetWindowTextLength(ctl->hwnd)) { + // Draw the text and optinally the arrow + char szText[MAX_PATH]; + SIZE sz; + RECT rcText; + + CopyRect(&rcText, &rcClient); + GetWindowText(ctl->hwnd, szText, sizeof(szText)); + SetBkMode(hdcPaint, TRANSPARENT); + SelectObject(hdcPaint, ctl->hFont); + // XP w/themes doesn't used the glossy disabled text. Is it always using COLOR_GRAYTEXT? Seems so. + SetTextColor(hdcPaint, IsWindowEnabled(ctl->hwnd)||!ctl->hThemeButton?GetSysColor(COLOR_BTNTEXT):GetSysColor(COLOR_GRAYTEXT)); + GetTextExtentPoint32(hdcPaint, szText, lstrlen(szText), &sz); + if (ctl->cHot) { + SIZE szHot; + + GetTextExtentPoint32(hdcPaint, "&", 1, &szHot); + sz.cx -= szHot.cx; + } + if (ctl->arrow) { + DrawState(hdcPaint,NULL,NULL,(LPARAM)ctl->arrow,0,rcClient.right-rcClient.left-5-GetSystemMetrics(SM_CXSMICON)+(!ctl->hThemeButton&&ctl->stateId==PBS_PRESSED?1:0),(rcClient.bottom-rcClient.top)/2-GetSystemMetrics(SM_CYSMICON)/2+(!ctl->hThemeButton&&ctl->stateId==PBS_PRESSED?1:0),GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),IsWindowEnabled(ctl->hwnd)?DST_ICON:DST_ICON|DSS_DISABLED); + } + SelectObject(hdcPaint, ctl->hFont); + DrawState(hdcPaint,NULL,NULL,(LPARAM)szText,0,(rcText.right-rcText.left-sz.cx)/2+(!ctl->hThemeButton&&ctl->stateId==PBS_PRESSED?1:0),ctl->hThemeButton?(rcText.bottom-rcText.top-sz.cy)/2:(rcText.bottom-rcText.top-sz.cy)/2-(ctl->stateId==PBS_PRESSED?0:1),sz.cx,sz.cy,IsWindowEnabled(ctl->hwnd)||ctl->hThemeButton?DST_PREFIXTEXT|DSS_NORMAL:DST_PREFIXTEXT|DSS_DISABLED); + } + } +} + +static LRESULT CALLBACK MButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { + MButtonCtrl* bct = (MButtonCtrl *)GetWindowLong(hwndDlg, 0); + switch(msg) { + case WM_NCCREATE: + { + SetWindowLong(hwndDlg, GWL_STYLE, GetWindowLong(hwndDlg, GWL_STYLE)|BS_OWNERDRAW); + bct = malloc(sizeof(MButtonCtrl)); + if (bct==NULL) return FALSE; + bct->hwnd = hwndDlg; + bct->stateId = PBS_NORMAL; + bct->focus = 0; + bct->hFont = GetStockObject(DEFAULT_GUI_FONT); + bct->arrow = NULL; + bct->defbutton = 0; + bct->hIcon = NULL; + bct->hBitmap = NULL; + bct->pushBtn = 0; + bct->pbState = 0; + bct->hThemeButton = NULL; + bct->hThemeToolbar = NULL; + bct->cHot = 0; + bct->flatBtn = 0; + LoadTheme(bct); + SetWindowLong(hwndDlg, 0, (LONG)bct); + if (((CREATESTRUCT *)lParam)->lpszName) SetWindowText(hwndDlg, ((CREATESTRUCT *)lParam)->lpszName); + return TRUE; + } + case WM_DESTROY: + { + if (bct) { + EnterCriticalSection(&csTips); + if (hwndToolTips) { + TOOLINFO ti; + + ZeroMemory(&ti, sizeof(ti)); + ti.cbSize = sizeof(ti); + ti.uFlags = TTF_IDISHWND; + ti.hwnd = bct->hwnd; + ti.uId = (UINT)bct->hwnd; + if (SendMessage(hwndToolTips, TTM_GETTOOLINFO, 0, (LPARAM)&ti)) { + SendMessage(hwndToolTips, TTM_DELTOOL, 0, (LPARAM)&ti); + } + if (SendMessage(hwndToolTips, TTM_GETTOOLCOUNT, 0, (LPARAM)&ti)==0) { + DestroyWindow(hwndToolTips); + hwndToolTips = NULL; + } + } + LeaveCriticalSection(&csTips); + DestroyTheme(bct); + free(bct); + } + SetWindowLong(hwndDlg,0,(LONG)NULL); + break; // DONT! fall thru + } + case WM_SETTEXT: + { + bct->cHot = 0; + if ((char*)lParam) { + char *tmp = (char*)lParam; + while (*tmp) { + if (*tmp=='&' && *(tmp+1)) { + bct->cHot = tolower(*(tmp+1)); + break; + } + tmp++; + } + InvalidateRect(bct->hwnd, NULL, TRUE); + } + break; + } + case WM_SYSKEYUP: + if (bct->stateId!=PBS_DISABLED && bct->cHot && bct->cHot == tolower((int)wParam)) { + if (bct->pushBtn) { + if (bct->pbState) bct->pbState = 0; + else bct->pbState = 1; + InvalidateRect(bct->hwnd, NULL, TRUE); + } + SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM)hwndDlg); + return 0; + } + break; + case WM_THEMECHANGED: { + // themed changed, reload theme object + LoadTheme(bct); + InvalidateRect(bct->hwnd, NULL, TRUE); // repaint it + break; + } + case WM_SETFONT: // remember the font so we can use it later + { + bct->hFont = (HFONT)wParam; // maybe we should redraw? + break; + } + case WM_PAINT: + { + PAINTSTRUCT ps; + HDC hdcPaint; + + hdcPaint = BeginPaint(hwndDlg, &ps); + if (hdcPaint) { + PaintWorker(bct, hdcPaint); + EndPaint(hwndDlg, &ps); + } + break; + } + case BM_SETIMAGE: + if (wParam == IMAGE_ICON) { + bct->hIcon = (HICON)lParam; + bct->hBitmap = NULL; + InvalidateRect(bct->hwnd, NULL, TRUE); + } + else if (wParam == IMAGE_BITMAP) { + bct->hBitmap = (HBITMAP)lParam; + bct->hIcon = NULL; + InvalidateRect(bct->hwnd, NULL, TRUE); + } + break; + case BM_SETCHECK: + if (!bct->pushBtn) break; + if (wParam == BST_CHECKED) { + bct->pbState = 1; + bct->stateId = PBS_PRESSED; + } + else if (wParam == BST_UNCHECKED) { + bct->pbState = 0; + bct->stateId = PBS_NORMAL; + } + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case BM_GETCHECK: + if (bct->pushBtn) { + return bct->pbState?BST_CHECKED:BST_UNCHECKED; + } + return 0; + case BUTTONSETARROW: // turn arrow on/off + if (wParam) { + //if (!bct->arrow) + //bct->arrow = (HICON)LoadImage(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_DOWNARROW),IMAGE_ICON,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),0); + } + else { + if (bct->arrow) { + DestroyIcon(bct->arrow); + bct->arrow = NULL; + } + } + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case BUTTONSETDEFAULT: + bct->defbutton = wParam?1:0; + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case BUTTONSETASPUSHBTN: + bct->pushBtn = 1; + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case BUTTONSETASFLATBTN: + bct->flatBtn = 1; + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case BUTTONADDTOOLTIP: + { + TOOLINFO ti; + + if (!(char*)wParam) break; + EnterCriticalSection(&csTips); + if (!hwndToolTips) { + hwndToolTips = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, "", WS_POPUP, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(NULL), NULL); + } + ZeroMemory(&ti, sizeof(ti)); + ti.cbSize = sizeof(ti); + ti.uFlags = TTF_IDISHWND; + ti.hwnd = bct->hwnd; + ti.uId = (UINT)bct->hwnd; + if (SendMessage(hwndToolTips, TTM_GETTOOLINFO, 0, (LPARAM)&ti)) { + SendMessage(hwndToolTips, TTM_DELTOOL, 0, (LPARAM)&ti); + } + ti.uFlags = TTF_IDISHWND|TTF_SUBCLASS; + ti.uId = (UINT)bct->hwnd; + ti.lpszText=(char*)wParam; + SendMessage(hwndToolTips,TTM_ADDTOOL,0,(LPARAM)&ti); + LeaveCriticalSection(&csTips); + break; + } + case WM_SETFOCUS: // set keybord focus and redraw + bct->focus = 1; + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case WM_KILLFOCUS: // kill focus and redraw + bct->focus = 0; + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case WM_WINDOWPOSCHANGED: + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case WM_ENABLE: // windows tells us to enable/disable + { + bct->stateId = wParam?PBS_NORMAL:PBS_DISABLED; + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + } + case WM_MOUSELEAVE: // faked by the WM_TIMER + { + if (bct->stateId!=PBS_DISABLED) { // don't change states if disabled + bct->stateId = PBS_NORMAL; + InvalidateRect(bct->hwnd, NULL, TRUE); + } + break; + } + case WM_LBUTTONDOWN: + { + if (bct->stateId!=PBS_DISABLED) { // don't change states if disabled + bct->stateId = PBS_PRESSED; + InvalidateRect(bct->hwnd, NULL, TRUE); + } + break; + } + case WM_LBUTTONUP: + { + if (bct->pushBtn) { + if (bct->pbState) bct->pbState = 0; + else bct->pbState = 1; + } + if (bct->stateId!=PBS_DISABLED) { // don't change states if disabled + if (msg==WM_LBUTTONUP) bct->stateId = PBS_HOT; + else bct->stateId = PBS_NORMAL; + InvalidateRect(bct->hwnd, NULL, TRUE); + } + // Tell your daddy you got clicked. + SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM)hwndDlg); + break; + } + case WM_MOUSEMOVE: + if (bct->stateId == PBS_NORMAL) { + bct->stateId = PBS_HOT; + InvalidateRect(bct->hwnd, NULL, TRUE); + } + // Call timer, used to start cheesy TrackMouseEvent faker + SetTimer(hwndDlg,BUTTON_POLLID,BUTTON_POLLDELAY,NULL); + break; + case WM_TIMER: // use a timer to check if they have did a mouseout + { + if (wParam==BUTTON_POLLID) { + RECT rc; + POINT pt; + GetWindowRect(hwndDlg,&rc); + GetCursorPos(&pt); + if(!PtInRect(&rc,pt)) { // mouse must be gone, trigger mouse leave + PostMessage(hwndDlg,WM_MOUSELEAVE,0,0L); + KillTimer(hwndDlg,BUTTON_POLLID); + } + } + break; + } + case WM_ERASEBKGND: + return 1; + } + return DefWindowProc(hwndDlg, msg, wParam, lParam); +} diff --git a/plugins/TopToolBar/afxres.h b/plugins/TopToolBar/afxres.h new file mode 100644 index 0000000000..4b9ab506f5 --- /dev/null +++ b/plugins/TopToolBar/afxres.h @@ -0,0 +1,2 @@ +#include +#include diff --git a/plugins/TopToolBar/bmp/bitmap1.bmp b/plugins/TopToolBar/bmp/bitmap1.bmp new file mode 100644 index 0000000000..573b7d6186 Binary files /dev/null and b/plugins/TopToolBar/bmp/bitmap1.bmp differ diff --git a/plugins/TopToolBar/bmp/bmp00001.bmp b/plugins/TopToolBar/bmp/bmp00001.bmp new file mode 100644 index 0000000000..7c97999188 Binary files /dev/null and b/plugins/TopToolBar/bmp/bmp00001.bmp differ diff --git a/plugins/TopToolBar/bmp/bmp00002.bmp b/plugins/TopToolBar/bmp/bmp00002.bmp new file mode 100644 index 0000000000..6e8e840620 Binary files /dev/null and b/plugins/TopToolBar/bmp/bmp00002.bmp differ diff --git a/plugins/TopToolBar/bmp/borderup.bmp b/plugins/TopToolBar/bmp/borderup.bmp new file mode 100644 index 0000000000..2d7fd71299 Binary files /dev/null and b/plugins/TopToolBar/bmp/borderup.bmp differ diff --git a/plugins/TopToolBar/bmp/borederdn.bmp b/plugins/TopToolBar/bmp/borederdn.bmp new file mode 100644 index 0000000000..53809acff3 Binary files /dev/null and b/plugins/TopToolBar/bmp/borederdn.bmp differ diff --git a/plugins/TopToolBar/bmp/cpaneldn.bmp b/plugins/TopToolBar/bmp/cpaneldn.bmp new file mode 100644 index 0000000000..2f4e2a95b5 Binary files /dev/null and b/plugins/TopToolBar/bmp/cpaneldn.bmp differ diff --git a/plugins/TopToolBar/bmp/cpanelup.bmp b/plugins/TopToolBar/bmp/cpanelup.bmp new file mode 100644 index 0000000000..fc3531facd Binary files /dev/null and b/plugins/TopToolBar/bmp/cpanelup.bmp differ diff --git a/plugins/TopToolBar/bmp/findusedn.bmp b/plugins/TopToolBar/bmp/findusedn.bmp new file mode 100644 index 0000000000..f21e56fb95 Binary files /dev/null and b/plugins/TopToolBar/bmp/findusedn.bmp differ diff --git a/plugins/TopToolBar/bmp/finduser.bmp b/plugins/TopToolBar/bmp/finduser.bmp new file mode 100644 index 0000000000..e6a884651b Binary files /dev/null and b/plugins/TopToolBar/bmp/finduser.bmp differ diff --git a/plugins/TopToolBar/bmp/finduserdn.bmp b/plugins/TopToolBar/bmp/finduserdn.bmp new file mode 100644 index 0000000000..668a92c4b5 Binary files /dev/null and b/plugins/TopToolBar/bmp/finduserdn.bmp differ diff --git a/plugins/TopToolBar/bmp/groupdn.bmp b/plugins/TopToolBar/bmp/groupdn.bmp new file mode 100644 index 0000000000..9a106b15ee Binary files /dev/null and b/plugins/TopToolBar/bmp/groupdn.bmp differ diff --git a/plugins/TopToolBar/bmp/groupup.bmp b/plugins/TopToolBar/bmp/groupup.bmp new file mode 100644 index 0000000000..7bc71b6764 Binary files /dev/null and b/plugins/TopToolBar/bmp/groupup.bmp differ diff --git a/plugins/TopToolBar/bmp/launch.bmp b/plugins/TopToolBar/bmp/launch.bmp new file mode 100644 index 0000000000..326c0d31c6 Binary files /dev/null and b/plugins/TopToolBar/bmp/launch.bmp differ diff --git a/plugins/TopToolBar/bmp/launchdn.bmp b/plugins/TopToolBar/bmp/launchdn.bmp new file mode 100644 index 0000000000..0e72934853 Binary files /dev/null and b/plugins/TopToolBar/bmp/launchdn.bmp differ diff --git a/plugins/TopToolBar/bmp/launchup.bmp b/plugins/TopToolBar/bmp/launchup.bmp new file mode 100644 index 0000000000..22584a7e3b Binary files /dev/null and b/plugins/TopToolBar/bmp/launchup.bmp differ diff --git a/plugins/TopToolBar/bmp/menudn.bmp b/plugins/TopToolBar/bmp/menudn.bmp new file mode 100644 index 0000000000..ad93aff878 Binary files /dev/null and b/plugins/TopToolBar/bmp/menudn.bmp differ diff --git a/plugins/TopToolBar/bmp/menuup.bmp b/plugins/TopToolBar/bmp/menuup.bmp new file mode 100644 index 0000000000..a3a902ae6e Binary files /dev/null and b/plugins/TopToolBar/bmp/menuup.bmp differ diff --git a/plugins/TopToolBar/bmp/minimize.bmp b/plugins/TopToolBar/bmp/minimize.bmp new file mode 100644 index 0000000000..4749fa9369 Binary files /dev/null and b/plugins/TopToolBar/bmp/minimize.bmp differ diff --git a/plugins/TopToolBar/bmp/minimizedn.bmp b/plugins/TopToolBar/bmp/minimizedn.bmp new file mode 100644 index 0000000000..f8470a3d6a Binary files /dev/null and b/plugins/TopToolBar/bmp/minimizedn.bmp differ diff --git a/plugins/TopToolBar/bmp/options.bmp b/plugins/TopToolBar/bmp/options.bmp new file mode 100644 index 0000000000..945be884f4 Binary files /dev/null and b/plugins/TopToolBar/bmp/options.bmp differ diff --git a/plugins/TopToolBar/bmp/searchtest.bmp b/plugins/TopToolBar/bmp/searchtest.bmp new file mode 100644 index 0000000000..2b2fda1042 Binary files /dev/null and b/plugins/TopToolBar/bmp/searchtest.bmp differ diff --git a/plugins/TopToolBar/bmp/sep.bmp b/plugins/TopToolBar/bmp/sep.bmp new file mode 100644 index 0000000000..1665285275 Binary files /dev/null and b/plugins/TopToolBar/bmp/sep.bmp differ diff --git a/plugins/TopToolBar/bmp/separator.bmp b/plugins/TopToolBar/bmp/separator.bmp new file mode 100644 index 0000000000..fa4a4449f0 Binary files /dev/null and b/plugins/TopToolBar/bmp/separator.bmp differ diff --git a/plugins/TopToolBar/bmp/soundsdn.bmp b/plugins/TopToolBar/bmp/soundsdn.bmp new file mode 100644 index 0000000000..224e299691 Binary files /dev/null and b/plugins/TopToolBar/bmp/soundsdn.bmp differ diff --git a/plugins/TopToolBar/bmp/soundsup.bmp b/plugins/TopToolBar/bmp/soundsup.bmp new file mode 100644 index 0000000000..c11e7521fe Binary files /dev/null and b/plugins/TopToolBar/bmp/soundsup.bmp differ diff --git a/plugins/TopToolBar/bmp/test.bmp b/plugins/TopToolBar/bmp/test.bmp new file mode 100644 index 0000000000..b3b4252fef Binary files /dev/null and b/plugins/TopToolBar/bmp/test.bmp differ diff --git a/plugins/TopToolBar/button.c b/plugins/TopToolBar/button.c new file mode 100644 index 0000000000..a8ed3d0270 --- /dev/null +++ b/plugins/TopToolBar/button.c @@ -0,0 +1,541 @@ +/* +Miranda IM +Copyright (C) 2002 Robert Rainwater + +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. +*/ +#include "common.h" + +// TODO: +// - Support for bitmap buttons (simple call to DrawIconEx()) + +static LRESULT CALLBACK MButtonWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); + +typedef struct { + HWND hwnd; + int stateId; // button state + int focus; // has focus (1 or 0) + HFONT hFont; // font + HICON arrow; // uses down arrow + int defbutton; // default button + HICON hIcon; + HBITMAP hBitmap; + int pushBtn; + int pbState; + HANDLE hThemeButton; + HANDLE hThemeToolbar; + char cHot; + int flatBtn; +} MButtonCtrl; + + +// External theme methods and properties +static HMODULE themeAPIHandle = NULL; // handle to uxtheme.dll +static HANDLE (WINAPI *MyOpenThemeData)(HWND,LPCWSTR); +static HRESULT (WINAPI *MyCloseThemeData)(HANDLE); +static BOOL (WINAPI *MyIsThemeBackgroundPartiallyTransparent)(HANDLE,int,int); +static HRESULT (WINAPI *MyDrawThemeParentBackground)(HWND,HDC,RECT *); +static HRESULT (WINAPI *MyDrawThemeBackground)(HANDLE,HDC,int,int,const RECT *,const RECT *); +static HRESULT (WINAPI *MyDrawThemeText)(HANDLE,HDC,int,int,LPCWSTR,int,DWORD,DWORD,const RECT *); + +static CRITICAL_SECTION csTips; +static HWND hwndToolTips = NULL; + +int UnloadButtonModule(WPARAM wParam, LPARAM lParam) { + DeleteCriticalSection(&csTips); + return 0; +} + +int LoadButtonModule(void) { + WNDCLASSEX wc; + + ZeroMemory(&wc, sizeof(wc)); + wc.cbSize = sizeof(wc); + wc.lpszClassName = MYMIRANDABUTTONCLASS; + wc.lpfnWndProc = MButtonWndProc; + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.cbWndExtra = sizeof(MButtonCtrl*); + wc.hbrBackground = 0; + wc.style = CS_GLOBALCLASS; + RegisterClassEx(&wc); + InitializeCriticalSection(&csTips); + HookEvent(ME_SYSTEM_SHUTDOWN, UnloadButtonModule); + return 0; +} + +// Used for our own cheap TrackMouseEvent +#define BUTTON_POLLID 100 +#define BUTTON_POLLDELAY 50 + +#define MGPROC(x) GetProcAddress(themeAPIHandle,x) +static int ThemeSupport() { + if (IsWinVerXPPlus()) { + if (!themeAPIHandle) { + themeAPIHandle = GetModuleHandle("uxtheme"); + if (themeAPIHandle) { + MyOpenThemeData = (HANDLE (WINAPI *)(HWND,LPCWSTR))MGPROC("OpenThemeData"); + MyCloseThemeData = (HRESULT (WINAPI *)(HANDLE))MGPROC("CloseThemeData"); + MyIsThemeBackgroundPartiallyTransparent = (BOOL (WINAPI *)(HANDLE,int,int))MGPROC("IsThemeBackgroundPartiallyTransparent"); + MyDrawThemeParentBackground = (HRESULT (WINAPI *)(HWND,HDC,RECT *))MGPROC("DrawThemeParentBackground"); + MyDrawThemeBackground = (HRESULT (WINAPI *)(HANDLE,HDC,int,int,const RECT *,const RECT *))MGPROC("DrawThemeBackground"); + MyDrawThemeText = (HRESULT (WINAPI *)(HANDLE,HDC,int,int,LPCWSTR,int,DWORD,DWORD,const RECT *))MGPROC("DrawThemeText"); + } + } + // Make sure all of these methods are valid (i would hope either all or none work) + if (MyOpenThemeData + &&MyCloseThemeData + &&MyIsThemeBackgroundPartiallyTransparent + &&MyDrawThemeParentBackground + &&MyDrawThemeBackground + &&MyDrawThemeText) { + return 1; + } + } + return 0; +} + +static void DestroyTheme(MButtonCtrl *ctl) { + if (ThemeSupport()) { + if (ctl->hThemeButton) { + MyCloseThemeData(ctl->hThemeButton); + ctl->hThemeButton = NULL; + } + if (ctl->hThemeToolbar) { + MyCloseThemeData(ctl->hThemeToolbar); + ctl->hThemeToolbar = NULL; + } + } +} + +static void LoadTheme(MButtonCtrl *ctl) { + if (ThemeSupport()) { + DestroyTheme(ctl); + ctl->hThemeButton = MyOpenThemeData(ctl->hwnd,L"BUTTON"); + ctl->hThemeToolbar = MyOpenThemeData(ctl->hwnd,L"TOOLBAR"); + } +} + +static int TBStateConvert2Flat(int state) { + switch(state) { + case PBS_NORMAL: return TS_NORMAL; + case PBS_HOT: return TS_HOT; + case PBS_PRESSED: return TS_PRESSED; + case PBS_DISABLED: return TS_DISABLED; + case PBS_DEFAULTED: return TS_NORMAL; + } + return TS_NORMAL; +} + +static void PaintWorker(MButtonCtrl *ctl, HDC hdcPaint) { + if (hdcPaint) { + HDC hdcMem; + HBITMAP hbmMem; + HDC hOld; + RECT rcClient; + + GetClientRect(ctl->hwnd, &rcClient); + hdcMem = CreateCompatibleDC(hdcPaint); + hbmMem = CreateCompatibleBitmap(hdcPaint, rcClient.right-rcClient.left, rcClient.bottom-rcClient.top); + hOld = SelectObject(hdcMem, hbmMem); + + // If its a push button, check to see if it should stay pressed + if (ctl->pushBtn && ctl->pbState) ctl->stateId = PBS_PRESSED; + + // Draw the flat button + if (ctl->flatBtn) { + if (ctl->hThemeToolbar) { + int state = IsWindowEnabled(ctl->hwnd)?(ctl->stateId==PBS_NORMAL&&ctl->defbutton?PBS_DEFAULTED:ctl->stateId):PBS_DISABLED; + if (MyIsThemeBackgroundPartiallyTransparent(ctl->hThemeToolbar, TP_BUTTON, TBStateConvert2Flat(state))) { + MyDrawThemeParentBackground(ctl->hwnd, hdcMem, &rcClient); + } + MyDrawThemeBackground(ctl->hThemeToolbar, hdcMem, TP_BUTTON, TBStateConvert2Flat(state), &rcClient, &rcClient); + } + else { + HBRUSH hbr; + + if (ctl->stateId==PBS_PRESSED||ctl->stateId==PBS_HOT) + hbr = GetSysColorBrush(COLOR_3DLIGHT); + else { + HDC dc; + HWND hwndParent; + + hwndParent = GetParent(ctl->hwnd); + dc=GetDC(hwndParent); + hbr = (HBRUSH)SendMessage(hwndParent, WM_CTLCOLORDLG, (WPARAM)dc, (LPARAM)hwndParent); + ReleaseDC(hwndParent,dc); + } + if (hbr) { + FillRect(hdcMem, &rcClient, hbr); + DeleteObject(hbr); + } + if (ctl->stateId==PBS_HOT||ctl->focus) { + if (ctl->pbState) + DrawEdge(hdcMem,&rcClient, EDGE_ETCHED,BF_RECT|BF_SOFT); + else DrawEdge(hdcMem,&rcClient, BDR_RAISEDOUTER,BF_RECT|BF_SOFT|BF_FLAT); + } + else if (ctl->stateId==PBS_PRESSED) + DrawEdge(hdcMem, &rcClient, BDR_SUNKENOUTER,BF_RECT|BF_SOFT); + } + } + else { + // Draw background/border + if (ctl->hThemeButton) { + int state = IsWindowEnabled(ctl->hwnd)?(ctl->stateId==PBS_NORMAL&&ctl->defbutton?PBS_DEFAULTED:ctl->stateId):PBS_DISABLED; + if (MyIsThemeBackgroundPartiallyTransparent(ctl->hThemeButton, BP_PUSHBUTTON, state)) { + MyDrawThemeParentBackground(ctl->hwnd, hdcMem, &rcClient); + } + MyDrawThemeBackground(ctl->hThemeButton, hdcMem, BP_PUSHBUTTON, state, &rcClient, &rcClient); + } + else { + UINT uState = DFCS_BUTTONPUSH|((ctl->stateId==PBS_HOT)?DFCS_HOT:0)|((ctl->stateId == PBS_PRESSED)?DFCS_PUSHED:0); + if (ctl->defbutton&&ctl->stateId==PBS_NORMAL) uState |= DLGC_DEFPUSHBUTTON; + DrawFrameControl(hdcMem, &rcClient, DFC_BUTTON, uState); + } + + // Draw focus rectangle if button has focus + if (ctl->focus) { + RECT focusRect = rcClient; + InflateRect(&focusRect, -3, -3); + DrawFocusRect(hdcMem, &focusRect); + } + } + + // If we have an icon or a bitmap, ignore text and only draw the image on the button + if (ctl->hIcon) { + int ix = (rcClient.right-rcClient.left)/2 - (GetSystemMetrics(SM_CXSMICON)/2); + int iy = (rcClient.bottom-rcClient.top)/2 - (GetSystemMetrics(SM_CYSMICON)/2); + if (ctl->stateId == PBS_PRESSED) { + ix++; + iy++; + } + { + HIMAGELIST hImageList; + HICON hIconNew; + + hImageList = ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON), IsWinVerXPPlus()? ILC_COLOR32 | ILC_MASK : ILC_COLOR16 | ILC_MASK, 1, 0); + ImageList_AddIcon(hImageList, ctl->hIcon); + hIconNew = ImageList_GetIcon(hImageList, 0, ILD_NORMAL); + DrawState(hdcMem,NULL,NULL,(LPARAM)hIconNew,0,ix,iy,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),IsWindowEnabled(ctl->hwnd)?DST_ICON|DSS_NORMAL:DST_ICON|DSS_DISABLED); + ImageList_RemoveAll(hImageList); + ImageList_Destroy(hImageList); + DestroyIcon(hIconNew); + } + } + else if (ctl->hBitmap) { + BITMAP bminfo; + int ix,iy; + + GetObject(ctl->hBitmap, sizeof(bminfo), &bminfo); + ix = (rcClient.right-rcClient.left)/2 - (bminfo.bmWidth/2); + iy = (rcClient.bottom-rcClient.top)/2 - (bminfo.bmHeight/2); + if (ctl->stateId == PBS_PRESSED) { + ix++; + iy++; + } + DrawState(hdcMem,NULL,NULL,(LPARAM)ctl->hBitmap,0,ix,iy,bminfo.bmWidth,bminfo.bmHeight,IsWindowEnabled(ctl->hwnd)?DST_BITMAP:DST_BITMAP|DSS_DISABLED); + } + else if (GetWindowTextLength(ctl->hwnd)) { + // Draw the text and optinally the arrow + char szText[MAX_PATH]; + SIZE sz; + RECT rcText; + HFONT hOldFont; + + CopyRect(&rcText, &rcClient); + GetWindowText(ctl->hwnd, szText, sizeof(szText)); + SetBkMode(hdcMem, TRANSPARENT); + hOldFont = SelectObject(hdcMem, ctl->hFont); + // XP w/themes doesn't used the glossy disabled text. Is it always using COLOR_GRAYTEXT? Seems so. + SetTextColor(hdcMem, IsWindowEnabled(ctl->hwnd)||!ctl->hThemeButton?GetSysColor(COLOR_BTNTEXT):GetSysColor(COLOR_GRAYTEXT)); + GetTextExtentPoint32(hdcMem, szText, lstrlen(szText), &sz); + if (ctl->cHot) { + SIZE szHot; + + GetTextExtentPoint32(hdcMem, "&", 1, &szHot); + sz.cx -= szHot.cx; + } + if (ctl->arrow) { + DrawState(hdcMem,NULL,NULL,(LPARAM)ctl->arrow,0,rcClient.right-rcClient.left-5-GetSystemMetrics(SM_CXSMICON)+(!ctl->hThemeButton&&ctl->stateId==PBS_PRESSED?1:0),(rcClient.bottom-rcClient.top)/2-GetSystemMetrics(SM_CYSMICON)/2+(!ctl->hThemeButton&&ctl->stateId==PBS_PRESSED?1:0),GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),IsWindowEnabled(ctl->hwnd)?DST_ICON:DST_ICON|DSS_DISABLED); + } + SelectObject(hdcMem, ctl->hFont); + DrawState(hdcMem,NULL,NULL,(LPARAM)szText,0,(rcText.right-rcText.left-sz.cx)/2+(!ctl->hThemeButton&&ctl->stateId==PBS_PRESSED?1:0),ctl->hThemeButton?(rcText.bottom-rcText.top-sz.cy)/2:(rcText.bottom-rcText.top-sz.cy)/2-(ctl->stateId==PBS_PRESSED?0:1),sz.cx,sz.cy,IsWindowEnabled(ctl->hwnd)||ctl->hThemeButton?DST_PREFIXTEXT|DSS_NORMAL:DST_PREFIXTEXT|DSS_DISABLED); + SelectObject(hdcMem, hOldFont); + } + BitBlt(hdcPaint, 0, 0, rcClient.right-rcClient.left, rcClient.bottom-rcClient.top, hdcMem, 0, 0, SRCCOPY); + SelectObject(hdcMem, hOld); + DeleteObject(hbmMem); + DeleteDC(hdcMem); + + } +} + +static LRESULT CALLBACK MButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { + MButtonCtrl* bct = (MButtonCtrl *)GetWindowLong(hwndDlg, 0); + switch(msg) { + case WM_NCCREATE: + { + SetWindowLong(hwndDlg, GWL_STYLE, GetWindowLong(hwndDlg, GWL_STYLE)|BS_OWNERDRAW); + bct = malloc(sizeof(MButtonCtrl)); + if (bct==NULL) return FALSE; + bct->hwnd = hwndDlg; + bct->stateId = PBS_NORMAL; + bct->focus = 0; + bct->hFont = GetStockObject(DEFAULT_GUI_FONT); + bct->arrow = NULL; + bct->defbutton = 0; + bct->hIcon = NULL; + bct->hBitmap = NULL; + bct->pushBtn = 0; + bct->pbState = 0; + bct->hThemeButton = NULL; + bct->hThemeToolbar = NULL; + bct->cHot = 0; + bct->flatBtn = 0; + LoadTheme(bct); + SetWindowLong(hwndDlg, 0, (LONG)bct); + if (((CREATESTRUCT *)lParam)->lpszName) SetWindowText(hwndDlg, ((CREATESTRUCT *)lParam)->lpszName); + return TRUE; + } + case WM_DESTROY: + { + if (bct) { + EnterCriticalSection(&csTips); + if (hwndToolTips) { + TOOLINFO ti; + + ZeroMemory(&ti, sizeof(ti)); + ti.cbSize = sizeof(ti); + ti.uFlags = TTF_IDISHWND; + ti.hwnd = bct->hwnd; + ti.uId = (UINT)bct->hwnd; + if (SendMessage(hwndToolTips, TTM_GETTOOLINFO, 0, (LPARAM)&ti)) { + SendMessage(hwndToolTips, TTM_DELTOOL, 0, (LPARAM)&ti); + } + if (SendMessage(hwndToolTips, TTM_GETTOOLCOUNT, 0, (LPARAM)&ti)==0) { + DestroyWindow(hwndToolTips); + hwndToolTips = NULL; + } + } + LeaveCriticalSection(&csTips); + DestroyTheme(bct); + free(bct); + } + SetWindowLong(hwndDlg,0,(LONG)NULL); + break; // DONT! fall thru + } + case WM_SETTEXT: + { + bct->cHot = 0; + if ((char*)lParam) { + char *tmp = (char*)lParam; + while (*tmp) { + if (*tmp=='&' && *(tmp+1)) { + bct->cHot = tolower(*(tmp+1)); + break; + } + tmp++; + } + InvalidateRect(bct->hwnd, NULL, TRUE); + } + break; + } + case WM_SYSKEYUP: + if (bct->stateId!=PBS_DISABLED && bct->cHot && bct->cHot == tolower((int)wParam)) { + if (bct->pushBtn) { + if (bct->pbState) bct->pbState = 0; + else bct->pbState = 1; + InvalidateRect(bct->hwnd, NULL, TRUE); + } + SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM)hwndDlg); + return 0; + } + break; + case WM_THEMECHANGED: { + // themed changed, reload theme object + LoadTheme(bct); + InvalidateRect(bct->hwnd, NULL, TRUE); // repaint it + break; + } + case WM_SETFONT: // remember the font so we can use it later + { + bct->hFont = (HFONT)wParam; // maybe we should redraw? + break; + } + case WM_NCPAINT: + case WM_PAINT: + { + PAINTSTRUCT ps; + HDC hdcPaint; + + hdcPaint = BeginPaint(hwndDlg, &ps); + if (hdcPaint) { + PaintWorker(bct, hdcPaint); + EndPaint(hwndDlg, &ps); + } + break; + } + case BM_SETIMAGE: + if (wParam == IMAGE_ICON) { + bct->hIcon = (HICON)lParam; + bct->hBitmap = NULL; + InvalidateRect(bct->hwnd, NULL, TRUE); + } + else if (wParam == IMAGE_BITMAP) { + bct->hBitmap = (HBITMAP)lParam; + bct->hIcon = NULL; + InvalidateRect(bct->hwnd, NULL, TRUE); + } + break; + case BM_SETCHECK: + if (!bct->pushBtn) break; + if (wParam == BST_CHECKED) { + bct->pbState = 1; + bct->stateId = PBS_PRESSED; + } + else if (wParam == BST_UNCHECKED) { + bct->pbState = 0; + bct->stateId = PBS_NORMAL; + } + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case BM_GETCHECK: + if (bct->pushBtn) { + return bct->pbState?BST_CHECKED:BST_UNCHECKED; + } + return 0; + case BUTTONSETARROW: // turn arrow on/off + if (wParam) { +// if (!bct->arrow) +// bct->arrow = (HICON)LoadImage(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_DOWNARROW),IMAGE_ICON,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),0); + } + else { + if (bct->arrow) { + DestroyIcon(bct->arrow); + bct->arrow = NULL; + } + } + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case BUTTONSETDEFAULT: + bct->defbutton = wParam?1:0; + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case BUTTONSETASPUSHBTN: + bct->pushBtn = 1; + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case BUTTONSETASFLATBTN: + bct->flatBtn = 1; + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case BUTTONADDTOOLTIP: + { + TOOLINFO ti; + + if (!(char*)wParam) break; + EnterCriticalSection(&csTips); + if (!hwndToolTips) { + hwndToolTips = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, "", WS_POPUP, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(NULL), NULL); + } + ZeroMemory(&ti, sizeof(ti)); + ti.cbSize = sizeof(ti); + ti.uFlags = TTF_IDISHWND; + ti.hwnd = bct->hwnd; + ti.uId = (UINT)bct->hwnd; + if (SendMessage(hwndToolTips, TTM_GETTOOLINFO, 0, (LPARAM)&ti)) { + SendMessage(hwndToolTips, TTM_DELTOOL, 0, (LPARAM)&ti); + } + ti.uFlags = TTF_IDISHWND|TTF_SUBCLASS; + ti.uId = (UINT)bct->hwnd; + ti.lpszText=(char*)wParam; + SendMessage(hwndToolTips,TTM_ADDTOOL,0,(LPARAM)&ti); + LeaveCriticalSection(&csTips); + break; + } + case WM_SETFOCUS: // set keybord focus and redraw + bct->focus = 1; + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case WM_KILLFOCUS: // kill focus and redraw + bct->focus = 0; + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case WM_WINDOWPOSCHANGED: + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + case WM_ENABLE: // windows tells us to enable/disable + { + bct->stateId = wParam?PBS_NORMAL:PBS_DISABLED; + InvalidateRect(bct->hwnd, NULL, TRUE); + break; + } + case WM_MOUSELEAVE: // faked by the WM_TIMER + { + if (bct->stateId!=PBS_DISABLED) { // don't change states if disabled + bct->stateId = PBS_NORMAL; + InvalidateRect(bct->hwnd, NULL, TRUE); + } + break; + } + case WM_LBUTTONDOWN: + { + if (bct->stateId!=PBS_DISABLED) { // don't change states if disabled + bct->stateId = PBS_PRESSED; + InvalidateRect(bct->hwnd, NULL, TRUE); + } + break; + } + case WM_LBUTTONUP: + { + if (bct->pushBtn) { + if (bct->pbState) bct->pbState = 0; + else bct->pbState = 1; + } + if (bct->stateId!=PBS_DISABLED) { // don't change states if disabled + if (msg==WM_LBUTTONUP) bct->stateId = PBS_HOT; + else bct->stateId = PBS_NORMAL; + InvalidateRect(bct->hwnd, NULL, TRUE); + } + // Tell your daddy you got clicked. + SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM)hwndDlg); + break; + } + case WM_MOUSEMOVE: + if (bct->stateId == PBS_NORMAL) { + bct->stateId = PBS_HOT; + InvalidateRect(bct->hwnd, NULL, TRUE); + } + // Call timer, used to start cheesy TrackMouseEvent faker + SetTimer(hwndDlg,BUTTON_POLLID,BUTTON_POLLDELAY,NULL); + break; + case WM_TIMER: // use a timer to check if they have did a mouseout + { + if (wParam==BUTTON_POLLID) { + RECT rc; + POINT pt; + GetWindowRect(hwndDlg,&rc); + GetCursorPos(&pt); + if(!PtInRect(&rc,pt)) { // mouse must be gone, trigger mouse leave + PostMessage(hwndDlg,WM_MOUSELEAVE,0,0L); + KillTimer(hwndDlg,BUTTON_POLLID); + } + } + break; + } + case WM_ERASEBKGND: + return 1; + } + return DefWindowProc(hwndDlg, msg, wParam, lParam); +} diff --git a/plugins/TopToolBar/buttonopt.c b/plugins/TopToolBar/buttonopt.c new file mode 100644 index 0000000000..b1d8275953 --- /dev/null +++ b/plugins/TopToolBar/buttonopt.c @@ -0,0 +1,340 @@ +#include "common.h" +#pragma hdrstop + +extern HINSTANCE hInst; + +char *DBGetString(HANDLE hContact,const char *szModule,const char *szSetting) +{ + char *str=NULL; + DBVARIANT dbv; + DBGetContactSetting(hContact,szModule,szSetting,&dbv); + if(dbv.type==DBVT_ASCIIZ) + str=strdup(dbv.pszVal); + DBFreeVariant(&dbv); + return str; +} + + + + +struct OrderData { + int dragging; + HTREEITEM hDragItem; +}; + + + +int CheckButtonOrder() +{ + boolean protochanged=FALSE; + int StoredButCount; + int i,count; + int v; + char buf[10]; + char buf2[10]; + + //curproto=0; + //curproto[1]='22'; + + StoredButCount=DBGetContactSettingByte(0,TTB_OPTDIR,"ButCount",-1); + if (StoredButCount==-1){protochanged=TRUE;}; + if (protochanged) + { + //reseting all settings; + + CallService(MS_PROTO_ENUMPROTOCOLS,(WPARAM)&count,(LPARAM)&protos); + + v=0; + for(i=0;itype!=PROTOTYPE_PROTOCOL || CallProtoService(protos[i]->szName,PS_GETCAPS,PFLAGNUM_2,0)==0) continue; + itoa(v,&buf,10); + DBWriteContactSettingString(0,"Protocols",&buf,protos[i]->szName); + + itoa(OFFSET_VISIBLE+v,&buf,10);//save default visible status + DBWriteContactSettingByte(0,"Protocols",&buf,1); + + v++; + }; + DBWriteContactSettingByte(0,TTB_OPTDIR,"ButCount",v); + return(1); + } + else + { + return(0); + }; + + + +}; + + + +static BOOL CALLBACK ProtocolOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ struct ProtocolOrderData *dat; + + dat=(struct ProtocolOrderData*)GetWindowLong(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),GWL_USERDATA); + + switch (msg) + { + case WM_INITDIALOG: { + PROTOCOLDESCRIPTOR **protos; + TVINSERTSTRUCT tvis; + ProtocolData *PD; + char szName[64]; + char *szSTName; + char buf[10]; + int i,count; + + dat=(struct ProtocolOrderData*)malloc(sizeof(struct ProtocolOrderData)); + SetWindowLong(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),GWL_USERDATA,(LONG)dat); + dat->dragging=0; + + SetWindowLong(GetDlgItem(hwndDlg,IDC_PROTOCOLVISIBILITY),GWL_STYLE,GetWindowLong(GetDlgItem(hwndDlg,IDC_PROTOCOLVISIBILITY),GWL_STYLE)|TVS_NOHSCROLL); + SetWindowLong(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),GWL_STYLE,GetWindowLong(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),GWL_STYLE)|TVS_NOHSCROLL); + + { HIMAGELIST himlCheckBoxes; + himlCheckBoxes=ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),ILC_COLOR4|ILC_MASK,2,2); + ImageList_AddIcon(himlCheckBoxes,LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_NOTICK))); + ImageList_AddIcon(himlCheckBoxes,LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_TICK))); + TreeView_SetImageList(GetDlgItem(hwndDlg,IDC_PROTOCOLVISIBILITY),himlCheckBoxes,TVSIL_NORMAL); + // + TreeView_SetImageList(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),himlCheckBoxes,TVSIL_NORMAL); + + } + + tvis.hParent=NULL; + tvis.hInsertAfter=TVI_LAST; + tvis.item.mask=TVIF_PARAM|TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE; + + CheckProtocolOrder(); + + count=DBGetContactSettingByte(0,"Protocols","ProtoCount",-1); + if (count==-1){return(FALSE);}; + + for(i=0;itype!=PROTOTYPE_PROTOCOL || CallProtoService(protos[i]->szName,PS_GETCAPS,PFLAGNUM_2,0)==0) continue; + itoa(i,&buf,10); + szSTName=DBGetString(0,"Protocols",&buf); + if (szSTName==NULL){continue;}; + + CallProtoService(szSTName,PS_GETNAME,sizeof(szName),(LPARAM)szName); + PD=(ProtocolData*)malloc(sizeof(ProtocolData)); + + + PD->RealName=szSTName; + + itoa(OFFSET_VISIBLE+i,&buf,10); + PD->show=DBGetContactSettingByte(0,"Protocols",&buf,1); + + itoa(OFFSET_PROTOPOS+i,&buf,10); + PD->protopos=DBGetContactSettingByte(0,"Protocols",&buf,-1); + + tvis.item.lParam=(LPARAM)PD; + tvis.item.pszText=Translate(szName); + tvis.item.iImage=tvis.item.iSelectedImage=PD->show; + TreeView_InsertItem(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),&tvis); + tvis.item.iImage=tvis.item.iSelectedImage=PD->show; + TreeView_InsertItem(GetDlgItem(hwndDlg,IDC_PROTOCOLVISIBILITY),&tvis); + + //free(szSTName); + } + return TRUE; + } + case WM_NOTIFY: + switch(((LPNMHDR)lParam)->idFrom) { + case 0: + switch (((LPNMHDR)lParam)->code) + { + case PSN_APPLY: + { + TVITEM tvi; + PROTOCOLDESCRIPTOR **protos; + int count; + char idstr[33]; + char buf[10]; + + /* + tvi.hItem=TreeView_GetRoot(GetDlgItem(hwndDlg,IDC_PROTOCOLVISIBILITY)); + tvi.cchTextMax=32; + tvi.mask=TVIF_TEXT|TVIF_IMAGE|TVIF_PARAM|TVIF_HANDLE; + tvi.pszText=&idstr; + //count=0; + while(tvi.hItem!=NULL) { + itoa(OFFSET_VISIBLE+count,&buf,10); + TreeView_GetItem(GetDlgItem(hwndDlg,IDC_PROTOCOLVISIBILITY),&tvi); + DBWriteContactSettingByte(NULL,"Protocols",&buf,(byte)tvi.iImage); + tvi.hItem=TreeView_GetNextSibling(GetDlgItem(hwndDlg,IDC_PROTOCOLVISIBILITY),tvi.hItem); + //count++; + } + */ + tvi.hItem=TreeView_GetRoot(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER)); + tvi.cchTextMax=32; + tvi.mask=TVIF_TEXT|TVIF_PARAM|TVIF_HANDLE; + tvi.pszText=&idstr; + //CallService(MS_PROTO_ENUMPROTOCOLS,(WPARAM)&count,(LPARAM)&protos); + //count--; + count=0; + + while(tvi.hItem!=NULL) { + itoa(count,buf,10); + TreeView_GetItem(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),&tvi); + DBWriteContactSettingString(NULL,"Protocols",&buf,((ProtocolData *)tvi.lParam)->RealName); + + itoa(OFFSET_PROTOPOS+count,&buf,10);//save pos in protos + DBWriteContactSettingByte(0,"Protocols",&buf,((ProtocolData *)tvi.lParam)->protopos); + + itoa(OFFSET_VISIBLE+count,&buf,10);//save pos in protos + DBWriteContactSettingByte(0,"Protocols",&buf,((ProtocolData *)tvi.lParam)->show); + + tvi.hItem=TreeView_GetNextSibling(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),tvi.hItem); + + count++; + } + CluiProtocolStatusChanged(0,0); + } + } + break; + /* + case IDC_PROTOCOLORDER: //IDC_PROTOCOLVISIBILITY: + 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_ONITEMICON) { + TVITEM tvi; + tvi.mask=TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE; + tvi.hItem=hti.hItem; + TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom,&tvi); + tvi.iImage=tvi.iSelectedImage=!tvi.iImage; + ((ProtocolData *)tvi.lParam)->show=tvi.iImage; + TreeView_SetItem(((LPNMHDR)lParam)->hwndFrom,&tvi); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + ShowWindow(GetDlgItem(hwndDlg,IDC_PROTOCOLORDERWARNING),SW_SHOW); + } + } + break; + */ + case IDC_PROTOCOLORDER: + switch (((LPNMHDR)lParam)->code) { + case TVN_BEGINDRAG: + SetCapture(hwndDlg); + dat->dragging=1; + dat->hDragItem=((LPNMTREEVIEW)lParam)->itemNew.hItem; + TreeView_SelectItem(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),dat->hDragItem); + //ShowWindow(GetDlgItem(hwndDlg,IDC_PROTOCOLORDERWARNING),SW_SHOW); + 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_ONITEMICON) { + TVITEM tvi; + tvi.mask=TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE; + tvi.hItem=hti.hItem; + TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom,&tvi); + tvi.iImage=tvi.iSelectedImage=!tvi.iImage; + ((ProtocolData *)tvi.lParam)->show=tvi.iImage; + TreeView_SetItem(((LPNMHDR)lParam)->hwndFrom,&tvi); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + + //all changes take effect in runtime + //ShowWindow(GetDlgItem(hwndDlg,IDC_PROTOCOLORDERWARNING),SW_SHOW); + } + + + + }; + } + break; + } + break; + case WM_MOUSEMOVE: + if(!dat->dragging) break; + { TVHITTESTINFO hti; + hti.pt.x=(short)LOWORD(lParam); + hti.pt.y=(short)HIWORD(lParam); + ClientToScreen(hwndDlg,&hti.pt); + ScreenToClient(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),&hti.pt); + TreeView_HitTest(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),&hti); + if(hti.flags&(TVHT_ONITEM|TVHT_ONITEMRIGHT)) { + hti.pt.y-=TreeView_GetItemHeight(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER))/2; + TreeView_HitTest(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),&hti); + TreeView_SetInsertMark(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),hti.hItem,1); + } + else { + if(hti.flags&TVHT_ABOVE) SendDlgItemMessage(hwndDlg,IDC_PROTOCOLORDER,WM_VSCROLL,MAKEWPARAM(SB_LINEUP,0),0); + if(hti.flags&TVHT_BELOW) SendDlgItemMessage(hwndDlg,IDC_PROTOCOLORDER,WM_VSCROLL,MAKEWPARAM(SB_LINEDOWN,0),0); + TreeView_SetInsertMark(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),NULL,0); + } + } + break; + case WM_LBUTTONUP: + if(!dat->dragging) break; + TreeView_SetInsertMark(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),NULL,0); + dat->dragging=0; + ReleaseCapture(); + { TVHITTESTINFO hti; + TVITEM tvi; + hti.pt.x=(short)LOWORD(lParam); + hti.pt.y=(short)HIWORD(lParam); + ClientToScreen(hwndDlg,&hti.pt); + ScreenToClient(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),&hti.pt); + hti.pt.y-=TreeView_GetItemHeight(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER))/2; + TreeView_HitTest(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),&hti); + if(dat->hDragItem==hti.hItem) break; + tvi.mask=TVIF_HANDLE|TVIF_PARAM; + tvi.hItem=hti.hItem; + TreeView_GetItem(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),&tvi); + if(hti.flags&(TVHT_ONITEM|TVHT_ONITEMRIGHT)) { + TVINSERTSTRUCT tvis; + char name[128]; + tvis.item.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE; + tvis.item.stateMask=0xFFFFFFFF; + tvis.item.pszText=name; + tvis.item.cchTextMax=sizeof(name); + tvis.item.hItem=dat->hDragItem; + // + tvis.item.iImage=tvis.item.iSelectedImage=((ProtocolData *)tvi.lParam)->show; + + TreeView_GetItem(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),&tvis.item); + + + TreeView_DeleteItem(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),dat->hDragItem); + tvis.hParent=NULL; + tvis.hInsertAfter=hti.hItem; + TreeView_SelectItem(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),TreeView_InsertItem(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),&tvis)); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + } + break; + } + return FALSE; +} + +static int ProtocolOrderInit(WPARAM wParam,LPARAM lParam) { + OPTIONSDIALOGPAGE odp; + + ZeroMemory(&odp,sizeof(odp)); + odp.cbSize=sizeof(odp); + odp.position=-1000000000; + odp.hInstance=hInst;//GetModuleHandle(NULL); + odp.pszTemplate=MAKEINTRESOURCE(IDD_OPT_PROTOCOLORDER); + odp.pszGroup=Translate("Contact List"); + odp.pszTitle=Translate("Protocols"); + odp.pfnDlgProc=ProtocolOrderOpts; + odp.flags=ODPF_BOLDGROUPS|ODPF_EXPERTONLY; + CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp); + + return 0; +} + +int LoadProtocolOrderModule(void) { + HookEvent(ME_OPT_INITIALISE,ProtocolOrderInit); + return 0; +} \ No newline at end of file diff --git a/plugins/TopToolBar/common.h b/plugins/TopToolBar/common.h new file mode 100644 index 0000000000..3150ca3a23 --- /dev/null +++ b/plugins/TopToolBar/common.h @@ -0,0 +1,150 @@ +#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_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_langpack.h" +#include "m_options.h" +#include "resource.h" +#include "m_toptoolbar.h" +#include "m_button.h" +#include "m_icolib.h" +#include "BkgrCfg.h" + +#define TTB_OPTDIR "TopToolBar" +#define TTBDEFAULT_BKBMPUSE CLB_STRETCH + + +#define TTBDEFAULT_BKCOLOUR GetSysColor(COLOR_3DFACE) +#define TTBDEFAULT_USEBITMAP 0 +#define TTBDEFAULT_SELBKCOLOUR GetSysColor(COLOR_HIGHLIGHT) + +int TTBOptInit(WPARAM wParam,LPARAM lParam); +//append string +char __inline *AS(char *str,const char *setting,char *addstr); + +int ttbOptionsChanged(); + +int ArrangeButtons(); +int RecreateWindows(); + +typedef struct { + HWND hwnd; + HWND hwndTip; + int id; + BOOL bPushed; + int dwFlags; + int x,y; + HBITMAP hbBitmapUp,hbBitmapDown; + HBITMAP hbDefBitmapUp,hbDefBitmapDown; + HBITMAP hbWBordBitmapUp,hbWBordBitmapDown; + HICON hIconUp,hIconDn; + + char *pszServiceUp,*pszServiceDown; + char *tooltip; + char *name; + + LPARAM lParamUp; + WPARAM wParamUp; + LPARAM lParamDown; + WPARAM wParamDown; + WORD arrangedpos; + char *UserDefinedbmUp; + char *UserDefinedbmDown; + + +}TopButtonInt; + +typedef struct tagSortData { + int oldpos; + int arrangeval; +} SortData; + +#define MAX_BUTTONS 64 +//#define BUTTWIDTH 20 + +//#define BUTTHEIGHT 16 +#define SEPWIDTH 3 + +typedef struct tagButtonOptData { + char *name; + int pos; + boolean show; +} ButtonOptData; + +boolean OptionsOpened; +HWND OptionshWnd; +int OptionsPageRebuild(); +void lockbut(); +void ulockbut(); + +//return - 0 success, -1 on error +#define TTB_ADDSEPARATOR "TTB/AddSeparator" +//wparam sepid +#define TTB_REMOVESEPARATOR "TTB/RemoveSeparator" + + +//append string +char *AS(char *str,const char *setting,char *addstr) +{ + if(str!=NULL) { + strcpy(str,setting); + strcat(str,addstr); + } + return str; +}; + + +char *DBGetString(HANDLE hContact,const char *szModule,const char *szSetting); + + +#define TTB_LAUNCHSERVICE "TTB/LaunchSerice" +//wparam -id +//lparam &LBTOPT +#define TTB_MODIFYLBUTTON "TTB/ModifyLButton" + +//wparam -id +//lparam &LBTOPT +#define TTB_GETLBUTTON "TTB/GetLButton" + +#define TTB_ADDLBUTTON "TTB/AddLButton" +#define TTB_REMOVELBUTTON "TTB/RemoveLButton" +#define MYMIRANDABUTTONCLASS "MyMIRANDABUTTONCLASS" + + +int InitLBut(); +int UnInitLBut(); + +typedef struct +{ +int hframe; +char *lpath; +char *name; +}LBUTOPT; + +int LoadCLCButtonModule(void); +#define BM_SETPRIVATEICON (WM_USER + 6) +#define BM_SETIMLICON (WM_USER + 7) +#define UseIcoLibDefaultValue 0 +#define UseMirandaButtonClassDefaultValue 1 + +#endif \ No newline at end of file diff --git a/plugins/TopToolBar/find.ico b/plugins/TopToolBar/find.ico new file mode 100644 index 0000000000..415a0bccd7 Binary files /dev/null and b/plugins/TopToolBar/find.ico differ diff --git a/plugins/TopToolBar/icos/Find_Add Contacts_DN.ico b/plugins/TopToolBar/icos/Find_Add Contacts_DN.ico new file mode 100644 index 0000000000..06027e5bbe Binary files /dev/null and b/plugins/TopToolBar/icos/Find_Add Contacts_DN.ico differ diff --git a/plugins/TopToolBar/icos/Find_Add Contacts_UP.ico b/plugins/TopToolBar/icos/Find_Add Contacts_UP.ico new file mode 100644 index 0000000000..452f2efc98 Binary files /dev/null and b/plugins/TopToolBar/icos/Find_Add Contacts_UP.ico differ diff --git a/plugins/TopToolBar/icos/Groups On_Off_DN.ico b/plugins/TopToolBar/icos/Groups On_Off_DN.ico new file mode 100644 index 0000000000..99b7dddd38 Binary files /dev/null and b/plugins/TopToolBar/icos/Groups On_Off_DN.ico differ diff --git a/plugins/TopToolBar/icos/Groups On_Off_UP.ico b/plugins/TopToolBar/icos/Groups On_Off_UP.ico new file mode 100644 index 0000000000..fffe8e32c4 Binary files /dev/null and b/plugins/TopToolBar/icos/Groups On_Off_UP.ico differ diff --git a/plugins/TopToolBar/icos/Minimize Button_DN.ico b/plugins/TopToolBar/icos/Minimize Button_DN.ico new file mode 100644 index 0000000000..1fc45867e8 Binary files /dev/null and b/plugins/TopToolBar/icos/Minimize Button_DN.ico differ diff --git a/plugins/TopToolBar/icos/Minimize Button_UP.ico b/plugins/TopToolBar/icos/Minimize Button_UP.ico new file mode 100644 index 0000000000..dd9a8451d7 Binary files /dev/null and b/plugins/TopToolBar/icos/Minimize Button_UP.ico differ diff --git a/plugins/TopToolBar/icos/Run.ico b/plugins/TopToolBar/icos/Run.ico new file mode 100644 index 0000000000..7a87fadc82 Binary files /dev/null and b/plugins/TopToolBar/icos/Run.ico differ diff --git a/plugins/TopToolBar/icos/Show Main Menu_DN.ico b/plugins/TopToolBar/icos/Show Main Menu_DN.ico new file mode 100644 index 0000000000..075649f4ac Binary files /dev/null and b/plugins/TopToolBar/icos/Show Main Menu_DN.ico differ diff --git a/plugins/TopToolBar/icos/Show Main Menu_UP.ico b/plugins/TopToolBar/icos/Show Main Menu_UP.ico new file mode 100644 index 0000000000..8602e4cf3e Binary files /dev/null and b/plugins/TopToolBar/icos/Show Main Menu_UP.ico differ diff --git a/plugins/TopToolBar/icos/Show Options Page_DN.ico b/plugins/TopToolBar/icos/Show Options Page_DN.ico new file mode 100644 index 0000000000..62558dbd69 Binary files /dev/null and b/plugins/TopToolBar/icos/Show Options Page_DN.ico differ diff --git a/plugins/TopToolBar/icos/Show Options Page_UP.ico b/plugins/TopToolBar/icos/Show Options Page_UP.ico new file mode 100644 index 0000000000..d6945d94f5 Binary files /dev/null and b/plugins/TopToolBar/icos/Show Options Page_UP.ico differ diff --git a/plugins/TopToolBar/icos/Show only Online Users_DN.ico b/plugins/TopToolBar/icos/Show only Online Users_DN.ico new file mode 100644 index 0000000000..87ef1abbb5 Binary files /dev/null and b/plugins/TopToolBar/icos/Show only Online Users_DN.ico differ diff --git a/plugins/TopToolBar/icos/Show only Online Users_UP.ico b/plugins/TopToolBar/icos/Show only Online Users_UP.ico new file mode 100644 index 0000000000..e35e015123 Binary files /dev/null and b/plugins/TopToolBar/icos/Show only Online Users_UP.ico differ diff --git a/plugins/TopToolBar/icos/Sounds Enable_Disable_DN.ico b/plugins/TopToolBar/icos/Sounds Enable_Disable_DN.ico new file mode 100644 index 0000000000..a52dd8a8fe Binary files /dev/null and b/plugins/TopToolBar/icos/Sounds Enable_Disable_DN.ico differ diff --git a/plugins/TopToolBar/icos/Sounds Enable_Disable_UP.ico b/plugins/TopToolBar/icos/Sounds Enable_Disable_UP.ico new file mode 100644 index 0000000000..31342f4ef5 Binary files /dev/null and b/plugins/TopToolBar/icos/Sounds Enable_Disable_UP.ico differ diff --git a/plugins/TopToolBar/icos/icon1.ico b/plugins/TopToolBar/icos/icon1.ico new file mode 100644 index 0000000000..bf61a00df5 Binary files /dev/null and b/plugins/TopToolBar/icos/icon1.ico differ diff --git a/plugins/TopToolBar/icos/mirandad.ico b/plugins/TopToolBar/icos/mirandad.ico new file mode 100644 index 0000000000..423daa96e1 Binary files /dev/null and b/plugins/TopToolBar/icos/mirandad.ico differ diff --git a/plugins/TopToolBar/icos/mirandau.ico b/plugins/TopToolBar/icos/mirandau.ico new file mode 100644 index 0000000000..423daa96e1 Binary files /dev/null and b/plugins/TopToolBar/icos/mirandau.ico differ diff --git a/plugins/TopToolBar/icos/notick.ico b/plugins/TopToolBar/icos/notick.ico new file mode 100644 index 0000000000..4ff17dfa7b Binary files /dev/null and b/plugins/TopToolBar/icos/notick.ico differ diff --git a/plugins/TopToolBar/icos/notick1.ico b/plugins/TopToolBar/icos/notick1.ico new file mode 100644 index 0000000000..d24d6adbbf Binary files /dev/null and b/plugins/TopToolBar/icos/notick1.ico differ diff --git a/plugins/TopToolBar/launchbt.c b/plugins/TopToolBar/launchbt.c new file mode 100644 index 0000000000..cffce36be0 --- /dev/null +++ b/plugins/TopToolBar/launchbt.c @@ -0,0 +1,211 @@ +#include "common.h" +#pragma hdrstop + +extern HINSTANCE hInst; +#define MAXLBUTS 32 + +LBUTOPT LBUTS[MAXLBUTS]; +static int LButCnt=0; + +extern char *AS(char *str,const char *setting,char *addstr); +//wparam i; +INT_PTR LaunchService(WPARAM wParam,LPARAM lParam) +{ + PROCESS_INFORMATION pi; + STARTUPINFO si={0}; + si.cb=sizeof(si); + if ((lParam<0)||(lParam>=MAXLBUTS)){return(-1);}; + + if(CreateProcess(NULL,LBUTS[lParam].lpath,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi)) { + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); + } + Sleep(20); +CallService(MS_TTB_SETBUTTONSTATE,LBUTS[lParam].hframe,TTBST_RELEASED); +return(0); +}; + +//wparam -id +//lparam &LBTOPT +INT_PTR GetLButton(WPARAM wParam,LPARAM lParam) +{ + LBUTOPT *lbo=lParam; + if ((wParam<0)||(wParam>=MAXLBUTS)){return(-1);}; + if (lbo==NULL){return(-1);}; + if (LBUTS[wParam].hframe==0){return(-1);}; + *lbo=LBUTS[wParam]; + + return(0); +}; +//wparam -id +//lparam &LBTOPT +INT_PTR ModifyLButton(WPARAM wParam,LPARAM lParam) +{ + LBUTOPT *lbo=lParam; + if ((wParam<0)||(wParam>=LButCnt)){return(-1);}; + if (lbo==NULL){return(-1);}; + + if (LBUTS[wParam].hframe==0){return(-1);}; + DeleteLBut(wParam,0); + if (LBUTS[wParam].lpath!=NULL){free(LBUTS[wParam].lpath);}; + if (LBUTS[wParam].name!=NULL){free(LBUTS[wParam].name);}; + LBUTS[wParam].name=NULL; + LBUTS[wParam].lpath=NULL; + + + if (lbo->name!=NULL){LBUTS[wParam].name=_strdup(lbo->name);}; + if (lbo->lpath!=NULL){LBUTS[wParam].lpath=_strdup(lbo->lpath);}; + + LBUTS[wParam].hframe=InsertLBut(wParam); + SaveAllLButs(); + return(0); +}; + +int InsertLBut(int id) +{ + TTBButton ttb; + + HBITMAP DefLUp; + HBITMAP DefLDn; + + DefLDn=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_LAUNCHDN)); + DefLUp=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_LAUNCHUP)); + //itoa(SeparatorCnt++,buf,10); + + //wsprintf(buf,"%s %d",Translate("Separator"),id); + memset(&ttb,0,sizeof(ttb)); + ttb.cbSize=sizeof(ttb); + ttb.hbBitmapDown=DefLDn; + ttb.hbBitmapUp=DefLUp; + ttb.dwFlags=TTBBF_VISIBLE|TTBBF_ISLBUTTON; + ttb.pszServiceDown=TTB_LAUNCHSERVICE; + //ttb.pszServiceUp=TTB_LAUNCHSERVICE; + ttb.lParamDown=id; + ttb.name=LBUTS[id].name; + LButCnt++; + return(TTBAddButton(&ttb,0)); +}; +INT_PTR DeleteLBut(WPARAM id,LPARAM lParam) +{ + if (LBUTS[id].hframe!=0) + { + TTBRemoveButton(LBUTS[id].hframe,0); + LBUTS[id].hframe=0; + if (LBUTS[id].name!=NULL){free(LBUTS[id].name);}; + if (LBUTS[id].lpath!=NULL){free(LBUTS[id].lpath);}; + LBUTS[id].name=NULL; + LBUTS[id].lpath=NULL; + + LButCnt--; + }; + return(0); +}; + +int LoadAllLButs() +{ + char buf[255]; + char buf1[10]; + char fixname[255]; + int id,i; +// char *oldtb; + + //must be locked + memset(buf,0,sizeof(buf)); + + memset(LBUTS,0,sizeof(LBUTS)); + for (i=0;i0 + ) + { + Buttons[butpos].dwFlags|=(TTBBF_VISIBLE); + }; + Buttons[butpos].UserDefinedbmDown=DBGetString(0,TTB_OPTDIR,AS(buf,Buttons[butpos].name,"_BmpDown")); + if ((Buttons[butpos].UserDefinedbmDown!=NULL)&&strlen(Buttons[butpos].UserDefinedbmDown)==0){free(Buttons[butpos].UserDefinedbmDown);Buttons[butpos].UserDefinedbmDown=NULL;}; + + Buttons[butpos].UserDefinedbmUp=DBGetString(0,TTB_OPTDIR,AS(buf,Buttons[butpos].name,"_BmpUp")); + if ((Buttons[butpos].UserDefinedbmUp!=NULL)&&strlen(Buttons[butpos].UserDefinedbmUp)==0){free(Buttons[butpos].UserDefinedbmUp);Buttons[butpos].UserDefinedbmUp=NULL;}; + return 0; +} + + +int ttbOptionsChanged() +{ + + //load options + if(TRUE) { + DBVARIANT dbv; + bkColour=DBGetContactSettingDword(NULL,TTB_OPTDIR,"BkColour",TTBDEFAULT_BKCOLOUR); + if(hBmpBackground) {DeleteObject(hBmpBackground); hBmpBackground=NULL;} + if(DBGetContactSettingByte(NULL,TTB_OPTDIR,"UseBitmap",TTBDEFAULT_USEBITMAP)) { + 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(hwndTopToolBar,&rc); + InvalidateRect(hwndTopToolBar,&rc,TRUE); + UpdateWindow(hwndTopToolBar); + } + ArrangeButtons(); + SetAllBitmaps(); + SaveAllSeparators(); + SaveAllButtonsOptions(); + + return(0); +}; + +INT_PTR TTBRemoveButton(WPARAM wParam,LPARAM lParam) +{ + int pos; + + lockbut(); + pos=idtopos(wParam); + if (pos<0||pos>=nButtonsCount){ulockbut();return(-1);}; + + DestroyWindow(Buttons[pos].hwnd); + if (Buttons[pos].pszServiceDown!=NULL) free(Buttons[pos].pszServiceDown); + if (Buttons[pos].pszServiceUp!=NULL) free(Buttons[pos].pszServiceUp); + RemoveItemFromList(pos,&Buttons,&nButtonsCount); + ArrangeButtons(); + ulockbut(); + OptionsPageRebuild(); + return(0); + +}; +static HBITMAP DrawBorderForBitmap(HBITMAP hb,BOOL up) +{ + HBITMAP Border,workbmp; + HDC workdc,destdc,srcdc; + + Border=LoadBitmap(hInst,MAKEINTRESOURCE(up?IDB_BORDERUP:IDB_BORDERDN)); + workdc=GetDC(hwndContactList); + destdc=CreateCompatibleDC(workdc); + srcdc=CreateCompatibleDC(workdc); + + workbmp=CreateBitmap(BUTTWIDTH,BUTTHEIGHT,1,GetDeviceCaps(workdc,BITSPIXEL),NULL); + SelectObject(destdc,workbmp); + + SelectObject(srcdc,Border); + + BitBlt(destdc,0,0,BUTTWIDTH,BUTTHEIGHT,srcdc,0,0,SRCCOPY); + SelectObject(srcdc,hb); + BitBlt(destdc,1,1,BUTTWIDTH-4,BUTTHEIGHT-4,srcdc,0,0,SRCCOPY); + + + + DeleteDC(destdc); + DeleteDC(srcdc); + ReleaseDC(hwndContactList,workdc); + return(workbmp); +}; + +static int UpdateToolTip(int bpos) +{ + { + TOOLINFO ti; + + ZeroMemory(&ti,sizeof(ti)); + ti.cbSize=sizeof(ti); + ti.lpszText=Buttons[bpos].tooltip; + ti.hinst=hInst; + ti.uFlags=TTF_IDISHWND|TTF_SUBCLASS ; + ti.uId=(UINT_PTR)Buttons[bpos].hwnd; + return(SendMessage(Buttons[bpos].hwndTip,TTM_UPDATETIPTEXT ,0,(LPARAM)&ti)); + } + +}; + +boolean nameexists(const char *name) +{ + //must be locked + int i; + + for (i=0;icbSize==sizeof(TTBButton)) + { + //(TTBButton)but=*((TTBButton*)wParam); + memcpy(&but,(void *)wParam,sizeof(TTBButton)); + } + if (((TTBButton*)wParam)->cbSize==sizeof(TTBButtonV2)) + { + memcpy(&but,(void *)wParam,sizeof(TTBButtonV2)); + } + + if ( (but.name==NULL) || nameexists(but.name)){return(-1);}; + + Buttons[i].id=nextButtonId++; + Buttons[i].hbBitmapDown=but.hbBitmapDown; + Buttons[i].hbBitmapUp=but.hbBitmapUp; + Buttons[i].hbDefBitmapDown=but.hbBitmapDown; + Buttons[i].hbDefBitmapUp =but.hbBitmapUp; + + if(but.pszServiceDown!=NULL) Buttons[i].pszServiceDown=strdup(but.pszServiceDown); + if(but.pszServiceUp!=NULL) Buttons[i].pszServiceUp=strdup(but.pszServiceUp); + Buttons[i].name=strdup(but.name); + + Buttons[i].dwFlags=but.dwFlags; + + if (Buttons[i].dwFlags&TTBBF_DRAWBORDER) + { + Buttons[i].hbWBordBitmapDown=DrawBorderForBitmap(Buttons[i].hbBitmapDown,FALSE); + Buttons[i].hbWBordBitmapUp=DrawBorderForBitmap(Buttons[i].hbBitmapUp,TRUE); + }; + + Buttons[i].wParamUp=but.wParamUp; + Buttons[i].lParamUp=but.lParamUp; + Buttons[i].wParamDown=but.wParamDown; + Buttons[i].lParamDown=but.lParamDown; + + Buttons[i].dwFlags=but.dwFlags; + + Buttons[i].bPushed=(but.dwFlags&TTBBF_PUSHED)?TRUE:FALSE; + + CreateOneWindow(i); + + Buttons[i].hIconUp =but.hIconUp ; + Buttons[i].hIconDn =but.hIconDn ; + + + if (UseIcoLib&&(!(Buttons[i].dwFlags&TTBBF_ISSEPARATOR))) + { + char buf[256]; + sprintf(buf,"%s_up",Buttons[i].name); + Buttons[i].hIconUp=LoadIconFromLibrary("TopToolBar",buf,buf,but.hIconDn,TRUE,NULL); + sprintf(buf,"%s_dn",Buttons[i].name); + Buttons[i].hIconDn=LoadIconFromLibrary("TopToolBar",buf,buf,but.hIconUp,TRUE,NULL); + + } + + + //WS_EX_TRANSPARENT + //SetWindowLong(Buttons[i].hwnd,GWL_EXSTYLE,WS_EX_TRANSPARENT); + + + Buttons[i].hwndTip + =CreateWindowEx(0, TOOLTIPS_CLASS, NULL, + WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, + CW_USEDEFAULT, CW_USEDEFAULT, + CW_USEDEFAULT, CW_USEDEFAULT, + hwndTopToolBar, NULL, hInst, + NULL); + +SetWindowPos(Buttons[i].hwndTip, HWND_TOPMOST,0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + { + TOOLINFO ti; + int res; + + ZeroMemory(&ti,sizeof(ti)); + ti.cbSize=sizeof(ti); + ti.lpszText=""; + ti.hinst=hInst; + ti.uFlags=TTF_IDISHWND|TTF_SUBCLASS ; + ti.uId=(UINT_PTR)Buttons[i].hwnd; + res=SendMessage(Buttons[i].hwndTip,TTM_ADDTOOL,0,(LPARAM)&ti); + } + + SendMessage(Buttons[i].hwndTip,TTM_ACTIVATE,(WPARAM)(Buttons[i].dwFlags&TTBBF_SHOWTOOLTIP)?TRUE:FALSE,0); + + SetWindowLong(Buttons[i].hwnd,GWLP_USERDATA,Buttons[i].id); + + //lastxpos+=BUTTWIDTH+2; + + { + //char readbuf[256]; + //sprintf(readbuf,"(%08x)Adding TTB Button:%s (%08x) id(%d),current buttons count %d\r\n",wParam,Buttons[i].name,Buttons[i].dwFlags,Buttons[i].id,nButtonsCount); + //OutputDebugStringMy(readbuf); + } + + + nButtonsCount++; + + retval=Buttons[i].id; + DBLoadButtonSettings(i); + applyuserbitmaps(i); + + SetButtBitmap(i); + ulockbut(); + ArrangeButtons(); + OptionsPageRebuild(); + + { + //char readbuf[256]; + //sprintf(readbuf,"(%08x)Added TTB Button:%s (%08x) id(%d),current buttons count %d, All Done\r\n",wParam,Buttons[i].name,Buttons[i].dwFlags,Buttons[i].id,nButtonsCount); + //OutputDebugStringMy(readbuf); + } + + return(retval); +}; + +/* +//wparam=*TTBButton; +int TTBAddButton(WPARAM wParam,LPARAM lParam) +{ + int i,retval; + TTBButton but; + + if (wParam==NULL){return(-1);}; + if (hwndContactList==0){hwndContactList=CallService(MS_CLUI_GETHWND,0,0);}; + if (hwndContactList==0) + { + //oops clui even now not loaded...sorry no buttons available + return(-1); + } + lockbut(); + if (nButtonsCount==MAX_BUTTONS){return(-1);}; + + + i=nButtonsCount; + but=*((TTBButton*)wParam); + if (but.cbSize!=sizeof(but)){return(-1);}; + if ( (but.name==NULL) || nameexists(but.name)){return(-1);}; + + Buttons[i].id=nextButtonId++; + Buttons[i].hbBitmapDown=but.hbBitmapDown; + Buttons[i].hbBitmapUp=but.hbBitmapUp; + Buttons[i].hbDefBitmapDown=but.hbBitmapDown; + Buttons[i].hbDefBitmapUp =but.hbBitmapUp; + + if(but.pszServiceDown!=NULL) Buttons[i].pszServiceDown=strdup(but.pszServiceDown); + if(but.pszServiceUp!=NULL) Buttons[i].pszServiceUp=strdup(but.pszServiceUp); + Buttons[i].name=strdup(but.name); + + Buttons[i].dwFlags=but.dwFlags; + + if (Buttons[i].dwFlags&TTBBF_DRAWBORDER) + { + Buttons[i].hbWBordBitmapDown=DrawBorderForBitmap(Buttons[i].hbBitmapDown,FALSE); + Buttons[i].hbWBordBitmapUp=DrawBorderForBitmap(Buttons[i].hbBitmapUp,TRUE); + }; + + Buttons[i].wParamUp=but.wParamUp; + Buttons[i].lParamUp=but.lParamUp; + Buttons[i].wParamDown=but.wParamDown; + Buttons[i].lParamDown=but.lParamDown; + + Buttons[i].dwFlags=but.dwFlags; + + Buttons[i].bPushed=(but.dwFlags&TTBBF_PUSHED)?TRUE:FALSE; + + CreateOneWindow(i); + + if (UseIcoLib&&(!(Buttons[i].dwFlags&TTBBF_ISSEPARATOR))) + { + char buf[256]; + sprintf(buf,"%s_up",Buttons[i].name); + Buttons[i].hIconUp=LoadIconFromLibrary("TopToolBar",buf,buf,NULL,TRUE,NULL); + sprintf(buf,"%s_dn",Buttons[i].name); + Buttons[i].hIconDn=LoadIconFromLibrary("TopToolBar",buf,buf,NULL,TRUE,NULL); + + } + + + //WS_EX_TRANSPARENT + //SetWindowLong(Buttons[i].hwnd,GWL_EXSTYLE,WS_EX_TRANSPARENT); + + + Buttons[i].hwndTip + =CreateWindowEx(NULL, TOOLTIPS_CLASS, NULL, + WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, + CW_USEDEFAULT, CW_USEDEFAULT, + CW_USEDEFAULT, CW_USEDEFAULT, + hwndTopToolBar, NULL, hInst, + NULL); + +SetWindowPos(Buttons[i].hwndTip, HWND_TOPMOST,0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + { + TOOLINFO ti; + int res; + + ZeroMemory(&ti,sizeof(ti)); + ti.cbSize=sizeof(ti); + ti.lpszText=""; + ti.hinst=hInst; + ti.uFlags=TTF_IDISHWND|TTF_SUBCLASS ; + ti.uId=Buttons[i].hwnd; + res=SendMessage(Buttons[i].hwndTip,TTM_ADDTOOL,0,&ti); + } + + SendMessage(Buttons[i].hwndTip,TTM_ACTIVATE,(WPARAM)(Buttons[i].dwFlags&TTBBF_SHOWTOOLTIP)?TRUE:FALSE,0); + + SetWindowLong(Buttons[i].hwnd,GWL_USERDATA,Buttons[i].id); + + //lastxpos+=BUTTWIDTH+2; + + + nButtonsCount++; + + retval=Buttons[i].id; + DBLoadButtonSettings(i); + applyuserbitmaps(i); + + SetButtBitmap(i); + ulockbut(); + ArrangeButtons(); + OptionsPageRebuild(); + return(retval); +}; + +*/ + +int sortfunc(const void *a,const void *b) +{ + SortData *sd1,*sd2; + sd1=a; + sd2=b; + if (sd1->arrangeval > sd2->arrangeval){return(1);}; + if (sd1->arrangeval < sd2->arrangeval){return(-1);}; + /*if (sd1->arrangeval = sd2->arrangeval)*/{return(0);}; + +}; +boolean isSep(int i) +{ + if (Buttons[i].dwFlags&TTBBF_ISSEPARATOR){return(TRUE);} + return(FALSE); +}; +int getbutw(i) +{ + RECT rc; + GetWindowRect(Buttons[i].hwnd,&rc); + return(rc.right-rc.left); +}; + +int MakeSortArr(boolean vis) +{ + int i; + int v; + v=0; + memset(&arrangedbuts,0,sizeof(arrangedbuts)); + for (i=0;i0) + { + qsort(&(arrangedbuts[0]),v,sizeof(SortData),sortfunc); + }; + return(v); + +}; + +int CreateOneWindow(int ButtonPos) +{ + if (DBGetContactSettingByte(0,TTB_OPTDIR,"UseMirandaButtonClass",UseMirandaButtonClassDefaultValue)&& !(Buttons[ButtonPos].dwFlags&TTBBF_ISSEPARATOR)) + { + Buttons[ButtonPos].hwnd=CreateWindow(MYMIRANDABUTTONCLASS,"",BS_PUSHBUTTON|WS_CHILD|WS_TABSTOP|SS_NOTIFY,0,0,BUTTWIDTH,BUTTHEIGHT,hwndTopToolBar,NULL,hInst,0); + //"CLCButtonClass" + //SS_NOTIFY| + //MYMIRANDABUTTONCLASS + }else + { + Buttons[ButtonPos].hwnd=CreateWindow("STATIC","",WS_CHILD|SS_NOTIFY, + 0,0,BUTTWIDTH,BUTTHEIGHT,hwndTopToolBar,NULL,hInst,0); + }; + SetWindowLong(Buttons[ButtonPos].hwnd,GWLP_USERDATA,Buttons[ButtonPos].id); + if (DBGetContactSettingByte(0,TTB_OPTDIR,"UseFlatButton",1)) + SendMessage(Buttons[ButtonPos].hwnd,BUTTONSETASFLATBTN,0,0); + + return(0); + +} +int RecreateWindows() +{ + int i; + lockbut(); + for (i=0;i0) + { + for (i=0;iwinrc.left)) + { + lastxpos=1; + lastypos+=BUTTHEIGHT+2; + if (Buttons[arrangedbuts[i+1].oldpos].dwFlags&TTBBF_VISIBLE) + { + CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_HEIGHT,hFrameTopWindow),lastypos+BUTTHEIGHT+1); + newheight=lastypos+BUTTHEIGHT+1; + }; + } + else + { + lastxpos+=(isSep(arrangedbuts[i].oldpos))?(SEPWIDTH+2):(BUTTWIDTH+1); + if (isSep(arrangedbuts[i+1].oldpos)) + { + lastxpos+=1; + }; + + + + }; + + }; + }; + + } + v=MakeSortArr(FALSE); + ulockbut(); + + //RedrawWindow(hwndTopToolBar,NULL,NULL,RDW_UPDATENOW|RDW_ALLCHILDREN|RDW_ERASE|RDW_INVALIDATE); + //UpdateWindow(hwndTopToolBar); + if (newheight!=winrc.top) + { + //SendMessage(GetParent(hwndTopToolBar),WM_SIZE,0,0); + }; + + return (1); + +}; + + +int applyuserbitmaps(int pos) +{ +int t=IMAGE_BITMAP; + Buttons[pos].hbBitmapDown=Buttons[pos].hbDefBitmapDown; +Buttons[pos].hbBitmapUp=Buttons[pos].hbDefBitmapUp; +if (Buttons[pos].UserDefinedbmDown!=NULL) +{ + if (strstr(Buttons[pos].UserDefinedbmDown,".ico")) {t=IMAGE_ICON;}; + Buttons[pos].hbBitmapDown=LoadImage(0,Buttons[pos].UserDefinedbmDown,t,0,0,LR_LOADFROMFILE); + //Buttons[pos].hbBitmapDown=CopyImage(Buttons[pos].hbBitmapDown,t,0,0,LR_CREATEDIBSECTION); +}; + +if (Buttons[pos].UserDefinedbmUp!=NULL) +{ + if (strstr(Buttons[pos].UserDefinedbmUp,".ico")) {t=IMAGE_ICON;}; + Buttons[pos].hbBitmapUp=LoadImage(0,Buttons[pos].UserDefinedbmUp,t,0,0,LR_LOADFROMFILE); +}; + + +return(0); +}; + +int SetAllBitmaps() +{ + int i; + + lockbut(); + for (i=0;i=nButtonsCount){ulockbut();;return(-1);}; + + Buttons[pos].bPushed=(lParam&TTBST_PUSHED)?TRUE:FALSE; + Buttons[pos].bPushed=(lParam&TTBST_RELEASED)?FALSE:TRUE; + SetButtBitmap(pos); + ulockbut(); + return(0); +}; + +//wparam=hTTBButton +//lparam=0 +//return=state +INT_PTR TTBGetState(WPARAM wParam,LPARAM lParam) +{ + int pos,retval; + + lockbut(); + pos=idtopos(wParam); + if (pos<0||pos>=nButtonsCount){ulockbut();return(-1);}; + + retval=(Buttons[pos].bPushed==TRUE)?TTBST_PUSHED:TTBST_RELEASED; + ulockbut(); + return(retval); +}; + +INT_PTR TTBGetOptions(WPARAM wParam,LPARAM lParam) +{ + int pos,retval; + + lockbut(); + pos=idtopos(HIWORD(wParam)); + if (pos<0||pos>=nButtonsCount){ulockbut();return(-1);}; + + switch(LOWORD(wParam)) + { + case TTBO_FLAGS: + + retval=Buttons[pos].dwFlags&(!TTBBF_PUSHED); + if (Buttons[pos].bPushed){retval|=TTBBF_PUSHED;}; + break; + + case TTBO_POS: + retval=(int)pos; + break; + + case TTBO_TIPNAME: + retval=(int)Buttons[pos].tooltip; + break; + + case TTBO_ALLDATA: + { + + lpTTBButton lpTTB=lParam; + + if (lParam==0){break;}; + if (lpTTB->cbSize!=sizeof(TTBButton)){break;}; + lpTTB->dwFlags=Buttons[pos].dwFlags&(!TTBBF_PUSHED); + if (Buttons[pos].bPushed){lpTTB->dwFlags|=TTBBF_PUSHED;}; + + lpTTB->hbBitmapDown=Buttons[pos].hbBitmapDown; + lpTTB->hbBitmapUp=Buttons[pos].hbBitmapUp; + lpTTB->lParamUp=Buttons[pos].lParamUp; + lpTTB->wParamUp=Buttons[pos].wParamUp; + lpTTB->lParamDown=Buttons[pos].lParamDown; + lpTTB->wParamDown=Buttons[pos].wParamDown; + + lpTTB->pszServiceDown=_strdup(Buttons[pos].pszServiceDown); + lpTTB->pszServiceUp=_strdup(Buttons[pos].pszServiceUp); + + retval=lpTTB; + break; + } + + default: + retval=-1; + break; + } + + + ulockbut(); + return(retval); + +}; + + +INT_PTR TTBSetOptions(WPARAM wParam,LPARAM lParam) +{ + int pos,retval; + + lockbut(); + pos=idtopos(HIWORD(wParam)); + if (pos<0||pos>=nButtonsCount){ulockbut();return(-1);}; + + switch(LOWORD(wParam)) + { + case TTBO_FLAGS: + //retval=Buttons[i].dwFlags; + if (Buttons[pos].dwFlags==lParam){break;}; + Buttons[pos].dwFlags=lParam; + Buttons[pos].bPushed=(Buttons[pos].dwFlags&TTBBF_PUSHED)?TRUE:FALSE; + if (Buttons[pos].dwFlags&TTBBF_DRAWBORDER) + { + Buttons[pos].hbWBordBitmapDown=DrawBorderForBitmap(Buttons[pos].hbBitmapDown,FALSE); + Buttons[pos].hbWBordBitmapUp=DrawBorderForBitmap(Buttons[pos].hbBitmapUp,TRUE); + }; + + SetButtBitmap(pos); + SendMessage(Buttons[pos].hwndTip,TTM_ACTIVATE,(WPARAM)(Buttons[pos].dwFlags&TTBBF_SHOWTOOLTIP)?TRUE:FALSE,0); + retval=1; + break; + + case TTBO_POS: + { + TopButtonInt tempttb; + + if (lParam<0||lParam>=nButtonsCount){break;}; + tempttb=Buttons[lParam]; + Buttons[lParam]=Buttons[pos]; + Buttons[pos]=tempttb; + + ArrangeButtons(); + + retval=(int)1; + break; + } + + case TTBO_TIPNAME: + if (lParam==0){break;}; + if (Buttons[pos].tooltip!=NULL){free(Buttons[pos].tooltip);}; + Buttons[pos].tooltip=_strdup((LPCSTR)lParam); + UpdateToolTip(pos); + retval=1; + break; + + case TTBO_ALLDATA: + { + + lpTTBButton lpTTB=lParam; + + if (lParam==0){break;}; + if (lpTTB->cbSize!=sizeof(TTBButton)){break;}; + Buttons[pos].dwFlags=lpTTB->dwFlags; + Buttons[pos].hbBitmapDown=lpTTB->hbBitmapDown; + Buttons[pos].hbBitmapUp=lpTTB->hbBitmapUp; + Buttons[pos].lParamUp=lpTTB->lParamUp; + Buttons[pos].wParamUp=lpTTB->wParamUp; + Buttons[pos].lParamDown=lpTTB->lParamDown; + Buttons[pos].wParamDown=lpTTB->wParamDown; + + if (Buttons[pos].pszServiceDown!=NULL){free(Buttons[pos].pszServiceDown);}; + if (Buttons[pos].pszServiceUp!=NULL){free(Buttons[pos].pszServiceUp);}; + + Buttons[pos].pszServiceDown=_strdup(lpTTB->pszServiceDown); + Buttons[pos].pszServiceUp=_strdup(lpTTB->pszServiceUp); + + if (Buttons[pos].dwFlags&TTBBF_DRAWBORDER) + { + Buttons[pos].hbWBordBitmapDown=DrawBorderForBitmap(Buttons[pos].hbBitmapDown,FALSE); + Buttons[pos].hbWBordBitmapUp=DrawBorderForBitmap(Buttons[pos].hbBitmapUp,TRUE); + }; + + + Buttons[pos].bPushed=(Buttons[pos].dwFlags&TTBBF_PUSHED)?TRUE:FALSE; + SendMessage(Buttons[pos].hwndTip,TTM_ACTIVATE,(WPARAM)(Buttons[pos].dwFlags&TTBBF_SHOWTOOLTIP)?TRUE:FALSE,0); + ArrangeButtons(); + retval=1; + break; + } + + default: + retval=-1; + break; + } + + + ulockbut(); + return(retval); + +}; + + +BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) +{ + hInst=hinstDLL; + return TRUE; +} + +LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) + { + case WM_CREATE: + { + { + hwndTopToolBar=hwnd; + } + + return(FALSE); + }; + + case WM_MOVE: + { + //RedrawWindow(hwnd,NULL,NULL,RDW_INVALIDATE|RDW_UPDATENOW|RDW_ALLCHILDREN); + return(0); + }; + + case WM_WINDOWPOSCHANGING: + case WM_SIZE: + { + ArrangeButtons(); + + //RedrawWindow(hwnd,NULL,NULL,RDW_INVALIDATE|RDW_UPDATENOW|RDW_ALLCHILDREN); + return(0); + }; + + //InvalidateRect(hwnd,NULL,TRUE); + //ArrangeButtons(); + case WM_PAINT: + { + HDC hdcMem,hdc; + RECT clRect,*rcPaint; + int yScroll=0; + int y; + PAINTSTRUCT paintst; + HBITMAP hBmpOsb,hOldBmp; + DWORD style=GetWindowLong(hwnd,GWL_STYLE); + int grey=0; + HBRUSH hBrushAlternateGrey=NULL; + + InvalidateRect(hwnd,0,FALSE); + + hdc=BeginPaint(hwnd,&paintst); + rcPaint=&(paintst.rcPaint); + + GetClientRect(hwnd,&clRect); + if(rcPaint==NULL) rcPaint=&clRect; + y=-yScroll; + hdcMem=CreateCompatibleDC(hdc); + hBmpOsb=CreateBitmap(clRect.right,clRect.bottom,1,GetDeviceCaps(hdc,BITSPIXEL),NULL); + hOldBmp=SelectObject(hdcMem,hBmpOsb); + SetBkMode(hdcMem,TRANSPARENT); + { HBRUSH hBrush,hoBrush; + + hBrush=CreateSolidBrush(bkColour); + hoBrush=(HBRUSH)SelectObject(hdcMem,hBrush); + FillRect(hdcMem,rcPaint,hBrush); + SelectObject(hdcMem,hoBrush); + DeleteObject(hBrush); + if(hBmpBackground) { + BITMAP bmp; + HDC hdcBmp; + int x,y; + int maxx,maxy; + int destw,desth; + + GetObject(hBmpBackground,sizeof(bmp),&bmp); + hdcBmp=CreateCompatibleDC(hdcMem); + SelectObject(hdcBmp,hBmpBackground); + y=backgroundBmpUse&CLBF_SCROLL?-yScroll:0; + maxx=backgroundBmpUse&CLBF_TILEH?clRect.right:1; + maxy=backgroundBmpUse&CLBF_TILEV?maxy=rcPaint->bottom:y+1; + switch(backgroundBmpUse&CLBM_TYPE) { + case CLB_STRETCH: + if(backgroundBmpUse&CLBF_PROPORTIONAL) { + if(clRect.right*bmp.bmHeighttop-desth) continue; + for(x=0;xleft,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); + + + return(0); + }; + case WM_LBUTTONDOWN: + { + if (DBGetContactSettingByte(NULL,"CLUI","ClientAreaDrag",0)) { + POINT pt; + //pt=nm->pt; + GetCursorPos(&pt); + return SendMessage(GetParent(hwnd), WM_SYSCOMMAND, SC_MOVE|HTCAPTION,MAKELPARAM(pt.x,pt.y)); + } + return(0); + }; + case WM_NOTIFY: + { + int id=wParam; + LPNMHDR lpnm=(LPNMHDR)lParam; + switch(lpnm->code) + { + case 1:{;}; + }; + + return(0); + }; + case WM_COMMAND: + { + if ((HIWORD(wParam)==STN_CLICKED|| HIWORD(wParam)==STN_DBLCLK)) + { + int id=GetWindowLong((HWND)lParam,GWLP_USERDATA); + int pos; + + if (id==0){break;}; + lockbut(); + pos=idtopos(id); + if(isSep(pos)){ulockbut();return(0);}; + if (Buttons[pos].bPushed) + {//Dn -> Up + Buttons[pos].bPushed=!Buttons[pos].bPushed; + SetButtBitmap(pos); + + if(Buttons[pos].pszServiceUp!=NULL) CallService(Buttons[pos].pszServiceUp,Buttons[pos].wParamUp,Buttons[pos].lParamUp); + } + else + {//Up -> Dn + Buttons[pos].bPushed=!Buttons[pos].bPushed; + SetButtBitmap(pos); + + if(Buttons[pos].pszServiceDown!=NULL) CallService(Buttons[pos].pszServiceDown,Buttons[pos].wParamDown,Buttons[pos].lParamDown); + }; + ulockbut(); + }; + break; + }; + + default: + return DefWindowProc(hwnd, msg, wParam, lParam); + + }; + return(TRUE); +}; + +int addTopToolBarWindow(HWND parent) +{ + WNDCLASS wndclass; + + CLISTFrame Frame; + int retval; + HWND pluginwind; + char pluginname[]="TopToolBar"; + + wndclass.style = 0; + wndclass.lpfnWndProc = TopToolBarProc; + wndclass.cbClsExtra = 0; + wndclass.cbWndExtra = 0; + wndclass.hInstance = hInst; + wndclass.hIcon = NULL; + wndclass.hCursor = LoadCursor (NULL, IDC_ARROW); + wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);//NULL;//(HBRUSH)(COLOR_3DFACE+1); + wndclass.lpszMenuName = NULL; + wndclass.lpszClassName = pluginname; + RegisterClass(&wndclass); + pluginwind=CreateWindow(pluginname,pluginname, + WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN, + 0,0,0,0,parent,NULL,hInst,NULL); + + //font=SendMessage(parent,WM_GETFONT,0,0); + //SendMessage(pluginwind,WM_SETFONT,font,0); + ttbOptionsChanged(); + // + memset(&Frame,0,sizeof(Frame)); + Frame.name=(char *)malloc(255); + memset(Frame.name,0,255); + memcpy(Frame.name,pluginname,sizeof(pluginname)); + Frame.cbSize=sizeof(Frame); + Frame.hWnd=pluginwind; + Frame.align=alTop; + Frame.Flags=F_VISIBLE|F_NOBORDER|F_LOCKED; + Frame.height=18; + + retval=CallService(MS_CLIST_FRAMES_ADDFRAME,(WPARAM)&Frame,0); + free(Frame.name); + + + return(retval); + + +}; + +VOID CALLBACK TimerProc( + HWND hwnd, // handle to window + UINT uMsg, // WM_TIMER message + UINT_PTR idEvent, // timer identifier + DWORD dwTime // current system time +) +{ + KillTimer(0,idEvent); + NotifyEventHooks(hHookTTBModuleLoaded, 0,0); + + +}; + +static INT_PTR OnEventFire(WPARAM wParam,LPARAM lParam) { + CallService(MS_SYSTEM_REMOVEWAIT,wParam,0); + StopArrange=FALSE; + NotifyEventHooks(hHookTTBModuleLoaded, 0,0); + return(0); +}; + +int OnIconChange(WPARAM wParam,LPARAM lParam) { +int i; + lockbut(); + for (i=0;i=MAXSEPS)) + { + MessageBoxA(0,"Wrong id","Error",0); + return(0); + }; + + if (Separators[id]!=0) + { + TTBRemoveButton(Separators[id],0); + Separators[id]=0; + SeparatorCnt--; + }; + SaveAllSeparators(); + return (1); +}; +int LoadAllSeparators() +{ + char buf[255]; + char buf1[10]; + int id,i; + + //must be locked + memset(buf,0,sizeof(buf)); + + memset(Separators,0,sizeof(Separators)); + for (i=0;i',':','|','"' 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.c b/plugins/TopToolBar/ttbopt.c new file mode 100644 index 0000000000..f202e7a6c0 --- /dev/null +++ b/plugins/TopToolBar/ttbopt.c @@ -0,0 +1,970 @@ +#include "common.h" +#include +#pragma hdrstop + +static BOOL CALLBACK DlgProcTTBBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); +extern int ttbOptionsChanged(); +extern HINSTANCE hInst; + +extern TopButtonInt Buttons[MAX_BUTTONS]; +extern int nButtonsCount; + +extern SortData arrangedbuts[MAX_BUTTONS]; + +extern void lockbut(); +extern void ulockbut(); +extern int applyuserbitmaps(); + +struct OrderData { + int dragging; + HTREEITEM hDragItem; +}; + +char *SetEndSlash(char *str) +{ + char *outs; + if (str==NULL){return(NULL);}; + if (strlen(str)==0){return(NULL);}; + outs=str; + + if (str[strlen(str)-1]!='\\') + { + outs=(char*)malloc(strlen(str)+3); + memset(outs,0,strlen(str)+3); + strcat(outs,str); + outs[strlen(str)]='\\'; + //free(str); + }; + return(outs); +}; +boolean FileExists(char *fname) +{ + HANDLE h; + WIN32_FIND_DATA wfd; + + + + /* + h=CreateFile(fname,GENERIC_READ, + FILE_SHARE_READ, + NULL,OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + */ + memset(&wfd,0,sizeof(wfd)); + h=FindFirstFile(fname,&wfd); + + if (h==INVALID_HANDLE_VALUE) { + return(FALSE); + } + else + { + FindClose(h); + return(TRUE); + }; + + +}; + + +char *ReplaceBadChar(char *str,char bad,char toreplace) +{ + int i; + for (i=0;i','_'); + ReplaceBadChar(str,'<','_'); + ReplaceBadChar(str,':','_'); + ReplaceBadChar(str,'*','_'); + + return(str); +}; + +void AssignBitmapsFromDir(char *dir) +{ + char curnameUP[512],curnameDN[512]; + char ChangedName[512]; + + int i; + + if (dir==NULL){return;}; + if (strlen(dir)==0){return;}; + dir=SetEndSlash(dir); +lockbut(); + for(i=0;iname; + pos=((ButtonOptData *)tvi.lParam)->pos; + if (pos>=0&&posshow==TRUE )?TTBBF_VISIBLE:0; + Buttons[pos].arrangedpos=count; + // int DBSaveButtonSettings(int butpos) + }; + + + tvi.hItem=TreeView_GetNextSibling(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),tvi.hItem); + + count++; + } + ulockbut(); + ttbOptionsChanged(); + return (TRUE); +}; + +int BuildTree(HWND hwndDlg) +{ + struct OrderData *dat; + TVINSERTSTRUCT tvis; + ButtonOptData *PD; + int i; + + PostMessage(GetDlgItem(hwndDlg,IDC_BMPUP), STM_SETIMAGE,IMAGE_BITMAP,0); + PostMessage(GetDlgItem(hwndDlg,IDC_BMPDN), STM_SETIMAGE,IMAGE_BITMAP,0); + + // LockWindowUpdate(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE)); + dat=(struct OrderData*)GetWindowLong(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),GWLP_USERDATA); + tvis.hParent=NULL; + tvis.hInsertAfter=TVI_LAST; + tvis.item.mask=TVIF_PARAM|TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE; + TreeView_DeleteAllItems(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE)); + //CheckBUTORDER(); + + + if (nButtonsCount==0){return(FALSE);}; + + for(i=0;iname=Buttons[arrangedbuts[i].oldpos].name; + PD->show=Buttons[arrangedbuts[i].oldpos].dwFlags&TTBBF_VISIBLE?TRUE:FALSE; + PD->pos=arrangedbuts[i].oldpos; + tvis.item.lParam=(LPARAM)PD; + tvis.item.pszText=Translate(PD->name); + tvis.item.iImage=tvis.item.iSelectedImage=PD->show; + TreeView_InsertItem(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),&tvis); + + tvis.item.iImage=tvis.item.iSelectedImage=PD->show; + }; + // LockWindowUpdate(NULL); + return (TRUE); +}; + +void SetImagesForCurrent (HWND hwndDlg,int curselect) +{ + + { + + int t=IMAGE_BITMAP; + char *curname; + + PostMessage(GetDlgItem(hwndDlg,IDC_BMPUP), STM_SETIMAGE,t,0); + PostMessage(GetDlgItem(hwndDlg,IDC_BMPDN), STM_SETIMAGE,t,0); + + curname=Buttons[curselect].UserDefinedbmUp; + if (curname!=NULL) + { + int st; + if (strstr(curname,".ico")) {t=IMAGE_ICON;}; + st=WS_CHILDWINDOW|SS_NOTIFY|WS_VISIBLE;(t==IMAGE_ICON)?(st|=SS_ICON):(st|=SS_BITMAP); + SetWindowLong(GetDlgItem(hwndDlg,IDC_BMPUP),GWL_STYLE,st); + }else + { + SetWindowLong(GetDlgItem(hwndDlg,IDC_BMPUP),GWL_STYLE,WS_CHILDWINDOW|WS_VISIBLE|SS_NOTIFY|(Buttons[curselect].hbBitmapDown==NULL?SS_ICON:SS_BITMAP)); + t=IMAGE_ICON; + } + + PostMessage(GetDlgItem(hwndDlg,IDC_BMPUP), STM_SETIMAGE,t,(LPARAM)(Buttons[curselect].hbBitmapUp==NULL?Buttons[curselect].hIconUp:Buttons[curselect].hbBitmapUp)); + + curname=Buttons[curselect].UserDefinedbmDown; + if (curname!=NULL) + { + int st; + if (strstr(curname,".ico")) {t=IMAGE_ICON;}; + st=WS_CHILDWINDOW|SS_NOTIFY|WS_VISIBLE;(t==IMAGE_ICON)?(st|=SS_ICON):(st|=SS_BITMAP); + SetWindowLong(GetDlgItem(hwndDlg,IDC_BMPDN),GWL_STYLE,st); + }else + { + SetWindowLong(GetDlgItem(hwndDlg,IDC_BMPDN),GWL_STYLE,WS_CHILDWINDOW|WS_VISIBLE|SS_NOTIFY|(Buttons[curselect].hbBitmapDown==NULL?SS_ICON:SS_BITMAP)); + t=IMAGE_ICON; + } + + PostMessage(GetDlgItem(hwndDlg,IDC_BMPDN), STM_SETIMAGE,t,(LPARAM)(Buttons[curselect].hbBitmapDown==NULL?Buttons[curselect].hIconDn:Buttons[curselect].hbBitmapDown )); + } +} + +static BOOL CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ struct OrderData *dat; + + dat=(struct OrderData*)GetWindowLong(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),GWLP_USERDATA); + + switch (msg) + { + case WM_INITDIALOG: { + + + TranslateDialogDefault(hwndDlg); + dat=(struct OrderData*)malloc(sizeof(struct OrderData)); + SetWindowLong(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),GWLP_USERDATA,(LONG)dat); + dat->dragging=0; + + //SetWindowLong(GetDlgItem(hwndDlg,IDC_PROTOCOLVISIBILITY),GWL_STYLE,GetWindowLong(GetDlgItem(hwndDlg,IDC_PROTOCOLVISIBILITY),GWL_STYLE)|TVS_NOHSCROLL); + SetWindowLong(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),GWL_STYLE,GetWindowLong(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),GWL_STYLE)|TVS_NOHSCROLL); + + { HIMAGELIST himlCheckBoxes; + himlCheckBoxes=ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),ILC_COLOR4|ILC_MASK,2,2); + ImageList_AddIcon(himlCheckBoxes,LoadIcon(hInst,MAKEINTRESOURCE(IDI_NOTICK))); + ImageList_AddIcon(himlCheckBoxes,LoadIcon(hInst,MAKEINTRESOURCE(IDI_TICK))); + //TreeView_SetImageList(GetDlgItem(hwndDlg,IDC_PROTOCOLVISIBILITY),himlCheckBoxes,TVSIL_NORMAL); + // + TreeView_SetImageList(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),himlCheckBoxes,TVSIL_NORMAL); + + } + PostMessage(GetDlgItem(hwndDlg,IDC_BMPUP), STM_SETIMAGE,IMAGE_BITMAP,0); + PostMessage(GetDlgItem(hwndDlg,IDC_BMPDN), STM_SETIMAGE,IMAGE_BITMAP,0); + SetDlgItemInt(hwndDlg,IDC_BUTTHEIGHT,DBGetContactSettingByte(0,TTB_OPTDIR,"BUTTHEIGHT",16),FALSE); + SetDlgItemInt(hwndDlg,IDC_BUTTWIDTH,DBGetContactSettingByte(0,TTB_OPTDIR,"BUTTWIDTH",20),FALSE); + CheckDlgButton(hwndDlg,IDC_USEMIRANDABUTTON,DBGetContactSettingByte(0,TTB_OPTDIR,"UseMirandaButtonClass",UseMirandaButtonClassDefaultValue)); + CheckDlgButton(hwndDlg,IDC_USEFLAT,DBGetContactSettingByte(0,TTB_OPTDIR,"UseFlatButton",1)); + + if (!ServiceExists(MS_SKIN2_ADDICON)) + { + EnableWindow(GetDlgItem(hwndDlg,IDC_USEICOLIB),FALSE); + } + CheckDlgButton(hwndDlg,IDC_USEICOLIB,ServiceExists(MS_SKIN2_ADDICON)&&DBGetContactSettingByte(0,TTB_OPTDIR,"UseIcoLib",UseIcoLibDefaultValue)); + + + + BuildTree(hwndDlg); + OptionsOpened=TRUE; + EnableWindow(GetDlgItem(hwndDlg,IDC_ENAME),FALSE); + EnableWindow(GetDlgItem(hwndDlg,IDC_EPATH),FALSE); + EnableWindow(GetDlgItem(hwndDlg,IDC_DELLBUTTON),FALSE); + + SetDlgItemText(hwndDlg,IDC_IMGDIR,DBGetString(0,TTB_OPTDIR,"ImgDir")); + SendMessage(hwndDlg,WM_COMMAND,0,0); + OptionshWnd=hwndDlg; + return TRUE; + } + case WM_COMMAND: + { + //if (IDC_BMPUP) + ShowWindow(GetDlgItem(hwndDlg,IDC_BMPUP),IsDlgButtonChecked(hwndDlg,IDC_USEICOLIB)?SW_HIDE:SW_SHOW); + ShowWindow(GetDlgItem(hwndDlg,IDC_BMPDN),IsDlgButtonChecked(hwndDlg,IDC_USEICOLIB)?SW_HIDE:SW_SHOW); + ShowWindow(GetDlgItem(hwndDlg,IDC_DEFAULT),IsDlgButtonChecked(hwndDlg,IDC_USEICOLIB)?SW_HIDE:SW_SHOW); + + ShowWindow(GetDlgItem(hwndDlg,IDC_STATIC1),IsDlgButtonChecked(hwndDlg,IDC_USEICOLIB)?SW_HIDE:SW_SHOW); + ShowWindow(GetDlgItem(hwndDlg,IDC_STATIC2),IsDlgButtonChecked(hwndDlg,IDC_USEICOLIB)?SW_HIDE:SW_SHOW); + ShowWindow(GetDlgItem(hwndDlg,IDC_STATIC3),IsDlgButtonChecked(hwndDlg,IDC_USEICOLIB)?SW_HIDE:SW_SHOW); + + EnableWindow(GetDlgItem(hwndDlg,IDC_USEFLAT),IsDlgButtonChecked(hwndDlg,IDC_USEMIRANDABUTTON)); + + if (HIWORD(wParam)==EN_CHANGE ) + { + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + }; + if ((HIWORD(wParam)==BN_CLICKED|| HIWORD(wParam)==BN_DBLCLK)) + { + int ctrlid=LOWORD(wParam); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + + if (ctrlid==IDC_OPENIMGDIR) + { + char buf[512]; + PCIDLIST_ABSOLUTE res; + + BROWSEINFO bi; + memset(&bi,0,sizeof(bi)); + bi.hwndOwner=hwndDlg; + bi.pszDisplayName=buf; + bi.lpszTitle=Translate("Select Directory"); + bi.ulFlags=BIF_RETURNONLYFSDIRS; + res=SHBrowseForFolder(&bi); + if(res!=NULL) + { + if (SHGetPathFromIDList(res,buf)==TRUE) + { + + SetDlgItemText(hwndDlg,IDC_IMGDIR,(LPCSTR)&buf); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + }; + + }; + + break; + }; + if (ctrlid==IDC_LBUTTONSET) + { + int curselect; + TVITEM tvi; + tvi.hItem=TreeView_GetSelection(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE)); + if (tvi.hItem==NULL){break;}; + + tvi.mask=TVIF_PARAM; + TreeView_GetItem(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),&tvi); + + curselect=((ButtonOptData *)tvi.lParam)->pos; + if (Buttons[curselect].dwFlags&TTBBF_ISLBUTTON) + { + LBUTOPT lbo; + char buf[256]; + memset(&lbo,0,sizeof(lbo)); + + + GetDlgItemText(hwndDlg,IDC_ENAME,buf,255); + lbo.name=_strdup(buf); + + GetDlgItemText(hwndDlg,IDC_EPATH,buf,255); + lbo.lpath=_strdup(buf); + + CallService(TTB_MODIFYLBUTTON,Buttons[curselect].lParamDown,(LPARAM)&lbo); + free(lbo.name); + free(lbo.lpath); + }; + + break; + }; + if (ctrlid==IDC_ADDLBUTTON) + { + if (CallService(TTB_ADDLBUTTON,0,0)==0) + { + // BuildTree(hwndDlg); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + + }; + break; + }; + + if (ctrlid==IDC_DELLBUTTON) + { + int curselect; + TVITEM tvi; + tvi.hItem=TreeView_GetSelection(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE)); + if (tvi.hItem==NULL){break;}; + tvi.mask=TVIF_PARAM; + TreeView_GetItem(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),&tvi); + + curselect=((ButtonOptData *)tvi.lParam)->pos; + if (Buttons[curselect].dwFlags&TTBBF_ISLBUTTON) + { + CallService(TTB_REMOVELBUTTON,Buttons[curselect].lParamDown,0); + EnableWindow(GetDlgItem(hwndDlg,IDC_ENAME),FALSE); + EnableWindow(GetDlgItem(hwndDlg,IDC_EPATH),FALSE); + BuildTree(hwndDlg); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + + }; + + + }; + if (ctrlid==IDC_ADDSEP) + { + if (CallService(TTB_ADDSEPARATOR,0,0)==0) + { + // BuildTree(hwndDlg); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + }; + break; + }; + if (ctrlid==IDC_REMOVESEP) + { + int curselect; + TVITEM tvi; + memset(&tvi,0,sizeof(tvi)); + tvi.hItem=TreeView_GetSelection(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE)); + if (tvi.hItem==NULL){break;}; + + //MessageBoxA(0,"GetSelItem","log",0); + tvi.mask=TVIF_PARAM; + TreeView_GetItem(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),&tvi); + + if (tvi.lParam==0){break;}; + //MessageBoxA(0,"Getting curselect","log",0); + //!!! in win98 cause crash ? + if (IsBadCodePtr(tvi.lParam)) + { + MessageBoxA(0,"Bad Code Ptr: tvi.lParam","log",0); + break; + }; + curselect=((ButtonOptData *)tvi.lParam)->pos; + + if ((curselect>=0)&&(curselectpos; + lockbut(); + + if (Buttons[curselect].UserDefinedbmUp!=NULL){free(Buttons[curselect].UserDefinedbmUp);}; + if (Buttons[curselect].UserDefinedbmDown!=NULL){free(Buttons[curselect].UserDefinedbmDown);}; + Buttons[curselect].UserDefinedbmUp=NULL; + Buttons[curselect].UserDefinedbmDown=NULL; + applyuserbitmaps(curselect); + SetImagesForCurrent(hwndDlg,curselect); + //PostMessage(GetDlgItem(hwndDlg,IDC_BMPUP), STM_SETIMAGE,IMAGE_BITMAP,Buttons[curselect].hbBitmapUp); + //PostMessage(GetDlgItem(hwndDlg,IDC_BMPDN), STM_SETIMAGE,IMAGE_BITMAP,Buttons[curselect].hbBitmapDown); + + ulockbut(); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + }; + }; + + if ((HIWORD(wParam)==STN_CLICKED|| HIWORD(wParam)==STN_DBLCLK)) + { + int ctrlid=LOWORD(wParam); + if (ctrlid==IDC_BMPUP||ctrlid==IDC_BMPDN) + { + + + char filename[MAX_PATH]; + OPENFILENAME ofn={0}; + char filter[512],*pfilter; + int curselect; + TVITEM tvi; + + tvi.hItem=TreeView_GetSelection(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE)); + if (tvi.hItem==NULL){break;}; + tvi.mask=TVIF_PARAM; + TreeView_GetItem(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),&tvi); + + if (tvi.lParam==0){break;}; + curselect=((ButtonOptData *)tvi.lParam)->pos; + + + filename[0]=0; + memset(&ofn,0,sizeof(ofn)); + ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; + ofn.hwndOwner = hwndDlg; + ofn.hInstance = NULL; + strcpy(filter,Translate("Bitmap/Icon files")); + //sprintf(filter,"Bitmap/Icon files \0 *.bmp;*.ico \0\0" ); + + strcat(filter," (*.bmp;*.ico)"); + + pfilter=filter+strlen(filter)+1; + strcpy(pfilter,"*.bmp;*.ico"); + pfilter=pfilter+strlen(pfilter)+1; + + strcpy(pfilter,Translate("All Files")); + strcat(pfilter,"(*)"); + pfilter=pfilter+strlen(pfilter)+1; + strcpy(pfilter,"*"); + + + pfilter=pfilter+strlen(pfilter)+1; + *pfilter='\0'; + + ofn.lpstrFilter = filter; + ofn.lpstrFile = filename; + ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; + ofn.nMaxFile = sizeof(filename); + ofn.nMaxFileTitle = MAX_PATH; + ofn.lpstrDefExt = "bmp"; + ofn.lpstrTitle=(ctrlid==IDC_BMPUP)?Translate("Select Up Bitmap"):Translate("Select Down Bitmap"); + if(GetOpenFileName(&ofn)) { + lockbut(); + if (ctrlid==IDC_BMPUP){ + if (Buttons[curselect].UserDefinedbmUp!=NULL){free(Buttons[curselect].UserDefinedbmUp);}; + Buttons[curselect].UserDefinedbmUp=_strdup(ofn.lpstrFile); + }; + if (ctrlid==IDC_BMPDN){ + if (Buttons[curselect].UserDefinedbmDown!=NULL){free(Buttons[curselect].UserDefinedbmDown);}; + Buttons[curselect].UserDefinedbmDown=_strdup(ofn.lpstrFile); + }; + applyuserbitmaps(curselect); + SetImagesForCurrent(hwndDlg,curselect); + + ulockbut(); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + }; + }; + }; + break; + } + + + + + + + + + + + case WM_NOTIFY: + switch(((LPNMHDR)lParam)->idFrom) { + case 0: + switch (((LPNMHDR)lParam)->code) + { + case PSN_APPLY: + { + + DBWriteContactSettingByte(0,TTB_OPTDIR,"BUTTHEIGHT",GetDlgItemInt(hwndDlg,IDC_BUTTHEIGHT,FALSE,FALSE)); + DBWriteContactSettingByte(0,TTB_OPTDIR,"BUTTWIDTH",GetDlgItemInt(hwndDlg,IDC_BUTTWIDTH,FALSE,FALSE)); + DBWriteContactSettingByte(0,TTB_OPTDIR,"UseMirandaButtonClass",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_USEMIRANDABUTTON)); + DBWriteContactSettingByte(0,TTB_OPTDIR,"UseFlatButton",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_USEFLAT)); + + DBWriteContactSettingByte(0,TTB_OPTDIR,"UseIcoLib",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_USEICOLIB)); + + + SaveTree(hwndDlg); + ApplyNewDir(hwndDlg); + RecreateWindows(); + ArrangeButtons(); + + } + } + break; + case IDC_BUTTONORDERTREE: + switch (((LPNMHDR)lParam)->code) { + case TVN_BEGINDRAG: + SetCapture(hwndDlg); + dat->dragging=1; + dat->hDragItem=((LPNMTREEVIEW)lParam)->itemNew.hItem; + TreeView_SelectItem(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),dat->hDragItem); + //ShowWindow(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREEWARNING),SW_SHOW); + 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_ONITEMICON) { + TVITEM tvi; + tvi.mask=TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; + tvi.hItem=hti.hItem; + TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom,&tvi); + tvi.iImage=tvi.iSelectedImage=!tvi.iImage; + ((ButtonOptData *)tvi.lParam)->show=tvi.iImage; + TreeView_SetItem(((LPNMHDR)lParam)->hwndFrom,&tvi); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + + //all changes take effect in runtime + //ShowWindow(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREEWARNING),SW_SHOW); + } + + + }; + } + break; + case TVN_SELCHANGED: + + { + + if(1/*TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom,&hti)*/) + if (1/*hti.flags&TVHT_ONITEMLABEL*/) + { + TVITEM tvi; + HTREEITEM hti; + + hti=TreeView_GetSelection(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE)); + if (hti==NULL){break;}; + tvi.mask=TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; + tvi.hItem=hti; + TreeView_GetItem(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),&tvi); + + + lockbut(); + EnableWindow(GetDlgItem(hwndDlg,IDC_BMPUP),FALSE); + EnableWindow(GetDlgItem(hwndDlg,IDC_BMPDN),FALSE); + + SetImagesForCurrent(hwndDlg,((ButtonOptData *)tvi.lParam)->pos); + //PostMessage(GetDlgItem(hwndDlg,IDC_BMPUP), STM_SETIMAGE,IMAGE_BITMAP,Buttons[((ButtonOptData *)tvi.lParam)->pos].hbBitmapUp); + //PostMessage(GetDlgItem(hwndDlg,IDC_BMPDN), STM_SETIMAGE,IMAGE_BITMAP,Buttons[((ButtonOptData *)tvi.lParam)->pos].hbBitmapDown); + + EnableWindow(GetDlgItem(hwndDlg,IDC_REMOVESEP),FALSE); + if (Buttons[((ButtonOptData *)tvi.lParam)->pos].dwFlags&TTBBF_ISSEPARATOR) + { + + EnableWindow(GetDlgItem(hwndDlg,IDC_REMOVESEP),TRUE); + }else + { + EnableWindow(GetDlgItem(hwndDlg,IDC_BMPUP),TRUE); + EnableWindow(GetDlgItem(hwndDlg,IDC_BMPDN),TRUE); + + }; + EnableWindow(GetDlgItem(hwndDlg,IDC_ENAME),FALSE); + EnableWindow(GetDlgItem(hwndDlg,IDC_EPATH),FALSE); + EnableWindow(GetDlgItem(hwndDlg,IDC_DELLBUTTON),FALSE); + EnableWindow(GetDlgItem(hwndDlg,IDC_LBUTTONSET),FALSE); + {SetDlgItemText(hwndDlg,IDC_ENAME,"");} + {SetDlgItemText(hwndDlg,IDC_EPATH,"");} + + + if (Buttons[((ButtonOptData *)tvi.lParam)->pos].dwFlags&TTBBF_ISLBUTTON) + { + LBUTOPT lbo; + + memset(&lbo,0,sizeof(lbo)); + CallService(TTB_GETLBUTTON,Buttons[((ButtonOptData *)tvi.lParam)->pos].lParamDown,(LPARAM)&lbo); + if (lbo.hframe!=0) + { + EnableWindow(GetDlgItem(hwndDlg,IDC_ENAME),TRUE); + EnableWindow(GetDlgItem(hwndDlg,IDC_EPATH),TRUE); + EnableWindow(GetDlgItem(hwndDlg,IDC_DELLBUTTON),TRUE); + EnableWindow(GetDlgItem(hwndDlg,IDC_LBUTTONSET),TRUE); + + if (lbo.name!=NULL){SetDlgItemText(hwndDlg,IDC_ENAME,lbo.name);}; + if (lbo.lpath!=NULL){SetDlgItemText(hwndDlg,IDC_EPATH,lbo.lpath);}; + }; + + + }; + + ulockbut(); + }; + + + + }; + + + + } + break; + } + break; + case WM_MOUSEMOVE: + if(!dat->dragging) break; + { TVHITTESTINFO hti; + hti.pt.x=(short)LOWORD(lParam); + hti.pt.y=(short)HIWORD(lParam); + ClientToScreen(hwndDlg,&hti.pt); + ScreenToClient(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),&hti.pt); + TreeView_HitTest(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),&hti); + if(hti.flags&(TVHT_ONITEM|TVHT_ONITEMRIGHT)) { + hti.pt.y-=TreeView_GetItemHeight(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE))/2; + TreeView_HitTest(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),&hti); + TreeView_SetInsertMark(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),hti.hItem,1); + } + else { + if(hti.flags&TVHT_ABOVE) SendDlgItemMessage(hwndDlg,IDC_BUTTONORDERTREE,WM_VSCROLL,MAKEWPARAM(SB_LINEUP,0),0); + if(hti.flags&TVHT_BELOW) SendDlgItemMessage(hwndDlg,IDC_BUTTONORDERTREE,WM_VSCROLL,MAKEWPARAM(SB_LINEDOWN,0),0); + TreeView_SetInsertMark(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),NULL,0); + } + + } + break; + case WM_DESTROY: + { + OptionsOpened=FALSE; + return(0); + }; + + case WM_LBUTTONUP: + if(!dat->dragging) break; + TreeView_SetInsertMark(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),NULL,0); + dat->dragging=0; + ReleaseCapture(); + { TVHITTESTINFO hti; + TVITEM tvi; + hti.pt.x=(short)LOWORD(lParam); + hti.pt.y=(short)HIWORD(lParam); + ClientToScreen(hwndDlg,&hti.pt); + ScreenToClient(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),&hti.pt); + hti.pt.y-=TreeView_GetItemHeight(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE))/2; + TreeView_HitTest(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),&hti); + if(dat->hDragItem==hti.hItem) break; + tvi.mask=TVIF_HANDLE|TVIF_PARAM; + tvi.hItem=hti.hItem; + TreeView_GetItem(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),&tvi); + if(hti.flags&(TVHT_ONITEM|TVHT_ONITEMRIGHT)) { + TVINSERTSTRUCT tvis; + char name[128]; + tvis.item.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE; + tvis.item.stateMask=0xFFFFFFFF; + tvis.item.pszText=name; + tvis.item.cchTextMax=sizeof(name); + tvis.item.hItem=dat->hDragItem; + // + tvis.item.iImage=tvis.item.iSelectedImage=((ButtonOptData *)tvi.lParam)->show; + + TreeView_GetItem(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),&tvis.item); + + + TreeView_DeleteItem(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),dat->hDragItem); + tvis.hParent=NULL; + tvis.hInsertAfter=hti.hItem; + TreeView_SelectItem(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),TreeView_InsertItem(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),&tvis)); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + SaveTree(hwndDlg); + } + } + break; + } + return FALSE; +} + + + +int TTBOptInit(WPARAM wParam,LPARAM lParam) +{ + OPTIONSDIALOGPAGE odp; + + ZeroMemory(&odp,sizeof(odp)); + odp.cbSize=sizeof(odp); + odp.position=0; + odp.hInstance=hInst; + odp.pszGroup=Translate("TopToolBar"); + + if (ServiceExists(MS_BACKGROUNDCONFIG_REGISTER)) + { + + }else + { + odp.pszTemplate=MAKEINTRESOURCE(IDD_OPT_TTBBKG); + odp.pszTitle=Translate("TTBBackground"); + odp.pfnDlgProc=DlgProcTTBBkgOpts; + odp.flags=ODPF_BOLDGROUPS; + CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp); + }; + + ZeroMemory(&odp,sizeof(odp)); + odp.cbSize=sizeof(odp); + odp.position=-1000000000; + odp.hInstance=hInst;//GetModuleHandle(NULL); + odp.pszTemplate=MAKEINTRESOURCE(IDD_OPT_BUTORDER); + odp.pszGroup=Translate("TopToolBar"); + odp.pszTitle=Translate("Buttons"); + odp.pfnDlgProc=ButOrderOpts; + odp.flags=ODPF_BOLDGROUPS|ODPF_EXPERTONLY; + CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp); + + return 0; +} + +static BOOL CALLBACK DlgProcTTBBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) + { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + CheckDlgButton(hwndDlg,IDC_BITMAP,DBGetContactSettingByte(NULL,TTB_OPTDIR,"UseBitmap",TTBDEFAULT_USEBITMAP)?BST_CHECKED:BST_UNCHECKED); + SendMessage(hwndDlg,WM_USER+10,0,0); + SendDlgItemMessage(hwndDlg,IDC_BKGCOLOUR,CPM_SETDEFAULTCOLOUR,0,TTBDEFAULT_BKCOLOUR); + SendDlgItemMessage(hwndDlg,IDC_BKGCOLOUR,CPM_SETCOLOUR,0,DBGetContactSettingDword(NULL,TTB_OPTDIR,"BkColour",TTBDEFAULT_BKCOLOUR)); + SendDlgItemMessage(hwndDlg,IDC_SELCOLOUR,CPM_SETDEFAULTCOLOUR,0,TTBDEFAULT_SELBKCOLOUR); + SendDlgItemMessage(hwndDlg,IDC_SELCOLOUR,CPM_SETCOLOUR,0,DBGetContactSettingDword(NULL,TTB_OPTDIR,"SelBkColour",TTBDEFAULT_SELBKCOLOUR)); + { DBVARIANT dbv; + if(!DBGetContactSetting(NULL,TTB_OPTDIR,"BkBitmap",&dbv)) { + SetDlgItemText(hwndDlg,IDC_FILENAME,dbv.pszVal); + DBFreeVariant(&dbv); + + } + } + { WORD bmpUse=DBGetContactSettingWord(NULL,TTB_OPTDIR,"BkBmpUse",TTBDEFAULT_BKBMPUSE); + CheckDlgButton(hwndDlg,IDC_STRETCHH,bmpUse&CLB_STRETCHH?BST_CHECKED:BST_UNCHECKED); + CheckDlgButton(hwndDlg,IDC_STRETCHV,bmpUse&CLB_STRETCHV?BST_CHECKED:BST_UNCHECKED); + CheckDlgButton(hwndDlg,IDC_TILEH,bmpUse&CLBF_TILEH?BST_CHECKED:BST_UNCHECKED); + CheckDlgButton(hwndDlg,IDC_TILEV,bmpUse&CLBF_TILEV?BST_CHECKED:BST_UNCHECKED); + CheckDlgButton(hwndDlg,IDC_SCROLL,bmpUse&CLBF_SCROLL?BST_CHECKED:BST_UNCHECKED); + CheckDlgButton(hwndDlg,IDC_PROPORTIONAL,bmpUse&CLBF_PROPORTIONAL?BST_CHECKED:BST_UNCHECKED); + } + { HRESULT (STDAPICALLTYPE *MySHAutoComplete)(HWND,DWORD); + MySHAutoComplete=(HRESULT (STDAPICALLTYPE*)(HWND,DWORD))GetProcAddress(GetModuleHandle("shlwapi"),"SHAutoComplete"); + if(MySHAutoComplete) MySHAutoComplete(GetDlgItem(hwndDlg,IDC_FILENAME),1); + } + return TRUE; + case WM_USER+10: + EnableWindow(GetDlgItem(hwndDlg,IDC_FILENAME),IsDlgButtonChecked(hwndDlg,IDC_BITMAP)); + EnableWindow(GetDlgItem(hwndDlg,IDC_BROWSE),IsDlgButtonChecked(hwndDlg,IDC_BITMAP)); + EnableWindow(GetDlgItem(hwndDlg,IDC_STRETCHH),IsDlgButtonChecked(hwndDlg,IDC_BITMAP)); + EnableWindow(GetDlgItem(hwndDlg,IDC_STRETCHV),IsDlgButtonChecked(hwndDlg,IDC_BITMAP)); + EnableWindow(GetDlgItem(hwndDlg,IDC_TILEH),IsDlgButtonChecked(hwndDlg,IDC_BITMAP)); + EnableWindow(GetDlgItem(hwndDlg,IDC_TILEV),IsDlgButtonChecked(hwndDlg,IDC_BITMAP)); + EnableWindow(GetDlgItem(hwndDlg,IDC_SCROLL),IsDlgButtonChecked(hwndDlg,IDC_BITMAP)); + EnableWindow(GetDlgItem(hwndDlg,IDC_PROPORTIONAL),IsDlgButtonChecked(hwndDlg,IDC_BITMAP)); + break; + case WM_COMMAND: + if(LOWORD(wParam)==IDC_BROWSE) { + char str[MAX_PATH]; + OPENFILENAME ofn={0}; + char filter[512]; + + GetDlgItemText(hwndDlg,IDC_FILENAME,str,sizeof(str)); + ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; + ofn.hwndOwner = hwndDlg; + ofn.hInstance = NULL; + CallService(MS_UTILS_GETBITMAPFILTERSTRINGS,sizeof(filter),(LPARAM)filter); + ofn.lpstrFilter = filter; + ofn.lpstrFile = str; + ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; + ofn.nMaxFile = sizeof(str); + ofn.nMaxFileTitle = MAX_PATH; + ofn.lpstrDefExt = "bmp"; + if(!GetOpenFileName(&ofn)) break; + SetDlgItemText(hwndDlg,IDC_FILENAME,str); + } + else if(LOWORD(wParam)==IDC_FILENAME && HIWORD(wParam)!=EN_CHANGE) break; + if(LOWORD(wParam)==IDC_BITMAP) SendMessage(hwndDlg,WM_USER+10,0,0); + if(LOWORD(wParam)==IDC_FILENAME && (HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus())) return 0; + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + case WM_NOTIFY: + switch(((LPNMHDR)lParam)->idFrom) { + case 0: + switch (((LPNMHDR)lParam)->code) + { + case PSN_APPLY: + DBWriteContactSettingByte(NULL,TTB_OPTDIR,"UseBitmap",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_BITMAP)); + { COLORREF col; + col=SendDlgItemMessage(hwndDlg,IDC_BKGCOLOUR,CPM_GETCOLOUR,0,0); + if(col==TTBDEFAULT_BKCOLOUR) DBDeleteContactSetting(NULL,TTB_OPTDIR,"BkColour"); + else DBWriteContactSettingDword(NULL,TTB_OPTDIR,"BkColour",col); + col=SendDlgItemMessage(hwndDlg,IDC_SELCOLOUR,CPM_GETCOLOUR,0,0); + if(col==TTBDEFAULT_SELBKCOLOUR) DBDeleteContactSetting(NULL,TTB_OPTDIR,"SelBkColour"); + else DBWriteContactSettingDword(NULL,TTB_OPTDIR,"SelBkColour",col); + } + { char str[MAX_PATH]; + GetDlgItemText(hwndDlg,IDC_FILENAME,str,sizeof(str)); + DBWriteContactSettingString(NULL,TTB_OPTDIR,"BkBitmap",str); + } + { WORD flags=0; + if(IsDlgButtonChecked(hwndDlg,IDC_STRETCHH)) flags|=CLB_STRETCHH; + if(IsDlgButtonChecked(hwndDlg,IDC_STRETCHV)) flags|=CLB_STRETCHV; + if(IsDlgButtonChecked(hwndDlg,IDC_TILEH)) flags|=CLBF_TILEH; + if(IsDlgButtonChecked(hwndDlg,IDC_TILEV)) flags|=CLBF_TILEV; + if(IsDlgButtonChecked(hwndDlg,IDC_SCROLL)) flags|=CLBF_SCROLL; + if(IsDlgButtonChecked(hwndDlg,IDC_PROPORTIONAL)) flags|=CLBF_PROPORTIONAL; + DBWriteContactSettingWord(NULL,TTB_OPTDIR,"BkBmpUse",flags); + } + + ttbOptionsChanged(); + return TRUE; + } + break; + } + break; + } + return FALSE; +} -- cgit v1.2.3