home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / mac / UserInterface / UGraphicGizmos.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  7.8 KB  |  304 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. #pragma once
  20.  
  21. #include <PP_Prefix.h>
  22. #include <LPane.h>
  23.  
  24. #include "UStdBevels.h"
  25.  
  26. #ifndef __TEXTEDIT__
  27. #include <TextEdit.h>
  28. #endif
  29.  
  30. #ifndef __ICONS__
  31. #include <Icons.h>
  32. #endif
  33.  
  34. enum {
  35.     teFlushBottom = teFlushRight,
  36.     teFlushTop = teFlushLeft
  37. };
  38.  
  39. enum {
  40.     wHiliteLight     = 5,
  41.     wHiliteDark,
  42.     wTitleBarLight,
  43.     wTitleBarDark,
  44.     wDialogLight,
  45.     wDialogDark,
  46.     wTingeLight,
  47.     wTingeDark
  48. };
  49.  
  50. class CGWorld;
  51.  
  52. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  53. //    Ñ    Class UGraphicGizmos
  54. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  55.  
  56. class UGraphicGizmos
  57. {
  58.     public:
  59.  
  60.         static void        LoadBevelTraits(
  61.                             ResIDT                 inBevelTraitsID,
  62.                             SBevelColorDesc&     outBevelDesc);
  63.                             
  64.         static void     BevelRect(
  65.                                 const Rect&        inRect,
  66.                                 Int16             inBevel,
  67.                                 Int16             inTopColor,
  68.                                 Int16            inBottomColor);
  69.  
  70.         static void     BevelPartialRect(
  71.                                 const Rect &    inRect,
  72.                                 Int16             inBevel,
  73.                                 Int16             inTopColor,
  74.                                 Int16            inBottomColor,
  75.                                 const SBooleanRect&    inSides);
  76.  
  77.         static void     BevelRect(
  78.                                 const Rect&        inRect,
  79.                                 Int16             inBevel,
  80.                                 const RGBColor&    inTopColor,
  81.                                 const RGBColor&    inBottomColor);
  82.  
  83.         static void     BevelRectAGA(
  84.                                 const Rect&        inRect,
  85.                                 Int16             inBevel,
  86.                                 const RGBColor&    inTopColor,
  87.                                 const RGBColor&    inBottomColor);
  88.  
  89.         static void     BevelPartialRect(
  90.                                 const Rect &    inRect,
  91.                                 Int16             inBevel,
  92.                                 const RGBColor&    inTopColor,
  93.                                 const RGBColor&    inBottomColor,
  94.                                 const SBooleanRect&    inSides);
  95.  
  96.         static void        BevelTintRect(
  97.                                 const Rect&        inRect,
  98.                                 Int16             inBevel,
  99.                                 Uint16            inTopTint,
  100.                                 Uint16            inBottomTint);
  101.  
  102.         static void        BevelTintRoundRect(
  103.                                 const Rect&        inRect,
  104.                                 Int16            inOvalWidth,
  105.                                 Int16            inOvalHeight,
  106.                                 Uint16            inTint,
  107.                                 Boolean            inLighten);
  108.  
  109.         static void        BevelTintPartialRect(
  110.                                 const Rect &    inRect,
  111.                                 Int16             inBevel,
  112.                                 Uint16            inTopTint,
  113.                                 Uint16            inBottomTint,
  114.                                 const SBooleanRect& inSides);
  115.                                 
  116.         static void        BevelTintLine(
  117.                                 Int16            inStartX,
  118.                                 Int16            inStartY,
  119.                                 Int16            inEndX,
  120.                                 Int16            inEndY,
  121.                                 Uint16            inTint,
  122.                                 Boolean            inLighten);
  123.  
  124.         static void        BevelTintPixel(
  125.                                 Int16            inX,
  126.                                 Int16            inY,
  127.                                 Uint16            inTint,
  128.                                 Boolean            inLighten);
  129.  
  130.         static void        RaiseColorVolume(
  131.                                 const Rect&        inRect,
  132.                                 Uint16            inTint = 0x8000);
  133.                                 
  134.         static void        LowerColorVolume(
  135.                                 const Rect&        inRect,
  136.                                 Uint16            inTint = 0x8000);
  137.                                 
  138.         static void        LowerRoundRectColorVolume(
  139.                                 const Rect&        inRect,
  140.                                 Int16            inOvalWidth,
  141.                                 Int16            inOvalHeight,
  142.                                 Uint16            inTint = 0x8000);
  143.  
  144.         static void     PaintDisabledRect(
  145.                                 const Rect&        inRect,
  146.                                 Uint16            inTint = 0x8000,
  147.                                 Boolean            inMakeLighter = true);
  148.  
  149.         static void     CenterRectOnRect(
  150.                                 Rect&            inRect,
  151.                                 const Rect&        inOnRect);
  152.  
  153.         static void        AlignRectOnRect(
  154.                                 Rect&            inRect,
  155.                                 const Rect&        inOnRect,
  156.                                 Uint16            inAlignment);
  157.  
  158.         static void        PadAlignedRect(
  159.                                 Rect&            ioRect,
  160.                                 Uint16            inPad,
  161.                                 Uint16            inAlignment);
  162.  
  163.         static void        CenterStringInRect(
  164.                                 const StringPtr inString,
  165.                                 const Rect        &inRect);
  166.             
  167.         static void     PlaceStringInRect(
  168.                                 const StringPtr inString,
  169.                                 const Rect         &inRect,
  170.                                 Int16            inHorizJustType = teCenter,
  171.                                 Int16            inVertJustType = teCenter,
  172.                                 const FontInfo*    inFontInfo = NULL);
  173.                                 
  174.         static void     PlaceTextInRect(
  175.                                 const char*     inText,
  176.                                 Uint32            inTextLength,
  177.                                 const Rect         &inRect,
  178.                                 Int16            inHorizJustType = teCenter,
  179.                                 Int16            inVertJustType = teCenter,
  180.                                 const FontInfo*    inFontInfo = NULL,
  181.                                 Boolean            inDoTruncate = false,
  182.                                 TruncCode        inTruncWhere = truncMiddle);
  183.                                 
  184.         static Point    CalcStringPosition(
  185.                                 const Rect        &inRect,
  186.                                 Int16            inStringWidth,
  187.                                 Int16            inHorizJustType,
  188.                                 Int16            inVertJustType,
  189.                                 const FontInfo    *inFontInfo);                            
  190.                                 
  191.         static void     CalcWindowTingeColors(
  192.                                 WindowPtr        inWindowPtr,
  193.                                 RGBColor        &outLightTinge,
  194.                                 RGBColor        &outDarkTinge);
  195.                                 
  196.         static RGBColor FindInColorTable(
  197.                                 CTabHandle     inColorTable,
  198.                                 Int16             inColorID);
  199.         
  200.         static RGBColor MixColor(
  201.                                 const RGBColor& inLightColor,
  202.                                 const RGBColor&    inDarkColor,
  203.                                 Int16 inShade);
  204.     
  205.         static void        DrawArithPattern(
  206.                                 const Rect&         inFrame,
  207.                                 const Pattern&        inPattern,
  208.                                 Uint16                inTint,
  209.                                 Boolean                inLighten);
  210.                                 
  211.         static void        DrawPopupArrow(
  212.                                 const Rect&            inLocalFrame,
  213.                                 Boolean                inIsEnabled            = true,
  214.                                 Boolean                inIsActive            = true,
  215.                                 Boolean                inIsHilited            = false);
  216.         
  217.         static RGBColor    sLighter;
  218.         static RGBColor    sDarker;
  219.  
  220. private:
  221.  
  222.         static Boolean     GetTingeColorsFromColorTable (
  223.                                 CTabHandle        inColorTable,
  224.                                 RGBColor        &outLightTinge,
  225.                                 RGBColor        &outDarkTinge);
  226.  
  227. };
  228.  
  229. inline Int16 RectWidth(const Rect& inRect)
  230.     {    return inRect.right - inRect.left;        }
  231. inline Int16 RectHeight(const Rect& inRect)
  232.     {    return inRect.bottom - inRect.top;        }
  233.  
  234.  
  235. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  236. //    Ñ    Class CSicn
  237. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  238.  
  239. typedef Int16 SicnT[16];
  240.  
  241. class CSicn
  242. {
  243.     public:
  244.                         CSicn();
  245.                         CSicn(ResIDT inSicnID, Int16 inIndex = 0);
  246.  
  247.         void            LoadSicnData(ResIDT inSicnID, Int16 inIndex = 0);
  248.  
  249.         void            Plot(Int16 inMode = srcCopy);
  250.         void            Plot(const Rect &inRect, Int16 inMode = srcCopy);
  251.                 
  252.         operator        Rect*();
  253.         operator        Rect&();
  254.         
  255.     protected:
  256.         void            CopyImage(const Rect &inRect, Int16 inMode);
  257.         
  258.         SicnT            mSicnData;
  259.         Rect            mSicnRect;
  260. };
  261.  
  262. inline CSicn::operator Rect*()
  263.     {    return &mSicnRect;        }
  264. inline CSicn::operator Rect&()
  265.     {     return mSicnRect;          }
  266.  
  267.     
  268. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  269. //    Ñ    Class CIconFamily
  270. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  271.  
  272. class CIconFamily
  273. {
  274.     public:
  275.                         CIconFamily(ResIDT inFamilyID);
  276.                         ~CIconFamily();
  277.         
  278.         void            Plot(
  279.                             IconAlignmentType inAlign = atNone,
  280.                             IconTransformType inTransform = ttNone);
  281.                             
  282.         void            Plot(
  283.                             const Rect&         inRect,
  284.                             IconAlignmentType     inAlign = atNone,
  285.                             IconTransformType     inTransform = ttNone);
  286.  
  287.         operator        Rect*();
  288.         operator        Rect&();
  289.  
  290.         void            CalcBestSize(const Rect& inContainer);
  291.     
  292.     protected:
  293.         ResIDT            mFamilyID;
  294.         Rect            mIconRect;
  295.  
  296.     private:
  297.                         CIconFamily();    // parameters required
  298. };
  299.  
  300. inline CIconFamily::operator Rect*()
  301.     {    return &mIconRect;        }
  302. inline CIconFamily::operator Rect&()
  303.     {     return mIconRect;          }
  304.