wine/dlls/comctl32/trackbar.c
Alexandre Julliard d30dfd24d6 Release 980927
Sun Sep 27 14:25:38 1998  Petter Reinholdtsen <pere@td.org.uit.no>

	* [files/drive.c]
	Make sure GetDriveType32A() handles param NULL.  Added some
	doc on function.

Sun Sep 27 14:07:26 1998  Huw D M Davies <daviesh@abacus.physics.ox.ac.uk>

	* [controls/edit.c] [windows/win.c]
	Don't call SetWindowLong() in EDIT_WM_NCREATE.
	Fix SetWindowLong(GWL_[EX]STYLE) to work for 16bit windows. Remove
	UpdateWindow() call. 

Sun Sep 27 13:41:22 1998  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [scheduler/*.c] [server/event.c] [server/mutex.c]
	  [server/semaphore.c]
	Implemented server-side synchronisation objects.

Sun Sep 27 01:13:35 1998  Alex Priem <alexp@sci.kun.nl>

	* [dlls/comctl32/treeview.c] [include/treeview.h] [include/comctl.h]
	Treeview implementation.

	* [dlls/comctl32/trackbar.c] [include/trackbar.h] 
	Trackbar implementation.

Sat Sep 26 20:49:13 1998  Ulrich Weigand <weigand@informatik.uni-erlangen.de>

	* [if1632/thunk.c] [tools/build.c] [win32/kernel32.c]
	Bugfix: several problems with flat thunks fixed.

	* [memory/selector.c]
	Bugfix: IsBad...Ptr16 didn't work for limit_in_pages segments.

	* [scheduler/thread.c]
	Bugfix: CreateThread: Allow id parameter == NULL.

	* [objects/gdiobj.c]
	Bugfix: IsGDIObject: Return correct object type for stock objects.

	* [msdos/dpmi.c]
	Bugfix: fixed typo in INT_DoRealModeInt.

	* [msdos/int21.c]
	Bugfix: int21 READ *must* use WIN16_hread, not _hread16.

	* [if1632/kernel.spec] [if1632/dummy.c] [if1632/thunk.c]
	  [loader/ne/module.c] [scheduler/event.c] [scheduler/synchro.c]
	  [scheduler/thread.c] [win32/kernel32.c] [win32/ordinals.c]
	Added names/stubs for all undocumented KERNEL routines (Win95).
	Added the following undoc. 16-bit equivalents to Win32 routines:
	KERNEL.441-443,449-453,456-462,471-476,479-486,488.
	Added stubs for some other KERNEL routines.

	* [memory/heap.c] [memory/global.c] [include/global.h]
	Implemented Local32... 32-bit local heap routines (KERNEL.208-215, 229).

	* [miscemu/instr.c] [loader/module.c] [include/module.h]
	Implemented __GP fault handling and HasGPHandler (KERNEL.338).

	* [misc/error.c]
	Implemented LogParamErrorRegs (KERNEL.327).

	* [loader/task.c] [include/windows.h]
	Implemented GetCodeInfo (KERNEL.104).

	* [loader/task.c] [scheduler/thread.c] [include/thread.h]
	Implemented [GS]etThreadQueue and [GS]etFastQueue (KERNEL.463/4, 624/5).

	* [if1632/gdi.spec] [objects/dc.c] [objects/dib.c]
	  [objects/bitmap.c] [include/windows.h]
	Bugfix: fixed wrong parameter for CreateDIBSection16.
	Added [GS]etDIBColorTable16, stub for GetBoundsRect16.
	Partially implemented BITMAP_GetObject16 for DIBs.

	* [if1632/gdi.spec] [relay32/gdi32.spec] [objects/palette.c]
	Added some GDI stubs.

	* [if1632/Makefile.in] [if1632/display.spec] [if1632/mouse.spec]
	  [if1632/keyboard.spec] [if1632/builtin.c] [windows/keyboard.c]
	Added some stubs for Win16 drivers: KEYBOARD, MOUSE, DISPLAY.

	* [if1632/wprocs.spec] [msdos/vxd.c]
	Added some stubs for VxDs: VMM, ConfigMG, TimerAPI.

	* [msdos/int2f.c]
	Added some stubs for real-mode network drivers.

Sat Sep 26 18:18:18 1998  Marcus Meissner <marcus@jet.franken.de>

	* [configure.in]
	Merged in some more of the FreeBSD ports/emulators/wine patches. 
	(Maintainer(s) of this port: You can just submit these
	patches to Alexandre directly.)

	 * [loader/pe_image.c]
	Check filesize of image against size derived from header
	to spot truncated executeables without crashing.

	* [files/directory.c]
	Set envvar "COMSPEC". One win32(!!) program crashes without it.

	* [multimedia/mmio.c]
	Added mmioSetInfo32.

	* [include/file.h]
	Return STD_ERROR_HANDLE for AUX and PRT dos handles.

	* [loader/module.c]
	Handle executeables with spaces in their names a bit better in
	CreateProcess.

	* [relay32/msvfw32.spec][if1632/msvideo.spec][multimedia/msvideo.c][include/vfw.h]
	Started on MS Video support (can load Win32 ICMs).

	* [tools/testrun]
	A bit smarter use of ps.

	* [memory/virtual.c]
	Report PAGE_GUARDed pages as PAGE_PROTECTED (AutoCAD LT R17 fails
	without that check (since Win95 doesn't know about PAGE_GUARD)).

Sat Sep 26 15:04:05 1998  Ove Kaaven <ovek@arcticnet.no>

	* [include/miscemu.h] [if1632/builtin.c] [loader/task.c]
	  [miscemu/instr.c] [msdos/dpmi.c] [msdos/int21.c]
	  [msdos/interrupts.c] [windows/user.c]
	INT_[S|G]etHandler was renamed to INT_[S|G]etPMHandler.
	Added handlers to deal with real-mode interrupts; DOS
	programs are now able to hook real-mode interrupts.

	* [loader/dos/module.c] [msdos/dosmem.c] [msdos/int21.c]
	Moved real-mode interrupt table initialization to
	msdos/dosmem.c, and made new V86 tasks get a full copy
	of the existing "system memory" instead of almost empty
	space. Misc fixes.

	* [include/dosexe.h] [loader/dos/module.c] [msdos/dpmi.c]
	  [msdos/int2f.c]
	First shot at letting DOS programs start up DPMI (but DPMI
	is still disabled for DOS programs, for pkunzip's sake).

	* [include/debugger.h] [debugger/break.c] [debugger/dbg.y]
	  [debugger/registers.c] [debugger/memory.c] [debugger/info.c]
	  [loader/dos/dosvm.c]
	First shot at making Wine's debugger work for DOS programs.
	The -debug flag works, as do "nexti" and "stepi".

Sat Sep 26 13:13:13 1998  Juergen Schmied <juergen.schmied@metronet.de>

	* [dlls/shell32/dataobject.c]
	New classes IEnumFORMATETC implemented, IDataObject stubs.
	
	* [dlls/shell32/*.*][relay32/shell32.spec]
	Bugfixes.
	New: ICM_InsertItem(), ILCreateFromPath().
	Implemented: ILCloneFirst().
	Stubs: ILIsEqual(), ILFindChild(), SHLogILFromFSIL(),
	  PathMatchSpec(), PathIsExe().
	Changed: ILGetSize(), _ILIsDesktop(), PathCombine().

	* [include/shlobj.h]
	New SHLGUID's
	New structures: DVTARGETDEVICE32, STGMEDIUM32, FORMATETC32,
	CLIPFORMAT32.
	New interfaces: IEnumFORMATETC, IDataObject, ICommDlgBrowser
	IDockingWindowFrame, IServiceProvider.

	* [dlls/shell32/folders.c]
	Stubs for IShellLink.

	* [loader/resource.c]
	Small fixes.

	* [misc/crtdll.c][relay32/crtdll.spec]
	New __dllonexit().

	* [windows/message.c]
	SendNotifyMessageA, SendMessageCallBack32A half implemented.

	* [controls/edit.c]
	EDIT_WM_SetText set EF_UPDATE flag not for ES_MULTILINE.

	* [files/file.c]
	Handling of fileposition fixed.

Fri Sep 25 18:13:30 1998  Patrik Stridvall <ps@leissner.se>

	* [include/windows.h] [include/wintypes.h]
	  [ole/ole2nls.h] [relay32/kernel32.spec]
	Implemented EnumDateFormats and EnumTimeFormats.
	Only adds US English support.

	* [Makefile.in] [configure.in] 
	  [dlls/Makefile.in] [dlls/psapi/Makefile.in] 
	  [dlls/psapi/psapi_main.c] 
	New files to implement stubs for PSAPI.DLL (NT only).

	* [relay32/Makefile.in] [relay32/builtin32.c] 
	  [relay32/psapi.spec]
	New spec file for PSAPI.DLL (NT only).

	* [scheduler/handle.c]
	HANDLE_GetObjPtr should only interpret the pseudo handles as the
	current thread or the current process if a thread or a process is
	requested.

	* [include/winversion.h] [misc/version.c]
	Adds the global function VERSION_GetVersion() so functions can
	have different behavior depending on the -winver flag.

	* [include/oledlg.h] [ole/oledlg.c]
	Minor fixes. 

	* [windows/winproc.c]
	Minor changes.

	* [include/imm.h] [misc/imm.c]
	Now returns correct values under both Windows 95 and NT 4.0.

Thu Sep 24 22:11:44 1998  Kristian Nielsen  <kristian.nielsen@risoe.dk>

	* [configure.in] [include/acconfig.h] [include/thread.h]
	  [scheduler/sysdeps.c]
	Autoconfig test for non-reentrant libc.

Wed Sep 23 19:52:12 1998  Matthew Becker <mbecker@glasscity.net>

	* [*/*.c]
	Miscellaneous documentation updates and debugging output 
	standardizations.

	* [objects/clipping.c]
	Added ExtSelectClipRgn.

