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.

108 lines
3.2 KiB

  1. //// DspGDI.CPP - Display strings with GDI API
  2. //
  3. //
  4. #include "precomp.hxx"
  5. #include "global.h"
  6. void PaintGDI(
  7. HDC hdc,
  8. int *piY,
  9. RECT *prc,
  10. int iLineHeight)
  11. {
  12. HFONT hfont, hfontOld;
  13. HBRUSH hbrush, hbrushOld;
  14. HPEN hpen, hpenOld;
  15. COLORREF color, colorOld;
  16. hfont = CreateFontW(
  17. -(INT)(g_style[0].emSize + 0.5),
  18. 0, // int nWidth, // average character width
  19. 0, // int nEscapement, // angle of escapement
  20. 0, // int nOrientation, // base-line orientation angle
  21. g_style[0].style & FontStyleBold ? 700 : 400,
  22. g_style[0].style & FontStyleItalic ? 1 : 0,
  23. g_style[0].style & FontStyleUnderline ? 1 : 0,
  24. g_style[0].style & FontStyleStrikeout ? 1 : 0,
  25. 0, // DWORD fdwCharSet, // character set identifier
  26. 0, // DWORD fdwOutputPrecision, // output precision
  27. 0, // DWORD fdwClipPrecision, // clipping precision
  28. g_TextMode == 3 ? ANTIALIASED_QUALITY : NONANTIALIASED_QUALITY, // DWORD fdwQuality, // output quality
  29. 0, // DWORD fdwPitchAndFamily, // pitch and family
  30. g_style[0].faceName
  31. );
  32. Color textColor(g_TextColor);
  33. // Establish available width and height in device coordinates
  34. int plainTextWidth = prc->right - prc->left;
  35. int plainTextHeight = prc->bottom - *piY;
  36. RECT textRect = *prc;
  37. textRect.top = *piY;
  38. textRect.left = textRect.left + (plainTextWidth / 4);
  39. textRect.right = textRect.left + (plainTextWidth / 2);
  40. textRect.bottom = textRect.top + (plainTextHeight / 3);
  41. color = RGB(textColor.GetRed(), textColor.GetGreen(), textColor.GetBlue());
  42. hbrush = (HBRUSH)GetStockObject(HOLLOW_BRUSH);
  43. hpen = CreatePen(PS_SOLID, 0, color);
  44. colorOld = SetTextColor(hdc, color);
  45. hfontOld = (HFONT)SelectObject(hdc, hfont);
  46. hbrushOld = (HBRUSH)SelectObject(hdc, hbrush);
  47. hpenOld = (HPEN)SelectObject(hdc, hpen);
  48. SetBkMode(hdc, TRANSPARENT);
  49. PatBlt(hdc, prc->left, *piY, prc->right, prc->bottom, WHITENESS);
  50. for(int iRender=0;iRender<g_iNumRenders;iRender++)
  51. {
  52. if (g_UseDrawText)
  53. {
  54. int flags = DT_EXPANDTABS | DT_WORDBREAK;
  55. if (g_formatFlags & StringFormatFlagsNoWrap)
  56. flags |= DT_SINGLELINE;
  57. DrawTextW(
  58. hdc,
  59. g_wcBuf,
  60. g_iTextLen,
  61. &textRect,
  62. flags
  63. );
  64. }
  65. else
  66. {
  67. ExtTextOutW(
  68. hdc,
  69. textRect.left,
  70. textRect.top,
  71. ETO_CLIPPED,
  72. &textRect,
  73. g_wcBuf,
  74. g_iTextLen,
  75. NULL);
  76. }
  77. }
  78. Rectangle(hdc, textRect.left, textRect.top, textRect.right, textRect.bottom);
  79. GdiFlush();
  80. SetTextColor(hdc, colorOld);
  81. SelectObject(hdc, hbrushOld);
  82. SelectObject(hdc, hpenOld);
  83. SelectObject(hdc, hfontOld);
  84. DeleteObject(hpen);
  85. DeleteObject(hfont);
  86. *piY += (textRect.bottom - textRect.top) + iLineHeight;
  87. }