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.

1164 lines
26 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: ldc.c
  3. *
  4. * GDI functions that are handled on the client side.
  5. *
  6. * Created: 05-Jun-1991 01:45:21
  7. * Author: Charles Whitmer [chuckwh]
  8. *
  9. * Copyright (c) 1991-1999 Microsoft Corporation
  10. \**************************************************************************/
  11. #include "precomp.h"
  12. #pragma hdrstop
  13. #include "wowgdip.h"
  14. #define MIRRORED_DC(pDcAttr) (pDcAttr->dwLayout & LAYOUT_RTL)
  15. BOOL MF16_RecordParms2( HDC hdc, int parm2, WORD Func);
  16. /******************************Public*Routine******************************
  17. * GetAndSetDCDWord( HDC, UINT, UINT, UINT, UINT, UINT )
  18. *
  19. * Gerrit van Wingerden [gerritv]
  20. * 11-9-94 Wrote It.
  21. *
  22. **************************************************************************/
  23. DWORD GetAndSetDCDWord(
  24. HDC hdc,
  25. UINT uIndex,
  26. UINT uValue,
  27. UINT uEmr,
  28. WORD wEmr16,
  29. UINT uError )
  30. {
  31. DWORD uRet=0;
  32. DWORD retData;
  33. // Metafile the call.
  34. if( IS_ALTDC_TYPE(hdc) && ( uEmr != EMR_MAX+1 ) )
  35. {
  36. PLDC pldc;
  37. if (IS_METADC16_TYPE(hdc))
  38. return(MF16_RecordParmsD(hdc,uValue,wEmr16));
  39. DC_PLDC(hdc,pldc,uError)
  40. if (pldc->iType == LO_METADC)
  41. {
  42. if (!MF_SetD(hdc,(DWORD)uValue,uEmr))
  43. return(uRet);
  44. }
  45. }
  46. uRet = NtGdiGetAndSetDCDword(hdc,
  47. uIndex,
  48. uValue,
  49. &retData);
  50. return (( uRet ) ? retData : uError);
  51. }
  52. /******************************Public*Routine******************************\
  53. * SetBkMode
  54. *
  55. * Arguments:
  56. *
  57. * hdc - DC handle
  58. * iMode - new mode
  59. *
  60. * Return Value:
  61. *
  62. * Old mode value or 0 for failure
  63. *
  64. \**************************************************************************/
  65. int
  66. META
  67. APIENTRY
  68. SetBkMode(
  69. HDC hdc,
  70. int iMode
  71. )
  72. {
  73. int iModeOld = 0;
  74. PDC_ATTR pDcAttr;
  75. FIXUP_HANDLE(hdc);
  76. if( IS_ALTDC_TYPE(hdc) )
  77. {
  78. PLDC pldc;
  79. if (IS_METADC16_TYPE(hdc))
  80. return(MF16_RecordParmsD(hdc,iMode,META_SETBKMODE));
  81. DC_PLDC(hdc,pldc,iModeOld)
  82. if (pldc->iType == LO_METADC)
  83. {
  84. if (!MF_SetD(hdc,(DWORD)iMode,EMR_SETBKMODE))
  85. return(iModeOld);
  86. }
  87. }
  88. PSHARED_GET_VALIDATE(pDcAttr,hdc,DC_TYPE);
  89. if (pDcAttr)
  90. {
  91. iModeOld = pDcAttr->lBkMode;
  92. pDcAttr->jBkMode = (iMode == OPAQUE) ? OPAQUE : TRANSPARENT;
  93. pDcAttr->lBkMode = iMode;
  94. }
  95. else
  96. {
  97. GdiSetLastError(ERROR_INVALID_PARAMETER);
  98. }
  99. return(iModeOld);
  100. }
  101. /******************************Public*Routine******************************\
  102. * SetPolyFillMode
  103. *
  104. * Arguments:
  105. *
  106. * hdc - DC handle
  107. * iMode - new mode
  108. *
  109. * Return Value:
  110. *
  111. * Old mode value or 0 for failure
  112. *
  113. \**************************************************************************/
  114. int META APIENTRY SetPolyFillMode(HDC hdc,int iMode)
  115. {
  116. int iModeOld = 0;
  117. PDC_ATTR pDcAttr;
  118. FIXUP_HANDLE(hdc);
  119. if( IS_ALTDC_TYPE(hdc) )
  120. {
  121. PLDC pldc;
  122. if (IS_METADC16_TYPE(hdc))
  123. return(MF16_RecordParmsD(hdc,iMode,META_SETPOLYFILLMODE));
  124. DC_PLDC(hdc,pldc,iModeOld)
  125. if (pldc->iType == LO_METADC)
  126. {
  127. if (!MF_SetD(hdc,(DWORD)iMode,EMR_SETPOLYFILLMODE))
  128. return(iModeOld);
  129. }
  130. }
  131. PSHARED_GET_VALIDATE(pDcAttr,hdc,DC_TYPE);
  132. if (pDcAttr)
  133. {
  134. CHECK_AND_FLUSH(hdc, pDcAttr);
  135. iModeOld = pDcAttr->lFillMode;
  136. pDcAttr->jFillMode = (iMode == WINDING) ? WINDING : ALTERNATE;
  137. pDcAttr->lFillMode = iMode;
  138. }
  139. else
  140. {
  141. GdiSetLastError(ERROR_INVALID_PARAMETER);
  142. }
  143. return(iModeOld);
  144. }
  145. /******************************Public*Routine******************************\
  146. * SetROP2
  147. *
  148. * Arguments:
  149. *
  150. * hdc - DC handle
  151. * iMode - new mode
  152. *
  153. * Return Value:
  154. *
  155. * Old mode value or 0 for failure
  156. *
  157. \**************************************************************************/
  158. int META APIENTRY SetROP2(HDC hdc,int iMode)
  159. {
  160. int iOldROP2 = 0;
  161. PDC_ATTR pDcAttr;
  162. FIXUP_HANDLE(hdc);
  163. if( IS_ALTDC_TYPE(hdc) )
  164. {
  165. PLDC pldc;
  166. if (IS_METADC16_TYPE(hdc))
  167. return(MF16_RecordParmsD(hdc,iMode,META_SETROP2));
  168. DC_PLDC(hdc,pldc,iOldROP2)
  169. if (pldc->iType == LO_METADC)
  170. {
  171. if (!MF_SetD(hdc,(DWORD)iMode,EMR_SETROP2))
  172. return(iOldROP2);
  173. }
  174. }
  175. PSHARED_GET_VALIDATE(pDcAttr,hdc,DC_TYPE);
  176. if (pDcAttr)
  177. {
  178. CHECK_AND_FLUSH(hdc, pDcAttr);
  179. iOldROP2 = pDcAttr->jROP2;
  180. pDcAttr->jROP2 = (BYTE)iMode;
  181. }
  182. else
  183. {
  184. GdiSetLastError(ERROR_INVALID_PARAMETER);
  185. }
  186. return(iOldROP2);
  187. }
  188. /******************************Public*Routine******************************\
  189. * SetStretchBltMode
  190. *
  191. * Arguments:
  192. *
  193. * hdc - DC handle
  194. * iMode - new mode
  195. *
  196. * Return Value:
  197. *
  198. * Old mode value or 0 for failure
  199. *
  200. \**************************************************************************/
  201. int META APIENTRY SetStretchBltMode(HDC hdc,int iMode)
  202. {
  203. int iModeOld = 0;
  204. PDC_ATTR pDcAttr;
  205. FIXUP_HANDLE(hdc);
  206. if( IS_ALTDC_TYPE(hdc) )
  207. {
  208. PLDC pldc;
  209. if (IS_METADC16_TYPE(hdc))
  210. return(MF16_RecordParmsD(hdc,iMode,META_SETSTRETCHBLTMODE));
  211. DC_PLDC(hdc,pldc,iModeOld)
  212. if (pldc->iType == LO_METADC)
  213. {
  214. if (!MF_SetD(hdc,(DWORD)iMode,EMR_SETSTRETCHBLTMODE))
  215. return(iModeOld);
  216. }
  217. }
  218. PSHARED_GET_VALIDATE(pDcAttr,hdc,DC_TYPE);
  219. if (pDcAttr)
  220. {
  221. iModeOld = pDcAttr->lStretchBltMode;
  222. pDcAttr->lStretchBltMode = iMode;
  223. if ((iMode <= 0) || (iMode > MAXSTRETCHBLTMODE))
  224. {
  225. iMode = (DWORD) WHITEONBLACK;
  226. }
  227. pDcAttr->jStretchBltMode = (BYTE)iMode;
  228. }
  229. else
  230. {
  231. GdiSetLastError(ERROR_INVALID_PARAMETER);
  232. }
  233. return(iModeOld);
  234. }
  235. /******************************Public*Routine******************************\
  236. * SetTextAlign
  237. *
  238. * Arguments:
  239. *
  240. * hdc - DC handle
  241. * iMode - new mode
  242. *
  243. * Return Value:
  244. *
  245. * Old mode value or 0 for failure
  246. *
  247. \**************************************************************************/
  248. UINT META APIENTRY SetTextAlign(HDC hdc,UINT iMode)
  249. {
  250. int iModeOld = GDI_ERROR;
  251. PDC_ATTR pDcAttr;
  252. FIXUP_HANDLE(hdc);
  253. if( IS_ALTDC_TYPE(hdc) )
  254. {
  255. PLDC pldc;
  256. if (IS_METADC16_TYPE(hdc))
  257. return(MF16_RecordParmsD(hdc,iMode,META_SETTEXTALIGN));
  258. DC_PLDC(hdc,pldc,iModeOld)
  259. if (pldc->iType == LO_METADC)
  260. {
  261. if (!MF_SetD(hdc,(DWORD)iMode,EMR_SETTEXTALIGN))
  262. return(iModeOld);
  263. }
  264. }
  265. PSHARED_GET_VALIDATE(pDcAttr,hdc,DC_TYPE);
  266. if (pDcAttr)
  267. {
  268. iModeOld = pDcAttr->lTextAlign;
  269. pDcAttr->lTextAlign = iMode;
  270. if (MIRRORED_DC(pDcAttr) && (iMode & TA_CENTER) != TA_CENTER) {
  271. iMode = iMode ^ TA_RIGHT;
  272. }
  273. pDcAttr->flTextAlign = iMode & (TA_UPDATECP | TA_CENTER | TA_BASELINE);
  274. }
  275. else
  276. {
  277. GdiSetLastError(ERROR_INVALID_PARAMETER);
  278. }
  279. return(iModeOld);
  280. }
  281. /******************************Public*Routine******************************\
  282. * SetRelAbs (hdc,iMode)
  283. *
  284. * Client side attribute setting routine.
  285. *
  286. * History:
  287. * 5-11-94 -by- Lingyun Wang [lingyunw]
  288. * Moved client side attr to server side
  289. *
  290. * 09-Jun-1992 -by- Eric Kutter [erick]
  291. * Wrote it.
  292. \**************************************************************************/
  293. int APIENTRY SetRelAbs(HDC hdc,int iMode)
  294. {
  295. FIXUP_HANDLE(hdc);
  296. return((int) GetAndSetDCDWord( hdc,
  297. GASDDW_RELABS,
  298. iMode,
  299. EMR_MAX+1,
  300. EMR_MAX+1,
  301. 0 ));
  302. }
  303. /******************************Public*Routine******************************\
  304. * SetTextCharacterExtra (hdc,dx)
  305. *
  306. * Client side attribute setting routine.
  307. *
  308. * 5-11-94 -by- Lingyun Wang [lingyunw]
  309. * Moved client side attr to server side
  310. *
  311. * Sat 08-Jun-1991 00:53:45 -by- Charles Whitmer [chuckwh]
  312. * Wrote it.
  313. \**************************************************************************/
  314. int META APIENTRY SetTextCharacterExtra(HDC hdc,int dx)
  315. {
  316. int iRet = 0x80000000L;
  317. PDC_ATTR pDcAttr;
  318. FIXUP_HANDLE(hdc);
  319. // Validate the spacing.
  320. if (dx == 0x80000000)
  321. {
  322. GdiSetLastError(ERROR_INVALID_PARAMETER);
  323. return(iRet);
  324. }
  325. // Metafile the call for 16-bit only.
  326. // For enhanced metafiles, the extras are included in the textout records.
  327. if (IS_METADC16_TYPE(hdc))
  328. return(MF16_RecordParms2(hdc,dx,META_SETTEXTCHAREXTRA));
  329. PSHARED_GET_VALIDATE(pDcAttr,hdc,DC_TYPE);
  330. if (pDcAttr)
  331. {
  332. CHECK_AND_FLUSH_TEXT(hdc, pDcAttr);
  333. iRet = pDcAttr->lTextExtra;
  334. pDcAttr->lTextExtra = dx;
  335. }
  336. else
  337. {
  338. GdiSetLastError(ERROR_INVALID_PARAMETER);
  339. }
  340. return (iRet);
  341. }
  342. /******************************Public*Routine******************************\
  343. * SetTextColor
  344. *
  345. * Arguments:
  346. *
  347. * hdc - DC handle
  348. * color - new color
  349. *
  350. * Return Value:
  351. *
  352. * Old mode value or 0 for failure
  353. *
  354. \**************************************************************************/
  355. COLORREF META APIENTRY SetTextColor(HDC hdc,COLORREF color)
  356. {
  357. COLORREF crRet = CLR_INVALID;
  358. PDC_ATTR pdcattr;
  359. FIXUP_HANDLE(hdc);
  360. if( IS_ALTDC_TYPE(hdc) )
  361. {
  362. PLDC pldc;
  363. if (IS_METADC16_TYPE(hdc))
  364. return(MF16_RecordParmsD(hdc,color,META_SETTEXTCOLOR));
  365. DC_PLDC(hdc,pldc,crRet)
  366. if (pldc->iType == LO_METADC)
  367. {
  368. CHECK_COLOR_PAGE(pldc,color);
  369. if (!MF_SetD(hdc,(DWORD)color,EMR_SETTEXTCOLOR))
  370. return(crRet);
  371. }
  372. }
  373. PSHARED_GET_VALIDATE(pdcattr,hdc,DC_TYPE);
  374. if (pdcattr)
  375. {
  376. crRet = pdcattr->ulForegroundClr;
  377. pdcattr->ulForegroundClr = color;
  378. color &= 0x13ffffff;
  379. if (!(color & 0x01000000) && bNeedTranslateColor(pdcattr))
  380. {
  381. COLORREF NewColor;
  382. BOOL bStatus = IcmTranslateCOLORREF(hdc,
  383. pdcattr,
  384. color,
  385. &NewColor,
  386. ICM_FORWARD);
  387. if (bStatus)
  388. {
  389. color = NewColor;
  390. }
  391. }
  392. if (pdcattr->crForegroundClr != color)
  393. {
  394. pdcattr->crForegroundClr = color;
  395. pdcattr->ulDirty_ |= (DIRTY_FILL|DIRTY_LINE|DIRTY_TEXT);
  396. }
  397. }
  398. else
  399. {
  400. GdiSetLastError(ERROR_INVALID_PARAMETER);
  401. }
  402. return(crRet);
  403. }
  404. /******************************Public*Routine******************************\
  405. * SetBkColor
  406. *
  407. * Arguments:
  408. *
  409. * hdc - DC handle
  410. * color - new color
  411. *
  412. * Return Value:
  413. *
  414. * Old mode value or 0 for failure
  415. *
  416. \**************************************************************************/
  417. COLORREF META APIENTRY SetBkColor(HDC hdc,COLORREF color)
  418. {
  419. COLORREF crRet = CLR_INVALID;
  420. PDC_ATTR pdcattr;
  421. FIXUP_HANDLE(hdc);
  422. if( IS_ALTDC_TYPE(hdc) )
  423. {
  424. PLDC pldc;
  425. if (IS_METADC16_TYPE(hdc))
  426. return(MF16_RecordParmsD(hdc,color,META_SETBKCOLOR));
  427. DC_PLDC(hdc,pldc,crRet)
  428. if (pldc->iType == LO_METADC)
  429. {
  430. CHECK_COLOR_PAGE(pldc,color);
  431. if (!MF_SetD(hdc,(DWORD)color,EMR_SETBKCOLOR))
  432. return(crRet);
  433. }
  434. }
  435. PSHARED_GET_VALIDATE(pdcattr,hdc,DC_TYPE);
  436. if (pdcattr)
  437. {
  438. //
  439. // set app specified color
  440. //
  441. crRet = pdcattr->ulBackgroundClr;
  442. pdcattr->ulBackgroundClr = color;
  443. color &= 0x13ffffff;
  444. //
  445. // check icm if not PALINDEX
  446. //
  447. if (!(color & 0x01000000) && bNeedTranslateColor(pdcattr))
  448. {
  449. COLORREF NewColor;
  450. BOOL bStatus = IcmTranslateCOLORREF(hdc,
  451. pdcattr,
  452. color,
  453. &NewColor,
  454. ICM_FORWARD);
  455. if (bStatus)
  456. {
  457. color = NewColor;
  458. }
  459. }
  460. if (color != pdcattr->crBackgroundClr)
  461. {
  462. pdcattr->crBackgroundClr = color;
  463. pdcattr->ulDirty_ |= (DIRTY_FILL|DIRTY_LINE|DIRTY_BACKGROUND);
  464. }
  465. }
  466. else
  467. {
  468. GdiSetLastError(ERROR_INVALID_PARAMETER);
  469. }
  470. return(crRet);
  471. }
  472. /******************************Public*Routine******************************\
  473. * SetDCBrushColor
  474. *
  475. * Arguments:
  476. *
  477. * hdc - DC handle
  478. * color - new color
  479. *
  480. * Return Value:
  481. *
  482. * Old mode value or 0 for failure
  483. *
  484. * History :
  485. *
  486. * Feb.16.1997 -by- Hideyuki Nagase [hideyukn]
  487. * ICM-aware version.
  488. \**************************************************************************/
  489. COLORREF META APIENTRY SetDCBrushColor(HDC hdc,COLORREF color)
  490. {
  491. COLORREF crRet = CLR_INVALID;
  492. PDC_ATTR pdcattr;
  493. FIXUP_HANDLE(hdc);
  494. PSHARED_GET_VALIDATE(pdcattr,hdc,DC_TYPE);
  495. if (pdcattr)
  496. {
  497. if (IS_ALTDC_TYPE(hdc))
  498. {
  499. if (!IS_METADC16_TYPE(hdc))
  500. {
  501. PLDC pldc;
  502. DC_PLDC(hdc,pldc,crRet);
  503. if (pldc->iType == LO_METADC)
  504. {
  505. CHECK_COLOR_PAGE(pldc,color);
  506. if (pdcattr->hbrush == ghbrDCBrush)
  507. {
  508. BOOL bRet = FALSE;
  509. HBRUSH hbr = CreateSolidBrush (color);
  510. if (hbr != NULL)
  511. {
  512. // If there is an old DCbrush, delete it now
  513. if (pldc->oldSetDCBrushColorBrush)
  514. DeleteObject (pldc->oldSetDCBrushColorBrush);
  515. bRet = MF_SelectAnyObject (hdc, hbr, EMR_SELECTOBJECT);
  516. // Store the new tmp DC brush in the LDC.
  517. pldc->oldSetDCBrushColorBrush = hbr;
  518. }
  519. if (!bRet)
  520. return (CLR_INVALID);
  521. }
  522. }
  523. }
  524. }
  525. //
  526. // set app specified color
  527. //
  528. crRet = pdcattr->ulDCBrushClr;
  529. pdcattr->ulDCBrushClr = color;
  530. color &= 0x13ffffff;
  531. //
  532. // check icm if not PALINDEX
  533. //
  534. if (!(color & 0x01000000) && bNeedTranslateColor(pdcattr))
  535. {
  536. COLORREF NewColor;
  537. BOOL bStatus = IcmTranslateCOLORREF(hdc,
  538. pdcattr,
  539. color,
  540. &NewColor,
  541. ICM_FORWARD);
  542. if (bStatus)
  543. {
  544. color = NewColor;
  545. }
  546. }
  547. if (color != pdcattr->crDCBrushClr)
  548. {
  549. pdcattr->crDCBrushClr = color;
  550. pdcattr->ulDirty_ |= DIRTY_FILL;
  551. }
  552. }
  553. else
  554. {
  555. GdiSetLastError(ERROR_INVALID_PARAMETER);
  556. }
  557. return(crRet);
  558. }
  559. /******************************Public*Routine******************************\
  560. * GetDCBrushColor
  561. *
  562. * Arguments:
  563. *
  564. * hdc - DC handle
  565. *
  566. * Return Value:
  567. *
  568. * Old mode value or 0 for failure
  569. *
  570. \**************************************************************************/
  571. COLORREF META APIENTRY GetDCBrushColor(HDC hdc)
  572. {
  573. COLORREF crRet = CLR_INVALID;
  574. PDC_ATTR pDcAttr;
  575. FIXUP_HANDLE(hdc);
  576. PSHARED_GET_VALIDATE(pDcAttr,hdc,DC_TYPE);
  577. if (pDcAttr)
  578. {
  579. crRet = pDcAttr->ulDCBrushClr;
  580. }
  581. else
  582. {
  583. GdiSetLastError(ERROR_INVALID_PARAMETER);
  584. }
  585. return(crRet);
  586. }
  587. /******************************Public*Routine******************************\
  588. * SetDCPenColor
  589. *
  590. * Arguments:
  591. *
  592. * hdc - DC handle
  593. * color - new color
  594. *
  595. * Return Value:
  596. *
  597. * Old mode value or 0 for failure
  598. *
  599. * History :
  600. *
  601. * Feb.16.1997 -by- Hideyuki Nagase [hideyukn]
  602. * ICM-aware version.
  603. \**************************************************************************/
  604. COLORREF META APIENTRY SetDCPenColor(HDC hdc,COLORREF color)
  605. {
  606. COLORREF crRet = CLR_INVALID;
  607. PDC_ATTR pdcattr;
  608. FIXUP_HANDLE(hdc);
  609. PSHARED_GET_VALIDATE(pdcattr,hdc,DC_TYPE);
  610. if (pdcattr)
  611. {
  612. if(IS_ALTDC_TYPE(hdc))
  613. {
  614. if (!IS_METADC16_TYPE(hdc))
  615. {
  616. PLDC pldc;
  617. DC_PLDC(hdc,pldc,crRet);
  618. if (pldc->iType == LO_METADC)
  619. {
  620. CHECK_COLOR_PAGE(pldc,color);
  621. if (pdcattr->hpen == ghbrDCPen)
  622. {
  623. BOOL bRet = FALSE;
  624. HPEN hpen = CreatePen (PS_SOLID,0,color);
  625. if (hpen != NULL)
  626. {
  627. // If there is a old temp DC pen, delete it.
  628. if (pldc->oldSetDCPenColorPen)
  629. DeleteObject(pldc->oldSetDCPenColorPen);
  630. bRet = MF_SelectAnyObject (hdc, hpen, EMR_SELECTOBJECT);
  631. // Store the new tmp pen in the LDC.
  632. pldc->oldSetDCPenColorPen = hpen;
  633. }
  634. if (!bRet)
  635. return (CLR_INVALID);
  636. }
  637. }
  638. }
  639. }
  640. //
  641. // set app specified color
  642. //
  643. crRet = pdcattr->ulDCPenClr;
  644. pdcattr->ulDCPenClr = color;
  645. color &= 0x13ffffff;
  646. //
  647. // check icm if not PALINDEX
  648. //
  649. if (!(color & 0x01000000) && bNeedTranslateColor(pdcattr))
  650. {
  651. COLORREF NewColor;
  652. BOOL bStatus = IcmTranslateCOLORREF(hdc,
  653. pdcattr,
  654. color,
  655. &NewColor,
  656. ICM_FORWARD);
  657. if (bStatus)
  658. {
  659. color = NewColor;
  660. }
  661. }
  662. if (color != pdcattr->crDCPenClr)
  663. {
  664. pdcattr->crDCPenClr = color;
  665. pdcattr->ulDirty_ |= DIRTY_LINE;
  666. }
  667. }
  668. else
  669. {
  670. GdiSetLastError(ERROR_INVALID_PARAMETER);
  671. }
  672. return(crRet);
  673. }
  674. /******************************Public*Routine******************************\
  675. * GetDCPenColor
  676. *
  677. * Arguments:
  678. *
  679. * hdc - DC handle
  680. *
  681. * Return Value:
  682. *
  683. * Old mode value or 0 for failure
  684. *
  685. \**************************************************************************/
  686. COLORREF META APIENTRY GetDCPenColor(HDC hdc)
  687. {
  688. COLORREF crRet = CLR_INVALID;
  689. PDC_ATTR pDcAttr;
  690. FIXUP_HANDLE(hdc);
  691. PSHARED_GET_VALIDATE(pDcAttr,hdc,DC_TYPE);
  692. if (pDcAttr)
  693. {
  694. crRet = pDcAttr->ulDCPenClr;
  695. }
  696. else
  697. {
  698. GdiSetLastError(ERROR_INVALID_PARAMETER);
  699. }
  700. return(crRet);
  701. }
  702. /******************************Public*Routine******************************
  703. * GetDCDWord( HDC hdc, UINT index, UINT error )
  704. *
  705. * This routine can be used to return a DWORD of information about a DC
  706. * from the server side. The parameter index is used to specify which
  707. * one. The values for indext are define in "ntgdi.h"
  708. *
  709. * Gerrit van Wingerden [gerritv]
  710. * 11-9-94 Wrote It.
  711. *
  712. **************************************************************************/
  713. DWORD GetDCDWord( HDC hdc, UINT index, INT error )
  714. {
  715. DWORD uRet=0;
  716. DWORD retData;
  717. uRet = NtGdiGetDCDword(hdc,
  718. index,
  719. &retData);
  720. return (uRet ? retData : error);
  721. }
  722. /******************************Public*Routine******************************\
  723. * GetGraphicsMode(hdc)
  724. * GetROP2(hdc)
  725. * GetBkMode(hdc)
  726. * GetPolyFillMode(hdc)
  727. * GetStretchBltMode(hdc)
  728. * GetTextAlign(hdc)
  729. * GetTextCharacterExtra(hdc)
  730. * GetTextColor(hdc)
  731. * GetBkColor(hdc)
  732. * GetRelAbs(hdc)
  733. * GetFontLanguageInfo(hdc)
  734. *
  735. * added by Lingyunw:
  736. * GetBreakExtra (hdc)
  737. * GetcBreak (hdc)
  738. *
  739. * Simple client side handlers that just retrieve data from the LDC.
  740. *
  741. * Mon 19-Oct-1992 -by- Bodin Dresevic [BodinD]
  742. * update: GetGraphicsMode
  743. *
  744. * Sat 08-Jun-1991 00:47:52 -by- Charles Whitmer [chuckwh]
  745. * Wrote them.
  746. \**************************************************************************/
  747. #define BIDI_MASK (GCP_DIACRITIC|GCP_GLYPHSHAPE|GCP_KASHIDA|GCP_LIGATE|GCP_REORDER)
  748. DWORD APIENTRY GetFontLanguageInfo(HDC hdc)
  749. {
  750. DWORD dwRet = 0;
  751. DWORD dwRet1;
  752. FIXUP_HANDLE(hdc);
  753. #ifdef LANGPACK
  754. if (gbLpk)
  755. {
  756. int iCharSet = NtGdiGetTextCharsetInfo(hdc, NULL, 0);
  757. if ((iCharSet == ARABIC_CHARSET) || (iCharSet == HEBREW_CHARSET))
  758. dwRet |= BIDI_MASK;
  759. }
  760. #endif
  761. dwRet1 = GetDCDWord(hdc, DDW_FONTLANGUAGEINFO, (DWORD)GCP_ERROR);
  762. if (dwRet1 != GCP_ERROR)
  763. {
  764. dwRet |= dwRet1;
  765. }
  766. else
  767. {
  768. dwRet = dwRet1;
  769. }
  770. return dwRet;
  771. }
  772. int APIENTRY GetGraphicsMode(HDC hdc)
  773. {
  774. int mode = 0;
  775. PDC_ATTR pDcAttr;
  776. FIXUP_HANDLE(hdc);
  777. PSHARED_GET_VALIDATE(pDcAttr,hdc,DC_TYPE);
  778. if (pDcAttr)
  779. {
  780. mode = pDcAttr->iGraphicsMode;
  781. }
  782. return(mode);
  783. }
  784. int APIENTRY GetROP2(HDC hdc)
  785. {
  786. int rop = 0;
  787. PDC_ATTR pDcAttr;
  788. FIXUP_HANDLE(hdc);
  789. PSHARED_GET_VALIDATE(pDcAttr,hdc,DC_TYPE);
  790. if (pDcAttr)
  791. {
  792. rop = pDcAttr->jROP2;
  793. }
  794. return(rop);
  795. }
  796. int APIENTRY GetBkMode(HDC hdc)
  797. {
  798. int mode = 0;
  799. PDC_ATTR pDcAttr;
  800. FIXUP_HANDLE(hdc);
  801. PSHARED_GET_VALIDATE(pDcAttr,hdc,DC_TYPE);
  802. if (pDcAttr)
  803. {
  804. mode = pDcAttr->lBkMode;
  805. }
  806. return(mode);
  807. }
  808. int APIENTRY GetPolyFillMode(HDC hdc)
  809. {
  810. int mode = 0;
  811. PDC_ATTR pDcAttr;
  812. PSHARED_GET_VALIDATE(pDcAttr,hdc,DC_TYPE);
  813. if (pDcAttr)
  814. {
  815. mode = pDcAttr->lFillMode;
  816. }
  817. return(mode);
  818. }
  819. int APIENTRY GetStretchBltMode(HDC hdc)
  820. {
  821. int mode = 0;
  822. PDC_ATTR pDcAttr;
  823. FIXUP_HANDLE(hdc);
  824. PSHARED_GET_VALIDATE(pDcAttr,hdc,DC_TYPE);
  825. if (pDcAttr)
  826. {
  827. mode = pDcAttr->lStretchBltMode;
  828. }
  829. return(mode);
  830. }
  831. UINT APIENTRY GetTextAlign(HDC hdc)
  832. {
  833. UINT al = GDI_ERROR;
  834. PDC_ATTR pDcAttr;
  835. FIXUP_HANDLE(hdc);
  836. PSHARED_GET_VALIDATE(pDcAttr,hdc,DC_TYPE);
  837. if (pDcAttr)
  838. {
  839. al = pDcAttr->lTextAlign;
  840. }
  841. return(al);
  842. }
  843. int APIENTRY GetTextCharacterExtra(HDC hdc)
  844. {
  845. int iExtra = 0x80000000;
  846. PDC_ATTR pDcAttr;
  847. FIXUP_HANDLE(hdc);
  848. PSHARED_GET_VALIDATE(pDcAttr,hdc,DC_TYPE);
  849. if (pDcAttr)
  850. {
  851. iExtra = pDcAttr->lTextExtra;
  852. }
  853. return(iExtra);
  854. }
  855. COLORREF APIENTRY GetTextColor(HDC hdc)
  856. {
  857. COLORREF co = CLR_INVALID;
  858. PDC_ATTR pDcAttr;
  859. FIXUP_HANDLE(hdc);
  860. PSHARED_GET_VALIDATE(pDcAttr,hdc,DC_TYPE);
  861. if (pDcAttr)
  862. {
  863. co = pDcAttr->ulForegroundClr;
  864. }
  865. return(co);
  866. }
  867. COLORREF APIENTRY GetBkColor(HDC hdc)
  868. {
  869. COLORREF co = CLR_INVALID;
  870. PDC_ATTR pDcAttr;
  871. FIXUP_HANDLE(hdc);
  872. PSHARED_GET_VALIDATE(pDcAttr,hdc,DC_TYPE);
  873. if (pDcAttr)
  874. {
  875. co = pDcAttr->ulBackgroundClr;
  876. }
  877. return(co);
  878. }
  879. int APIENTRY GetRelAbs(HDC hdc,int iMode)
  880. {
  881. iMode;
  882. FIXUP_HANDLE(hdc);
  883. return( (int) GetDCDWord( hdc, DDW_RELABS,(DWORD) 0 ));
  884. }
  885. //added for retrieve lBreakExtra from server side
  886. int GetBreakExtra (HDC hdc)
  887. {
  888. return( (int) GetDCDWord( hdc, DDW_BREAKEXTRA,(DWORD) 0 ));
  889. }
  890. //added for retrieve cBreak from server side
  891. int GetcBreak (HDC hdc)
  892. {
  893. return( (int) GetDCDWord( hdc, DDW_CBREAK,(DWORD) 0 ));
  894. }
  895. //added to retrieve hlfntNew for USER
  896. HFONT APIENTRY GetHFONT (HDC hdc)
  897. {
  898. HFONT hfnt = NULL;
  899. PDC_ATTR pDcAttr;
  900. PSHARED_GET_VALIDATE(pDcAttr,hdc,DC_TYPE);
  901. if (pDcAttr)
  902. {
  903. hfnt = (HFONT)pDcAttr->hlfntNew;
  904. }
  905. return(hfnt);
  906. }
  907. /******************************Public*Routine******************************\
  908. * GdiIsPlayMetafileDC
  909. *
  910. * Arguments:
  911. *
  912. * hdc - DC handle
  913. *
  914. * Return Value:
  915. *
  916. * True if we are playing a metafile on DC, FALSE otherwise
  917. *
  918. * History :
  919. * Aug-31-97 -by- Samer Arafeh [SamerA]
  920. \**************************************************************************/
  921. BOOL APIENTRY GdiIsPlayMetafileDC(HDC hdc)
  922. {
  923. PDC_ATTR pDcAttr;
  924. BOOL bRet=FALSE;
  925. FIXUP_HANDLE(hdc);
  926. PSHARED_GET_VALIDATE(pDcAttr,hdc,DC_TYPE);
  927. if (pDcAttr)
  928. {
  929. bRet = (pDcAttr->ulDirty_&DC_PLAYMETAFILE) ? TRUE : FALSE;
  930. }
  931. return(bRet);
  932. }