home *** CD-ROM | disk | FTP | other *** search
- // MenuView.cpp : implementation of the CMenus1View class
- //
-
- #include "stdafx.h"
- #include "Menus1.h"
-
- #include "Menu1Doc.h"
- #include "MenuView.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- const COLORREF BLACK=RGB(0,0,0);
- const COLORREF RED=RGB(255,0,0);
- const COLORREF GREEN=RGB(0,255,0);
- const COLORREF BLUE=RGB(0,0,255);
-
- /////////////////////////////////////////////////////////////////////////////
- // CMenus1View
-
- IMPLEMENT_DYNCREATE(CMenus1View, CView)
-
- BEGIN_MESSAGE_MAP(CMenus1View, CView)
- //{{AFX_MSG_MAP(CMenus1View)
- ON_COMMAND(ID_COLORS_BLACK, OnColorsBlack)
- ON_COMMAND(ID_COLORS_BLUE, OnColorsBlue)
- ON_COMMAND(ID_COLORS_GREEN, OnColorsGreen)
- ON_COMMAND(ID_COLORS_RED, OnColorsRed)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CMenus1View construction/destruction
-
- CMenus1View::CMenus1View()
- {
- }
-
- CMenus1View::~CMenus1View()
- {
- }
-
- BOOL CMenus1View::PreCreateWindow(CREATESTRUCT& cs)
- {
- return CView::PreCreateWindow(cs);
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CMenus1View drawing
-
- void CMenus1View::OnDraw(CDC* pDC)
- {
- CMenus1Doc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
-
- CRect r;
- GetClientRect(&r);
- int x = r.right / 2, y = r.bottom / 2;
-
- pDC->SetTextColor(pDoc->GetColor());
- pDC->SetTextAlign (TA_CENTER | TA_BASELINE);
- pDC->TextOut (x, y, pDoc->GetPhrase());
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CMenus1View diagnostics
-
- #ifdef _DEBUG
- void CMenus1View::AssertValid() const
- {
- CView::AssertValid();
- }
-
- void CMenus1View::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
-
- CMenus1Doc* CMenus1View::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMenus1Doc)));
- return (CMenus1Doc*)m_pDocument;
- }
- #endif //_DEBUG
-
- /////////////////////////////////////////////////////////////////////////////
- // CMenus1View message handlers
-
- void CMenus1View::OnColorsBlack()
- {
- CMenus1Doc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
-
- pDoc->SetColor(BLACK);
- Invalidate();
- }
-
- void CMenus1View::OnColorsBlue()
- {
- CMenus1Doc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
-
- pDoc->SetColor(BLUE);
- Invalidate();
- }
-
- void CMenus1View::OnColorsGreen()
- {
- CMenus1Doc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
-
- pDoc->SetColor(GREEN);
- Invalidate();
- }
-
- void CMenus1View::OnColorsRed()
- {
- CMenus1Doc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
-
- pDoc->SetColor(RED);
- Invalidate();
- }
-