home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / gui / CDragBarDockControl.cp < prev    next >
Encoding:
Text File  |  1998-04-08  |  15.0 KB  |  517 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. //    CDragBarDockControl.cp
  21. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  22. #include "CDragBarDockControl.h"
  23.  
  24.  
  25. #include "CDragBar.h"
  26. #include "CSharedPatternWorld.h"
  27. #include "UGraphicGizmos.h"
  28.  
  29. #include <LArray.h>
  30. #include <LArrayIterator.h>
  31. #include <UTextTraits.h>
  32. #include <LString.h>
  33.  
  34. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  35. //    Ñ    
  36. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  37.  
  38. CDragBarDockControl::CDragBarDockControl(LStream* inStream)
  39.     :    LControl(inStream),
  40.         mBars(sizeof(CDragBar*))
  41. {
  42.     mNeedsRecalc = true;
  43.     mMouseInside = nil;
  44.     
  45.     // Ñ╩These constants should be in the PPob....
  46.     
  47.     ResIDT thePatternID;
  48.     *inStream >> thePatternID;
  49.     mBackPattern = CSharedPatternWorld::CreateSharedPatternWorld(thePatternID);
  50.     ThrowIfNULL_(mBackPattern);
  51.     mBackPattern->AddUser(this);
  52.     mBackPatternHilite = CSharedPatternWorld::CreateSharedPatternWorld(10001);
  53.     ThrowIfNULL_(mBackPatternHilite);
  54.     mBackPatternHilite->AddUser(this);
  55.  
  56.     mGrippy = CSharedPatternWorld::CreateSharedPatternWorld(10004);
  57.     ThrowIfNULL_(mGrippy);
  58.     mGrippy->AddUser(this);
  59.     mGrippyHilite = CSharedPatternWorld::CreateSharedPatternWorld(10005);
  60.     ThrowIfNULL_(mGrippyHilite);
  61.     mGrippyHilite->AddUser(this);
  62.  
  63.     *inStream >> mBarTraitsID;
  64.  
  65.     mTriangle = ::GetCIcon(10000);
  66.     ThrowIfNULL_(mTriangle);
  67.  
  68.     SetRefreshAllWhenResized(false);
  69. }
  70.  
  71. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  72. //    Ñ    
  73. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  74.  
  75. CDragBarDockControl::~CDragBarDockControl()
  76. {
  77.     mBackPattern->RemoveUser(this);
  78.     mBackPatternHilite->RemoveUser(this);
  79.     mGrippy->RemoveUser(this);
  80.     mGrippyHilite->RemoveUser(this);
  81.     
  82.     ::DisposeCIcon(mTriangle);
  83. }
  84.  
  85. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  86. //    Ñ    
  87. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  88.  
  89. void CDragBarDockControl::SetNeedsRecalc(Boolean inRecalc)
  90. {
  91.     mNeedsRecalc = inRecalc;
  92. }
  93.  
  94. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  95. //    Ñ    
  96. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  97.  
  98. Boolean CDragBarDockControl::IsRecalcRequired(void) const
  99. {
  100.     return mNeedsRecalc;
  101. }
  102.  
  103. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  104. //    Ñ    
  105. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  106.  
  107. void CDragBarDockControl::AddBarToDock(CDragBar* inBar)
  108. {
  109.     inBar->Dock();
  110.     mBars.InsertItemsAt(1, LArray::index_First, &inBar);
  111.     SetNeedsRecalc(true);
  112. }
  113.  
  114. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  115. //    Ñ    
  116. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  117.  
  118. void CDragBarDockControl::RemoveBarFromDock(CDragBar* inBar)
  119. {
  120.     inBar->Undock();
  121.     mBars.Remove(&inBar);
  122.     SetNeedsRecalc(true);
  123. }
  124.  
  125. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  126. //    Ñ    
  127. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  128.  
  129. Boolean CDragBarDockControl::HasDockedBars(void) const
  130. {
  131.     return (mBars.GetCount() > 0);
  132. }
  133.  
  134. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  135. //    Ñ    
  136. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  137.  
  138. void CDragBarDockControl::RecalcDock(void)
  139. {
  140.     FocusDraw();
  141.     UTextTraits::SetPortTextTraits(mBarTraitsID);
  142.  
  143.     Rect theFrame;
  144.     CalcLocalFrameRect(theFrame);
  145.     Int16 theLeftIndex = theFrame.left;
  146.     
  147.     CDragBar* theBar;
  148.     LArrayIterator theIter(mBars, LArrayIterator::from_Start);
  149.     while (theIter.Next(&theBar))
  150.         {
  151.         SDimension16 theBarSize;
  152.         theBar->GetFrameSize(theBarSize);
  153.         
  154.         Rect theBarFrame;
  155.         theBarFrame.left = theLeftIndex;
  156.         theBarFrame.top = theFrame.top;
  157.         theBarFrame.right = theBarFrame.left + theBarSize.height + 12; 
  158.         theBarFrame.bottom = theFrame.bottom;
  159.         CalcOneDockedBar(theBar, theBarFrame);
  160.  
  161.         theLeftIndex += RectWidth(theBarFrame);
  162.         }    
  163. }
  164.  
  165. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  166. //    Ñ    
  167. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  168.  
  169. void CDragBarDockControl::CalcOneDockedBar(
  170.     CDragBar*        inBar,
  171.     const Rect&        inBounds)
  172. {
  173.     Int16 theHeight = RectHeight(inBounds);
  174.     
  175.     ::OpenRgn();
  176.     ::MoveTo(inBounds.left, inBounds.top);
  177.     ::LineTo(inBounds.right, inBounds.top);
  178.     ::LineTo(inBounds.right - theHeight, inBounds.bottom);
  179.     
  180.     if (mBars.FetchIndexOf(&inBar) == LArray::index_First)
  181.         ::LineTo(inBounds.left, inBounds.bottom);
  182.     else
  183.         ::LineTo(inBounds.left - theHeight, inBounds.bottom);
  184.         
  185.     ::LineTo(inBounds.left, inBounds.top);
  186.     ::CloseRgn(inBar->mDockedMask);
  187. }
  188.  
  189.  
  190. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  191. //    Ñ    
  192. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  193.  
  194. void CDragBarDockControl::DrawSelf(void)
  195. {
  196.     if (mBars.GetCount() == 0)
  197.         {
  198.         Assert_(false);        // we should have been hidden and not drawn
  199.         return;
  200.         }
  201.         
  202.     if (IsRecalcRequired())
  203.         RecalcDock();
  204.  
  205.     Rect theFrame;
  206.     CalcLocalFrameRect(theFrame);
  207.     StClipRgnState theClipSaver(theFrame);
  208.  
  209.     // FIXME the port relative calculation works when you're a view and not a pane
  210.     Point theAlignment;
  211.     //    CSharedPatternWorld::CalcRelativePoint(this, CSharedPatternWorld::eOrientation_Port, theAlignment);
  212.     mSuperView->GetPortOrigin(theAlignment);
  213.  
  214.     // We do this instead of LPane::GetMacPort() because we may be being
  215.     // drawn offscreen.
  216.     CGrafPtr thePort;
  217.     ::GetPort(&(GrafPtr)thePort);
  218.  
  219.     mBackPattern->Fill(thePort, theFrame, theAlignment);
  220.     UGraphicGizmos::LowerColorVolume(theFrame, 0x2000);
  221.     
  222.     CDragBar* theBar;
  223.     LArrayIterator theIter(mBars, LArrayIterator::from_Start);
  224.     while (theIter.Next(&theBar))
  225.         DrawOneDockedBar(theBar);
  226. }
  227.  
  228.  
  229. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  230. //    Ñ    
  231. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  232.  
  233.  
  234. void CDragBarDockControl::DrawOneDockedBar(
  235.     CDragBar*             inBar)
  236. {
  237.     StClipRgnState theClipSaver(inBar->mDockedMask);
  238.     Rect theTabFrame = (**static_cast<RgnHandle>(inBar->mDockedMask)).rgnBBox;
  239.     Int16 theHeight = RectHeight(theTabFrame);
  240.     Int16 theHalfHeight = theHeight / 2;
  241.  
  242.     // FIXME the port relative calculation works when you're a view and not a pane
  243.     Point theAlignment;
  244.     //    CSharedPatternWorld::CalcRelativePoint(this, CSharedPatternWorld::eOrientation_Port, theAlignment);
  245.     mSuperView->GetPortOrigin(theAlignment);
  246.  
  247.     CGrafPtr thePort;
  248.     ::GetPort(&(GrafPtr)thePort);
  249.     if ( mMouseInside == inBar )
  250.         mBackPatternHilite->Fill(thePort, theTabFrame, theAlignment);
  251.     else
  252.         mBackPattern->Fill(thePort, theTabFrame, theAlignment);
  253.  
  254.         // Draw the beveled outline hilighting
  255.     RGBColor theTintColor = { 0x5000, 0x5000, 0x5000 };
  256.     ::RGBForeColor(&theTintColor);
  257.     ::OpColor(&UGraphicGizmos::sLighter);
  258.     ::PenMode(addPin);
  259.  
  260.     ArrayIndexT theIndex = mBars.FetchIndexOf(&inBar);
  261.     ::MoveTo(theTabFrame.left, theTabFrame.bottom - 1);
  262.     if (theIndex == LArray::index_First)
  263.         ::LineTo(theTabFrame.left, theTabFrame.top);
  264.     else
  265.         ::LineTo(theTabFrame.left + theHeight, theTabFrame.top);
  266.  
  267.     ::LineTo(theTabFrame.right - 1, theTabFrame.top);
  268.     
  269.     ::OpColor(&UGraphicGizmos::sDarker);
  270.     ::PenMode(subPin);
  271.  
  272.     ::LineTo(theTabFrame.right - theHeight - 1, theTabFrame.bottom - 1);
  273.     ::LineTo(theTabFrame.left, theTabFrame.bottom - 1);
  274.  
  275.         // Draw the triangle
  276.     Rect theTriangleDest = theTabFrame;
  277.     if (theIndex == LArray::index_First)
  278.         theTriangleDest.left += theHalfHeight;
  279.     else
  280.         theTriangleDest.left += theHeight;
  281.     theTriangleDest.right = theTriangleDest.left + (theHeight / 2);
  282.  
  283.     Rect theTriangleFrame = (**mTriangle).iconPMap.bounds;
  284.     UGraphicGizmos::CenterRectOnRect(theTriangleFrame, theTriangleDest);
  285.     ::PlotCIcon(&theTriangleFrame, mTriangle);
  286.  
  287.         // Inset the tab shape then knock out the area surrounding the triangle.
  288.     StRegion theInsetCopy(inBar->mDockedMask);
  289.     ::InsetRgn(theInsetCopy, 2, 2);
  290.  
  291.     theTriangleDest.left = theTabFrame.left;
  292.     theTriangleDest.right += theHalfHeight;
  293.     StRegion theTriangleMask(theTriangleDest);
  294.     ::DiffRgn(theInsetCopy, theTriangleMask, theInsetCopy);
  295.     ::SetClip(theInsetCopy);
  296.     
  297.         // draw the grippy pattern
  298.     Rect thePatternFrame = (**static_cast<RgnHandle>(theInsetCopy)).rgnBBox;
  299.     if ( mMouseInside == inBar )
  300.         mGrippyHilite->Fill(thePort, thePatternFrame, theAlignment);
  301.     else
  302.         mGrippy->Fill(thePort, thePatternFrame, theAlignment);
  303.  
  304. }
  305.  
  306.  
  307.  
  308. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  309. //    Ñ    
  310. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  311.  
  312. void CDragBarDockControl::ResizeFrameBy(
  313.     Int16             inWidthDelta,
  314.     Int16            inHeightDelta,
  315.     Boolean            inRefresh)
  316. {
  317.     LControl::ResizeFrameBy(inWidthDelta, inHeightDelta, inRefresh);
  318.     SetNeedsRecalc(true);
  319. }
  320.  
  321. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  322. //    Ñ Hides the bar from the dock if docked - mjc
  323. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  324. void CDragBarDockControl::HideBar(CDragBar* inBar)
  325. {
  326.     if (inBar->IsDocked() && inBar->IsAvailable())
  327.     {
  328.         mBars.Remove(&inBar);
  329.         SetNeedsRecalc(true);
  330.     }
  331. }
  332.  
  333. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  334. //    Ñ Shows the bar in the dock if it was docked previously (use with HideBar) - mjc
  335. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  336. void CDragBarDockControl::ShowBar(CDragBar* inBar)
  337. {
  338.     if (inBar->IsDocked()  && !inBar->IsAvailable())
  339.     {
  340.         mBars.InsertItemsAt(1, LArray::index_First, &inBar);
  341.         SetNeedsRecalc(true);
  342.     }
  343. }
  344.  
  345.  
  346. //
  347. // MouseWithin
  348. //
  349. // Called by powerPlant when the mouse is inside the control. Find which collapsed bar the mouse
  350. // is hovering over and if it is different from the one that is currently hilighted, 
  351. // redraw.
  352. //
  353. void 
  354. CDragBarDockControl :: MouseWithin ( Point inPoint, const EventRecord & /* inEvent */) 
  355. {
  356.     PortToLocalPoint(inPoint);
  357.     const CDragBar* curr = FindBarSpot ( inPoint );
  358.     if ( mMouseInside != curr ) {
  359.         mMouseInside = curr;
  360.         Refresh();
  361.         ExecuteAttachments(msg_HideTooltip, nil);
  362.     }
  363. }
  364.  
  365.  
  366. //
  367. // MouseLeave
  368. //
  369. // Called by powerplant when the mouse leaves the control. No more hilighting, so forget
  370. // that any bar is selected and redraw back to the normal state
  371. //
  372. void 
  373. CDragBarDockControl :: MouseLeave ( )
  374. {
  375.     if ( mMouseInside ) {
  376.         mMouseInside = nil;
  377.         Refresh();
  378.     }
  379. }
  380.  
  381.  
  382. //
  383. // 
  384. void
  385. CDragBarDockControl :: FindTooltipForMouseLocation ( const EventRecord& inMacEvent, StringPtr outTip )
  386. {    
  387.     Point where = inMacEvent.where;
  388.     GlobalToPortPoint ( where );
  389.     PortToLocalPoint ( where );
  390.     const CDragBar* curr = FindBarSpot ( where );
  391.     if ( curr )
  392.         curr->GetDescriptor(outTip);
  393.     else
  394.         ::GetIndString ( outTip, 10506, 13 );        // supply a helpful message...
  395.  
  396. } // FindTooltipForMouseLocation
  397.  
  398.  
  399. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  400. //
  401. #pragma mark --- CONTROL BEHAVIOUR ---
  402. //
  403. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  404.  
  405. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  406. //    Ñ    
  407. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  408.  
  409. Int16 CDragBarDockControl::FindHotSpot(Point inPoint)
  410. {
  411.     Int16 theHotSpot = 0;
  412.     CDragBar* theBar;
  413.     LArrayIterator theIter(mBars, LArrayIterator::from_Start);
  414.     while (theIter.Next(&theBar))
  415.         {            
  416.         if (::PtInRgn(inPoint, theBar->mDockedMask))
  417.             {
  418.             theHotSpot = theIter.GetCurrentIndex();
  419.             break;
  420.             }
  421.         }
  422.     
  423.     return theHotSpot;
  424. }
  425.  
  426. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  427. //    Ñ    
  428. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  429.  
  430. Boolean CDragBarDockControl::PointInHotSpot(Point inPoint, Int16 inHotSpot)
  431. {
  432.     CDragBar* theBar = NULL;
  433.     mBars.FetchItemAt(inHotSpot, &theBar);
  434.     Assert_(theBar != NULL);    
  435.  
  436.     Boolean bInHotSpot = ::PtInRgn(inPoint, theBar->mDockedMask);
  437.     return bInHotSpot;
  438. }
  439.  
  440. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  441. //    Ñ    
  442. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  443.  
  444. void CDragBarDockControl::HotSpotAction(
  445.     Int16                /* inHotSpot */,
  446.     Boolean             /* inCurrInside */,
  447.     Boolean                /* inPrevInside */)
  448. {
  449. }
  450.  
  451. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  452. //    Ñ    
  453. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  454.                                     
  455. void CDragBarDockControl::HotSpotResult(Int16 inHotSpot)
  456. {
  457.     CDragBar* theBar = NULL;
  458.     mBars.FetchItemAt(inHotSpot, &theBar);
  459.     Assert_(theBar != NULL);
  460.     
  461.     BroadcastMessage(msg_DragBarExpand, theBar);
  462. }
  463.  
  464.  
  465. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  466. //    Ñ    
  467. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  468.  
  469. void CDragBarDockControl::SavePlace(LStream *outPlace)
  470. {
  471.     *outPlace << mBars.GetCount();
  472.  
  473.     CDragBar* theBar;
  474.     LArrayIterator theIter(mBars, LArrayIterator::from_Start);
  475.     while (theIter.Next(&theBar))
  476.         *outPlace << theBar->GetPaneID();
  477. }
  478.  
  479. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  480. //    Ñ    
  481. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  482.  
  483. void CDragBarDockControl::RestorePlace(LStream *inPlace)
  484. {
  485.     Int32 theBarCount;
  486.     *inPlace >> theBarCount;
  487.     
  488.     for (Int32 theIndex = LArray::index_First; theIndex <= theBarCount; theIndex++)
  489.         {
  490.         PaneIDT theBarID;
  491.         *inPlace >> theBarID;
  492.         
  493.         CDragBar* theBar;
  494.         LArrayIterator theIter(mBars, LArrayIterator::from_Start);
  495.         while (theIter.Next(&theBar))
  496.             {
  497.             if (theBar->GetPaneID() == theBarID)
  498.                 mBars.MoveItem(theIter.GetCurrentIndex(), theIndex);                
  499.             }
  500.         }
  501. }
  502.  
  503. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  504. //    Ñ    
  505. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  506.  
  507. const CDragBar* CDragBarDockControl::FindBarSpot(
  508.     Point                 inLocalPoint)
  509. {
  510.     const CDragBar* theBar = NULL;
  511.     Int16 theHotSpot = FindHotSpot(inLocalPoint);
  512.     if (theHotSpot != 0)
  513.         mBars.FetchItemAt(theHotSpot, &theBar);
  514.  
  515.     return theBar;
  516. }
  517.