home *** CD-ROM | disk | FTP | other *** search
- // $$VAL:BaseViewCpp$$ : implementation of the $$VAL:BaseViewClass$$ class
- //
-
- #include "stdafx.h"
- #include "$$VAL:ResInclude$$"
-
- #include "$$VAL:BaseViewHeader$$"
-
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // $$VAL:BaseViewClass$$
-
- IMPLEMENT_DYNCREATE($$VAL:BaseViewClass$$, CScrollView)
-
- BEGIN_MESSAGE_MAP($$VAL:BaseViewClass$$, CScrollView)
- //{{AFX_MSG_MAP($$VAL:BaseViewClass$$)
- // 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
- // Standard printing commands
- ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview)
- ON_WM_PALETTECHANGED()
- ON_WM_QUERYNEWPALETTE()
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // $$VAL:BaseViewClass$$ construction/destruction
-
- $$VAL:BaseViewClass$$::$$VAL:BaseViewClass$$()
- {
- }
-
- $$VAL:BaseViewClass$$::~$$VAL:BaseViewClass$$()
- {
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // $$VAL:BaseViewClass$$ drawing
-
- void $$VAL:BaseViewClass$$::OnDraw(CDC* pDC)
- {
- $$VAL:BaseDocClass$$* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
-
- if (pDoc->m_Bitmap.m_hObject != NULL)
- {
- CDC dc;
- VERIFY( dc.CreateCompatibleDC(pDC) );
- CBitmap *pOldBitmap = dc.SelectObject( &pDoc->m_Bitmap );
-
- CPalette *pOldPalette;
- if (pDoc->GetPalette() != NULL)
- {
- pOldPalette = pDC->SelectPalette( pDoc->GetPalette(), TRUE );
- pDC->RealizePalette();
- }
-
- CSize sz = pDoc->GetSize();
- pDC->BitBlt( 0, 0, sz.cx, sz.cy, &dc, 0, 0, SRCCOPY );
-
- if (pDoc->GetPalette() != NULL)
- pDC->SelectPalette( pOldPalette, TRUE );
- }
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // $$VAL:BaseViewClass$$ printing
-
- BOOL $$VAL:BaseViewClass$$::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // default preparation
- return DoPreparePrinting(pInfo);
- }
-
- void $$VAL:BaseViewClass$$::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add extra initialization before printing
- }
-
- void $$VAL:BaseViewClass$$::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add cleanup after printing
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // $$VAL:BaseViewClass$$ diagnostics
-
- #ifdef _DEBUG
- void $$VAL:BaseViewClass$$::AssertValid() const
- {
- CScrollView::AssertValid();
- }
-
- void $$VAL:BaseViewClass$$::Dump(CDumpContext& dc) const
- {
- CScrollView::Dump(dc);
- }
-
- $$VAL:DocClass$$* $$VAL:BaseViewClass$$::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS($$VAL:DocClass$$)));
- return ($$VAL:DocClass$$*)m_pDocument;
- }
- #endif //_DEBUG
-
- /////////////////////////////////////////////////////////////////////////////
- // $$VAL:BaseViewClass$$ message handlers
-
- void $$VAL:BaseViewClass$$::OnInitialUpdate()
- {
- CScrollView::OnInitialUpdate();
-
- OnUpdate(NULL, 0, NULL);
- }
-
- void $$VAL:BaseViewClass$$::OnUpdate(CScrollView* pSender, LPARAM lHint, CObject* pHint)
- {
- $$VAL:BaseDocClass$$* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
-
- SetScrollSizes(MM_TEXT, pDoc->GetSize());
- Invalidate();
- }
-
- void $$VAL:BaseViewClass$$::OnPaletteChanged(CWnd* pFocusWnd)
- {
- if (pFocusWnd == this || IsChild(pFocusWnd))
- return;
-
- OnQueryNewPalette();
- }
-
- BOOL $$VAL:BaseViewClass$$::OnQueryNewPalette()
- {
- $$VAL:BaseDocClass$$* pDoc = ($$VAL:BaseDocClass$$ *)GetDocument();
- if (pDoc == NULL || pDoc->GetPalette() == NULL)
- return FALSE;
-
- // BLOCK: Realize our new palette
- {
- CClientDC dc(this);
- CPalette* pOldPalette = dc.SelectPalette(pDoc->GetPalette(),
- GetCurrentMessage()->message == WM_PALETTECHANGED);
- UINT nChanged = dc.RealizePalette();
- dc.SelectPalette(pOldPalette, TRUE);
-
- if (nChanged == 0) // no change to our mapping
- return FALSE;
- }
-
- // some changes have been made; invalidate our view
- Invalidate(FALSE);
-
- return TRUE;
- }