home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / mac / UserInterface / CBevelButton.cp < prev    next >
Encoding:
Text File  |  1998-04-08  |  4.7 KB  |  143 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. #ifdef PowerPlant_PCH
  20. #include PowerPlant_PCH
  21. #endif
  22.  
  23. #include <UGWorld.h>
  24. #include <UDrawingState.h>
  25. #include <UDrawingUtils.h>
  26. #include <UMemoryMgr.h>
  27. #include <UTextTraits.h>
  28. #include <LStream.h>
  29. #include "UGraphicGizmos.h"
  30. #include "CBevelButton.h"
  31.  
  32. #ifndef __ICONS__
  33. #include <Icons.h>
  34. #endif
  35.  
  36. #ifndef __PALETTES__
  37. #include <Palettes.h>
  38. #endif
  39.  
  40. #ifndef __TOOLUTILS__
  41. #include <ToolUtils.h>
  42. #endif
  43.  
  44. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  45. //    ÑÑÑ
  46. //    Ñ    Class CBevelButton
  47. //    ÑÑÑ    
  48. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  49.  
  50. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  51. //    Ñ    CBevelButton
  52. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  53.  
  54. CBevelButton::CBevelButton(LStream *inStream)
  55.     :    CButton(inStream)
  56. {
  57.     *inStream >> mBevel;
  58.     
  59.     ResIDT theBevelTraitsID;
  60.     *inStream >> theBevelTraitsID;
  61.     UGraphicGizmos::LoadBevelTraits(theBevelTraitsID, mUpColors);
  62.  
  63.     *inStream >> theBevelTraitsID;
  64.     UGraphicGizmos::LoadBevelTraits(theBevelTraitsID, mDownColors);
  65. }
  66.  
  67. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  68. //    Ñ    ~CBevelButton
  69. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  70.  
  71. CBevelButton::~CBevelButton()
  72. {
  73. }
  74.  
  75. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  76. //    Ñ    
  77. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  78.  
  79. void CBevelButton::DrawSelfDisabled(void)
  80. {
  81.     UGraphicGizmos::PaintDisabledRect(mCachedButtonFrame);
  82. }
  83.  
  84. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  85. //    Ñ    DrawButtonContent
  86. //
  87. //    Here we draw the button's frame and beveled area.  Subclasses should not
  88. //    need to override this method, nor call it directly.
  89. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  90.  
  91. void CBevelButton::DrawButtonContent(void)
  92. {
  93.     const SBevelColorDesc& theColors = (IsTrackInside() || GetValue() == Button_On) ? mDownColors : mUpColors;
  94.  
  95.     Rect tempButtonRect = mCachedButtonFrame;
  96.     ::PmForeColor(theColors.frameColor);
  97.     ::FrameRoundRect(&tempButtonRect, mOvalWidth, mOvalHeight);
  98.     ::InsetRect(&tempButtonRect, 1, 1);
  99.     ::PmForeColor(theColors.fillColor);
  100.     ::PaintRoundRect(&tempButtonRect, mOvalWidth, mOvalHeight);
  101.     
  102.     UGraphicGizmos::BevelRect(tempButtonRect, mBevel, theColors.topBevelColor, theColors.bottomBevelColor);
  103. }
  104.  
  105. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  106. //    ÑÑÑ
  107. //    Ñ    Class CDeluxeBevelButton
  108. //    ÑÑÑ    
  109. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  110.  
  111. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  112. //    Ñ    
  113. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  114.  
  115. CDeluxeBevelButton::CDeluxeBevelButton(LStream *inStream)
  116.     :    CBevelButton(inStream)
  117. {
  118. }
  119.  
  120. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  121. //    Ñ    
  122. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  123.  
  124. void CDeluxeBevelButton::DrawButtonContent(void)
  125. {
  126.     const SBevelColorDesc& theColors = (IsTrackInside() || GetValue() == Button_On) ? mDownColors : mUpColors;
  127.  
  128.     Rect tempButtonRect = mCachedButtonFrame;
  129.     ::PmForeColor(theColors.frameColor);
  130.     ::FrameRoundRect(&tempButtonRect, mOvalWidth, mOvalHeight);
  131.     ::InsetRect(&tempButtonRect, 1, 1);
  132.     ::PmForeColor(theColors.fillColor);
  133.     ::PaintRoundRect(&tempButtonRect, mOvalWidth, mOvalHeight);
  134.     
  135.     Int16 theShiftedTopColor = (theColors.topBevelColor > eStdGray93) ? theColors.topBevelColor - 1 : eStdGrayWhite;
  136.  
  137.     UGraphicGizmos::BevelRect(tempButtonRect, mBevel, theColors.topBevelColor, theColors.bottomBevelColor);
  138.     ::InsetRect(&tempButtonRect, 1, 1);
  139.     UGraphicGizmos::BevelRect(tempButtonRect, mBevel, theShiftedTopColor, theColors.bottomBevelColor - 1);
  140. }
  141.  
  142.  
  143.