Commit f3b8e682 authored by Alexandre Julliard's avatar Alexandre Julliard

comctl32/pager: Use DrawFrameControl to paint the buttons.

parent 1aa15750
......@@ -84,9 +84,6 @@ typedef struct
INT direction; /* direction of the scroll, (e.g. PGF_SCROLLUP) */
} PAGER_INFO;
#define MIN_ARROW_WIDTH 8
#define MIN_ARROW_HEIGHT 5
#define TIMERID1 1
#define TIMERID2 2
#define INITIAL_DELAY 500
......@@ -116,115 +113,13 @@ PAGER_GetButtonRects(const PAGER_INFO* infoPtr, RECT* prcTopLeft, RECT* prcBotto
}
}
/* the horizontal arrows are:
*
* 01234 01234
* 1 * *
* 2 ** **
* 3*** ***
* 4*** ***
* 5 ** **
* 6 * *
* 7
*
*/
static void
PAGER_DrawHorzArrow (HDC hdc, RECT r, INT colorRef, BOOL left)
{
INT x, y, w, h;
HPEN hPen, hOldPen;
w = r.right - r.left + 1;
h = r.bottom - r.top + 1;
if ((h < MIN_ARROW_WIDTH) || (w < MIN_ARROW_HEIGHT))
return; /* refuse to draw partial arrow */
if (!(hPen = CreatePen( PS_SOLID, 1, GetSysColor( colorRef )))) return;
hOldPen = SelectObject ( hdc, hPen );
if (left)
{
x = r.left + ((w - MIN_ARROW_HEIGHT) / 2) + 3;
y = r.top + ((h - MIN_ARROW_WIDTH) / 2) + 1;
MoveToEx (hdc, x, y, NULL);
LineTo (hdc, x--, y+5); y++;
MoveToEx (hdc, x, y, NULL);
LineTo (hdc, x--, y+3); y++;
MoveToEx (hdc, x, y, NULL);
LineTo (hdc, x, y+1);
}
else
{
x = r.left + ((w - MIN_ARROW_HEIGHT) / 2) + 1;
y = r.top + ((h - MIN_ARROW_WIDTH) / 2) + 1;
MoveToEx (hdc, x, y, NULL);
LineTo (hdc, x++, y+5); y++;
MoveToEx (hdc, x, y, NULL);
LineTo (hdc, x++, y+3); y++;
MoveToEx (hdc, x, y, NULL);
LineTo (hdc, x, y+1);
}
SelectObject( hdc, hOldPen );
DeleteObject( hPen );
}
/* the vertical arrows are:
*
* 01234567 01234567
* 1****** **
* 2 **** ****
* 3 ** ******
* 4
*
*/
static void
PAGER_DrawVertArrow (HDC hdc, RECT r, INT colorRef, BOOL up)
{
INT x, y, w, h;
HPEN hPen, hOldPen;
w = r.right - r.left + 1;
h = r.bottom - r.top + 1;
if ((h < MIN_ARROW_WIDTH) || (w < MIN_ARROW_HEIGHT))
return; /* refuse to draw partial arrow */
if (!(hPen = CreatePen( PS_SOLID, 1, GetSysColor( colorRef )))) return;
hOldPen = SelectObject ( hdc, hPen );
if (up)
{
x = r.left + ((w - MIN_ARROW_HEIGHT) / 2) + 1;
y = r.top + ((h - MIN_ARROW_WIDTH) / 2) + 3;
MoveToEx (hdc, x, y, NULL);
LineTo (hdc, x+5, y--); x++;
MoveToEx (hdc, x, y, NULL);
LineTo (hdc, x+3, y--); x++;
MoveToEx (hdc, x, y, NULL);
LineTo (hdc, x+1, y);
}
else
{
x = r.left + ((w - MIN_ARROW_HEIGHT) / 2) + 1;
y = r.top + ((h - MIN_ARROW_WIDTH) / 2) + 1;
MoveToEx (hdc, x, y, NULL);
LineTo (hdc, x+5, y++); x++;
MoveToEx (hdc, x, y, NULL);
LineTo (hdc, x+3, y++); x++;
MoveToEx (hdc, x, y, NULL);
LineTo (hdc, x+1, y);
}
SelectObject( hdc, hOldPen );
DeleteObject( hPen );
}
static void
PAGER_DrawButton(HDC hdc, COLORREF clrBk, RECT arrowRect,
PAGER_DrawButton(HDC hdc, COLORREF clrBk, RECT rc,
BOOL horz, BOOL topLeft, INT btnState)
{
HBRUSH hBrush, hOldBrush;
RECT rc = arrowRect;
UINT flags;
TRACE("arrowRect = %s, btnState = %d\n", wine_dbgstr_rect(&arrowRect), btnState);
TRACE("rc = %s, btnState = %d\n", wine_dbgstr_rect(&rc), btnState);
if (btnState == PGF_INVISIBLE)
return;
......@@ -232,54 +127,26 @@ PAGER_DrawButton(HDC hdc, COLORREF clrBk, RECT arrowRect,
if ((rc.right - rc.left <= 0) || (rc.bottom - rc.top <= 0))
return;
hBrush = CreateSolidBrush(clrBk);
hOldBrush = SelectObject(hdc, hBrush);
FillRect(hdc, &rc, hBrush);
if (horz)
flags = topLeft ? DFCS_SCROLLLEFT : DFCS_SCROLLRIGHT;
else
flags = topLeft ? DFCS_SCROLLUP : DFCS_SCROLLDOWN;
if (btnState == PGF_HOT)
switch (btnState)
{
DrawEdge( hdc, &rc, BDR_RAISEDINNER, BF_RECT);
if (horz)
PAGER_DrawHorzArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
else
PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
}
else if (btnState == PGF_NORMAL)
{
DrawEdge (hdc, &rc, BDR_OUTER, BF_FLAT);
if (horz)
PAGER_DrawHorzArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
else
PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
}
else if (btnState == PGF_DEPRESSED)
{
DrawEdge( hdc, &rc, BDR_SUNKENOUTER, BF_RECT);
if (horz)
PAGER_DrawHorzArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
else
PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
}
else if (btnState == PGF_GRAYED)
{
DrawEdge (hdc, &rc, BDR_OUTER, BF_FLAT);
if (horz)
{
PAGER_DrawHorzArrow(hdc, rc, COLOR_3DHIGHLIGHT, topLeft);
rc.left++, rc.top++; rc.right++, rc.bottom++;
PAGER_DrawHorzArrow(hdc, rc, COLOR_3DSHADOW, topLeft);
}
else
{
PAGER_DrawVertArrow(hdc, rc, COLOR_3DHIGHLIGHT, topLeft);
rc.left++, rc.top++; rc.right++, rc.bottom++;
PAGER_DrawVertArrow(hdc, rc, COLOR_3DSHADOW, topLeft);
}
case PGF_HOT:
break;
case PGF_NORMAL:
flags |= DFCS_FLAT;
break;
case PGF_DEPRESSED:
flags |= DFCS_PUSHED;
break;
case PGF_GRAYED:
flags |= DFCS_INACTIVE | DFCS_FLAT;
break;
}
SelectObject( hdc, hOldBrush );
DeleteObject(hBrush);
DrawFrameControl( hdc, &rc, DFC_SCROLL, flags );
}
/* << PAGER_GetDropTarget >> */
......
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