home *** CD-ROM | disk | FTP | other *** search
- // TabDemVw.cpp : implementation of the CTabDemoView class
- //
-
- #include "stdafx.h"
- #include "TabDemo.h"
-
- #include "TabDeDoc.h"
- #include "TabDemVw.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CTabDemoView
-
- IMPLEMENT_DYNCREATE(CTabDemoView, CView)
-
- BEGIN_MESSAGE_MAP(CTabDemoView, CView)
- //{{AFX_MSG_MAP(CTabDemoView)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- // DO NOT EDIT what you see in these blocks of generated code!
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CTabDemoView construction/destruction
-
- CTabDemoView::CTabDemoView()
- {
- // TODO: add construction code here
-
- }
-
- CTabDemoView::~CTabDemoView()
- {
- }
-
- BOOL CTabDemoView::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
-
- return CView::PreCreateWindow(cs);
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CTabDemoView drawing
-
- void CTabDemoView::OnDraw(CDC* pDC)
- {
- CTabDemoDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
-
- // TODO: add draw code for native data here
-
- RECT ClientRect;
- CFont Font;
- LOGFONT LF;
- int LineHeight;
- CFont *PtrOldFont;
- int X, Y;
-
- // fill LF with the features of a standard system font:
- CFont TempFont;
- if (pDoc->m_Pitch == PITCH_VARIABLE)
- TempFont.CreateStockObject (SYSTEM_FONT);
- else
- TempFont.CreateStockObject (SYSTEM_FIXED_FONT);
- TempFont.GetObject (sizeof (LOGFONT), &LF);
-
- // now customize lfWeight, lfItalic, and lfUnderline fields:
- if (pDoc->m_Bold)
- LF.lfWeight = FW_BOLD;
- if (pDoc->m_Italic)
- LF.lfItalic = 1;
- if (pDoc->m_Underline)
- LF.lfUnderline = 1;
-
- // create and select font:
- Font.CreateFontIndirect (&LF);
- PtrOldFont = pDC->SelectObject (&Font);
-
- // set justification:
- GetClientRect (&ClientRect);
- switch (pDoc->m_Justify)
- {
- case JUSTIFY_LEFT:
- pDC->SetTextAlign (TA_LEFT);
- X = ClientRect.left + 5;
- break;
- case JUSTIFY_CENTER:
- pDC->SetTextAlign (TA_CENTER);
- X = ClientRect.right / 2;
- break;
- case JUSTIFY_RIGHT:
- pDC->SetTextAlign (TA_RIGHT);
- X = ClientRect.right - 5;
- break;
- }
-
- // set text color and background mode:
- pDC->SetTextColor (::GetSysColor (COLOR_WINDOWTEXT));
- pDC->SetBkMode (TRANSPARENT);
-
- // draw lines:
- LineHeight = LF.lfHeight * pDoc->m_Spacing;
- Y = 5;
- pDC->TextOut (X, Y, "This is the first line of sample text.");
- Y += LineHeight;
- pDC->TextOut (X, Y, "This is the second line of sample text.");
- Y += LineHeight;
- pDC->TextOut (X, Y, "This is the third line of sample text.");
-
- // unselect font:
- pDC->SelectObject (PtrOldFont);
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CTabDemoView diagnostics
-
- #ifdef _DEBUG
- void CTabDemoView::AssertValid() const
- {
- CView::AssertValid();
- }
-
- void CTabDemoView::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
-
- CTabDemoDoc* CTabDemoView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTabDemoDoc)));
- return (CTabDemoDoc*)m_pDocument;
- }
- #endif //_DEBUG
-
- /////////////////////////////////////////////////////////////////////////////
- // CTabDemoView message handlers
-