-#ifdef UNICODE
-#undef UNICODE
-#endif
+#include "precomp.h"
-#undef WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include <ddk/ntddk.h>
-#include <win32k/kapi.h>
-
-HGDIOBJ STDCALL
-GetStockObject(int Index)
-{
- return(W32kGetStockObject(Index));
-}
-
-
-int STDCALL
-GetClipBox(HDC hDc, LPRECT Rect)
-{
- return(W32kGetClipBox(hDc, Rect));
-}
+#define NDEBUG
+#include <debug.h>
+/*
+ * @implemented
+ */
HDC
STDCALL
CreateDCA (
return hDC;
}
+
+/*
+ * @implemented
+ */
HDC
STDCALL
CreateDCW (
CONST DEVMODEW * lpInitData
)
{
- return W32kCreateDC (
- lpwszDriver,
- lpwszDevice,
- lpwszOutput,
- (PDEVMODEW)lpInitData
- );
+ UNICODE_STRING Driver, Device, Output;
+
+ if(lpwszDriver)
+ RtlInitUnicodeString(&Driver, lpwszDriver);
+ if(lpwszDevice)
+ RtlInitUnicodeString(&Driver, lpwszDevice);
+ if(lpwszOutput)
+ RtlInitUnicodeString(&Driver, lpwszOutput);
+
+ return NtGdiCreateDC((lpwszDriver ? &Driver : NULL),
+ (lpwszDevice ? &Device : NULL),
+ (lpwszOutput ? &Output : NULL),
+ (PDEVMODEW)lpInitData);
}
-BOOL STDCALL DeleteDC( HDC hDC )
+
+/*
+ * @implemented
+ */
+HDC
+STDCALL
+CreateICW(
+ LPCWSTR lpszDriver,
+ LPCWSTR lpszDevice,
+ LPCWSTR lpszOutput,
+ CONST DEVMODEW * lpdvmInit
+ )
{
- return W32kDeleteDC( hDC );
+ UNICODE_STRING Driver, Device, Output;
+
+ if(lpszDriver)
+ RtlInitUnicodeString(&Driver, lpszDriver);
+ if(lpszDevice)
+ RtlInitUnicodeString(&Device, lpszDevice);
+ if(lpszOutput)
+ RtlInitUnicodeString(&Output, lpszOutput);
+ return NtGdiCreateIC ((lpszDriver ? &Driver : NULL),
+ (lpszDevice ? &Device : NULL),
+ (lpszOutput ? &Output : NULL),
+ (CONST PDEVMODEW)lpdvmInit );
}
+/*
+ * @implemented
+ */
HDC
STDCALL
-CreateCompatibleDC(
- HDC hDC
+CreateICA(
+ LPCSTR lpszDriver,
+ LPCSTR lpszDevice,
+ LPCSTR lpszOutput,
+ CONST DEVMODEA * lpdvmInit
)
{
- return W32kCreateCompatableDC(hDC);
+ NTSTATUS Status;
+ LPWSTR lpszDriverW, lpszDeviceW, lpszOutputW;
+ UNICODE_STRING Driver, Device, Output;
+ LPDEVMODEW dvmInitW = NULL;
+ HDC rc = 0;
+
+ Status = HEAP_strdupA2W ( &lpszDriverW, lpszDriver );
+ if (!NT_SUCCESS (Status))
+ SetLastError (RtlNtStatusToDosError(Status));
+ else
+ {
+ Status = HEAP_strdupA2W ( &lpszDeviceW, lpszDevice );
+ if (!NT_SUCCESS (Status))
+ SetLastError (RtlNtStatusToDosError(Status));
+ else
+ {
+ Status = HEAP_strdupA2W ( &lpszOutputW, lpszOutput );
+ if (!NT_SUCCESS (Status))
+ SetLastError (RtlNtStatusToDosError(Status));
+ else
+ {
+ if ( lpdvmInit )
+ dvmInitW = GdiConvertToDevmodeW((LPDEVMODEA)lpdvmInit);
+
+ RtlInitUnicodeString(&Driver, lpszDriverW);
+ RtlInitUnicodeString(&Device, lpszDeviceW);
+ RtlInitUnicodeString(&Output, lpszOutputW);
+ rc = NtGdiCreateIC ( &Driver,
+ &Device,
+ &Output,
+ lpdvmInit ? dvmInitW : NULL );
+ HEAP_free (dvmInitW);
+ HEAP_free ( lpszOutputW );
+ }
+ HEAP_free ( lpszDeviceW );
+ }
+ HEAP_free ( lpszDriverW );
+ }
+ return rc;
}
-HGDIOBJ
+
+/*
+ * @implemented
+ */
+BOOL
STDCALL
-SelectObject(
- HDC hDC,
- HGDIOBJ hGDIObj
- )
+DeleteObject(HGDIOBJ hObject)
{
- return W32kSelectObject(hDC, hGDIObj);
+ if (0 != ((DWORD) hObject & GDI_HANDLE_STOCK_MASK))
+ {
+ DPRINT1("Trying to delete system object 0x%x\n", hObject);
+ return TRUE;
+ }
+
+ /* deleting a handle that doesn't belong to the caller should be rather rarely
+ so for the sake of speed just try to delete it without checking validity */
+ return NtGdiDeleteObject(hObject);
}
-int
+
+/*
+ * @implemented
+ */
+DWORD
STDCALL
-SetMapMode(
- HDC a0,
- int a1
- )
+GetRelAbs(
+ HDC hdc,
+ DWORD dwIgnore
+ )
{
- return W32kSetMapMode( a0, a1 );
+ return NtGdiGetRelAbs(hdc);
}
-BOOL
+/*
+ * @implemented
+*/
+LONG
STDCALL
-SetViewportOrgEx(
- HDC a0,
- int a1,
- int a2,
- LPPOINT a3
- )
+GetDCOrg(
+ HDC hdc
+ )
{
- return W32kSetViewportOrgEx( a0, a1, a2, a3 );
+ // Officially obsolete by Microsoft
+ POINT Pt;
+ if (!NtGdiGetDCOrgEx(hdc, &Pt))
+ return 0;
+ return(MAKELONG(Pt.x, Pt.y));
}
-BOOL
+
+/*
+ * @unimplemented
+ */
+int
+STDCALL
+GetObjectA(HGDIOBJ Handle, int Size, LPVOID Buffer)
+{
+ LOGFONTW LogFontW;
+ DWORD Type;
+ int Result;
+
+ Type = NtGdiGetObjectType(Handle);
+ if (0 == Type)
+ {
+ return 0;
+ }
+
+ if (OBJ_FONT == Type)
+ {
+ if (Size < sizeof(LOGFONTA))
+ {
+ SetLastError(ERROR_BUFFER_OVERFLOW);
+ return 0;
+ }
+ Result = NtGdiGetObject(Handle, sizeof(LOGFONTW), &LogFontW);
+ if (0 == Result)
+ {
+ return 0;
+ }
+ LogFontW2A((LPLOGFONTA) Buffer, &LogFontW);
+ Result = sizeof(LOGFONTA);
+ }
+ else
+ {
+ Result = NtGdiGetObject(Handle, Size, Buffer);
+ }
+
+ return Result;
+}
+
+
+/*
+ * @unimplemented
+ */
+int
+STDCALL
+GetObjectW(HGDIOBJ Handle, int Size, LPVOID Buffer)
+{
+ return NtGdiGetObject(Handle, Size, Buffer);
+}
+
+
+/*
+ * @implemented
+ */
+COLORREF
STDCALL
-SetWindowOrgEx(
- HDC a0,
- int a1,
- int a2,
- LPPOINT a3
- )
+GetDCBrushColor(
+ HDC hdc
+)
{
- return W32kSetWindowOrgEx( a0, a1, a2, a3 );
+ return NtUserGetDCBrushColor(hdc);
}
+/*
+ * @implemented
+ */
+COLORREF
+STDCALL
+GetDCPenColor(
+ HDC hdc
+)
+{
+ return NtUserGetDCPenColor(hdc);
+}
-BOOL
+/*
+ * @implemented
+ */
+COLORREF
STDCALL
-DeleteObject(
- HGDIOBJ a0
- )
+SetDCBrushColor(
+ HDC hdc,
+ COLORREF crColor
+)
{
- return W32kDeleteObject(a0);
+ return NtUserSetDCBrushColor(hdc, crColor);
}
-HPALETTE
+/*
+ * @implemented
+ */
+COLORREF
STDCALL
-SelectPalette(
- HDC a0,
- HPALETTE a1,
- BOOL a2
+SetDCPenColor(
+ HDC hdc,
+ COLORREF crColor
+)
+{
+ return NtUserSetDCPenColor(hdc, crColor);
+}
+
+
+/*
+ * @implemented
+ */
+HDC
+STDCALL
+ResetDCW(
+ HDC hdc,
+ CONST DEVMODEW *lpInitData
)
{
- return W32kSelectPalette( a0, a1,a2 );
+ return NtGdiResetDC ( hdc, lpInitData );
}
-UINT
+
+/*
+ * @implemented
+ */
+HDC
STDCALL
-RealizePalette(
- HDC a0
+ResetDCA(
+ HDC hdc,
+ CONST DEVMODEA *lpInitData
)
{
- return W32kRealizePalette( a0 );
+ LPDEVMODEW InitDataW;
+ HDC hDc;
+
+ InitDataW = GdiConvertToDevmodeW((LPDEVMODEA)lpInitData);
+
+ hDc = NtGdiResetDC ( hdc, InitDataW );
+ HEAP_free(InitDataW);
+ return hDc;
}
+/*
+ * @implemented
+ */
+int
+STDCALL
+StartDocW(
+ HDC hdc,
+ CONST DOCINFOW *a1
+ )
+{
+ return NtGdiStartDoc ( hdc, (DOCINFOW *)a1 );
+}
+
+/*
+ * @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:
+ Ret = OBJ_DC;
+ break;
+ case GDI_OBJECT_TYPE_METADC:
+ Ret = OBJ_METADC;
+ break;
+ case GDI_OBJECT_TYPE_METAFILE:
+ Ret = OBJ_METAFILE;
+ break;
+ case GDI_OBJECT_TYPE_ENHMETAFILE:
+ Ret = OBJ_ENHMETAFILE;
+ break;
+ case GDI_OBJECT_TYPE_ENHMETADC:
+ Ret = OBJ_ENHMETADC;
+ break;
+ case GDI_OBJECT_TYPE_EXTPEN:
+ Ret = OBJ_EXTPEN;
+ break;
+ case GDI_OBJECT_TYPE_MEMDC:
+ Ret = OBJ_MEMDC;
+ break;
+
+ default:
+ DPRINT1("GetObjectType: Magic 0x%08x not implemented\n", Type);
+ break;
+ }
+ }
+
+ return Ret;
+}