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.

103 lines
2.5 KiB

  1. //// DspPath.CPP - Display plaintext using AddString and DrawPath APIs
  2. //
  3. //
  4. #include "precomp.hxx"
  5. #include "global.h"
  6. void PaintPath(
  7. HDC hdc,
  8. int *piY,
  9. RECT *prc,
  10. int iLineHeight) {
  11. int icpLineStart; // First character of line
  12. int icpLineEnd; // End of line (end of buffer or index of CR character)
  13. HFONT hFont;
  14. HFONT hOldFont;
  15. LOGFONT lf;
  16. // Establish available width and height in device coordinates
  17. int plainTextWidth = prc->right - prc->left;
  18. int plainTextHeight = prc->bottom - *piY;
  19. // Draw a simple figure in the world coordinate system
  20. Graphics g(hdc);
  21. Matrix matrix;
  22. g.ResetTransform();
  23. g.SetPageUnit(UnitPixel);
  24. g.TranslateTransform(REAL(prc->left), REAL(*piY));
  25. // Clear the background
  26. RectF rEntire(0, 0, REAL(plainTextWidth), REAL(plainTextHeight));
  27. SolidBrush whiteBrush(Color(0xff, 0xff, 0xff));
  28. g.FillRectangle(&whiteBrush, rEntire);
  29. // Apply selected world transform, adjusted to middle of the plain text
  30. // area.
  31. g.SetTransform(&g_WorldTransform);
  32. g.TranslateTransform(
  33. REAL(prc->left + plainTextWidth/2),
  34. REAL(*piY + plainTextHeight/2),
  35. MatrixOrderAppend);
  36. // Put some text in the middle
  37. RectF textRect(REAL(-25*plainTextWidth/100), REAL(-25*plainTextHeight/100),
  38. REAL( 50*plainTextWidth/100), REAL( 50*plainTextHeight/100));
  39. StringFormat format(g_formatFlags);
  40. format.SetTrimming(g_lineTrim);
  41. format.SetAlignment(g_align);
  42. format.SetLineAlignment(g_lineAlign);
  43. format.SetHotkeyPrefix(g_hotkey);
  44. REAL tab[3] = {textRect.Width/4,
  45. textRect.Width*3/16,
  46. textRect.Width*1/8};
  47. format.SetTabStops(0.0, sizeof(tab)/sizeof(REAL), tab);
  48. Color blackColor(0, 0, 0);
  49. SolidBrush blackBrush(blackColor);
  50. Pen blackPen(&blackBrush, 1.0);
  51. for(int iRender=0;iRender<g_iNumRenders;iRender++)
  52. {
  53. GraphicsPath path;
  54. path.AddString(
  55. g_wcBuf,
  56. g_iTextLen,
  57. &FontFamily(g_style[0].faceName),
  58. g_style[0].style,
  59. REAL(g_style[0].emSize * g.GetDpiY() / 72.0),
  60. textRect,
  61. &format);
  62. g.DrawPath(&blackPen, &path);
  63. }
  64. // Show the text rectangle
  65. if (!g_AutoDrive)
  66. {
  67. g.DrawRectangle(&blackPen, textRect);
  68. }
  69. *piY += plainTextHeight;
  70. }