mirror of
https://github.com/reactos/reactos.git
synced 2024-12-30 19:14:31 +00:00
use GradientFill() for gradient captions
svn path=/trunk/; revision=8116
This commit is contained in:
parent
8336410c76
commit
8fe4a9e38d
2 changed files with 31 additions and 79 deletions
|
@ -1084,12 +1084,10 @@ DrawCaption(HWND hWnd, HDC hDC, LPCRECT lprc, UINT uFlags)
|
||||||
{
|
{
|
||||||
if (uFlags & DC_GRADIENT)
|
if (uFlags & DC_GRADIENT)
|
||||||
{
|
{
|
||||||
|
static GRADIENT_RECT gcap = {0, 1};
|
||||||
|
TRIVERTEX vert[2];
|
||||||
COLORREF Colors[2];
|
COLORREF Colors[2];
|
||||||
BYTE cr[3], cg[3], cb[3];
|
LONG xx;
|
||||||
LONG xx, wd, wdh;
|
|
||||||
POINT OldPoint;
|
|
||||||
HPEN Pen;
|
|
||||||
HGDIOBJ OldObj;
|
|
||||||
|
|
||||||
r.right = (lprc->right - lprc->left);
|
r.right = (lprc->right - lprc->left);
|
||||||
if (uFlags & DC_SMALLCAP)
|
if (uFlags & DC_SMALLCAP)
|
||||||
|
@ -1125,42 +1123,24 @@ DrawCaption(HWND hWnd, HDC hDC, LPCRECT lprc, UINT uFlags)
|
||||||
UserDrawSysMenuButton(hWnd, MemDC, &r);
|
UserDrawSysMenuButton(hWnd, MemDC, &r);
|
||||||
r.top ++;
|
r.top ++;
|
||||||
r.left += xx;
|
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];
|
|
||||||
|
|
||||||
wd = r.right - r.left;
|
|
||||||
wdh = wd / 2;
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
GdiGradientFill(MemDC, vert, 2, &gcap, 1, GRADIENT_FILL_RECT_H);
|
||||||
|
|
||||||
if(OldBrush)
|
if(OldBrush)
|
||||||
{
|
{
|
||||||
SelectObject(MemDC, OldBrush);
|
SelectObject(MemDC, OldBrush);
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* 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
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -88,6 +88,8 @@ IntEngGradientFillRect(
|
||||||
IN POINTL *pptlDitherOrg,
|
IN POINTL *pptlDitherOrg,
|
||||||
IN BOOL Horizontal)
|
IN BOOL Horizontal)
|
||||||
{
|
{
|
||||||
|
SURFOBJ *OutputObj;
|
||||||
|
SURFGDI *OutputGDI;
|
||||||
TRIVERTEX *v1, *v2;
|
TRIVERTEX *v1, *v2;
|
||||||
RECT rcGradient, rcSG;
|
RECT rcGradient, rcSG;
|
||||||
RECT_ENUM RectEnum;
|
RECT_ENUM RectEnum;
|
||||||
|
@ -116,14 +118,18 @@ IntEngGradientFillRect(
|
||||||
dy = abs(rcGradient.bottom - rcGradient.top);
|
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)
|
if((v1->Red != v2->Red || v1->Green != v2->Green || v1->Blue != v2->Blue) && dy > 1)
|
||||||
{
|
{
|
||||||
CLIPOBJ_cEnumStart(pco, FALSE, CT_RECTANGLES, CD_RIGHTDOWN, 0);
|
CLIPOBJ_cEnumStart(pco, FALSE, CT_RECTANGLES, CD_RIGHTDOWN, 0);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
RECT FillRect;
|
RECT FillRect;
|
||||||
SURFOBJ *OutputObj;
|
|
||||||
SURFGDI *OutputGDI;
|
|
||||||
ULONG Color;
|
ULONG Color;
|
||||||
|
|
||||||
if(Horizontal)
|
if(Horizontal)
|
||||||
|
@ -136,11 +142,6 @@ IntEngGradientFillRect(
|
||||||
HVINITCOL(Red, 0);
|
HVINITCOL(Red, 0);
|
||||||
HVINITCOL(Green, 1);
|
HVINITCOL(Green, 1);
|
||||||
HVINITCOL(Blue, 2);
|
HVINITCOL(Blue, 2);
|
||||||
if(!IntEngEnter(&EnterLeave, psoDest, &FillRect, FALSE, &Translate, &OutputObj))
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
OutputGDI = AccessInternalObjectFromUserObject(OutputObj);
|
|
||||||
|
|
||||||
for(y = rcSG.left; y < FillRect.right; y++)
|
for(y = rcSG.left; y < FillRect.right; y++)
|
||||||
{
|
{
|
||||||
|
@ -153,11 +154,6 @@ IntEngGradientFillRect(
|
||||||
HVSTEPCOL(1);
|
HVSTEPCOL(1);
|
||||||
HVSTEPCOL(2);
|
HVSTEPCOL(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!IntEngLeave(&EnterLeave))
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,11 +169,6 @@ IntEngGradientFillRect(
|
||||||
HVINITCOL(Red, 0);
|
HVINITCOL(Red, 0);
|
||||||
HVINITCOL(Green, 1);
|
HVINITCOL(Green, 1);
|
||||||
HVINITCOL(Blue, 2);
|
HVINITCOL(Blue, 2);
|
||||||
if(!IntEngEnter(&EnterLeave, psoDest, &FillRect, FALSE, &Translate, &OutputObj))
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
OutputGDI = AccessInternalObjectFromUserObject(OutputObj);
|
|
||||||
|
|
||||||
for(y = rcSG.top; y < FillRect.bottom; y++)
|
for(y = rcSG.top; y < FillRect.bottom; y++)
|
||||||
{
|
{
|
||||||
|
@ -190,17 +181,12 @@ IntEngGradientFillRect(
|
||||||
HVSTEPCOL(1);
|
HVSTEPCOL(1);
|
||||||
HVSTEPCOL(2);
|
HVSTEPCOL(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!IntEngLeave(&EnterLeave))
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} while(EnumMore);
|
} while(EnumMore);
|
||||||
|
|
||||||
return TRUE;
|
return IntEngLeave(&EnterLeave);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* rectangle has only one color, no calculation required */
|
/* rectangle has only one color, no calculation required */
|
||||||
|
@ -208,8 +194,6 @@ IntEngGradientFillRect(
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
RECT FillRect;
|
RECT FillRect;
|
||||||
SURFOBJ *OutputObj;
|
|
||||||
SURFGDI *OutputGDI;
|
|
||||||
ULONG Color = XLATEOBJ_iXlate(pxlo, RGB(v1->Red, v1->Green, v1->Blue));
|
ULONG Color = XLATEOBJ_iXlate(pxlo, RGB(v1->Red, v1->Green, v1->Blue));
|
||||||
|
|
||||||
EnumMore = CLIPOBJ_bEnum(pco, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
|
EnumMore = CLIPOBJ_bEnum(pco, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
|
||||||
|
@ -217,27 +201,15 @@ IntEngGradientFillRect(
|
||||||
{
|
{
|
||||||
if(NtGdiIntersectRect(&FillRect, &RectEnum.arcl[i], &rcSG))
|
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++)
|
for(; FillRect.top < FillRect.bottom; FillRect.top++)
|
||||||
{
|
{
|
||||||
OutputGDI->DIB_HLine(OutputObj, FillRect.left, FillRect.right, FillRect.top, Color);
|
OutputGDI->DIB_HLine(OutputObj, FillRect.left, FillRect.right, FillRect.top, Color);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!IntEngLeave(&EnterLeave))
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while(EnumMore);
|
} while(EnumMore);
|
||||||
|
|
||||||
return TRUE;
|
return IntEngLeave(&EnterLeave);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NLINES 3
|
#define NLINES 3
|
||||||
|
|
Loading…
Reference in a new issue