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.

168 lines
4.3 KiB

  1. /*****************************************************************************
  2. *
  3. * rects - Entry points for Win32 to Win 16 converter
  4. *
  5. * Date: 7/1/91
  6. * Author: Jeffrey Newman (c-jeffn)
  7. *
  8. * Copyright 1991 Microsoft Corp
  9. *****************************************************************************/
  10. #include "precomp.h"
  11. #pragma hdrstop
  12. /***************************************************************************
  13. * Rectangle - Win32 to Win16 Metafile Converter Entry Point
  14. **************************************************************************/
  15. BOOL WINAPI DoRectangle
  16. (
  17. PLOCALDC pLocalDC,
  18. int x1,
  19. int y1,
  20. int x2,
  21. int y2
  22. )
  23. {
  24. BOOL b ;
  25. b = bConicCommon (pLocalDC, x1, y1, x2, y2, 0, 0, 0, 0, EMR_RECTANGLE) ;
  26. return(b) ;
  27. }
  28. /***************************************************************************
  29. * RoundRect - Win32 to Win16 Metafile Converter Entry Point
  30. **************************************************************************/
  31. BOOL WINAPI DoRoundRect
  32. (
  33. PLOCALDC pLocalDC,
  34. int x1,
  35. int y1,
  36. int x2,
  37. int y2,
  38. int x3,
  39. int y3
  40. )
  41. {
  42. BOOL b ;
  43. b = bConicCommon (pLocalDC, x1, y1, x2, y2, x3, y3, 0, 0, EMR_ROUNDRECT);
  44. return(b) ;
  45. }
  46. /***************************************************************************
  47. * IntersectClipRect/ExcludeClipRect - Win32 to Win16 Metafile Converter
  48. * Entry Point
  49. **************************************************************************/
  50. BOOL WINAPI DoClipRect
  51. (
  52. PLOCALDC pLocalDC,
  53. INT xLeft,
  54. INT yTop,
  55. INT xRight,
  56. INT yBottom,
  57. INT mrType
  58. )
  59. {
  60. BOOL bNoClipRgn ;
  61. // Do it to the helper DC.
  62. // If there is no initial clip region, we have to
  63. // create one. Otherwise, GDI will create some random default
  64. // clipping region for us!
  65. bNoClipRgn = bNoDCRgn(pLocalDC, DCRGN_CLIP);
  66. if (bNoClipRgn)
  67. {
  68. BOOL bRet;
  69. HRGN hrgnDefault;
  70. if (!(hrgnDefault = CreateRectRgn((int) (SHORT) MINSHORT,
  71. (int) (SHORT) MINSHORT,
  72. (int) (SHORT) MAXSHORT,
  73. (int) (SHORT) MAXSHORT)))
  74. {
  75. ASSERTGDI(FALSE, "MF3216: CreateRectRgn failed");
  76. return(FALSE);
  77. }
  78. bRet = (ExtSelectClipRgn(pLocalDC->hdcHelper, hrgnDefault, RGN_COPY)
  79. != ERROR);
  80. ASSERTGDI(bRet, "MF3216: ExtSelectClipRgn failed");
  81. if (!DeleteObject(hrgnDefault))
  82. ASSERTGDI(FALSE, "MF3216: DeleteObject failed");
  83. if (!bRet)
  84. return(FALSE);
  85. }
  86. switch(mrType)
  87. {
  88. case EMR_INTERSECTCLIPRECT:
  89. if (!IntersectClipRect(pLocalDC->hdcHelper, xLeft, yTop, xRight, yBottom))
  90. return(FALSE);
  91. break;
  92. case EMR_EXCLUDECLIPRECT:
  93. if (!ExcludeClipRect(pLocalDC->hdcHelper, xLeft, yTop, xRight, yBottom))
  94. return(FALSE);
  95. break;
  96. default:
  97. ASSERTGDI(FALSE, "MF3216: DoClipRect, bad mrType\n");
  98. break;
  99. }
  100. // Dump the clip region data.
  101. return(bDumpDCClipping(pLocalDC));
  102. #if 0
  103. // It's too much work to try to optimize it here!
  104. POINTL aptl[2] ;
  105. // Dump the clip region data if there is a strange xform.
  106. if (pLocalDC->flags & STRANGE_XFORM || bNoClipRgn)
  107. return(bDumpDCClipping(pLocalDC));
  108. // Do the simple case.
  109. // Are they inclusive-exclusive?!
  110. aptl[0].x = xLeft;
  111. aptl[0].y = yTop ;
  112. aptl[1].x = xRight;
  113. aptl[1].y = yBottom ;
  114. // Order the rectangle first, see EXFORMOBJ::bXform(ERECTL) in gre!
  115. if (!bXformRWorldToPPage(pLocalDC, (PPOINTL) aptl, 2))
  116. return(FALSE);
  117. ASSERTGDI(bCoordinateOverflowTest((PLONG) aptl, 4), "MF3216: coord overflow");
  118. // Verify rectangle ordering and check off-by-1 error!
  119. if (mrType == EMR_INTERSECTCLIPRECT)
  120. return(bEmitWin16IntersectClipRect(pLocalDC,
  121. (SHORT) aptl[0].x,
  122. (SHORT) aptl[0].y,
  123. (SHORT) aptl[1].x,
  124. (SHORT) aptl[1].y));
  125. else
  126. return(bEmitWin16ExcludeClipRect(pLocalDC,
  127. (SHORT) aptl[0].x,
  128. (SHORT) aptl[0].y,
  129. (SHORT) aptl[1].x,
  130. (SHORT) aptl[1].y));
  131. #endif
  132. }