home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / gui / CSpinningN.cp < prev    next >
Encoding:
Text File  |  1998-04-08  |  14.5 KB  |  542 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. //    CSpinningN.cp
  21. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  22.  
  23. #include <UResourceMgr.h>
  24. #include "CSpinningN.h"
  25. #include "UGraphicGizmos.h"
  26. #include "UGAAppearance.h"
  27. #include "CSharedPatternWorld.h"
  28. #include "macutil.h"
  29. #include "CNSContext.h"    // for the broadcast messages
  30. #include "uapp.h"
  31. #include "resgui.h"
  32.  
  33. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  34. //    Internal Constants
  35. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  36.  
  37. const Int32     kSpinInterval             =     10;
  38. const ResIDT    ResID_LargeSpinIconBase =    700;
  39. const ResIDT    ResID_SmallSpinIconBase =    800;
  40. const ResIDT    ResID_LargeCicnBase     =    700;
  41. const ResIDT    ResID_SmallCicnBase     =    128;
  42. short CSpinningN::mAnimResFile            =    -1;        // refNum_Undefined
  43.  
  44. const Int16        cLargeIconHeight        =    30;
  45. const Int16        cLargeIconWidth            =    30;
  46. const Int16        cSmallIconHeight        =    16;
  47. const Int16        cSmallIconWidth            =    16;
  48. const Int16        cButtonBevelBorderSize    =    8;
  49.  
  50. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  51. //    Ñ    
  52. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  53.  
  54. CSpinningN::CSpinningN(LStream *inStream)
  55.     :    mAdornment(nil),
  56.         mFill(nil),
  57.         
  58.         CPatternButton(inStream)
  59. {
  60.     mSpinCounter = 0;        // 0 indicates the icon is not spinning
  61.     mIsCoBranded = false;
  62.     mSmallSeqCount = 0;
  63.     mLargeSeqCount = 0;
  64.     mRefCount = 0;
  65.  
  66.     mHasLargeCoBrand = true;
  67.     mHasSmallCoBrand = true;
  68.  
  69.     mFinishedCreatingSelf = false;
  70. }
  71.  
  72. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  73. //    Ñ    
  74. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  75.  
  76. void CSpinningN::FinishCreateSelf(void)
  77. {
  78.     CPatternButton::FinishCreateSelf();
  79.     
  80.     CalcAnimationMode();
  81.     RepositionSelf();
  82.     mFinishedCreatingSelf = true;
  83.     
  84.     LView* theSuperView = GetSuperView();
  85.     if (theSuperView)
  86.     {
  87.         mAdornment    = theSuperView->FindPaneByID(kAdornmentPaneID);
  88.         mFill        = theSuperView->FindPaneByID(kFillPaneID);
  89.     }
  90. }
  91.  
  92. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  93. //    Ñ    
  94. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  95.     
  96. void CSpinningN::ListenToMessage(
  97.     MessageT            inMessage,
  98.     void*                /* ioParam */)
  99. {
  100.     switch (inMessage)
  101.         {
  102.         case msg_NSCStartLoadURL:
  103.             StartRepeating();
  104.             break;
  105.             
  106.         case msg_NSCAllConnectionsComplete:
  107.             StopRepeating();
  108.             break;
  109.         }
  110. }
  111.  
  112. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  113. //    Ñ    
  114. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  115.  
  116. void CSpinningN::AdaptToSuperFrameSize(
  117.     Int32                inSurrWidthDelta,
  118.     Int32                inSurrHeightDelta,
  119.     Boolean             inRefresh)
  120. {
  121.     LPane::AdaptToSuperFrameSize(inSurrWidthDelta, inSurrHeightDelta, inRefresh);
  122.  
  123. //    1997-03-22 pkc
  124. //    Put in hack to work around problem below. We can't comment out call
  125. //    to RepositionSelf because then the spinning 'n' won't resize itself when
  126. //    the toolbar containing it changes its size.
  127.     if (mFinishedCreatingSelf)
  128.         RepositionSelf();
  129. //        Don't do that here: AdaptToSuperFrameSize() can be called before
  130. //        FinishCreateSelf() and for some reason, the resource file may
  131. //        not be positionned correctly at that time.
  132. }
  133.  
  134. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  135. //    Ñ    
  136. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  137.  
  138. void CSpinningN::StartRepeating(void)
  139. {
  140.     if (mRefCount == 0)
  141.     {
  142.         mSpinCounter = 1;        // > 0 means that we're spinning
  143.         mLastSpinTicks = ::TickCount();
  144.     
  145.         LPeriodical::StartRepeating();
  146.     }
  147.     ++mRefCount;
  148. }
  149.  
  150. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  151. //    Ñ    
  152. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  153.  
  154. void CSpinningN::StopRepeating()
  155. {
  156.     if (mRefCount <= 1)
  157.     {
  158.         LPeriodical::StopRepeating();
  159.         
  160.         mSpinCounter = 0;        // 0 indicates the icon is not spinning
  161.         mLastSpinTicks = ::TickCount();
  162.         
  163.         if (IsVisible() && FocusDraw())
  164.             Draw(NULL);
  165.     }
  166.  
  167.     --mRefCount;
  168.     if (mRefCount < 0)
  169.         mRefCount = 0;
  170. }
  171.  
  172. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  173. //    Ñ    
  174. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  175. // BEWARE: this method bypasses the mRefCount counter in order to force
  176. // the icon to stop spinning. It's useful in several places where we do
  177. // know for sure that all background activity has stopped.
  178. void CSpinningN::StopSpinningNow()
  179. {
  180.     mRefCount = 1;
  181.     StopRepeating();
  182. }
  183.  
  184.  
  185. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  186. //    Ñ    
  187. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  188.  
  189. void CSpinningN::SpendTime(const EventRecord& /* inMacEvent */)
  190. {
  191.     if ((::TickCount() - mLastSpinTicks) < kSpinInterval) 
  192.         return;
  193.     
  194.     mLastSpinTicks = ::TickCount();
  195.  
  196.     mSpinCounter = (mSpinCounter + 1) % mIconCount;
  197.     if (mSpinCounter == 0) // skip zero
  198.         mSpinCounter++;
  199.         
  200.     if (IsVisible() && FocusDraw())
  201.         Draw(NULL);
  202. }
  203.  
  204. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  205. //    Ñ    
  206. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  207.  
  208. void CSpinningN::DrawSelf(void)
  209. {
  210.     PrepareDrawButton();
  211.  
  212.     DrawButtonContent();
  213.     
  214.     DrawButtonGraphic();            
  215.             
  216.     FinalizeDrawButton();
  217. }
  218.  
  219. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  220. //    Ñ    DrawButtonContent
  221. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  222.     
  223. void CSpinningN::DrawButtonContent(void)
  224. {
  225.     CGrafPtr thePort;
  226.     ::GetPort(&(GrafPtr)thePort);
  227.     
  228.     Rect theFrame = mCachedButtonFrame;
  229.     Point theAlignment;
  230.     
  231.     CalcOrientationPoint(theAlignment);
  232.     mPatternWorld->Fill(thePort, theFrame, theAlignment);
  233.  
  234.     ::InsetRect(&theFrame, 2, 2);
  235.  
  236.     if (IsActive() && IsEnabled())
  237.         {
  238.         if (IsTrackInside() || (!IsBehaviourButton() && (mValue == Button_On)))
  239.             {
  240.             DrawButtonHilited();
  241.             }
  242.         else
  243.             {
  244.             DrawButtonNormal();
  245.             }
  246.         }
  247.     else
  248.         {
  249.         DrawSelfDisabled();
  250.         }
  251. }
  252.  
  253. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  254. //    Ñ    DrawSelfDisabled
  255. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  256.     
  257. void CSpinningN::DrawSelfDisabled(void)
  258. {
  259.     UGAAppearance::DrawGAButtonDimmedBevelTint(mCachedButtonFrame);
  260. }
  261.  
  262. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  263. //    Ñ    DrawButtonGraphic
  264. //
  265. //    the first cicn's or icl8's in each of the large and small sequences should
  266. //    be preloaded and locked.
  267. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  268.  
  269. void CSpinningN::DrawButtonGraphic(void)
  270. {
  271.     Rect theFrame;
  272.     CalcLocalFrameRect(theFrame);
  273.     
  274.     UGraphicGizmos::CenterRectOnRect(mCachedIconFrame, theFrame);
  275.  
  276.     if (IsTrackInside() || (GetValue() == Button_On))
  277.         ::OffsetRect(&mCachedIconFrame, 1, 1);
  278.  
  279.     if (mIsCoBranded)
  280.         {
  281.         StUseResFile rf(mAnimResFile);
  282.         CIconHandle theHandle = ::GetCIcon(mGraphicID + mSpinCounter);
  283.         if (theHandle == NULL)
  284.             theHandle = ::GetCIcon(mGraphicID);
  285.     
  286.         if (theHandle != NULL)    
  287.             {
  288.             ::PlotCIcon(&mCachedIconFrame, theHandle);
  289.             ::DisposeCIcon(theHandle);
  290.             }
  291.         }
  292.     else
  293.         {
  294. //        UGraphicGizmos::CenterRectOnRect(mCachedIconFrame, theFrame);
  295.         OSErr theErr = ::PlotIconID(&mCachedIconFrame, atNone, ttNone, mGraphicID + mSpinCounter);
  296.         if (theErr != noErr)
  297.             ::PlotIconID(&mCachedIconFrame, atNone, ttNone, mGraphicID);
  298.         }
  299. }
  300.  
  301.  
  302. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  303. //    Ñ    
  304. //  For E-Kit compatability continue to support cicn resources as well
  305. //    as icl icons. E-Kit must also allow for a variable number of frames
  306. //    and non-default icon dimensions.
  307. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  308.  
  309. void CSpinningN::CalcAnimationMode(void)
  310. {
  311.     StResLoad theResLoad(false);
  312.     StUseResFile rf(mAnimResFile);
  313.     
  314.     Handle theSequence = ::Get1Resource('cicn', ResID_LargeCicnBase + mLargeSeqCount);
  315.     while (theSequence != NULL)
  316.         {
  317.         mLargeSeqCount++;
  318.         theSequence = ::Get1Resource('cicn', ResID_LargeCicnBase + mLargeSeqCount);
  319.         }
  320.         
  321.     theSequence = ::Get1Resource('cicn', ResID_SmallCicnBase + mSmallSeqCount);
  322.     while (theSequence != NULL)
  323.         {
  324.         mSmallSeqCount++;
  325.         theSequence = ::Get1Resource('cicn', ResID_SmallCicnBase + mSmallSeqCount);
  326.         }
  327.  
  328.     mHasSmallCoBrand = mSmallSeqCount > 0;
  329.     mHasLargeCoBrand = mLargeSeqCount > 0;
  330.  
  331.     if (!mHasSmallCoBrand) {
  332.         mSmallSeqCount = kMaxSpinStages;
  333.     }
  334.  
  335.     if (!mHasLargeCoBrand) {
  336.         mLargeSeqCount = kMaxSpinStages;
  337.     }
  338. }
  339.  
  340. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  341. //    Ñ    ChangeMode
  342. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  343.  
  344. Boolean CSpinningN::ChangeMode(Int8 inNewMode, SDimension16& outDimensionDeltas)
  345. {
  346.     SDimension16 oldDimensions, frameSize;
  347.     GetFrameSize(oldDimensions);
  348.  
  349.     outDimensionDeltas.width = 0;
  350.     outDimensionDeltas.height = 0;
  351.  
  352.     mCurrentMode = inNewMode;
  353.  
  354.     switch (inNewMode)
  355.     {
  356.         case eMode_IconsOnly:
  357.         case eMode_TextOnly:
  358.             GetSmallIconFrameSize(frameSize);
  359.             break;
  360.         
  361.         case eMode_IconsAndText:
  362.             GetLargeIconFrameSize(frameSize);
  363.             break;
  364.     }
  365.  
  366.     outDimensionDeltas.width = frameSize.width - oldDimensions.width;
  367.     outDimensionDeltas.height = frameSize.height - oldDimensions.height;
  368.     ResizeFrameBy(outDimensionDeltas.width, outDimensionDeltas.height, true);
  369.     return true;
  370. }
  371.  
  372. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  373. //    Ñ    
  374. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  375.  
  376. void CSpinningN::RepositionSelf(SDimension16* inNewToolbarSize)
  377. {
  378.     SDimension16    theSuperFrameSize;
  379.     
  380.     Assert_(GetSuperView() != NULL);
  381.     if (!GetSuperView())
  382.         return;
  383.     
  384.     if (!inNewToolbarSize)
  385.         GetSuperView()->GetFrameSize(theSuperFrameSize);
  386.     else
  387.     {
  388.         theSuperFrameSize.height = inNewToolbarSize->height;
  389.         theSuperFrameSize.width = inNewToolbarSize->width;
  390.     }
  391.     
  392.     Int16 theHeight, theWidth;
  393.     SDimension16 frameSize;
  394.     // Initalize frameSize to default value just in case GetLargeIconFrameSize fails
  395.     frameSize.height = frameSize.width = cLargeIconHeight + cButtonBevelBorderSize;
  396.     GetLargeIconFrameSize(frameSize);
  397.     
  398.     if (theSuperFrameSize.height >= frameSize.height)
  399.         {
  400.         mIconCount = mLargeSeqCount;
  401.         mIsCoBranded = mHasLargeCoBrand;
  402.         
  403.         if (mIsCoBranded)
  404.             {
  405.             mGraphicID = ResID_LargeCicnBase;
  406.             }
  407.         else
  408.             {
  409.             mGraphicID = ResID_LargeSpinIconBase;
  410.             theHeight = theWidth = cLargeIconHeight;
  411.             ::SetRect(&mCachedIconFrame, 0, 0, 32, 32);
  412.             }
  413.         }
  414.     else
  415.         {
  416.         mIconCount = mSmallSeqCount;
  417.         mIsCoBranded = mHasSmallCoBrand;
  418.         
  419.         if (mIsCoBranded)
  420.             {
  421.             mGraphicID = ResID_SmallCicnBase;
  422.             }
  423.         else
  424.             {
  425.             mGraphicID = ResID_SmallSpinIconBase;
  426.             theHeight = theWidth = cSmallIconHeight;
  427.             ::SetRect(&mCachedIconFrame, 0, 0, 32, 32);
  428.             }
  429.         }
  430.  
  431.     if (mIsCoBranded)
  432.         {
  433.         StUseResFile rf(mAnimResFile);
  434.         CIconHandle theIcon = ::GetCIcon(mGraphicID);
  435.         if (theIcon != NULL)
  436.             {
  437.             theHeight = RectHeight((*theIcon)->iconPMap.bounds);
  438.             theWidth = RectWidth((*theIcon)->iconPMap.bounds);
  439.             ::SetRect(&mCachedIconFrame, 0, 0, theWidth, theHeight);
  440.             ::DisposeCIcon(theIcon);
  441.             }
  442.         }
  443.  
  444.     if (mSpinCounter >= mIconCount)
  445.         mSpinCounter = 1;
  446.  
  447.  
  448.     // Adjust the position and size of this pane (center vertically)
  449.     
  450.     SInt32    h;
  451.     SInt32    v;
  452.     
  453. //    SDimension16 frameSize;
  454.     GetFrameSize(frameSize);
  455.     
  456. //    v = (theSuperFrameSize.height - theHeight) / 2;
  457. //    h = theSuperFrameSize.width - theWidth - v - 1;
  458. //    PlaceInSuperFrameAt(h, v, false);
  459. //    ResizeFrameTo(theWidth, theHeight, true);
  460.  
  461.     // Adjust theWidth and theHeight to take into account
  462.     // button bevel
  463.     
  464.     theWidth += 8;
  465.     theHeight += 8;
  466.  
  467.     v = (theSuperFrameSize.height - theHeight) / 2;
  468.     h = theSuperFrameSize.width - theWidth - v - 1;
  469.     PlaceInSuperFrameAt(h, v, false);
  470.     ResizeFrameTo(theWidth, theHeight, true);
  471.  
  472. /*
  473.     // Adjust the adornment pane
  474.     
  475.     if (theSuperFrameSize.height <= theHeight || theHeight < 40)
  476.     {
  477.         if (mAdornment)
  478.             mAdornment->Hide();
  479.     }
  480.     else
  481.     {
  482.         if (mAdornment)
  483.         {
  484.             mAdornment->PlaceInSuperFrameAt(h - 1, v - 1, false);
  485.             mAdornment->ResizeFrameTo(theWidth + 2, theHeight + 2, true);
  486.             mAdornment->Show();
  487.         }
  488.     }
  489.     
  490.     // Adjust the position and size of the fill pane
  491.     
  492.     if (mFill)
  493.     {
  494.         h = theSuperFrameSize.width - theWidth - v - 1;
  495.         mFill->PlaceInSuperFrameAt(h, 1, false);
  496.         mFill->ResizeFrameTo(theSuperFrameSize.width - h, theSuperFrameSize.height - 2, true);
  497.     }
  498. */
  499. }
  500.  
  501. void CSpinningN::GetLargeIconFrameSize(SDimension16& outFrameSize)
  502. {
  503.     if (mHasLargeCoBrand)
  504.     {
  505.         StUseResFile rf(mAnimResFile);
  506.         CIconHandle theIcon = ::GetCIcon(ResID_LargeCicnBase);
  507.         if (theIcon != NULL)
  508.             {
  509.             outFrameSize.height = RectHeight((*theIcon)->iconPMap.bounds) + cButtonBevelBorderSize;
  510.             outFrameSize.width = RectWidth((*theIcon)->iconPMap.bounds) + cButtonBevelBorderSize;
  511.             ::DisposeCIcon(theIcon);
  512.             }
  513.     }
  514.     else
  515.     {
  516.         outFrameSize.height = cLargeIconHeight + cButtonBevelBorderSize;
  517.         outFrameSize.width = cLargeIconWidth + cButtonBevelBorderSize;
  518.     }
  519. }
  520.  
  521. void CSpinningN::GetSmallIconFrameSize(SDimension16& outFrameSize)
  522. {
  523.     if (mHasSmallCoBrand)
  524.     {
  525.         StUseResFile rf(mAnimResFile);
  526.         CIconHandle theIcon = ::GetCIcon(ResID_SmallCicnBase);
  527.         if (theIcon != NULL)
  528.             {
  529.             outFrameSize.height = RectHeight((*theIcon)->iconPMap.bounds) + cButtonBevelBorderSize;
  530.             outFrameSize.width = RectWidth((*theIcon)->iconPMap.bounds) + cButtonBevelBorderSize;
  531.             ::DisposeCIcon(theIcon);
  532.             }
  533.     }
  534.     else
  535.     {
  536.         outFrameSize.height = cSmallIconHeight + cButtonBevelBorderSize;
  537.         outFrameSize.width = cSmallIconWidth + cButtonBevelBorderSize;
  538.     }
  539. }
  540.  
  541.  
  542.