Commit 0d5aae1a authored by Duane Clark's avatar Duane Clark Committed by Alexandre Julliard

Oops, back to hard coding initial thumb size until we figure out how

it really should work. Fix the channel size/selection range for the TBS_ENABLESELRANGE style. One pixel tweaks in several spots.
parent cae7755a
...@@ -143,12 +143,12 @@ TRACKBAR_ConvertPlaceToPosition (TRACKBAR_INFO *infoPtr, int place, ...@@ -143,12 +143,12 @@ TRACKBAR_ConvertPlaceToPosition (TRACKBAR_INFO *infoPtr, int place,
range = infoPtr->lRangeMax - infoPtr->lRangeMin; range = infoPtr->lRangeMax - infoPtr->lRangeMin;
if (vertical) { if (vertical) {
offsetthumb = (infoPtr->rcThumb.bottom - infoPtr->rcThumb.top)/2 + 1; offsetthumb = (infoPtr->rcThumb.bottom - infoPtr->rcThumb.top)/2;
width = infoPtr->rcChannel.bottom - infoPtr->rcChannel.top - (offsetthumb * 2); width = infoPtr->rcChannel.bottom - infoPtr->rcChannel.top - (offsetthumb * 2) - 1;
pos = (range*(place - infoPtr->rcChannel.top - offsetthumb)) / width; pos = (range*(place - infoPtr->rcChannel.top - offsetthumb)) / width;
} else { } else {
offsetthumb = (infoPtr->rcThumb.right - infoPtr->rcThumb.left)/2 + 1; offsetthumb = (infoPtr->rcThumb.right - infoPtr->rcThumb.left)/2;
width = infoPtr->rcChannel.right - infoPtr->rcChannel.left - (offsetthumb * 2); width = infoPtr->rcChannel.right - infoPtr->rcChannel.left - (offsetthumb * 2) - 1;
pos = (range*(place - infoPtr->rcChannel.left - offsetthumb)) / width; pos = (range*(place - infoPtr->rcChannel.left - offsetthumb)) / width;
} }
pos += infoPtr->lRangeMin; pos += infoPtr->lRangeMin;
...@@ -228,11 +228,14 @@ TRACKBAR_CalcChannel (TRACKBAR_INFO *infoPtr) ...@@ -228,11 +228,14 @@ TRACKBAR_CalcChannel (TRACKBAR_INFO *infoPtr)
offsetthumb = infoPtr->uThumbLen / 4; offsetthumb = infoPtr->uThumbLen / 4;
offsetedge = offsetthumb + 3; offsetedge = offsetthumb + 3;
cyChannel = (dwStyle & TBS_ENABLESELRANGE) ? (offsetthumb+1)*3 : 4; cyChannel = (dwStyle & TBS_ENABLESELRANGE) ? offsetthumb*3 : 4;
if (dwStyle & TBS_VERT) { if (dwStyle & TBS_VERT) {
channel->top = lpRect.top + offsetedge; channel->top = lpRect.top + offsetedge;
channel->bottom = lpRect.bottom - offsetedge; channel->bottom = lpRect.bottom - offsetedge;
channel->left = lpRect.left + (infoPtr->uThumbLen / 2) - 1; if (dwStyle & TBS_ENABLESELRANGE)
channel->left = lpRect.left + ((infoPtr->uThumbLen - cyChannel + 2) / 2);
else
channel->left = lpRect.left + (infoPtr->uThumbLen / 2) - 1;
if (dwStyle & TBS_BOTH) { if (dwStyle & TBS_BOTH) {
if (dwStyle & TBS_NOTICKS) if (dwStyle & TBS_NOTICKS)
channel->left += 1; channel->left += 1;
...@@ -249,7 +252,10 @@ TRACKBAR_CalcChannel (TRACKBAR_INFO *infoPtr) ...@@ -249,7 +252,10 @@ TRACKBAR_CalcChannel (TRACKBAR_INFO *infoPtr)
} else { } else {
channel->left = lpRect.left + offsetedge; channel->left = lpRect.left + offsetedge;
channel->right = lpRect.right - offsetedge; channel->right = lpRect.right - offsetedge;
channel->top = lpRect.top + (infoPtr->uThumbLen / 2) - 1; if (dwStyle & TBS_ENABLESELRANGE)
channel->top = lpRect.top + ((infoPtr->uThumbLen - cyChannel + 2) / 2);
else
channel->top = lpRect.top + (infoPtr->uThumbLen / 2) - 1;
if (dwStyle & TBS_BOTH) { if (dwStyle & TBS_BOTH) {
if (dwStyle & TBS_NOTICKS) if (dwStyle & TBS_NOTICKS)
channel->top += 1; channel->top += 1;
...@@ -281,7 +287,7 @@ TRACKBAR_CalcThumb (TRACKBAR_INFO *infoPtr, LONG lPos, RECT *thumb) ...@@ -281,7 +287,7 @@ TRACKBAR_CalcThumb (TRACKBAR_INFO *infoPtr, LONG lPos, RECT *thumb)
GetClientRect(infoPtr->hwndSelf, &lpRect); GetClientRect(infoPtr->hwndSelf, &lpRect);
if (dwStyle & TBS_VERT) if (dwStyle & TBS_VERT)
{ {
height = infoPtr->rcChannel.bottom - infoPtr->rcChannel.top - thumbwidth - 1; height = infoPtr->rcChannel.bottom - infoPtr->rcChannel.top - thumbwidth;
if ((dwStyle & (TBS_BOTH | TBS_LEFT)) && !(dwStyle & TBS_NOTICKS)) if ((dwStyle & (TBS_BOTH | TBS_LEFT)) && !(dwStyle & TBS_NOTICKS))
thumb->left = 10; thumb->left = 10;
...@@ -294,7 +300,7 @@ TRACKBAR_CalcThumb (TRACKBAR_INFO *infoPtr, LONG lPos, RECT *thumb) ...@@ -294,7 +300,7 @@ TRACKBAR_CalcThumb (TRACKBAR_INFO *infoPtr, LONG lPos, RECT *thumb)
} }
else else
{ {
width = infoPtr->rcChannel.right - infoPtr->rcChannel.left - thumbwidth - 1; width = infoPtr->rcChannel.right - infoPtr->rcChannel.left - thumbwidth;
thumb->left = infoPtr->rcChannel.left + thumb->left = infoPtr->rcChannel.left +
(width*(lPos - infoPtr->lRangeMin))/range; (width*(lPos - infoPtr->lRangeMin))/range;
...@@ -348,23 +354,26 @@ TRACKBAR_CalcSelection (TRACKBAR_INFO *infoPtr) ...@@ -348,23 +354,26 @@ TRACKBAR_CalcSelection (TRACKBAR_INFO *infoPtr)
{ {
RECT *selection = &infoPtr->rcSelection; RECT *selection = &infoPtr->rcSelection;
int range = infoPtr->lRangeMax - infoPtr->lRangeMin; int range = infoPtr->lRangeMax - infoPtr->lRangeMin;
int offsetthumb, height, width;
if (range <= 0) { if (range <= 0) {
SetRectEmpty (selection); SetRectEmpty (selection);
} else { } else {
if (GetWindowLongW (infoPtr->hwndSelf, GWL_STYLE) & TBS_VERT) { if (GetWindowLongW (infoPtr->hwndSelf, GWL_STYLE) & TBS_VERT) {
int height = infoPtr->rcChannel.right - infoPtr->rcChannel.left; offsetthumb = (infoPtr->rcThumb.bottom - infoPtr->rcThumb.top)/2;
selection->top = infoPtr->rcChannel.top + height = infoPtr->rcChannel.bottom - infoPtr->rcChannel.top - offsetthumb*2;
selection->top = infoPtr->rcChannel.top + offsetthumb +
(height*infoPtr->lSelMin)/range; (height*infoPtr->lSelMin)/range;
selection->bottom = infoPtr->rcChannel.top + selection->bottom = infoPtr->rcChannel.top + offsetthumb +
(height*infoPtr->lSelMax)/range; (height*infoPtr->lSelMax)/range;
selection->left = infoPtr->rcChannel.left + 3; selection->left = infoPtr->rcChannel.left + 3;
selection->right = infoPtr->rcChannel.right - 3; selection->right = infoPtr->rcChannel.right - 3;
} else { } else {
int width = infoPtr->rcChannel.right - infoPtr->rcChannel.left; offsetthumb = (infoPtr->rcThumb.right - infoPtr->rcThumb.left)/2;
selection->left = infoPtr->rcChannel.left + width = infoPtr->rcChannel.right - infoPtr->rcChannel.left - offsetthumb*2;
selection->left = infoPtr->rcChannel.left + offsetthumb +
(width*infoPtr->lSelMin)/range; (width*infoPtr->lSelMin)/range;
selection->right = infoPtr->rcChannel.left + selection->right = infoPtr->rcChannel.left + offsetthumb +
(width*infoPtr->lSelMax)/range; (width*infoPtr->lSelMax)/range;
selection->top = infoPtr->rcChannel.top + 3; selection->top = infoPtr->rcChannel.top + 3;
selection->bottom = infoPtr->rcChannel.bottom - 3; selection->bottom = infoPtr->rcChannel.bottom - 3;
...@@ -418,14 +427,14 @@ TRACKBAR_DrawOneTic (TRACKBAR_INFO *infoPtr, HDC hdc, LONG ticPos, int flags) ...@@ -418,14 +427,14 @@ TRACKBAR_DrawOneTic (TRACKBAR_INFO *infoPtr, HDC hdc, LONG ticPos, int flags)
RECT rcTics; RECT rcTics;
if (flags & TBS_VERT) { if (flags & TBS_VERT) {
offsetthumb = (infoPtr->rcThumb.bottom - infoPtr->rcThumb.top)/2 + 1; offsetthumb = (infoPtr->rcThumb.bottom - infoPtr->rcThumb.top)/2;
rcTics.left = infoPtr->rcThumb.left - 2; rcTics.left = infoPtr->rcThumb.left - 2;
rcTics.right = infoPtr->rcThumb.right + 2; rcTics.right = infoPtr->rcThumb.right + 2;
rcTics.top = infoPtr->rcChannel.top + offsetthumb; rcTics.top = infoPtr->rcChannel.top + offsetthumb + 1;
rcTics.bottom = infoPtr->rcChannel.bottom - offsetthumb; rcTics.bottom = infoPtr->rcChannel.bottom - offsetthumb;
} else { } else {
offsetthumb = (infoPtr->rcThumb.right - infoPtr->rcThumb.left)/2 + 1; offsetthumb = (infoPtr->rcThumb.right - infoPtr->rcThumb.left)/2;
rcTics.left = infoPtr->rcChannel.left + offsetthumb; rcTics.left = infoPtr->rcChannel.left + offsetthumb + 1;
rcTics.right = infoPtr->rcChannel.right - offsetthumb; rcTics.right = infoPtr->rcChannel.right - offsetthumb;
rcTics.top = infoPtr->rcThumb.top - 2; rcTics.top = infoPtr->rcThumb.top - 2;
rcTics.bottom = infoPtr->rcThumb.bottom + 2; rcTics.bottom = infoPtr->rcThumb.bottom + 2;
...@@ -454,13 +463,9 @@ TRACKBAR_DrawOneTic (TRACKBAR_INFO *infoPtr, HDC hdc, LONG ticPos, int flags) ...@@ -454,13 +463,9 @@ TRACKBAR_DrawOneTic (TRACKBAR_INFO *infoPtr, HDC hdc, LONG ticPos, int flags)
if (flags & TBS_VERT) { if (flags & TBS_VERT) {
int height = rcTics.bottom - rcTics.top; int height = rcTics.bottom - rcTics.top;
y = rcTics.top + (height*(ticPos - infoPtr->lRangeMin))/range; y = rcTics.top + (height*(ticPos - infoPtr->lRangeMin))/range;
/* x -= (offset + 2) * side;
y += indent;*/
} else { } else {
int width = rcTics.right - rcTics.left; int width = rcTics.right - rcTics.left;
x = rcTics.left + (width*(ticPos - infoPtr->lRangeMin))/range; x = rcTics.left + (width*(ticPos - infoPtr->lRangeMin))/range;
/* x += indent;
y -= (offset + 2) * side;*/
} }
ox = x; ox = x;
...@@ -960,6 +965,7 @@ static LONG inline ...@@ -960,6 +965,7 @@ static LONG inline
TRACKBAR_GetTicPos (TRACKBAR_INFO *infoPtr, INT iTic) TRACKBAR_GetTicPos (TRACKBAR_INFO *infoPtr, INT iTic)
{ {
LONG range, width, pos, tic; LONG range, width, pos, tic;
int offsetthumb;
if ((iTic < 0) || (iTic >= infoPtr->uNumTics) || !infoPtr->tics) if ((iTic < 0) || (iTic >= infoPtr->uNumTics) || !infoPtr->tics)
return -1; return -1;
...@@ -967,8 +973,9 @@ TRACKBAR_GetTicPos (TRACKBAR_INFO *infoPtr, INT iTic) ...@@ -967,8 +973,9 @@ TRACKBAR_GetTicPos (TRACKBAR_INFO *infoPtr, INT iTic)
tic = TRACKBAR_GetTic (infoPtr, iTic); tic = TRACKBAR_GetTic (infoPtr, iTic);
range = infoPtr->lRangeMax - infoPtr->lRangeMin; range = infoPtr->lRangeMax - infoPtr->lRangeMin;
if (range <= 0) range = 1; if (range <= 0) range = 1;
width = infoPtr->rcChannel.right - infoPtr->rcChannel.left; offsetthumb = (infoPtr->rcThumb.right - infoPtr->rcThumb.left)/2;
pos = infoPtr->rcChannel.left + (width * tic) / range; width = infoPtr->rcChannel.right - infoPtr->rcChannel.left - offsetthumb*2;
pos = infoPtr->rcChannel.left + offsetthumb + (width * tic) / range;
return pos; return pos;
} }
...@@ -1247,15 +1254,15 @@ TRACKBAR_InitializeThumb (TRACKBAR_INFO *infoPtr) ...@@ -1247,15 +1254,15 @@ TRACKBAR_InitializeThumb (TRACKBAR_INFO *infoPtr)
int clientWidth, clientMetric; int clientWidth, clientMetric;
/* initial thumb length */ /* initial thumb length */
clientMetric = GetSystemMetrics(SM_CYCAPTION); clientMetric = (dwStyle & TBS_ENABLESELRANGE) ? 23 : 21;
GetClientRect(infoPtr->hwndSelf,&rect); GetClientRect(infoPtr->hwndSelf,&rect);
if (dwStyle & TBS_VERT) { if (dwStyle & TBS_VERT) {
clientWidth = rect.right - rect.left; clientWidth = rect.right - rect.left;
} else { } else {
clientWidth = rect.bottom - rect.top; clientWidth = rect.bottom - rect.top;
} }
if (clientWidth > clientMetric) if (clientWidth >= clientMetric)
infoPtr->uThumbLen = clientMetric + 1; infoPtr->uThumbLen = clientMetric;
else else
infoPtr->uThumbLen = clientWidth > 9 ? clientWidth - 6 : 4; infoPtr->uThumbLen = clientWidth > 9 ? clientWidth - 6 : 4;
......
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