CtlTipOfTheDayText.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /* Copyright (c) 2002-2012 Croteam Ltd.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of version 2 of the GNU General Public License as published by
  4. the Free Software Foundation
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License along
  10. with this program; if not, write to the Free Software Foundation, Inc.,
  11. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
  12. // CtlTipOfTheDayText.cpp : implementation file
  13. //
  14. #include "stdafx.h"
  15. #include "WorldEditor.h"
  16. #include "CtlTipOfTheDayText.h"
  17. #ifdef _DEBUG
  18. #undef new
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CCtlTipOfTheDayText
  25. CCtlTipOfTheDayText::CCtlTipOfTheDayText()
  26. {
  27. }
  28. CCtlTipOfTheDayText::~CCtlTipOfTheDayText()
  29. {
  30. }
  31. BEGIN_MESSAGE_MAP(CCtlTipOfTheDayText, CStatic)
  32. //{{AFX_MSG_MAP(CCtlTipOfTheDayText)
  33. ON_WM_PAINT()
  34. //}}AFX_MSG_MAP
  35. END_MESSAGE_MAP()
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CCtlTipOfTheDayText message handlers
  38. void CCtlTipOfTheDayText::OnPaint()
  39. {
  40. CPaintDC dc(this); // device context for painting
  41. // get rectangle of the text area inside dialog
  42. RECT rectWin;
  43. GetWindowRect(&rectWin);
  44. ScreenToClient(&rectWin);
  45. // calculate positions of the upper and left rectangle and separating line
  46. int iy, ix0, ix1;
  47. RECT rectUp;
  48. RECT rectDn;
  49. ix0 = rectUp.left = rectDn.left = rectWin.left;
  50. ix1 = rectUp.right = rectDn.right = rectWin.right;
  51. iy = rectUp.bottom = rectDn.top = int((rectWin.bottom+rectWin.top)*0.25f);
  52. rectUp.top = rectWin.top;
  53. rectDn.bottom = rectWin.bottom;
  54. InflateRect(&rectDn, -5,-10);
  55. InflateRect(&rectUp, -5,-10);
  56. OffsetRect(&rectDn, 0,5);
  57. OffsetRect(&rectUp, 0,5);
  58. // draw white rectangle with sunken edge
  59. CBrush brWhite;
  60. brWhite.CreateStockObject(WHITE_BRUSH);
  61. dc.FillRect(&rectWin, &brWhite);
  62. dc.DrawEdge(&rectWin, BDR_SUNKENOUTER, BF_RIGHT|BF_BOTTOM|BF_TOP);
  63. // draw separating line
  64. CBrush brGray;
  65. brGray.CreateStockObject(GRAY_BRUSH);
  66. dc.SelectObject(brGray);
  67. dc.MoveTo(ix0-1, iy);
  68. dc.LineTo(ix1, iy);
  69. // create two fonts, big and small
  70. LOGFONT lf;
  71. ::ZeroMemory (&lf, sizeof (lf));
  72. lf.lfHeight = 145;
  73. lf.lfWeight = FW_BOLD;
  74. lf.lfItalic = FALSE;
  75. wcscpy(lf.lfFaceName, L"Times New Roman");
  76. CFont fontBig;
  77. fontBig.CreatePointFontIndirect (&lf);
  78. ::ZeroMemory (&lf, sizeof (lf));
  79. lf.lfHeight = 100;
  80. lf.lfWeight = FW_NORMAL;
  81. lf.lfItalic = FALSE;
  82. wcscpy(lf.lfFaceName, L"Arial");
  83. CFont fontSmall;
  84. fontSmall.CreatePointFontIndirect (&lf);
  85. // print heading with big font
  86. dc.SelectObject(&fontBig);
  87. dc.DrawText("Did you know...", &rectUp, DT_VCENTER|DT_SINGLELINE);
  88. // print text with small font
  89. dc.SelectObject(&fontSmall);
  90. dc.DrawText(m_strTipText, &rectDn, DT_WORDBREAK);
  91. }