Sun Jun 15 10:30:35 1998 Andreas Mohr <100.30936@germany.net> * [files/dos_fs.c] [files/file.c] [if1632/wprocs.spec] [misc/aspi.c] Added support for scanners that need Adaptec's ASPI2DOS. * [graphics/env.c] [misc/printerdrv.c] [graphics/win16drv/init.c] [if1632/gdi.spec] [include/gdi.h] Enhanced printer support (especially Win95): Drv[GS]etPrinterData, [GS]etEnvironment; added AbortProc handling. * [misc/tapi32.c] [relay32/tapi32.spec] Added some stubs. * [configure.in] [graphics/fontengine.c] [include/windows.h] [misc/comm.c] [misc/w32skrnl.c] [misc/win32s16.c] Made Wine compile on HP-UX (just for fun ;) * [controls/menu.c] [include/windows.h] Complete rewrite of EnableMenuItem32. Free Agent 32 still doesn't work :( * [misc/version.c] [if1632/kernel.spec] [include/winbase.h] Implemented GetVersionEx16. * [misc/network.c] [if1632/user.spec] Fixed arguments of WNetGetPropertyText. * [misc/version.c] [relay32/comctl32.spec] [relay32/oleaut32.spec] Implemented COMCTL32_DllGetVersion, OaBuildVersion. * [win32/file.c] Fixed UNC handling of CreateFile32. Sat Jun 13 22:35:12 1998 Douglas Ridgway <ridgway@winehq.com> * [Makefile.in] [Make.rules.in] Added pattern for CVS merge files to 'make clean' * [ole/olecli.c] [windows/scroll.c] [windows/grahics.c] Add some DC handle unlocking. (When hdc's are always unlocked, they can be made moveable.) * [documentation/wine.texinfo] Started a Wine Design chapter with discussion of graphics driver model. Sat Jun 13 11:19:25 1998 David Luyer <luyer@ucs.uwa.edu.au> * [misc/main.c] [relay32/relay386.c] Added new option -debugmsg +relay=.... or -debugmsg -relay=... Fri Jun 12 22:56:09 1998 Marcus Meissner <marcus@jet.franken.de> * [relay32/snoop.c][relay32/builtin.c][loader/pe_image.c] Added inter win32 dll snooping. Use -debugmsg +snoop. Number of arguments and string references are autodetected. Some small bugfixes in the PE loader. * [misc/system.c] Disabled SystemTimers. They do not work with the current %fs handling in the 32->16 relaycode. (helps labview) * [msdos/dpmi.c][msdos/int2f.c][files/drive.c] Added a monoton linear increasing memory allocator for DPMI (required for LabView, HAFAS, ...) mscdex handling in emulated realmode interrupts (for mcicda.drv) allocate logical drives only once. (helps Myst) * [files/profile.c] Handle ^Z as space. Found on CDROMS (helps Myst Installer). * [multimedia/mmio.c] mmio* partially updated to win32. No funny additions. * [windows/driver.c] Added win32 driver handling (will be used for win32 multimedia/ msvideo drivers). * [win32/device.c] Added device handling (K32OBJ_DEVICE_IOCTL). Implemented VTDAPI.5 (used by win95' WINMM.timeGetTime()) Fri Jun 12 18:01:18 1998 Rein Klazes <rklazes@casema.net> * [ole/compobj.c relay32/ole32.spec] Add a stub for CoLockObjectExternal32. * [objects/clipping.c] Fix in IntersectClipRect(), when there is no initial clipping region. * [graphics/x11drv/graphics.c] Corrected several "one-off" errors for the Ellipse, Rectangle and RoundRectangle (especially small ones) draw routines. Arc and friends still have to be done. Fri Jun 12 06:23:19 1998 Matthew Becker <mbecker@glasscity.net> * [misc/ntdll.c] Fixed some of the parameter counts. * [misc/registry.c] General cleanup, documentation. Standard keys are allowed to be 'closed' and succeed. * [misc/shell.c] Check for correct return values from Reg* functions. * [win32/newfns.c] Added stubs for OpenDesktopA, SetThreadDesktop, and SetUserObjectInformationA. Wed Jun 10 20:28:08 1998 James Juran <jrj120@psu.edu> * [debugger/break.c] Fixed bug introduced in 980503 that broke the -debug command line option for PE executable files. * [configure.in] [include/acconfig.h] [include/debugtools.h] [documentation/debug-msgs] Added 'configure' options to compile out debugging messages. Use --disable-debug to disable all debugging messages, and --disable-trace to just disable TRACE messages. This results in a stripped executable that is 15-20% smaller. This option is very much untested--don't expect it to work. * [documentation/debug-msgs] [documentation/debugging] Minor updates. * [*/*.c] Fixed some compile warnings. This also includes the compile_warnings_trivial patch from WineHQ. Tue Jun 10 22:00:18 1998 Eric Kohl <ekohl@abo.rhein-zeitung.de> * [windows/sysmetrics.c][include/sysmetrics.h] Fixed some Win95 values. * [windows/nonclient.c][include/windows.h] Fixed some Win95 drawing bugs. Added extended window style flags (WS_EX_xxx). * [misc/printdrv.c][relay32/winspool.spec] Added stubs for DeletePrinterDriver32A, DeleteMonitor32A and DeletePort32A. * [windows/mdi.c][include/windows.h][relay32/user32.spec] Added stubs for CascadeWindows and TileWindows. * [controls/toolbar.c][include/toolbar.h] Fixed a few bugs and implemented new features. * [misc/shellord.c][relay32/shell32.spec] Added stubs for SHELL32_60, SHELL32_61 and SHELL32_184. * [controls/comctl32undoc.c][relay32/comctl32.spec] New file comctl32undoc.c. Contains undocumented functions of COMCTL32.DLL. These functions are needed to run EXPLORER.EXE IEXPLORE.EXE and TASKMAN.EXE. * [controls/status.c] Added text alignment. Tue Jun 8 22:00:00 1998 Bertho Stultiens <bertho@akhphd.au.dk> * [programs/*/Makefile.in] Changed the rules to use wrc as resource compiler but passing the source through gcc first for macro expansion. * [programs/*/*.rc] Added #include "windows.h" for the resource compiler in the appropriate files. * [tools/wrc/wrc.[ch]] [tools/wrc/writeres.c] Added commandline option -A for autoregister code. Corrected the underscore problem by checking the proper define from config.h. Sun Jun 7 22:09:29 1998 Pascal Cuoq <pcuoq@ens-lyon.fr> * [ole/ole2nls.c] [memory/string.c] Improved LCMapString32A, and changed CompareString32A, lstrcmp, lstrcmpi to use it. Sat Jun 6 19:00:50 1998 Martin Strömberg <ams@ludd.luth.se> * [include/winnt.h] Added typedefs for security and tokens. Sat Jun 6 12:26:31 1998 Morten Welinder <terra@diku.dk> * [objects/text.c] Use debugstr_an in DrawText16. * [loader/resource.c] Use debugres_w in FindResourceEx32W. Avoid crashing during debug when wm is NULL. * [if1632/relay.c] In RELAY_DebugCallTo16, send output to the right place and avoid side effects in macro arguments. Wed Jun 3 20:56:03 1998 Huw D M Davies <daviesh@abacus.physics.ox.ac.uk> * [controls/scroll.c] [windows/nonclient.c] Fix several off by one errors in scrollbar painting. Tue Jun 2 23:58:59 1998 Insomnia (Stea Greene) <insomnia@core.binghamton.edu> * [graphics/dsound.c] Rewrote mixer code to handle panning and volume for 16->16, 16->8, 8->16, and 8->8 bit mixes. Conforms to DirectX's "logarithmic hearing scale" as specified in M$VC docs. Still does not handle mixing of different frequencies (I am still working on that). Tested 16->16 extensively with StarCraft. Other mixing combinations untested but should work fine. Still kind of a work in progress, so be warned. Tue Jun 2 03:31:33 1998 Alexander V. Lukyanov <lav@long.yar.ru> * [tools/wrc/utils.c] dup_basename: fix to strip directory. Mon Jun 1 20:00:00 1998 Juergen Schmied <juergen.schmied@metronet.de> * [include/windows.h] [objects/cursoricon.c] [relay32/user32.spec] Added stubs LoadCursorFromFileW and LoadCursorFromFileA.
1861 lines
45 KiB
C
1861 lines
45 KiB
C
/*
|
|
* Toolbar control
|
|
*
|
|
* Copyright 1998 Eric Kohl
|
|
*
|
|
* NOTES
|
|
* PLEASE don't try to improve or change this code right now. Many
|
|
* features are still missing, but I'm working on it. I want to avoid
|
|
* any confusion. This note will be removed as soon as most of the
|
|
* features are implemented.
|
|
* Eric <ekohl@abo.rhein-zeitung.de>
|
|
*
|
|
* TODO:
|
|
* - Many messages.
|
|
* - All notifications.
|
|
* - Fix TB_GETBITMAPFLAGS.
|
|
* - Fix TB_GETROWS and TB_SETROWS.
|
|
* - Tooltip support (partially).
|
|
* - Unicode suppport.
|
|
* - Internal COMMCTL32 bitmaps.
|
|
* - Customize dialog.
|
|
*
|
|
* Testing:
|
|
* - Run tests using Waite Group Windows95 API Bible Volume 2.
|
|
* The second cdrom contains executables addstr.exe, btncount.exe,
|
|
* btnstate.exe, butstrsz.exe, chkbtn.exe, chngbmp.exe, customiz.exe,
|
|
* enablebtn.exe, getbmp.exe, getbtn.exe, getflags.exe, hidebtn.exe,
|
|
* indetbtn.exe, insbtn.exe, pressbtn.exe, setbtnsz.exe, setcmdid.exe,
|
|
* setparnt.exe, setrows.exe, toolwnd.exe.
|
|
* - additional features.
|
|
*/
|
|
|
|
#include "windows.h"
|
|
#include "commctrl.h"
|
|
#include "cache.h"
|
|
#include "toolbar.h"
|
|
#include "heap.h"
|
|
#include "win.h"
|
|
#include "debug.h"
|
|
|
|
|
|
#define SEPARATOR_WIDTH 8
|
|
#define SEPARATOR_HEIGHT 5
|
|
|
|
|
|
|
|
|
|
#define TOOLBAR_GetInfoPtr(wndPtr) ((TOOLBAR_INFO *)wndPtr->wExtra[0])
|
|
|
|
|
|
static void
|
|
TOOLBAR_DrawButton (WND *wndPtr, TBUTTON_INFO *btnPtr, HDC32 hdc)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
RECT32 rc;
|
|
|
|
if (btnPtr->fsState & TBSTATE_HIDDEN) return;
|
|
|
|
rc = btnPtr->rect;
|
|
if (btnPtr->fsStyle & TBSTYLE_SEP) {
|
|
|
|
}
|
|
else {
|
|
if (!(btnPtr->fsState & TBSTATE_ENABLED)) {
|
|
/* button is disabled */
|
|
HICON32 hIcon;
|
|
DrawEdge32 (hdc, &rc, EDGE_RAISED,
|
|
BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
|
|
hIcon = ImageList_GetIcon (infoPtr->himlDef, btnPtr->iBitmap, ILD_IMAGE);
|
|
DrawState32A (hdc, (HBRUSH32)NULL, NULL, MAKELONG(hIcon, 0), 0,
|
|
rc.left+1, rc.top+1,
|
|
infoPtr->nBitmapWidth, infoPtr->nBitmapHeight, DST_ICON|DSS_DISABLED);
|
|
// ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc,
|
|
// rc.left+1, rc.top+1, ILD_NORMAL);
|
|
return;
|
|
}
|
|
|
|
/* TBSTYLE_BUTTON */
|
|
if (btnPtr->fsState & TBSTATE_PRESSED) {
|
|
DrawEdge32 (hdc, &rc, EDGE_SUNKEN,
|
|
BF_RECT | BF_MIDDLE | BF_ADJUST);
|
|
ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
|
|
rc.left+2, rc.top+2, ILD_NORMAL);
|
|
return;
|
|
}
|
|
|
|
if ((btnPtr->fsStyle & TBSTYLE_CHECK) &&
|
|
(btnPtr->fsState & TBSTATE_CHECKED)) {
|
|
HBRUSH32 hbr;
|
|
DrawEdge32 (hdc, &rc, EDGE_SUNKEN,
|
|
BF_RECT | BF_MIDDLE | BF_ADJUST);
|
|
|
|
hbr = SelectObject32 (hdc, CACHE_GetPattern55AABrush ());
|
|
PatBlt32 (hdc, rc.left, rc.top, rc.right - rc.left,
|
|
rc.bottom - rc.top, 0x00FA0089);
|
|
SelectObject32 (hdc, hbr);
|
|
ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
|
|
rc.left+2, rc.top+2, ILD_NORMAL);
|
|
return;
|
|
}
|
|
|
|
if (btnPtr->fsState & TBSTATE_INDETERMINATE) {
|
|
HBRUSH32 hbr;
|
|
DrawEdge32 (hdc, &rc, EDGE_RAISED,
|
|
BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
|
|
|
|
hbr = SelectObject32 (hdc, CACHE_GetPattern55AABrush ());
|
|
PatBlt32 (hdc, rc.left, rc.top, rc.right - rc.left,
|
|
rc.bottom - rc.top, 0x00FA0089);
|
|
SelectObject32 (hdc, hbr);
|
|
// ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
|
|
// rc.left+1, rc.top+1, ILD_NORMAL);
|
|
return;
|
|
}
|
|
|
|
/* normal state */
|
|
DrawEdge32 (hdc, &rc, EDGE_RAISED,
|
|
BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
|
|
ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
|
|
rc.left+1, rc.top+1, ILD_NORMAL);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
TOOLBAR_Refresh (WND *wndPtr, HDC32 hdc)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
TBUTTON_INFO *btnPtr;
|
|
INT32 i;
|
|
|
|
|
|
/* draw buttons */
|
|
|
|
btnPtr = infoPtr->buttons;
|
|
for (i = 0; i < infoPtr->nNumButtons; i++) {
|
|
TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
|
|
btnPtr++;
|
|
}
|
|
}
|
|
|
|
|
|
static void
|
|
TOOLBAR_CalcToolbar (WND *wndPtr)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
TBUTTON_INFO *btnPtr;
|
|
RECT32 rect;
|
|
INT32 i;
|
|
|
|
rect.left = infoPtr->nIndent;
|
|
rect.top = infoPtr->nButtonTop;
|
|
// rect.right = rect.left + infoPtr->nButtonWidth;
|
|
rect.bottom = rect.top + infoPtr->nButtonHeight;
|
|
|
|
btnPtr = infoPtr->buttons;
|
|
for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
|
|
if (btnPtr->fsState & TBSTATE_HIDDEN) {
|
|
btnPtr->rect.left = 0;
|
|
btnPtr->rect.right = 0;
|
|
btnPtr->rect.top = 0;
|
|
btnPtr->rect.bottom = 0;
|
|
continue;
|
|
}
|
|
|
|
btnPtr->rect = rect;
|
|
if (btnPtr->fsStyle & TBSTYLE_SEP)
|
|
btnPtr->rect.right = btnPtr->rect.left + SEPARATOR_WIDTH;
|
|
else
|
|
btnPtr->rect.right = btnPtr->rect.left + infoPtr->nButtonWidth;
|
|
rect.left = btnPtr->rect.right;
|
|
}
|
|
|
|
infoPtr->nHeight = rect.bottom + 8;
|
|
}
|
|
|
|
|
|
static INT32
|
|
TOOLBAR_InternalHitTest (WND *wndPtr, LPPOINT32 lpPt)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
TBUTTON_INFO *btnPtr;
|
|
INT32 i;
|
|
|
|
|
|
btnPtr = infoPtr->buttons;
|
|
for (i = 0; i < infoPtr->nNumButtons; i++) {
|
|
if (btnPtr->fsStyle & TBSTYLE_SEP) {
|
|
if (PtInRect32 (&btnPtr->rect, *lpPt)) {
|
|
TRACE (toolbar, " ON SEPARATOR %d!\n", i);
|
|
return -i;
|
|
}
|
|
}
|
|
else {
|
|
if (PtInRect32 (&btnPtr->rect, *lpPt)) {
|
|
TRACE (toolbar, " ON BUTTON %d!\n", i);
|
|
return i;
|
|
}
|
|
|
|
}
|
|
|
|
btnPtr++;
|
|
}
|
|
|
|
TRACE (toolbar, " NOWHERE!\n");
|
|
return -1;
|
|
}
|
|
|
|
|
|
static INT32
|
|
TOOLBAR_GetButtonIndex (TOOLBAR_INFO *infoPtr, INT32 idCommand)
|
|
{
|
|
TBUTTON_INFO *btnPtr;
|
|
INT32 i;
|
|
|
|
btnPtr = infoPtr->buttons;
|
|
for (i = 0; i < infoPtr->nNumButtons; i++) {
|
|
if (btnPtr->idCommand == idCommand) {
|
|
TRACE (toolbar, "command=%d index=%d\n", idCommand, i);
|
|
return i;
|
|
}
|
|
btnPtr++;
|
|
}
|
|
TRACE (toolbar, "no index found for command=%d\n", idCommand);
|
|
return -1;
|
|
}
|
|
|
|
|
|
static INT32
|
|
TOOLBAR_GetCheckedGroupButtonIndex (TOOLBAR_INFO *infoPtr, INT32 nIndex)
|
|
{
|
|
TBUTTON_INFO *btnPtr;
|
|
INT32 nRunIndex;
|
|
|
|
if ((nIndex < 0) || (nIndex > infoPtr->nNumButtons))
|
|
return -1;
|
|
|
|
/* check index button */
|
|
btnPtr = &infoPtr->buttons[nIndex];
|
|
if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
|
|
if (btnPtr->fsState & TBSTATE_CHECKED)
|
|
return nIndex;
|
|
}
|
|
|
|
/* check previous buttons */
|
|
nRunIndex = nIndex - 1;
|
|
while (nRunIndex >= 0) {
|
|
btnPtr = &infoPtr->buttons[nRunIndex];
|
|
if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
|
|
if (btnPtr->fsState & TBSTATE_CHECKED)
|
|
return nRunIndex;
|
|
}
|
|
else
|
|
break;
|
|
nRunIndex--;
|
|
}
|
|
|
|
/* check next buttons */
|
|
nRunIndex = nIndex + 1;
|
|
while (nRunIndex < infoPtr->nNumButtons) {
|
|
btnPtr = &infoPtr->buttons[nRunIndex];
|
|
if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
|
|
if (btnPtr->fsState & TBSTATE_CHECKED)
|
|
return nRunIndex;
|
|
}
|
|
else
|
|
break;
|
|
nRunIndex++;
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_AddBitmap (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
LPTBADDBITMAP lpAddBmp = (LPTBADDBITMAP)lParam;
|
|
INT32 nIndex = 0;
|
|
|
|
if ((!lpAddBmp) || ((INT32)wParam <= 0))
|
|
return -1;
|
|
|
|
TRACE (toolbar, "adding %d bitmaps!\n", wParam);
|
|
|
|
if (!(infoPtr->himlDef)) {
|
|
/* create new default image list */
|
|
TRACE (toolbar, "creating default image list!\n");
|
|
infoPtr->himlDef =
|
|
ImageList_Create (infoPtr->nBitmapWidth,
|
|
infoPtr->nBitmapHeight, ILC_COLOR | ILC_MASK,
|
|
(INT32)wParam, 2);
|
|
}
|
|
|
|
#if 0
|
|
if (!(infoPtr->himlDis)) {
|
|
/* create new disabled image list */
|
|
TRACE (toolbar, "creating disabled image list!\n");
|
|
infoPtr->himlDis =
|
|
ImageList_Create (infoPtr->nBitmapWidth,
|
|
infoPtr->nBitmapHeight, ILC_COLOR | ILC_MASK,
|
|
(INT32)wParam, 2);
|
|
}
|
|
#endif
|
|
|
|
/* Add bitmaps to the default image list */
|
|
if (lpAddBmp->hInst == (HINSTANCE32)0) {
|
|
nIndex =
|
|
ImageList_AddMasked (infoPtr->himlDef, (HBITMAP32)lpAddBmp->nID,
|
|
0xC0C0C0);
|
|
// GetSysColor32 (COLOR_3DFACE));
|
|
}
|
|
else if (lpAddBmp->hInst == HINST_COMMCTRL) {
|
|
/* add internal bitmaps */
|
|
FIXME (toolbar, "internal bitmaps not supported!\n");
|
|
|
|
/* Hack to "add" some reserved images within the image list
|
|
to get the right image indices */
|
|
nIndex = ImageList_GetImageCount (infoPtr->himlDef);
|
|
ImageList_SetImageCount (infoPtr->himlDef, nIndex + (INT32)wParam);
|
|
}
|
|
else {
|
|
HBITMAP32 hBmp =
|
|
LoadBitmap32A (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
|
|
|
|
nIndex = ImageList_Add (infoPtr->himlDef, hBmp, (HBITMAP32)0);
|
|
|
|
DeleteObject32 (hBmp);
|
|
}
|
|
|
|
|
|
infoPtr->nNumBitmaps += (INT32)wParam;
|
|
|
|
return nIndex;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_AddButtons32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
|
|
INT32 nOldButtons, nNewButtons, nAddButtons, nCount;
|
|
HDC32 hdc;
|
|
|
|
TRACE (toolbar, "adding %d buttons!\n", wParam);
|
|
|
|
nAddButtons = (UINT32)wParam;
|
|
nOldButtons = infoPtr->nNumButtons;
|
|
nNewButtons = nOldButtons + nAddButtons;
|
|
|
|
if (infoPtr->nNumButtons == 0) {
|
|
infoPtr->buttons =
|
|
HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY,
|
|
sizeof (TBUTTON_INFO) * nNewButtons);
|
|
}
|
|
else {
|
|
TBUTTON_INFO *oldButtons = infoPtr->buttons;
|
|
infoPtr->buttons =
|
|
HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY,
|
|
sizeof (TBUTTON_INFO) * nNewButtons);
|
|
memcpy (&infoPtr->buttons[0], &oldButtons[0],
|
|
nOldButtons * sizeof(TBUTTON_INFO));
|
|
HeapFree (SystemHeap, 0, oldButtons);
|
|
}
|
|
|
|
infoPtr->nNumButtons = nNewButtons;
|
|
|
|
/* insert new button data (bad implementation)*/
|
|
for (nCount = 0; nCount < nAddButtons; nCount++) {
|
|
infoPtr->buttons[nOldButtons+nCount].iBitmap = lpTbb[nCount].iBitmap;
|
|
infoPtr->buttons[nOldButtons+nCount].idCommand = lpTbb[nCount].idCommand;
|
|
infoPtr->buttons[nOldButtons+nCount].fsState = lpTbb[nCount].fsState;
|
|
infoPtr->buttons[nOldButtons+nCount].fsStyle = lpTbb[nCount].fsStyle;
|
|
infoPtr->buttons[nOldButtons+nCount].dwData = lpTbb[nCount].dwData;
|
|
infoPtr->buttons[nOldButtons+nCount].iString = lpTbb[nCount].iString;
|
|
}
|
|
|
|
TOOLBAR_CalcToolbar (wndPtr);
|
|
|
|
hdc = GetDC32 (wndPtr->hwndSelf);
|
|
TOOLBAR_Refresh (wndPtr, hdc);
|
|
ReleaseDC32 (wndPtr->hwndSelf, hdc);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
// << TOOLBAR_AddButtons32W >>
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_AddString32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
INT32 nIndex;
|
|
|
|
if (wParam) {
|
|
char szString[256];
|
|
INT32 len;
|
|
TRACE (toolbar, "adding string from resource!\n");
|
|
|
|
len = LoadString32A ((HINSTANCE32)wParam, (UINT32)lParam,
|
|
szString, 256);
|
|
|
|
TRACE (toolbar, "len=%d\n", len);
|
|
nIndex = infoPtr->nNumStrings;
|
|
if (infoPtr->nNumStrings == 0) {
|
|
infoPtr->strings =
|
|
HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY, sizeof(char *));
|
|
}
|
|
else {
|
|
char **oldStrings = infoPtr->strings;
|
|
infoPtr->strings =
|
|
HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY,
|
|
sizeof(char *) * (infoPtr->nNumStrings + 1));
|
|
memcpy (&infoPtr->strings[0], &oldStrings[0],
|
|
sizeof(char *) * infoPtr->nNumStrings);
|
|
HeapFree (SystemHeap, 0, oldStrings);
|
|
}
|
|
|
|
infoPtr->strings[infoPtr->nNumStrings] =
|
|
HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY, sizeof(char)*(len+1));
|
|
lstrcpy32A (infoPtr->strings[infoPtr->nNumStrings], szString);
|
|
infoPtr->nNumStrings++;
|
|
}
|
|
else {
|
|
char *p = (char*)lParam;
|
|
INT32 len;
|
|
|
|
if (p == NULL) return -1;
|
|
TRACE (toolbar, "adding string(s) from array!\n");
|
|
nIndex = infoPtr->nNumStrings;
|
|
while (*p) {
|
|
len = lstrlen32A (p);
|
|
TRACE (toolbar, "len=%d\n", len);
|
|
|
|
if (infoPtr->nNumStrings == 0) {
|
|
infoPtr->strings =
|
|
HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY, sizeof(char *));
|
|
}
|
|
else {
|
|
char **oldStrings = infoPtr->strings;
|
|
infoPtr->strings =
|
|
HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY,
|
|
sizeof(char *) * (infoPtr->nNumStrings + 1));
|
|
memcpy (&infoPtr->strings[0], &oldStrings[0],
|
|
sizeof(char *) * infoPtr->nNumStrings);
|
|
HeapFree (SystemHeap, 0, oldStrings);
|
|
}
|
|
|
|
infoPtr->strings[infoPtr->nNumStrings] =
|
|
HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY, sizeof(char)*(len+1));
|
|
lstrcpy32A (infoPtr->strings[infoPtr->nNumStrings], p);
|
|
infoPtr->nNumStrings++;
|
|
|
|
p += (len+1);
|
|
}
|
|
|
|
}
|
|
|
|
return nIndex;
|
|
}
|
|
|
|
|
|
// << TOOLBAR_AddString32W >>
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_AutoSize (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
|
|
TRACE (toolbar, "auto size!\n");
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_ButtonCount (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
|
|
return infoPtr->nNumButtons;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_ButtonStructSize (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
|
|
infoPtr->dwStructSize = (DWORD)wParam;
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_ChangeBitmap (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
TBUTTON_INFO *btnPtr;
|
|
HDC32 hdc;
|
|
INT32 nIndex;
|
|
|
|
nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
|
|
if (nIndex == -1)
|
|
return FALSE;
|
|
|
|
btnPtr = &infoPtr->buttons[nIndex];
|
|
btnPtr->iBitmap = LOWORD(lParam);
|
|
|
|
hdc = GetDC32 (wndPtr->hwndSelf);
|
|
TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
|
|
ReleaseDC32 (wndPtr->hwndSelf, hdc);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_CheckButton (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
TBUTTON_INFO *btnPtr;
|
|
HDC32 hdc;
|
|
INT32 nIndex;
|
|
INT32 nOldIndex = -1;
|
|
|
|
nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
|
|
if (nIndex == -1)
|
|
return FALSE;
|
|
|
|
btnPtr = &infoPtr->buttons[nIndex];
|
|
|
|
if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
|
|
return FALSE;
|
|
|
|
if (LOWORD(lParam) == FALSE)
|
|
btnPtr->fsState &= ~TBSTATE_CHECKED;
|
|
else {
|
|
if (btnPtr->fsStyle & TBSTYLE_GROUP) {
|
|
nOldIndex =
|
|
TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
|
|
if (nOldIndex == nIndex)
|
|
return 0;
|
|
if (nOldIndex != -1)
|
|
infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
|
|
}
|
|
btnPtr->fsState |= TBSTATE_CHECKED;
|
|
}
|
|
|
|
hdc = GetDC32 (wndPtr->hwndSelf);
|
|
if (nOldIndex != -1)
|
|
TOOLBAR_DrawButton (wndPtr, &infoPtr->buttons[nOldIndex], hdc);
|
|
TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
|
|
ReleaseDC32 (wndPtr->hwndSelf, hdc);
|
|
|
|
/* FIXME: Send a WM_COMMAND or WM_NOTIFY */
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_CommandToIndex (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
|
|
return TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
|
|
}
|
|
|
|
|
|
// << TOOLBAR_Customize >>
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_DeleteButton (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
INT32 nIndex = (INT32)wParam;
|
|
|
|
if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
|
return FALSE;
|
|
|
|
if (infoPtr->nNumButtons == 1) {
|
|
TRACE (toolbar, " simple delete!\n");
|
|
HeapFree (SystemHeap, 0, infoPtr->buttons);
|
|
infoPtr->buttons = NULL;
|
|
infoPtr->nNumButtons = 0;
|
|
}
|
|
else {
|
|
TBUTTON_INFO *oldButtons = infoPtr->buttons;
|
|
TRACE(toolbar, "complex delete! [nIndex=%d]\n", nIndex);
|
|
|
|
infoPtr->nNumButtons--;
|
|
infoPtr->buttons = HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY,
|
|
sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
|
|
if (nIndex > 0) {
|
|
memcpy (&infoPtr->buttons[0], &oldButtons[0],
|
|
nIndex * sizeof(TBUTTON_INFO));
|
|
}
|
|
|
|
if (nIndex < infoPtr->nNumButtons) {
|
|
memcpy (&infoPtr->buttons[nIndex], &oldButtons[nIndex+1],
|
|
(infoPtr->nNumButtons - nIndex) * sizeof(TBUTTON_INFO));
|
|
}
|
|
|
|
HeapFree (SystemHeap, 0, oldButtons);
|
|
}
|
|
|
|
TOOLBAR_CalcToolbar (wndPtr);
|
|
|
|
InvalidateRect32 (wndPtr->hwndSelf, NULL, TRUE);
|
|
UpdateWindow32 (wndPtr->hwndSelf);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_EnableButton (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
TBUTTON_INFO *btnPtr;
|
|
HDC32 hdc;
|
|
INT32 nIndex;
|
|
|
|
nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
|
|
if (nIndex == -1)
|
|
return FALSE;
|
|
|
|
btnPtr = &infoPtr->buttons[nIndex];
|
|
if (LOWORD(lParam) == FALSE)
|
|
btnPtr->fsState &= ~TBSTATE_ENABLED;
|
|
else
|
|
btnPtr->fsState |= TBSTATE_ENABLED;
|
|
|
|
hdc = GetDC32 (wndPtr->hwndSelf);
|
|
TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
|
|
ReleaseDC32 (wndPtr->hwndSelf, hdc);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
// << TOOLBAR_GetAnchorHighlight >>
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_GetBitmap (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
INT32 nIndex;
|
|
|
|
nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
|
|
if (nIndex == -1)
|
|
return 0;
|
|
|
|
return infoPtr->buttons[nIndex].iBitmap;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_GetBitmapFlags (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
FIXME (toolbar, "stub!\n");
|
|
return 0;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_GetButton (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
|
|
INT32 nIndex = (INT32)wParam;
|
|
TBUTTON_INFO *btnPtr;
|
|
|
|
if (infoPtr == NULL) return FALSE;
|
|
if (lpTbb == NULL) return FALSE;
|
|
|
|
if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
|
return FALSE;
|
|
|
|
btnPtr = &infoPtr->buttons[nIndex];
|
|
lpTbb->iBitmap = btnPtr->iBitmap;
|
|
lpTbb->idCommand = btnPtr->idCommand;
|
|
lpTbb->fsState = btnPtr->fsState;
|
|
lpTbb->fsStyle = btnPtr->fsStyle;
|
|
lpTbb->dwData = btnPtr->dwData;
|
|
lpTbb->iString = btnPtr->iString;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
// << TOOLBAR_GetButtonInfo >>
|
|
// << TOOLBAR_GetButtonSize >>
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_GetButtonText32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
INT32 nIndex, nStringIndex;
|
|
|
|
nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
|
|
if (nIndex == -1)
|
|
return -1;
|
|
|
|
nStringIndex = infoPtr->buttons[nIndex].iString;
|
|
|
|
TRACE (toolbar, "index=%d stringIndex=%d\n", nIndex, nStringIndex);
|
|
|
|
if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
|
|
return -1;
|
|
|
|
if (lParam == 0) return -1;
|
|
|
|
lstrcpy32A ((LPSTR)lParam, (LPSTR)infoPtr->strings[nStringIndex]);
|
|
|
|
return lstrlen32A ((LPSTR)infoPtr->strings[nStringIndex]);
|
|
}
|
|
|
|
|
|
// << TOOLBAR_GetButtonText32W >>
|
|
// << TOOLBAR_GetColorScheme >>
|
|
// << TOOLBAR_GetDisabledImageList >>
|
|
// << TOOLBAR_GetExtendedStyle >>
|
|
// << TOOLBAR_GetHotImageList >>
|
|
// << TOOLBAR_GetHotItem >>
|
|
// << TOOLBAR_GetImageList >>
|
|
// << TOOLBAR_GetInsertMark >>
|
|
// << TOOLBAR_GetInsertMarkColor >>
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_GetItemRect (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
TBUTTON_INFO *btnPtr;
|
|
LPRECT32 lpRect;
|
|
INT32 nIndex;
|
|
|
|
if (infoPtr == NULL) return FALSE;
|
|
nIndex = (INT32)wParam;
|
|
btnPtr = &infoPtr->buttons[nIndex];
|
|
if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
|
return FALSE;
|
|
lpRect = (LPRECT32)lParam;
|
|
if (lpRect == NULL) return FALSE;
|
|
if (btnPtr->fsState & TBSTATE_HIDDEN) return FALSE;
|
|
|
|
lpRect->left = btnPtr->rect.left;
|
|
lpRect->right = btnPtr->rect.right;
|
|
lpRect->bottom = btnPtr->rect.bottom;
|
|
lpRect->top = btnPtr->rect.top;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
// << TOOLBAR_GetMaxSize >>
|
|
// << TOOLBAR_GetObject >>
|
|
// << TOOLBAR_GetPadding >>
|
|
// << TOOLBAR_GetRect >>
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_GetRows (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
|
|
if (wndPtr->dwStyle & TBSTYLE_WRAPABLE)
|
|
return infoPtr->nMaxRows;
|
|
else
|
|
return 1;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_GetState (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
INT32 nIndex;
|
|
|
|
nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
|
|
if (nIndex == -1) return -1;
|
|
|
|
return infoPtr->buttons[nIndex].fsState;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_GetStyle (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
INT32 nIndex;
|
|
|
|
nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
|
|
if (nIndex == -1) return -1;
|
|
|
|
return infoPtr->buttons[nIndex].fsStyle;
|
|
}
|
|
|
|
|
|
// << TOOLBAR_GetTextRows >>
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_GetToolTips (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
|
|
if (infoPtr == NULL) return 0;
|
|
return infoPtr->hwndToolTip;
|
|
}
|
|
|
|
|
|
// << TOOLBAR_GetUnicodeFormat >>
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_HideButton (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
TBUTTON_INFO *btnPtr;
|
|
INT32 nIndex;
|
|
|
|
nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
|
|
if (nIndex == -1)
|
|
return FALSE;
|
|
|
|
btnPtr = &infoPtr->buttons[nIndex];
|
|
if (LOWORD(lParam) == FALSE)
|
|
btnPtr->fsState &= ~TBSTATE_HIDDEN;
|
|
else
|
|
btnPtr->fsState |= TBSTATE_HIDDEN;
|
|
|
|
TOOLBAR_CalcToolbar (wndPtr);
|
|
|
|
InvalidateRect32 (wndPtr->hwndSelf, NULL, TRUE);
|
|
UpdateWindow32 (wndPtr->hwndSelf);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_HitTest (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
return TOOLBAR_InternalHitTest (wndPtr, (LPPOINT32)lParam);
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_Indeterminate (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
TBUTTON_INFO *btnPtr;
|
|
HDC32 hdc;
|
|
INT32 nIndex;
|
|
|
|
nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
|
|
if (nIndex == -1)
|
|
return FALSE;
|
|
|
|
btnPtr = &infoPtr->buttons[nIndex];
|
|
if (LOWORD(lParam) == FALSE)
|
|
btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
|
|
else
|
|
btnPtr->fsState |= TBSTATE_INDETERMINATE;
|
|
|
|
hdc = GetDC32 (wndPtr->hwndSelf);
|
|
TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
|
|
ReleaseDC32 (wndPtr->hwndSelf, hdc);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_InsertButton32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
|
|
INT32 nIndex = (INT32)wParam;
|
|
TBUTTON_INFO *oldButtons;
|
|
HDC32 hdc;
|
|
|
|
if (lpTbb == NULL) return FALSE;
|
|
if (nIndex < 0) return FALSE;
|
|
|
|
TRACE (toolbar, "inserting button index=%d\n", nIndex);
|
|
if (nIndex > infoPtr->nNumButtons) {
|
|
nIndex = infoPtr->nNumButtons;
|
|
TRACE (toolbar, "adjust index=%d\n", nIndex);
|
|
}
|
|
|
|
oldButtons = infoPtr->buttons;
|
|
infoPtr->nNumButtons++;
|
|
infoPtr->buttons = HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY,
|
|
sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
|
|
/* pre insert copy */
|
|
if (nIndex > 0) {
|
|
memcpy (&infoPtr->buttons[0], &oldButtons[0],
|
|
nIndex * sizeof(TBUTTON_INFO));
|
|
}
|
|
|
|
/* insert new button */
|
|
infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
|
|
infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
|
|
infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
|
|
infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
|
|
infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
|
|
infoPtr->buttons[nIndex].iString = lpTbb->iString;
|
|
|
|
/* post insert copy */
|
|
if (nIndex < infoPtr->nNumButtons - 1) {
|
|
memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
|
|
(infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
|
|
}
|
|
|
|
HeapFree (SystemHeap, 0, oldButtons);
|
|
|
|
TOOLBAR_CalcToolbar (wndPtr);
|
|
|
|
hdc = GetDC32 (wndPtr->hwndSelf);
|
|
TOOLBAR_Refresh (wndPtr, hdc);
|
|
ReleaseDC32 (wndPtr->hwndSelf, hdc);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
// << TOOLBAR_InsertButton32W >>
|
|
// << TOOLBAR_InsertMarkHitTest >>
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_IsButtonChecked (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
INT32 nIndex;
|
|
|
|
nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
|
|
if (nIndex == -1)
|
|
return FALSE;
|
|
|
|
return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED);
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_IsButtonEnabled (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
INT32 nIndex;
|
|
|
|
nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
|
|
if (nIndex == -1)
|
|
return FALSE;
|
|
|
|
return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED);
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_IsButtonHidden (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
INT32 nIndex;
|
|
|
|
nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
|
|
if (nIndex == -1)
|
|
return FALSE;
|
|
|
|
return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN);
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_IsButtonHighlighted (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
INT32 nIndex;
|
|
|
|
nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
|
|
if (nIndex == -1)
|
|
return FALSE;
|
|
|
|
return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED);
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_IsButtonIndeterminate (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
INT32 nIndex;
|
|
|
|
nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
|
|
if (nIndex == -1)
|
|
return FALSE;
|
|
|
|
return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE);
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_IsButtonPressed (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
INT32 nIndex;
|
|
|
|
nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
|
|
if (nIndex == -1)
|
|
return FALSE;
|
|
|
|
return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED);
|
|
}
|
|
|
|
|
|
// << TOOLBAR_LoadImages >>
|
|
// << TOOLBAR_MapAccelerator >>
|
|
// << TOOLBAR_MarkButton >>
|
|
// << TOOLBAR_MoveButton >>
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_PressButton (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
TBUTTON_INFO *btnPtr;
|
|
HDC32 hdc;
|
|
INT32 nIndex;
|
|
|
|
nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
|
|
if (nIndex == -1)
|
|
return FALSE;
|
|
|
|
btnPtr = &infoPtr->buttons[nIndex];
|
|
if (LOWORD(lParam) == FALSE)
|
|
btnPtr->fsState &= ~TBSTATE_PRESSED;
|
|
else
|
|
btnPtr->fsState |= TBSTATE_PRESSED;
|
|
|
|
hdc = GetDC32 (wndPtr->hwndSelf);
|
|
TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
|
|
ReleaseDC32 (wndPtr->hwndSelf, hdc);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
// << TOOLBAR_ReplaceBitmap >>
|
|
// << TOOLBAR_SaveRestore >>
|
|
// << TOOLBAR_SetAnchorHighlight >>
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_SetBitmapSize (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
|
|
if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
|
|
return FALSE;
|
|
|
|
infoPtr->nBitmapWidth = (INT32)LOWORD(lParam);
|
|
infoPtr->nBitmapHeight = (INT32)HIWORD(lParam);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
// << TOOLBAR_SetButtonInfo >>
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_SetButtonSize (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
|
|
if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
|
|
return FALSE;
|
|
|
|
infoPtr->nButtonWidth = (INT32)LOWORD(lParam);
|
|
infoPtr->nButtonHeight = (INT32)HIWORD(lParam);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
// << TOOLBAR_SetButtonWidth >>
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_SetCmdId (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
INT32 nIndex = (INT32)wParam;
|
|
|
|
if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
|
|
return FALSE;
|
|
|
|
infoPtr->buttons[nIndex].idCommand = (INT32)lParam;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
// << TOOLBAR_SetColorScheme >>
|
|
// << TOOLBAR_SetDisabledImageList >>
|
|
// << TOOLBAR_SetDrawTextFlags >>
|
|
// << TOOLBAR_SetExtendedStyle >>
|
|
// << TOOLBAR_SetHotImageList >>
|
|
// << TOOLBAR_SetHotItem >>
|
|
// << TOOLBAR_SetImageList >>
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_SetIndent (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
HDC32 hdc;
|
|
|
|
infoPtr->nIndent = (INT32)wParam;
|
|
TOOLBAR_CalcToolbar (wndPtr);
|
|
hdc = GetDC32 (wndPtr->hwndSelf);
|
|
TOOLBAR_Refresh (wndPtr, hdc);
|
|
ReleaseDC32 (wndPtr->hwndSelf, hdc);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
// << TOOLBAR_SetInsertMark >>
|
|
// << TOOLBAR_SetInsertMarkColor >>
|
|
// << TOOLBAR_SetMaxTextRows >>
|
|
// << TOOLBAR_SetPadding >>
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_SetParent (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
HWND32 hwndOldNotify;
|
|
|
|
if (infoPtr == NULL) return 0;
|
|
hwndOldNotify = infoPtr->hwndNotify;
|
|
infoPtr->hwndNotify = (HWND32)wParam;
|
|
|
|
return hwndOldNotify;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_SetRows (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
|
|
FIXME (toolbar, "support multiple rows!\n");
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_SetState (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
TBUTTON_INFO *btnPtr;
|
|
HDC32 hdc;
|
|
INT32 nIndex;
|
|
|
|
nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
|
|
if (nIndex == -1)
|
|
return FALSE;
|
|
|
|
btnPtr = &infoPtr->buttons[nIndex];
|
|
btnPtr->fsState = LOWORD(lParam);
|
|
|
|
hdc = GetDC32 (wndPtr->hwndSelf);
|
|
TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
|
|
ReleaseDC32 (wndPtr->hwndSelf, hdc);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_SetStyle (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
TBUTTON_INFO *btnPtr;
|
|
HDC32 hdc;
|
|
INT32 nIndex;
|
|
|
|
nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
|
|
if (nIndex == -1)
|
|
return FALSE;
|
|
|
|
btnPtr = &infoPtr->buttons[nIndex];
|
|
btnPtr->fsStyle = LOWORD(lParam);
|
|
|
|
hdc = GetDC32 (wndPtr->hwndSelf);
|
|
TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
|
|
ReleaseDC32 (wndPtr->hwndSelf, hdc);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_SetToolTips (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
|
|
if (infoPtr == NULL) return 0;
|
|
infoPtr->hwndToolTip = (HWND32)wParam;
|
|
return 0;
|
|
}
|
|
|
|
|
|
// << TOOLBAR_SetUnicodeFormat >>
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_Create (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr;
|
|
|
|
/* allocate memory for info structure */
|
|
infoPtr = (TOOLBAR_INFO *)HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY,
|
|
sizeof(TOOLBAR_INFO));
|
|
wndPtr->wExtra[0] = (DWORD)infoPtr;
|
|
|
|
if (infoPtr == NULL) {
|
|
ERR (toolbar, "could not allocate info memory!\n");
|
|
return 0;
|
|
}
|
|
|
|
/* initialize info structure */
|
|
infoPtr->nButtonHeight = 22;
|
|
infoPtr->nButtonWidth = 23;
|
|
infoPtr->nButtonTop = 2;
|
|
infoPtr->nBitmapHeight = 15;
|
|
infoPtr->nBitmapWidth = 16;
|
|
|
|
infoPtr->nHeight = infoPtr->nButtonHeight + 6;
|
|
infoPtr->nMaxRows = 1;
|
|
|
|
infoPtr->bCaptured = 0;
|
|
infoPtr->nButtonDown = -1;
|
|
infoPtr->nOldHit = -1;
|
|
|
|
infoPtr->hwndNotify = GetParent32 (wndPtr->hwndSelf);
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_Destroy (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
|
|
/* delete tool tip */
|
|
if (infoPtr->hwndToolTip)
|
|
DestroyWindow32 (infoPtr->hwndToolTip);
|
|
|
|
/* delete button data */
|
|
if (infoPtr->buttons)
|
|
HeapFree (SystemHeap, 0, infoPtr->buttons);
|
|
|
|
/* delete strings */
|
|
if (infoPtr->strings) {
|
|
INT32 i;
|
|
for (i = 0; i < infoPtr->nNumStrings; i++)
|
|
if (infoPtr->strings[i])
|
|
HeapFree (SystemHeap, 0, infoPtr->strings[i]);
|
|
|
|
HeapFree (SystemHeap, 0, infoPtr->strings);
|
|
}
|
|
|
|
/* destroy default image list */
|
|
if (infoPtr->himlDef)
|
|
ImageList_Destroy (infoPtr->himlDef);
|
|
|
|
/* destroy disabled image list */
|
|
if (infoPtr->himlDis)
|
|
ImageList_Destroy (infoPtr->himlDis);
|
|
|
|
/* destroy hot image list */
|
|
if (infoPtr->himlHot)
|
|
ImageList_Destroy (infoPtr->himlHot);
|
|
|
|
/* free toolbar info data */
|
|
HeapFree (SystemHeap, 0, infoPtr);
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_LButtonDblClk (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
TBUTTON_INFO *btnPtr;
|
|
POINT32 pt;
|
|
INT32 nHit;
|
|
HDC32 hdc;
|
|
|
|
pt.x = (INT32)LOWORD(lParam);
|
|
pt.y = (INT32)HIWORD(lParam);
|
|
nHit = TOOLBAR_InternalHitTest (wndPtr, &pt);
|
|
|
|
if (nHit >= 0) {
|
|
btnPtr = &infoPtr->buttons[nHit];
|
|
if (!(btnPtr->fsState & TBSTATE_ENABLED))
|
|
return 0;
|
|
SetCapture32 (wndPtr->hwndSelf);
|
|
infoPtr->bCaptured = TRUE;
|
|
infoPtr->nButtonDown = nHit;
|
|
|
|
btnPtr->fsState |= TBSTATE_PRESSED;
|
|
|
|
hdc = GetDC32 (wndPtr->hwndSelf);
|
|
TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
|
|
ReleaseDC32 (wndPtr->hwndSelf, hdc);
|
|
}
|
|
else if (wndPtr->dwStyle & CCS_ADJUSTABLE) {
|
|
/* customize */
|
|
|
|
FIXME (toolbar, "customization not implemented!\n");
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_LButtonDown (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
TBUTTON_INFO *btnPtr;
|
|
POINT32 pt;
|
|
INT32 nHit;
|
|
HDC32 hdc;
|
|
|
|
pt.x = (INT32)LOWORD(lParam);
|
|
pt.y = (INT32)HIWORD(lParam);
|
|
nHit = TOOLBAR_InternalHitTest (wndPtr, &pt);
|
|
|
|
if (nHit >= 0) {
|
|
btnPtr = &infoPtr->buttons[nHit];
|
|
if (!(btnPtr->fsState & TBSTATE_ENABLED))
|
|
return 0;
|
|
|
|
SetCapture32 (wndPtr->hwndSelf);
|
|
infoPtr->bCaptured = TRUE;
|
|
infoPtr->nButtonDown = nHit;
|
|
infoPtr->nOldHit = nHit;
|
|
|
|
btnPtr->fsState |= TBSTATE_PRESSED;
|
|
|
|
hdc = GetDC32 (wndPtr->hwndSelf);
|
|
TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
|
|
ReleaseDC32 (wndPtr->hwndSelf, hdc);
|
|
}
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_LButtonUp (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
TBUTTON_INFO *btnPtr;
|
|
POINT32 pt;
|
|
INT32 nHit;
|
|
INT32 nOldIndex = -1;
|
|
HDC32 hdc;
|
|
|
|
pt.x = (INT32)LOWORD(lParam);
|
|
pt.y = (INT32)HIWORD(lParam);
|
|
nHit = TOOLBAR_InternalHitTest (wndPtr, &pt);
|
|
|
|
if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) {
|
|
infoPtr->bCaptured = FALSE;
|
|
ReleaseCapture ();
|
|
btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
|
|
btnPtr->fsState &= ~TBSTATE_PRESSED;
|
|
|
|
if (btnPtr->fsStyle & TBSTYLE_CHECK) {
|
|
if (btnPtr->fsStyle & TBSTYLE_GROUP) {
|
|
nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, infoPtr->nButtonDown);
|
|
if (nOldIndex == infoPtr->nButtonDown)
|
|
return 0;
|
|
if (nOldIndex != -1)
|
|
infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
|
|
btnPtr->fsState |= TBSTATE_CHECKED;
|
|
}
|
|
else {
|
|
if (btnPtr->fsState & TBSTATE_CHECKED)
|
|
btnPtr->fsState &= ~TBSTATE_CHECKED;
|
|
else
|
|
btnPtr->fsState |= TBSTATE_CHECKED;
|
|
}
|
|
}
|
|
|
|
infoPtr->nButtonDown = -1;
|
|
infoPtr->nOldHit = -1;
|
|
|
|
hdc = GetDC32 (wndPtr->hwndSelf);
|
|
if (nOldIndex != -1)
|
|
TOOLBAR_DrawButton (wndPtr, &infoPtr->buttons[nOldIndex], hdc);
|
|
TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
|
|
ReleaseDC32 (wndPtr->hwndSelf, hdc);
|
|
|
|
SendMessage32A (GetParent32 (wndPtr->hwndSelf), WM_COMMAND,
|
|
MAKEWPARAM(btnPtr->idCommand, 0),
|
|
(LPARAM)wndPtr->hwndSelf);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_MouseMove (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
TBUTTON_INFO *btnPtr;
|
|
POINT32 pt;
|
|
INT32 nHit;
|
|
HDC32 hdc;
|
|
|
|
pt.x = (INT32)LOWORD(lParam);
|
|
pt.y = (INT32)HIWORD(lParam);
|
|
nHit = TOOLBAR_InternalHitTest (wndPtr, &pt);
|
|
|
|
if (infoPtr->bCaptured) {
|
|
if (infoPtr->nOldHit != nHit) {
|
|
btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
|
|
if (infoPtr->nOldHit == infoPtr->nButtonDown) {
|
|
btnPtr->fsState &= ~TBSTATE_PRESSED;
|
|
hdc = GetDC32 (wndPtr->hwndSelf);
|
|
TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
|
|
ReleaseDC32 (wndPtr->hwndSelf, hdc);
|
|
}
|
|
else if (nHit == infoPtr->nButtonDown) {
|
|
btnPtr->fsState |= TBSTATE_PRESSED;
|
|
hdc = GetDC32 (wndPtr->hwndSelf);
|
|
TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
|
|
ReleaseDC32 (wndPtr->hwndSelf, hdc);
|
|
}
|
|
}
|
|
infoPtr->nOldHit = nHit;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_NCCalcSize (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
RECT32 tmpRect = {0, 0, 0, 0};
|
|
LPRECT32 winRect;
|
|
|
|
// DefWindowProc32A (wndPtr->hwndSelf, WM_NCCALCSIZE, wParam, lParam);
|
|
|
|
winRect = (LPRECT32)lParam;
|
|
|
|
// if (wndPtr->dwStyle & WS_BORDER)
|
|
// InflateRect32 (&tmpRect, 1, 1);
|
|
|
|
if (!(wndPtr->dwStyle & CCS_NODIVIDER)) {
|
|
tmpRect.top -= 2;
|
|
tmpRect.bottom -= 2;
|
|
}
|
|
|
|
winRect->left -= tmpRect.left;
|
|
winRect->top -= tmpRect.top;
|
|
winRect->right -= tmpRect.right;
|
|
winRect->bottom -= tmpRect.bottom;
|
|
|
|
return DefWindowProc32A (wndPtr->hwndSelf, WM_NCCALCSIZE, wParam, lParam);
|
|
// return 0;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_NCPaint (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
HDC32 hdc;
|
|
RECT32 rect;
|
|
HWND32 hwnd = wndPtr->hwndSelf;
|
|
|
|
if ( wndPtr->dwStyle & WS_MINIMIZE ||
|
|
!WIN_IsWindowDrawable( wndPtr, 0 )) return 0; /* Nothing to do */
|
|
|
|
DefWindowProc32A (hwnd, WM_NCPAINT, wParam, lParam);
|
|
|
|
if (!(hdc = GetDCEx32( hwnd, 0, DCX_USESTYLE | DCX_WINDOW ))) return 0;
|
|
|
|
if (ExcludeVisRect( hdc, wndPtr->rectClient.left-wndPtr->rectWindow.left,
|
|
wndPtr->rectClient.top-wndPtr->rectWindow.top,
|
|
wndPtr->rectClient.right-wndPtr->rectWindow.left,
|
|
wndPtr->rectClient.bottom-wndPtr->rectWindow.top )
|
|
== NULLREGION)
|
|
{
|
|
ReleaseDC32( hwnd, hdc );
|
|
return 0;
|
|
}
|
|
|
|
if (!(wndPtr->flags & WIN_MANAGED)) {
|
|
if (!(wndPtr->dwStyle & CCS_NODIVIDER)) {
|
|
rect.left = wndPtr->rectClient.left;
|
|
rect.top = wndPtr->rectClient.top - 2;
|
|
rect.right = wndPtr->rectClient.right;
|
|
|
|
SelectObject32 ( hdc, GetSysColorPen32 (COLOR_3DSHADOW));
|
|
MoveToEx32 (hdc, rect.left, rect.top, NULL);
|
|
LineTo32 (hdc, rect.right, rect.top);
|
|
rect.top++;
|
|
SelectObject32 ( hdc, GetSysColorPen32 (COLOR_3DHILIGHT));
|
|
MoveToEx32 (hdc, rect.left, rect.top, NULL);
|
|
LineTo32 (hdc, rect.right, rect.top);
|
|
}
|
|
|
|
}
|
|
|
|
ReleaseDC32( hwnd, hdc );
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_Paint (WND *wndPtr, WPARAM32 wParam)
|
|
{
|
|
HDC32 hdc;
|
|
PAINTSTRUCT32 ps;
|
|
|
|
hdc = wParam==0 ? BeginPaint32 (wndPtr->hwndSelf, &ps) : (HDC32)wParam;
|
|
TOOLBAR_Refresh (wndPtr, hdc);
|
|
if (!wParam)
|
|
EndPaint32 (wndPtr->hwndSelf, &ps);
|
|
return 0;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
TOOLBAR_Size (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
|
RECT32 parent_rect;
|
|
HWND32 parent;
|
|
INT32 flags;
|
|
|
|
flags = (INT32) wParam;
|
|
|
|
/* FIXME for flags =
|
|
* SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED, SIZE_RESTORED
|
|
*/
|
|
|
|
// if (flags == SIZE_RESTORED) {
|
|
/* width and height don't apply */
|
|
parent = GetParent32 (wndPtr->hwndSelf);
|
|
GetClientRect32(parent, &parent_rect);
|
|
infoPtr->nWidth = parent_rect.right - parent_rect.left;
|
|
TOOLBAR_CalcToolbar (wndPtr);
|
|
MoveWindow32(wndPtr->hwndSelf, parent_rect.left, parent_rect.top, //0, 0,
|
|
infoPtr->nWidth, infoPtr->nHeight, TRUE);
|
|
// }
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LRESULT WINAPI
|
|
ToolbarWindowProc (HWND32 hwnd, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam)
|
|
{
|
|
WND *wndPtr = WIN_FindWndPtr(hwnd);
|
|
|
|
switch (uMsg)
|
|
{
|
|
case TB_ADDBITMAP:
|
|
return TOOLBAR_AddBitmap (wndPtr, wParam, lParam);
|
|
|
|
case TB_ADDBUTTONS32A:
|
|
return TOOLBAR_AddButtons32A (wndPtr, wParam, lParam);
|
|
|
|
// case TB_ADDBUTTONS32W:
|
|
|
|
case TB_ADDSTRING32A:
|
|
return TOOLBAR_AddString32A (wndPtr, wParam, lParam);
|
|
|
|
// case TB_ADDSTRING32W:
|
|
|
|
case TB_AUTOSIZE:
|
|
return TOOLBAR_AutoSize (wndPtr, wParam, lParam);
|
|
|
|
case TB_BUTTONCOUNT:
|
|
return TOOLBAR_ButtonCount (wndPtr, wParam, lParam);
|
|
|
|
case TB_BUTTONSTRUCTSIZE:
|
|
return TOOLBAR_ButtonStructSize (wndPtr, wParam, lParam);
|
|
|
|
case TB_CHANGEBITMAP:
|
|
return TOOLBAR_ChangeBitmap (wndPtr, wParam, lParam);
|
|
|
|
case TB_CHECKBUTTON:
|
|
return TOOLBAR_CheckButton (wndPtr, wParam, lParam);
|
|
|
|
case TB_COMMANDTOINDEX:
|
|
return TOOLBAR_CommandToIndex (wndPtr, wParam, lParam);
|
|
|
|
// case TB_CUSTOMIZE:
|
|
|
|
case TB_DELETEBUTTON:
|
|
return TOOLBAR_DeleteButton (wndPtr, wParam, lParam);
|
|
|
|
case TB_ENABLEBUTTON:
|
|
return TOOLBAR_EnableButton (wndPtr, wParam, lParam);
|
|
|
|
// case TB_GETANCHORHIGHLIGHT: /* 4.71 */
|
|
|
|
case TB_GETBITMAP:
|
|
return TOOLBAR_GetBitmap (wndPtr, wParam, lParam);
|
|
|
|
case TB_GETBITMAPFLAGS:
|
|
return TOOLBAR_GetBitmapFlags (wndPtr, wParam, lParam);
|
|
|
|
case TB_GETBUTTON:
|
|
return TOOLBAR_GetButton (wndPtr, wParam, lParam);
|
|
|
|
// case TB_GETBUTTONINFO: /* 4.71 */
|
|
// case TB_GETBUTTONSIZE: /* 4.70 */
|
|
|
|
case TB_GETBUTTONTEXT32A:
|
|
return TOOLBAR_GetButtonText32A (wndPtr, wParam, lParam);
|
|
|
|
// case TB_GETBUTTONTEXT32W:
|
|
// case TB_GETCOLORSCHEME: /* 4.71 */
|
|
// case TB_GETDISABLEDIMAGELIST: /* 4.70 */
|
|
// case TB_GETEXTENDEDSTYLE: /* 4.71 */
|
|
// case TB_GETHOTIMAGELIST: /* 4.70 */
|
|
// case TB_GETHOTITEM: /* 4.71 */
|
|
// case TB_GETIMAGELIST: /* 4.70 */
|
|
// case TB_GETINSERTMARK: /* 4.71 */
|
|
// case TB_GETINSERTMARKCOLOR: /* 4.71 */
|
|
|
|
case TB_GETITEMRECT:
|
|
return TOOLBAR_GetItemRect (wndPtr, wParam, lParam);
|
|
|
|
// case TB_GETMAXSIZE: /* 4.71 */
|
|
// case TB_GETOBJECT: /* 4.71 */
|
|
// case TB_GETPADDING: /* 4.71 */
|
|
// case TB_GETRECT: /* 4.70 */
|
|
|
|
case TB_GETROWS:
|
|
return TOOLBAR_GetRows (wndPtr, wParam, lParam);
|
|
|
|
case TB_GETSTATE:
|
|
return TOOLBAR_GetState (wndPtr, wParam, lParam);
|
|
|
|
case TB_GETSTYLE:
|
|
return TOOLBAR_GetStyle (wndPtr, wParam, lParam);
|
|
|
|
// case TB_GETTEXTROWS: /* 4.70 */
|
|
|
|
case TB_GETTOOLTIPS:
|
|
return TOOLBAR_GetToolTips (wndPtr, wParam, lParam);
|
|
|
|
// case TB_GETUNICODEFORMAT:
|
|
|
|
case TB_HIDEBUTTON:
|
|
return TOOLBAR_HideButton (wndPtr, wParam, lParam);
|
|
|
|
case TB_HITTEST:
|
|
return TOOLBAR_HitTest (wndPtr, wParam, lParam);
|
|
|
|
case TB_INDETERMINATE:
|
|
return TOOLBAR_Indeterminate (wndPtr, wParam, lParam);
|
|
|
|
case TB_INSERTBUTTON32A:
|
|
return TOOLBAR_InsertButton32A (wndPtr, wParam, lParam);
|
|
|
|
// case TB_INSERTBUTTON32W:
|
|
// case TB_INSERTMARKHITTEST: /* 4.71 */
|
|
|
|
case TB_ISBUTTONCHECKED:
|
|
return TOOLBAR_IsButtonChecked (wndPtr, wParam, lParam);
|
|
|
|
case TB_ISBUTTONENABLED:
|
|
return TOOLBAR_IsButtonEnabled (wndPtr, wParam, lParam);
|
|
|
|
case TB_ISBUTTONHIDDEN:
|
|
return TOOLBAR_IsButtonHidden (wndPtr, wParam, lParam);
|
|
|
|
case TB_ISBUTTONHIGHLIGHTED:
|
|
return TOOLBAR_IsButtonHighlighted (wndPtr, wParam, lParam);
|
|
|
|
case TB_ISBUTTONINDETERMINATE:
|
|
return TOOLBAR_IsButtonIndeterminate (wndPtr, wParam, lParam);
|
|
|
|
case TB_ISBUTTONPRESSED:
|
|
return TOOLBAR_IsButtonPressed (wndPtr, wParam, lParam);
|
|
|
|
// case TB_LOADIMAGES: /* 4.70 */
|
|
// case TB_MAPACCELERATOR32A: /* 4.71 */
|
|
// case TB_MAPACCELERATOR32W: /* 4.71 */
|
|
// case TB_MARKBUTTON: /* 4.71 */
|
|
// case TB_MOVEBUTTON: /* 4.71 */
|
|
|
|
case TB_PRESSBUTTON:
|
|
return TOOLBAR_PressButton (wndPtr, wParam, lParam);
|
|
|
|
// case TB_REPLACEBITMAP:
|
|
// case TB_SAVERESTORE32A:
|
|
// case TB_SAVERESTORE32W:
|
|
// case TB_SETANCHORHIGHLIGHT: /* 4.71 */
|
|
|
|
case TB_SETBITMAPSIZE:
|
|
return TOOLBAR_SetBitmapSize (wndPtr, wParam, lParam);
|
|
|
|
// case TB_SETBUTTONINFO: /* 4.71 */
|
|
|
|
case TB_SETBUTTONSIZE:
|
|
return TOOLBAR_SetButtonSize (wndPtr, wParam, lParam);
|
|
|
|
// case TB_SETBUTTONWIDTH: /* 4.70 */
|
|
|
|
case TB_SETCMDID:
|
|
return TOOLBAR_SetCmdId (wndPtr, wParam, lParam);
|
|
|
|
// case TB_SETCOLORSCHEME: /* 4.71 */
|
|
// case TB_SETDISABLEDIMAGELIST: /* 4.70 */
|
|
// case TB_SETDRAWTEXTFLAGS: /* 4.71 */
|
|
// case TB_SETEXTENDEDSTYLE: /* 4.71 */
|
|
// case TB_SETHOTIMAGELIST: /* 4.70 */
|
|
// case TB_SETHOTITEM: /* 4.71 */
|
|
// case TB_SETIMAGELIST: /* 4.70 */
|
|
|
|
case TB_SETINDENT:
|
|
return TOOLBAR_SetIndent (wndPtr, wParam, lParam);
|
|
|
|
// case TB_SETINSERTMARK: /* 4.71 */
|
|
// case TB_SETINSERTMARKCOLOR: /* 4.71 */
|
|
// case TB_SETMAXTEXTROWS: /* 4.70 */
|
|
// case TB_SETPADDING: /* 4.71 */
|
|
|
|
case TB_SETPARENT:
|
|
return TOOLBAR_SetParent (wndPtr, wParam, lParam);
|
|
|
|
case TB_SETROWS:
|
|
return TOOLBAR_SetRows (wndPtr, wParam, lParam);
|
|
|
|
case TB_SETSTATE:
|
|
return TOOLBAR_SetState (wndPtr, wParam, lParam);
|
|
|
|
case TB_SETSTYLE:
|
|
return TOOLBAR_SetStyle (wndPtr, wParam, lParam);
|
|
|
|
case TB_SETTOOLTIPS:
|
|
return TOOLBAR_SetToolTips (wndPtr, wParam, lParam);
|
|
|
|
// case TB_SETUNICODEFORMAT:
|
|
|
|
case WM_CREATE:
|
|
return TOOLBAR_Create (wndPtr, wParam, lParam);
|
|
|
|
case WM_DESTROY:
|
|
return TOOLBAR_Destroy (wndPtr, wParam, lParam);
|
|
|
|
case WM_LBUTTONDBLCLK:
|
|
return TOOLBAR_LButtonDblClk (wndPtr, wParam, lParam);
|
|
|
|
case WM_LBUTTONDOWN:
|
|
return TOOLBAR_LButtonDown (wndPtr, wParam, lParam);
|
|
|
|
case WM_LBUTTONUP:
|
|
return TOOLBAR_LButtonUp (wndPtr, wParam, lParam);
|
|
|
|
case WM_MOUSEMOVE:
|
|
return TOOLBAR_MouseMove (wndPtr, wParam, lParam);
|
|
|
|
// case WM_NCACTIVATE:
|
|
// return TOOLBAR_NCActivate (wndPtr, wParam, lParam);
|
|
|
|
case WM_NCCALCSIZE:
|
|
return TOOLBAR_NCCalcSize (wndPtr, wParam, lParam);
|
|
|
|
case WM_NCPAINT:
|
|
return TOOLBAR_NCPaint (wndPtr, wParam, lParam);
|
|
|
|
// case WM_NOTIFY:
|
|
|
|
case WM_PAINT:
|
|
return TOOLBAR_Paint (wndPtr, wParam);
|
|
|
|
case WM_SIZE:
|
|
return TOOLBAR_Size (wndPtr, wParam, lParam);
|
|
|
|
// case WM_SYSCOLORCHANGE:
|
|
|
|
// case WM_WININICHANGE:
|
|
|
|
case WM_CHARTOITEM:
|
|
case WM_COMMAND:
|
|
case WM_DRAWITEM:
|
|
case WM_MEASUREITEM:
|
|
case WM_VKEYTOITEM:
|
|
return SendMessage32A (GetParent32 (hwnd), uMsg, wParam, lParam);
|
|
|
|
default:
|
|
if (uMsg >= WM_USER)
|
|
ERR (toolbar, "unknown msg %04x wp=%08x lp=%08lx\n",
|
|
uMsg, wParam, lParam);
|
|
return DefWindowProc32A (hwnd, uMsg, wParam, lParam);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|
|
void
|
|
TOOLBAR_Register (void)
|
|
{
|
|
WNDCLASS32A wndClass;
|
|
|
|
if (GlobalFindAtom32A (TOOLBARCLASSNAME32A)) return;
|
|
|
|
ZeroMemory (&wndClass, sizeof(WNDCLASS32A));
|
|
wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
|
|
wndClass.lpfnWndProc = (WNDPROC32)ToolbarWindowProc;
|
|
wndClass.cbClsExtra = 0;
|
|
wndClass.cbWndExtra = sizeof(TOOLBAR_INFO *);
|
|
wndClass.hCursor = LoadCursor32A (0, IDC_ARROW32A);
|
|
wndClass.hbrBackground = (HBRUSH32)(COLOR_3DFACE + 1);
|
|
wndClass.lpszClassName = TOOLBARCLASSNAME32A;
|
|
|
|
RegisterClass32A (&wndClass);
|
|
}
|
|
|