From 654ee2c132404a6c58f551d7130a714c534e2b04 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sat, 22 May 1999 10:52:31 +0000 Subject: [PATCH] Toolbar customization dialog (take one). --- dlls/comctl32/comctl32.h | 30 ++++++ dlls/comctl32/propsheet.c | 2 +- dlls/comctl32/propsheet.h | 16 --- dlls/comctl32/rsrc.rc | 21 +++- dlls/comctl32/toolbar.c | 205 +++++++++++++++++++++++++++++++++++--- include/commctrl.h | 17 ++++ include/toolbar.h | 2 + 7 files changed, 261 insertions(+), 32 deletions(-) create mode 100644 dlls/comctl32/comctl32.h delete mode 100644 dlls/comctl32/propsheet.h diff --git a/dlls/comctl32/comctl32.h b/dlls/comctl32/comctl32.h new file mode 100644 index 00000000000..da5e70263d1 --- /dev/null +++ b/dlls/comctl32/comctl32.h @@ -0,0 +1,30 @@ +/****************************************************************************** + * + * Common definitions (resource ids and global variables) + * + * Copyright 1999 Thuy Nguyen + * Copyright 1999 Eric Kohl + * + */ + +extern HMODULE COMCTL32_hModule; + +/* Property sheet / Wizard */ +#define IDD_PROPSHEET 1006 +#define IDD_WIZARD 1020 + +#define IDC_TABCONTROL 12320 +#define IDC_APPLY_BUTTON 12321 + + +/* Toolbar customization dialog */ +#define IDD_TBCUSTOMIZE 200 + +#define IDC_AVAILBTN_LBOX 201 +#define IDC_RESET_BTN 202 +#define IDC_TOOLBARBTN_LBOX 203 +#define IDC_REMOVE_BTN 204 +#define IDC_HELP_BTN 205 +#define IDC_MOVEUP_BTN 206 +#define IDC_MOVEDN_BTN 207 + diff --git a/dlls/comctl32/propsheet.c b/dlls/comctl32/propsheet.c index f5c1c3f057f..ab31345cde5 100644 --- a/dlls/comctl32/propsheet.c +++ b/dlls/comctl32/propsheet.c @@ -15,7 +15,7 @@ #include "commctrl.h" #include "prsht.h" #include "winnls.h" -#include "propsheet.h" +#include "comctl32.h" #include "debug.h" diff --git a/dlls/comctl32/propsheet.h b/dlls/comctl32/propsheet.h deleted file mode 100644 index 1bb2037ab1d..00000000000 --- a/dlls/comctl32/propsheet.h +++ /dev/null @@ -1,16 +0,0 @@ -/****************************************************************************** - * - * Property Sheets - * - * Copyright 1999 Thuy Nguyen - * - */ - -extern HMODULE COMCTL32_hModule; - -#define IDD_PROPSHEET 1006 -#define IDD_WIZARD 1020 - -#define IDC_TABCONTROL 12320 -#define IDC_APPLY_BUTTON 12321 - diff --git a/dlls/comctl32/rsrc.rc b/dlls/comctl32/rsrc.rc index d04a52f241f..6fc87af1441 100644 --- a/dlls/comctl32/rsrc.rc +++ b/dlls/comctl32/rsrc.rc @@ -1,5 +1,5 @@ #include "winuser.h" -#include "propsheet.h" +#include "comctl32.h" IDD_PROPSHEET DIALOG DISCARDABLE 0, 0, 292, 159 @@ -14,3 +14,22 @@ BEGIN CONTROL "Tab", IDC_TABCONTROL,"SysTabControl32",WS_CLIPSIBLINGS,7,7,278,125 END + +IDD_TBCUSTOMIZE DIALOG DISCARDABLE 10, 20, 357, 125 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Customize Toolbar" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "&Close", IDCANCEL,308,6,44,14 + PUSHBUTTON "R&eset", IDC_RESET_BTN,308,23,44,14 + PUSHBUTTON "&Help", IDC_HELP_BTN,308,40,44,14 + PUSHBUTTON "Move &Up", IDC_MOVEUP_BTN,308,74,44,14 + PUSHBUTTON "Move &Down", IDC_MOVEDN_BTN,308,91,44,14 + LTEXT "A&vailable buttons:", -1,4,5,84,10 + LISTBOX IDC_AVAILBTN_LBOX,4,17,120,100, LBS_NOTIFY | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP + PUSHBUTTON "&Add ->", IDOK, 131, 42, 44, 14 + PUSHBUTTON "<- &Remove", IDC_REMOVE_BTN,131,62,44,14 + LTEXT "&Toolbar buttons:", -1,182,5,78,10 + LISTBOX IDC_TOOLBARBTN_LBOX, 182,17,120,100,LBS_NOTIFY | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP +END + diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c index c397f3a1f03..ac8f2804266 100644 --- a/dlls/comctl32/toolbar.c +++ b/dlls/comctl32/toolbar.c @@ -1,8 +1,7 @@ - /* * Toolbar control * - * Copyright 1998 Eric Kohl + * Copyright 1998,1999 Eric Kohl * * TODO: * - A little bug in TOOLBAR_DrawMasked() @@ -14,7 +13,7 @@ * - Unicode suppport. * - Internal COMMCTL32 bitmaps. * - Fix TOOLBAR_SetButtonInfo32A. - * - Fix TOOLBAR_Customize. (Customize dialog.) + * - Customize dialog (under construction). * * Testing: * - Run tests using Waite Group Windows95 API Bible Volume 2. @@ -32,6 +31,7 @@ #include "commctrl.h" #include "sysmetrics.h" #include "cache.h" +#include "comctl32.h" #include "toolbar.h" #include "debug.h" @@ -41,9 +41,9 @@ DEFAULT_DEBUG_CHANNEL(toolbar) #define TOP_BORDER 2 #define BOTTOM_BORDER 2 - #define TOOLBAR_GetInfoPtr(wndPtr) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0)) + static void TOOLBAR_DrawFlatSeparator (LPRECT lpRect, HDC hdc) { @@ -716,6 +716,151 @@ TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg, SendMessageA (hwndTip, TTM_RELAYEVENT, 0, (LPARAM)&msg); } + +/*********************************************************************** + * TOOLBAR_CustomizeDialogProc + * This function implements the toolbar customization dialog. + */ +BOOL WINAPI +TOOLBAR_CustomizeDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + TOOLBAR_INFO *infoPtr = (TOOLBAR_INFO *)GetWindowLongA (hwnd, DWL_USER); + static HDSA hDsa = NULL; + + switch (uMsg) + { + case WM_INITDIALOG: + infoPtr = (TOOLBAR_INFO *)lParam; + SetWindowLongA (hwnd, DWL_USER, (DWORD)infoPtr); + + hDsa = DSA_Create (sizeof(TBUTTON_INFO), 5); + + if (infoPtr) + { + TBUTTON_INFO *btnPtr; + INT i; + + /* insert 'virtual' separator button into 'available buttons' list */ + SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)""); + + /* copy all buttons and append them to the right listbox */ + btnPtr = infoPtr->buttons; + for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) + { + DSA_InsertItem (hDsa, i, btnPtr); + + if (btnPtr->fsState & TBSTATE_HIDDEN) + { + SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)""); + } + else + { + SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)""); + } + } + + /* append 'virtual' sepatator button to the 'toolbar buttons' list */ + /* TODO */ + } + return TRUE; + + case WM_CLOSE: + EndDialog(hwnd, FALSE); + return TRUE; + + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDCANCEL: + EndDialog(hwnd, FALSE); + break; + } + return TRUE; + + case WM_DESTROY: + if (hDsa) + DSA_Destroy (hDsa); + return TRUE; + + case WM_DRAWITEM: + if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX) + { + LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam; + RECT rcButton; + RECT rcText; + HPEN hOldPen; + HBRUSH hOldBrush; + COLORREF oldText = 0; + COLORREF oldBk = 0; + + FIXME(toolbar, "action: %x itemState: %x\n", + lpdis->itemAction, lpdis->itemState); + + if (lpdis->itemState & ODS_FOCUS) + { + oldBk = SetBkColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT)); + oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); + } + + hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW)); + hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW)); + + /* fill background rectangle */ + Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, + lpdis->rcItem.right, lpdis->rcItem.bottom); + + /* calculate button and text rectangles */ + CopyRect (&rcButton, &lpdis->rcItem); + InflateRect (&rcButton, -1, -1); + CopyRect (&rcText, &rcButton); + rcButton.right = rcButton.left + infoPtr->nBitmapWidth + 6; + rcText.left = rcButton.right + 2; + + /* draw focus rectangle */ + if (lpdis->itemState & ODS_FOCUS) + DrawFocusRect (lpdis->hDC, &lpdis->rcItem); + + /* draw button */ + DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT); + + /* draw text */ + if (wParam == IDC_AVAILBTN_LBOX && lpdis->itemID == 0) + DrawTextA (lpdis->hDC, "Separator", -1, &rcText, + DT_LEFT | DT_VCENTER | DT_SINGLELINE); + + if (lpdis->itemState & ODS_FOCUS) + { + SetBkColor (lpdis->hDC, oldBk); + SetTextColor (lpdis->hDC, oldText); + } + + SelectObject (lpdis->hDC, hOldBrush); + SelectObject (lpdis->hDC, hOldPen); + + return TRUE; + } + return FALSE; + + case WM_MEASUREITEM: + if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX) + { + MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam; + + if (infoPtr) + lpmis->itemHeight = infoPtr->nBitmapHeight + 8; + else + lpmis->itemHeight = 16 + 8; /* default height */ + + return TRUE; + } + return FALSE; + + default: + return FALSE; + } +} + + /*********************************************************************** * TOOLBAR_AddBitmap: Add the bitmaps to the default image list. * @@ -1156,9 +1301,41 @@ TOOLBAR_CommandToIndex (HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT TOOLBAR_Customize (HWND hwnd) { - FIXME (toolbar, "customization not implemented!\n"); + TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); + LRESULT ret; + LPCVOID template; + HRSRC hRes; + NMHDR nmhdr; - return 0; + /* send TBN_BEGINADJUST notification */ + nmhdr.hwndFrom = hwnd; + nmhdr.idFrom = GetWindowLongA (hwnd, GWL_ID); + nmhdr.code = TBN_BEGINADJUST; + + SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, + (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr); + + if (!(hRes = FindResourceA (COMCTL32_hModule, + MAKEINTRESOURCEA(IDD_TBCUSTOMIZE), + RT_DIALOGA))) + return FALSE; + + if(!(template = (LPVOID)LoadResource (COMCTL32_hModule, hRes))) + return FALSE; + + ret = DialogBoxIndirectParamA (GetWindowLongA (hwnd, GWL_HINSTANCE), + (LPDLGTEMPLATEA)template, + hwnd, + (DLGPROC)TOOLBAR_CustomizeDialogProc, + (LPARAM)infoPtr); + + /* send TBN_ENDADJUST notification */ + nmhdr.code = TBN_ENDADJUST; + + SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, + (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr); + + return ret; } @@ -2769,7 +2946,7 @@ ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case TB_ADDBUTTONSA: return TOOLBAR_AddButtonsA (hwnd, wParam, lParam); -/* case TB_ADDBUTTONS32W: */ +/* case TB_ADDBUTTONSW: */ case TB_ADDSTRINGA: return TOOLBAR_AddStringA (hwnd, wParam, lParam); @@ -2818,7 +2995,7 @@ ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case TB_GETBUTTONINFOA: return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam); -/* case TB_GETBUTTONINFO32W: */ /* 4.71 */ +/* case TB_GETBUTTONINFOW: */ /* 4.71 */ case TB_GETBUTTONSIZE: return TOOLBAR_GetButtonSize (hwnd); @@ -2826,7 +3003,7 @@ ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case TB_GETBUTTONTEXTA: return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam); -/* case TB_GETBUTTONTEXT32W: */ +/* case TB_GETBUTTONTEXTW: */ /* case TB_GETCOLORSCHEME: */ /* 4.71 */ case TB_GETDISABLEDIMAGELIST: @@ -2888,7 +3065,7 @@ ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case TB_INSERTBUTTONA: return TOOLBAR_InsertButtonA (hwnd, wParam, lParam); -/* case TB_INSERTBUTTON32W: */ +/* case TB_INSERTBUTTONW: */ /* case TB_INSERTMARKHITTEST: */ /* 4.71 */ case TB_ISBUTTONCHECKED: @@ -2910,8 +3087,8 @@ ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam); /* case TB_LOADIMAGES: */ /* 4.70 */ -/* case TB_MAPACCELERATOR32A: */ /* 4.71 */ -/* case TB_MAPACCELERATOR32W: */ /* 4.71 */ +/* case TB_MAPACCELERATORA: */ /* 4.71 */ +/* case TB_MAPACCELERATORW: */ /* 4.71 */ /* case TB_MARKBUTTON: */ /* 4.71 */ /* case TB_MOVEBUTTON: */ /* 4.71 */ @@ -2923,7 +3100,7 @@ ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case TB_SAVERESTOREA: return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam); -/* case TB_SAVERESTORE32W: */ +/* case TB_SAVERESTOREW: */ /* case TB_SETANCHORHIGHLIGHT: */ /* 4.71 */ case TB_SETBITMAPSIZE: @@ -2932,7 +3109,7 @@ ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case TB_SETBUTTONINFOA: return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam); -/* case TB_SETBUTTONINFO32W: */ /* 4.71 */ +/* case TB_SETBUTTONINFOW: */ /* 4.71 */ case TB_SETBUTTONSIZE: return TOOLBAR_SetButtonSize (hwnd, wParam, lParam); diff --git a/include/commctrl.h b/include/commctrl.h index f4567da58fc..28ac75b6510 100644 --- a/include/commctrl.h +++ b/include/commctrl.h @@ -893,6 +893,23 @@ typedef struct tagNMHDDISPINFOW #define TBN_GETBUTTONINFOA (TBN_FIRST-0) #define TBN_GETBUTTONINFOW (TBN_FIRST-20) #define TBN_GETBUTTONINFO WINELIB_NAME_AW(TBN_GETBUTTONINFO) +#define TBN_BEGINDRAG (TBN_FIRST-1) +#define TBN_ENDDRAG (TBN_FIRST-2) +#define TBN_BEGINADJUST (TBN_FIRST-3) +#define TBN_ENDADJUST (TBN_FIRST-4) +#define TBN_RESET (TBN_FIRST-5) +#define TBN_QUERYINSERT (TBN_FIRST-6) +#define TBN_QUERYDELETE (TBN_FIRST-7) +#define TBN_TOOLBARCHANGE (TBN_FIRST-8) +#define TBN_CUSTHELP (TBN_FIRST-9) +#define TBN_DROPDOWN (TBN_FIRST-10) +#define TBN_GETOBJECT (TBN_FIRST-12) +#define TBN_HOTITEMCHANGE (TBN_FIRST-13) +#define TBN_DRAGOUT (TBN_FIRST-14) +#define TBN_DELETINGBUTTON (TBN_FIRST-15) +#define TBN_GETDISPINFOA (TBN_FIRST-16) +#define TBN_GETDISPINFOW (TBN_FIRST-17) +#define TBN_GETDISPINFO WINELIB_NAME_AW(TBN_GETDISPINFO) #define TBN_GETINFOTIPA (TBN_FIRST-18) #define TBN_GETINFOTIPW (TBN_FIRST-19) #define TBN_GETINFOTIP WINELIB_NAME_AW(TBN_GETINFOTIP) diff --git a/include/toolbar.h b/include/toolbar.h index 968dab5db36..bb6d8ff2ec1 100644 --- a/include/toolbar.h +++ b/include/toolbar.h @@ -65,6 +65,8 @@ typedef struct tagTOOLBAR_INFO } TOOLBAR_INFO; +extern BOOL WINAPI TBARCUST_DialogProc (HWND, UINT, WPARAM, LPARAM); + extern VOID TOOLBAR_Register (VOID); extern VOID TOOLBAR_Unregister (VOID);