📄 dc.c
字号:
SetLastError(ERROR_INVALID_HANDLE);
}
return 0;
}
/*
* @implemented
*/
int
STDCALL
GetObjectA(HGDIOBJ hGdiObj, int cbSize, LPVOID lpBuffer)
{
ENUMLOGFONTEXDVW LogFont;
DWORD dwType;
INT Result = 0;
dwType = GDI_HANDLE_GET_TYPE(hGdiObj);;
if(dwType == GDI_OBJECT_TYPE_COLORSPACE) //Stays here, processes struct A
{
SetLastError(ERROR_NOT_SUPPORTED);
return 0;
}
if (dwType == GDI_OBJECT_TYPE_FONT)
{
if (!lpBuffer)
{
return sizeof(LOGFONTA);
}
if (cbSize == 0)
{
/* Windows does not SetLastError() */
return 0;
}
// ENUMLOGFONTEXDVW is the default size and should be the structure for
// Entry->KernelData for Font objects.
Result = NtGdiExtGetObjectW(hGdiObj, sizeof(ENUMLOGFONTEXDVW), &LogFont);
if (0 == Result)
{
return 0;
}
switch (cbSize)
{
case sizeof(ENUMLOGFONTEXDVA):
// need to move more here.
case sizeof(ENUMLOGFONTEXA):
EnumLogFontExW2A( (LPENUMLOGFONTEXA) lpBuffer, &LogFont.elfEnumLogfontEx );
break;
case sizeof(ENUMLOGFONTA):
// Same here, maybe? Check the structures.
case sizeof(EXTLOGFONTA):
// Same here
case sizeof(LOGFONTA):
LogFontW2A((LPLOGFONTA) lpBuffer, &LogFont.elfEnumLogfontEx.elfLogFont);
break;
default:
SetLastError(ERROR_BUFFER_OVERFLOW);
return 0;
}
return cbSize;
}
return GetNonFontObject(hGdiObj, cbSize, lpBuffer);
}
/*
* @implemented
*/
int
STDCALL
GetObjectW(HGDIOBJ hGdiObj, int cbSize, LPVOID lpBuffer)
{
DWORD dwType = GDI_HANDLE_GET_TYPE(hGdiObj);
INT Result = 0;
/*
Check List:
MSDN, "This can be a handle to one of the following: logical bitmap, a brush,
a font, a palette, a pen, or a device independent bitmap created by calling
the CreateDIBSection function."
*/
if(dwType == GDI_OBJECT_TYPE_COLORSPACE) //Stays here, processes struct W
{
SetLastError(ERROR_NOT_SUPPORTED); // Not supported yet.
return 0;
}
if (dwType == GDI_OBJECT_TYPE_FONT)
{
if (!lpBuffer)
{
return sizeof(LOGFONTW);
}
if (cbSize == 0)
{
/* Windows does not SetLastError() */
return 0;
}
// Poorly written apps are not ReactOS problem!
// We fix it here if the size is larger than the default size.
if( cbSize > sizeof(ENUMLOGFONTEXDVW) ) cbSize = sizeof(ENUMLOGFONTEXDVW);
Result = NtGdiExtGetObjectW(hGdiObj, cbSize, lpBuffer); // Should handle the copy.
if (0 == Result)
{
return 0;
}
return cbSize;
}
return GetNonFontObject(hGdiObj, cbSize, lpBuffer);
}
/*
* @implemented
*/
COLORREF
STDCALL
GetDCBrushColor(
HDC hdc
)
{
#if 0
PDC_ATTR Dc_Attr;
if (!GdiGetHandleUserData((HGDIOBJ) hdc, (PVOID) &Dc_Attr)) return CLR_INVALID;
return (COLORREF) Dc_Attr->ulPenClr;
#endif
return NtUserGetDCBrushColor(hdc);
}
/*
* @implemented
*/
COLORREF
STDCALL
GetDCPenColor(
HDC hdc
)
{
#if 0
PDC_ATTR Dc_Attr;
if (!GdiGetHandleUserData((HGDIOBJ) hdc, (PVOID) &Dc_Attr)) return CLR_INVALID;
return (COLORREF) Dc_Attr->ulPenClr;
#endif
return NtUserGetDCPenColor(hdc);
}
/*
* @implemented
*/
COLORREF
STDCALL
SetDCBrushColor(
HDC hdc,
COLORREF crColor
)
{
#if 0
PDC_ATTR Dc_Attr;
COLORREF OldColor = CLR_INVALID;
if (!GdiGetHandleUserData((HGDIOBJ) hdc, (PVOID) &Dc_Attr)) return OldColor;
else
{
OldColor = (COLORREF) Dc_Attr->ulBrushClr;
Dc_Attr->ulBrushClr = (ULONG) crColor;
if ( Dc_Attr->crBrushClr != crColor ) // if same, don't force a copy.
{
Dc_Attr->ulDirty_ |= DIRTY_FILL;
Dc_Attr->crBrushClr = crColor;
}
}
return OldColor;
#endif
return NtUserSetDCBrushColor(hdc, crColor);
}
/*
* @implemented
*/
COLORREF
STDCALL
SetDCPenColor(
HDC hdc,
COLORREF crColor
)
{
#if 0
PDC_ATTR Dc_Attr;
COLORREF OldColor = CLR_INVALID;
if (!GdiGetHandleUserData((HGDIOBJ) hdc, (PVOID) &Dc_Attr)) return OldColor;
else
{
OldColor = (COLORREF) Dc_Attr->ulPenClr;
Dc_Attr->ulPenClr = (ULONG) crColor;
if ( Dc_Attr->crPenClr != crColor )
{
Dc_Attr->ulDirty_ |= DIRTY_LINE;
Dc_Attr->crPenClr = crColor;
}
}
return OldColor;
#endif
return NtUserSetDCPenColor(hdc, crColor);
}
/*
* @implemented
*/
HDC
STDCALL
ResetDCW(
HDC hdc,
CONST DEVMODEW *lpInitData
)
{
NtGdiResetDC ( hdc, (PDEVMODEW)lpInitData, NULL, NULL, NULL);
return hdc;
}
/*
* @implemented
*/
HDC
STDCALL
ResetDCA(
HDC hdc,
CONST DEVMODEA *lpInitData
)
{
LPDEVMODEW InitDataW;
InitDataW = GdiConvertToDevmodeW((LPDEVMODEA)lpInitData);
NtGdiResetDC ( hdc, InitDataW, NULL, NULL, NULL);
HEAP_free(InitDataW);
return hdc;
}
/*
* @implemented
*/
int
STDCALL
StartDocW(
HDC hdc,
CONST DOCINFOW *a1
)
{
return NtGdiStartDoc ( hdc, (DOCINFOW *)a1, NULL, 0);
}
/*
* @implemented
*/
DWORD
STDCALL
GetObjectType(
HGDIOBJ h
)
{
DWORD Ret = 0;
if(GdiIsHandleValid(h))
{
LONG Type = GDI_HANDLE_GET_TYPE(h);
switch(Type)
{
case GDI_OBJECT_TYPE_PEN:
Ret = OBJ_PEN;
break;
case GDI_OBJECT_TYPE_BRUSH:
Ret = OBJ_BRUSH;
break;
case GDI_OBJECT_TYPE_BITMAP:
Ret = OBJ_BITMAP;
break;
case GDI_OBJECT_TYPE_FONT:
Ret = OBJ_FONT;
break;
case GDI_OBJECT_TYPE_PALETTE:
Ret = OBJ_PAL;
break;
case GDI_OBJECT_TYPE_REGION:
Ret = OBJ_REGION;
break;
case GDI_OBJECT_TYPE_DC:
if ( GetDCDWord( h, GdiGetIsMemDc, 0))
{
Ret = OBJ_MEMDC;
}
else
Ret = OBJ_DC;
break;
case GDI_OBJECT_TYPE_COLORSPACE:
Ret = OBJ_COLORSPACE;
break;
case GDI_OBJECT_TYPE_METAFILE:
Ret = OBJ_METAFILE;
break;
case GDI_OBJECT_TYPE_ENHMETAFILE:
Ret = OBJ_ENHMETAFILE;
break;
case GDI_OBJECT_TYPE_METADC:
Ret = OBJ_METADC;
break;
case GDI_OBJECT_TYPE_EXTPEN:
Ret = OBJ_EXTPEN;
break;
default:
DPRINT1("GetObjectType: Magic 0x%08x not implemented\n", Type);
break;
}
}
else
/* From Wine: GetObjectType does SetLastError() on a null object */
SetLastError(ERROR_INVALID_HANDLE);
return Ret;
}
/*
* @implemented
*/
HGDIOBJ
WINAPI
GetStockObject(
INT h
)
{
HGDIOBJ Ret = NULL;
if ((h < 0) || (h >= NB_STOCK_OBJECTS)) return Ret;
Ret = stock_objects[h];
if (!Ret)
{
HGDIOBJ Obj = NtGdiGetStockObject( h );
if (GdiIsHandleValid(Obj))
{
stock_objects[h] = Obj;
return Obj;
}// Returns Null anyway.
}
return Ret;
}
BOOL
STDCALL
GetViewportExtEx(
HDC hdc,
LPSIZE lpSize
)
{
#if 0
PDC_ATTR Dc_Attr;
if (!GdiGetHandleUserData((HGDIOBJ) hdc, (PVOID) &Dc_Attr)) return FALSE;
if ( Dc_Attr->flXform & PAGE_EXTENTS_CHANGED ) // Something was updated, go to kernel.
#endif
return NtGdiGetDCPoint( hdc, GdiGetViewPortExt, (LPPOINT) lpSize );
#if 0
else
{
lpSize->cx = Dc_Attr->szlViewportExt.cx;
lpSize->cy = Dc_Attr->szlViewportExt.cy;
}
return TRUE;
#endif
}
BOOL
STDCALL
GetViewportOrgEx(
HDC hdc,
LPPOINT lpPoint
)
{
#if 0
PDC_ATTR Dc_Attr;
if (!GdiGetHandleUserData((HGDIOBJ) hdc, (PVOID) &Dc_Attr)) return FALSE;
lpPoint->x = Dc_Attr->ptlViewportOrg.x;
lpPoint->x = Dc_Attr->ptlViewportOrg.x;
return TRUE;
#endif
// Do it this way for now.
return NtGdiGetDCPoint( hdc, GdiGetViewPortOrg, lpPoint );
}
BOOL
STDCALL
GetWindowExtEx(
HDC hdc,
LPSIZE lpSize
)
{
#if 0
PDC_ATTR Dc_Attr;
if (!GdiGetHandleUserData((HGDIOBJ) hdc, (PVOID) &Dc_Attr)) return FALSE;
lpSize->cx = Dc_Attr->szlWindowExt.cx;
lpSize->cy = Dc_Attr->szlWindowExt.cy;
return TRUE;
#endif
// Do it this way for now.
return NtGdiGetDCPoint( hdc, GdiGetWindowExt, (LPPOINT) lpSize );
}
BOOL
STDCALL
GetWindowOrgEx(
HDC hdc,
LPPOINT lpPoint
)
{
#if 0
PDC_ATTR Dc_Attr;
if (!GdiGetHandleUserData((HGDIOBJ) hdc, (PVOID) &Dc_Attr)) return FALSE;
lpPoint->x = Dc_Attr->ptlWindowOrg.x;
lpPoint->x = Dc_Attr->ptlWindowOrg.x;
return TRUE;
#endif
// Do it this way for now.
return NtGdiGetDCPoint( hdc, GdiGetWindowOrg, lpPoint );
}
/* FIXME: include correct header */
HPALETTE STDCALL NtUserSelectPalette(HDC hDC,
HPALETTE hpal,
BOOL ForceBackground);
HPALETTE
STDCALL
SelectPalette(
HDC hDC,
HPALETTE hPal,
BOOL bForceBackground)
{
return NtUserSelectPalette(hDC, hPal, bForceBackground);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -