home *** CD-ROM | disk | FTP | other *** search
/ ...taking it to the Macs! / ...taking it to the Macs!.iso / Extras / ActiveX Mac SDK / ActiveX SDK / Containers / ActiveXApp / CActiveXShadowView.cpp < prev    next >
Encoding:
Text File  |  1996-12-10  |  8.2 KB  |  275 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    CActiveXShadowView.cpp               ©1996 Microsoft Corporation. All rights reserved.
  3. // ===========================================================================
  4. //
  5. //    manages an active x control
  6.  
  7. #ifdef PowerPlant_PCH
  8. #include PowerPlant_PCH
  9. #endif
  10.  
  11. #include "ActiveXAppConstants.h"
  12. #include "CActiveXDocument.h"
  13. #include "CActiveXView.h"
  14. #include "CActiveXShadowView.h"
  15. #include "CArgumentParser.h"
  16. #include <LStream.h>
  17. #include <UDrawingState.h>
  18.  
  19. #ifndef __TOOLUTILS__
  20. #include <ToolUtils.h>
  21. #endif
  22.  
  23. #include "HEADERS.H"
  24.  
  25. #pragma mark === CActiveXShadowView::Construction & Destruction ===
  26.  
  27. // ---------------------------------------------------------------------------
  28. //        • CActiveXShadowView::CreateActiveXShadowViewStream [static]
  29. // ---------------------------------------------------------------------------
  30. //    Return a new Picture object initialized using data from a Stream
  31.  
  32. CActiveXShadowView*
  33. CActiveXShadowView::CreateActiveXShadowViewStream(
  34.     LStream    *inStream)
  35. {
  36.     return (new CActiveXShadowView(inStream));
  37. }
  38.  
  39.  
  40. // ---------------------------------------------------------------------------
  41. //        • CActiveXShadowView::CActiveXShadowView
  42. // ---------------------------------------------------------------------------
  43. //    Default Constructor
  44.  
  45. CActiveXShadowView::CActiveXShadowView() : LDragAndDrop(UQDGlobals::GetCurrentPort(), this)
  46. {
  47.     mMasterView = NULL;
  48.     mMasterViewID = 0;
  49.     mContextDirty = false;
  50. }
  51.  
  52.  
  53. // ---------------------------------------------------------------------------
  54. //        • CActiveXShadowView::CActiveXShadowView(LStream*)
  55. // ---------------------------------------------------------------------------
  56. //    Construct shadow view from the data in a Stream
  57.  
  58. CActiveXShadowView::CActiveXShadowView(
  59.     LStream    *inStream)
  60.         : LView(inStream), LDragAndDrop(UQDGlobals::GetCurrentPort(), this)
  61. {
  62.     mMasterView = NULL;
  63.     mMasterViewID = 0;
  64.     mContextDirty = false;
  65.  
  66.     inStream->ReadData(&mMasterViewID, sizeof(mMasterViewID));
  67. }
  68.  
  69.  
  70. // ---------------------------------------------------------------------------
  71. //        • CActiveXShadowView::~CActiveXShadowView()
  72. // ---------------------------------------------------------------------------
  73. //    Destructor
  74.  
  75. CActiveXShadowView::~CActiveXShadowView(void)
  76. {
  77.     if ( mMasterView )
  78.         mMasterView->RemoveShadowView( this );
  79. }
  80.  
  81.  
  82. #pragma mark === CActiveXShadowView ===
  83.  
  84. // ---------------------------------------------------------------------------
  85. //        • CActiveXShadowView::DrawSelf
  86. // ---------------------------------------------------------------------------
  87. //    Draw the shadow view
  88.  
  89. void
  90. CActiveXShadowView::DrawSelf()
  91. {
  92.     if (!mMasterView)
  93.         FindMasterView(this);
  94.  
  95.     if (mMasterView)
  96.     {
  97.         mMasterView->DrawShadowView( this, mContextDirty );
  98.         mContextDirty = false;
  99.     }
  100. }
  101.     
  102.  
  103. // ---------------------------------------------------------------------------
  104. //        • CActiveXShadowView::DoEvent
  105. // ---------------------------------------------------------------------------
  106. //    Pass events to Active X
  107.  
  108. void
  109. CActiveXShadowView::DoEvent(EventRecord *Event, Boolean *PassEventUp, Boolean *RemoveAttachment)
  110. {
  111.     if (!mMasterView)
  112.         FindMasterView(this);
  113.  
  114.     if (mMasterView)
  115.         mMasterView->DoEvent(Event, PassEventUp, RemoveAttachment);
  116. }
  117.  
  118.  
  119. // ---------------------------------------------------------------------------
  120. //        • CActiveXShadowView::SetMasterView
  121. // ---------------------------------------------------------------------------
  122. //    Change the master view
  123.  
  124. void
  125. CActiveXShadowView::SetMasterView(CActiveXView *inMasterView)
  126. {
  127.     mMasterView = inMasterView;
  128. }
  129.  
  130.  
  131. // ---------------------------------------------------------------------------
  132. //        • CActiveXShadowView::FindMasterView [static]
  133. // ---------------------------------------------------------------------------
  134. //    find the containing window
  135.  
  136. void
  137. CActiveXShadowView::FindMasterView(CActiveXShadowView* inView)
  138. {
  139.     LView    *CurrentView = inView;
  140.     LView    *NextView;
  141.  
  142.     while ((NextView = CurrentView->GetSuperView()) != NULL)
  143.         CurrentView = NextView;
  144.  
  145.     inView->mMasterView = (CActiveXView *) CurrentView->FindPaneByID( inView->mMasterViewID );
  146.     inView->mMasterView->AddShadowView(inView);
  147. }
  148.  
  149.  
  150. #pragma mark === CActiveXShadowView::LView ===
  151.  
  152. // ---------------------------------------------------------------------------
  153. //        • CActiveXShadowView::LView::Click
  154. // ---------------------------------------------------------------------------
  155. //    Pass Mouse Click Events to Active X
  156.  
  157. void
  158. CActiveXShadowView::Click(SMouseDownEvent &inMouseDown)
  159. {
  160.     if (!mMasterView)
  161.         FindMasterView(this);
  162.  
  163.     if (mMasterView)
  164.         mMasterView->ClickInShadowView(this, inMouseDown);
  165. }
  166.  
  167.  
  168. // ---------------------------------------------------------------------------
  169. //        • CActiveXShadowView::LView::ResizeFrameBy
  170. // ---------------------------------------------------------------------------
  171. //    Log self as the active draw context, and pass through the click
  172.  
  173. void
  174. CActiveXShadowView::ResizeFrameBy(Int16 inWidthDelta, Int16 inHeightDelta, Boolean inRefresh)
  175. {
  176.     mContextDirty = true;
  177.     LView::ResizeFrameBy(inWidthDelta, inHeightDelta, inRefresh);
  178. }
  179.  
  180.  
  181. // ---------------------------------------------------------------------------
  182. //        • CActiveXShadowView::LView::MoveBy
  183. // ---------------------------------------------------------------------------
  184. //    Log self as the active draw context, and pass through the click
  185.  
  186. void
  187. CActiveXShadowView::MoveBy(Int32 inHorizDelta, Int32 inVertDelta, Boolean inRefresh)
  188. {
  189.     mContextDirty = true;
  190.     LView::MoveBy(inHorizDelta, inVertDelta, inRefresh);
  191. }
  192.  
  193.  
  194. // ---------------------------------------------------------------------------
  195. //        • CActiveXShadowView::LView::AdaptToNewSurroundings
  196. // ---------------------------------------------------------------------------
  197. //    Log self as the active draw context, and pass through the click
  198.  
  199. void
  200. CActiveXShadowView::AdaptToNewSurroundings(void)
  201. {
  202.     mContextDirty = true;
  203.     LView::AdaptToNewSurroundings();
  204. }
  205.  
  206.  
  207. // ---------------------------------------------------------------------------
  208. //        • CActiveXShadowView::LView::AdaptToSuperFrameSize
  209. // ---------------------------------------------------------------------------
  210. //    Log self as the active draw context, and pass through the click
  211.  
  212. void
  213. CActiveXShadowView::AdaptToSuperFrameSize(Int32 inSurrWidthDelta, Int32 inSurrHeightDelta, Boolean inRefresh)
  214. {
  215.     mContextDirty = true;
  216.     LView::AdaptToSuperFrameSize(inSurrWidthDelta, inSurrHeightDelta, inRefresh);
  217. }
  218.  
  219.  
  220. // ---------------------------------------------------------------------------
  221. //        • CActiveXShadowView::LView::ScrollImageBy
  222. // ---------------------------------------------------------------------------
  223. //    Log self as the active draw context, and pass through the click
  224.  
  225. void
  226. CActiveXShadowView::ScrollImageBy(Int32 inLeftDelta, Int32 inTopDelta, Boolean inRefresh)
  227. {
  228.     mContextDirty = true;
  229.     LView::ScrollImageBy(inLeftDelta, inTopDelta, inRefresh);
  230. }
  231.  
  232.  
  233. // ---------------------------------------------------------------------------
  234. //        • CActiveXShadowView::LView::ResizeImageBy
  235. // ---------------------------------------------------------------------------
  236. //    Log self as the active draw context, and pass through the click
  237.  
  238. void
  239. CActiveXShadowView::ResizeImageBy(Int32 inWidthDelta, Int32 inHeightDelta, Boolean inRefresh)
  240. {
  241.     mContextDirty = true;
  242.     LView::ResizeImageBy(inWidthDelta, inHeightDelta, inRefresh);
  243. }
  244.  
  245.  
  246. #pragma mark === CActiveXView::LDragAndDrop ===
  247.  
  248. // ---------------------------------------------------------------------------
  249. //        • CActiveXShadowView::LDragAndDrop::ItemIsAcceptable
  250. // ---------------------------------------------------------------------------
  251. //    tell the control about a draw context change
  252.  
  253. Boolean
  254. CActiveXShadowView::ItemIsAcceptable( DragReference inDragRef, ItemReference inItemRef )
  255. {
  256.     if (mMasterView)
  257.         return mMasterView->ItemIsAcceptable(inDragRef, inItemRef);
  258.  
  259.     return false;
  260. }
  261.  
  262.  
  263. // ---------------------------------------------------------------------------
  264. //        • CActiveXShadowView::LDragAndDrop::ReceiveDragItem
  265. // ---------------------------------------------------------------------------
  266. //    tell the control about a draw context change
  267.  
  268. void
  269. CActiveXShadowView::ReceiveDragItem( DragReference inDragRef, DragAttributes inDragAttrs,
  270.                             ItemReference inItemRef, Rect &inItemBounds)
  271. {
  272.     if (mMasterView)
  273.         mMasterView->ReceiveDragItem(inDragRef, inDragAttrs, inItemRef, inItemBounds);
  274. }
  275.