home *** CD-ROM | disk | FTP | other *** search
/ Media Share 13 / mediashare_13.zip / mediashare_13 / ZIPPED / PROGRAM / WTJ9403.ZIP / CONTAIN / CNTRITEM.CPP < prev    next >
C/C++ Source or Header  |  1994-01-06  |  4KB  |  134 lines

  1. // cntritem.cpp : implementation of the CContainCntrItem class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "contain.h"
  6.  
  7. #include "contadoc.h"
  8. #include "cntritem.h"
  9.  
  10. #ifdef _DEBUG
  11. #undef THIS_FILE
  12. static char BASED_CODE THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CContainCntrItem implementation
  17.  
  18. IMPLEMENT_SERIAL(CContainCntrItem, COleClientItem, 0)
  19.  
  20. CContainCntrItem::CContainCntrItem(CContainDoc* pContainer)
  21.     : COleClientItem(pContainer)
  22. {
  23.     // TODO: add one-time construction code here
  24. }
  25.  
  26. CContainCntrItem::~CContainCntrItem()
  27. {
  28.     // TODO: add cleanup code here
  29. }
  30.  
  31. void CContainCntrItem::OnChange(OLE_NOTIFICATION nCode, DWORD dwParam)
  32. {
  33.     ASSERT_VALID(this);
  34.  
  35.     COleClientItem::OnChange(nCode, dwParam);
  36.  
  37.     // When an item is being edited (either in-place or fully open)
  38.     //  it sends OnChange notifications for changes in the state of the
  39.     //  item or visual appearance of its content.
  40.  
  41.     // TODO: invalidate the item by calling UpdateAllViews
  42.     //  (with hints appropriate to your application)
  43.  
  44.     GetDocument()->UpdateAllViews(NULL);
  45.         // for now just update ALL views/no hints
  46. }
  47.  
  48. BOOL CContainCntrItem::OnChangeItemPosition(const CRect& rectPos)
  49. {
  50.     ASSERT_VALID(this);
  51.  
  52.     // During in-place activation CContainCntrItem::OnChangeItemPosition
  53.     //  is called by the server to change the position on of the in-place
  54.     //  window.  Usually, this is a result of the data in the server
  55.     //  document changing such that the extent has changed or as a result
  56.     //  of in-place resizing.
  57.     //
  58.     // The default here is to call the base class, which will call
  59.     //  COleClientItem::SetItemRects to move the item
  60.     //  to the new position.
  61.  
  62.     if (!COleClientItem::OnChangeItemPosition(rectPos))
  63.         return FALSE;
  64.  
  65.     // TODO: update any cache you may have of the item's rectangle/extent
  66.  
  67.     return TRUE;
  68. }
  69.  
  70. void CContainCntrItem::OnGetItemPosition(CRect& rPosition)
  71. {
  72.     ASSERT_VALID(this);
  73.  
  74.     // During in-place activation, CContainCntrItem::OnGetItemPosition
  75.     //  will be called to determine the location of this item.  The default
  76.     //  implementation created from AppWizard simply returns a hard-coded
  77.     //  rectangle.  Usually, this rectangle would reflect the current
  78.     //  position of the item relative to the view used for activation.
  79.     //  You can obtain the view by calling CContainCntrItem::GetActiveView.
  80.  
  81.     // TODO: return correct rectangle (in pixels) in rectPos
  82.  
  83.     rPosition.SetRect(10, 10, 210, 210);
  84. }
  85.  
  86. void CContainCntrItem::OnDeactivateUI(BOOL bUndoable)
  87. {
  88.     COleClientItem::OnDeactivateUI(bUndoable);
  89.  
  90.     // Close an in-place active item whenever it removes the user
  91.     //  interface.  The action here should match as closely as possible
  92.     //  to the handling of the escape key in the view.
  93.  
  94.     Deactivate();   // nothing fancy here -- just deactivate the object
  95. }
  96.  
  97. void CContainCntrItem::Serialize(CArchive& ar)
  98. {
  99.     ASSERT_VALID(this);
  100.  
  101.     // Call base class first to read in COleClientItem data.
  102.     // Since this sets up the m_pDocument pointer returned from
  103.     //  CContainCntrItem::GetDocument, it is a good idea to call
  104.     //  the base class Serialize first.
  105.     COleClientItem::Serialize(ar);
  106.  
  107.     // now store/retrieve data specific to CContainCntrItem
  108.     if (ar.IsStoring())
  109.     {
  110.         // TODO: add storing code here
  111.     }
  112.     else
  113.     {
  114.         // TODO: add loading code here
  115.     }
  116. }
  117.  
  118. /////////////////////////////////////////////////////////////////////////////
  119. // CContainCntrItem diagnostics
  120.  
  121. #ifdef _DEBUG
  122. void CContainCntrItem::AssertValid() const
  123. {
  124.     COleClientItem::AssertValid();
  125. }
  126.  
  127. void CContainCntrItem::Dump(CDumpContext& dc) const
  128. {
  129.     COleClientItem::Dump(dc);
  130. }
  131. #endif
  132.  
  133. /////////////////////////////////////////////////////////////////////////////
  134.