home *** CD-ROM | disk | FTP | other *** search
- // gpsrcView.cpp : implementation of the CGpsrcView class
- //
-
- #include "stdafx.h"
- #include "gpsrc.h"
-
- #include "gpsrcDoc.h"
- #include "gpsrcView.h"
-
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CGpsrcView
-
- IMPLEMENT_DYNCREATE(CGpsrcView, CScrollView)
-
- BEGIN_MESSAGE_MAP(CGpsrcView, CScrollView)
- //{{AFX_MSG_MAP(CGpsrcView)
- ON_WM_CREATE()
- ON_COMMAND(ID_VIEW_CLEAR, OnViewClear)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CGpsrcView construction/destruction
-
- CGpsrcView::CGpsrcView()
- {
- // TODO: add construction code here
-
- }
-
- CGpsrcView::~CGpsrcView()
- {
- }
-
- BOOL CGpsrcView::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
-
- return CScrollView::PreCreateWindow(cs);
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CGpsrcView drawing
-
- void CGpsrcView::OnDraw(CDC* pDC)
- {
- CGpsrcDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
-
- // TODO: add draw code for native data here
- // jh: set scroll size based upon number of strings in document.
- CStringArray& strings= GetDocument()->m_strings;
- CSize sizeTotal;
- sizeTotal.cx = 100;
- TEXTMETRIC tm;
- pDC->GetTextMetrics(&tm);
- sizeTotal.cy = tm.tmHeight*strings.GetSize();
- SetScrollSizes(MM_TEXT, sizeTotal);
-
- for (int idx=0; idx<strings.GetSize(); idx++) {
- CString str;
- str.Format("%d: %s", idx, strings.GetAt(idx));
- pDC->TabbedTextOut(0,idx*tm.tmHeight,str,0,NULL,0);
- }
-
- }
-
- void CGpsrcView::OnInitialUpdate()
- {
- CScrollView::OnInitialUpdate();
- CSize sizeTotal;
- // TODO: calculate the total size of this view
- sizeTotal.cx = sizeTotal.cy = 100;
- SetScrollSizes(MM_TEXT, sizeTotal);
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CGpsrcView diagnostics
-
- #ifdef _DEBUG
- void CGpsrcView::AssertValid() const
- {
- CScrollView::AssertValid();
- }
-
- void CGpsrcView::Dump(CDumpContext& dc) const
- {
- CScrollView::Dump(dc);
- }
-
- CGpsrcDoc* CGpsrcView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CGpsrcDoc)));
- return (CGpsrcDoc*)m_pDocument;
- }
- #endif //_DEBUG
-
- /////////////////////////////////////////////////////////////////////////////
- // CGpsrcView message handlers
- // Timer
- void CALLBACK EXPORT TimerProc(
- HWND hWnd, //handle of CWnd that called SetTimer
- UINT nMsg, //WM_TIMER
- UINT nIDEvent, //timer identification
- DWORD dwTime //system time
- )
- {
-
- }
-
-
-
- int CGpsrcView::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CScrollView::OnCreate(lpCreateStruct) == -1)
- return -1;
-
- // TODO: Add your specialized creation code here
-
- return 0;
- }
-
- void CGpsrcView::OnViewClear()
- {
- // TODO: Add your command handler code here
- GetDocument()->DeleteContents();
-
- }
-