Author: mkupfer Date: Mon Jun 29 15:23:10 2009 New Revision: 41682
URL: http://svn.reactos.org/svn/reactos?rev=41682&view=rev Log: - minor improvements in drawing - remarks for problems and further changes
Modified: trunk/reactos/dll/win32/user32/windows/draw.c
Modified: trunk/reactos/dll/win32/user32/windows/draw.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/dr... ============================================================================== --- trunk/reactos/dll/win32/user32/windows/draw.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/windows/draw.c [iso-8859-1] Mon Jun 29 15:23:10 2009 @@ -5,6 +5,7 @@ * Copyright 2001 Casper S. Hournstroup * Copyright 2003 Andrew Greenwood * Copyright 2003 Filip Navara + * Copyright 2009 Matthias Kupfer * * Based on Wine code. * @@ -650,6 +651,9 @@ * Does a pretty good job in emulating MS behavior. Some quirks are * however there because MS uses a TrueType font (Marlett) to draw * the buttons. + * + * FIXME: This looks a little bit strange, needs to be rewritten completely + * (several quirks with adjust, DFCS_CHECKED aso) */ static BOOL UITOOLS95_DFC_ButtonPush(HDC dc, LPRECT r, UINT uFlags) { @@ -814,7 +818,6 @@
static BOOL UITOOLS95_DrawFrameCaption(HDC dc, LPRECT r, UINT uFlags) { - int colorIdx = uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_BTNTEXT; LOGFONT lf; HFONT hFont, hOldFont; COLORREF clrsave; @@ -841,6 +844,161 @@ default: return FALSE; } + IntDrawRectEdge(dc,r,(uFlags&DFCS_PUSHED) ? EDGE_SUNKEN : EDGE_RAISED, BF_RECT | BF_MIDDLE | BF_SOFT); + ZeroMemory(&lf, sizeof(LOGFONT)); + UITOOLS_MakeSquareRect(r, &myr); + myr.left += 1; + myr.top += 1; + myr.right -= 1; + myr.bottom -= 1; + if(uFlags & DFCS_PUSHED) + OffsetRect(&myr,1,1); + lf.lfHeight = myr.bottom - myr.top; + lf.lfWidth = 0; + lf.lfWeight = FW_NORMAL; + lf.lfCharSet = DEFAULT_CHARSET; + lstrcpy(lf.lfFaceName, TEXT("Marlett")); + hFont = CreateFontIndirect(&lf); + /* save font and text color */ + hOldFont = SelectObject(dc, hFont); + clrsave = GetTextColor(dc); + bkmode = GetBkMode(dc); + /* set color and drawing mode */ + SetBkMode(dc, TRANSPARENT); + if(uFlags & DFCS_INACTIVE) + { + /* draw shadow */ + SetTextColor(dc, GetSysColor(COLOR_BTNHIGHLIGHT)); + TextOut(dc, myr.left + 1, myr.top + 1, &Symbol, 1); + } + SetTextColor(dc, GetSysColor((uFlags & DFCS_INACTIVE) ? COLOR_BTNSHADOW : COLOR_BTNTEXT)); + /* draw selected symbol */ + TextOut(dc, myr.left, myr.top, &Symbol, 1); + /* restore previous settings */ + SetTextColor(dc, clrsave); + SelectObject(dc, hOldFont); + SetBkMode(dc, bkmode); + DeleteObject(hFont); + return TRUE; +} + +static BOOL UITOOLS95_DrawFrameScroll(HDC dc, LPRECT r, UINT uFlags) +{ + LOGFONT lf; + HFONT hFont, hOldFont; + COLORREF clrsave; + RECT myr; + INT bkmode; + TCHAR Symbol; + // for scrollgripsize + POINT Line[4]; + int SmallDiam = UITOOLS_MakeSquareRect(r, &myr) - 2; + int i; + HBRUSH hbsave; + HPEN hpsave; + COLORREF crPen1, crPen2, crBrush1, crBrush2; + int d46, d93; + // end scrollgripsize + switch(uFlags & 0xff) + { + case DFCS_SCROLLCOMBOBOX: + case DFCS_SCROLLDOWN: + Symbol = '6'; + break; + + case DFCS_SCROLLUP: + Symbol = '5'; + break; + + case DFCS_SCROLLLEFT: + Symbol = '3'; + break; + + case DFCS_SCROLLRIGHT: + Symbol = '4'; + break; + + case DFCS_SCROLLSIZEGRIP: + // FIXME: needs to use marlett too, copied for compatibility only + /* This one breaks the flow... */ + IntDrawRectEdge(dc, r, EDGE_BUMP, BF_MIDDLE | ((uFlags&(DFCS_MONO|DFCS_FLAT)) ? BF_MONO : 0)); + hpsave = (HPEN)SelectObject(dc, GetStockObject(DC_PEN)); + hbsave = (HBRUSH)SelectObject(dc, GetStockObject(DC_BRUSH)); + if(uFlags & (DFCS_MONO|DFCS_FLAT)) + { + crPen1 = crPen2 = GetSysColor(COLOR_WINDOWFRAME); + crBrush1 = crBrush2 = GetSysColor(COLOR_WINDOWFRAME); + } + else + { + crPen1 = GetSysColor(COLOR_BTNHIGHLIGHT); + crPen2 = GetSysColor(COLOR_BTNSHADOW); + crBrush1 = GetSysColor(COLOR_BTNHIGHLIGHT); + crBrush2 = GetSysColor(COLOR_BTNSHADOW); + } + + Line[0].x = Line[1].x = r->right-1; + Line[2].y = Line[3].y = r->bottom-1; + d46 = 46*SmallDiam/750; + d93 = 93*SmallDiam/750; + + i = 586*SmallDiam/750; + Line[0].y = r->bottom - i - 1; + Line[3].x = r->right - i - 1; + Line[1].y = Line[0].y + d46; + Line[2].x = Line[3].x + d46; + SetDCBrushColor(dc, crBrush1); + SetDCPenColor(dc, crPen1); + Polygon(dc, Line, 4); + + Line[1].y++; Line[2].x++; + Line[0].y = Line[1].y + d93; + Line[3].x = Line[2].x + d93; + SetDCBrushColor(dc, crBrush2); + SetDCPenColor(dc, crPen2); + Polygon(dc, Line, 4); + + i = 398*SmallDiam/750; + Line[0].y = r->bottom - i - 1; + Line[3].x = r->right - i - 1; + Line[1].y = Line[0].y + d46; + Line[2].x = Line[3].x + d46; + SetDCBrushColor(dc, crBrush1); + SetDCPenColor(dc, crPen1); + Polygon(dc, Line, 4); + + Line[1].y++; Line[2].x++; + Line[0].y = Line[1].y + d93; + Line[3].x = Line[2].x + d93; + SetDCBrushColor(dc, crBrush2); + SetDCPenColor(dc, crPen2); + Polygon(dc, Line, 4); + + i = 210*SmallDiam/750; + Line[0].y = r->bottom - i - 1; + Line[3].x = r->right - i - 1; + Line[1].y = Line[0].y + d46; + Line[2].x = Line[3].x + d46; + SetDCBrushColor(dc, crBrush1); + SetDCPenColor(dc, crPen1); + Polygon(dc, Line, 4); + + Line[1].y++; Line[2].x++; + Line[0].y = Line[1].y + d93; + Line[3].x = Line[2].x + d93; + SetDCBrushColor(dc, crBrush2); + SetDCPenColor(dc, crPen2); + Polygon(dc, Line, 4); + + SelectObject(dc, hpsave); + SelectObject(dc, hbsave); + return TRUE; + case DFCS_SCROLLSIZEGRIPRIGHT: + return FALSE; // unimplemented yet + default: + return FALSE; + } + // FIXME: the following edge isn't windows-like if(uFlags & DFCS_PUSHED) IntDrawRectEdge(dc,r,EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_SOFT); else @@ -872,166 +1030,7 @@ SetTextColor(dc, GetSysColor(COLOR_BTNHIGHLIGHT)); TextOut(dc, myr.left + 1, myr.top + 1, &Symbol, 1); } - SetTextColor(dc, GetSysColor(colorIdx)); - /* draw selected symbol */ - TextOut(dc, myr.left, myr.top, &Symbol, 1); - /* restore previous settings */ - SetTextColor(dc, clrsave); - SelectObject(dc, hOldFont); - SetBkMode(dc, bkmode); - DeleteObject(hFont); - return TRUE; -} - -static BOOL UITOOLS95_DrawFrameScroll(HDC dc, LPRECT r, UINT uFlags) -{ - int colorIdx = uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_BTNTEXT; - LOGFONT lf; - HFONT hFont, hOldFont; - COLORREF clrsave; - RECT myr; - INT bkmode; - TCHAR Symbol; - // for scrollgripsize - POINT Line[4]; - int SmallDiam = UITOOLS_MakeSquareRect(r, &myr) - 2; - int i; - HBRUSH hbsave; - HPEN hpsave; - COLORREF crPen1, crPen2, crBrush1, crBrush2; - int d46, d93; - // end scrollgripsize - switch(uFlags & 0xff) - { - case DFCS_SCROLLCOMBOBOX: - case DFCS_SCROLLDOWN: - Symbol = '6'; - break; - - case DFCS_SCROLLUP: - Symbol = '5'; - break; - - case DFCS_SCROLLLEFT: - Symbol = '3'; - break; - - case DFCS_SCROLLRIGHT: - Symbol = '4'; - break; - - case DFCS_SCROLLSIZEGRIP: - // FIXME: needs to use marlett too, copied for compatibility only - /* This one breaks the flow... */ - IntDrawRectEdge(dc, r, EDGE_BUMP, BF_MIDDLE | ((uFlags&(DFCS_MONO|DFCS_FLAT)) ? BF_MONO : 0)); - hpsave = (HPEN)SelectObject(dc, GetStockObject(DC_PEN)); - hbsave = (HBRUSH)SelectObject(dc, GetStockObject(DC_BRUSH)); - if(uFlags & (DFCS_MONO|DFCS_FLAT)) - { - crPen1 = crPen2 = GetSysColor(COLOR_WINDOWFRAME); - crBrush1 = crBrush2 = GetSysColor(COLOR_WINDOWFRAME); - } - else - { - crPen1 = GetSysColor(COLOR_BTNHIGHLIGHT); - crPen2 = GetSysColor(COLOR_BTNSHADOW); - crBrush1 = GetSysColor(COLOR_BTNHIGHLIGHT); - crBrush2 = GetSysColor(COLOR_BTNSHADOW); - } - - Line[0].x = Line[1].x = r->right-1; - Line[2].y = Line[3].y = r->bottom-1; - d46 = 46*SmallDiam/750; - d93 = 93*SmallDiam/750; - - i = 586*SmallDiam/750; - Line[0].y = r->bottom - i - 1; - Line[3].x = r->right - i - 1; - Line[1].y = Line[0].y + d46; - Line[2].x = Line[3].x + d46; - SetDCBrushColor(dc, crBrush1); - SetDCPenColor(dc, crPen1); - Polygon(dc, Line, 4); - - Line[1].y++; Line[2].x++; - Line[0].y = Line[1].y + d93; - Line[3].x = Line[2].x + d93; - SetDCBrushColor(dc, crBrush2); - SetDCPenColor(dc, crPen2); - Polygon(dc, Line, 4); - - i = 398*SmallDiam/750; - Line[0].y = r->bottom - i - 1; - Line[3].x = r->right - i - 1; - Line[1].y = Line[0].y + d46; - Line[2].x = Line[3].x + d46; - SetDCBrushColor(dc, crBrush1); - SetDCPenColor(dc, crPen1); - Polygon(dc, Line, 4); - - Line[1].y++; Line[2].x++; - Line[0].y = Line[1].y + d93; - Line[3].x = Line[2].x + d93; - SetDCBrushColor(dc, crBrush2); - SetDCPenColor(dc, crPen2); - Polygon(dc, Line, 4); - - i = 210*SmallDiam/750; - Line[0].y = r->bottom - i - 1; - Line[3].x = r->right - i - 1; - Line[1].y = Line[0].y + d46; - Line[2].x = Line[3].x + d46; - SetDCBrushColor(dc, crBrush1); - SetDCPenColor(dc, crPen1); - Polygon(dc, Line, 4); - - Line[1].y++; Line[2].x++; - Line[0].y = Line[1].y + d93; - Line[3].x = Line[2].x + d93; - SetDCBrushColor(dc, crBrush2); - SetDCPenColor(dc, crPen2); - Polygon(dc, Line, 4); - - SelectObject(dc, hpsave); - SelectObject(dc, hbsave); - return TRUE; - case DFCS_SCROLLSIZEGRIPRIGHT: - return FALSE; // unimplemented yet - default: - return FALSE; - } - if(uFlags & DFCS_PUSHED) - IntDrawRectEdge(dc,r,EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_SOFT); - else - IntDrawRectEdge(dc,r,BDR_RAISEDINNER | BDR_RAISEDOUTER, BF_RECT | - BF_SOFT | BF_MIDDLE); - ZeroMemory(&lf, sizeof(LOGFONT)); - UITOOLS_MakeSquareRect(r, &myr); - myr.left += 1; - myr.top += 1; - myr.right -= 1; - myr.bottom -= 1; - if(uFlags & DFCS_PUSHED) - OffsetRect(&myr,1,1); - lf.lfHeight = myr.bottom - myr.top; - lf.lfWidth = 0; - lf.lfWeight = FW_NORMAL; - lf.lfCharSet = DEFAULT_CHARSET; - lstrcpy(lf.lfFaceName, TEXT("Marlett")); - hFont = CreateFontIndirect(&lf); - /* save font and text color */ - hOldFont = SelectObject(dc, hFont); - clrsave = GetTextColor(dc); - bkmode = GetBkMode(dc); - /* set color and drawing mode */ - SetBkMode(dc, TRANSPARENT); - if(uFlags & DFCS_INACTIVE) - { - /* draw shadow */ - SetTextColor(dc, GetSysColor(COLOR_BTNHIGHLIGHT)); - TextOut(dc, myr.left + 1, myr.top + 1, &Symbol, 1); - } - SetTextColor(dc, GetSysColor(colorIdx)); + SetTextColor(dc, GetSysColor((uFlags & DFCS_INACTIVE) ? COLOR_BTNSHADOW : COLOR_BTNTEXT)); /* draw selected symbol */ TextOut(dc, myr.left, myr.top, &Symbol, 1); /* restore previous settings */ @@ -1081,6 +1080,13 @@ hFont = CreateFontIndirect(&lf); /* save font */ hOldFont = SelectObject(dc, hFont); + if(uFlags & DFCS_INACTIVE) + { + /* draw shadow */ + SetTextColor(dc, GetSysColor(COLOR_BTNHIGHLIGHT)); + TextOut(dc, r->left + 1, r->top + 1, &Symbol, 1); + } + SetTextColor(dc, GetSysColor((uFlags & DFCS_INACTIVE) ? COLOR_BTNSHADOW : COLOR_BTNTEXT)); /* draw selected symbol */ TextOut(dc, r->left, r->top, &Symbol, 1); /* restore previous settings */