home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / samples / c07 / splitter / italview.cpp next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  2.2 KB  |  102 lines

  1. // ItalView.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "splitter.h"
  6.  
  7. #include "SplitDoc.h"
  8. #include "ItalView.h"
  9.  
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15.  
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CItalicsView
  18.  
  19. IMPLEMENT_DYNCREATE(CItalicsView, CView)
  20.  
  21. CItalicsView::CItalicsView()
  22. {
  23. }
  24.  
  25. CItalicsView::~CItalicsView()
  26. {
  27. }
  28.  
  29. BEGIN_MESSAGE_MAP(CItalicsView, CView)
  30.     //{{AFX_MSG_MAP(CItalicsView)
  31.         // NOTE - the ClassWizard will add and remove mapping macros here.
  32.     //}}AFX_MSG_MAP
  33. END_MESSAGE_MAP()
  34.  
  35. /////////////////////////////////////////////////////////////////////////////
  36. // CItalicsView drawing
  37.  
  38. void CItalicsView::OnDraw(CDC* pDC)
  39. {
  40.     CSplitterDoc* pDoc = GetDocument();
  41.     ASSERT_VALID(pDoc);
  42.  
  43.     CFont * pOldFont, tempFont;
  44.     LOGFONT lf;  
  45.  
  46.     // Obtain a pointer to the current font.
  47.     pOldFont = pDC->GetCurrentFont();
  48.     
  49.     // Fill this function's LOGFONT object with the current font.
  50.     pOldFont->GetLogFont(&lf);
  51.     
  52.     // Make the desired modification(s).
  53.     lf.lfItalic = TRUE;
  54.  
  55.     // Fill this function's CFont object with the logfont.
  56.     tempFont.CreateFontIndirect(&lf);
  57.  
  58.     // Select the new font object into the device context.
  59.     pOldFont = (CFont *) pDC->SelectObject(&tempFont);
  60.  
  61.     CRect r;
  62.     GetClientRect(&r);
  63.     int x = r.right / 2, y = r.bottom / 2;
  64.  
  65.     pDC->SetTextColor(pDoc->GetColor());
  66.     pDC->SetTextAlign (TA_CENTER | TA_BASELINE);
  67.     pDC->TextOut (x, y, pDoc->GetPhrase());
  68.  
  69.     // Restore the font that existed at the beginning of this function.
  70.     pDC->SelectObject(pOldFont);
  71. }
  72.  
  73. /////////////////////////////////////////////////////////////////////////////
  74. // CItalicsView diagnostics
  75.  
  76. #ifdef _DEBUG
  77. void CItalicsView::AssertValid() const
  78. {
  79.     CView::AssertValid();
  80. }
  81.  
  82. CSplitterDoc* CItalicsView::GetDocument()
  83. {
  84.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSplitterDoc)));
  85.     return (CSplitterDoc*)m_pDocument;
  86. }
  87.  
  88. void CItalicsView::Dump(CDumpContext& dc) const
  89. {
  90.     CView::Dump(dc);
  91. }
  92. #endif //_DEBUG
  93.  
  94. /////////////////////////////////////////////////////////////////////////////
  95. // CItalicsView message handlers
  96.  
  97. void CItalicsView::OnInitialUpdate() 
  98. {
  99.     CView::OnInitialUpdate();
  100.     
  101. }
  102.