home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / gui / CDragBarDragTask.cp < prev    next >
Encoding:
Text File  |  1998-04-08  |  4.3 KB  |  160 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  20. //    CDragBarDragTask.cp
  21. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  22.  
  23. #include "CDragBarDragTask.h"
  24. #include "CDragBar.h"
  25. #include "CGWorld.h"
  26.  
  27. #include "StCaptureView.h"
  28. #include "CEnvironment.h"
  29.  
  30. #include <Drag.h>
  31.  
  32. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  33. //    Ñ    
  34. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  35.  
  36. CDragBarDragTask::CDragBarDragTask(
  37.     CDragBar*            inBar,
  38.     const EventRecord&     inEventRecord)
  39.     :    LDragTask(inEventRecord)
  40. {
  41.     mBar = inBar;
  42. }
  43.  
  44. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  45. //    Ñ    
  46. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  47.                                     
  48. CDragBarDragTask::~CDragBarDragTask()
  49. {
  50. }
  51.  
  52. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  53. //    Ñ    
  54. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  55.  
  56. OSErr CDragBarDragTask::DoDrag(void)
  57. {
  58.     if (UEnvironment::HasFeature(env_HasDragMgrImageSupport))
  59.         {
  60.         Boolean bTranslucentFailed = false;
  61.         try
  62.             {
  63.             DoTranslucentDrag();
  64.             }
  65.         catch (...)
  66.             {
  67.             bTranslucentFailed = true;
  68.             }
  69.             
  70.         if (bTranslucentFailed)
  71.             DoNormalDrag();
  72.         }
  73.     else
  74.         DoNormalDrag();
  75.         
  76.     return noErr;
  77. }
  78.  
  79. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  80. //    Ñ    
  81. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  82.  
  83. void CDragBarDragTask::DoNormalDrag(void)
  84. {
  85.     mBar->StartTracking();
  86.     LDragTask::DoDrag();
  87.     mBar->StopTracking();
  88. }
  89.  
  90. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  91. //    Ñ    
  92. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  93.  
  94. void CDragBarDragTask::DoTranslucentDrag(void)
  95. {
  96.     StColorState::Normalize();
  97.     mBar->FocusDraw();
  98.     
  99.     Rect theFrame;
  100.     mBar->CalcLocalFrameRect(theFrame);
  101.  
  102.     CGWorld theOffWorld(theFrame, 0, useTempMem);
  103.     StCaptureView theCaptureView(*mBar);
  104.     theCaptureView.Capture(theOffWorld);
  105.  
  106.     mBar->FocusDraw();
  107.  
  108.        Point theOffsetPoint = topLeft(theFrame);
  109.     ::LocalToGlobal(&theOffsetPoint);
  110.  
  111.     StRegion theTrackMask(theFrame);
  112.     PixMapHandle theMap = ::GetGWorldPixMap(theOffWorld.GetMacGWorld());
  113.     OSErr theErr = ::SetDragImage(mDragRef, theMap, theTrackMask, theOffsetPoint, kDragDarkerTranslucency);
  114.     ThrowIfOSErr_(theErr);
  115.     
  116.     mBar->StartTracking();
  117.     LDragTask::DoDrag();
  118.     mBar->StopTracking();
  119. }
  120.  
  121. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  122. //    Ñ    
  123. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  124.  
  125. void CDragBarDragTask::AddFlavors(
  126.     DragReference            inDragRef)
  127. {
  128.     OSErr theErr = ::AddDragItemFlavor(inDragRef, (ItemReference)this, Flavor_DragBar, mBar, sizeof(CDragBar*), flavorSenderOnly);
  129.     ThrowIfOSErr_(theErr);
  130. }
  131.  
  132. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  133. //    Ñ    
  134. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  135.  
  136. void CDragBarDragTask::MakeDragRegion(
  137.     DragReference        inDragRef,
  138.     RgnHandle            /* inDragRegion */)
  139. {
  140.     
  141.     Rect theLocalBarFrame;
  142.     mBar->FocusDraw();
  143.     mBar->CalcLocalFrameRect(theLocalBarFrame);
  144.     
  145.     Rect theGlobalFrame = theLocalBarFrame;
  146.     ::LocalToGlobal(&topLeft(theGlobalFrame));
  147.     ::LocalToGlobal(&botRight(theGlobalFrame));
  148.     
  149.     // Get the single item and add this, its rectangle
  150.     ItemReference item;
  151.     ::GetDragItemReferenceNumber(inDragRef, 1, &item);
  152.     AddRectDragItem(item, theGlobalFrame);
  153. }
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.