home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / labs / c05 / lab06 / ex04 / diffview.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  3.8 KB  |  170 lines

  1. // diffView.cpp : implementation of the CDiffView class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "diff.h"
  6.  
  7. #include "diffDoc.h"
  8. #include "diffView.h"
  9. #include "progress.h"
  10. #include "splitter.h"
  11. #include "mainfrm.h"
  12. #include "resource.h"
  13. #ifdef _DEBUG
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17.  
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CDiffView
  20.  
  21. IMPLEMENT_DYNCREATE(CDiffView, CRichEditView)
  22.  
  23. BEGIN_MESSAGE_MAP(CDiffView, CRichEditView)
  24.     ON_WM_CONTEXTMENU()
  25.     //{{AFX_MSG_MAP(CDiffView)
  26.     ON_WM_DROPFILES()
  27.     ON_WM_RBUTTONUP()
  28.     ON_COMMAND(ID_EDIT_FONT, OnEditFont)
  29.     ON_COMMAND(IDC_EDIT_COLOR_ADDITIONS, OnEditColorAdditions)
  30.     ON_COMMAND(IDC_EDIT_COLOR_DELETIONS, OnEditColorDeletions)
  31.     //}}AFX_MSG_MAP
  32.     // Standard printing commands
  33.     ON_COMMAND(ID_FILE_PRINT, CRichEditView::OnFilePrint)
  34.     ON_COMMAND(ID_FILE_PRINT_DIRECT, CRichEditView::OnFilePrint)
  35.     ON_COMMAND(ID_FILE_PRINT_PREVIEW, CRichEditView::OnFilePrintPreview)
  36. END_MESSAGE_MAP()
  37.  
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CDiffView construction/destruction
  40.  
  41. CDiffView::CDiffView()
  42. {
  43.     // TODO: add construction code here
  44.  
  45. }
  46.  
  47. CDiffView::~CDiffView()
  48. {
  49. }
  50.  
  51. BOOL CDiffView::PreCreateWindow(CREATESTRUCT& cs)
  52. {
  53.     // TODO: Modify the Window class or styles here by modifying
  54.     //  the CREATESTRUCT cs
  55.  
  56.     return CRichEditView::PreCreateWindow(cs);
  57. }
  58.  
  59. /////////////////////////////////////////////////////////////////////////////
  60. // CDiffView drawing
  61.  
  62. void CDiffView::OnDraw(CDC* pDC)
  63. {
  64.     CDiffDoc* pDoc = GetDocument();
  65.     ASSERT_VALID(pDoc);
  66.  
  67.     // TODO: add draw code for native data here
  68. }
  69.  
  70. /////////////////////////////////////////////////////////////////////////////
  71. // CDiffView printing
  72.  
  73. BOOL CDiffView::OnPreparePrinting(CPrintInfo* pInfo)
  74. {
  75.     // default preparation
  76.     return DoPreparePrinting(pInfo);
  77. }
  78.  
  79. void CDiffView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  80. {
  81.     // TODO: add extra initialization before printing
  82. }
  83.  
  84. void CDiffView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  85. {
  86.     // TODO: add cleanup after printing
  87. }
  88.  
  89. /////////////////////////////////////////////////////////////////////////////
  90. // CDiffView diagnostics
  91.  
  92. #ifdef _DEBUG
  93. void CDiffView::AssertValid() const
  94. {
  95.     CRichEditView::AssertValid();
  96. }
  97.  
  98. void CDiffView::Dump(CDumpContext& dc) const
  99. {
  100.     CRichEditView::Dump(dc);
  101. }
  102.  
  103. CDiffDoc* CDiffView::GetDocument() // non-debug version is inline
  104. {
  105.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDiffDoc)));
  106.     return (CDiffDoc*)m_pDocument;
  107. }
  108. #endif //_DEBUG
  109.  
  110. /////////////////////////////////////////////////////////////////////////////
  111. // CDiffView message handlers
  112.  
  113. void CDiffView::OnInitialUpdate() 
  114. {
  115.     CRichEditView::OnInitialUpdate();
  116.     
  117.     GetRichEditCtrl().SetReadOnly();
  118.     
  119. }
  120.  
  121. void CDiffView::OnDropFiles(HDROP hDropInfo) 
  122. {
  123.     CDiffApp::GetApp()->GetMainFrame()->
  124.         SendMessage ( WM_DROPFILES,
  125.                       (WPARAM)hDropInfo);
  126.     //Don't call the default -- we don't want OLE
  127.     //embedding behavior    
  128.     //CRichEditView::OnDropFiles(hDropInfo);
  129. }
  130.  
  131. void CDiffView::OnContextMenu(CWnd *pWnd, CPoint point)
  132. {
  133.     UNUSED_ALWAYS (pWnd);    CMenu menu;
  134.     VERIFY(menu.LoadMenu(IDR_POPUP_DIFF_VIEW));
  135.  
  136.     CMenu* pPopup = menu.GetSubMenu(0);
  137.     ASSERT(pPopup != NULL);
  138.  
  139.     if (pPopup != NULL)
  140.         pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);
  141. }
  142.  
  143. void CDiffView::OnRButtonUp(UINT nFlags, CPoint point) 
  144. {
  145.     
  146.     //CRichEditView::OnRButtonUp(nFlags, point);
  147.     ClientToScreen (&point);
  148.     OnContextMenu ((CWnd *)NULL, point);
  149.  
  150. }
  151.  
  152. void CDiffView::OnEditFont() 
  153. {
  154.     AfxMessageBox ("In OnEditFont()");
  155.     
  156. }
  157.  
  158.  
  159. void CDiffView::OnEditColorAdditions() 
  160. {
  161.     AfxMessageBox ("In OnEditColorAdditions()");
  162.     
  163. }
  164.  
  165. void CDiffView::OnEditColorDeletions() 
  166. {
  167.     AfxMessageBox ("In OnEditColorDeletions()");
  168.     
  169. }
  170.