home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / gui / CPatternedGrippyPane.cp < prev    next >
Encoding:
Text File  |  1998-04-08  |  4.4 KB  |  147 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. // CPatternedGrippyPane.cp
  21. //
  22. // Implementation for class that draws a "grippy" pattern in the pane rectangle so users know
  23. // they can drag/click in this area. Also hilights when mouse enters (roll-over feedback).
  24. //
  25. // I didn't actually write this class, just moved it out of DragBar.h.
  26. // 
  27.  
  28.  
  29. #include "CPatternedGrippyPane.h"
  30. #include "CSharedPatternWorld.h"
  31. #include "UGraphicGizmos.h"
  32.  
  33.  
  34. CPatternedGrippyPane::CPatternedGrippyPane(LStream* inStream)
  35.     :    LPane(inStream)
  36. {
  37.     ResIDT theBackgroundID;    
  38.     *inStream >> theBackgroundID;
  39.     ResIDT theBackgroundHiliteID;    
  40.     *inStream >> theBackgroundHiliteID;
  41.     
  42.     ResIDT theGrippyID;
  43.     *inStream >> theGrippyID;
  44.     Int16 theGrippyHiliteID;
  45.     *inStream >> theGrippyHiliteID;
  46.     
  47.     ResIDT theTriangleID;
  48.     *inStream >> theTriangleID;
  49.     
  50.     mBackPattern = CSharedPatternWorld::CreateSharedPatternWorld(theBackgroundID);
  51.     ThrowIfNULL_(mBackPattern);
  52.     mBackPattern->AddUser(this);
  53.     mBackPatternHilite = CSharedPatternWorld::CreateSharedPatternWorld(theBackgroundHiliteID);
  54.     ThrowIfNULL_(mBackPatternHilite);
  55.     mBackPatternHilite->AddUser(this);
  56.  
  57.     mGrippy = CSharedPatternWorld::CreateSharedPatternWorld(theGrippyID);
  58.     ThrowIfNULL_(mGrippy);
  59.     mGrippy->AddUser(this);
  60.     mGrippyHilite = CSharedPatternWorld::CreateSharedPatternWorld(theGrippyHiliteID);
  61.     ThrowIfNULL_(mGrippyHilite);
  62.     mGrippyHilite->AddUser(this);
  63.  
  64.     mTriangle = ::GetCIcon(theTriangleID);
  65.     ThrowIfNULL_(mTriangle);
  66.  
  67.     mMouseInside = false;
  68. }
  69.  
  70. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  71. //    Ñ    
  72. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  73.  
  74. CPatternedGrippyPane::~CPatternedGrippyPane()
  75. {
  76.     mGrippy->RemoveUser(this);
  77.     mGrippyHilite->RemoveUser(this);
  78.     mBackPattern->RemoveUser(this);
  79.     mBackPatternHilite->RemoveUser(this);
  80.     ::DisposeCIcon(mTriangle);
  81. }
  82.  
  83. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  84. //    Ñ    
  85. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  86.  
  87. void CPatternedGrippyPane::DrawSelf(void)
  88. {
  89.     Rect theFrame;
  90.     CalcLocalFrameRect(theFrame);
  91.     StClipRgnState theClipSaver(theFrame);
  92.  
  93.     Point theAlignment;
  94.     CSharedPatternWorld::CalcRelativePoint(this, CSharedPatternWorld::eOrientation_Self, theAlignment);
  95.  
  96.         // We do this instead of LPane::GetMacPort()
  97.         // because we may be being drawn offscreen.
  98.     CGrafPtr thePort;
  99.     ::GetPort(&(GrafPtr)thePort);
  100.     if ( mMouseInside )
  101.         mBackPatternHilite->Fill(thePort, theFrame, theAlignment);
  102.     else
  103.         mBackPattern->Fill(thePort, theFrame, theAlignment);
  104.     
  105.     UGraphicGizmos::BevelTintRect(theFrame, 1, 0x4000, 0x4000);
  106.  
  107.     Rect theTriangleFrame = (**mTriangle).iconPMap.bounds;
  108.     Rect theTriangleDest = theFrame;
  109.     theTriangleDest.bottom = theTriangleDest.top + RectWidth(theFrame);
  110.     
  111.     UGraphicGizmos::CenterRectOnRect(theTriangleFrame, theTriangleDest);
  112.     ::PlotCIcon(&theTriangleFrame, mTriangle);
  113.  
  114.     Rect thePatternDest = theFrame;
  115.     ::InsetRect(&thePatternDest, 2, 2);
  116.     thePatternDest.top = theTriangleDest.bottom - 1;    
  117.     ::ClipRect(&thePatternDest);
  118.      
  119.      // hack to make it look centered for both drag bars and expand/collapse widget
  120.      if ( thePatternDest.right - thePatternDest.left > 5 )
  121.          theAlignment.h++;
  122.      
  123.     if ( mMouseInside )
  124.         mGrippyHilite->Fill(thePort, thePatternDest, theAlignment);
  125.     else
  126.         mGrippy->Fill(thePort, thePatternDest, theAlignment);
  127.         
  128. //    UGraphicGizmos::DrawArithPattern(theFrame, mBottomShadePat, 0x6000, false);
  129. }
  130.  
  131.  
  132. void 
  133. CPatternedGrippyPane :: MouseEnter ( Point /* inPoint */, const EventRecord & /* inEvent */ ) 
  134. {
  135.     mMouseInside = true;
  136.     Refresh();
  137. }
  138.  
  139. void 
  140. CPatternedGrippyPane :: MouseLeave ( )
  141. {
  142.     mMouseInside = false;
  143.     Refresh();
  144. }
  145.  
  146.  
  147.