summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/TopToolBar/CLCButton.cpp624
-rw-r--r--plugins/TopToolBar/TopToolBar.vcxproj2
-rw-r--r--plugins/TopToolBar/TopToolBar.vcxproj.filters6
-rw-r--r--plugins/TopToolBar/button.cpp534
-rw-r--r--plugins/TopToolBar/buttonopt.cpp323
-rw-r--r--plugins/TopToolBar/common.h8
-rw-r--r--plugins/TopToolBar/find.icobin1406 -> 0 bytes
-rw-r--r--plugins/TopToolBar/launchbt.cpp7
-rw-r--r--plugins/TopToolBar/main.cpp2
-rw-r--r--plugins/TopToolBar/main.rc20
-rw-r--r--plugins/TopToolBar/resource.h25
-rw-r--r--plugins/TopToolBar/toolbar.cpp62
-rw-r--r--plugins/TopToolBar/ttbopt.cpp174
13 files changed, 111 insertions, 1676 deletions
diff --git a/plugins/TopToolBar/CLCButton.cpp b/plugins/TopToolBar/CLCButton.cpp
deleted file mode 100644
index d884ea603c..0000000000
--- a/plugins/TopToolBar/CLCButton.cpp
+++ /dev/null
@@ -1,624 +0,0 @@
-/*
-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);
-
-struct MButtonCtrl
-{
- 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;
-};
-
-// 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;
-
-// 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 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 == NULL)
- return;
-
- HFONT hOldFont = NULL;
- RECT rcClient;
- GetClientRect(ctl->hwnd, &rcClient);
- HDC hdcMem = CreateCompatibleDC(hdcPaint);
- HBITMAP hbmMem = CreateCompatibleBitmap(hdcPaint, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top);
- HDC hOld = (HDC)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 {
- HWND hwndParent = GetParent(ctl->hwnd);
- HDC 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 = (HFONT)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;
- GetObject(ctl->hBitmap, sizeof(bminfo), &bminfo);
- int ix = (rcClient.right - rcClient.left) / 2 - (bminfo.bmWidth / 2);
- int 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 *) GetWindowLongPtr(hwndDlg, 0);
- switch (msg) {
- case WM_NCCREATE:
- SetWindowLongPtr(hwndDlg, GWL_STYLE, GetWindowLongPtr(hwndDlg, GWL_STYLE) | BS_OWNERDRAW);
- bct = ( MButtonCtrl* )malloc(sizeof(MButtonCtrl));
- if (bct == NULL)
- return FALSE;
-
- bct->hwnd = hwndDlg;
- bct->stateId = PBS_NORMAL;
- bct->focus = 0;
- bct->hFont = (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);
- SetWindowLongPtr(hwndDlg, 0, (LONG) bct);
- if (((CREATESTRUCTA *) lParam)->lpszName)
- SetWindowTextA(hwndDlg, ((CREATESTRUCTA *) lParam)->lpszName);
- return TRUE;
-
- 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) {
- if (bct->hIconPrivate)
- DestroyIcon(bct->hIconPrivate);
-
- ICONINFO ii;
- GetIconInfo((HICON) lParam, &ii);
-
- BITMAP bm;
- 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:
- if (wParam) {
- EnterCriticalSection(&csTips);
- if (!hwndToolTips)
- hwndToolTips = CreateWindowExA(WS_EX_TOPMOST, TOOLTIPS_CLASSA, "", WS_POPUP, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(NULL), NULL);
-
- TOOLINFO ti = { 0 };
- 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 = (TCHAR*) 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;
-
- case WM_DESTROY:
- if (bct) {
- EnterCriticalSection(&csTips);
- if (hwndToolTips) {
- TOOLINFO ti = { 0 };
- 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);
- }
- SetWindowLongPtr(hwndDlg, 0, (LONG) NULL);
- break; // DONT! fall thru
- }
-
- return DefWindowProc(hwndDlg, msg, wParam, lParam);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-int LoadCLCButtonModule(void)
-{
- g_cxsmIcon = GetSystemMetrics(SM_CXSMICON);
- g_cysmIcon = GetSystemMetrics(SM_CYSMICON);
-
- WNDCLASSEX wc = { 0 };
- wc.cbSize = sizeof(wc);
- wc.lpszClassName = _T("CLCButtonClass");
- wc.lpfnWndProc = TSButtonWndProc;
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.cbWndExtra = sizeof(MButtonCtrl *);
- wc.hbrBackground = 0;
- wc.style = CS_GLOBALCLASS;
- RegisterClassEx(&wc);
-
- InitializeCriticalSection(&csTips);
- return 0;
-}
-
-int UnloadTSButtonModule(WPARAM wParam, LPARAM lParam)
-{
- DeleteCriticalSection(&csTips);
- return 0;
-}
diff --git a/plugins/TopToolBar/TopToolBar.vcxproj b/plugins/TopToolBar/TopToolBar.vcxproj
index 0822bd90e2..e6813542f5 100644
--- a/plugins/TopToolBar/TopToolBar.vcxproj
+++ b/plugins/TopToolBar/TopToolBar.vcxproj
@@ -239,7 +239,6 @@
</ItemGroup>
<ItemGroup>
<None Include="bmp\sep.bmp" />
- <None Include="find.ico" />
<None Include="icos\Find_Add Contacts_DN.ico" />
<None Include="icos\Find_Add Contacts_UP.ico" />
<None Include="icos\Groups On_Off_DN.ico" />
@@ -267,7 +266,6 @@
</ResourceCompile>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="button.cpp" />
<ClCompile Include="InternalButtons.cpp" />
<ClCompile Include="launchbt.cpp" />
<ClCompile Include="main.cpp">
diff --git a/plugins/TopToolBar/TopToolBar.vcxproj.filters b/plugins/TopToolBar/TopToolBar.vcxproj.filters
index 43d0d470cc..ab04955ff5 100644
--- a/plugins/TopToolBar/TopToolBar.vcxproj.filters
+++ b/plugins/TopToolBar/TopToolBar.vcxproj.filters
@@ -26,9 +26,6 @@
</ClInclude>
</ItemGroup>
<ItemGroup>
- <None Include="find.ico">
- <Filter>Resource Files</Filter>
- </None>
<None Include="icos\Find_Add Contacts_DN.ico">
<Filter>Resource Files</Filter>
</None>
@@ -105,9 +102,6 @@
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="button.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="toolbar.cpp">
<Filter>Source Files</Filter>
</ClCompile>
diff --git a/plugins/TopToolBar/button.cpp b/plugins/TopToolBar/button.cpp
deleted file mode 100644
index e6d40bdd02..0000000000
--- a/plugins/TopToolBar/button.cpp
+++ /dev/null
@@ -1,534 +0,0 @@
-/*
-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())
-
-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;
- TCHAR 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;
-
-// 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");
- }
-}
-
-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) {
- RECT rcClient;
- GetClientRect(ctl->hwnd, &rcClient);
-
- HDC hdcMem = (HDC)CreateCompatibleDC(hdcPaint);
- HBITMAP hbmMem = (HBITMAP)CreateCompatibleBitmap(hdcPaint, rcClient.right-rcClient.left, rcClient.bottom-rcClient.top);
- HDC hOld = (HDC)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 = ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON), IsWinVerXPPlus()? ILC_COLOR32 | ILC_MASK : ILC_COLOR16 | ILC_MASK, 1, 0);
- ImageList_AddIcon(hImageList, ctl->hIcon);
- 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;
- GetObject(ctl->hBitmap, sizeof(bminfo), &bminfo);
- int ix = (rcClient.right-rcClient.left)/2 - (bminfo.bmWidth/2);
- int 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
- TCHAR szText[MAX_PATH];
- SIZE sz;
- RECT rcText;
- CopyRect(&rcText, &rcClient);
-
- GetWindowText(ctl->hwnd, szText, SIZEOF(szText));
- SetBkMode(hdcMem, TRANSPARENT);
- HFONT hOldFont = (HFONT)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, _T("&"), 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 *)GetWindowLongPtr(hwndDlg, 0);
- switch(msg) {
- case WM_NCCREATE:
- SetWindowLongPtr(hwndDlg, GWL_STYLE, GetWindowLongPtr(hwndDlg, GWL_STYLE)|BS_OWNERDRAW);
- bct = (MButtonCtrl*)malloc(sizeof(MButtonCtrl));
- if (bct == NULL)
- return FALSE;
-
- bct->hwnd = hwndDlg;
- bct->stateId = PBS_NORMAL;
- bct->focus = 0;
- bct->hFont = (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);
- SetWindowLongPtr(hwndDlg, 0, (LONG)bct);
- if (((CREATESTRUCT *)lParam)->lpszName) SetWindowText(hwndDlg, ((CREATESTRUCT *)lParam)->lpszName);
- return TRUE;
-
- 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:
- if (wParam) {
- EnterCriticalSection(&csTips);
- if (!hwndToolTips)
- hwndToolTips = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, _T(""), WS_POPUP, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(NULL), NULL);
-
- TOOLINFO ti = { 0 };
- 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 = ( LPTSTR )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;
-
- case WM_DESTROY:
- if (bct) {
- EnterCriticalSection(&csTips);
- if (hwndToolTips) {
- TOOLINFO ti = { 0 };
- 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);
- }
- SetWindowLongPtr(hwndDlg,0,(LONG)NULL);
- break;
- }
- return DefWindowProc(hwndDlg, msg, wParam, lParam);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-int LoadButtonModule(void)
-{
- WNDCLASSEX wc = { 0 };
- 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);
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-int UnloadButtonModule()
-{
- DeleteCriticalSection(&csTips);
- return 0;
-}
diff --git a/plugins/TopToolBar/buttonopt.cpp b/plugins/TopToolBar/buttonopt.cpp
deleted file mode 100644
index ace5bc14b4..0000000000
--- a/plugins/TopToolBar/buttonopt.cpp
+++ /dev/null
@@ -1,323 +0,0 @@
-#include "common.h"
-
-#define OFFSET_PROTOPOS 200
-#define OFFSET_VISIBLE 400
-
-extern HINSTANCE hInst;
-
-struct OrderData {
- int dragging;
- HTREEITEM hDragItem;
-};
-
-char *MyDbGetString(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;
-}
-
-int CheckButtonOrder()
-{
- bool protochanged = FALSE;
- char buf[10];
- char buf2[10];
-
- int StoredButCount = DBGetContactSettingByte(0, TTB_OPTDIR, "ButCount", -1);
- if (StoredButCount == -1)
- protochanged = TRUE;
- if (protochanged) {
- //reseting all settings;
- PROTOCOLDESCRIPTOR **protos;
- int count;
- CallService(MS_PROTO_ENUMPROTOCOLS, (WPARAM)&count, (LPARAM)&protos);
-
- int v = 0;
- for (int i = 0;i<count;i++) {
- if (protos[i]->type != 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;
- }
-
- return 0;
-}
-
-static BOOL CALLBACK ProtocolOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- ProtocolOrderData *dat = (ProtocolOrderData*)GetWindowLongPtr(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));
- SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_PROTOCOLORDER), GWL_USERDATA, (LONG)dat);
- dat->dragging = 0;
-
- SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_PROTOCOLVISIBILITY), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_PROTOCOLVISIBILITY), GWL_STYLE)|TVS_NOHSCROLL);
- SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_PROTOCOLORDER), GWL_STYLE, GetWindowLongPtr(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;i<count;i++) {
- //if (protos[i]->type != PROTOTYPE_PROTOCOL || CallProtoService(protos[i]->szName, PS_GETCAPS, PFLAGNUM_2, 0) == 0) continue;
- itoa(i, &buf, 10);
- szSTName = MyDbGetString(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
index 7a51636e2a..93c219e200 100644
--- a/plugins/TopToolBar/common.h
+++ b/plugins/TopToolBar/common.h
@@ -58,7 +58,6 @@ struct TopButtonInt
BOOL bPushed;
int dwFlags;
int x, y;
- HBITMAP hbWBordBitmapUp, hbWBordBitmapDown;
HICON hIconUp, hIconDn;
HANDLE hIconHandleUp, hIconHandleDn;
@@ -122,14 +121,11 @@ char *AS(char *str, const char *setting, char *addstr)
#define TTB_ADDLBUTTON "TTB/AddLButton"
#define TTB_REMOVELBUTTON "TTB/RemoveLButton"
-#define MYMIRANDABUTTONCLASS _T("MyMIRANDABUTTONCLASS")
+#define MYMIRANDABUTTONCLASS _T("MButtonClass") //_T("MyMIRANDABUTTONCLASS")
int LoadInternalButtons( HWND );
int UnLoadInternalButtons( void );
-int LoadButtonModule( void );
-int UnloadButtonModule( void );
-
int LoadToolbarModule( void );
int UnloadToolbarModule( void );
@@ -167,7 +163,5 @@ struct LBUTOPT
#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
deleted file mode 100644
index 415a0bccd7..0000000000
--- a/plugins/TopToolBar/find.ico
+++ /dev/null
Binary files differ
diff --git a/plugins/TopToolBar/launchbt.cpp b/plugins/TopToolBar/launchbt.cpp
index fd0e15d600..3e24b0c2b1 100644
--- a/plugins/TopToolBar/launchbt.cpp
+++ b/plugins/TopToolBar/launchbt.cpp
@@ -77,13 +77,10 @@ INT_PTR ModifyLButton(WPARAM wParam, LPARAM lParam)
INT_PTR InsertLBut(int id)
{
- HBITMAP DefLUp = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_LAUNCHDN));
- HBITMAP DefLDn = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_LAUNCHUP));
-
TTBButton ttb = { 0 };
ttb.cbSize = sizeof(ttb);
- //ttb.hbBitmapDown = DefLDn; !!!!!!!!!!!!!!
- //ttb.hbBitmapUp = DefLUp; !!!!!!!!!!!!!!
+ ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
+ ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
ttb.dwFlags = TTBBF_VISIBLE|TTBBF_ISLBUTTON;
ttb.pszServiceDown = TTB_LAUNCHSERVICE;
ttb.lParamDown = id;
diff --git a/plugins/TopToolBar/main.cpp b/plugins/TopToolBar/main.cpp
index 54b7542c24..a00460132c 100644
--- a/plugins/TopToolBar/main.cpp
+++ b/plugins/TopToolBar/main.cpp
@@ -59,7 +59,6 @@ extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
mir_getLI( &li );
mir_getLP(&pluginInfo);
- LoadButtonModule();
LoadToolbarModule();
hHookTTBModuleLoaded = CreateHookableEvent(ME_TTB_MODULELOADED);
@@ -73,7 +72,6 @@ extern "C" int __declspec(dllexport) Unload(void)
UnInitLBut();
UnLoadInternalButtons();
UnloadToolbarModule();
- UnloadButtonModule();
for (int i=0; i < arHooks.getCount(); i++ )
UnhookEvent( arHooks[i] );
diff --git a/plugins/TopToolBar/main.rc b/plugins/TopToolBar/main.rc
index 332f6cac40..5c805d63ea 100644
--- a/plugins/TopToolBar/main.rc
+++ b/plugins/TopToolBar/main.rc
@@ -29,26 +29,24 @@ STYLE DS_SETFONT | WS_CHILD
FONT 8, "MS Sans Serif", 0, 0, 0x1
BEGIN
GROUPBOX "Buttons Order && Visibility",IDC_STATIC,10,0,150,180
- CONTROL "Tree1",IDC_BUTTONORDERTREE,"SysTreeView32",TVS_NOTOOLTIPS | WS_BORDER | WS_HSCROLL | WS_TABSTOP,18,25,134,148
+ CONTROL "Tree1",IDC_BUTTONORDERTREE,"SysTreeView32",TVS_NOTOOLTIPS | TVS_CHECKBOXES | WS_BORDER | WS_HSCROLL | WS_TABSTOP,18,25,134,148
LTEXT "Buttons order:",IDC_STATIC,18,15,132,8
PUSHBUTTON "Add Separator",IDC_ADDSEP,175,15,55,14
PUSHBUTTON "Del Separator",IDC_REMOVESEP,235,15,55,14
PUSHBUTTON "Add Launch",IDC_ADDLBUTTON,180,60,100,14
PUSHBUTTON "Del Launch",IDC_DELLBUTTON,180,81,100,14
- EDITTEXT IDC_ENAME,195,111,85,14,ES_AUTOHSCROLL
+ EDITTEXT IDC_ENAME,195,111,85,14,ES_AUTOHSCROLL | WS_TABSTOP
LTEXT "Name: ",IDC_LBUTTONNAME,170,114,24,8
- EDITTEXT IDC_EPATH,195,134,85,14,ES_AUTOHSCROLL
+ EDITTEXT IDC_EPATH,195,134,85,14,ES_AUTOHSCROLL | WS_TABSTOP
LTEXT "Path:",IDC_LBUTTONPATH,170,136,18,8
PUSHBUTTON "Set",IDC_LBUTTONSET,205,158,50,14
GROUPBOX "Separator Button",IDC_STATIC,165,0,130,40
GROUPBOX "Launch Button",IDC_STATIC,165,45,130,136
LTEXT "Button Height:",IDC_STATIC,11,190,46,8
- EDITTEXT IDC_BUTTHEIGHT,65,187,24,14,ES_AUTOHSCROLL
+ EDITTEXT IDC_BUTTHEIGHT,65,187,24,14,ES_AUTOHSCROLL | WS_TABSTOP
LTEXT "Button Width: ",IDC_STATIC,11,211,46,8
- EDITTEXT IDC_BUTTWIDTH,65,209,24,14,ES_AUTOHSCROLL
- CONTROL "Use Miranda Button Class",IDC_USEMIRANDABUTTON,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,196,97,10
+ EDITTEXT IDC_BUTTWIDTH,65,209,24,14,ES_AUTOHSCROLL | WS_TABSTOP
CONTROL "Use Flat Mode",IDC_USEFLAT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,186,208,62,10
- CONTROL "Use IcoLib (need restart!)",IDC_USEICOLIB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,184,95,10
END
@@ -131,18 +129,18 @@ IDB_SEP BITMAP "bmp\\sep.bmp"
// TEXTINCLUDE
//
-1 TEXTINCLUDE
+1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
-2 TEXTINCLUDE
+2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
-3 TEXTINCLUDE
+3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
@@ -158,6 +156,7 @@ END
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
+IDI_RUN ICON "icos\\run.ico"
IDI_SHOWONLINEUP ICON "icos\\Show only Online Users_UP.ico"
IDI_SHOWONLINEDN ICON "icos\\Show only Online Users_DN.ico"
IDI_GROUPSUP ICON "icos\\Groups On_Off_UP.ico"
@@ -309,4 +308,3 @@ END
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
-
diff --git a/plugins/TopToolBar/resource.h b/plugins/TopToolBar/resource.h
index 13e4d07678..e87c3f88fb 100644
--- a/plugins/TopToolBar/resource.h
+++ b/plugins/TopToolBar/resource.h
@@ -2,23 +2,7 @@
// Microsoft Developer Studio generated include file.
// Used by main.rc
//
-#define IDB_SOUNDSUP 103
-#define IDB_SOUNDSDN 104
-#define IDB_BORDERDN 105
-#define IDB_BORDERUP 106
-#define IDB_TESTBITMAP 108
-#define IDB_OPTIONS 109
-#define IDB_CPANELDN 112
-#define IDB_CPANELUP 113
-#define IDB_MENUUP 114
-#define IDB_MENUDN 115
-#define IDB_LAUNCHDN 117
#define IDB_SEP 118
-#define IDB_LAUNCHUP 119
-#define IDB_MINIMIZEUP 121
-#define IDB_MINIMIZEDN 122
-#define IDB_FINDUSERDN 123
-#define IDB_FINDUSERUP 124
#define IDI_SHOWONLINEUP 125
#define IDI_SHOWONLINEDN 126
#define IDI_GROUPSUP 127
@@ -33,17 +17,14 @@
#define IDI_FINDADDDN 136
#define IDI_MIRANDAUP 137
#define IDI_ICON1 138
-#define IDI_MIRANDADN 138
+#define IDI_MIRANDADN 139
+#define IDI_RUN 140
#define IDI_NOTICK 205
#define IDI_TICK 206
#define IDD_OPT_TTBBKG 230
-#define IDB_ONLINEUP 262
#define IDD_OPT_INTERNALORDER 262
#define IDD_OPT_BUTORDER 262
-#define IDB_ONLINEDN 264
#define IDD_FRAMEPLUG2 265
-#define IDB_GROUPUP 268
-#define IDB_GROUPDN 269
#define IDC_BUTTON1 1002
#define IDC_ADDSEP 1003
#define IDC_REMOVESEP 1004
@@ -57,9 +38,7 @@
#define IDC_BUTTHEIGHT 1015
#define IDC_EDIT2 1016
#define IDC_BUTTWIDTH 1016
-#define IDC_USEMIRANDABUTTON 1017
#define IDC_USEFLAT 1018
-#define IDC_USEICOLIB 1019
#define IDC_BROWSE 1184
#define IDC_BKGCOLOUR 1269
#define IDC_FILENAME 1271
diff --git a/plugins/TopToolBar/toolbar.cpp b/plugins/TopToolBar/toolbar.cpp
index 7c0dae64d5..6e48408bd6 100644
--- a/plugins/TopToolBar/toolbar.cpp
+++ b/plugins/TopToolBar/toolbar.cpp
@@ -8,7 +8,6 @@ bool StopArrange;
int BUTTWIDTH = 20;
int BUTTHEIGHT = 16;
-bool UseIcoLib = false;
int nextButtonId = 200;
int nButtonsCount = 0;
@@ -152,31 +151,6 @@ INT_PTR TTBRemoveButton(WPARAM wParam, LPARAM lParam)
return 0;
}
-static HBITMAP DrawBorderForBitmap(HICON hIcon, BOOL up)
-{
- ICONINFO ii;
- GetIconInfo(hIcon, &ii);
-
- HBITMAP Border = LoadBitmap(hInst, MAKEINTRESOURCE(up?IDB_BORDERUP:IDB_BORDERDN));
- HDC workdc = GetDC(hwndContactList);
- HDC destdc = CreateCompatibleDC(workdc);
- HDC srcdc = CreateCompatibleDC(workdc);
-
- HBITMAP 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, ii.hbmColor);
- 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 = { 0 };
@@ -226,7 +200,7 @@ HICON LoadIconFromLibrary(char *Name, char *Description, HICON hIcon, HANDLE* ph
int CreateOneWindow(int ButtonPos)
{
- if (DBGetContactSettingByte(0, TTB_OPTDIR, "UseMirandaButtonClass", UseMirandaButtonClassDefaultValue) && !(Buttons[ButtonPos].dwFlags & TTBBF_ISSEPARATOR))
+ if (!(Buttons[ButtonPos].dwFlags & TTBBF_ISSEPARATOR))
Buttons[ButtonPos].hwnd = CreateWindow(MYMIRANDABUTTONCLASS, _T(""), BS_PUSHBUTTON|WS_CHILD|WS_TABSTOP|SS_NOTIFY, 0, 0, BUTTWIDTH, BUTTHEIGHT, hwndTopToolBar, NULL, hInst, 0);
else
Buttons[ButtonPos].hwnd = CreateWindow( _T("STATIC"), _T(""), WS_CHILD|SS_NOTIFY, 0, 0, BUTTWIDTH, BUTTHEIGHT, hwndTopToolBar, NULL, hInst, 0);
@@ -279,11 +253,6 @@ INT_PTR TTBAddButton(WPARAM wParam, LPARAM lParam)
b.hIconUp = but->hIconUp;
}
- if (b.dwFlags & TTBBF_DRAWBORDER) {
- b.hbWBordBitmapDown = DrawBorderForBitmap(b.hIconDn, FALSE);
- b.hbWBordBitmapUp = DrawBorderForBitmap(b.hIconUp, TRUE);
- }
-
b.wParamUp = but->wParamUp;
b.lParamUp = but->lParamUp;
b.wParamDown = but->wParamDown;
@@ -296,9 +265,9 @@ INT_PTR TTBAddButton(WPARAM wParam, LPARAM lParam)
if ( !(b.dwFlags & TTBBF_ISSEPARATOR)) {
char buf[256];
sprintf(buf, "%s_up", b.name);
- b.hIconUp = LoadIconFromLibrary(buf, buf, b.hIconDn, &b.hIconHandleDn, NULL);
+ b.hIconUp = LoadIconFromLibrary(buf, buf, b.hIconUp, &b.hIconHandleUp, NULL);
sprintf(buf, "%s_dn", b.name);
- b.hIconDn = LoadIconFromLibrary(buf, buf, b.hIconUp, &b.hIconHandleUp, NULL);
+ b.hIconDn = LoadIconFromLibrary(buf, buf, b.hIconDn, &b.hIconHandleDn, NULL);
}
b.hwndTip = CreateWindowEx(0, TOOLTIPS_CLASS, NULL,
@@ -502,11 +471,8 @@ int SetButtBitmap(int pos)
SetWindowLongPtr(Buttons[pos].hwnd, GWL_STYLE, curstyle | SS_ICON);
if (Buttons[pos].dwFlags & TTBBF_ISSEPARATOR) {
- if (!(Buttons[pos].dwFlags & TTBBF_DRAWBORDER)) {
- SendMessage(Buttons[pos].hwnd, STM_SETIMAGE, IMAGE_ICON, (LPARAM)((Buttons[pos].bPushed)?(Buttons[pos].hIconDn):(Buttons[pos].hIconUp)));
- SendMessage(Buttons[pos].hwnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)((Buttons[pos].bPushed)?(Buttons[pos].hIconDn):(Buttons[pos].hIconUp)));
- }
- else SendMessage(Buttons[pos].hwnd, STM_SETIMAGE, IMAGE_ICON, (LPARAM)((Buttons[pos].bPushed)?(Buttons[pos].hbWBordBitmapDown):(Buttons[pos].hbWBordBitmapUp)));
+ SendMessage(Buttons[pos].hwnd, STM_SETIMAGE, IMAGE_ICON, (LPARAM)((Buttons[pos].bPushed)?(Buttons[pos].hIconDn):(Buttons[pos].hIconUp)));
+//!! SendMessage(Buttons[pos].hwnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)((Buttons[pos].bPushed)?(Buttons[pos].hIconDn):(Buttons[pos].hIconUp)));
}
else SendMessage(Buttons[pos].hwnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)((Buttons[pos].bPushed)?(Buttons[pos].hIconDn):(Buttons[pos].hIconUp)));
@@ -584,6 +550,8 @@ INT_PTR TTBGetOptions(WPARAM wParam, LPARAM lParam)
if (Buttons[pos].bPushed)
lpTTB->dwFlags |= TTBBF_PUSHED;
+ lpTTB->hIconDn=Buttons[pos].hIconDn;
+ lpTTB->hIconUp=Buttons[pos].hIconUp;
lpTTB->lParamUp = Buttons[pos].lParamUp;
lpTTB->wParamUp = Buttons[pos].wParamUp;
lpTTB->lParamDown = Buttons[pos].lParamDown;
@@ -620,11 +588,7 @@ INT_PTR TTBSetOptions(WPARAM wParam, LPARAM 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].hIconDn, FALSE);
- Buttons[pos].hbWBordBitmapUp = DrawBorderForBitmap(Buttons[pos].hIconUp, TRUE);
- }
+ Buttons[pos].bPushed = (Buttons[pos].dwFlags & TTBBF_PUSHED) ? TRUE : FALSE;
SetButtBitmap(pos);
SendMessage(Buttons[pos].hwndTip, TTM_ACTIVATE, (WPARAM)(Buttons[pos].dwFlags & TTBBF_SHOWTOOLTIP) ? TRUE : FALSE, 0);
@@ -660,6 +624,8 @@ INT_PTR TTBSetOptions(WPARAM wParam, LPARAM lParam)
break;
Buttons[pos].dwFlags = lpTTB->dwFlags;
+ Buttons[pos].hIconUp = lpTTB->hIconUp;
+ Buttons[pos].hIconDn = lpTTB->hIconDn;
Buttons[pos].lParamUp = lpTTB->lParamUp;
Buttons[pos].wParamUp = lpTTB->wParamUp;
Buttons[pos].lParamDown = lpTTB->lParamDown;
@@ -673,11 +639,6 @@ INT_PTR TTBSetOptions(WPARAM wParam, LPARAM lParam)
Buttons[pos].pszServiceDown = _strdup(lpTTB->pszServiceDown);
Buttons[pos].pszServiceUp = _strdup(lpTTB->pszServiceUp);
- if (Buttons[pos].dwFlags & TTBBF_DRAWBORDER) {
- Buttons[pos].hbWBordBitmapDown = DrawBorderForBitmap(Buttons[pos].hIconDn, FALSE);
- Buttons[pos].hbWBordBitmapUp = DrawBorderForBitmap(Buttons[pos].hIconUp, 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();
@@ -758,7 +719,7 @@ static void PaintToolbar(HWND hwnd)
if (backgroundBmpUse&CLBF_PROPORTIONAL) {
destw = clRect.right;
desth = destw*bmp.bmHeight/bmp.bmWidth;
- if (backgroundBmpUse&CLBF_TILEVTOROWHEIGHT)
+ if (backgroundBmpUse & CLBF_TILEVTOROWHEIGHT)
desth = BUTTHEIGHT+2;
}
else {
@@ -856,6 +817,7 @@ LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
if (Buttons[pos].pszServiceDown != NULL)
CallService(Buttons[pos].pszServiceDown, Buttons[pos].wParamDown, Buttons[pos].lParamDown);
}
+
ulockbut();
}
}
diff --git a/plugins/TopToolBar/ttbopt.cpp b/plugins/TopToolBar/ttbopt.cpp
index dadfe7e305..a9b8402060 100644
--- a/plugins/TopToolBar/ttbopt.cpp
+++ b/plugins/TopToolBar/ttbopt.cpp
@@ -15,42 +15,52 @@ HWND OptionshWnd = 0;
struct ButtonOptData
{
- char *name;
int pos;
- bool show;
};
struct OrderData
{
int dragging;
HTREEITEM hDragItem;
+ HIMAGELIST himlButtonIcons;
};
int BuildTree(HWND hwndDlg)
{
+ HWND hTree = GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE);
OrderData *dat = (struct OrderData*)GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE), GWLP_USERDATA);
- TVINSERTSTRUCT tvis;
- tvis.hParent = NULL;
- tvis.hInsertAfter = TVI_LAST;
- tvis.item.mask = TVIF_PARAM|TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
- TreeView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE));
+ dat->himlButtonIcons = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 2, 2);
+ TreeView_SetImageList(hTree, dat->himlButtonIcons, TVSIL_NORMAL);
+ SetWindowLongPtr(hTree, GWL_STYLE, GetWindowLongPtr(hTree,GWL_STYLE)|TVS_NOHSCROLL);
+ TreeView_DeleteAllItems(hTree);
if (nButtonsCount == 0)
return FALSE;
+ TVINSERTSTRUCT tvis = { 0 };
+ tvis.hInsertAfter = TVI_LAST;
+ tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
+
for (int i = 0; i < nButtonsCount; i++) {
ButtonOptData *PD = (ButtonOptData*)malloc(sizeof(ButtonOptData));
- PD->name = Buttons[arrangedbuts[i].oldpos].name;
- PD->show = Buttons[arrangedbuts[i].oldpos].dwFlags & TTBBF_VISIBLE?TRUE:FALSE;
- PD->pos = arrangedbuts[i].oldpos;
+ TopButtonInt &b = Buttons[PD->pos = arrangedbuts[i].oldpos];
+
+ int index;
+ if (b.dwFlags & TTBBF_ICONBYHANDLE) {
+ HICON hIcon = Skin_GetIconByHandle(b.hIconHandleUp);
+ index = ImageList_AddIcon(dat->himlButtonIcons, hIcon);
+ Skin_ReleaseIcon(hIcon);
+ }
+ else index = ImageList_AddIcon(dat->himlButtonIcons, b.hIconUp);
+
tvis.item.lParam = (LPARAM)PD;
- tvis.item.pszText = TranslateTS( mir_a2t( PD->name));
- tvis.item.iImage = tvis.item.iSelectedImage = PD->show;
- TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE), &tvis);
+ tvis.item.pszText = TranslateTS( mir_a2t( b.name ));
+ tvis.item.iImage = tvis.item.iSelectedImage = index;
+ HTREEITEM hti = TreeView_InsertItem(hTree, &tvis);
mir_free( tvis.item.pszText );
- tvis.item.iImage = tvis.item.iSelectedImage = PD->show;
+ TreeView_SetCheckState(hTree, hti, (b.dwFlags & TTBBF_VISIBLE) ? TRUE : FALSE);
}
return (TRUE);
@@ -59,7 +69,7 @@ int BuildTree(HWND hwndDlg)
//call this when options opened and buttons added/removed
int OptionsPageRebuild()
{
- if (OptionsOpened)
+ if (OptionsOpened)
BuildTree(OptionshWnd);
return 0;
@@ -67,27 +77,29 @@ int OptionsPageRebuild()
int SaveTree(HWND hwndDlg)
{
- TCHAR idstr[100];
- TVITEM tvi;
- tvi.hItem = TreeView_GetRoot(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE));
- tvi.cchTextMax = 99;
- tvi.mask = TVIF_TEXT|TVIF_PARAM|TVIF_HANDLE;
- tvi.pszText = idstr;
+ HWND hTree = GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE);
+
+ TVITEM tvi = { 0 };
+ tvi.hItem = TreeView_GetRoot(hTree);
int count = 0;
lockbut();
while(tvi.hItem != NULL) {
- TreeView_GetItem(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE), &tvi);
- char* name = ((ButtonOptData *)tvi.lParam)->name;
+ tvi.stateMask = TVIS_STATEIMAGEMASK;
+ tvi.mask = TVIF_PARAM | TVIF_HANDLE | TVIF_STATE;
+ TreeView_GetItem(hTree, &tvi);
+
int pos = ((ButtonOptData *)tvi.lParam)->pos;
if (pos >= 0 && pos < nButtonsCount) {
- Buttons[pos].dwFlags &= ~(TTBBF_VISIBLE);
- Buttons[pos].dwFlags |= (((ButtonOptData *)tvi.lParam)->show == TRUE ) ? TTBBF_VISIBLE : 0;
+ if ((tvi.state >> 12 ) == 0x2)
+ Buttons[pos].dwFlags |= TTBBF_VISIBLE;
+ else
+ Buttons[pos].dwFlags &= ~TTBBF_VISIBLE;
Buttons[pos].arrangedpos = count;
}
- tvi.hItem = TreeView_GetNextSibling(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE), tvi.hItem);
+ tvi.hItem = TreeView_GetNextSibling(hTree, tvi.hItem);
count++;
}
@@ -121,19 +133,12 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
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, TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_USEICOLIB), FALSE);
-
BuildTree(hwndDlg);
OptionsOpened = true;
EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_DELLBUTTON), FALSE);
SendMessage(hwndDlg, WM_COMMAND, 0, 0);
@@ -141,8 +146,6 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
return TRUE;
case WM_COMMAND:
- EnableWindow(GetDlgItem(hwndDlg, IDC_USEFLAT), IsDlgButtonChecked(hwndDlg, IDC_USEMIRANDABUTTON));
-
if (HIWORD(wParam) == EN_CHANGE ) {
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
@@ -162,7 +165,7 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
tvi.mask = TVIF_PARAM;
TreeView_GetItem(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE), &tvi);
- curselect = ((ButtonOptData *)tvi.lParam)->pos;
+ curselect = ((ButtonOptData *)tvi.lParam)->pos;
if (Buttons[curselect].dwFlags & TTBBF_ISLBUTTON) {
LBUTOPT lbo = { 0 };
TCHAR buf[256];
@@ -179,10 +182,10 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
break;
}
- if (ctrlid == IDC_ADDLBUTTON) {
+ if (ctrlid == IDC_ADDLBUTTON) {
if (CallService(TTB_ADDLBUTTON, 0, 0) == 0) {
// BuildTree(hwndDlg);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
break;
}
@@ -197,7 +200,7 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
tvi.mask = TVIF_PARAM;
TreeView_GetItem(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE), &tvi);
- curselect = ((ButtonOptData *)tvi.lParam)->pos;
+ curselect = ((ButtonOptData *)tvi.lParam)->pos;
if (Buttons[curselect].dwFlags & TTBBF_ISLBUTTON) {
CallService(TTB_REMOVELBUTTON, Buttons[curselect].lParamDown, 0);
EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), FALSE);
@@ -205,12 +208,12 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
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);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
break;
}
@@ -232,8 +235,8 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
MessageBoxA(0, "Bad Code Ptr: tvi.lParam", "log", 0);
break;
}
-
- int curselect = ((ButtonOptData *)tvi.lParam)->pos;
+
+ int curselect = ((ButtonOptData *)tvi.lParam)->pos;
if ( curselect >= 0 && curselect < nButtonsCount ) {
if (Buttons[curselect].dwFlags & TTBBF_ISSEPARATOR) {
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
@@ -247,17 +250,13 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
case WM_NOTIFY:
switch(((LPNMHDR)lParam)->idFrom) {
- case 0:
+ 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);
RecreateWindows();
ArrangeButtons();
@@ -280,47 +279,41 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
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);
+ if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti))
+ if (hti.flags & TVHT_ONITEMSTATEICON) {
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ TreeView_SelectItem(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE), hti.hItem);
}
- }
}
break;
case TVN_SELCHANGED:
{
- TVITEM tvi;
- HTREEITEM hti;
+ HTREEITEM hti = TreeView_GetSelection(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE));
+ if (hti == NULL)
+ break;
- hti = TreeView_GetSelection(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE));
- if (hti == NULL){break;}
- tvi.mask = TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM;
+ TVITEM tvi;
+ tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
tvi.hItem = hti;
TreeView_GetItem(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE), &tvi);
+ TopButtonInt &b = Buttons[((ButtonOptData *)tvi.lParam)->pos];
lockbut();
EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVESEP), FALSE);
- if (Buttons[((ButtonOptData *)tvi.lParam)->pos].dwFlags & TTBBF_ISSEPARATOR)
- EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVESEP), TRUE);
+ if (b.dwFlags & TTBBF_ISSEPARATOR)
+ EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVESEP), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_DELLBUTTON), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_LBUTTONSET), FALSE);
SetDlgItemTextA(hwndDlg, IDC_ENAME, "");
SetDlgItemTextA(hwndDlg, IDC_EPATH, "");
- if (Buttons[((ButtonOptData *)tvi.lParam)->pos].dwFlags & TTBBF_ISLBUTTON) {
+ if (b.dwFlags & TTBBF_ISLBUTTON) {
LBUTOPT lbo = { 0 };
- CallService(TTB_GETLBUTTON, Buttons[((ButtonOptData *)tvi.lParam)->pos].lParamDown, (LPARAM)&lbo);
+ CallService(TTB_GETLBUTTON, b.lParamDown, (LPARAM)&lbo);
if (lbo.hframe != 0) {
EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), TRUE);
@@ -349,63 +342,66 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
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)) {
+ 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);
+ 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:
+ if (dat) {
+ ImageList_Destroy(dat->himlButtonIcons);
+ free(dat);
+ }
OptionsOpened = false;
return 0;
case WM_LBUTTONUP:
if (dat->dragging) {
- TreeView_SetInsertMark(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE), NULL, 0);
+ HWND hTree = GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE);
+ TreeView_SetInsertMark(hTree, 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;
+ TreeView_HitTest(hTree, &hti);
+ if (dat->hDragItem == hti.hItem)
+ break;
+
+ TVITEM tvi;
tvi.mask = TVIF_HANDLE|TVIF_PARAM;
tvi.hItem = hti.hItem;
- TreeView_GetItem(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE), &tvi);
+ TreeView_GetItem(hTree, &tvi);
if (hti.flags&(TVHT_ONITEM|TVHT_ONITEMRIGHT)) {
TVINSERTSTRUCT tvis;
TCHAR name[128];
- tvis.item.mask = TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
+ tvis.item.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_STATE;
tvis.item.stateMask = 0xFFFFFFFF;
tvis.item.pszText = name;
tvis.item.cchTextMax = SIZEOF(name);
tvis.item.hItem = dat->hDragItem;
- //
- tvis.item.iImage = tvis.item.iSelectedImage = ((ButtonOptData *)tvi.lParam)->show;
-
- TreeView_GetItem(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE), &tvis.item);
+ TreeView_GetItem(hTree, &tvis.item);
- TreeView_DeleteItem(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE), dat->hDragItem);
+ TreeView_DeleteItem(hTree, dat->hDragItem);
tvis.hParent = NULL;
tvis.hInsertAfter = hti.hItem;
- TreeView_SelectItem(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE), TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE), &tvis));
+ TreeView_SelectItem(hTree, TreeView_InsertItem(hTree, &tvis));
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- SaveTree(hwndDlg);
}
}
- break;
+ break;
}
return FALSE;
}
@@ -493,7 +489,7 @@ static INT_PTR CALLBACK DlgProcTTBBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
DBWriteContactSettingByte(NULL, TTB_OPTDIR, "UseBitmap", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_BITMAP));
- {
+ {
COLORREF col = SendDlgItemMessage(hwndDlg, IDC_BKGCOLOUR, CPM_GETCOLOUR, 0, 0);
if (col == TTBDEFAULT_BKCOLOUR)
DBDeleteContactSetting(NULL, TTB_OPTDIR, "BkColour");
@@ -518,7 +514,7 @@ static INT_PTR CALLBACK DlgProcTTBBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
if (IsDlgButtonChecked(hwndDlg, IDC_PROPORTIONAL)) flags |= CLBF_PROPORTIONAL;
DBWriteContactSettingWord(NULL, TTB_OPTDIR, "BkBmpUse", flags);
}
-
+
ttbOptionsChanged();
return TRUE;
}
@@ -539,7 +535,7 @@ int TTBOptInit(WPARAM wParam, LPARAM lParam)
odp.hInstance = hInst;
odp.pszGroup = LPGEN("TopToolBar");
- if ( !ServiceExists(MS_BACKGROUNDCONFIG_REGISTER)) {
+ if ( !ServiceExists(MS_BACKGROUNDCONFIG_REGISTER)) {
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_TTBBKG);
odp.pszTitle = LPGEN("TTBBackground");
odp.pfnDlgProc = DlgProcTTBBkgOpts;