Commit 506115b8 authored by Alex Priem's avatar Alex Priem Committed by Alexandre Julliard

- Tooltip support

- Vertical trackbars supported now - TBS_BOTH support (goes along with partial cleanup of drawing code) - Use COMCTL32 heap instead of system heap
parent 2d37e9b8
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
* Copyright 1998 Eric Kohl <ekohl@abo.rhein-zeitung.de> * Copyright 1998 Eric Kohl <ekohl@abo.rhein-zeitung.de>
* Copyright 1998 Alex Priem <alexp@sci.kun.nl> * Copyright 1998 Alex Priem <alexp@sci.kun.nl>
* *
* NOTES
* *
* TODO: * TODO:
* - Some messages. * - Some messages.
...@@ -21,8 +19,7 @@ ...@@ -21,8 +19,7 @@
-TBM_SETRANGEMAX & TBM_SETRANGEMIN should only change the view of the -TBM_SETRANGEMAX & TBM_SETRANGEMIN should only change the view of the
trackbar, not the actual amount of tics in the list. trackbar, not the actual amount of tics in the list.
-TBM_GETTIC & TBM_GETTICPOS shouldn't rely on infoPtr->tics being sorted. -TBM_GETTIC & TBM_GETTICPOS shouldn't rely on infoPtr->tics being sorted.
-code currently only handles horizontal trackbars correct. - Make drawing code exact match of w95 drawing.
-TB_DRAGTIMER behaves wierd.
*/ */
...@@ -41,14 +38,25 @@ ...@@ -41,14 +38,25 @@
/* Used by TRACKBAR_Refresh to find out which parts of the control /* Used by TRACKBAR_Refresh to find out which parts of the control
need to be recalculated */ need to be recalculated */
#define TB_THUMBPOSCHANGED 1 #define TB_THUMBPOSCHANGED 1
#define TB_THUMBSIZECHANGED 2 #define TB_THUMBSIZECHANGED 2
#define TB_THUMBCHANGED 3 #define TB_THUMBCHANGED (TB_THUMBPOSCHANGED | TB_THUMBPOSCHANGED)
#define TB_SELECTIONCHANGED 4 #define TB_SELECTIONCHANGED 4
#define TB_DRAG_TIMER_SET 16
#define TB_DRAGPOSVALID 32 #define TB_DRAG_MODE 16 /* we're dragging the slider */
#define TB_DRAGPOSVALID 32 /* current Position is in dragPos */
#define TB_SHOW_TOOLTIP 64 /* tooltip-style enabled and tooltip on */
#define TB_REFRESH_TIMER_SET 128 /* is a TRACBKAR_Refresh queued?*/
/* helper defines for TRACKBAR_DrawTic */
#define TIC_LEFTEDGE 0x20
#define TIC_RIGHTEDGE 0x40
#define TIC_EDGE (TIC_LEFTEDGE | TIC_RIGHTEDGE)
#define TIC_SELECTIONMARKMAX 0x80
#define TIC_SELECTIONMARKMIN 0x100
#define TIC_SELECTIONMARK (TIC_SELECTIONMARKMAX | TIC_SELECTIONMARKMIN)
static BOOL32 TRACKBAR_SendNotify (WND *wndPtr, UINT32 code); static BOOL32 TRACKBAR_SendNotify (WND *wndPtr, UINT32 code);
void TRACKBAR_RecalculateTics (TRACKBAR_INFO *infoPtr) void TRACKBAR_RecalculateTics (TRACKBAR_INFO *infoPtr)
...@@ -67,8 +75,7 @@ void TRACKBAR_RecalculateTics (TRACKBAR_INFO *infoPtr) ...@@ -67,8 +75,7 @@ void TRACKBAR_RecalculateTics (TRACKBAR_INFO *infoPtr)
} }
if (nrTics!=infoPtr->uNumTics) { if (nrTics!=infoPtr->uNumTics) {
infoPtr->tics=HeapReAlloc( SystemHeap, 0, infoPtr->tics, infoPtr->tics=COMCTL32_ReAlloc (infoPtr->tics, (nrTics+1)*sizeof (DWORD));
(nrTics+1)*sizeof (DWORD));
infoPtr->uNumTics=nrTics; infoPtr->uNumTics=nrTics;
} }
infoPtr->uNumTics=nrTics; infoPtr->uNumTics=nrTics;
...@@ -82,13 +89,19 @@ void TRACKBAR_RecalculateTics (TRACKBAR_INFO *infoPtr) ...@@ -82,13 +89,19 @@ void TRACKBAR_RecalculateTics (TRACKBAR_INFO *infoPtr)
(in range of trackbar) */ (in range of trackbar) */
static inline INT32 static inline INT32
TRACKBAR_ConvertPlaceToPosition (TRACKBAR_INFO *infoPtr, int place) TRACKBAR_ConvertPlaceToPosition (TRACKBAR_INFO *infoPtr, int place,
int vertical)
{ {
double range,width,pos; double range,width,pos;
range=infoPtr->nRangeMax - infoPtr->nRangeMin; range=infoPtr->nRangeMax - infoPtr->nRangeMin;
width=infoPtr->rcChannel.right - infoPtr->rcChannel.left; if (vertical) {
pos=(range*(place - infoPtr->rcChannel.left)) / width; width=infoPtr->rcChannel.bottom - infoPtr->rcChannel.top;
pos=(range*(place - infoPtr->rcChannel.top)) / width;
} else {
width=infoPtr->rcChannel.right - infoPtr->rcChannel.left;
pos=(range*(place - infoPtr->rcChannel.left)) / width;
}
TRACE (trackbar,"%.2f\n",pos); TRACE (trackbar,"%.2f\n",pos);
return pos; return pos;
...@@ -114,8 +127,8 @@ TRACKBAR_CalcChannel (WND *wndPtr, TRACKBAR_INFO *infoPtr) ...@@ -114,8 +127,8 @@ TRACKBAR_CalcChannel (WND *wndPtr, TRACKBAR_INFO *infoPtr)
channel->bottom = lpRect.bottom - 8; channel->bottom = lpRect.bottom - 8;
if (wndPtr->dwStyle & TBS_BOTH) { if (wndPtr->dwStyle & TBS_BOTH) {
channel->left = (lpRect.bottom - cyChannel) / 2; channel->left = (lpRect.right - cyChannel) / 2;
channel->right = (lpRect.bottom + cyChannel) / 2; channel->right = (lpRect.right + cyChannel) / 2;
} }
else if (wndPtr->dwStyle & TBS_LEFT) { else if (wndPtr->dwStyle & TBS_LEFT) {
channel->left = lpRect.left + 10; channel->left = lpRect.left + 10;
...@@ -153,13 +166,22 @@ TRACKBAR_CalcThumb (WND *wndPtr, TRACKBAR_INFO *infoPtr) ...@@ -153,13 +166,22 @@ TRACKBAR_CalcThumb (WND *wndPtr, TRACKBAR_INFO *infoPtr)
thumb=&infoPtr->rcThumb; thumb=&infoPtr->rcThumb;
range=infoPtr->nRangeMax - infoPtr->nRangeMin; range=infoPtr->nRangeMax - infoPtr->nRangeMin;
width=infoPtr->rcChannel.right - infoPtr->rcChannel.left; if (wndPtr->dwStyle & TBS_VERT) {
width=infoPtr->rcChannel.bottom - infoPtr->rcChannel.top;
thumb->left = infoPtr->rcChannel.left - 1;
thumb->right = infoPtr->rcChannel.left + infoPtr->uThumbLen - 8;
thumb->top = infoPtr->rcChannel.top +
(width*infoPtr->nPos)/range - 5;
thumb->bottom = thumb->top + infoPtr->uThumbLen/3;
thumb->left = infoPtr->rcChannel.left + } else {
(width*infoPtr->nPos)/range - 5; width=infoPtr->rcChannel.right - infoPtr->rcChannel.left;
thumb->right = thumb->left + infoPtr->uThumbLen/3; thumb->left = infoPtr->rcChannel.left +
thumb->top = infoPtr->rcChannel.top - 1; (width*infoPtr->nPos)/range - 5;
thumb->bottom = infoPtr->rcChannel.top + infoPtr->uThumbLen - 8; thumb->right = thumb->left + infoPtr->uThumbLen/3;
thumb->top = infoPtr->rcChannel.top - 1;
thumb->bottom = infoPtr->rcChannel.top + infoPtr->uThumbLen - 8;
}
} }
static VOID static VOID
...@@ -172,35 +194,200 @@ TRACKBAR_CalcSelection (WND *wndPtr, TRACKBAR_INFO *infoPtr) ...@@ -172,35 +194,200 @@ TRACKBAR_CalcSelection (WND *wndPtr, TRACKBAR_INFO *infoPtr)
range=infoPtr->nRangeMax - infoPtr->nRangeMin; range=infoPtr->nRangeMax - infoPtr->nRangeMin;
width=infoPtr->rcChannel.right - infoPtr->rcChannel.left; width=infoPtr->rcChannel.right - infoPtr->rcChannel.left;
if (range > 0) { if (range <= 0)
selection->left = infoPtr->rcChannel.left +
(width*infoPtr->nSelMin)/range;
selection->right = infoPtr->rcChannel.left +
(width*infoPtr->nSelMax)/range;
selection->top = infoPtr->rcChannel.top + 2;
selection->bottom = infoPtr->rcChannel.bottom - 2;
}
else
SetRectEmpty32 (selection); SetRectEmpty32 (selection);
else
if (wndPtr->dwStyle & TBS_VERT) {
selection->left = infoPtr->rcChannel.left +
(width*infoPtr->nSelMin)/range;
selection->right = infoPtr->rcChannel.left +
(width*infoPtr->nSelMax)/range;
selection->top = infoPtr->rcChannel.top + 2;
selection->bottom = infoPtr->rcChannel.bottom - 2;
} else {
selection->top = infoPtr->rcChannel.top +
(width*infoPtr->nSelMin)/range;
selection->bottom = infoPtr->rcChannel.top +
(width*infoPtr->nSelMax)/range;
selection->left = infoPtr->rcChannel.left + 2;
selection->right = infoPtr->rcChannel.right - 2;
}
}
static void
TRACKBAR_QueueRefresh (WND *wndPtr)
{
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
TRACE (trackbar,"queued\n");
if (infoPtr->flags & TB_REFRESH_TIMER_SET) {
KillTimer32 (wndPtr->hwndSelf, TB_REFRESH_TIMER);
}
SetTimer32 (wndPtr->hwndSelf, TB_REFRESH_TIMER, TB_REFRESH_DELAY, 0);
infoPtr->flags|=TB_REFRESH_TIMER_SET;
} }
/* Trackbar drawing code. I like my spaghetti done milanese. */
/* ticPos is in tic-units, not in pixels */
static VOID
TRACKBAR_DrawHorizTic (TRACKBAR_INFO *infoPtr, HDC32 hdc, LONG ticPos,
int flags, COLORREF clrTic)
{
RECT32 rcChannel=infoPtr->rcChannel;
int x,y,width,range,side;
range=infoPtr->nRangeMax - infoPtr->nRangeMin;
width=rcChannel.right - rcChannel.left;
if (flags & TBS_TOP) {
y=rcChannel.top-2;
side=-1;
} else {
y=rcChannel.bottom+2;
side=1;
}
if (flags & TIC_SELECTIONMARK) {
if (flags & TIC_SELECTIONMARKMIN)
x=rcChannel.left + (width*ticPos)/range - 1;
else
x=rcChannel.left + (width*ticPos)/range + 1;
SetPixel32 (hdc, x,y+6*side, clrTic);
SetPixel32 (hdc, x,y+7*side, clrTic);
return;
}
if ((ticPos>infoPtr->nRangeMin) && (ticPos<infoPtr->nRangeMax)) {
x=rcChannel.left + (width*ticPos)/range;
SetPixel32 (hdc, x,y+5*side, clrTic);
SetPixel32 (hdc, x,y+6*side, clrTic);
SetPixel32 (hdc, x,y+7*side, clrTic);
}
if (flags & TIC_EDGE) {
if (flags & TIC_LEFTEDGE)
x=rcChannel.left;
else
x=rcChannel.right;
SetPixel32 (hdc, x,y+5*side, clrTic);
SetPixel32 (hdc, x,y+6*side, clrTic);
SetPixel32 (hdc, x,y+7*side, clrTic);
SetPixel32 (hdc, x,y+8*side, clrTic);
}
}
static VOID
TRACKBAR_DrawVertTic (TRACKBAR_INFO *infoPtr, HDC32 hdc, LONG ticPos,
int flags, COLORREF clrTic)
{
RECT32 rcChannel=infoPtr->rcChannel;
int x,y,width,range,side;
range=infoPtr->nRangeMax - infoPtr->nRangeMin;
width=rcChannel.bottom - rcChannel.top;
if (flags & TBS_TOP) {
x=rcChannel.right-2;
side=-1;
} else {
x=rcChannel.left+2;
side=1;
}
if (flags & TIC_SELECTIONMARK) {
if (flags & TIC_SELECTIONMARKMIN)
y=rcChannel.top + (width*ticPos)/range - 1;
else
y=rcChannel.top + (width*ticPos)/range + 1;
SetPixel32 (hdc, x+6*side, y, clrTic);
SetPixel32 (hdc, x+7*side, y, clrTic);
return;
}
if ((ticPos>infoPtr->nRangeMin) && (ticPos<infoPtr->nRangeMax)) {
y=rcChannel.top + (width*ticPos)/range;
SetPixel32 (hdc, x+5*side, y, clrTic);
SetPixel32 (hdc, x+6*side, y, clrTic);
SetPixel32 (hdc, x+7*side, y, clrTic);
}
if (flags & TIC_EDGE) {
if (flags & TIC_LEFTEDGE)
y=rcChannel.top;
else
y=rcChannel.bottom;
SetPixel32 (hdc, x+5*side, y, clrTic);
SetPixel32 (hdc, x+6*side, y, clrTic);
SetPixel32 (hdc, x+7*side, y, clrTic);
SetPixel32 (hdc, x+8*side, y, clrTic);
}
}
static VOID
TRACKBAR_DrawTics (TRACKBAR_INFO *infoPtr, HDC32 hdc, LONG ticPos,
int flags, COLORREF clrTic)
{
if (flags & TBS_VERT) {
if ((flags & TBS_TOP) || (flags & TBS_BOTH))
TRACKBAR_DrawVertTic (infoPtr, hdc, ticPos,
flags | TBS_TOP , clrTic);
if (!(flags & TBS_TOP) || (flags & TBS_BOTH))
TRACKBAR_DrawVertTic (infoPtr, hdc, ticPos, flags, clrTic);
return;
}
if ((flags & TBS_TOP) || (flags & TBS_BOTH))
TRACKBAR_DrawHorizTic (infoPtr, hdc, ticPos, flags | TBS_TOP , clrTic);
if (!(flags & TBS_TOP) || (flags & TBS_BOTH))
TRACKBAR_DrawHorizTic (infoPtr, hdc, ticPos, flags, clrTic);
}
static VOID static VOID
TRACKBAR_Refresh (WND *wndPtr, HDC32 hdc) TRACKBAR_Refresh (WND *wndPtr, HDC32 hdc)
{ {
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr); TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
RECT32 rcClient, rcChannel, rcSelection; RECT32 rcClient, rcChannel, rcSelection;
HBRUSH32 hBrush = CreateSolidBrush32 (infoPtr->clrBk); HBRUSH32 hBrush = CreateSolidBrush32 (infoPtr->clrBk);
INT32 x,y,tic; int i;
int i,range,width;
GetClientRect32 (wndPtr->hwndSelf, &rcClient); GetClientRect32 (wndPtr->hwndSelf, &rcClient);
hBrush = CreateSolidBrush32 (infoPtr->clrBk); hBrush = CreateSolidBrush32 (infoPtr->clrBk);
FillRect32 (hdc, &rcClient, hBrush); FillRect32 (hdc, &rcClient, hBrush);
DeleteObject32 (hBrush); DeleteObject32 (hBrush);
if (infoPtr->flags & TB_REFRESH_TIMER_SET) {
KillTimer32 (wndPtr->hwndSelf, TB_REFRESH_TIMER);
infoPtr->flags &= ~TB_REFRESH_TIMER_SET;
}
if (infoPtr->flags & TB_DRAGPOSVALID) {
infoPtr->nPos=infoPtr->dragPos;
infoPtr->flags |= TB_THUMBPOSCHANGED;
}
if (infoPtr->flags & TB_THUMBCHANGED) { if (infoPtr->flags & TB_THUMBCHANGED) {
TRACKBAR_CalcThumb (wndPtr, infoPtr); TRACKBAR_CalcThumb (wndPtr, infoPtr);
...@@ -209,7 +396,7 @@ TRACKBAR_Refresh (WND *wndPtr, HDC32 hdc) ...@@ -209,7 +396,7 @@ TRACKBAR_Refresh (WND *wndPtr, HDC32 hdc)
} }
if (infoPtr->flags & TB_SELECTIONCHANGED) if (infoPtr->flags & TB_SELECTIONCHANGED)
TRACKBAR_CalcSelection (wndPtr, infoPtr); TRACKBAR_CalcSelection (wndPtr, infoPtr);
infoPtr->flags &= ~ (TB_THUMBCHANGED | TB_SELECTIONCHANGED); infoPtr->flags &= ~ (TB_THUMBCHANGED | TB_SELECTIONCHANGED | TB_DRAGPOSVALID);
/* draw channel */ /* draw channel */
...@@ -220,9 +407,12 @@ TRACKBAR_Refresh (WND *wndPtr, HDC32 hdc) ...@@ -220,9 +407,12 @@ TRACKBAR_Refresh (WND *wndPtr, HDC32 hdc)
if (wndPtr->dwStyle & TBS_ENABLESELRANGE) { /* fill the channel */ if (wndPtr->dwStyle & TBS_ENABLESELRANGE) { /* fill the channel */
HBRUSH32 hbr = CreateSolidBrush32 (RGB(255,255,255)); HBRUSH32 hbr = CreateSolidBrush32 (RGB(255,255,255));
FillRect32 (hdc, &rcChannel, hbr); FillRect32 (hdc, &rcChannel, hbr);
if (rcSelection.left!=rcSelection.right) { if (((wndPtr->dwStyle & TBS_VERT) &&
hbr=CreateSolidBrush32 (COLOR_HIGHLIGHT); (rcSelection.left!=rcSelection.right)) ||
FillRect32 (hdc, &rcSelection, hbr); ((!(wndPtr->dwStyle & TBS_VERT)) &&
(rcSelection.left!=rcSelection.right))) {
hbr=CreateSolidBrush32 (COLOR_HIGHLIGHT);
FillRect32 (hdc, &rcSelection, hbr);
} }
DeleteObject32 (hbr); DeleteObject32 (hbr);
} }
...@@ -231,58 +421,29 @@ TRACKBAR_Refresh (WND *wndPtr, HDC32 hdc) ...@@ -231,58 +421,29 @@ TRACKBAR_Refresh (WND *wndPtr, HDC32 hdc)
/* draw tics */ /* draw tics */
if (!(wndPtr->dwStyle & TBS_NOTICKS)) { if (!(wndPtr->dwStyle & TBS_NOTICKS)) {
int ticFlags=wndPtr->dwStyle & 0x0f;
COLORREF clrTic=GetSysColor32 (COLOR_3DDKSHADOW); COLORREF clrTic=GetSysColor32 (COLOR_3DDKSHADOW);
x=rcChannel.left; for (i=0; i<infoPtr->uNumTics; i++)
y=rcChannel.bottom+2; TRACKBAR_DrawTics (infoPtr, hdc, infoPtr->tics[i],
range=infoPtr->nRangeMax - infoPtr->nRangeMin; ticFlags, clrTic);
width=rcChannel.right - rcChannel.left;
if (wndPtr->dwStyle & TBS_VERT) { /* swap x/y */ TRACKBAR_DrawTics (infoPtr, hdc, 0, ticFlags | TIC_LEFTEDGE, clrTic);
} TRACKBAR_DrawTics (infoPtr, hdc, 0, ticFlags | TIC_RIGHTEDGE, clrTic);
if ((wndPtr->dwStyle & TBS_TOP) || (wndPtr->dwStyle & TBS_BOTH)) { if ((wndPtr->dwStyle & TBS_ENABLESELRANGE) &&
/* draw upper tics */ (rcSelection.left!=rcSelection.right)) {
} TRACKBAR_DrawTics (infoPtr, hdc, infoPtr->nSelMin,
ticFlags | TIC_SELECTIONMARKMIN, clrTic);
// if (!((wndPtr->dwStyle & TBS_TOP) || (!(wndPtr->dwStyle & TBS_BOTH)))) TRACKBAR_DrawTics (infoPtr, hdc, infoPtr->nSelMax,
/* draw lower tics */ ticFlags | TIC_SELECTIONMARKMAX, clrTic);
// 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*tic)/range;
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*infoPtr->nSelMin)/range - 1;
SetPixel32 (hdc, x,y+6, clrTic);
SetPixel32 (hdc, x,y+7, clrTic);
x=rcChannel.left + (width*infoPtr->nSelMax)/range + 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 */ /* draw thumb */
if (!(wndPtr->dwStyle & TBS_NOTHUMB)) { if (!(wndPtr->dwStyle & TBS_NOTHUMB)) {
HBRUSH32 hbr = CreateSolidBrush32 (COLOR_BACKGROUND); HBRUSH32 hbr = CreateSolidBrush32 (COLOR_BACKGROUND);
RECT32 thumb = infoPtr->rcThumb; RECT32 thumb = infoPtr->rcThumb;
...@@ -294,10 +455,10 @@ TRACKBAR_Refresh (WND *wndPtr, HDC32 hdc) ...@@ -294,10 +455,10 @@ TRACKBAR_Refresh (WND *wndPtr, HDC32 hdc)
} else { } else {
POINT32 points[6]; POINT32 points[6];
RECT32 triangle; /* for correct shadows of thumb */
/* first, fill the thumb */ /* first, fill the thumb */
/* FIXME: revamp. check for TBS_VERT */
SetPolyFillMode32 (hdc,WINDING); SetPolyFillMode32 (hdc,WINDING);
points[0].x=thumb.left; points[0].x=thumb.left;
points[0].y=thumb.top; points[0].y=thumb.top;
...@@ -312,19 +473,26 @@ TRACKBAR_Refresh (WND *wndPtr, HDC32 hdc) ...@@ -312,19 +473,26 @@ TRACKBAR_Refresh (WND *wndPtr, HDC32 hdc)
points[5].x=points[0].x; points[5].x=points[0].x;
points[5].y=points[0].y; points[5].y=points[0].y;
Polygon32 (hdc, points, 6); Polygon32 (hdc, points, 6);
DrawEdge32 (hdc, &thumb, EDGE_RAISED, BF_TOPLEFT);
// DrawEdge32 (hdc, &thumb, EDGE_SUNKEN, BF_BOTTOMRIGHT); if (wndPtr->dwStyle & TBS_VERT) {
// draw edge
} else {
RECT32 triangle; /* for correct shadows of thumb */
DrawEdge32 (hdc, &thumb, EDGE_RAISED, BF_TOPLEFT);
/* draw notch */ /* draw notch */
triangle.right = thumb.right+5; triangle.right = thumb.right+5;
triangle.left = points[3].x+5; triangle.left = points[3].x+5;
triangle.top = thumb.bottom +5; triangle.top = thumb.bottom +5;
triangle.bottom= thumb.bottom +1; triangle.bottom= thumb.bottom +1;
DrawEdge32 (hdc, &triangle, EDGE_SUNKEN, BF_DIAGONAL | BF_TOP | BF_RIGHT); DrawEdge32 (hdc, &triangle, EDGE_SUNKEN,
triangle.left = thumb.left+6; BF_DIAGONAL | BF_TOP | BF_RIGHT);
triangle.right = points[3].x+6; triangle.left = thumb.left+6;
DrawEdge32 (hdc, &triangle, EDGE_RAISED, BF_DIAGONAL | BF_TOP | BF_LEFT); triangle.right = points[3].x+6;
DrawEdge32 (hdc, &triangle, EDGE_RAISED,
BF_DIAGONAL | BF_TOP | BF_LEFT);
}
} }
DeleteObject32 (hbr); DeleteObject32 (hbr);
} }
...@@ -413,7 +581,7 @@ TRACKBAR_ClearTics (WND *wndPtr, WPARAM32 wParam, LPARAM lParam) ...@@ -413,7 +581,7 @@ TRACKBAR_ClearTics (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr); TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
if (infoPtr->tics) { if (infoPtr->tics) {
HeapFree (GetProcessHeap (), 0, infoPtr->tics); COMCTL32_Free (infoPtr->tics);
infoPtr->tics = NULL; infoPtr->tics = NULL;
infoPtr->uNumTics = 0; infoPtr->uNumTics = 0;
} }
...@@ -896,7 +1064,7 @@ TRACKBAR_SetTic (WND *wndPtr, WPARAM32 wParam, LPARAM lParam) ...@@ -896,7 +1064,7 @@ TRACKBAR_SetTic (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
return FALSE; return FALSE;
infoPtr->uNumTics++; infoPtr->uNumTics++;
infoPtr->tics=HeapReAlloc( SystemHeap, 0, infoPtr->tics, infoPtr->tics=COMCTL32_ReAlloc( infoPtr->tics,
(infoPtr->uNumTics)*sizeof (DWORD)); (infoPtr->uNumTics)*sizeof (DWORD));
infoPtr->tics[infoPtr->uNumTics-1]=nPos; infoPtr->tics[infoPtr->uNumTics-1]=nPos;
...@@ -956,8 +1124,7 @@ TRACKBAR_Create (WND *wndPtr, WPARAM32 wParam, LPARAM lParam) ...@@ -956,8 +1124,7 @@ TRACKBAR_Create (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{ {
TRACKBAR_INFO *infoPtr; TRACKBAR_INFO *infoPtr;
infoPtr = (TRACKBAR_INFO *)HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, infoPtr = (TRACKBAR_INFO *)COMCTL32_Alloc (sizeof(TRACKBAR_INFO));
sizeof(TRACKBAR_INFO));
wndPtr->wExtra[0] = (DWORD)infoPtr; wndPtr->wExtra[0] = (DWORD)infoPtr;
...@@ -973,9 +1140,43 @@ TRACKBAR_Create (WND *wndPtr, WPARAM32 wParam, LPARAM lParam) ...@@ -973,9 +1140,43 @@ TRACKBAR_Create (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
infoPtr->uTicFreq = 1; infoPtr->uTicFreq = 1;
infoPtr->tics = NULL; infoPtr->tics = NULL;
infoPtr->clrBk = GetSysColor32 (COLOR_BACKGROUND); infoPtr->clrBk = GetSysColor32 (COLOR_BACKGROUND);
infoPtr->hwndNotify = GetParent32 (wndPtr->hwndSelf);
TRACKBAR_InitializeThumb (wndPtr); TRACKBAR_InitializeThumb (wndPtr);
if (wndPtr->dwStyle & TBS_TOOLTIPS) { /* Create tooltip control */
TTTOOLINFO32A ti;
infoPtr->hwndToolTip =
CreateWindowEx32A (0, TOOLTIPS_CLASS32A, NULL, 0,
CW_USEDEFAULT32, CW_USEDEFAULT32,
CW_USEDEFAULT32, CW_USEDEFAULT32,
wndPtr->hwndSelf, 0, 0, 0);
/* Send NM_TOOLTIPSCREATED notification */
if (infoPtr->hwndToolTip) {
NMTOOLTIPSCREATED nmttc;
nmttc.hdr.hwndFrom = wndPtr->hwndSelf;
nmttc.hdr.idFrom = wndPtr->wIDmenu;
nmttc.hdr.code = NM_TOOLTIPSCREATED;
nmttc.hwndToolTips = infoPtr->hwndToolTip;
SendMessage32A (GetParent32 (wndPtr->hwndSelf), WM_NOTIFY,
(WPARAM32)wndPtr->wIDmenu, (LPARAM)&nmttc);
}
ZeroMemory (&ti, sizeof(TTTOOLINFO32A));
ti.cbSize = sizeof(TTTOOLINFO32A);
ti.uFlags = TTF_IDISHWND | TTF_TRACK;
ti.hwnd = wndPtr->hwndSelf;
ti.uId = 0;
ti.lpszText = "Test"; // LPSTR_TEXTCALLBACK;
SetRectEmpty32 (&ti.rect);
SendMessage32A (infoPtr->hwndToolTip, TTM_ADDTOOL32A, 0, (LPARAM)&ti);
}
return 0; return 0;
} }
...@@ -985,10 +1186,14 @@ TRACKBAR_Destroy (WND *wndPtr, WPARAM32 wParam, LPARAM lParam) ...@@ -985,10 +1186,14 @@ TRACKBAR_Destroy (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{ {
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr); TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
if (infoPtr->flags & TB_DRAG_TIMER_SET) if (infoPtr->flags & TB_REFRESH_TIMER_SET)
KillTimer32 (wndPtr->hwndSelf, TB_DRAG_TIMER); KillTimer32 (wndPtr->hwndSelf, TB_REFRESH_TIMER);
HeapFree (GetProcessHeap (), 0, infoPtr); /* delete tooltip control */
if (infoPtr->hwndToolTip)
DestroyWindow32 (infoPtr->hwndToolTip);
COMCTL32_Free (infoPtr);
return 0; return 0;
} }
...@@ -997,17 +1202,12 @@ static LRESULT ...@@ -997,17 +1202,12 @@ static LRESULT
TRACKBAR_KillFocus (WND *wndPtr, WPARAM32 wParam, LPARAM lParam) TRACKBAR_KillFocus (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{ {
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr); TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
HDC32 hdc;
TRACE (trackbar,"\n"); TRACE (trackbar,"\n");
if (infoPtr->flags & TB_DRAG_TIMER_SET)
KillTimer32 (wndPtr->hwndSelf, TB_DRAG_TIMER);
infoPtr->bFocus = FALSE; infoPtr->bFocus = FALSE;
hdc = GetDC32 (wndPtr->hwndSelf); infoPtr->flags &= ~TB_DRAG_MODE;
TRACKBAR_Refresh (wndPtr, hdc); TRACKBAR_QueueRefresh (wndPtr);
ReleaseDC32 (wndPtr->hwndSelf, hdc);
InvalidateRect32 (wndPtr->hwndSelf, NULL, TRUE); InvalidateRect32 (wndPtr->hwndSelf, NULL, TRUE);
return 0; return 0;
...@@ -1018,20 +1218,44 @@ static LRESULT ...@@ -1018,20 +1218,44 @@ static LRESULT
TRACKBAR_LButtonDown (WND *wndPtr, WPARAM32 wParam, LPARAM lParam) TRACKBAR_LButtonDown (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{ {
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr); TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
int clickPlace,prevPos,clickPos; int clickPlace,prevPos,clickPos,vertical;
SetFocus32 (wndPtr->hwndSelf); SetFocus32 (wndPtr->hwndSelf);
clickPlace=(INT32)LOWORD(lParam); vertical=wndPtr->dwStyle & TBS_VERT;
if (vertical)
if ((clickPlace>infoPtr->rcThumb.left) && clickPlace=(INT32)HIWORD(lParam);
(clickPlace<infoPtr->rcThumb.right)) { else
SetTimer32 (wndPtr->hwndSelf, TB_DRAG_TIMER, TB_DRAG_DELAY, 0); clickPlace=(INT32)LOWORD(lParam);
infoPtr->flags |= TB_DRAG_TIMER_SET;
if ((vertical &&
(clickPlace>infoPtr->rcThumb.top) &&
(clickPlace<infoPtr->rcThumb.bottom)) ||
(!vertical &&
(clickPlace>infoPtr->rcThumb.left) &&
(clickPlace<infoPtr->rcThumb.right))) {
infoPtr->flags |= TB_DRAG_MODE;
if (wndPtr->dwStyle & TBS_TOOLTIPS) { /* enable tooltip */
TTTOOLINFO32A ti;
POINT32 pt;
GetCursorPos32 (&pt);
SendMessage32A (infoPtr->hwndToolTip, TTM_TRACKPOSITION, 0,
(LPARAM)MAKELPARAM(pt.x, pt.y));
ti.cbSize = sizeof(TTTOOLINFO32A);
ti.uId = 0;
ti.hwnd = (UINT32)wndPtr->hwndSelf;
infoPtr->flags |= TB_SHOW_TOOLTIP;
SetCapture32 (wndPtr->hwndSelf);
SendMessage32A (infoPtr->hwndToolTip, TTM_TRACKACTIVATE,
(WPARAM32)TRUE, (LPARAM)&ti);
}
return 0; return 0;
} }
clickPos=TRACKBAR_ConvertPlaceToPosition (infoPtr, clickPlace); clickPos=TRACKBAR_ConvertPlaceToPosition (infoPtr, clickPlace, vertical);
prevPos = infoPtr->nPos; prevPos = infoPtr->nPos;
if (clickPos > prevPos) { /* similar to VK_NEXT */ if (clickPos > prevPos) { /* similar to VK_NEXT */
...@@ -1045,14 +1269,10 @@ TRACKBAR_LButtonDown (WND *wndPtr, WPARAM32 wParam, LPARAM lParam) ...@@ -1045,14 +1269,10 @@ TRACKBAR_LButtonDown (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
infoPtr->nPos = infoPtr->nRangeMin; infoPtr->nPos = infoPtr->nRangeMin;
TRACKBAR_SendNotify (wndPtr, TB_PAGEDOWN); TRACKBAR_SendNotify (wndPtr, TB_PAGEDOWN);
} }
if (prevPos!=infoPtr->nPos) { if (prevPos!=infoPtr->nPos) {
HDC32 hdc;
hdc=GetDC32 (wndPtr->hwndSelf);
infoPtr->flags |=TB_THUMBPOSCHANGED; infoPtr->flags |=TB_THUMBPOSCHANGED;
TRACKBAR_Refresh (wndPtr, hdc); TRACKBAR_QueueRefresh (wndPtr);
ReleaseDC32 (wndPtr->hwndSelf, hdc);
} }
return 0; return 0;
...@@ -1063,13 +1283,24 @@ TRACKBAR_LButtonUp (WND *wndPtr, WPARAM32 wParam, LPARAM lParam) ...@@ -1063,13 +1283,24 @@ TRACKBAR_LButtonUp (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{ {
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr); TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
if (infoPtr->flags & TB_DRAG_TIMER_SET) { TRACKBAR_QueueRefresh (wndPtr);
KillTimer32 (wndPtr->hwndSelf, TB_DRAG_TIMER);
infoPtr->flags &= ~TB_DRAG_TIMER_SET;
}
TRACKBAR_SendNotify (wndPtr, TB_ENDTRACK); TRACKBAR_SendNotify (wndPtr, TB_ENDTRACK);
infoPtr->flags &= ~TB_DRAG_MODE;
if (wndPtr->dwStyle & TBS_TOOLTIPS) { /* disable tooltip */
TTTOOLINFO32A ti;
ti.cbSize = sizeof(TTTOOLINFO32A);
ti.uId = 0;
ti.hwnd = (UINT32)wndPtr->hwndSelf;
infoPtr->flags &= ~TB_SHOW_TOOLTIP;
ReleaseCapture ();
SendMessage32A (infoPtr->hwndToolTip, TTM_TRACKACTIVATE,
(WPARAM32)FALSE, (LPARAM)&ti);
}
return 0; return 0;
} }
...@@ -1078,13 +1309,12 @@ TRACKBAR_CaptureChanged (WND *wndPtr, WPARAM32 wParam, LPARAM lParam) ...@@ -1078,13 +1309,12 @@ TRACKBAR_CaptureChanged (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{ {
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr); TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
if (infoPtr->flags & TB_DRAG_TIMER_SET) if (infoPtr->flags & TB_DRAGPOSVALID) {
KillTimer32 (wndPtr->hwndSelf, TB_DRAG_TIMER);
if (infoPtr->flags & TB_DRAGPOSVALID)
infoPtr->nPos=infoPtr->dragPos; infoPtr->nPos=infoPtr->dragPos;
TRACKBAR_QueueRefresh (wndPtr);
infoPtr->flags &= ~ (TB_DRAGPOSVALID | TB_DRAG_TIMER_SET); }
infoPtr->flags &= ~ TB_DRAGPOSVALID;
TRACKBAR_SendNotify (wndPtr, TB_ENDTRACK); TRACKBAR_SendNotify (wndPtr, TB_ENDTRACK);
return 0; return 0;
...@@ -1145,20 +1375,58 @@ TRACKBAR_SendNotify (WND *wndPtr, UINT32 code) ...@@ -1145,20 +1375,58 @@ TRACKBAR_SendNotify (WND *wndPtr, UINT32 code)
return (BOOL32) SendMessage32A (GetParent32 (wndPtr->hwndSelf), return (BOOL32) SendMessage32A (GetParent32 (wndPtr->hwndSelf),
WM_HSCROLL, (WPARAM32)code, (LPARAM) wndPtr->hwndSelf); WM_HSCROLL, (WPARAM32)code, (LPARAM) wndPtr->hwndSelf);
return 0;
} }
static LRESULT static LRESULT
TRACKBAR_MouseMove (WND *wndPtr, WPARAM32 wParam, LPARAM lParam) TRACKBAR_MouseMove (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{ {
TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr); TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(wndPtr);
INT32 clickPlace; INT32 clickPlace,vertical;
HDC32 hdc;
char buf[80];
clickPlace=(INT32)LOWORD(lParam); TRACE (trackbar, "%x\n",wParam);
vertical=wndPtr->dwStyle & TBS_VERT;
if (vertical)
clickPlace=(INT32)HIWORD(lParam);
else
clickPlace=(INT32)LOWORD(lParam);
if (!(infoPtr->flags & TB_DRAG_MODE)) return TRUE;
infoPtr->dragPos=TRACKBAR_ConvertPlaceToPosition (infoPtr, clickPlace); infoPtr->dragPos=TRACKBAR_ConvertPlaceToPosition (infoPtr, clickPlace, vertical);
infoPtr->flags|=TB_DRAGPOSVALID; infoPtr->flags|= TB_DRAGPOSVALID;
TRACKBAR_SendNotify (wndPtr, TB_THUMBTRACK | (infoPtr->nPos>>16));
if (infoPtr->flags & TB_SHOW_TOOLTIP) {
POINT32 pt;
TTTOOLINFO32A ti;
ti.cbSize = sizeof(TTTOOLINFO32A);
ti.hwnd = wndPtr->hwndSelf;
ti.uId = 0;
ti.hinst=0;
sprintf (buf,"%d",infoPtr->nPos);
ti.lpszText = (LPSTR) buf;
GetCursorPos32 (&pt);
if (vertical) {
SendMessage32A (infoPtr->hwndToolTip, TTM_TRACKPOSITION,
0, (LPARAM)MAKELPARAM(pt.x+5, pt.y+15));
} else {
SendMessage32A (infoPtr->hwndToolTip, TTM_TRACKPOSITION,
0, (LPARAM)MAKELPARAM(pt.x+15, pt.y+5));
}
SendMessage32A (infoPtr->hwndToolTip, TTM_UPDATETIPTEXT32A,
0, (LPARAM)&ti);
}
hdc = GetDC32 (wndPtr->hwndSelf);
TRACKBAR_Refresh (wndPtr, hdc);
ReleaseDC32 (wndPtr->hwndSelf, hdc);
TRACKBAR_SendNotify (wndPtr, TB_THUMBTRACK | (infoPtr->dragPos>>16));
return TRUE; return TRUE;
} }
...@@ -1216,12 +1484,8 @@ TRACKBAR_KeyDown (WND *wndPtr, WPARAM32 wParam, LPARAM lParam) ...@@ -1216,12 +1484,8 @@ TRACKBAR_KeyDown (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
} }
if (pos!=infoPtr->nPos) { if (pos!=infoPtr->nPos) {
HDC32 hdc;
hdc=GetDC32 (wndPtr->hwndSelf);
infoPtr->flags |=TB_THUMBPOSCHANGED; infoPtr->flags |=TB_THUMBPOSCHANGED;
TRACKBAR_Refresh (wndPtr, hdc); TRACKBAR_QueueRefresh (wndPtr);
ReleaseDC32 (wndPtr->hwndSelf, hdc);
} }
return TRUE; return TRUE;
...@@ -1253,12 +1517,13 @@ TRACKBAR_HandleTimer ( WND *wndPtr, WPARAM32 wParam, LPARAM lParam) ...@@ -1253,12 +1517,13 @@ TRACKBAR_HandleTimer ( WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
TRACE (trackbar,"timer\n"); TRACE (trackbar,"timer\n");
switch (wParam) { switch (wParam) {
case TB_DRAG_TIMER: case TB_REFRESH_TIMER:
KillTimer32 (wndPtr->hwndSelf, TB_REFRESH_TIMER );
if (infoPtr->flags & TB_DRAGPOSVALID) { if (infoPtr->flags & TB_DRAGPOSVALID) {
infoPtr->nPos=infoPtr->dragPos; infoPtr->nPos=infoPtr->dragPos;
infoPtr->flags |= TB_THUMBPOSCHANGED; infoPtr->flags |= TB_THUMBPOSCHANGED;
} }
infoPtr->flags &= ~ (TB_DRAG_TIMER_SET | TB_DRAGPOSVALID); infoPtr->flags &= ~ (TB_REFRESH_TIMER_SET | TB_DRAGPOSVALID);
hdc=GetDC32 (wndPtr->hwndSelf); hdc=GetDC32 (wndPtr->hwndSelf);
TRACKBAR_Refresh (wndPtr, hdc); TRACKBAR_Refresh (wndPtr, hdc);
ReleaseDC32 (wndPtr->hwndSelf, hdc); ReleaseDC32 (wndPtr->hwndSelf, hdc);
...@@ -1271,7 +1536,9 @@ TRACKBAR_HandleTimer ( WND *wndPtr, WPARAM32 wParam, LPARAM lParam) ...@@ -1271,7 +1536,9 @@ TRACKBAR_HandleTimer ( WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
LRESULT WINAPI LRESULT WINAPI
TRACKBAR_WindowProc (HWND32 hwnd, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam) TRACKBAR_WindowProc (HWND32 hwnd, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam)
{ {
WND *wndPtr = WIN_FindWndPtr(hwnd); WND *wndPtr = WIN_FindWndPtr(hwnd);
// TRACE (trackbar, "msg %04x wp=%08x lp=%08lx\n", uMsg, wParam, lParam);
switch (uMsg) switch (uMsg)
{ {
...@@ -1431,7 +1698,7 @@ TRACKBAR_WindowProc (HWND32 hwnd, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam) ...@@ -1431,7 +1698,7 @@ TRACKBAR_WindowProc (HWND32 hwnd, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam)
return TRACKBAR_InitializeThumb (wndPtr); return TRACKBAR_InitializeThumb (wndPtr);
default: default:
if (uMsg >= WM_USER) if (uMsg >= WM_USER)
ERR (trackbar, "unknown msg %04x wp=%08x lp=%08lx\n", ERR (trackbar, "unknown msg %04x wp=%08x lp=%08lx\n",
uMsg, wParam, lParam); uMsg, wParam, lParam);
return DefWindowProc32A (hwnd, uMsg, wParam, lParam); return DefWindowProc32A (hwnd, uMsg, wParam, lParam);
......
...@@ -19,6 +19,7 @@ typedef struct tagTRACKBAR_INFO ...@@ -19,6 +19,7 @@ typedef struct tagTRACKBAR_INFO
UINT32 uThumbLen; UINT32 uThumbLen;
UINT32 uNumTics; UINT32 uNumTics;
UINT32 uTicFreq; UINT32 uTicFreq;
HWND32 hwndNotify;
HWND32 hwndToolTip; HWND32 hwndToolTip;
HWND32 hwndBuddyLA; HWND32 hwndBuddyLA;
HWND32 hwndBuddyRB; HWND32 hwndBuddyRB;
...@@ -30,13 +31,13 @@ typedef struct tagTRACKBAR_INFO ...@@ -30,13 +31,13 @@ typedef struct tagTRACKBAR_INFO
RECT32 rcChannel; RECT32 rcChannel;
RECT32 rcSelection; RECT32 rcSelection;
RECT32 rcThumb; RECT32 rcThumb;
INT32 dragPos; INT32 dragPos;
LPLONG tics; LPLONG tics;
} TRACKBAR_INFO; } TRACKBAR_INFO;
#define TB_DRAG_TIMER 1 #define TB_REFRESH_TIMER 1
#define TB_DRAG_DELAY 10 #define TB_REFRESH_DELAY 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment