Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1145 lines
33 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: xform.c
  3. *
  4. * Created: 01-Dec-1994 09:58:41
  5. * Author: Eric Kutter [erick]
  6. *
  7. * Copyright (c) 1993-1999 Microsoft Corporation
  8. *
  9. \**************************************************************************/
  10. #include "precomp.h"
  11. #pragma hdrstop
  12. /******************************Macro***************************************\
  13. *
  14. * Transform macros
  15. *
  16. *
  17. *
  18. *
  19. *
  20. *
  21. *
  22. * History:
  23. *
  24. * 16-Jan-1996 -by- Mark Enstrom [marke]
  25. *
  26. \**************************************************************************/
  27. #define DCA_PAGE_EXTENTS_CHANGED(pdcattr) \
  28. { \
  29. CLEAR_CACHED_TEXT(pdcattr); \
  30. pdcattr->flXform |= (INVALIDATE_ATTRIBUTES | \
  31. PAGE_EXTENTS_CHANGED | \
  32. DEVICE_TO_WORLD_INVALID); \
  33. }
  34. #define DCA_PAGE_XLATE_CHANGED(pdcattr) \
  35. { \
  36. pdcattr->flXform |= (PAGE_XLATE_CHANGED | \
  37. DEVICE_TO_WORLD_INVALID); \
  38. }
  39. #define GET_LOGICAL_WINDOW_ORG_X(pdcattr, pptl) \
  40. { \
  41. pptl->x = pdcattr->lWindowOrgx; \
  42. }
  43. #define SET_LOGICAL_WINDOW_ORG_X(pdcattr, x) \
  44. { \
  45. pdcattr->lWindowOrgx = x; \
  46. }
  47. #define MIRROR_WINDOW_ORG(hdc, pdcAttr) \
  48. { \
  49. if (pdcAttr->dwLayout & LAYOUT_RTL) { \
  50. NtGdiMirrorWindowOrg(hdc); \
  51. } \
  52. }
  53. #define MIRROR_X(pdcAttr, x) \
  54. { \
  55. if (pdcAttr->dwLayout & LAYOUT_RTL) \
  56. x = -x; \
  57. }
  58. DWORD APIENTRY
  59. SetLayoutWidth(HDC hdc, LONG wox, DWORD dwLayout)
  60. {
  61. DWORD dwRet = GDI_ERROR;
  62. FIXUP_HANDLE(hdc);
  63. if(!IS_ALTDC_TYPE(hdc))
  64. {
  65. PDC_ATTR pdcattr;
  66. PSHARED_GET_VALIDATE((PVOID)pdcattr,hdc,DC_TYPE);
  67. if (pdcattr) {
  68. dwRet = NtGdiSetLayout(hdc, wox, dwLayout);
  69. } else {
  70. GdiSetLastError(ERROR_INVALID_PARAMETER);
  71. }
  72. }
  73. return dwRet;
  74. }
  75. DWORD APIENTRY
  76. SetLayout(HDC hdc, DWORD dwLayout)
  77. {
  78. PDC_ATTR pdcattr;
  79. DWORD dwRet = GDI_ERROR;
  80. FIXUP_HANDLE(hdc);
  81. if(IS_ALTDC_TYPE(hdc))
  82. {
  83. PLDC pldc;
  84. if (IS_METADC16_TYPE(hdc))
  85. return(MF16_RecordParmsD(hdc,dwLayout,META_SETLAYOUT));
  86. DC_PLDC(hdc,pldc,dwRet)
  87. if (pldc->iType == LO_METADC) {
  88. if (!MF_SetD(hdc,dwLayout,EMR_SETLAYOUT)) {
  89. return dwRet;
  90. }
  91. }
  92. }
  93. PSHARED_GET_VALIDATE((PVOID)pdcattr,hdc,DC_TYPE);
  94. if (pdcattr) {
  95. dwRet = NtGdiSetLayout(hdc, -1, dwLayout);
  96. } else {
  97. GdiSetLastError(ERROR_INVALID_PARAMETER);
  98. }
  99. return dwRet;
  100. }
  101. DWORD APIENTRY
  102. GetLayout(HDC hdc)
  103. {
  104. DWORD dwRet = GDI_ERROR;
  105. FIXUP_HANDLE(hdc);
  106. if(!IS_METADC16_TYPE(hdc)) {
  107. PDC_ATTR pdcattr;
  108. PSHARED_GET_VALIDATE((PVOID)pdcattr,hdc,DC_TYPE);
  109. if (pdcattr) {
  110. dwRet = pdcattr->dwLayout;
  111. } else {
  112. GdiSetLastError(ERROR_INVALID_PARAMETER);
  113. }
  114. }
  115. return dwRet;
  116. }
  117. /******************************Public*Routine******************************\
  118. * GetMapMode *
  119. * *
  120. * Client side stub. *
  121. * *
  122. * Fri 07-Jun-1991 18:01:50 -by- Charles Whitmer [chuckwh] *
  123. * Wrote it. *
  124. \**************************************************************************/
  125. int APIENTRY GetMapMode(HDC hdc)
  126. {
  127. int iRet = 0;
  128. FIXUP_HANDLE(hdc);
  129. if (!IS_METADC16_TYPE(hdc))
  130. {
  131. PDC_ATTR pdcattr;
  132. PSHARED_GET_VALIDATE((PVOID)pdcattr,hdc,DC_TYPE);
  133. if (pdcattr)
  134. {
  135. iRet = pdcattr->iMapMode;
  136. }
  137. else
  138. {
  139. GdiSetLastError(ERROR_INVALID_PARAMETER);
  140. }
  141. }
  142. return(iRet);
  143. }
  144. /******************************Public*Routine******************************\
  145. * SetMapMode *
  146. * *
  147. * Client side stub. *
  148. * *
  149. * History: *
  150. * Thu 06-Jun-1991 23:10:01 -by- Charles Whitmer [chuckwh] *
  151. * Wrote it. *
  152. * *
  153. * Mon 22-May-1993 -by- Paul Butzi *
  154. * Converted to Size measured in micrometers. *
  155. \**************************************************************************/
  156. int META WINAPI SetMapMode(HDC hdc,int iMode)
  157. {
  158. int iRet = 0;
  159. FIXUP_HANDLE(hdc);
  160. if (IS_METADC16_TYPE(hdc))
  161. {
  162. iRet = MF16_RecordParms2(hdc,iMode,META_SETMAPMODE);
  163. }
  164. else
  165. {
  166. PDC_ATTR pdcattr;
  167. PSHARED_GET_VALIDATE((PVOID)pdcattr,hdc,DC_TYPE);
  168. if (pdcattr)
  169. {
  170. iRet = pdcattr->iMapMode;
  171. if ((iMode != pdcattr->iMapMode) || (iMode == MM_ISOTROPIC))
  172. {
  173. CLEAR_CACHED_TEXT(pdcattr);
  174. iRet =(int) GetAndSetDCDWord(
  175. hdc,
  176. GASDDW_MAPMODE,
  177. iMode,
  178. EMR_SETMAPMODE,
  179. 0,
  180. 0);
  181. }
  182. }
  183. else
  184. {
  185. GdiSetLastError(ERROR_INVALID_PARAMETER);
  186. }
  187. }
  188. return(iRet);
  189. }
  190. /******************************Public*Function*****************************\
  191. * GetWindowExtEx
  192. * GetViewportOrgEx
  193. * GetWindowOrgEx
  194. *
  195. * Client side stub.
  196. *
  197. * History:
  198. *
  199. * 11-Jan-1996 -by- Mark Enstrom [marke]
  200. * User dcattr for ext and org data
  201. * 09-Dec-1992 -by- Wendy Wu [wendywu]
  202. * Wrote it.
  203. \**************************************************************************/
  204. BOOL APIENTRY GetViewportExtEx(HDC hdc,LPSIZE psizl)
  205. {
  206. BOOL bRet = FALSE;
  207. PDC_ATTR pdcattr;
  208. FIXUP_HANDLE(hdc);
  209. PSHARED_GET_VALIDATE((PVOID)pdcattr,hdc,DC_TYPE);
  210. if (pdcattr)
  211. {
  212. if (psizl != (PSIZEL) NULL)
  213. {
  214. if ((pdcattr->flXform & PAGE_EXTENTS_CHANGED) &&
  215. (pdcattr->iMapMode == MM_ISOTROPIC))
  216. {
  217. NtGdiGetDCPoint (hdc, DCPT_VPEXT, (PPOINTL)psizl);
  218. }
  219. else
  220. {
  221. *psizl = pdcattr->szlViewportExt;
  222. }
  223. bRet = TRUE;
  224. }
  225. }
  226. return(bRet);
  227. }
  228. BOOL APIENTRY GetWindowExtEx(HDC hdc,LPSIZE psizl)
  229. {
  230. BOOL bRet = FALSE;
  231. PDC_ATTR pdcattr;
  232. FIXUP_HANDLE(hdc);
  233. PSHARED_GET_VALIDATE((PVOID)pdcattr,hdc,DC_TYPE);
  234. if (pdcattr)
  235. {
  236. if (psizl != (PSIZEL) NULL)
  237. {
  238. *psizl = pdcattr->szlWindowExt;
  239. MIRROR_X(pdcattr, psizl->cx);
  240. bRet = TRUE;
  241. }
  242. }
  243. return(bRet);
  244. }
  245. BOOL APIENTRY GetViewportOrgEx(HDC hdc,LPPOINT pptl)
  246. {
  247. BOOL bRet = FALSE;
  248. PDC_ATTR pdcattr;
  249. FIXUP_HANDLE(hdc);
  250. //
  251. // get DCATTR
  252. //
  253. PSHARED_GET_VALIDATE((PVOID)pdcattr,hdc,DC_TYPE);
  254. if (pdcattr)
  255. {
  256. if (pptl != (LPPOINT) NULL)
  257. {
  258. *pptl = *((LPPOINT)&pdcattr->ptlViewportOrg);
  259. MIRROR_X(pdcattr, pptl->x);
  260. bRet = TRUE;
  261. }
  262. }
  263. return(bRet);
  264. }
  265. BOOL APIENTRY GetWindowOrgEx(HDC hdc,LPPOINT pptl)
  266. {
  267. BOOL bRet = FALSE;
  268. PDC_ATTR pdcattr;
  269. FIXUP_HANDLE(hdc);
  270. //
  271. // get DCATTR
  272. //
  273. PSHARED_GET_VALIDATE((PVOID)pdcattr,hdc,DC_TYPE);
  274. if (pdcattr)
  275. {
  276. if (pptl != (LPPOINT) NULL)
  277. {
  278. *pptl = *((LPPOINT)&pdcattr->ptlWindowOrg);
  279. GET_LOGICAL_WINDOW_ORG_X(pdcattr, pptl);
  280. bRet = TRUE;
  281. }
  282. }
  283. return(bRet);
  284. }
  285. /******************************Public*Routine******************************\
  286. * SetViewportExtEx *
  287. * *
  288. * Client side stub. *
  289. * *
  290. * History: *
  291. * Thu 06-Jun-1991 23:10:01 -by- Charles Whitmer [chuckwh] *
  292. * Wrote it. *
  293. \**************************************************************************/
  294. BOOL META WINAPI SetViewportExtEx(HDC hdc,int x,int y,LPSIZE psizl)
  295. {
  296. BOOL bRet = FALSE;
  297. PDC_ATTR pdcattr;
  298. FIXUP_HANDLE(hdc);
  299. if (IS_ALTDC_TYPE(hdc))
  300. {
  301. PLDC pldc;
  302. if (IS_METADC16_TYPE(hdc))
  303. return(MF16_RecordParms3(hdc,x,y,META_SETVIEWPORTEXT));
  304. DC_PLDC(hdc,pldc,bRet);
  305. if (pldc->iType == LO_METADC)
  306. {
  307. if (!MF_SetViewportExtEx(hdc,x,y))
  308. return(bRet);
  309. }
  310. }
  311. PSHARED_GET_VALIDATE((PVOID)pdcattr,hdc,DC_TYPE);
  312. if (pdcattr)
  313. {
  314. //
  315. // if psizl is supplied, return old viewport ext
  316. //
  317. if (psizl != (PSIZEL) NULL)
  318. {
  319. *psizl = pdcattr->szlViewportExt;
  320. }
  321. //
  322. // if fixed scale and new exts equal old exts then no work needs
  323. // to be done
  324. //
  325. if (
  326. (pdcattr->iMapMode <= MM_MAX_FIXEDSCALE) ||
  327. (
  328. (pdcattr->szlViewportExt.cx == x) &&
  329. (pdcattr->szlViewportExt.cy == y)
  330. )
  331. )
  332. {
  333. return(TRUE);
  334. }
  335. //
  336. // Can't set to zero extents.
  337. //
  338. if ((x == 0) || (y == 0))
  339. {
  340. return(TRUE);
  341. }
  342. //
  343. // update extents and flags
  344. //
  345. CHECK_AND_FLUSH(hdc, pdcattr);
  346. pdcattr->szlViewportExt.cx = x;
  347. pdcattr->szlViewportExt.cy = y;
  348. MIRROR_WINDOW_ORG(hdc, pdcattr);
  349. DCA_PAGE_EXTENTS_CHANGED(pdcattr);
  350. return(TRUE);
  351. }
  352. else
  353. {
  354. GdiSetLastError(ERROR_INVALID_PARAMETER);
  355. }
  356. return(bRet);
  357. }
  358. /******************************Public*Routine******************************\
  359. * SetViewportOrgEx *
  360. * *
  361. * Client side stub. *
  362. * *
  363. * History: *
  364. * Thu 06-Jun-1991 23:10:01 -by- Charles Whitmer [chuckwh] *
  365. * Wrote it. *
  366. \**************************************************************************/
  367. BOOL META WINAPI SetViewportOrgEx(HDC hdc,int x,int y,LPPOINT pptl)
  368. {
  369. POINT pt;
  370. BOOL bRet = FALSE;
  371. PDC_ATTR pdcattr;
  372. FIXUP_HANDLE(hdc);
  373. if (IS_ALTDC_TYPE(hdc))
  374. {
  375. PLDC pldc;
  376. if (IS_METADC16_TYPE(hdc))
  377. return(MF16_RecordParms3(hdc,x,y,META_SETVIEWPORTORG));
  378. DC_PLDC(hdc,pldc,bRet);
  379. if (pldc->iType == LO_METADC)
  380. {
  381. if (!MF_SetViewportOrgEx(hdc,x,y))
  382. return(bRet);
  383. }
  384. }
  385. //
  386. // get DCATTR
  387. //
  388. PSHARED_GET_VALIDATE((PVOID)pdcattr,hdc,DC_TYPE);
  389. if (pdcattr)
  390. {
  391. bRet = TRUE;
  392. MIRROR_X(pdcattr, x);
  393. if (pptl != (LPPOINT) NULL)
  394. {
  395. *pptl = *((LPPOINT)&pdcattr->ptlViewportOrg);
  396. MIRROR_X(pdcattr, pptl->x);
  397. }
  398. if (!
  399. ((pdcattr->ptlViewportOrg.x == x) && (pdcattr->ptlViewportOrg.y == y))
  400. )
  401. {
  402. pdcattr->ptlViewportOrg.x = x;
  403. pdcattr->ptlViewportOrg.y = y;
  404. DCA_PAGE_XLATE_CHANGED(pdcattr);
  405. }
  406. }
  407. return(bRet);
  408. }
  409. /******************************Public*Routine******************************\
  410. * SetWindowExtEx *
  411. * *
  412. * Client side stub. *
  413. * *
  414. * History: *
  415. * Thu 06-Jun-1991 23:10:01 -by- Charles Whitmer [chuckwh] *
  416. * Wrote it. *
  417. \**************************************************************************/
  418. BOOL META WINAPI SetWindowExtEx(HDC hdc,int x,int y,LPSIZE psizl)
  419. {
  420. BOOL bRet = FALSE;
  421. PDC_ATTR pdcattr;
  422. #if DBG_XFORM
  423. DbgPrint("SetWindowExtEx: hdc = %p, (%lx, %lx)\n", hdc, x, y);
  424. #endif
  425. FIXUP_HANDLE(hdc);
  426. if (IS_ALTDC_TYPE(hdc))
  427. {
  428. PLDC pldc;
  429. if (IS_METADC16_TYPE(hdc))
  430. return(MF16_RecordParms3(hdc,x,y,META_SETWINDOWEXT));
  431. DC_PLDC(hdc,pldc,bRet);
  432. if (pldc->iType == LO_METADC)
  433. {
  434. if (!MF_SetWindowExtEx(hdc,x,y))
  435. return(bRet);
  436. }
  437. }
  438. PSHARED_GET_VALIDATE((PVOID)pdcattr,hdc,DC_TYPE);
  439. if (pdcattr)
  440. {
  441. bRet = TRUE;
  442. //
  443. // Get old extents and return if either of these is true
  444. // 1) Fixed scale mapping mode. (Can't change extent)
  445. // 2) Set to the same size.
  446. //
  447. MIRROR_X(pdcattr, x);
  448. if (psizl != (PSIZEL) NULL)
  449. {
  450. *psizl = pdcattr->szlWindowExt;
  451. MIRROR_X(pdcattr, psizl->cx);
  452. }
  453. if (
  454. (pdcattr->iMapMode <= MM_MAX_FIXEDSCALE) ||
  455. ((pdcattr->szlWindowExt.cx == x) && (pdcattr->szlWindowExt.cy == y))
  456. )
  457. {
  458. return(TRUE);
  459. }
  460. //
  461. // Can't set to zero.
  462. //
  463. if (x == 0 || y == 0)
  464. {
  465. return(FALSE);
  466. }
  467. CHECK_AND_FLUSH(hdc,pdcattr);
  468. pdcattr->szlWindowExt.cx = x;
  469. pdcattr->szlWindowExt.cy = y;
  470. MIRROR_WINDOW_ORG(hdc, pdcattr);
  471. DCA_PAGE_EXTENTS_CHANGED(pdcattr);
  472. }
  473. else
  474. {
  475. GdiSetLastError(ERROR_INVALID_PARAMETER);
  476. }
  477. return(bRet);
  478. }
  479. /******************************Public*Routine******************************\
  480. * SetWindowOrgEx *
  481. * *
  482. * Client side stub. *
  483. * *
  484. * History: *
  485. * Thu 06-Jun-1991 23:10:01 -by- Charles Whitmer [chuckwh] *
  486. * Wrote it. *
  487. \**************************************************************************/
  488. BOOL META WINAPI SetWindowOrgEx(HDC hdc,int x,int y,LPPOINT pptl)
  489. {
  490. BOOL bRet = FALSE;
  491. PDC_ATTR pdcattr;
  492. FIXUP_HANDLE(hdc);
  493. if (IS_ALTDC_TYPE(hdc))
  494. {
  495. PLDC pldc;
  496. if (IS_METADC16_TYPE(hdc))
  497. return(MF16_RecordParms3(hdc,x,y,META_SETWINDOWORG));
  498. DC_PLDC(hdc,pldc,bRet);
  499. if (pldc->iType == LO_METADC)
  500. {
  501. if (!MF_SetWindowOrgEx(hdc,x,y))
  502. return(bRet);
  503. }
  504. }
  505. PSHARED_GET_VALIDATE((PVOID)pdcattr,hdc,DC_TYPE);
  506. if (pdcattr)
  507. {
  508. bRet = TRUE;
  509. if (pptl != (LPPOINT) NULL)
  510. {
  511. *pptl = *((LPPOINT)&pdcattr->ptlWindowOrg);
  512. GET_LOGICAL_WINDOW_ORG_X(pdcattr, pptl);
  513. }
  514. if (
  515. !((pdcattr->ptlWindowOrg.x == x) && (pdcattr->ptlWindowOrg.y == y))
  516. )
  517. {
  518. CHECK_AND_FLUSH(hdc,pdcattr);
  519. pdcattr->ptlWindowOrg.x = x;
  520. pdcattr->ptlWindowOrg.y = y;
  521. SET_LOGICAL_WINDOW_ORG_X(pdcattr, x);
  522. MIRROR_WINDOW_ORG(hdc, pdcattr);
  523. DCA_PAGE_XLATE_CHANGED(pdcattr);
  524. }
  525. }
  526. return(bRet);
  527. }
  528. /******************************Public*Routine******************************\
  529. * OffsetViewportOrgEx *
  530. * *
  531. * Client side stub. *
  532. * *
  533. * History: *
  534. * Thu 06-Jun-1991 23:10:01 -by- Charles Whitmer [chuckwh] *
  535. * Wrote it. *
  536. \**************************************************************************/
  537. BOOL META WINAPI OffsetViewportOrgEx(HDC hdc,int x,int y,LPPOINT pptl)
  538. {
  539. POINT pt;
  540. BOOL bRet = FALSE;
  541. PDC_ATTR pdcattr;
  542. FIXUP_HANDLE(hdc);
  543. if (IS_ALTDC_TYPE(hdc))
  544. {
  545. PLDC pldc;
  546. if (IS_METADC16_TYPE(hdc))
  547. return(MF16_RecordParms3(hdc,x,y,META_OFFSETVIEWPORTORG));
  548. DC_PLDC(hdc,pldc,bRet);
  549. if (pldc->iType == LO_METADC)
  550. {
  551. if (!MF_OffsetViewportOrgEx(hdc,x,y))
  552. return(bRet);
  553. }
  554. }
  555. //
  556. // get DCATTR
  557. //
  558. PSHARED_GET_VALIDATE((PVOID)pdcattr,hdc,DC_TYPE);
  559. if (pdcattr)
  560. {
  561. bRet = TRUE;
  562. MIRROR_X(pdcattr, x);
  563. if (pptl != (LPPOINT) NULL)
  564. {
  565. *pptl = *((LPPOINT)&pdcattr->ptlViewportOrg);
  566. MIRROR_X(pdcattr, pptl->x);
  567. }
  568. if ((x != 0) || (y != 0))
  569. {
  570. CHECK_AND_FLUSH(hdc, pdcattr);
  571. pdcattr->ptlViewportOrg.x+=x;
  572. pdcattr->ptlViewportOrg.y+=y;
  573. DCA_PAGE_XLATE_CHANGED(pdcattr);
  574. }
  575. }
  576. return(bRet);
  577. }
  578. /******************************Public*Routine******************************\
  579. * OffsetWindowOrgEx *
  580. * *
  581. * Client side stub. *
  582. * *
  583. * History: *
  584. * Thu 06-Jun-1991 23:10:01 -by- Charles Whitmer [chuckwh] *
  585. * Wrote it. *
  586. \**************************************************************************/
  587. BOOL META WINAPI OffsetWindowOrgEx(HDC hdc,int x,int y,LPPOINT pptl)
  588. {
  589. BOOL bRet = FALSE;
  590. PDC_ATTR pdcattr;
  591. FIXUP_HANDLE(hdc);
  592. if (IS_ALTDC_TYPE(hdc))
  593. {
  594. PLDC pldc;
  595. if (IS_METADC16_TYPE(hdc))
  596. return(MF16_RecordParms3(hdc,x,y,META_OFFSETWINDOWORG));
  597. DC_PLDC(hdc,pldc,bRet);
  598. if (pldc->iType == LO_METADC)
  599. {
  600. if (!MF_OffsetWindowOrgEx(hdc,x,y))
  601. return(bRet);
  602. }
  603. }
  604. PSHARED_GET_VALIDATE((PVOID)pdcattr,hdc,DC_TYPE);
  605. if (pdcattr)
  606. {
  607. bRet = TRUE;
  608. if (pptl != (LPPOINT) NULL)
  609. {
  610. *pptl = *((LPPOINT)&pdcattr->ptlWindowOrg);
  611. GET_LOGICAL_WINDOW_ORG_X(pdcattr, pptl);
  612. }
  613. if ((x != 0) || (y != 0))
  614. {
  615. CHECK_AND_FLUSH(hdc,pdcattr);
  616. pdcattr->ptlWindowOrg.x+=x;
  617. pdcattr->ptlWindowOrg.y+=y;
  618. pdcattr->lWindowOrgx +=x;
  619. DCA_PAGE_XLATE_CHANGED(pdcattr);
  620. }
  621. }
  622. return(bRet);
  623. }
  624. /******************************Public*Routine******************************\
  625. *
  626. * int SetGraphicsMode(HDC hdc,int iMode)
  627. *
  628. * the same as SetGraphicsMode, except it does not do any checks
  629. *
  630. * History:
  631. * 3-Nov-1994 -by- Lingyun Wang [lingyunw]
  632. * moved client side attr to server side
  633. * 02-Dec-1992 -by- Bodin Dresevic [BodinD]
  634. * Wrote it.
  635. \**************************************************************************/
  636. int META APIENTRY SetGraphicsMode(HDC hdc,int iMode)
  637. {
  638. int iRet = 0;
  639. PDC_ATTR pDcAttr;
  640. FIXUP_HANDLE(hdc);
  641. PSHARED_GET_VALIDATE((PVOID)pDcAttr,hdc,DC_TYPE);
  642. if (pDcAttr &&
  643. ((iMode == GM_COMPATIBLE) || (iMode == GM_ADVANCED)))
  644. {
  645. if (iMode == pDcAttr->iGraphicsMode)
  646. return iMode;
  647. CLEAR_CACHED_TEXT(pDcAttr);
  648. iRet = pDcAttr->iGraphicsMode;
  649. CHECK_AND_FLUSH(hdc,pDcAttr);
  650. pDcAttr->iGraphicsMode = iMode;
  651. }
  652. else
  653. {
  654. GdiSetLastError(ERROR_INVALID_PARAMETER);
  655. }
  656. return(iRet);
  657. }
  658. /******************************Public*Routine******************************\
  659. * ScaleViewportExtEx *
  660. * *
  661. * Client side stub. *
  662. * *
  663. * History: *
  664. * Thu 06-Jun-1991 23:10:01 -by- Charles Whitmer [chuckwh] *
  665. * Wrote it. *
  666. \**************************************************************************/
  667. BOOL META WINAPI ScaleViewportExtEx
  668. (
  669. HDC hdc,
  670. int xNum,
  671. int xDenom,
  672. int yNum,
  673. int yDenom,
  674. LPSIZE psizl
  675. )
  676. {
  677. BOOL bRet = FALSE;
  678. PDC_ATTR pDcAttr;
  679. FIXUP_HANDLE(hdc);
  680. if (IS_ALTDC_TYPE(hdc))
  681. {
  682. PLDC pldc;
  683. if (IS_METADC16_TYPE(hdc))
  684. return (MF16_RecordParms5(hdc,xNum,xDenom,yNum,
  685. yDenom,META_SCALEVIEWPORTEXT));
  686. DC_PLDC(hdc,pldc,bRet);
  687. if (pldc->iType == LO_METADC)
  688. {
  689. if (!MF_SetDDDD(hdc,(DWORD)xNum,(DWORD)xDenom,
  690. (DWORD)yNum,(DWORD)yDenom,EMR_SCALEVIEWPORTEXTEX))
  691. return(bRet);
  692. }
  693. }
  694. PSHARED_GET_VALIDATE((PVOID)pDcAttr,hdc,DC_TYPE);
  695. if (pDcAttr)
  696. {
  697. CLEAR_CACHED_TEXT(pDcAttr);
  698. bRet = NtGdiScaleViewportExtEx(hdc,xNum,xDenom,yNum,yDenom,psizl);
  699. }
  700. else
  701. {
  702. GdiSetLastError(ERROR_INVALID_PARAMETER);
  703. }
  704. return(bRet);
  705. }
  706. /******************************Public*Routine******************************\
  707. * ScaleWindowExtEx *
  708. * *
  709. * Client side stub. *
  710. * *
  711. * History: *
  712. * Thu 06-Jun-1991 23:10:01 -by- Charles Whitmer [chuckwh] *
  713. * Wrote it. *
  714. \**************************************************************************/
  715. BOOL META WINAPI ScaleWindowExtEx
  716. (
  717. HDC hdc,
  718. int xNum,
  719. int xDenom,
  720. int yNum,
  721. int yDenom,
  722. LPSIZE psizl
  723. )
  724. {
  725. BOOL bRet = FALSE;
  726. PDC_ATTR pDcAttr;
  727. FIXUP_HANDLE(hdc);
  728. if (IS_ALTDC_TYPE(hdc))
  729. {
  730. PLDC pldc;
  731. if (IS_METADC16_TYPE(hdc))
  732. return (MF16_RecordParms5(hdc,xNum,xDenom,yNum,yDenom,META_SCALEWINDOWEXT));
  733. DC_PLDC(hdc,pldc,bRet);
  734. if (pldc->iType == LO_METADC)
  735. {
  736. if (!MF_SetDDDD(hdc,(DWORD)xNum,(DWORD)xDenom,(DWORD)yNum,(DWORD)yDenom,EMR_SCALEWINDOWEXTEX))
  737. return(bRet);
  738. }
  739. }
  740. PSHARED_GET_VALIDATE((PVOID)pDcAttr,hdc,DC_TYPE);
  741. if (pDcAttr)
  742. {
  743. CLEAR_CACHED_TEXT(pDcAttr);
  744. bRet = NtGdiScaleWindowExtEx(hdc,xNum,xDenom,yNum,yDenom,psizl);
  745. }
  746. else
  747. {
  748. GdiSetLastError(ERROR_INVALID_PARAMETER);
  749. }
  750. return(bRet);
  751. }
  752. /******************************Public*Routine******************************\
  753. * SetVirtualResolution *
  754. * *
  755. * Client side stub. This is a private api for metafile component. *
  756. * *
  757. * Set the virtual resolution of the specified dc. *
  758. * The virtual resolution is used to compute transform matrix in metafiles. *
  759. * Otherwise, we will need to duplicate server transform code here. *
  760. * *
  761. * If the virtual units are all zeros, the default physical units are used. *
  762. * Otherwise, non of the units can be zero. *
  763. * *
  764. * Currently used by metafile component only. *
  765. * *
  766. * History: *
  767. * Tue Aug 27 16:55:36 1991 -by- Hock San Lee [hockl] *
  768. * Wrote it. *
  769. \**************************************************************************/
  770. BOOL WINAPI SetVirtualResolution
  771. (
  772. HDC hdc,
  773. int cxVirtualDevicePixel, // Width of the device in pels
  774. int cyVirtualDevicePixel, // Height of the device in pels
  775. int cxVirtualDeviceMm, // Width of the device in millimeters
  776. int cyVirtualDeviceMm // Height of the device in millimeters
  777. )
  778. {
  779. FIXUP_HANDLE(hdc);
  780. return(NtGdiSetVirtualResolution(
  781. hdc,
  782. cxVirtualDevicePixel,
  783. cyVirtualDevicePixel,
  784. cxVirtualDeviceMm,
  785. cyVirtualDeviceMm
  786. ));
  787. }
  788. /******************************Public*Routine******************************\
  789. * SetSizeDevice *
  790. * *
  791. * Client side stub. This is a private api for metafile component. *
  792. * *
  793. * This is to fix rounding error in vMakeIso in xformgdi.cxx *
  794. * The cx/yVirtualDeviceMm set in SetVirtualResoltion could result in slight*
  795. * rounding error which will cause problem when accumulated *
  796. * *
  797. * Currently used by metafile component only. *
  798. * *
  799. * History: *
  800. * 5/17/99 -by- Lingyun Wang [lingyunw] *
  801. * Wrote it. *
  802. \**************************************************************************/
  803. BOOL SetSizeDevice
  804. (
  805. HDC hdc,
  806. int cxVirtualDevice, // Width of the device in micrometers
  807. int cyVirtualDevice // Height of the device in micrometers
  808. )
  809. {
  810. FIXUP_HANDLE(hdc);
  811. return(NtGdiSetSizeDevice(
  812. hdc,
  813. cxVirtualDevice,
  814. cyVirtualDevice
  815. ));
  816. }
  817. /******************************Public*Routine******************************\
  818. * GetTransform()
  819. *
  820. * History:
  821. * 30-Nov-1994 -by- Eric Kutter [erick]
  822. * Wrote it.
  823. \**************************************************************************/
  824. BOOL APIENTRY GetTransform(
  825. HDC hdc,
  826. ULONG iXform,
  827. PXFORM pxf)
  828. {
  829. FIXUP_HANDLE(hdc);
  830. return(NtGdiGetTransform(hdc,iXform,pxf));
  831. }
  832. /******************************Public*Routine******************************\
  833. * GetWorldTransform *
  834. * *
  835. * Client side stub. *
  836. * *
  837. * Fri 07-Jun-1991 18:01:50 -by- Charles Whitmer [chuckwh] *
  838. * Wrote it. *
  839. \**************************************************************************/
  840. BOOL APIENTRY GetWorldTransform(HDC hdc,LPXFORM pxform)
  841. {
  842. FIXUP_HANDLE(hdc);
  843. return(GetTransform(hdc,XFORM_WORLD_TO_PAGE,pxform));
  844. }
  845. /******************************Public*Routine******************************\
  846. * ModifyTransform()
  847. *
  848. * History:
  849. * 30-Nov-1994 -by- Eric Kutter [erick]
  850. * Wrote it.
  851. \**************************************************************************/
  852. BOOL META WINAPI ModifyWorldTransform(
  853. HDC hdc,
  854. CONST XFORM *pxf,
  855. DWORD iMode)
  856. {
  857. BOOL bRet = FALSE;
  858. PDC_ATTR pDcAttr;
  859. FIXUP_HANDLE(hdc);
  860. if (IS_ALTDC_TYPE(hdc))
  861. {
  862. PLDC pldc;
  863. if (IS_METADC16_TYPE(hdc))
  864. return(FALSE);
  865. DC_PLDC(hdc,pldc,bRet);
  866. if (pldc->iType == LO_METADC)
  867. {
  868. if (((iMode == MWT_SET) && !MF_SetWorldTransform(hdc,pxf)) ||
  869. !MF_ModifyWorldTransform(hdc,pxf,iMode))
  870. {
  871. return(FALSE);
  872. }
  873. }
  874. }
  875. PSHARED_GET_VALIDATE((PVOID)pDcAttr,hdc,DC_TYPE);
  876. if (pDcAttr)
  877. {
  878. if (pDcAttr->iGraphicsMode == GM_ADVANCED)
  879. {
  880. CLEAR_CACHED_TEXT(pDcAttr);
  881. bRet = NtGdiModifyWorldTransform(hdc,(PXFORM)pxf,iMode);
  882. }
  883. }
  884. else
  885. {
  886. GdiSetLastError(ERROR_INVALID_PARAMETER);
  887. }
  888. return(bRet);
  889. }
  890. /******************************Public*Routine******************************\
  891. * SetWorldTransform *
  892. * *
  893. * Client side stub. *
  894. * *
  895. * History: *
  896. * Thu 06-Jun-1991 23:10:01 -by- Charles Whitmer [chuckwh] *
  897. * Wrote it. *
  898. \**************************************************************************/
  899. BOOL META WINAPI SetWorldTransform(HDC hdc, CONST XFORM * pxform)
  900. {
  901. return(ModifyWorldTransform(hdc,pxform,MWT_SET));
  902. }
  903. /******************************Public*Routine******************************\
  904. * CombineTransform *
  905. * *
  906. * Client side stub. *
  907. * *
  908. * History: *
  909. * Thu 30-Jan-1992 16:10:09 -by- Wendy Wu [wendywu] *
  910. * Wrote it. *
  911. \**************************************************************************/
  912. BOOL WINAPI CombineTransform
  913. (
  914. LPXFORM pxformDst,
  915. CONST XFORM * pxformSrc1,
  916. CONST XFORM * pxformSrc2
  917. )
  918. {
  919. return(NtGdiCombineTransform(pxformDst,(PXFORM)pxformSrc1,(PXFORM)pxformSrc2));
  920. }