2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * PURPOSE: Coordinate systems
24 * FILE: subsys/win32k/objects/coord.c
28 /* INCLUDES ******************************************************************/
35 /* FUNCTIONS *****************************************************************/
38 IntFixIsotropicMapping(PDC dc
)
42 PDC_ATTR Dc_Attr
= dc
->pDc_Attr
;
43 if(!Dc_Attr
) Dc_Attr
= &dc
->Dc_Attr
;
45 xdim
= EngMulDiv(Dc_Attr
->szlViewportExt
.cx
,
46 ((PGDIDEVICE
)dc
->pPDev
)->GDIInfo
.ulHorzSize
,
47 ((PGDIDEVICE
)dc
->pPDev
)->GDIInfo
.ulHorzRes
) /
48 Dc_Attr
->szlWindowExt
.cx
;
49 ydim
= EngMulDiv(Dc_Attr
->szlViewportExt
.cy
,
50 ((PGDIDEVICE
)dc
->pPDev
)->GDIInfo
.ulVertSize
,
51 ((PGDIDEVICE
)dc
->pPDev
)->GDIInfo
.ulVertRes
) /
52 Dc_Attr
->szlWindowExt
.cy
;
56 Dc_Attr
->szlViewportExt
.cx
= Dc_Attr
->szlViewportExt
.cx
* abs(ydim
/ xdim
);
57 if (!Dc_Attr
->szlViewportExt
.cx
) Dc_Attr
->szlViewportExt
.cx
= 1;
61 Dc_Attr
->szlViewportExt
.cy
= Dc_Attr
->szlViewportExt
.cy
* abs(xdim
/ ydim
);
62 if (!Dc_Attr
->szlViewportExt
.cy
) Dc_Attr
->szlViewportExt
.cy
= 1;
67 IntGdiCombineTransform(LPXFORM XFormResult
,
72 /* Check for illegal parameters */
73 if (!XFormResult
|| !xform1
|| !xform2
)
78 /* Create the result in a temporary XFORM, since xformResult may be
79 * equal to xform1 or xform2 */
80 xformTemp
.eM11
= xform1
->eM11
* xform2
->eM11
+ xform1
->eM12
* xform2
->eM21
;
81 xformTemp
.eM12
= xform1
->eM11
* xform2
->eM12
+ xform1
->eM12
* xform2
->eM22
;
82 xformTemp
.eM21
= xform1
->eM21
* xform2
->eM11
+ xform1
->eM22
* xform2
->eM21
;
83 xformTemp
.eM22
= xform1
->eM21
* xform2
->eM12
+ xform1
->eM22
* xform2
->eM22
;
84 xformTemp
.eDx
= xform1
->eDx
* xform2
->eM11
+ xform1
->eDy
* xform2
->eM21
+ xform2
->eDx
;
85 xformTemp
.eDy
= xform1
->eDx
* xform2
->eM12
+ xform1
->eDy
* xform2
->eM22
+ xform2
->eDy
;
86 *XFormResult
= xformTemp
;
91 BOOL APIENTRY
NtGdiCombineTransform(LPXFORM UnsafeXFormResult
,
99 ProbeForWrite(UnsafeXFormResult
,
102 ProbeForRead(Unsafexform1
,
105 ProbeForRead(Unsafexform2
,
108 Ret
= IntGdiCombineTransform(UnsafeXFormResult
, Unsafexform1
, Unsafexform2
);
110 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
122 IntGetGraphicsMode ( PDC dc
)
126 Dc_Attr
= dc
->pDc_Attr
;
127 if(!Dc_Attr
) Dc_Attr
= &dc
->Dc_Attr
;
128 return Dc_Attr
->iGraphicsMode
;
133 IntGdiModifyWorldTransform(PDC pDc
,
134 CONST LPXFORM lpXForm
,
138 XFORM xformWorld2Wnd
;
143 xformWorld2Wnd
.eM11
= 1.0f
;
144 xformWorld2Wnd
.eM12
= 0.0f
;
145 xformWorld2Wnd
.eM21
= 0.0f
;
146 xformWorld2Wnd
.eM22
= 1.0f
;
147 xformWorld2Wnd
.eDx
= 0.0f
;
148 xformWorld2Wnd
.eDy
= 0.0f
;
149 XForm2MatrixS(&pDc
->DcLevel
.mxWorldToPage
, &xformWorld2Wnd
);
152 case MWT_LEFTMULTIPLY
:
153 MatrixS2XForm(&xformWorld2Wnd
, &pDc
->DcLevel
.mxWorldToPage
);
154 IntGdiCombineTransform(&xformWorld2Wnd
, lpXForm
, &xformWorld2Wnd
);
155 XForm2MatrixS(&pDc
->DcLevel
.mxWorldToPage
, &xformWorld2Wnd
);
158 case MWT_RIGHTMULTIPLY
:
159 MatrixS2XForm(&xformWorld2Wnd
, &pDc
->DcLevel
.mxWorldToPage
);
160 IntGdiCombineTransform(&xformWorld2Wnd
, &xformWorld2Wnd
, lpXForm
);
161 XForm2MatrixS(&pDc
->DcLevel
.mxWorldToPage
, &xformWorld2Wnd
);
164 case MWT_MAX
+1: // Must be MWT_SET????
165 XForm2MatrixS(&pDc
->DcLevel
.mxWorldToPage
, lpXForm
); // Do it like Wine.
171 DC_UpdateXforms(pDc
);
177 NtGdiGetTransform(HDC hDC
,
182 NTSTATUS Status
= STATUS_SUCCESS
;
184 dc
= DC_LockDc ( hDC
);
187 SetLastWin32Error(ERROR_INVALID_HANDLE
);
193 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
204 case GdiWorldSpaceToPageSpace
:
205 MatrixS2XForm(XForm
, &dc
->DcLevel
.mxWorldToPage
);
211 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
213 Status
= _SEH2_GetExceptionCode();
218 return NT_SUCCESS(Status
);
223 * Converts points from logical coordinates into device coordinates. Conversion depends on the mapping mode,
224 * world transfrom, viewport origin settings for the given device context.
225 * \param hDC device context.
226 * \param Points an array of POINT structures (in/out).
227 * \param Count number of elements in the array of POINT structures.
228 * \return TRUE if success.
232 NtGdiTransformPoints( HDC hDC
,
239 NTSTATUS Status
= STATUS_SUCCESS
;
246 SetLastWin32Error(ERROR_INVALID_HANDLE
);
250 if (!UnsafePtsIn
|| !UnsafePtOut
|| Count
<= 0)
253 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
257 Size
= Count
* sizeof(POINT
);
259 Points
= (LPPOINT
)ExAllocatePoolWithTag(PagedPool
, Size
, TAG_COORD
);
263 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
269 ProbeForWrite(UnsafePtOut
,
272 ProbeForRead(UnsafePtsIn
,
275 RtlCopyMemory(Points
,
279 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
281 Status
= _SEH2_GetExceptionCode();
285 if(!NT_SUCCESS(Status
))
288 ExFreePoolWithTag(Points
, TAG_COORD
);
289 SetLastNtError(Status
);
296 IntDPtoLP(dc
, Points
, Count
);
299 IntLPtoDP(dc
, Points
, Count
);
301 case 2: // Not supported yet. Need testing.
305 ExFreePoolWithTag(Points
, TAG_COORD
);
306 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
313 /* pointer was already probed! */
314 RtlCopyMemory(UnsafePtOut
,
318 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
320 Status
= _SEH2_GetExceptionCode();
324 if(!NT_SUCCESS(Status
))
327 ExFreePoolWithTag(Points
, TAG_COORD
);
328 SetLastNtError(Status
);
332 // If we are getting called that means User XForms is a mess!
335 ExFreePoolWithTag(Points
, TAG_COORD
);
341 NtGdiModifyWorldTransform(HDC hDC
,
352 SetLastWin32Error(ERROR_INVALID_HANDLE
);
356 // The xform is permitted to be NULL for MWT_IDENTITY.
357 // However, if it is not NULL, then it must be valid even though it is not used.
358 if (UnsafeXForm
!= NULL
|| Mode
!= MWT_IDENTITY
)
362 ProbeForRead(UnsafeXForm
, sizeof(XFORM
), 1);
363 RtlCopyMemory(&SafeXForm
, UnsafeXForm
, sizeof(XFORM
));
365 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
372 // Safe to handle kernel mode data.
373 if (Ret
) Ret
= IntGdiModifyWorldTransform(dc
, &SafeXForm
, Mode
);
380 NtGdiOffsetViewportOrgEx(HDC hDC
,
387 NTSTATUS Status
= STATUS_SUCCESS
;
389 dc
= DC_LockDc ( hDC
);
392 SetLastWin32Error(ERROR_INVALID_HANDLE
);
395 Dc_Attr
= dc
->pDc_Attr
;
396 if(!Dc_Attr
) Dc_Attr
= &dc
->Dc_Attr
;
402 ProbeForWrite(UnsafePoint
,
405 UnsafePoint
->x
= Dc_Attr
->ptlViewportOrg
.x
;
406 UnsafePoint
->y
= Dc_Attr
->ptlViewportOrg
.y
;
407 if ( Dc_Attr
->dwLayout
& LAYOUT_RTL
) UnsafePoint
->x
= -UnsafePoint
->x
;
409 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
411 Status
= _SEH2_GetExceptionCode();
415 if ( !NT_SUCCESS(Status
) )
417 SetLastNtError(Status
);
423 if ( Dc_Attr
->dwLayout
& LAYOUT_RTL
) XOffset
= -XOffset
;
424 Dc_Attr
->ptlViewportOrg
.x
+= XOffset
;
425 Dc_Attr
->ptlViewportOrg
.y
+= YOffset
;
433 NtGdiOffsetWindowOrgEx(HDC hDC
,
444 SetLastWin32Error(ERROR_INVALID_HANDLE
);
447 Dc_Attr
= dc
->pDc_Attr
;
448 if(!Dc_Attr
) Dc_Attr
= &dc
->Dc_Attr
;
452 NTSTATUS Status
= STATUS_SUCCESS
;
459 Point
->x
= Dc_Attr
->ptlWindowOrg
.x
;
460 Point
->y
= Dc_Attr
->ptlWindowOrg
.y
;
462 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
464 Status
= _SEH2_GetExceptionCode();
468 if(!NT_SUCCESS(Status
))
470 SetLastNtError(Status
);
476 Dc_Attr
->ptlWindowOrg
.x
+= XOffset
;
477 Dc_Attr
->ptlWindowOrg
.y
+= YOffset
;
487 NtGdiScaleViewportExtEx(HDC hDC
,
499 pDC
= DC_LockDc(hDC
);
502 SetLastWin32Error(ERROR_INVALID_HANDLE
);
505 pDc_Attr
= pDC
->pDc_Attr
;
506 if(!pDc_Attr
) pDc_Attr
= &pDC
->Dc_Attr
;
510 NTSTATUS Status
= STATUS_SUCCESS
;
518 pSize
->cx
= pDc_Attr
->szlViewportExt
.cx
;
519 pSize
->cy
= pDc_Attr
->szlViewportExt
.cy
;
521 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
523 Status
= _SEH2_GetExceptionCode();
527 if(!NT_SUCCESS(Status
))
529 SetLastNtError(Status
);
535 if (pDc_Attr
->iMapMode
> MM_TWIPS
)
537 if ( ( Xdenom
) && ( Ydenom
) )
539 X
= Xnum
* pDc_Attr
->szlViewportExt
.cx
/ Xdenom
;
542 Y
= Ynum
* pDc_Attr
->szlViewportExt
.cy
/ Ydenom
;
545 pDc_Attr
->szlViewportExt
.cx
= X
;
546 pDc_Attr
->szlViewportExt
.cy
= Y
;
548 IntMirrorWindowOrg(pDC
);
550 pDc_Attr
->flXform
|= (PAGE_EXTENTS_CHANGED
|INVALIDATE_ATTRIBUTES
|DEVICE_TO_WORLD_INVALID
);
552 if (pDc_Attr
->iMapMode
== MM_ISOTROPIC
) IntFixIsotropicMapping(pDC
);
553 DC_UpdateXforms(pDC
);
569 NtGdiScaleWindowExtEx(HDC hDC
,
581 pDC
= DC_LockDc(hDC
);
584 SetLastWin32Error(ERROR_INVALID_HANDLE
);
587 pDc_Attr
= pDC
->pDc_Attr
;
588 if(!pDc_Attr
) pDc_Attr
= &pDC
->Dc_Attr
;
592 NTSTATUS Status
= STATUS_SUCCESS
;
600 X
= pDc_Attr
->szlWindowExt
.cx
;
601 if (pDc_Attr
->dwLayout
& LAYOUT_RTL
) X
= -X
;
603 pSize
->cy
= pDc_Attr
->szlWindowExt
.cy
;
605 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
607 Status
= _SEH2_GetExceptionCode();
611 if(!NT_SUCCESS(Status
))
613 SetLastNtError(Status
);
619 if (pDc_Attr
->iMapMode
> MM_TWIPS
)
621 if (( Xdenom
) && ( Ydenom
))
623 X
= Xnum
* pDc_Attr
->szlWindowExt
.cx
/ Xdenom
;
626 Y
= Ynum
* pDc_Attr
->szlWindowExt
.cy
/ Ydenom
;
629 pDc_Attr
->szlWindowExt
.cx
= X
;
630 pDc_Attr
->szlWindowExt
.cy
= Y
;
632 IntMirrorWindowOrg(pDC
);
634 pDc_Attr
->flXform
|= (PAGE_EXTENTS_CHANGED
|INVALIDATE_ATTRIBUTES
|DEVICE_TO_WORLD_INVALID
);
636 if (pDc_Attr
->iMapMode
== MM_ISOTROPIC
) IntFixIsotropicMapping(pDC
);
637 DC_UpdateXforms(pDC
);
653 IntGdiSetMapMode(PDC dc
,
657 PDC_ATTR Dc_Attr
= dc
->pDc_Attr
;
658 if(!Dc_Attr
) Dc_Attr
= &dc
->Dc_Attr
;
660 PrevMapMode
= Dc_Attr
->iMapMode
;
662 Dc_Attr
->iMapMode
= MapMode
;
667 Dc_Attr
->szlWindowExt
.cx
= 1;
668 Dc_Attr
->szlWindowExt
.cy
= 1;
669 Dc_Attr
->szlViewportExt
.cx
= 1;
670 Dc_Attr
->szlViewportExt
.cy
= 1;
671 Dc_Attr
->flXform
&= ~(ISO_OR_ANISO_MAP_MODE
|PTOD_EFM22_NEGATIVE
|
672 PTOD_EFM11_NEGATIVE
|POSITIVE_Y_IS_UP
);
673 Dc_Attr
->flXform
|= (PAGE_XLATE_CHANGED
|PAGE_TO_DEVICE_SCALE_IDENTITY
|
674 INVALIDATE_ATTRIBUTES
|DEVICE_TO_WORLD_INVALID
);
678 Dc_Attr
->szlWindowExt
.cx
= 3600;
679 Dc_Attr
->szlWindowExt
.cy
= 2700;
680 Dc_Attr
->szlViewportExt
.cx
= ((PGDIDEVICE
)dc
->pPDev
)->GDIInfo
.ulHorzRes
;
681 Dc_Attr
->szlViewportExt
.cy
= -((PGDIDEVICE
)dc
->pPDev
)->GDIInfo
.ulVertRes
;
685 Dc_Attr
->szlWindowExt
.cx
= ((PGDIDEVICE
)dc
->pPDev
)->GDIInfo
.ulHorzSize
* 10;
686 Dc_Attr
->szlWindowExt
.cy
= ((PGDIDEVICE
)dc
->pPDev
)->GDIInfo
.ulVertSize
* 10;
687 Dc_Attr
->szlViewportExt
.cx
= ((PGDIDEVICE
)dc
->pPDev
)->GDIInfo
.ulHorzRes
;
688 Dc_Attr
->szlViewportExt
.cy
= -((PGDIDEVICE
)dc
->pPDev
)->GDIInfo
.ulVertRes
;
692 Dc_Attr
->szlWindowExt
.cx
= ((PGDIDEVICE
)dc
->pPDev
)->GDIInfo
.ulHorzSize
* 100;
693 Dc_Attr
->szlWindowExt
.cy
= ((PGDIDEVICE
)dc
->pPDev
)->GDIInfo
.ulVertSize
* 100;
694 Dc_Attr
->szlViewportExt
.cx
= ((PGDIDEVICE
)dc
->pPDev
)->GDIInfo
.ulHorzRes
;
695 Dc_Attr
->szlViewportExt
.cy
= -((PGDIDEVICE
)dc
->pPDev
)->GDIInfo
.ulVertRes
;
699 Dc_Attr
->szlWindowExt
.cx
= EngMulDiv(1000, ((PGDIDEVICE
)dc
->pPDev
)->GDIInfo
.ulHorzSize
, 254);
700 Dc_Attr
->szlWindowExt
.cy
= EngMulDiv(1000, ((PGDIDEVICE
)dc
->pPDev
)->GDIInfo
.ulVertSize
, 254);
701 Dc_Attr
->szlViewportExt
.cx
= ((PGDIDEVICE
)dc
->pPDev
)->GDIInfo
.ulHorzRes
;
702 Dc_Attr
->szlViewportExt
.cy
= -((PGDIDEVICE
)dc
->pPDev
)->GDIInfo
.ulVertRes
;
706 Dc_Attr
->szlWindowExt
.cx
= EngMulDiv(10000, ((PGDIDEVICE
)dc
->pPDev
)->GDIInfo
.ulHorzSize
, 254);
707 Dc_Attr
->szlWindowExt
.cy
= EngMulDiv(10000, ((PGDIDEVICE
)dc
->pPDev
)->GDIInfo
.ulVertSize
, 254);
708 Dc_Attr
->szlViewportExt
.cx
= ((PGDIDEVICE
)dc
->pPDev
)->GDIInfo
.ulHorzRes
;
709 Dc_Attr
->szlViewportExt
.cy
= -((PGDIDEVICE
)dc
->pPDev
)->GDIInfo
.ulVertRes
;
713 Dc_Attr
->szlWindowExt
.cx
= EngMulDiv(14400, ((PGDIDEVICE
)dc
->pPDev
)->GDIInfo
.ulHorzSize
, 254);
714 Dc_Attr
->szlWindowExt
.cy
= EngMulDiv(14400, ((PGDIDEVICE
)dc
->pPDev
)->GDIInfo
.ulVertSize
, 254);
715 Dc_Attr
->szlViewportExt
.cx
= ((PGDIDEVICE
)dc
->pPDev
)->GDIInfo
.ulHorzRes
;
716 Dc_Attr
->szlViewportExt
.cy
= -((PGDIDEVICE
)dc
->pPDev
)->GDIInfo
.ulVertRes
;
720 Dc_Attr
->flXform
&= ~(PAGE_TO_DEVICE_IDENTITY
|POSITIVE_Y_IS_UP
);
721 Dc_Attr
->flXform
|= ISO_OR_ANISO_MAP_MODE
;
724 Dc_Attr
->iMapMode
= PrevMapMode
;
734 NtGdiSetViewportExtEx(HDC hDC
,
745 SetLastWin32Error(ERROR_INVALID_HANDLE
);
748 Dc_Attr
= dc
->pDc_Attr
;
749 if(!Dc_Attr
) Dc_Attr
= &dc
->Dc_Attr
;
751 switch (Dc_Attr
->iMapMode
)
763 // Here we should (probably) check that SetWindowExtEx *really* has
770 NTSTATUS Status
= STATUS_SUCCESS
;
777 Size
->cx
= Dc_Attr
->szlViewportExt
.cx
;
778 Size
->cy
= Dc_Attr
->szlViewportExt
.cy
;
780 Dc_Attr
->szlViewportExt
.cx
= XExtent
;
781 Dc_Attr
->szlViewportExt
.cy
= YExtent
;
783 if (Dc_Attr
->iMapMode
== MM_ISOTROPIC
)
784 IntFixIsotropicMapping(dc
);
786 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
788 Status
= _SEH2_GetExceptionCode();
792 if(!NT_SUCCESS(Status
))
794 SetLastNtError(Status
);
809 NtGdiSetViewportOrgEx(HDC hDC
,
820 SetLastWin32Error(ERROR_INVALID_HANDLE
);
823 Dc_Attr
= dc
->pDc_Attr
;
824 if(!Dc_Attr
) Dc_Attr
= &dc
->Dc_Attr
;
828 NTSTATUS Status
= STATUS_SUCCESS
;
835 Point
->x
= Dc_Attr
->ptlViewportOrg
.x
;
836 Point
->y
= Dc_Attr
->ptlViewportOrg
.y
;
838 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
840 Status
= _SEH2_GetExceptionCode();
844 if(!NT_SUCCESS(Status
))
846 SetLastNtError(Status
);
852 Dc_Attr
->ptlViewportOrg
.x
= X
;
853 Dc_Attr
->ptlViewportOrg
.y
= Y
;
863 NtGdiSetWindowExtEx(HDC hDC
,
874 SetLastWin32Error(ERROR_INVALID_HANDLE
);
877 Dc_Attr
= dc
->pDc_Attr
;
878 if(!Dc_Attr
) Dc_Attr
= &dc
->Dc_Attr
;
880 switch (Dc_Attr
->iMapMode
)
894 NTSTATUS Status
= STATUS_SUCCESS
;
901 Size
->cx
= Dc_Attr
->szlWindowExt
.cx
;
902 Size
->cy
= Dc_Attr
->szlWindowExt
.cy
;
904 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
906 Status
= _SEH2_GetExceptionCode();
910 if(!NT_SUCCESS(Status
))
912 SetLastNtError(Status
);
918 Dc_Attr
->szlWindowExt
.cx
= XExtent
;
919 Dc_Attr
->szlWindowExt
.cy
= YExtent
;
929 NtGdiSetWindowOrgEx(HDC hDC
,
940 SetLastWin32Error(ERROR_INVALID_HANDLE
);
943 Dc_Attr
= dc
->pDc_Attr
;
944 if(!Dc_Attr
) Dc_Attr
= &dc
->Dc_Attr
;
948 NTSTATUS Status
= STATUS_SUCCESS
;
955 Point
->x
= Dc_Attr
->ptlWindowOrg
.x
;
956 Point
->y
= Dc_Attr
->ptlWindowOrg
.y
;
958 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
960 Status
= _SEH2_GetExceptionCode();
964 if(!NT_SUCCESS(Status
))
966 SetLastNtError(Status
);
972 Dc_Attr
->ptlWindowOrg
.x
= X
;
973 Dc_Attr
->ptlWindowOrg
.y
= Y
;
982 // Mirror Window function.
986 IntMirrorWindowOrg(PDC dc
)
991 Dc_Attr
= dc
->pDc_Attr
;
992 if(!Dc_Attr
) Dc_Attr
= &dc
->Dc_Attr
;
994 if (!(Dc_Attr
->dwLayout
& LAYOUT_RTL
))
996 Dc_Attr
->ptlWindowOrg
.x
= Dc_Attr
->lWindowOrgx
; // Flip it back.
999 if (!Dc_Attr
->szlViewportExt
.cx
) return;
1001 // WOrgx = wox - (Width - 1) * WExtx / VExtx
1003 X
= (dc
->erclWindow
.right
- dc
->erclWindow
.left
) - 1; // Get device width - 1
1005 X
= ( X
* Dc_Attr
->szlWindowExt
.cx
) / Dc_Attr
->szlViewportExt
.cx
;
1007 Dc_Attr
->ptlWindowOrg
.x
= Dc_Attr
->lWindowOrgx
- X
; // Now set the inverted win origion.
1014 // The default is left to right. This function changes it to right to left, which
1015 // is the standard in Arabic and Hebrew cultures.
1031 dc
= DC_LockDc(hdc
);
1034 SetLastWin32Error(ERROR_INVALID_HANDLE
);
1037 Dc_Attr
= dc
->pDc_Attr
;
1038 if(!Dc_Attr
) Dc_Attr
= &dc
->Dc_Attr
;
1040 Dc_Attr
->dwLayout
= dwLayout
;
1041 oLayout
= Dc_Attr
->dwLayout
;
1043 if (!(dwLayout
& LAYOUT_ORIENTATIONMASK
))
1049 if (dwLayout
& LAYOUT_RTL
) Dc_Attr
->iMapMode
= MM_ANISOTROPIC
;
1051 Dc_Attr
->szlWindowExt
.cy
= -Dc_Attr
->szlWindowExt
.cy
;
1052 Dc_Attr
->ptlWindowOrg
.x
= -Dc_Attr
->ptlWindowOrg
.x
;
1055 IntMirrorWindowOrg(dc
);
1057 Dc_Attr
->ptlWindowOrg
.x
= wox
- Dc_Attr
->ptlWindowOrg
.x
;
1059 if (!(Dc_Attr
->flTextAlign
& TA_CENTER
)) Dc_Attr
->flTextAlign
|= TA_RIGHT
;
1061 if (dc
->DcLevel
.flPath
& DCPATH_CLOCKWISE
)
1062 dc
->DcLevel
.flPath
&= ~DCPATH_CLOCKWISE
;
1064 dc
->DcLevel
.flPath
|= DCPATH_CLOCKWISE
;
1066 Dc_Attr
->flXform
|= (PAGE_EXTENTS_CHANGED
|INVALIDATE_ATTRIBUTES
|DEVICE_TO_WORLD_INVALID
);
1068 // DC_UpdateXforms(dc);
1078 NtGdiGetDeviceWidth(
1083 dc
= DC_LockDc(hdc
);
1086 SetLastWin32Error(ERROR_INVALID_HANDLE
);
1089 Ret
= dc
->erclWindow
.right
- dc
->erclWindow
.left
;
1099 NtGdiMirrorWindowOrg(
1103 dc
= DC_LockDc(hdc
);
1106 SetLastWin32Error(ERROR_INVALID_HANDLE
);
1109 IntMirrorWindowOrg(dc
);
1121 IN INT cxVirtualDevice
,
1122 IN INT cyVirtualDevice
)
1127 if (!cxVirtualDevice
||
1128 !cyVirtualDevice
) return FALSE
;
1130 dc
= DC_LockDc(hdc
);
1131 if (!dc
) return FALSE
;
1133 pDc_Attr
= dc
->pDc_Attr
;
1134 if(!pDc_Attr
) pDc_Attr
= &dc
->Dc_Attr
;
1136 pDc_Attr
->szlVirtualDeviceSize
.cx
= cxVirtualDevice
;
1137 pDc_Attr
->szlVirtualDeviceSize
.cy
= cyVirtualDevice
;
1139 // DC_UpdateXforms(dc);
1150 NtGdiSetVirtualResolution(
1152 IN INT cxVirtualDevicePixel
,
1153 IN INT cyVirtualDevicePixel
,
1154 IN INT cxVirtualDeviceMm
,
1155 IN INT cyVirtualDeviceMm
)
1160 // Need test types for zeros and non zeros
1162 dc
= DC_LockDc(hdc
);
1163 if (!dc
) return FALSE
;
1165 pDc_Attr
= dc
->pDc_Attr
;
1166 if(!pDc_Attr
) pDc_Attr
= &dc
->Dc_Attr
;
1168 pDc_Attr
->szlVirtualDevicePixel
.cx
= cxVirtualDevicePixel
;
1169 pDc_Attr
->szlVirtualDevicePixel
.cy
= cyVirtualDevicePixel
;
1170 pDc_Attr
->szlVirtualDeviceMm
.cx
= cxVirtualDeviceMm
;
1171 pDc_Attr
->szlVirtualDeviceMm
.cy
= cyVirtualDeviceMm
;
1173 // DC_UpdateXforms(dc);