mirror of
https://github.com/reactos/reactos.git
synced 2024-08-08 04:08:29 +00:00
More work on DrawStateA/DrawStateW. They are still both incomplete, and only really work for DSS_NORMAL and DST_TEXT at the moment. Button text drawing appears to be broken (window state is always disabled for some reason.)
svn path=/trunk/; revision=5621
This commit is contained in:
parent
17412a6d95
commit
04bd392176
|
@ -936,6 +936,7 @@ extern "C" {
|
||||||
#define DSS_UNION (16)
|
#define DSS_UNION (16)
|
||||||
#define DSS_DISABLED (32)
|
#define DSS_DISABLED (32)
|
||||||
#define DSS_MONO (128)
|
#define DSS_MONO (128)
|
||||||
|
#define DSS_RIGHT (0x8000) // Undocumented
|
||||||
|
|
||||||
/* DrawStatusText */
|
/* DrawStatusText */
|
||||||
#define SBT_NOBORDERS (256)
|
#define SBT_NOBORDERS (256)
|
||||||
|
|
|
@ -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: draw.c,v 1.20 2003/08/17 02:51:42 silverblade Exp $
|
/* $Id: draw.c,v 1.21 2003/08/17 19:07:11 silverblade Exp $
|
||||||
*
|
*
|
||||||
* PROJECT: ReactOS user32.dll
|
* PROJECT: ReactOS user32.dll
|
||||||
* FILE: lib/user32/windows/input.c
|
* FILE: lib/user32/windows/input.c
|
||||||
|
@ -1606,15 +1606,16 @@ DrawFocusRect(
|
||||||
// are only implemented for DSS_NORMAL and DST_TEXT, although some handling
|
// are only implemented for DSS_NORMAL and DST_TEXT, although some handling
|
||||||
// for DST_BITMAP has been included.
|
// for DST_BITMAP has been included.
|
||||||
|
|
||||||
WINBOOL DrawStateDraw(HDC hdc, UINT type, DRAWSTATEPROC func, LPARAM lData,
|
WINBOOL INTERNAL_DrawStateDraw(HDC hdc, UINT type, DRAWSTATEPROC lpOutputFunc,
|
||||||
WPARAM wData, LPRECT rc, UINT dtflags, BOOL unicode)
|
LPARAM lData, WPARAM wData, LPRECT rc, UINT dtflags,
|
||||||
|
BOOL unicode)
|
||||||
{
|
{
|
||||||
// HDC MemDC;
|
// HDC MemDC;
|
||||||
// HBITMAP MemBMP;
|
// HBITMAP MemBMP;
|
||||||
BOOL retval = FALSE;
|
BOOL retval = FALSE;
|
||||||
// INT cx = rc->right - rc->left;
|
INT cx = rc->right - rc->left;
|
||||||
// INT cy = rc->bottom - rc->top;
|
INT cy = rc->bottom - rc->top;
|
||||||
|
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case DST_TEXT :
|
case DST_TEXT :
|
||||||
|
@ -1640,8 +1641,16 @@ WINBOOL DrawStateDraw(HDC hdc, UINT type, DRAWSTATEPROC func, LPARAM lData,
|
||||||
|
|
||||||
case DST_COMPLEX :
|
case DST_COMPLEX :
|
||||||
{
|
{
|
||||||
// TODO
|
// Call lpOutputFunc, if necessary
|
||||||
return retval;
|
if (lpOutputFunc)
|
||||||
|
{
|
||||||
|
OffsetViewportOrgEx(hdc, rc->left, rc->top, NULL);
|
||||||
|
retval = lpOutputFunc(hdc, lData, wData, cx, cy);
|
||||||
|
OffsetViewportOrgEx(hdc, -rc->left, -rc->top, NULL);
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1649,7 +1658,7 @@ WINBOOL DrawStateDraw(HDC hdc, UINT type, DRAWSTATEPROC func, LPARAM lData,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
WINBOOL DoDrawState(
|
WINBOOL INTERNAL_DrawState(
|
||||||
HDC hdc,
|
HDC hdc,
|
||||||
HBRUSH hbr,
|
HBRUSH hbr,
|
||||||
DRAWSTATEPROC lpOutputFunc,
|
DRAWSTATEPROC lpOutputFunc,
|
||||||
|
@ -1669,20 +1678,24 @@ WINBOOL DoDrawState(
|
||||||
if ((! lpOutputFunc) && (fuFlags & DST_COMPLEX))
|
if ((! lpOutputFunc) && (fuFlags & DST_COMPLEX))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
UINT type = fuFlags & 0xf;
|
UINT type = fuFlags & 0xf; // DST_xxx
|
||||||
UINT state = fuFlags & 0x7ff0; // Correct?
|
UINT state = fuFlags & 0x7ff0; // DSS_xxx
|
||||||
INT len = wData;
|
INT len = wData; // Data length
|
||||||
RECT rect, subrect;
|
RECT rect;
|
||||||
UINT dtflags = DT_NOCLIP;
|
UINT dtflags = DT_NOCLIP; // Flags for DrawText
|
||||||
BOOL retval = FALSE;
|
BOOL retval = FALSE; // Return value
|
||||||
// HBRUSH ourbrush = NULL;
|
|
||||||
|
|
||||||
// Call lpOutputFunc, if necessary
|
|
||||||
if (((type == DST_COMPLEX) || (type == DST_TEXT)) && (lpOutputFunc))
|
|
||||||
lpOutputFunc(hdc, lData, wData, cx, cy);
|
|
||||||
|
|
||||||
|
|
||||||
DbgPrint("[draw.c] In DrawState()\n");
|
COLORREF ForeColor, // Foreground color
|
||||||
|
BackColor; // Background color
|
||||||
|
|
||||||
|
HDC MemDC = NULL; // Memory DC
|
||||||
|
HBITMAP MemBMP = NULL, // Memory bitmap (for MemDC)
|
||||||
|
OldBMP = NULL; // Old memory bitmap (for MemDC)
|
||||||
|
HFONT Font = NULL; // Old font (for MemDC)
|
||||||
|
HBRUSH OldBrush = NULL, // Old brush (for MemDC)
|
||||||
|
TempBrush = NULL; // Temporary brush (for MemDC)
|
||||||
|
|
||||||
|
DbgPrint("Entered DrawState, fuFlags %d, type %d, state %d\n", fuFlags, type, state);
|
||||||
|
|
||||||
if ((type == DST_TEXT || type == DST_PREFIXTEXT) && ! len)
|
if ((type == DST_TEXT || type == DST_PREFIXTEXT) && ! len)
|
||||||
{
|
{
|
||||||
|
@ -1705,6 +1718,8 @@ WINBOOL DoDrawState(
|
||||||
case DST_TEXT :
|
case DST_TEXT :
|
||||||
case DST_PREFIXTEXT :
|
case DST_PREFIXTEXT :
|
||||||
{
|
{
|
||||||
|
DbgPrint("DST_TEXT / DST_PREFIXTEXT\n");
|
||||||
|
|
||||||
BOOL success;
|
BOOL success;
|
||||||
if (unicode)
|
if (unicode)
|
||||||
success = GetTextExtentPoint32W(hdc, (LPWSTR) lData, len, &s);
|
success = GetTextExtentPoint32W(hdc, (LPWSTR) lData, len, &s);
|
||||||
|
@ -1717,12 +1732,15 @@ WINBOOL DoDrawState(
|
||||||
|
|
||||||
case DST_ICON :
|
case DST_ICON :
|
||||||
{
|
{
|
||||||
|
DbgPrint("DST_ICON\n");
|
||||||
// TODO
|
// TODO
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case DST_BITMAP :
|
case DST_BITMAP :
|
||||||
{
|
{
|
||||||
|
DbgPrint("DST_BITMAP\n");
|
||||||
|
|
||||||
if (!GetObjectA((HBITMAP) lData, sizeof(bm), &bm))
|
if (!GetObjectA((HBITMAP) lData, sizeof(bm), &bm))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -1732,6 +1750,7 @@ WINBOOL DoDrawState(
|
||||||
}
|
}
|
||||||
|
|
||||||
case DST_COMPLEX : // cx and cy must be set in this mode
|
case DST_COMPLEX : // cx and cy must be set in this mode
|
||||||
|
DbgPrint("DST_COMPLEX\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1739,79 +1758,117 @@ WINBOOL DoDrawState(
|
||||||
if (! cy) cy = s.cy;
|
if (! cy) cy = s.cy;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetRect(&rect, x, y, x + cx, y + cy);
|
|
||||||
SetRect(&subrect, 0, 0, cx, cy);
|
|
||||||
|
|
||||||
// Flags for DrawText
|
// Flags for DrawText
|
||||||
// if (fuFlags & DSS_RIGHT) // Undocumented
|
if (fuFlags & DSS_RIGHT) // Undocumented
|
||||||
// dtflags |= DT_RIGHT;
|
dtflags |= DT_RIGHT;
|
||||||
if (type == DST_TEXT)
|
if (type == DST_TEXT)
|
||||||
dtflags |= DT_NOPREFIX;
|
dtflags |= DT_NOPREFIX;
|
||||||
|
|
||||||
// We need to do additional processing if not DSS_NORMAL
|
// No additional processing needed for DSS_NORMAL
|
||||||
if (state == DSS_NORMAL)
|
if (state == DSS_NORMAL)
|
||||||
{
|
{
|
||||||
return DrawStateDraw(hdc, type, lpOutputFunc, lData, wData, &rect, dtflags, unicode);
|
DbgPrint("DSS_NORMAL\n");
|
||||||
|
SetRect(&rect, x, y, x + cx, y + cy);
|
||||||
|
return INTERNAL_DrawStateDraw(hdc, type, lpOutputFunc, lData, wData, &rect, dtflags, unicode);
|
||||||
}
|
}
|
||||||
|
|
||||||
HDC MemDC = NULL;
|
// Set the rectangle to that of the memory DC
|
||||||
HBITMAP MemBMP = NULL, OldBMP = NULL;
|
SetRect(&rect, 0, 0, cx, cy);
|
||||||
|
|
||||||
|
// Set colors
|
||||||
|
ForeColor = SetTextColor(hdc, RGB(0, 0, 0));
|
||||||
|
BackColor = SetBkColor(hdc, RGB(255, 255, 255));
|
||||||
|
|
||||||
|
// Create and initialize the memory DC
|
||||||
MemDC = CreateCompatibleDC(hdc);
|
MemDC = CreateCompatibleDC(hdc);
|
||||||
if (! MemDC) goto cleanup;
|
if (! MemDC) goto cleanup;
|
||||||
|
MemBMP = CreateBitmap(cx, cy, 1, 1, NULL);
|
||||||
MemBMP = CreateCompatibleBitmap(hdc, cx, cy);
|
|
||||||
if (! MemBMP) goto cleanup;
|
if (! MemBMP) goto cleanup;
|
||||||
|
|
||||||
OldBMP = (HBITMAP) SelectObject(MemDC, MemBMP);
|
OldBMP = (HBITMAP) SelectObject(MemDC, MemBMP);
|
||||||
if (! OldBMP) goto cleanup;
|
if (! OldBMP) goto cleanup;
|
||||||
|
|
||||||
|
DbgPrint("Created and inited MemDC\n");
|
||||||
|
|
||||||
|
// Set up the default colors and font
|
||||||
|
if (! FillRect(MemDC, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH))) goto cleanup;
|
||||||
|
SetBkColor(MemDC, RGB(255, 255, 255));
|
||||||
|
SetTextColor(MemDC, RGB(0, 0, 0));
|
||||||
|
Font = (HFONT)SelectObject(MemDC, GetCurrentObject(hdc, OBJ_FONT));
|
||||||
|
|
||||||
|
DbgPrint("Selected font and set colors\n");
|
||||||
|
|
||||||
DbgPrint("[draw.c] MemDC = 0x%x MemBMP = 0x%x OldBMP = 0x%x\n", MemDC, MemBMP, OldBMP);
|
// Enable this line to use the current DC image to begin with (wrong?)
|
||||||
|
// if (! BitBlt(MemDC, 0, 0, cx, cy, hdc, x, y, SRCCOPY)) goto cleanup;
|
||||||
|
|
||||||
// Copy the actual image into the memory DC (necessary?)
|
// DST_COMPLEX may draw text as well, so make sure font is selected
|
||||||
BitBlt(MemDC, 0, 0, cx, cy, hdc, x, y, SRCCOPY);
|
if (! Font && (type <= DST_PREFIXTEXT)) goto cleanup; // THIS FAILS
|
||||||
|
BOOL TempResult = INTERNAL_DrawStateDraw(MemDC, type, lpOutputFunc, lData, wData, &rect, dtflags, unicode);
|
||||||
|
if (Font) SelectObject(MemDC, Font);
|
||||||
|
if (! TempResult) goto cleanup;
|
||||||
|
|
||||||
|
DbgPrint("Done drawing\n");
|
||||||
|
|
||||||
// Apply state(s?)
|
// Apply state(s?)
|
||||||
|
|
||||||
if (state & DSS_UNION)
|
if (state & DSS_UNION)
|
||||||
{
|
{
|
||||||
// Dither the image
|
DbgPrint("DSS_UNION\n");
|
||||||
|
// Dither the image (not implemented in ReactOS yet?)
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prepare shadow brush
|
||||||
|
if (state & DSS_DISABLED)
|
||||||
|
TempBrush = CreateSolidBrush(GetSysColor(COLOR_3DHILIGHT));
|
||||||
|
// else if (state & DSS_DEFAULT)
|
||||||
|
// TempBrush = CreateSolidBrush(GetSysColor(COLOR_3DSHADOW));
|
||||||
|
|
||||||
|
// Draw shadow
|
||||||
|
if (state & (DSS_DISABLED /*|DSS_DEFAULT*/))
|
||||||
|
{
|
||||||
|
DbgPrint("DSS_DISABLED - Drawing shadow\n");
|
||||||
|
if (! TempBrush) goto cleanup;
|
||||||
|
OldBrush = (HBRUSH)SelectObject(hdc, TempBrush);
|
||||||
|
if (! OldBrush) goto cleanup;
|
||||||
|
if (! BitBlt(hdc, x + 1, y + 1, cx, cy, MemDC, 0, 0, 0x00B8074A)) goto cleanup;
|
||||||
|
SelectObject(hdc, OldBrush);
|
||||||
|
DeleteObject(TempBrush);
|
||||||
|
TempBrush = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (state & DSS_DISABLED)
|
if (state & DSS_DISABLED)
|
||||||
{
|
{
|
||||||
hbr = CreateSolidBrush(GetSysColor(COLOR_3DHILIGHT));
|
DbgPrint("DSS_DISABLED - Creating shadow brush 2\n");
|
||||||
if (! hbr) goto cleanup;
|
hbr = TempBrush = CreateSolidBrush(GetSysColor(COLOR_3DSHADOW));
|
||||||
|
if (! TempBrush) goto cleanup;
|
||||||
}
|
}
|
||||||
else if (! hbr)
|
else if (! hbr)
|
||||||
{
|
{
|
||||||
|
DbgPrint("Creating a brush\n");
|
||||||
hbr = (HBRUSH) GetStockObject(BLACK_BRUSH);
|
hbr = (HBRUSH) GetStockObject(BLACK_BRUSH);
|
||||||
}
|
}
|
||||||
|
|
||||||
// else if (state & DSS_DEFAULT)
|
|
||||||
// ....
|
|
||||||
|
|
||||||
if (state & (DSS_DISABLED /*|DSS_DEFAULT*/))
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
// HBRUSH oldbrush = (HBRUSH) SelectObject(MemDC, ourbrush);
|
DbgPrint("Selecting new brush\n");
|
||||||
|
OldBrush = (HBRUSH) SelectObject(hdc, hbr);
|
||||||
|
|
||||||
// Copy to hdc from MemDC
|
// Copy to hdc from MemDC
|
||||||
if (! BitBlt(hdc, x, y, cx, cy, MemDC, 0, 0, SRCCOPY)) goto cleanup;
|
DbgPrint("Blitting\n");
|
||||||
|
if (! BitBlt(hdc, x, y, cx, cy, MemDC, 0, 0, 0x00B8074A)) goto cleanup;
|
||||||
DbgPrint("[draw.c] Success!\n");
|
|
||||||
|
|
||||||
retval = TRUE;
|
retval = TRUE;
|
||||||
|
|
||||||
|
|
||||||
cleanup :
|
cleanup :
|
||||||
if (OldBMP) SelectObject(MemDC, OldBMP);
|
DbgPrint("In cleanup : Font %x OldBrush %x OldBMP %x Tempbrush %x MemBMP %x MemDC %x\n",
|
||||||
if (MemBMP) DeleteObject(MemBMP);
|
Font, OldBrush, OldBMP, TempBrush, MemBMP, MemDC);
|
||||||
if (MemDC) DeleteDC(MemDC);
|
SetTextColor(hdc, ForeColor);
|
||||||
|
SetBkColor(hdc, BackColor);
|
||||||
|
if (OldBrush) SelectObject(MemDC, OldBrush);
|
||||||
|
if (OldBMP) SelectObject(MemDC, OldBMP);
|
||||||
|
if (TempBrush) DeleteObject(TempBrush);
|
||||||
|
if (MemBMP) DeleteObject(MemBMP);
|
||||||
|
if (MemDC) DeleteDC(MemDC);
|
||||||
|
|
||||||
|
DbgPrint("Leaving DrawState() with retval %d\n", retval);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -1834,7 +1891,7 @@ DrawStateA(
|
||||||
int cy,
|
int cy,
|
||||||
UINT fuFlags)
|
UINT fuFlags)
|
||||||
{
|
{
|
||||||
return DoDrawState(hdc, hbr, lpOutputFunc, lData, wData, x, y, cx, cy, fuFlags, FALSE);
|
return INTERNAL_DrawState(hdc, hbr, lpOutputFunc, lData, wData, x, y, cx, cy, fuFlags, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1855,5 +1912,5 @@ DrawStateW(
|
||||||
int cy,
|
int cy,
|
||||||
UINT fuFlags)
|
UINT fuFlags)
|
||||||
{
|
{
|
||||||
return DoDrawState(hdc, hbr, lpOutputFunc, lData, wData, x, y, cx, cy, fuFlags, TRUE);
|
return INTERNAL_DrawState(hdc, hbr, lpOutputFunc, lData, wData, x, y, cx, cy, fuFlags, TRUE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: window.c,v 1.60 2003/08/17 17:32:58 royce Exp $
|
/* $Id: window.c,v 1.61 2003/08/17 19:07:11 silverblade Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS user32.dll
|
* PROJECT: ReactOS user32.dll
|
||||||
|
@ -707,7 +707,7 @@ CreateWindowExW(DWORD dwExStyle,
|
||||||
hMenu,
|
hMenu,
|
||||||
hInstance,
|
hInstance,
|
||||||
lpParam,
|
lpParam,
|
||||||
0);
|
sw);
|
||||||
|
|
||||||
return (HWND)Handle;
|
return (HWND)Handle;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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: window.c,v 1.94 2003/08/15 11:11:02 weiden Exp $
|
/* $Id: window.c,v 1.95 2003/08/17 19:07:11 silverblade Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -676,7 +676,7 @@ NtUserCreateWindowEx(DWORD dwExStyle,
|
||||||
*/
|
*/
|
||||||
WindowObject->Class = ClassObject;
|
WindowObject->Class = ClassObject;
|
||||||
WindowObject->ExStyle = dwExStyle;
|
WindowObject->ExStyle = dwExStyle;
|
||||||
WindowObject->Style = dwStyle;
|
WindowObject->Style = dwStyle & ~WS_VISIBLE;
|
||||||
DbgPrint("1: Style is now %d\n", WindowObject->Style);
|
DbgPrint("1: Style is now %d\n", WindowObject->Style);
|
||||||
|
|
||||||
WindowObject->x = x;
|
WindowObject->x = x;
|
||||||
|
|
Loading…
Reference in a new issue