Wed Sep 23 00:03:28 EDT 1998  Pete Ratzlaff <pratzlaff@cfa.harvard.edu>

	* [include/windows.h] [if1632/user.spec] [relay32/user32.spec]
	  [windows/keyboard.c]
	Added, marginally implemented, GetKeyboardLayoutName().
	Only returns US English keyboard name.

Tue Sep 22 16:32:41 1998  Marcel Baur <mbaur@iiic.ethz.ch>

	* [programs/control/*]
	New Winelib application.

Mon Sep 21 00:29:18 1998  Peter Hunnisett <hunnise@nortel.ca>

	* [include/dplay.h][multimedia/dplay.c][ole/compobj.c]
	Added all DirectPlayLobby interfaces and enhanced DirectPlay
	and DirectPlayLobby support. Still not all that much. Useful
	enough if you just need to start a program, don't try any
	real dplay/lobby stuff.

	* [documentation/status/directplay]
	Added a very little bit.

	* [graphics/ddraw.c]
	- Call to SetWindowLong32A wasn't working because there was no
	  memory set aside when the window class was registered.
	- Fixed some xlib reference counting and change the behaviour
	  of DirectDrawSurface3_SetPalette to mimic observed behaviour
	  (palette is associated will all backbuffers)
	- Also stored all palette colour fields and spit back our saved
	  colour fields rather than query X for them.
	- Added plenty of AddRef and Release traces.
	- Added Xlib support for using -desktop option.
	- Fixed Xlib message handling. Messages weren't being passed to
	  the application. Fixes mouse movements in some xlib DDraw games.
	- Added a few stubs.

	* [windows/win.c][include/winerror.h]
	Fixed up some error handling in WIN_SetWindowLong. SetLastError
	wasn't being used. Could cause problems with 0 return codes.
	Added new error in winerror (1400).

	* [AUTHORS] [include/authors.h]
	Added myself as a Wine author.

Sun Sep 20 21:22:44 1998  Alexander Larsson  <alla@lysator.liu.se>

	* [loader/module.c]
	Changed GetModuleFileName32A so that is returns the
	long version of the filename. Note that just the name
	is long, not the directories.

Sat Sep 19 20:05:30 1998 Per Ångström <pang@mind.nu> 

	* [controls/menu.c]
	Made a couple of fixes to make life easier for applications that alter
	their menus at runtime.

	* [windows/defdlg.c]
	Removed the cast of the return value from dialog procedures to a 16-bit
	bool. The return value needs to retain all its 32 bits, since it is not 
	always a bool, such as when responding to the WM_NCHITTEST message.

Fri Sep 18 11:30:38 1998  Sergey Turchanov <turchanov@usa.net>

	* [loader/resource.c]
	Fixed very funny bug (though gravely affecting further excecution)
	with FindResource[Ex]32 functions.

	* [include/multimon.h] [windows/multimon.c] [relay32/user32.spec]
	  [include/windows.h] [windows/sysmetrics.c]
	Default implementation for Multimonitor API.

	* [include/windows.h] [windows/winpos.c]
	Fixed incorrect declaration (and behaviour) of GetWindowRect32.

Wed Sep 16 10:21:15 1998  Gerard Patel <G.Patel@Wanadoo.fr>

	* [controls/edit.c]
	Fixed EDIT_EM_GetLine to use correctly length of lines.

Tue Sep 15 20:40:16 1998  Eric Kohl <ekohl@abo.rhein-zeitung.de>

	* [misc/tweak.c][include/tweak.h][controls/menu.c]
	Replaced the tweak graphic routines by calls to DrawEdge32().

	* [misc/tweak.c][include/tweak.h][documentation/win95look]
	  [wine.ini][*/*]
	Changed "look and feel" selection. Allows Win3.1, Win95 and
	Win98 (no GUI code implemented) look and feel.

	* [dlls/comctl32/header.c][include/header.h][include/commctrl.h]
	Started callback item support and did some minor improvements.

	* [dlls/comctl32/imagelist.c]
	Fixed bug in transparent image display.
	ImageList_GetIcon is still buggy :-(

	* [dlls/comctl32/toolbar.c]
	Fixed button drawing (partial hack).

	* [dlls/comctl32/commctrl.c]
	Fixed MenuHelp().

	* [controls/button.c]
	Added 3d effect for groupbox.

	* [windows/msgbox.c]
	Added font support for message boxes.

	* [windows/nonclient.c]
	Fixed window moving bug.

	* [dlls/comctl32/*.c]
	Various improvements.

	* [dlls/comctl32/listview.c][dlls/comctl32/rebar.c]
	  [include/commctrl.h]
	More messages.

	* [windows/syscolor.c][include/windows.h]
	Introduced new Win98 system colors.

Tue Sep 15 18:29:45 1998 Wesley Filardo <eightknots@aol.com>

	* [files/profile.c]
	Added support in PROFILE_LoadWineIni for -config option

	* [misc/main.c] [include/options.h]
	Added -config option.

Tue Sep 15 18:22:26 1998  Petter Reinholdtsen <pere@td.org.uit.no>

	* [documentation/Makefile.in]
	Make sure directory exists before installing into it.

Tue Sep 15 01:47:33 1998  Pablo Saratxaga <pablo.sarachaga@ping.be>

	* [ole/nls/*] [ole/ole2nls.c] [include/winnls.h]
	Fixed a few errors and completed some NLS files.

Mon Sep 14 01:23:45 1998  Joseph Pranevich <knight@baltimore.wwaves.com>

	* [include/miscemu.h] [msdos/interrupts.c]
	Removed a compilation warning, added INT 25 to the list of interrupts
	callable from DOS applications, added a debug message when unsupported
	interrupts are used.

Sun Sep 13 19:55:22 1998  Lawson Whitney <lawson_whitney@juno.com>

	* [if1632/relay.c]
	CallProcEx32W should not reverse arguments.

Sun Aug 17 21:18:12 1998  Eric Pouech  <eric.pouech@lemel.fr>

	* [multimedia/midi.c] [multimedia/init.c] [multimedia/mmsys.c] 
	  [include/multimedia.h] [include/mmsystem.h] 
	  [multimedia/Makefile.in] [multimedia/midipatch.c]
	  [if1632/multimedia.spec]
	Made MIDI input and output functional on OSS capable systems.

	* [multimedia/timer.c]
	Changes to trigger callbacks at the accurate pace even when
	fake timers are used.
1998-09-27 18:28:36 +00:00

1412 lines
33 KiB
C

/*
* Trackbar control
*
* Copyright 1998 Eric Kohli <ekohl@abo.rhein-zeitung.de>
* Copyright 1998 Alex Priem <alexp@sci.kun.nl>
*
* NOTES
*
* TODO:
* - Some messages.
* - more display code.
* - dragging slider
* - better tic handling.
* - more notifications.
* - tooltips
*/
/* known bugs:
-TBM_SETRANGEMAX & TBM_SETRANGEMIN should only change the view of the
trackbar, not the actual amount of tics in the list.
-TBM_GETTIC & TBM_GETTICPOS shouldn't rely on infoPtr->tics being sorted.
-code currently only handles horizontal trackbars correct.
*/
#include "windows.h"
#include "commctrl.h"
#include "trackbar.h"
#include "heap.h"
#include "win.h"
#include "debug.h"
#define TRACKBAR_GetInfoPtr(wndPtr) ((TRACKBAR_INFO *)wndPtr->wExtra[0])
/* Used by TRACKBAR_Refresh to find out which parts of the control
need to be recalculated */
#define TB_THUMBCHANGED 1
#define TB_SELECTIONCHANGED 2
static BOOL32 TRACKBAR_SendNotify (WND *wndPtr, UINT32 code);
void TRACKBAR_RecalculateTics (TRACKBAR_INFO *infoPtr)
{
int i,tic,nrTics;
if (infoPtr->uTicFreq)
nrTics=(infoPtr->nRangeMax - infoPtr->nRangeMin)/infoPtr->uTicFreq;
else {
nrTics=0;
HeapFree (SystemHeap,0,infoPtr->tics);
infoPtr->tics=NULL;
infoPtr->uNumTics=0;
return;
}
if (nrTics!=infoPtr->uNumTics) {
infoPtr->tics=HeapReAlloc( SystemHeap, 0, infoPtr->tics,
(nrTics+1)*sizeof (DWORD));
infoPtr->uNumTics=nrTics;
}
infoPtr->uNumTics=nrTics;
tic=infoPtr->nRangeMin+infoPtr->uTicFreq;
for (i=0; i<nrTics; i++,tic+=infoPtr->uTicFreq)
infoPtr->tics[i]=tic;
}
static INT32
TRACKBAR_ConvertPositionToTic (WND *wndPtr, TRACKBAR_INFO *infoPtr, POINT32 pt)
{
double newpos,newtic;
int i,range,width,delta,currentdelta,currenttic;
/* buggy */
range=infoPtr->nRangeMax - infoPtr->nRangeMin;
width=infoPtr->rcChannel.right - infoPtr->rcChannel.left;
newpos=(pt.x-infoPtr->rcChannel.left) / (double) width;
newtic=infoPtr->nRangeMin+newpos*range;
currenttic=0;
currentdelta=currenttic-infoPtr->nRangeMin;
for (i=0; i<infoPtr->uNumTics; i++) {
delta=newtic-infoPtr->tics[i];
if ((delta>0) && (delta<currentdelta)) {
currentdelta=delta;
currenttic=i;
}
}
return (INT32) currenttic;
}
static VOID
TRACKBAR_Calc (WND *wndPtr, TRACKBAR_INFO *infoPtr)
{
INT32 cyChannel;
RECT32 lpRect,*channel = & infoPtr->rcChannel;
GetClientRect32 (wndPtr->hwndSelf, &lpRect);
if (wndPtr->dwStyle & TBS_ENABLESELRANGE)
cyChannel = MAX(infoPtr->uThumbLen - 8, 4);
else
cyChannel = 4;
/* calculate channel rect */
if (wndPtr->dwStyle & TBS_VERT) {
channel->top = lpRect.top + 8;
channel->bottom = lpRect.bottom - 8;
if (wndPtr->dwStyle & TBS_BOTH) {
channel->left = (lpRect.bottom - cyChannel) / 2;
channel->right = (lpRect.bottom + cyChannel) / 2;
}
else if (wndPtr->dwStyle & TBS_LEFT) {
channel->left = lpRect.left + 10;
channel->right = channel->left + cyChannel;
}
else { /* TBS_RIGHT */
channel->right = lpRect.right - 10;
channel->left = channel->right - cyChannel;
}
}
else {
channel->left = lpRect.left + 8;
channel->right = lpRect.right - 8;
if (wndPtr->dwStyle & TBS_BOTH) {
channel->top = (lpRect.bottom - cyChannel) / 2;
channel->bottom = (lpRect.bottom + cyChannel) / 2;
}
else if (wndPtr->dwStyle & TBS_TOP) {
channel->top = lpRect.top + 10;
channel->bottom = channel->top + cyChannel;
}
else { /* TBS_BOTTOM */
channel->bottom = lpRect.bottom - 10;
channel->top = channel->bottom - cyChannel;
}
}
}
static VOID
TRACKBAR_CalcThumb (WND *wndPtr, TRACKBAR_INFO *infoPtr)
{
RECT32 *thumb;
int range, width;
thumb=&infoPtr->rcThumb;
range=infoPtr->nRangeMax - infoPtr->nRangeMin;
width=infoPtr->rcChannel.right - infoPtr->rcChannel.left;
thumb->left = infoPtr->rcChannel.left +
width*(65536*infoPtr->nPos/range)/65536 - 5;
thumb->right = thumb->left + 10;
thumb->top = infoPtr->rcChannel.top - 1;
thumb->bottom = infoPtr->rcChannel.top + infoPtr->uThumbLen - 8;
}
static VOID
TRACKBAR_CalcSelection (WND *wndPtr, TRACKBAR_INFO *infoPtr)
{
RECT32 *selection;
int range, width;
selection= & infoPtr->rcSelection;
range=infoPtr->nRangeMax - infoPtr->nRangeMin;
width=infoPtr->rcChannel.right - infoPtr->rcChannel.left;
selection->left = infoPtr->rcChannel.left +
width*(65536*infoPtr->nSelMin/range)/65536;
selection->right = infoPtr->rcChannel.left +
width*(65536*infoPtr->nSelMax/range)/65536;
selection->top = infoPtr->rcChannel.top + 2;
selection->bottom = infoPtr->rcChannel.bottom - 2;
}
static VOID
TRACKBAR_Refresh (WND *wndPtr, HDC32 hdc)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
RECT32 rcClient, rcChannel, rcSelection;
HBRUSH32 hBrush = CreateSolidBrush32 (infoPtr->clrBk);
INT32 x,y,tic;
int i,range,width;
GetClientRect32 (wndPtr->hwndSelf, &rcClient);
hBrush = CreateSolidBrush32 (infoPtr->clrBk);
FillRect32 (hdc, &rcClient, hBrush);
DeleteObject32 (hBrush);
if (infoPtr->flags & TB_THUMBCHANGED)
TRACKBAR_CalcThumb (wndPtr, infoPtr);
if (infoPtr->flags & TB_SELECTIONCHANGED)
TRACKBAR_CalcSelection (wndPtr, infoPtr);
infoPtr->flags &= ~ (TB_THUMBCHANGED | TB_SELECTIONCHANGED);
/* draw channel */
rcChannel = infoPtr->rcChannel;
rcSelection= infoPtr->rcSelection;
DrawEdge32 (hdc, &rcChannel, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
if (wndPtr->dwStyle & TBS_ENABLESELRANGE) { /* fill the channel */
HBRUSH32 hbr = CreateSolidBrush32 (RGB(255,255,255));
FillRect32 (hdc, &rcChannel, hbr);
if (rcSelection.left!=rcSelection.right) {
hbr=CreateSolidBrush32 (COLOR_HIGHLIGHT);
FillRect32 (hdc, &rcSelection, hbr);
}
DeleteObject32 (hbr);
}
/* draw tics */
if (!(wndPtr->dwStyle & TBS_NOTICKS)) {
COLORREF clrTic=GetSysColor32 (COLOR_3DDKSHADOW);
x=rcChannel.left;
y=rcChannel.bottom+2;
range=infoPtr->nRangeMax - infoPtr->nRangeMin;
width=rcChannel.right - rcChannel.left;
if (wndPtr->dwStyle & TBS_VERT) { /* swap x/y */
}
if ((wndPtr->dwStyle & TBS_TOP) || (wndPtr->dwStyle & TBS_BOTH)) {
/* draw upper tics */
}
// if (!((wndPtr->dwStyle & TBS_TOP) || (!(wndPtr->dwStyle & TBS_BOTH))))
/* draw lower tics */
// if (wndPtr->dwStyle & TBS_AUTOTICKS)
for (i=0; i<infoPtr->uNumTics; i++) {
tic=infoPtr->tics[i];
if ((tic>infoPtr->nRangeMin) && (tic<infoPtr->nRangeMax)) {
x=rcChannel.left + width*(65536*tic/range)/65536;
SetPixel32 (hdc, x,y+5, clrTic);
SetPixel32 (hdc, x,y+6, clrTic);
SetPixel32 (hdc, x,y+7, clrTic);
}
}
if ((wndPtr->dwStyle & TBS_ENABLESELRANGE) &&
(rcSelection.left!=rcSelection.right)) {
x=rcChannel.left + width*(65536*infoPtr->nSelMin/range)/65536 - 1;
SetPixel32 (hdc, x,y+6, clrTic);
SetPixel32 (hdc, x,y+7, clrTic);
x=rcChannel.left + width*(65536*infoPtr->nSelMax/range)/65536 + 1;
SetPixel32 (hdc, x,y+6, clrTic);
SetPixel32 (hdc, x,y+7, clrTic);
}
x=rcChannel.left;
SetPixel32 (hdc, x,y+5, clrTic);
SetPixel32 (hdc, x,y+6, clrTic);
SetPixel32 (hdc, x,y+7, clrTic);
SetPixel32 (hdc, x,y+8, clrTic);
x=rcChannel.right;
SetPixel32 (hdc, x,y+5, clrTic);
SetPixel32 (hdc, x,y+6, clrTic);
SetPixel32 (hdc, x,y+7, clrTic);
SetPixel32 (hdc, x,y+8, clrTic);
// }
}
/* draw thumb */
if (!(wndPtr->dwStyle & TBS_NOTHUMB)) {
HBRUSH32 hbr = CreateSolidBrush32 (COLOR_BACKGROUND);
RECT32 thumb = infoPtr->rcThumb;
SelectObject32 (hdc, hbr);
if (wndPtr->dwStyle & TBS_BOTH) {
FillRect32 (hdc, &thumb, hbr);
DrawEdge32 (hdc, &thumb, EDGE_RAISED, BF_TOPLEFT);
} else {
POINT32 points[6];
RECT32 triangle; /* for correct shadows of thumb */
/* first, fill the thumb */
SetPolyFillMode32 (hdc,WINDING);
points[0].x=thumb.left;
points[0].y=thumb.top;
points[1].x=thumb.right - 1;
points[1].y=thumb.top;
points[2].x=thumb.right - 1;
points[2].y=thumb.bottom -2;
points[3].x=(thumb.right + thumb.left-1)/2;
points[3].y=thumb.bottom+4;
points[4].x=thumb.left;
points[4].y=thumb.bottom -2;
points[5].x=points[0].x;
points[5].y=points[0].y;
Polygon32 (hdc, points, 6);
DrawEdge32 (hdc, &thumb, EDGE_RAISED, BF_TOPLEFT);
// DrawEdge32 (hdc, &thumb, EDGE_SUNKEN, BF_BOTTOMRIGHT);
/* draw notch */
triangle.right = thumb.right+5;
triangle.left = points[3].x+5;
triangle.top = thumb.bottom +5;
triangle.bottom= thumb.bottom +1;
DrawEdge32 (hdc, &triangle, EDGE_SUNKEN, BF_DIAGONAL | BF_TOP | BF_RIGHT);
triangle.left = thumb.left+6;
triangle.right = points[3].x+6;
DrawEdge32 (hdc, &triangle, EDGE_RAISED, BF_DIAGONAL | BF_TOP | BF_LEFT);
}
DeleteObject32 (hbr);
}
if (infoPtr->bFocus)
DrawFocusRect32 (hdc, &rcClient);
}
static VOID
TRACKBAR_AlignBuddies (WND *wndPtr, TRACKBAR_INFO *infoPtr)
{
HWND32 hwndParent = GetParent32 (wndPtr->hwndSelf);
RECT32 rcSelf, rcBuddy;
INT32 x, y;
GetWindowRect32 (wndPtr->hwndSelf, &rcSelf);
MapWindowPoints32 (HWND_DESKTOP, hwndParent, (LPPOINT32)&rcSelf, 2);
/* align buddy left or above */
if (infoPtr->hwndBuddyLA) {
GetWindowRect32 (infoPtr->hwndBuddyLA, &rcBuddy);
MapWindowPoints32 (HWND_DESKTOP, hwndParent, (LPPOINT32)&rcBuddy, 2);
if (wndPtr->dwStyle & TBS_VERT) {
x = (infoPtr->rcChannel.right + infoPtr->rcChannel.left) / 2 -
(rcBuddy.right - rcBuddy.left) / 2 + rcSelf.left;
y = rcSelf.top - (rcBuddy.bottom - rcBuddy.top);
}
else {
x = rcSelf.left - (rcBuddy.right - rcBuddy.left);
y = (infoPtr->rcChannel.bottom + infoPtr->rcChannel.top) / 2 -
(rcBuddy.bottom - rcBuddy.top) / 2 + rcSelf.top;
}
SetWindowPos32 (infoPtr->hwndBuddyLA, 0, x, y, 0, 0,
SWP_NOZORDER | SWP_NOSIZE);
}
/* align buddy right or below */
if (infoPtr->hwndBuddyRB) {
GetWindowRect32 (infoPtr->hwndBuddyRB, &rcBuddy);
MapWindowPoints32 (HWND_DESKTOP, hwndParent, (LPPOINT32)&rcBuddy, 2);
if (wndPtr->dwStyle & TBS_VERT) {
x = (infoPtr->rcChannel.right + infoPtr->rcChannel.left) / 2 -
(rcBuddy.right - rcBuddy.left) / 2 + rcSelf.left;
y = rcSelf.bottom;
}
else {
x = rcSelf.right;
y = (infoPtr->rcChannel.bottom + infoPtr->rcChannel.top) / 2 -
(rcBuddy.bottom - rcBuddy.top) / 2 + rcSelf.top;
}
SetWindowPos32 (infoPtr->hwndBuddyRB, 0, x, y, 0, 0,
SWP_NOZORDER | SWP_NOSIZE);
}
}
static LRESULT
TRACKBAR_ClearSel (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
infoPtr->nSelMin = 0;
infoPtr->nSelMax = 0;
infoPtr->flags |=TB_SELECTIONCHANGED;
if ((BOOL32)wParam) {
HDC32 hdc = GetDC32 (wndPtr->hwndSelf);
TRACKBAR_Refresh (wndPtr, hdc);
ReleaseDC32 (wndPtr->hwndSelf, hdc);
}
return 0;
}
static LRESULT
TRACKBAR_ClearTics (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
if (infoPtr->tics) {
HeapFree (GetProcessHeap (), 0, infoPtr->tics);
infoPtr->tics = NULL;
infoPtr->uNumTics = 0;
}
if (wParam) {
HDC32 hdc = GetDC32 (wndPtr->hwndSelf);
TRACKBAR_Refresh (wndPtr, hdc);
ReleaseDC32 (wndPtr->hwndSelf, hdc);
}
return 0;
}
static LRESULT
TRACKBAR_GetBuddy (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
if (wParam) /* buddy is left or above */
return (LRESULT)infoPtr->hwndBuddyLA;
/* buddy is right or below */
return (LRESULT) infoPtr->hwndBuddyRB;
}
static LRESULT
TRACKBAR_GetChannelRect (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
LPRECT32 lprc = (LPRECT32)lParam;
if (lprc == NULL)
return 0;
lprc->left = infoPtr->rcChannel.left;
lprc->right = infoPtr->rcChannel.right;
lprc->bottom = infoPtr->rcChannel.bottom;
lprc->top = infoPtr->rcChannel.top;
return 0;
}
static LRESULT
TRACKBAR_GetLineSize (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
return infoPtr->nLineSize;
}
static LRESULT
TRACKBAR_GetNumTics (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
if (wndPtr->dwStyle & TBS_NOTICKS)
return 0;
return infoPtr->uNumTics+2;
}
static LRESULT
TRACKBAR_GetPageSize (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
return infoPtr->nPageSize;
}
static LRESULT
TRACKBAR_GetPos (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
return infoPtr->nPos;
}
static LRESULT
TRACKBAR_GetRangeMax (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
return infoPtr->nRangeMax;
}
static LRESULT
TRACKBAR_GetRangeMin (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
return infoPtr->nRangeMin;
}
static LRESULT
TRACKBAR_GetSelEnd (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
return infoPtr->nSelMax;
}
static LRESULT
TRACKBAR_GetSelStart (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
return infoPtr->nSelMin;
}
static LRESULT
TRACKBAR_GetThumbLength (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
return infoPtr->uThumbLen;
}
static LRESULT
TRACKBAR_GetPTics (WND *wndPtr)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
return (LRESULT) infoPtr->tics;
}
static LRESULT
TRACKBAR_GetThumbRect (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
LPRECT32 lprc = (LPRECT32)lParam;
if (lprc == NULL)
return 0;
lprc->left = infoPtr->rcThumb.left;
lprc->right = infoPtr->rcThumb.right;
lprc->bottom = infoPtr->rcThumb.bottom;
lprc->top = infoPtr->rcThumb.top;
return 0;
}
static LRESULT
TRACKBAR_GetTic (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
INT32 iTic;
iTic=(INT32) wParam;
if ((iTic<0) || (iTic>infoPtr->uNumTics))
return -1;
return (LRESULT) infoPtr->tics[iTic];
}
static LRESULT
TRACKBAR_GetTicPos (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
INT32 iTic, range, width, pos;
iTic=(INT32 ) wParam;
if ((iTic<0) || (iTic>infoPtr->uNumTics))
return -1;
range=infoPtr->nRangeMax - infoPtr->nRangeMin;
width=infoPtr->rcChannel.right - infoPtr->rcChannel.left;
pos=infoPtr->rcChannel.left + width*(65536*infoPtr->tics[iTic]/range)/65536;
return (LRESULT) pos;
}
static LRESULT
TRACKBAR_GetToolTips (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
if (wndPtr->dwStyle & TBS_TOOLTIPS)
return (LRESULT)infoPtr->hwndToolTip;
return 0;
}
// case TBM_GETUNICODEFORMAT:
static LRESULT
TRACKBAR_SetBuddy (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
HWND32 hwndTemp;
if (wParam) {
/* buddy is left or above */
hwndTemp = infoPtr->hwndBuddyLA;
infoPtr->hwndBuddyLA = (HWND32)lParam;
FIXME (trackbar, "move buddy!\n");
}
else {
/* buddy is right or below */
hwndTemp = infoPtr->hwndBuddyRB;
infoPtr->hwndBuddyRB = (HWND32)lParam;
FIXME (trackbar, "move buddy!\n");
}
TRACKBAR_AlignBuddies (wndPtr, infoPtr);
return (LRESULT)hwndTemp;
}
static LRESULT
TRACKBAR_SetLineSize (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
INT32 nTemp = infoPtr->nLineSize;
infoPtr->nLineSize = (INT32)lParam;
return nTemp;
}
static LRESULT
TRACKBAR_SetPageSize (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
INT32 nTemp = infoPtr->nPageSize;
infoPtr->nPageSize = (INT32)lParam;
return nTemp;
}
static LRESULT
TRACKBAR_SetPos (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
infoPtr->nPos = (INT32)HIWORD(lParam);
if (infoPtr->nPos < infoPtr->nRangeMin)
infoPtr->nPos = infoPtr->nRangeMin;
if (infoPtr->nPos > infoPtr->nRangeMax)
infoPtr->nPos = infoPtr->nRangeMax;
infoPtr->flags |=TB_THUMBCHANGED;
if (wParam) {
HDC32 hdc = GetDC32 (wndPtr->hwndSelf);
TRACKBAR_Refresh (wndPtr, hdc);
ReleaseDC32 (wndPtr->hwndSelf, hdc);
}
return 0;
}
static LRESULT
TRACKBAR_SetRange (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
infoPtr->nRangeMin = (INT32)LOWORD(lParam);
infoPtr->nRangeMax = (INT32)HIWORD(lParam);
if (infoPtr->nPos < infoPtr->nRangeMin) {
infoPtr->nPos = infoPtr->nRangeMin;
infoPtr->flags |=TB_THUMBCHANGED;
}
if (infoPtr->nPos > infoPtr->nRangeMax) {
infoPtr->nPos = infoPtr->nRangeMax;
infoPtr->flags |=TB_THUMBCHANGED;
}
infoPtr->nPageSize=(infoPtr->nRangeMax - infoPtr->nRangeMin)/5;
TRACKBAR_RecalculateTics (infoPtr);
if (wParam) {
HDC32 hdc = GetDC32 (wndPtr->hwndSelf);
TRACKBAR_Refresh (wndPtr, hdc);
ReleaseDC32 (wndPtr->hwndSelf, hdc);
}
return 0;
}
static LRESULT
TRACKBAR_SetRangeMax (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
infoPtr->nRangeMax = (INT32)lParam;
if (infoPtr->nPos > infoPtr->nRangeMax) {
infoPtr->nPos = infoPtr->nRangeMax;
infoPtr->flags |=TB_THUMBCHANGED;
}
infoPtr->nPageSize=(infoPtr->nRangeMax - infoPtr->nRangeMin)/5;
TRACKBAR_RecalculateTics (infoPtr);
if (wParam) {
HDC32 hdc = GetDC32 (wndPtr->hwndSelf);
TRACKBAR_Refresh (wndPtr, hdc);
ReleaseDC32 (wndPtr->hwndSelf, hdc);
}
return 0;
}
static LRESULT
TRACKBAR_SetRangeMin (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
infoPtr->nRangeMin = (INT32)lParam;
if (infoPtr->nPos < infoPtr->nRangeMin) {
infoPtr->nPos = infoPtr->nRangeMin;
infoPtr->flags |=TB_THUMBCHANGED;
}
infoPtr->nPageSize=(infoPtr->nRangeMax - infoPtr->nRangeMin)/5;
TRACKBAR_RecalculateTics (infoPtr);
if (wParam) {
HDC32 hdc = GetDC32 (wndPtr->hwndSelf);
TRACKBAR_Refresh (wndPtr, hdc);
ReleaseDC32 (wndPtr->hwndSelf, hdc);
}
return 0;
}
static LRESULT
TRACKBAR_SetTicFreq (WND *wndPtr, WPARAM32 wParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
HDC32 hdc;
if (wndPtr->dwStyle & TBS_AUTOTICKS)
infoPtr->uTicFreq=(UINT32) wParam;
TRACKBAR_RecalculateTics (infoPtr);
hdc = GetDC32 (wndPtr->hwndSelf);
TRACKBAR_Refresh (wndPtr, hdc);
ReleaseDC32 (wndPtr->hwndSelf, hdc);
return 0;
}
static LRESULT
TRACKBAR_SetSel (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
infoPtr->nSelMin = (INT32)LOWORD(lParam);
infoPtr->nSelMax = (INT32)HIWORD(lParam);
infoPtr->flags |=TB_SELECTIONCHANGED;
if (!wndPtr->dwStyle & TBS_ENABLESELRANGE)
return 0;
if (infoPtr->nSelMin < infoPtr->nRangeMin)
infoPtr->nSelMin = infoPtr->nRangeMin;
if (infoPtr->nSelMax > infoPtr->nRangeMax)
infoPtr->nSelMax = infoPtr->nRangeMax;
if (wParam) {
HDC32 hdc = GetDC32 (wndPtr->hwndSelf);
TRACKBAR_Refresh (wndPtr, hdc);
ReleaseDC32 (wndPtr->hwndSelf, hdc);
}
return 0;
}
static LRESULT
TRACKBAR_SetSelEnd (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
if (!wndPtr->dwStyle & TBS_ENABLESELRANGE)
return 0;
infoPtr->nSelMax = (INT32)lParam;
infoPtr->flags |=TB_SELECTIONCHANGED;
if (infoPtr->nSelMax > infoPtr->nRangeMax)
infoPtr->nSelMax = infoPtr->nRangeMax;
if (wParam) {
HDC32 hdc = GetDC32 (wndPtr->hwndSelf);
TRACKBAR_Refresh (wndPtr, hdc);
ReleaseDC32 (wndPtr->hwndSelf, hdc);
}
return 0;
}
static LRESULT
TRACKBAR_SetSelStart (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
if (!wndPtr->dwStyle & TBS_ENABLESELRANGE)
return 0;
infoPtr->nSelMin = (INT32)lParam;
infoPtr->flags |=TB_SELECTIONCHANGED;
if (infoPtr->nSelMin < infoPtr->nRangeMin)
infoPtr->nSelMin = infoPtr->nRangeMin;
if (wParam) {
HDC32 hdc = GetDC32 (wndPtr->hwndSelf);
TRACKBAR_Refresh (wndPtr, hdc);
ReleaseDC32 (wndPtr->hwndSelf, hdc);
}
return 0;
}
static LRESULT
TRACKBAR_SetThumbLength (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
HDC32 hdc;
if (wndPtr->dwStyle & TBS_FIXEDLENGTH)
infoPtr->uThumbLen = (UINT32)wParam;
hdc = GetDC32 (wndPtr->hwndSelf);
infoPtr->flags |=TB_THUMBCHANGED;
TRACKBAR_Refresh (wndPtr, hdc);
ReleaseDC32 (wndPtr->hwndSelf, hdc);
return 0;
}
static LRESULT
TRACKBAR_SetTic (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
INT32 nPos = (INT32)lParam;
HDC32 hdc;
if ((nPos < infoPtr->nRangeMin) || (nPos> infoPtr->nRangeMax))
return FALSE;
infoPtr->uNumTics++;
infoPtr->tics=HeapReAlloc( SystemHeap, 0, infoPtr->tics,
(infoPtr->uNumTics)*sizeof (DWORD));
infoPtr->tics[infoPtr->uNumTics-1]=nPos;
hdc = GetDC32 (wndPtr->hwndSelf);
TRACKBAR_Refresh (wndPtr, hdc);
ReleaseDC32 (wndPtr->hwndSelf, hdc);
return TRUE;
}
static LRESULT
TRACKBAR_SetTipSide (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
INT32 fTemp = infoPtr->fLocation;
infoPtr->fLocation = (INT32)wParam;
return fTemp;
}
static LRESULT
TRACKBAR_SetToolTips (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
infoPtr->hwndToolTip = (HWND32)wParam;
return 0;
}
// case TBM_SETUNICODEFORMAT:
static LRESULT
TRACKBAR_InitializeThumb (WND *wndPtr)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
infoPtr->uThumbLen = 23; /* initial thumb length */
TRACKBAR_Calc (wndPtr,infoPtr);
TRACKBAR_CalcThumb (wndPtr, infoPtr);
infoPtr->flags &= ~TB_SELECTIONCHANGED;
return 0;
}
static LRESULT
TRACKBAR_Create (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr;
infoPtr = (TRACKBAR_INFO *)HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
sizeof(TRACKBAR_INFO));
wndPtr->wExtra[0] = (DWORD)infoPtr;
infoPtr->nRangeMin = 0; /* default values */
infoPtr->nRangeMax = 100;
infoPtr->nLineSize = 1;
infoPtr->nPageSize = 20;
infoPtr->nSelMin = 0;
infoPtr->nSelMax = 0;
infoPtr->nPos = 0;
infoPtr->uNumTics = 0; /* start and end tic are not included in count*/
infoPtr->uTicFreq = 1;
infoPtr->tics = NULL;
infoPtr->clrBk = GetSysColor32 (COLOR_BACKGROUND);
TRACKBAR_InitializeThumb (wndPtr);
return 0;
}
static LRESULT
TRACKBAR_Destroy (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
HeapFree (GetProcessHeap (), 0, infoPtr);
return 0;
}
static LRESULT
TRACKBAR_KillFocus (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
HDC32 hdc;
infoPtr->bFocus = FALSE;
hdc = GetDC32 (wndPtr->hwndSelf);
TRACKBAR_Refresh (wndPtr, hdc);
ReleaseDC32 (wndPtr->hwndSelf, hdc);
InvalidateRect32 (wndPtr->hwndSelf, NULL, TRUE);
return 0;
}
static LRESULT
TRACKBAR_LButtonDown (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
int prevPlace,range,width,clickPlace,prevPos;
SetFocus32 (wndPtr->hwndSelf);
clickPlace=(INT32)LOWORD(lParam);
range=infoPtr->nRangeMax - infoPtr->nRangeMin;
width=infoPtr->rcChannel.right - infoPtr->rcChannel.left;
prevPlace = infoPtr->rcChannel.left +
width*(65536*infoPtr->nPos/range)/65536;
printf ("%d->%d\n",prevPlace,clickPlace);
prevPos = infoPtr->nPos;
if (clickPlace > prevPlace) { /* similar to VK_NEXT */
infoPtr->nPos += infoPtr->nPageSize;
if (infoPtr->nPos > infoPtr->nRangeMax)
infoPtr->nPos = infoPtr->nRangeMax;
TRACKBAR_SendNotify (wndPtr, TB_PAGEUP);
} else {
infoPtr->nPos -= infoPtr->nPageSize; /* similar to VK_PRIOR */
if (infoPtr->nPos < infoPtr->nRangeMin)
infoPtr->nPos = infoPtr->nRangeMin;
TRACKBAR_SendNotify (wndPtr, TB_PAGEDOWN);
}
printf ("%d->%d\n",prevPos,infoPtr->nPos);
if (prevPos!=infoPtr->nPos) {
HDC32 hdc;
hdc=GetDC32 (wndPtr->hwndSelf);
infoPtr->flags |=TB_THUMBCHANGED;
TRACKBAR_Refresh (wndPtr, hdc);
ReleaseDC32 (wndPtr->hwndSelf, hdc);
}
return 0;
}
static LRESULT
TRACKBAR_LButtonUp (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
FIXME (trackbar,"stub\n");
TRACKBAR_SendNotify (wndPtr, TB_ENDTRACK);
return 0;
}
static LRESULT
TRACKBAR_CaptureChanged (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
FIXME (trackbar,"stub\n");
TRACKBAR_SendNotify (wndPtr, TB_ENDTRACK);
return 0;
}
static LRESULT
TRACKBAR_Paint (WND *wndPtr, WPARAM32 wParam)
{
HDC32 hdc;
PAINTSTRUCT32 ps;
hdc = wParam==0 ? BeginPaint32 (wndPtr->hwndSelf, &ps) : (HDC32)wParam;
TRACKBAR_Refresh (wndPtr, hdc);
if(!wParam)
EndPaint32 (wndPtr->hwndSelf, &ps);
return 0;
}
static LRESULT
TRACKBAR_SetFocus (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
HDC32 hdc;
infoPtr->bFocus = TRUE;
hdc = GetDC32 (wndPtr->hwndSelf);
TRACKBAR_Refresh (wndPtr, hdc);
ReleaseDC32 (wndPtr->hwndSelf, hdc);
return 0;
}
static LRESULT
TRACKBAR_Size (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
TRACKBAR_Calc (wndPtr, infoPtr);
TRACKBAR_AlignBuddies (wndPtr, infoPtr);
return 0;
}
// << TRACKBAR_Timer >>
static BOOL32
TRACKBAR_SendNotify (WND *wndPtr, UINT32 code)
{
TRACE (trackbar, "%x\n",code);
if (wndPtr->dwStyle & TBS_VERT)
return (BOOL32) SendMessage32A (GetParent32 (wndPtr->hwndSelf),
WM_VSCROLL, (WPARAM32)code, (LPARAM) wndPtr->hwndSelf);
return (BOOL32) SendMessage32A (GetParent32 (wndPtr->hwndSelf),
WM_HSCROLL, (WPARAM32)code, (LPARAM) wndPtr->hwndSelf);
}
static LRESULT
TRACKBAR_MouseMove (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
return TRUE;
}
static LRESULT
TRACKBAR_KeyDown (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
INT32 pos;
TRACE (trackbar, "%x\n",wParam);
pos=infoPtr->nPos;
switch (wParam) {
case VK_LEFT:
case VK_UP:
if (infoPtr->nPos == infoPtr->nRangeMin) return FALSE;
infoPtr->nPos -= infoPtr->nLineSize;
if (infoPtr->nPos < infoPtr->nRangeMin)
infoPtr->nPos = infoPtr->nRangeMin;
TRACKBAR_SendNotify (wndPtr, TB_LINEUP);
break;
case VK_RIGHT:
case VK_DOWN:
if (infoPtr->nPos == infoPtr->nRangeMax) return FALSE;
infoPtr->nPos += infoPtr->nLineSize;
if (infoPtr->nPos > infoPtr->nRangeMax)
infoPtr->nPos = infoPtr->nRangeMax;
TRACKBAR_SendNotify (wndPtr, TB_LINEDOWN);
break;
case VK_NEXT:
if (infoPtr->nPos == infoPtr->nRangeMax) return FALSE;
infoPtr->nPos += infoPtr->nPageSize;
if (infoPtr->nPos > infoPtr->nRangeMax)
infoPtr->nPos = infoPtr->nRangeMax;
TRACKBAR_SendNotify (wndPtr, TB_PAGEUP);
break;
case VK_PRIOR:
if (infoPtr->nPos == infoPtr->nRangeMin) return FALSE;
infoPtr->nPos -= infoPtr->nPageSize;
if (infoPtr->nPos < infoPtr->nRangeMin)
infoPtr->nPos = infoPtr->nRangeMin;
TRACKBAR_SendNotify (wndPtr, TB_PAGEDOWN);
break;
case VK_HOME:
if (infoPtr->nPos == infoPtr->nRangeMin) return FALSE;
infoPtr->nPos = infoPtr->nRangeMin;
TRACKBAR_SendNotify (wndPtr, TB_TOP);
break;
case VK_END:
if (infoPtr->nPos == infoPtr->nRangeMax) return FALSE;
infoPtr->nPos = infoPtr->nRangeMax;
TRACKBAR_SendNotify (wndPtr, TB_BOTTOM);
break;
}
if (pos!=infoPtr->nPos) {
HDC32 hdc;
hdc=GetDC32 (wndPtr->hwndSelf);
infoPtr->flags |=TB_THUMBCHANGED;
TRACKBAR_Refresh (wndPtr, hdc);
ReleaseDC32 (wndPtr->hwndSelf, hdc);
}
return TRUE;
}
static LRESULT
TRACKBAR_KeyUp (WND *wndPtr, WPARAM32 wParam)
{
switch (wParam) {
case VK_LEFT:
case VK_UP:
case VK_RIGHT:
case VK_DOWN:
case VK_NEXT:
case VK_PRIOR:
case VK_HOME:
case VK_END: TRACKBAR_SendNotify (wndPtr, TB_ENDTRACK);
}
return TRUE;
}
LRESULT WINAPI
TRACKBAR_WindowProc (HWND32 hwnd, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam)
{
WND *wndPtr = WIN_FindWndPtr(hwnd);
switch (uMsg)
{
case TBM_CLEARSEL:
return TRACKBAR_ClearSel (wndPtr, wParam, lParam);
case TBM_CLEARTICS:
return TRACKBAR_ClearTics (wndPtr, wParam, lParam);
case TBM_GETBUDDY:
return TRACKBAR_GetBuddy (wndPtr, wParam, lParam);
case TBM_GETCHANNELRECT:
return TRACKBAR_GetChannelRect (wndPtr, wParam, lParam);
case TBM_GETLINESIZE:
return TRACKBAR_GetLineSize (wndPtr, wParam, lParam);
case TBM_GETNUMTICS:
return TRACKBAR_GetNumTics (wndPtr, wParam, lParam);
case TBM_GETPAGESIZE:
return TRACKBAR_GetPageSize (wndPtr, wParam, lParam);
case TBM_GETPOS:
return TRACKBAR_GetPos (wndPtr, wParam, lParam);
case TBM_GETPTICS:
return TRACKBAR_GetPTics (wndPtr);
case TBM_GETRANGEMAX:
return TRACKBAR_GetRangeMax (wndPtr, wParam, lParam);
case TBM_GETRANGEMIN:
return TRACKBAR_GetRangeMin (wndPtr, wParam, lParam);
case TBM_GETSELEND:
return TRACKBAR_GetSelEnd (wndPtr, wParam, lParam);
case TBM_GETSELSTART:
return TRACKBAR_GetSelStart (wndPtr, wParam, lParam);
case TBM_GETTHUMBLENGTH:
return TRACKBAR_GetThumbLength (wndPtr, wParam, lParam);
case TBM_GETTHUMBRECT:
return TRACKBAR_GetThumbRect (wndPtr, wParam, lParam);
case TBM_GETTIC:
return TRACKBAR_GetTic (wndPtr, wParam, lParam);
case TBM_GETTICPOS:
return TRACKBAR_GetTicPos (wndPtr, wParam, lParam);
case TBM_GETTOOLTIPS:
return TRACKBAR_GetToolTips (wndPtr, wParam, lParam);
// case TBM_GETUNICODEFORMAT:
case TBM_SETBUDDY:
return TRACKBAR_SetBuddy (wndPtr, wParam, lParam);
case TBM_SETLINESIZE:
return TRACKBAR_SetLineSize (wndPtr, wParam, lParam);
case TBM_SETPAGESIZE:
return TRACKBAR_SetPageSize (wndPtr, wParam, lParam);
case TBM_SETPOS:
return TRACKBAR_SetPos (wndPtr, wParam, lParam);
case TBM_SETRANGE:
return TRACKBAR_SetRange (wndPtr, wParam, lParam);
case TBM_SETRANGEMAX:
return TRACKBAR_SetRangeMax (wndPtr, wParam, lParam);
case TBM_SETRANGEMIN:
return TRACKBAR_SetRangeMin (wndPtr, wParam, lParam);
case TBM_SETSEL:
return TRACKBAR_SetSel (wndPtr, wParam, lParam);
case TBM_SETSELEND:
return TRACKBAR_SetSelEnd (wndPtr, wParam, lParam);
case TBM_SETSELSTART:
return TRACKBAR_SetSelStart (wndPtr, wParam, lParam);
case TBM_SETTHUMBLENGTH:
return TRACKBAR_SetThumbLength (wndPtr, wParam, lParam);
case TBM_SETTIC:
return TRACKBAR_SetTic (wndPtr, wParam, lParam);
case TBM_SETTICFREQ:
return TRACKBAR_SetTicFreq (wndPtr, wParam);
case TBM_SETTIPSIDE:
return TRACKBAR_SetTipSide (wndPtr, wParam, lParam);
case TBM_SETTOOLTIPS:
return TRACKBAR_SetToolTips (wndPtr, wParam, lParam);
// case TBM_SETUNICODEFORMAT:
case WM_CAPTURECHANGED:
return TRACKBAR_CaptureChanged (wndPtr, wParam, lParam);
case WM_CREATE:
return TRACKBAR_Create (wndPtr, wParam, lParam);
case WM_DESTROY:
return TRACKBAR_Destroy (wndPtr, wParam, lParam);
// case WM_ENABLE:
// case WM_ERASEBKGND:
// return 0;
case WM_GETDLGCODE:
return DLGC_WANTARROWS;
case WM_KEYDOWN:
return TRACKBAR_KeyDown (wndPtr, wParam, lParam);
case WM_KEYUP:
return TRACKBAR_KeyUp (wndPtr, wParam);
case WM_KILLFOCUS:
return TRACKBAR_KillFocus (wndPtr, wParam, lParam);
case WM_LBUTTONDOWN:
return TRACKBAR_LButtonDown (wndPtr, wParam, lParam);
case WM_LBUTTONUP:
return TRACKBAR_LButtonUp (wndPtr, wParam, lParam);
case WM_MOUSEMOVE:
return TRACKBAR_MouseMove (wndPtr, wParam, lParam);
case WM_PAINT:
return TRACKBAR_Paint (wndPtr, wParam);
case WM_SETFOCUS:
return TRACKBAR_SetFocus (wndPtr, wParam, lParam);
case WM_SIZE:
return TRACKBAR_Size (wndPtr, wParam, lParam);
// case WM_TIMER:
case WM_WININICHANGE:
return TRACKBAR_InitializeThumb (wndPtr);
default:
if (uMsg >= WM_USER)
ERR (trackbar, "unknown msg %04x wp=%08x lp=%08lx\n",
uMsg, wParam, lParam);
return DefWindowProc32A (hwnd, uMsg, wParam, lParam);
}
return 0;
}
void
TRACKBAR_Register (void)
{
WNDCLASS32A wndClass;
if (GlobalFindAtom32A (TRACKBAR_CLASS32A)) return;
ZeroMemory (&wndClass, sizeof(WNDCLASS32A));
wndClass.style = CS_GLOBALCLASS;
wndClass.lpfnWndProc = (WNDPROC32)TRACKBAR_WindowProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = sizeof(TRACKBAR_INFO *);
wndClass.hCursor = LoadCursor32A (0, IDC_ARROW32A);
wndClass.hbrBackground = (HBRUSH32)(COLOR_3DFACE + 1);
wndClass.lpszClassName = TRACKBAR_CLASS32A;
RegisterClass32A (&wndClass);
}