home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / mac / UserInterface / UGraphicGizmos.cp < prev    next >
Encoding:
Text File  |  1998-04-08  |  38.5 KB  |  1,448 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 <UMemoryMgr.h>
  24. #include <UDrawingState.h>
  25. #include <UDrawingUtils.h>
  26. #include <UGAColorRamp.h>
  27.  
  28. #include "UGraphicGizmos.h"
  29. #include "CGWorld.h"
  30.  
  31. #include "mfinder.h" // needed for workaround function to bug in Appe's
  32.                      // ::TruncText and ::TruncString - andrewb 6/20/97
  33.  
  34. #ifndef __PALETTES__
  35. #include <Palettes.h>
  36. #endif
  37.  
  38. #include <string.h>
  39.  
  40. RGBColor UGraphicGizmos::sLighter = { 0xFFFF, 0xFFFF, 0xFFFF };
  41. RGBColor UGraphicGizmos::sDarker = { 0x0000, 0x0000, 0x0000 };
  42.  
  43. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  44. //    Ñ    LoadBevelTraits
  45. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  46.  
  47. void UGraphicGizmos::LoadBevelTraits(
  48.     ResIDT                 inBevelTraitsID,
  49.     SBevelColorDesc&     outBevelDesc)
  50. {
  51.     Assert_(inBevelTraitsID != resID_Undefined);
  52.     
  53.     StResource theBevelResource('BvTr', inBevelTraitsID);
  54.     ::BlockMoveData(*(theBevelResource.mResourceH), &outBevelDesc, sizeof(SBevelColorDesc));
  55. }
  56.  
  57. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  58. //    Ñ    BevelRect
  59. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  60.  
  61. void UGraphicGizmos::BevelRect(
  62.     const Rect&        inRect,
  63.     Int16             inBevel,
  64.     Int16             inTopColor,
  65.     Int16            inBottomColor)
  66. {
  67.     StColorPenState thePenSaver;
  68.     thePenSaver.Normalize();
  69.  
  70.     Rect theBevelRect = inRect;
  71.     theBevelRect.bottom--;
  72.     theBevelRect.right--;
  73.  
  74.     StDeviceLoop theLoop(inRect);
  75.     Int16 theDepth;
  76.     while (theLoop.NextDepth(theDepth))
  77.         {
  78.         if (theDepth < 4)
  79.             {
  80.             // Draw a monochrome bevel
  81.             QDGlobals* theQDPtr = UQDGlobals::GetQDGlobals();
  82.             PatPtr theTopPat, theBottomPat;
  83.     
  84.             if (inBevel < 0)
  85.                 {
  86.                 inBevel = -inBevel;
  87.                 theTopPat = &theQDPtr->black;
  88.                 theBottomPat = &theQDPtr->white;
  89.                 }
  90.             else
  91.                 {
  92.                 theTopPat = &theQDPtr->white;
  93.                 theBottomPat = &theQDPtr->black;
  94.                 }
  95.     
  96.             for (Int16 index = 1; index <= inBevel; index++)
  97.                 {
  98.                 ::PenPat(theTopPat);
  99.                 ::MoveTo(theBevelRect.right, theBevelRect.top);
  100.                 ::LineTo(theBevelRect.left, theBevelRect.top);
  101.                 // 1997-03-24 pkc
  102.                 // Don't draw topleft corner twice
  103.                 ::Move(0, 1);
  104.                 ::LineTo(theBevelRect.left, theBevelRect.bottom);
  105.                 
  106.                 ::PenPat(theBottomPat);
  107.                 ::LineTo(theBevelRect.right, theBevelRect.bottom);
  108.                 // 1997-03-24 pkc
  109.                 // Don't draw bottomright corner twice
  110.                 ::Move(0, -1);
  111.                 ::LineTo(theBevelRect.right, theBevelRect.top);
  112.         
  113.                 ::InsetRect(&theBevelRect, 1, 1);
  114.                 }
  115.             }
  116.         else
  117.             {
  118.             // Draw a color bevel
  119.             Int16 theTopColor, theBottomColor;
  120.     
  121.             if (inBevel < 0)
  122.                 {
  123.                 inBevel = -inBevel;
  124.                 theTopColor = inBottomColor;
  125.                 theBottomColor = inTopColor;
  126.                 }
  127.             else
  128.                 {
  129.                 theTopColor = inTopColor;
  130.                 theBottomColor = inBottomColor;
  131.                 }
  132.  
  133.             for (Int16 index = 1; index <= inBevel; index++)
  134.                 {
  135.                 ::PmForeColor(theTopColor);
  136.                 ::MoveTo(theBevelRect.right, theBevelRect.top);
  137.                 ::LineTo(theBevelRect.left, theBevelRect.top);
  138.                 // 1997-03-24 pkc
  139.                 // Don't draw topleft corner twice
  140.                 ::Move(0, 1);
  141.                 ::LineTo(theBevelRect.left, theBevelRect.bottom);
  142.                 
  143.                 ::PmForeColor(theBottomColor);
  144.                 ::LineTo(theBevelRect.right, theBevelRect.bottom);
  145.                 // 1997-03-24 pkc
  146.                 // Don't draw bottomright corner twice
  147.                 ::Move(0, -1);
  148.                 ::LineTo(theBevelRect.right, theBevelRect.top);
  149.                 
  150.                 ::InsetRect(&theBevelRect, 1, 1);
  151.                 }
  152.             }
  153.         }
  154. }
  155.  
  156. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  157. //    Ñ    BevelPartialRect
  158. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  159.  
  160. void UGraphicGizmos::BevelPartialRect(
  161.     const Rect&            inRect,
  162.     Int16                 inBevel,
  163.     Int16                 inTopColor,
  164.     Int16                inBottomColor,
  165.     const SBooleanRect&    inSides)
  166. {
  167.     StColorPenState thePenSaver;
  168.     thePenSaver.Normalize();
  169.  
  170.     Rect theBevelRect = inRect;
  171.     theBevelRect.bottom--;
  172.     theBevelRect.right--;
  173.  
  174.     for (Int16 index = 1; index <= inBevel; index++)
  175.         {
  176.         ::PmForeColor(inTopColor);
  177.         if (inSides.left)
  178.             {
  179.             // 1997-03-24 pkc
  180.             // Don't draw topleft corner twice
  181.             if (inSides.top)
  182.                 ::MoveTo(theBevelRect.left, theBevelRect.top + 1);
  183.             else
  184.                 ::MoveTo(theBevelRect.left, theBevelRect.top);
  185.             ::LineTo(theBevelRect.left, theBevelRect.bottom);
  186.             }
  187.             
  188.         if (inSides.top)
  189.             {
  190.             ::MoveTo(theBevelRect.right, theBevelRect.top);
  191.             ::LineTo(theBevelRect.left, theBevelRect.top);
  192.             }
  193.  
  194.         ::PmForeColor(inBottomColor);
  195.         if (inSides.right)
  196.             {
  197.             ::MoveTo(theBevelRect.right, theBevelRect.top);
  198.             // 1997-03-24 pkc
  199.             // Don't draw bottomright corner twice
  200.             if (inSides.bottom)
  201.                 ::LineTo(theBevelRect.right, theBevelRect.bottom - 1);
  202.             else
  203.                 ::LineTo(theBevelRect.right, theBevelRect.bottom);
  204.             }
  205.             
  206.         if (inSides.bottom)
  207.             {
  208.             ::MoveTo(theBevelRect.left, theBevelRect.bottom);
  209.             ::LineTo(theBevelRect.right, theBevelRect.bottom);
  210.             }
  211.         
  212.         ::InsetRect(&theBevelRect, 1, 1);
  213.         }
  214. }
  215.  
  216. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  217. //    Ñ    BevelRect
  218. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  219.  
  220. void UGraphicGizmos::BevelRect(
  221.     const Rect&        inRect,
  222.     Int16             inBevel,
  223.     const RGBColor&    inTopColor,
  224.     const RGBColor&    inBottomColor)
  225. {
  226.     StColorPenState thePenSaver;
  227.     thePenSaver.Normalize();
  228.  
  229.     Rect theBevelRect = inRect;
  230.     theBevelRect.bottom--;
  231.     theBevelRect.right--;
  232.  
  233.     StDeviceLoop theLoop(inRect);
  234.     Int16 theDepth;
  235.     while (theLoop.NextDepth(theDepth))
  236.         {
  237.         if (theDepth < 4)
  238.             {
  239.             // Draw a monochrome bevel
  240.             QDGlobals* theQDPtr = UQDGlobals::GetQDGlobals();
  241.             PatPtr theTopPat, theBottomPat;
  242.     
  243.             if (inBevel < 0)
  244.                 {
  245.                 inBevel = -inBevel;
  246.                 theTopPat = &theQDPtr->black;
  247.                 theBottomPat = &theQDPtr->white;
  248.                 }
  249.             else
  250.                 {
  251.                 theTopPat = &theQDPtr->white;
  252.                 theBottomPat = &theQDPtr->black;
  253.                 }
  254.     
  255.             for (Int16 index = 1; index <= inBevel; index++)
  256.                 {
  257.                 ::PenPat(theTopPat);
  258.                 ::MoveTo(theBevelRect.right, theBevelRect.top);
  259.                 ::LineTo(theBevelRect.left, theBevelRect.top);
  260.                 // 1997-03-24 pkc
  261.                 // Don't draw topleft corner twice
  262.                 ::Move(0, 1);
  263.                 ::LineTo(theBevelRect.left, theBevelRect.bottom);
  264.                 
  265.                 ::PenPat(theBottomPat);
  266.                 ::LineTo(theBevelRect.right, theBevelRect.bottom);
  267.                 // 1997-03-24 pkc
  268.                 // Don't draw bottomright corner twice
  269.                 ::Move(0, -1);
  270.                 ::LineTo(theBevelRect.right, theBevelRect.top);
  271.         
  272.                 ::InsetRect(&theBevelRect, 1, 1);
  273.                 }
  274.             }
  275.         else
  276.             {
  277.             // Draw a color bevel
  278.             RGBColor theTopColor, theBottomColor;
  279.     
  280.             if (inBevel < 0)
  281.                 {
  282.                 inBevel = -inBevel;
  283.                 theTopColor = inBottomColor;
  284.                 theBottomColor = inTopColor;
  285.                 }
  286.             else
  287.                 {
  288.                 theTopColor = inTopColor;
  289.                 theBottomColor = inBottomColor;
  290.                 }
  291.  
  292.             for (Int16 index = 1; index <= inBevel; index++)
  293.                 {
  294.                 ::RGBForeColor(&theTopColor);
  295.                 ::MoveTo(theBevelRect.right, theBevelRect.top);
  296.                 ::LineTo(theBevelRect.left, theBevelRect.top);
  297.                 // 1997-03-24 pkc
  298.                 // Don't draw topleft corner twice
  299.                 ::Move(0, 1);
  300.                 ::LineTo(theBevelRect.left, theBevelRect.bottom);
  301.                 
  302.                 ::RGBForeColor(&theBottomColor);
  303.                 ::LineTo(theBevelRect.right, theBevelRect.bottom);
  304.                 // 1997-03-24 pkc
  305.                 // Don't draw bottomright corner twice
  306.                 ::Move(0, -1);
  307.                 ::LineTo(theBevelRect.right, theBevelRect.top);
  308.                 
  309.                 ::InsetRect(&theBevelRect, 1, 1);
  310.                 }
  311.             }
  312.         }
  313. }
  314.  
  315. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  316. //    Ñ    BevelRectAGA
  317. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  318.  
  319. void UGraphicGizmos::BevelRectAGA(
  320.     const Rect&        inRect,
  321.     Int16             inBevel,
  322.     const RGBColor&    inTopColor,
  323.     const RGBColor&    inBottomColor)
  324. {
  325.     StColorPenState thePenSaver;
  326.     thePenSaver.Normalize();
  327.  
  328.     Rect theBevelRect = inRect;
  329.     theBevelRect.bottom--;
  330.     theBevelRect.right--;
  331.  
  332.     StDeviceLoop theLoop(inRect);
  333.     Int16 theDepth;
  334.     while (theLoop.NextDepth(theDepth))
  335.         {
  336.         if (theDepth < 4)
  337.             {
  338.             // Draw a monochrome bevel
  339.             QDGlobals* theQDPtr = UQDGlobals::GetQDGlobals();
  340.             PatPtr theTopPat, theBottomPat;
  341.     
  342.             if (inBevel < 0)
  343.                 {
  344.                 inBevel = -inBevel;
  345.                 theTopPat = &theQDPtr->black;
  346.                 theBottomPat = &theQDPtr->white;
  347.                 }
  348.             else
  349.                 {
  350.                 theTopPat = &theQDPtr->white;
  351.                 theBottomPat = &theQDPtr->black;
  352.                 }
  353.     
  354.             for (Int16 index = 1; index <= inBevel; index++)
  355.                 {
  356.                 ::PenPat(theTopPat);
  357.                 ::MoveTo(theBevelRect.right - 1, theBevelRect.top);
  358.                 ::LineTo(theBevelRect.left, theBevelRect.top);
  359.                 // 1997-03-24 pkc
  360.                 // Don't draw topleft corner twice
  361.                 ::Move(0, 1);
  362.                 ::LineTo(theBevelRect.left, theBevelRect.bottom - 1);
  363.                 
  364.                 ::PenPat(theBottomPat);
  365.                 ::MoveTo(theBevelRect.left + 1, theBevelRect.bottom);
  366.                 ::LineTo(theBevelRect.right, theBevelRect.bottom);
  367.                 // 1997-03-24 pkc
  368.                 // Don't draw bottomright corner twice
  369.                 ::Move(0, -1);
  370.                 ::LineTo(theBevelRect.right, theBevelRect.top + 1);
  371.         
  372.                 ::InsetRect(&theBevelRect, 1, 1);
  373.                 }
  374.             }
  375.         else
  376.             {
  377.             // Draw a color bevel
  378.             RGBColor theTopColor, theBottomColor;
  379.     
  380.             if (inBevel < 0)
  381.                 {
  382.                 inBevel = -inBevel;
  383.                 theTopColor = inBottomColor;
  384.                 theBottomColor = inTopColor;
  385.                 }
  386.             else
  387.                 {
  388.                 theTopColor = inTopColor;
  389.                 theBottomColor = inBottomColor;
  390.                 }
  391.  
  392.             for (Int16 index = 1; index <= inBevel; index++)
  393.                 {
  394.                 ::RGBForeColor(&theTopColor);
  395.                 ::MoveTo(theBevelRect.right - 1, theBevelRect.top);
  396.                 ::LineTo(theBevelRect.left, theBevelRect.top);
  397.                 // 1997-03-24 pkc
  398.                 // Don't draw topleft corner twice
  399.                 ::Move(0, 1);
  400.                 ::LineTo(theBevelRect.left, theBevelRect.bottom - 1);
  401.                 
  402.                 ::RGBForeColor(&theBottomColor);
  403.                 ::MoveTo(theBevelRect.left + 1, theBevelRect.bottom);
  404.                 ::LineTo(theBevelRect.right, theBevelRect.bottom);
  405.                 // 1997-03-24 pkc
  406.                 // Don't draw bottomright corner twice
  407.                 ::Move(0, -1);
  408.                 ::LineTo(theBevelRect.right, theBevelRect.top + 1);
  409.                 
  410.                 ::InsetRect(&theBevelRect, 1, 1);
  411.                 }
  412.             }
  413.         }
  414. }
  415.  
  416. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  417. //    Ñ    BevelPartialRect
  418. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  419.  
  420. void UGraphicGizmos::BevelPartialRect(
  421.     const Rect&            inRect,
  422.     Int16                 inBevel,
  423.     const RGBColor&        inTopColor,
  424.     const RGBColor&        inBottomColor,
  425.     const SBooleanRect&    inSides)
  426. {
  427.     StColorPenState thePenSaver;
  428.     thePenSaver.Normalize();
  429.  
  430.     Rect theBevelRect = inRect;
  431.     theBevelRect.bottom--;
  432.     theBevelRect.right--;
  433.  
  434.     for (Int16 index = 1; index <= inBevel; index++)
  435.         {
  436.         ::RGBForeColor(&inTopColor);
  437.         if (inSides.left)
  438.             {
  439.             // 1997-03-24 pkc
  440.             // Don't draw topleft corner twice
  441.             if (inSides.top)
  442.                 ::MoveTo(theBevelRect.left, theBevelRect.top + 1);
  443.             else
  444.                 ::MoveTo(theBevelRect.left, theBevelRect.top);
  445.             ::LineTo(theBevelRect.left, theBevelRect.bottom);
  446.             }
  447.             
  448.         if (inSides.top)
  449.             {
  450.             ::MoveTo(theBevelRect.right, theBevelRect.top);
  451.             ::LineTo(theBevelRect.left, theBevelRect.top);
  452.             }
  453.  
  454.         ::RGBForeColor(&inBottomColor);
  455.         if (inSides.right)
  456.             {
  457.             ::MoveTo(theBevelRect.right, theBevelRect.top);
  458.             // 1997-03-24 pkc
  459.             // Don't draw bottomright corner twice
  460.             if (inSides.bottom)
  461.                 ::LineTo(theBevelRect.right, theBevelRect.bottom - 1);
  462.             else
  463.                 ::LineTo(theBevelRect.right, theBevelRect.bottom);
  464.             }
  465.             
  466.         if (inSides.bottom)
  467.             {
  468.             ::MoveTo(theBevelRect.left, theBevelRect.bottom);
  469.             ::LineTo(theBevelRect.right, theBevelRect.bottom);
  470.             }
  471.         
  472.         ::InsetRect(&theBevelRect, 1, 1);
  473.         }
  474. }
  475.  
  476. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  477. //    Ñ    BevelTintPartialRect
  478. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  479.  
  480. void UGraphicGizmos::BevelTintPartialRect(
  481.     const Rect &    inRect,
  482.     Int16             inBevel,
  483.     Uint16            inTopTint,
  484.     Uint16            inBottomTint,
  485.     const SBooleanRect& inSides)
  486. {
  487.     StColorPenState thePenSaver;
  488.     thePenSaver.Normalize();
  489.  
  490.     RGBColor theAddColor = { inTopTint, inTopTint, inTopTint };
  491.     RGBColor theSubColor = { inBottomTint, inBottomTint, inBottomTint };
  492.  
  493.     Rect theBevelRect = inRect;
  494.     theBevelRect.bottom--;
  495.     theBevelRect.right--;
  496.  
  497.     if (inBevel >= 0)
  498.         {
  499.         ::RGBForeColor(&theAddColor);
  500.         ::OpColor(&sLighter);
  501.         ::PenMode(addPin);
  502.         }
  503.     else
  504.         {
  505.         ::RGBForeColor(&theSubColor);
  506.         ::OpColor(&sDarker);
  507.         ::PenMode(subPin);
  508.         }
  509.  
  510.     Int16 theBevel = (inBevel >= 0) ? inBevel : -inBevel;
  511.     for (Int16 index = 1; index <= theBevel; index++)
  512.         {
  513.         if (inSides.top)
  514.             {
  515.             ::MoveTo(theBevelRect.right, theBevelRect.top);
  516.             ::LineTo(theBevelRect.left, theBevelRect.top);
  517.             }
  518.         if (inSides.left)
  519.             {
  520.             // 1997-03-24 pkc
  521.             // Don't draw topleft corner twice
  522.             if (inSides.top)
  523.                 ::MoveTo(theBevelRect.left, theBevelRect.top + 1);
  524.             else
  525.                 ::MoveTo(theBevelRect.left, theBevelRect.top);
  526.             ::LineTo(theBevelRect.left, theBevelRect.bottom);
  527.             }
  528.         if (inSides.top)
  529.             theBevelRect.top++;
  530.         if (inSides.left)
  531.             theBevelRect.left++;
  532.         if (inSides.bottom)
  533.             theBevelRect.bottom--;
  534.         if (inSides.right)
  535.             theBevelRect.right--;
  536.         }
  537.         
  538.     theBevelRect = inRect;
  539.     theBevelRect.bottom--;
  540.     theBevelRect.right--;
  541.  
  542.     if (inBevel >= 0)
  543.         {
  544.         ::RGBForeColor(&theSubColor);
  545.         ::OpColor(&sDarker);
  546.         ::PenMode(subPin);
  547.         }
  548.     else
  549.         {
  550.         ::RGBForeColor(&theAddColor);
  551.         ::OpColor(&sLighter);
  552.         ::PenMode(addPin);
  553.         }
  554.  
  555.     theBevel = (inBevel >= 0) ? inBevel : -inBevel;
  556.     for (Int16 index = 1; index <= theBevel; index++)
  557.         {
  558.         if (inSides.bottom)
  559.             {
  560.             ::MoveTo(theBevelRect.left, theBevelRect.bottom);
  561.             ::LineTo(theBevelRect.right, theBevelRect.bottom);
  562.             }
  563.         if (inSides.right)
  564.             {
  565.             // 1997-03-24 pkc
  566.             // Don't draw bottomright corner twice
  567.             if (inSides.bottom)
  568.                 ::MoveTo(theBevelRect.right, theBevelRect.bottom - 1);
  569.             else
  570.                 ::MoveTo(theBevelRect.right, theBevelRect.bottom);
  571.             ::LineTo(theBevelRect.right, theBevelRect.top);
  572.             }
  573.         if (inSides.top)
  574.             theBevelRect.top++;
  575.         if (inSides.left)
  576.             theBevelRect.left++;
  577.         if (inSides.bottom)
  578.             theBevelRect.bottom--;
  579.         if (inSides.right)
  580.             theBevelRect.right--;
  581.         }
  582. }
  583.  
  584. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  585. //    Ñ    BevelTintRect
  586. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  587.  
  588. void UGraphicGizmos::BevelTintRect(
  589.     const Rect &    inRect,
  590.     Int16             inBevel,
  591.     Uint16            inTopTint,
  592.     Uint16            inBottomTint)
  593. {
  594.     SBooleanRect sides = { true, true, true, true };
  595.     BevelTintPartialRect(inRect, inBevel, inTopTint, inBottomTint, sides);
  596. }
  597.  
  598. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  599. //    Ñ    BevelTintRoundRect
  600. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  601.  
  602. void UGraphicGizmos::BevelTintRoundRect(
  603.     const Rect&        inRect,
  604.     Int16            inOvalWidth,
  605.     Int16            inOvalHeight,
  606.     Uint16            inTint,
  607.     Boolean            inLighten)
  608. {
  609.     StColorPenState thePenSaver;
  610.     thePenSaver.Normalize();
  611.     
  612.     Rect rect = inRect;
  613.     
  614.     RGBColor theTintColor = { inTint, inTint, inTint };
  615.  
  616.     ::RGBForeColor(&theTintColor);
  617.  
  618.     if (inLighten)
  619.         {
  620.         ::OpColor(&sLighter);
  621.         ::PenMode(addPin);
  622.         }
  623.     else
  624.         {
  625.         ::OpColor(&sDarker);
  626.         ::PenMode(subPin);
  627.         }
  628.     
  629.     ::FrameRoundRect(&rect, inOvalWidth, inOvalHeight);
  630. }
  631.  
  632.  
  633. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  634. //    Ñ    BevelTintLine
  635. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  636.  
  637. void UGraphicGizmos::BevelTintLine(
  638.     Int16            inStartX,
  639.     Int16            inStartY,
  640.     Int16            inEndX,
  641.     Int16            inEndY,
  642.     Uint16            inTint,
  643.     Boolean            inLighten)
  644. {
  645.     StColorPenState thePenSaver;
  646.     thePenSaver.Normalize();
  647.  
  648.     RGBColor theTintColor = { inTint, inTint, inTint };
  649.     
  650.     ::RGBForeColor(&theTintColor);
  651.  
  652.     if (inLighten)
  653.         {
  654.         ::OpColor(&sLighter);
  655.         ::PenMode(addPin);
  656.         }
  657.     else
  658.         {
  659.         ::OpColor(&sDarker);
  660.         ::PenMode(subPin);
  661.         }
  662.     
  663.     ::MoveTo(inStartX, inStartY);
  664.     ::LineTo(inEndX, inEndY);
  665. }
  666.  
  667. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  668. //    Ñ    BevelTintPixel
  669. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  670. void UGraphicGizmos::BevelTintPixel(
  671.     Int16            inX,
  672.     Int16            inY,
  673.     Uint16            inTint,
  674.     Boolean            inLighten)
  675. {
  676.     BevelTintLine(inX, inY, inX, inY, inTint, inLighten);
  677. }
  678.  
  679. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  680. //    Ñ    RaiseColorVolume
  681. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  682.  
  683. void UGraphicGizmos::RaiseColorVolume(
  684.     const Rect&        inRect,
  685.     Uint16            inTint)
  686. {
  687.     StColorPenState        theSavedState;
  688.     theSavedState.Normalize();
  689.  
  690.     RGBColor theAddColor = { inTint, inTint, inTint };
  691.     ::RGBForeColor(&theAddColor);
  692.     ::OpColor(&sLighter);
  693.     ::PenMode(addPin);
  694.     ::PaintRect(&inRect);
  695. }
  696.  
  697. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  698. //    Ñ    LowerColorVolume
  699. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  700.  
  701. void UGraphicGizmos::LowerColorVolume(
  702.     const Rect&        inRect,
  703.     Uint16            inTint)
  704. {
  705.     StColorPenState        theSavedState;
  706.     theSavedState.Normalize();
  707.  
  708.     RGBColor theSubColor = { inTint, inTint, inTint };
  709.     ::RGBForeColor(&theSubColor);
  710.     ::OpColor(&sDarker);
  711.     ::PenMode(subPin);
  712.     ::PaintRect(&inRect);
  713. }
  714.  
  715.  
  716. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  717. //    Ñ    LowerRoundRectColorVolume
  718. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  719.  
  720. void UGraphicGizmos::LowerRoundRectColorVolume(
  721.     const Rect&        inRect,
  722.     Int16            inOvalWidth,
  723.     Int16            inOvalHeight,
  724.     Uint16            inTint)
  725. {
  726.     StColorPenState        theSavedState;
  727.     theSavedState.Normalize();
  728.  
  729.     RGBColor theSubColor = { inTint, inTint, inTint };
  730.     ::RGBForeColor(&theSubColor);
  731.     ::OpColor(&sDarker);
  732.     ::PenMode(subPin);
  733.     ::PaintRoundRect(&inRect, inOvalWidth, inOvalHeight);
  734. }
  735.  
  736.  
  737. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  738. //    Ñ    PaintDisabledRect
  739. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  740.  
  741. void UGraphicGizmos::PaintDisabledRect(
  742.     const Rect&        inRect,
  743.     Uint16            inTint,
  744.     Boolean            inMakeLighter)
  745. {
  746.     StColorPenState        theSavedState;
  747.     theSavedState.Normalize();
  748.     
  749.     RGBColor theOpColor;
  750.     theOpColor.red = theOpColor.blue = theOpColor.green = inTint;
  751.     
  752.     RGBColor theNewColor;
  753.     if (inMakeLighter) 
  754.         theNewColor.red = theNewColor.blue = theNewColor.green = 0xFFFF;
  755.     else 
  756.         theNewColor.red = theNewColor.blue = theNewColor.green = 0x0000;
  757.     
  758.     ::OpColor(&theOpColor);
  759.     ::RGBForeColor(&theNewColor);
  760.     ::PenMode(blend);
  761.     ::PenPat(&qd.black);
  762.     ::PaintRect(&inRect);
  763. }
  764.  
  765. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  766. //    Ñ    CenterRectOnRect
  767. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  768.  
  769. void UGraphicGizmos::CenterRectOnRect(
  770.     Rect            &inRect,
  771.     const Rect        &inOnRect)
  772. {
  773.     Int16 theRectHeight = RectHeight(inRect);
  774.     Int16 theRectWidth = RectWidth(inRect);
  775.                 
  776.     inRect.top = inOnRect.top + ((RectHeight(inOnRect) - theRectHeight) / 2);
  777.     inRect.bottom = inRect.top + theRectHeight;
  778.     inRect.left = inOnRect.left + ((RectWidth(inOnRect) - theRectWidth) / 2);
  779.     inRect.right = inRect.left + theRectWidth;
  780. }
  781.  
  782. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  783. //    Ñ    AlignRectOnRect
  784. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  785.  
  786. void UGraphicGizmos::AlignRectOnRect(
  787.     Rect&            inRect,
  788.     const Rect&        inOnRect,
  789.     Uint16            inAlignment)
  790. {
  791.     Int16 theRectHeight = RectHeight(inRect);
  792.     Int16 theRectWidth = RectWidth(inRect);
  793.  
  794.     switch (inAlignment)
  795.         {
  796.         case kAlignVerticalCenter:
  797.             inRect.top = inOnRect.top + ((RectHeight(inOnRect) - theRectHeight) / 2);
  798.             inRect.bottom = inRect.top + theRectHeight;
  799.             break;
  800.             
  801.         case kAlignTop:
  802.             inRect.top = inOnRect.top;
  803.             inRect.bottom = inRect.top + theRectHeight;
  804.             break;
  805.             
  806.         case kAlignBottom:
  807.             inRect.bottom = inOnRect.bottom;
  808.             inRect.top = inRect.bottom - theRectHeight;
  809.             break;
  810.             
  811.         case kAlignHorizontalCenter:
  812.             inRect.left = inOnRect.left + ((RectWidth(inOnRect) - theRectWidth) / 2);
  813.             inRect.right = inRect.left + theRectWidth;
  814.             break;
  815.             
  816.         case kAlignAbsoluteCenter:
  817.             UGraphicGizmos::CenterRectOnRect(inRect, inOnRect);
  818.             break;
  819.             
  820.         case kAlignCenterTop:
  821.             inRect.left = inOnRect.left + ((RectWidth(inOnRect) - theRectWidth) / 2);
  822.             inRect.right = inRect.left + theRectWidth;
  823.             inRect.top = inOnRect.top;
  824.             inRect.bottom = inRect.top + theRectHeight;
  825.             break;
  826.             
  827.         case kAlignCenterBottom:
  828.             inRect.left = inOnRect.left + ((RectWidth(inOnRect) - theRectWidth) / 2);
  829.             inRect.right = inRect.left + theRectWidth;
  830.             inRect.bottom = inOnRect.bottom;
  831.             inRect.top = inRect.bottom - theRectHeight;
  832.             break;
  833.             
  834.         case kAlignLeft:
  835.             inRect.left = inOnRect.left;
  836.             inRect.right = inRect.left + theRectWidth;
  837.             break;
  838.             
  839.         case kAlignCenterLeft:
  840.             inRect.top = inOnRect.top + ((RectHeight(inOnRect) - theRectHeight) / 2);
  841.             inRect.bottom = inRect.top + theRectHeight;
  842.             inRect.left = inOnRect.left;
  843.             inRect.right = inRect.left + theRectWidth;
  844.             break;
  845.             
  846.         case kAlignTopLeft:
  847.             inRect.top = inOnRect.top;
  848.             inRect.bottom = inRect.top + theRectHeight;
  849.             inRect.left = inOnRect.left;
  850.             inRect.right = inRect.left + theRectWidth;
  851.             break;
  852.             
  853.         case kAlignBottomLeft:
  854.             inRect.bottom = inOnRect.bottom;
  855.             inRect.top = inRect.bottom - theRectHeight;
  856.             inRect.left = inOnRect.left;
  857.             inRect.right = inRect.left + theRectWidth;
  858.             break;
  859.             
  860.         case kAlignRight:
  861.             inRect.right = inOnRect.right;
  862.             inRect.left = inRect.right - theRectWidth;
  863.             break;
  864.             
  865.         case kAlignCenterRight:
  866.             inRect.top = inOnRect.top + ((RectHeight(inOnRect) - theRectHeight) / 2);
  867.             inRect.bottom = inRect.top + theRectHeight;
  868.             inRect.right = inOnRect.right;
  869.             inRect.left = inRect.right - theRectWidth;
  870.             break;
  871.             
  872.         case kAlignTopRight:
  873.             inRect.top = inOnRect.top;
  874.             inRect.bottom = inRect.top + theRectHeight;
  875.             inRect.right = inOnRect.right;
  876.             inRect.left = inRect.right - theRectWidth;
  877.             break;
  878.             
  879.         case kAlignBottomRight:
  880.             inRect.bottom = inOnRect.bottom;
  881.             inRect.top = inRect.bottom - theRectHeight;
  882.             inRect.right = inOnRect.right;
  883.             inRect.left = inRect.right - theRectWidth;
  884.             break;
  885.             
  886.         default:
  887.             Assert_(false);        // invalid selector
  888.             break;
  889.         }
  890. }
  891.  
  892. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  893. //    Ñ    PadAlignedRect
  894. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  895.  
  896. void UGraphicGizmos::PadAlignedRect(
  897.     Rect&            ioRect,
  898.     Uint16            inPad,
  899.     Uint16            inAlignment)
  900. {
  901.     Int16 theHOffset = 0, theVOffset = 0;
  902.  
  903.     switch (inAlignment)
  904.         {
  905.         case kAlignTop:
  906.         case kAlignCenterTop:
  907.             theVOffset = inPad;
  908.             break;
  909.             
  910.         case kAlignBottom:
  911.         case kAlignCenterBottom:
  912.             theVOffset = -inPad;
  913.             break;
  914.                         
  915.         case kAlignLeft:
  916.         case kAlignCenterLeft:
  917.             theHOffset = inPad;
  918.             break;
  919.             
  920.         case kAlignTopLeft:
  921.             theVOffset = inPad;
  922.             theHOffset = inPad;
  923.             break;
  924.                         
  925.         case kAlignBottomLeft:
  926.             theVOffset = -inPad;
  927.             theHOffset = inPad;
  928.             break;
  929.             
  930.         case kAlignRight:
  931.         case kAlignCenterRight:
  932.             theHOffset = -inPad;
  933.             break;
  934.                         
  935.         case kAlignTopRight:
  936.             theVOffset = inPad;
  937.             theHOffset = -inPad;
  938.             break;
  939.             
  940.         case kAlignBottomRight:
  941.             theVOffset = -inPad;
  942.             theHOffset = -inPad;
  943.             break;
  944.             
  945.         
  946.         case kAlignAbsoluteCenter:
  947.             // this is to prevent the Assert_
  948.             break;
  949.         
  950.         default:
  951.             Assert_(false);        // invalid selector
  952.             break;
  953.         }
  954.     
  955.     if (theHOffset != 0)
  956.         {
  957.         Int16 theRectWidth = RectWidth(ioRect);
  958.         ioRect.left += theHOffset;
  959.         ioRect.right = ioRect.left + theRectWidth;
  960.         }
  961.         
  962.     if (theVOffset != 0)
  963.         {
  964.         Int16 theRectHeight = RectHeight(ioRect);
  965.         ioRect.top += theVOffset;
  966.         ioRect.bottom = ioRect.top + theRectHeight;
  967.         }
  968. }
  969.  
  970. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  971. //    Ñ    CenterStringInRect
  972. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  973.  
  974. void UGraphicGizmos::CenterStringInRect(
  975.     const StringPtr inString,
  976.     const Rect        &inRect)
  977. {
  978.     FontInfo theFontInfo;
  979.     ::GetFontInfo(&theFontInfo);
  980.         
  981.     Point thePoint;
  982.     thePoint.h = inRect.left + ((RectWidth(inRect) - StringWidth(inString)) / 2);
  983.         
  984.     Int16 theFontHeight = theFontInfo.ascent + theFontInfo.descent + 1;
  985.     thePoint.v = inRect.top + ((RectHeight(inRect) - theFontHeight) / 2) + theFontInfo.ascent;
  986.     
  987.     MoveTo(thePoint.h, thePoint.v);
  988.     ::DrawString(inString);
  989. }
  990.  
  991. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  992. //    Ñ    PlaceStringInRect
  993. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  994.  
  995. void UGraphicGizmos::PlaceStringInRect(
  996.     const StringPtr inString,
  997.     const Rect         &inRect,
  998.     Int16            inHorizJustType,
  999.     Int16            inVertJustType,
  1000.     const FontInfo*    inFontInfo)
  1001. {
  1002.     Point  thePoint;
  1003.  
  1004.     thePoint = CalcStringPosition(inRect, ::StringWidth(inString), inHorizJustType, inVertJustType, inFontInfo);
  1005.     ::MoveTo(thePoint.h, thePoint.v);
  1006.     ::DrawString(inString);
  1007. }
  1008.  
  1009. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  1010. //    Ñ    PlaceTextInRect
  1011. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  1012.  
  1013. void UGraphicGizmos::PlaceTextInRect(
  1014.     const char*     inText,
  1015.     Uint32            inTextLength,
  1016.     const Rect         &inRect,
  1017.     Int16            inHorizJustType,
  1018.     Int16            inVertJustType,
  1019.     const FontInfo*    inFontInfo,
  1020.     Boolean            inDoTruncate,
  1021.     TruncCode        inTruncWhere)
  1022. {
  1023.     if (inRect.right <= inRect.left)
  1024.         return;
  1025.     const char* text = inText;
  1026.     short length = inTextLength;
  1027.     char buf[256];
  1028.     if (inDoTruncate)
  1029.     {
  1030.         // TSM - Text is not necessarily null terminated!
  1031.         ::strncpy(buf, inText, sizeof(buf) < inTextLength ? sizeof(buf) : inTextLength);
  1032.         
  1033.         // BUG IN APPLE's ::TruncText workaround is to call our own version
  1034.         // that has the added bonus of not crashing when you try and trunc
  1035.         // in the middle. Crash in Apple's code happens when you have a small space
  1036.         // and you degenerate into choosing between truncating in the beginning or end.
  1037.         
  1038.         short available = inRect.right - inRect.left;
  1039.         if (inTruncWhere == truncMiddle)
  1040.             MiddleTruncationThatWorks(buf, length, available);
  1041.         else
  1042.             ::TruncText(available, buf, &length, inTruncWhere);
  1043.             
  1044.         text = buf;
  1045.     }
  1046.     Point thePoint = CalcStringPosition(
  1047.              inRect,
  1048.              ::TextWidth(text, 0, length),
  1049.              inHorizJustType,
  1050.              inVertJustType,
  1051.              inFontInfo);
  1052.     ::MoveTo(thePoint.h, thePoint.v);
  1053.     ::DrawText(text, 0, length);
  1054. }    
  1055.  
  1056.  
  1057.  
  1058. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  1059. //    Ñ    CalcStringPosition
  1060. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  1061.  
  1062. Point UGraphicGizmos::CalcStringPosition(
  1063.     const Rect        &inRect,
  1064.     Int16            inStringWidth,
  1065.     Int16            inHorizJustType,
  1066.     Int16            inVertJustType,
  1067.     const FontInfo    *inFontInfo)
  1068. {
  1069.     Point  thePoint;
  1070.     FontInfo             theFontInfo;
  1071.     const FontInfo*    theFontInfoPtr;
  1072.     
  1073.     theFontInfoPtr = inFontInfo;
  1074.     if (inFontInfo == NULL)
  1075.         {
  1076.         ::GetFontInfo(&theFontInfo);
  1077.         theFontInfoPtr = &theFontInfo;
  1078.         }
  1079.  
  1080.     Int16 theFontHeight = theFontInfoPtr->ascent + theFontInfoPtr->descent; // + theFontInfoPtr->leading;
  1081.     Int16 theRectHeight = RectHeight(inRect);
  1082.     if (inHorizJustType == teFlushDefault)
  1083.         {
  1084.         inHorizJustType = ::GetSysDirection();
  1085.         if (inHorizJustType == teFlushDefault) // that's the way it behaves:
  1086.             inHorizJustType = teFlushLeft;
  1087.         }
  1088.     switch (inHorizJustType)
  1089.         {
  1090.         case teFlushRight:
  1091.             thePoint.h = inRect.right - inStringWidth;
  1092.             break;
  1093.             
  1094.         case teFlushLeft:
  1095.             thePoint.h = inRect.left;
  1096.             break;
  1097.                 
  1098.         case teCenter:
  1099.         default:
  1100.             thePoint.h = inRect.left + ((RectWidth(inRect) - inStringWidth) / 2);
  1101.             break;
  1102.         }
  1103.         
  1104.     switch (inVertJustType)
  1105.         {
  1106.         case teFlushTop:
  1107.             thePoint.v = inRect.top + theFontInfoPtr->ascent;
  1108.             break;
  1109.             
  1110.         case teFlushBottom:
  1111.             thePoint.v = inRect.bottom - theFontInfoPtr->descent;
  1112.             break;
  1113.             
  1114.         case teCenter:
  1115.         default:
  1116.             if (theFontHeight >= theRectHeight)
  1117.             {
  1118.                 // This is a fudge to fix a special case which is, however, common.  The height
  1119.                 // we calculated above allows extra space at the top for diacriticals.  So if there's
  1120.                 // a danger that we'll overlap at the bottom, make it overlap at the top, instead.
  1121.                 thePoint.v = inRect.bottom - theFontInfoPtr->descent;
  1122.             }
  1123.             else
  1124.                 thePoint.v
  1125.                     = inRect.top + ((theRectHeight - theFontHeight) / 2)
  1126.                     + theFontInfoPtr->ascent;
  1127.             break;
  1128.         }
  1129.         
  1130.     return thePoint;
  1131. }
  1132.  
  1133. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  1134. //    Ñ    CalcWindowTingeColors
  1135. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  1136.  
  1137. void UGraphicGizmos::CalcWindowTingeColors(WindowPtr inWindowPtr, RGBColor &outLightTinge, RGBColor &outDarkTinge)
  1138. {
  1139.     AuxWinHandle    theAuxHandle;                        // the default AuxWindow data
  1140.     Boolean            gotColors;
  1141.  
  1142.     ::GetAuxWin(inWindowPtr, &theAuxHandle);
  1143.  
  1144.     // look for tinge colors in the color table belonging to the given window
  1145.     if (!theAuxHandle || !(**theAuxHandle).awCTable ||
  1146.         !GetTingeColorsFromColorTable ((**theAuxHandle).awCTable, outLightTinge, outDarkTinge))
  1147.         {
  1148.         // didn't find them? try the system color table
  1149.         // (note: explicit documentation on the wisdom of passing a 0 to GetAuxWin is
  1150.         // hard to find; I finally found it in Toolbox Technote 33 (March 1997))
  1151.         // (also note: the asserts in here are just what they mean; none of this should
  1152.         // ever, ever fail under system 7.)
  1153.         ::GetAuxWin (0, &theAuxHandle);
  1154.         Assert_ (theAuxHandle && (**theAuxHandle).awCTable);
  1155.         gotColors = GetTingeColorsFromColorTable ((**theAuxHandle).awCTable, outLightTinge, outDarkTinge);
  1156.         Assert_ (gotColors);
  1157.         }
  1158. }
  1159.  
  1160.  
  1161. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  1162. //    Ñ    GetTingeColorsFromColorTable
  1163. //        returns true if it finds both tinges in the table
  1164. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  1165.  
  1166. Boolean UGraphicGizmos::GetTingeColorsFromColorTable (
  1167.         CTabHandle        inColorTable,
  1168.         RGBColor        &outLightTinge,
  1169.         RGBColor        &outDarkTinge)
  1170. {
  1171.     Boolean    foundThem;
  1172.  
  1173.     foundThem = false;
  1174.  
  1175.     // do we have a system 7 sized window color table?
  1176.     if ((**inColorTable).ctSize > wTitleBarColor)
  1177.         {
  1178.         // yes, now search for the tinge color, start at the end
  1179.         // because our tinge colors are usually last in the list.
  1180.         Boolean bLightFound = false;
  1181.         Boolean    bDarkFound = false;
  1182.         for (Int16 theIndex = (**inColorTable).ctSize; theIndex > 0; theIndex--)
  1183.             {
  1184.             if ((**inColorTable).ctTable[theIndex].value == wTingeLight)
  1185.                 {
  1186.                 outLightTinge = (**inColorTable).ctTable[theIndex].rgb;
  1187.                 bLightFound = true;
  1188.                 }
  1189.             else if ((**inColorTable).ctTable[theIndex].value == wTingeDark)
  1190.                 {
  1191.                 outDarkTinge = (**inColorTable).ctTable[theIndex].rgb;
  1192.                 bDarkFound = true;
  1193.                 }
  1194.  
  1195.             foundThem = bLightFound && bDarkFound;
  1196.             if (foundThem)
  1197.                 break;    
  1198.             }
  1199.         }
  1200.  
  1201.     return foundThem;
  1202. }
  1203.  
  1204. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  1205. //    Ñ    FindInColorTable
  1206. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  1207.  
  1208. RGBColor UGraphicGizmos::FindInColorTable(CTabHandle inColorTable, Int16 inColorID)
  1209. {
  1210.     RGBColor theFoundColor = { 0, 0, 0 };
  1211.     
  1212.     for (Int16 theIndex = (**inColorTable).ctSize; theIndex > 0; theIndex--)
  1213.         {
  1214.         if ((**inColorTable).ctTable[theIndex].value == inColorID)
  1215.             {
  1216.             theFoundColor = (**inColorTable).ctTable[theIndex].rgb;    
  1217.             break;
  1218.             }
  1219.         }
  1220.     
  1221.     return theFoundColor;
  1222. }
  1223.  
  1224. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  1225. //    Ñ    MixColor
  1226. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  1227.  
  1228. RGBColor UGraphicGizmos::MixColor(
  1229.     const RGBColor& inLightColor,
  1230.     const RGBColor&    inDarkColor,
  1231.     Int16 inShade)
  1232. {
  1233.     RGBColor theMixedColor;
  1234.     
  1235.     inShade = 0x0F - inShade;
  1236.         // This is necessary because we give shades between light and
  1237.         // dark (0% is light), but for colors, $0000 is black and $FFFF 
  1238.         // is dark.
  1239.  
  1240.     theMixedColor.red    = (Int32) (inLightColor.red   - inDarkColor.red)   * inShade / 15 + inDarkColor.red;
  1241.     theMixedColor.green = (Int32) (inLightColor.green - inDarkColor.green) * inShade / 15 + inDarkColor.green;
  1242.     theMixedColor.blue  = (Int32) (inLightColor.blue  - inDarkColor.blue)  * inShade / 15 + inDarkColor.blue;
  1243.  
  1244.     return theMixedColor;
  1245. }
  1246.  
  1247. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  1248. //    Ñ    DrawArithPattern
  1249. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  1250.  
  1251. void UGraphicGizmos::DrawArithPattern(
  1252.     const Rect&         inFrame,
  1253.     const Pattern&        inPattern,
  1254.     Uint16                inTint,
  1255.     Boolean                inLighten)
  1256. {
  1257.     StColorPenState thePenSaver;
  1258.     thePenSaver.Normalize();
  1259.  
  1260.     RGBColor thePinColor = { inTint, inTint, inTint };
  1261.  
  1262.     ::RGBBackColor(&sDarker);
  1263.     ::RGBForeColor(&thePinColor);
  1264.  
  1265.     if (inLighten)
  1266.         {
  1267.         ::OpColor(&sLighter);
  1268.         ::PenMode(addPin);
  1269.         }
  1270.     else
  1271.         {
  1272.         ::OpColor(&sDarker);
  1273.         ::PenMode(subPin);
  1274.         }
  1275.  
  1276.     ::PenPat(&inPattern);
  1277.     ::PaintRect(&inFrame);
  1278. }
  1279.  
  1280. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  1281. //    Ñ    DrawPopupArrow
  1282. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  1283. //    This function is based in part on LGAPopup::DrawPopupArrow().
  1284.  
  1285. void
  1286. UGraphicGizmos::DrawPopupArrow(
  1287.     const Rect&            inLocalFrame,
  1288.     Boolean                inIsEnabled,
  1289.     Boolean                inIsActive,
  1290.     Boolean                inIsHilited)
  1291. {
  1292.     Rect    theFrame = inLocalFrame;
  1293.     Int16    thePopupArrowHeight    = (theFrame.bottom - theFrame.top + 1);
  1294.     
  1295.     // Ñ Setup a device loop so that we can handle drawing at the correct bit depth
  1296.     
  1297.     // this is a hack to avoid a clipping problem--LineTo draws down and to the right of the coordinates
  1298.     // we'll add a pixel to the right and then decrement it after StDeviceLoop call which clips
  1299.     ++theFrame.right;
  1300.     ++theFrame.bottom;
  1301.     
  1302.     StDeviceLoop    theLoop ( theFrame );
  1303.  
  1304.     --theFrame.right;
  1305.     --theFrame.bottom;
  1306.  
  1307.     Int16            depth;
  1308.     while ( theLoop.NextDepth ( depth )) 
  1309.     {
  1310.         if ( depth < 4 )
  1311.         {
  1312.             // Ñ If we are hilited and enabled and active we draw the arrow
  1313.             //   in white otherwise it is drawn in black
  1314.             ::RGBForeColor ( &(inIsHilited && inIsEnabled && inIsActive ?
  1315.                                                 UGAColorRamp::GetWhiteColor () :
  1316.                                                 UGAColorRamp::GetBlackColor()));
  1317.             
  1318.             // Ñ If we are disabled we draw in gray
  1319.             if ( !inIsEnabled)
  1320.                 ::PenPat ( &UQDGlobals::GetQDGlobals()->gray );
  1321.         }
  1322.         else
  1323.         {
  1324.             StColorPenState::Normalize ();
  1325.             
  1326.             // Ñ Handle the actual drawing of the arrow,it is drawn in black in its normal
  1327.             // state, when it is hilited it is drawn in white, and it is drawn in gray when
  1328.             // dimmed
  1329.             if ( inIsHilited && inIsActive )
  1330.                 ::RGBForeColor ( &(inIsEnabled ? UGAColorRamp::GetWhiteColor() :
  1331.                                                 UGAColorRamp::GetColor(7)) );
  1332.             else if ( !inIsEnabled || !inIsActive)
  1333.                 ::RGBForeColor ( &UGAColorRamp::GetColor(7));
  1334.             else
  1335.                 ::RGBForeColor ( &UGAColorRamp::GetBlackColor());
  1336.         }
  1337.  
  1338.         // Ñ Arrow drawing loop draws thePopupArrowHeight rows to make the arrow
  1339.         Int16  counter;
  1340.         for ( counter = 0; counter <= thePopupArrowHeight - 1; counter++ )
  1341.         {
  1342.             ::MoveTo ( theFrame.left + counter, theFrame.top + counter );
  1343.             ::LineTo ( theFrame.right - counter, theFrame.top + counter );
  1344.         }
  1345.     }
  1346. }    
  1347.  
  1348. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  1349. //    Ñ    Class CSicn
  1350. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  1351.  
  1352. CSicn::CSicn()
  1353. {
  1354.     ::SetRect(&mSicnRect, 0, 0, 16, 16);
  1355. }
  1356.  
  1357. CSicn::CSicn(ResIDT inSicnID, Int16 inIndex)
  1358. {
  1359.     ::SetRect(&mSicnRect, 0, 0, 16, 16);
  1360.     LoadSicnData(inSicnID, inIndex);
  1361. }
  1362.  
  1363. void CSicn::LoadSicnData(ResIDT inSicnID, Int16 inIndex)
  1364. {
  1365.     StResource theSicnList('SICN', inSicnID);
  1366.     ThrowIf_((::GetHandleSize(theSicnList.mResourceH) / sizeof(SicnT)) <= inIndex);
  1367.  
  1368.     StHandleLocker theLocker(theSicnList);
  1369.     ::BlockMoveData((Ptr)(*((SicnT *)(*theSicnList.mResourceH) + inIndex)), mSicnData, sizeof(SicnT));
  1370. }
  1371.  
  1372. void CSicn::Plot(Int16 inMode)
  1373. {
  1374.     CopyImage(mSicnRect, inMode);
  1375. }
  1376.  
  1377. void CSicn::Plot(const Rect &inRect, Int16 inMode)
  1378. {
  1379.     CopyImage(inRect, inMode);
  1380. }
  1381.  
  1382. void CSicn::CopyImage(const Rect &inRect, Int16 inMode)
  1383. {
  1384.     // Set up a BitMap for the sicn
  1385.     BitMap theSourceBits;
  1386.     theSourceBits.baseAddr = (Ptr)(mSicnData);
  1387.     theSourceBits.rowBytes = 2;
  1388.     ::SetRect(&theSourceBits.bounds, 0, 0, 16, 16);
  1389.  
  1390.     // draw the small icon in the current grafport
  1391.     ::CopyBits(&theSourceBits, &(UQDGlobals::GetCurrentPort()->portBits),
  1392.                  &theSourceBits.bounds, &inRect, inMode, nil);
  1393. }
  1394.  
  1395. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  1396. //    Ñ    Class CIconFamily
  1397. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  1398.  
  1399. CIconFamily::CIconFamily(ResIDT inFamilyID)
  1400. {
  1401.     mFamilyID = inFamilyID;
  1402.     mIconRect.top = 0;
  1403.     mIconRect.left = 0;
  1404.     mIconRect.bottom = 0;
  1405.     mIconRect.right = 0;
  1406. }
  1407.  
  1408. CIconFamily::~CIconFamily()
  1409. {
  1410. }
  1411.  
  1412. void CIconFamily::Plot(
  1413.     IconAlignmentType inAlign,
  1414.     IconTransformType inTransform)
  1415. {
  1416.     ::PlotIconID(&mIconRect, inAlign, inTransform, mFamilyID);
  1417. }
  1418.  
  1419. void CIconFamily::Plot(
  1420.     const Rect&         inRect,
  1421.     IconAlignmentType     inAlign,
  1422.     IconTransformType     inTransform)
  1423. {
  1424.     ::PlotIconID(&inRect, inAlign, inTransform, mFamilyID);
  1425. }
  1426.  
  1427. CIconFamily::CIconFamily()
  1428. {
  1429.     Assert_(false);
  1430. }
  1431.  
  1432. void CIconFamily::CalcBestSize(const Rect& inContainer)
  1433. {
  1434.     mIconRect.top = mIconRect.left = 0;
  1435.  
  1436.     if ((RectWidth(inContainer) >= 32) && (RectHeight(inContainer) >= 32))
  1437.         mIconRect.right = mIconRect.bottom = 32;
  1438.     else if ((RectWidth(inContainer) >= 16) && (RectHeight(inContainer) >= 16))
  1439.         mIconRect.right = mIconRect.bottom = 16;
  1440.     else if ((RectWidth(inContainer) >= 16) && (RectHeight(inContainer) >= 12))
  1441.         {
  1442.         mIconRect.right = 16;
  1443.         mIconRect.bottom = 12;
  1444.         }
  1445.     else
  1446.         Assert_(false);    // you really wont be able to draw in bounds
  1447. }
  1448.