home *** CD-ROM | disk | FTP | other *** search
- // ModlView.cpp : implementation of the CModalView class
- //
-
- #include "stdafx.h"
- #include "Modal.h"
-
- #include "Dialogs.h"
- #include "XtraFunc.h"
-
- #include "ModalDoc.h"
- #include "ModlView.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CModalView
-
- IMPLEMENT_DYNCREATE(CModalView, CView)
-
- BEGIN_MESSAGE_MAP(CModalView, CView)
- //{{AFX_MSG_MAP(CModalView)
- ON_COMMAND(ID_MODIFY_SHOWDIALOG, OnModifyShowdialog)
- ON_COMMAND(ID_MODIFY_SHOWLISTDIALOG, OnModifyShowlistdialog)
- ON_COMMAND(ID_MODIFY_SHOWLISTITEMDATADIALOG, OnModifyShowlistitemdatadialog)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CModalView construction/destruction
-
- CModalView::CModalView()
- {
- }
-
- CModalView::~CModalView()
- {
- }
-
- BOOL CModalView::PreCreateWindow(CREATESTRUCT& cs)
- {
- return CView::PreCreateWindow(cs);
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CModalView drawing
-
- void CModalView::OnDraw(CDC* pDC)
- {
- CModalDoc* 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());
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CModalView diagnostics
-
- #ifdef _DEBUG
- void CModalView::AssertValid() const
- {
- CView::AssertValid();
- }
-
- void CModalView::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
-
- CModalDoc* CModalView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CModalDoc)));
- return (CModalDoc*)m_pDocument;
- }
- #endif //_DEBUG
-
- /////////////////////////////////////////////////////////////////////////////
- // CModalView message handlers
-
- void CModalView::OnModifyShowdialog()
- {
- CColorPhraseDlg dlg;
- CModalDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
-
- // Load the dialog box's members before
- // displaying it.
- dlg.m_phrase = pDoc->GetPhrase();
- dlg.m_color = RgbToInt(pDoc->GetColor());
-
- // If the user clicks on OK, replace the
- // document's members with the fields from
- // the dialog box, and repaint the view.
- if (IDOK == dlg.DoModal())
- {
- pDoc->SetPhrase(dlg.m_phrase);
- pDoc->SetColor(IntToRgb(dlg.m_color));
- Invalidate();
- }
- }
-
- void CModalView::OnModifyShowlistdialog()
- {
- CModalDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
-
- // In order to set the current selection in its list box, the
- // dialog box needs to know the current color. See the dialog box's
- // constructor and OnInitDialog for more information.
- CColorListDlg dlg2(pDoc->GetColor());
-
- // Load the dialog box's members before
- // displaying it.
- dlg2.m_phrase = pDoc->GetPhrase();
-
- // The dialog box's must do all the initialization of the
- // list box in its own overridden OnInitDialog function.
-
- // If the user clicks on OK, replace the document's
- // members with the fields from the dialog box, and repaint
- // the view. A list box can give back eitehr a string or an
- // int, but it will only give an int if the list box's sort
- // property is set to false.
- if (IDOK == dlg2.DoModal())
- {
- pDoc->SetPhrase(dlg2.m_phrase);
- pDoc->SetColor(IntToRgb(dlg2.m_color));
- Invalidate();
- }
- }
-
- void CModalView::OnModifyShowlistitemdatadialog()
- {
- CModalDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
-
- CListWithItemDataDlg dlg3;
-
- // Load the dialog box's members before displaying it.
- // Note that for this dialog box class, m_color was
- // manually added. Examine the dialog box's DoDataExchange
- // and InitDialog functions to see how it's used.
- dlg3.m_phrase = pDoc->GetPhrase();
- dlg3.m_color = pDoc->GetColor();
-
- // The dialog box's must do all the initialization of the
- // list box in its own overridden OnInitDialog function.
-
- // If the user clicks on OK, replace the
- // document's members with the fields from
- // the dialog box, and repaint the view.
- if (IDOK == dlg3.DoModal())
- {
- pDoc->SetPhrase(dlg3.m_phrase);
- pDoc->SetColor(dlg3.m_color); // NO CONVERSIONS!
- Invalidate();
- }
- }
-
-