use GradientFill() for gradient captions

svn path=/trunk/; revision=8116
This commit is contained in:
Thomas Bluemel 2004-02-09 16:37:59 +00:00
parent 8336410c76
commit 8fe4a9e38d
2 changed files with 31 additions and 79 deletions

View file

@ -1084,12 +1084,10 @@ DrawCaption(HWND hWnd, HDC hDC, LPCRECT lprc, UINT uFlags)
{
if (uFlags & DC_GRADIENT)
{
static GRADIENT_RECT gcap = {0, 1};
TRIVERTEX vert[2];
COLORREF Colors[2];
BYTE cr[3], cg[3], cb[3];
LONG xx, wd, wdh;
POINT OldPoint;
HPEN Pen;
HGDIOBJ OldObj;
LONG xx;
r.right = (lprc->right - lprc->left);
if (uFlags & DC_SMALLCAP)
@ -1127,39 +1125,21 @@ DrawCaption(HWND hWnd, HDC hDC, LPCRECT lprc, UINT uFlags)
r.left += xx;
}
cr[1] = GetRValue(Colors[0]);
cg[1] = GetGValue(Colors[0]);
cb[1] = GetBValue(Colors[0]);
cr[2] = GetRValue(Colors[1]) - cr[1];
cg[2] = GetGValue(Colors[1]) - cg[1];
cb[2] = GetBValue(Colors[1]) - cb[1];
vert[0].x = r.left;
vert[0].y = 0;
vert[0].Red = GetRValue(Colors[0]) << 8;
vert[0].Green = GetGValue(Colors[0]) << 8;
vert[0].Blue = GetBValue(Colors[0]) << 8;
vert[0].Alpha = 0;
wd = r.right - r.left;
wdh = wd / 2;
vert[1].x = r.right;
vert[1].y = lprc->bottom - lprc->top;
vert[1].Red = GetRValue(Colors[1]) << 8;
vert[1].Green = GetGValue(Colors[1]) << 8;
vert[1].Blue = GetBValue(Colors[1]) << 8;
vert[1].Alpha = 0;
if(wd > 0)
{
MoveToEx(MemDC, 0, 0, &OldPoint);
for(xx = 0; xx < wd; xx++)
{
cr[0] = (cr[1] + ((cr[2] * xx) + wdh) / wd);
cg[0] = (cg[1] + ((cg[2] * xx) + wdh) / wd);
cb[0] = (cb[1] + ((cb[2] * xx) + wdh) / wd);
Pen = CreatePen(PS_SOLID, 0, RGB(cr[0], cg[0], cb[0]));
if(!Pen)
{
break;
}
OldObj = SelectObject(MemDC, Pen);
MoveToEx(MemDC, r.left + xx, 0, NULL);
LineTo(MemDC, r.left + xx, lprc->bottom - lprc->top);
if(OldObj)
SelectObject(MemDC, OldObj);
DeleteObject(Pen);
}
MoveToEx(MemDC, OldPoint.x, OldPoint.y, NULL);
}
GdiGradientFill(MemDC, vert, 2, &gcap, 1, GRADIENT_FILL_RECT_H);
if(OldBrush)
{

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: gradient.c,v 1.2 2004/02/09 15:33:30 weiden Exp $
/* $Id: gradient.c,v 1.3 2004/02/09 16:37:59 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -88,6 +88,8 @@ IntEngGradientFillRect(
IN POINTL *pptlDitherOrg,
IN BOOL Horizontal)
{
SURFOBJ *OutputObj;
SURFGDI *OutputGDI;
TRIVERTEX *v1, *v2;
RECT rcGradient, rcSG;
RECT_ENUM RectEnum;
@ -116,14 +118,18 @@ IntEngGradientFillRect(
dy = abs(rcGradient.bottom - rcGradient.top);
}
if(!IntEngEnter(&EnterLeave, psoDest, &rcSG, FALSE, &Translate, &OutputObj))
{
return FALSE;
}
OutputGDI = AccessInternalObjectFromUserObject(OutputObj);
if((v1->Red != v2->Red || v1->Green != v2->Green || v1->Blue != v2->Blue) && dy > 1)
{
CLIPOBJ_cEnumStart(pco, FALSE, CT_RECTANGLES, CD_RIGHTDOWN, 0);
do
{
RECT FillRect;
SURFOBJ *OutputObj;
SURFGDI *OutputGDI;
ULONG Color;
if(Horizontal)
@ -136,11 +142,6 @@ IntEngGradientFillRect(
HVINITCOL(Red, 0);
HVINITCOL(Green, 1);
HVINITCOL(Blue, 2);
if(!IntEngEnter(&EnterLeave, psoDest, &FillRect, FALSE, &Translate, &OutputObj))
{
return FALSE;
}
OutputGDI = AccessInternalObjectFromUserObject(OutputObj);
for(y = rcSG.left; y < FillRect.right; y++)
{
@ -153,11 +154,6 @@ IntEngGradientFillRect(
HVSTEPCOL(1);
HVSTEPCOL(2);
}
if(!IntEngLeave(&EnterLeave))
{
return FALSE;
}
}
}
@ -173,11 +169,6 @@ IntEngGradientFillRect(
HVINITCOL(Red, 0);
HVINITCOL(Green, 1);
HVINITCOL(Blue, 2);
if(!IntEngEnter(&EnterLeave, psoDest, &FillRect, FALSE, &Translate, &OutputObj))
{
return FALSE;
}
OutputGDI = AccessInternalObjectFromUserObject(OutputObj);
for(y = rcSG.top; y < FillRect.bottom; y++)
{
@ -190,17 +181,12 @@ IntEngGradientFillRect(
HVSTEPCOL(1);
HVSTEPCOL(2);
}
if(!IntEngLeave(&EnterLeave))
{
return FALSE;
}
}
}
} while(EnumMore);
return TRUE;
return IntEngLeave(&EnterLeave);
}
/* rectangle has only one color, no calculation required */
@ -208,8 +194,6 @@ IntEngGradientFillRect(
do
{
RECT FillRect;
SURFOBJ *OutputObj;
SURFGDI *OutputGDI;
ULONG Color = XLATEOBJ_iXlate(pxlo, RGB(v1->Red, v1->Green, v1->Blue));
EnumMore = CLIPOBJ_bEnum(pco, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
@ -217,27 +201,15 @@ IntEngGradientFillRect(
{
if(NtGdiIntersectRect(&FillRect, &RectEnum.arcl[i], &rcSG))
{
if(!IntEngEnter(&EnterLeave, psoDest, &FillRect, FALSE, &Translate, &OutputObj))
{
return FALSE;
}
OutputGDI = AccessInternalObjectFromUserObject(OutputObj);
for(; FillRect.top < FillRect.bottom; FillRect.top++)
{
OutputGDI->DIB_HLine(OutputObj, FillRect.left, FillRect.right, FillRect.top, Color);
}
if(!IntEngLeave(&EnterLeave))
{
return FALSE;
}
}
}
} while(EnumMore);
return TRUE;
return IntEngLeave(&EnterLeave);
}
#define NLINES 3