home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-30 | 7.1 KB | 227 lines | [TEXT/CWIE] |
- // ===========================================================================
- // LAGAGroupBox.cp
- // ===========================================================================
- // “Apple Grayscale Appearance” compliant primary and secondary group boxes
- // Copyright © 1996 Chrisoft (Christophe ANDRES) All rights reserved.
- //
- // You may use this source code in any application (commercial, shareware, freeware,
- // postcardware, etc), but not remove this notice (no need to acknowledge the use of
- // this class in the about box)
- // You may not sell this source code in any form. This source code may be placed on
- // publicly accessable archive sites and source code disks. It may not be placed on
- // profit archive sites and source code disks without the permission of the author,
- // Christophe ANDRES.
- //
- // This source code is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- //
- // If you make any change or improvement on this class, please send the improved/changed
- // version to : chrisoft@calva.net or Christophe ANDRES
- // 20, rue Prosper Mérimée
- // 67100 STRASBOURG
- // FRANCE
- //
- // ===========================================================================
- // LAGAGroupBox.h <- double-click + Command-D to see classes declaration
- //
- // LAGAGroupBox is my implementation of the “Apple Grayscale Appearance for System 7.5”
- // primary group box, except that is can only have a text title and not a popup menu,
- // or a checkbox in its title.
- //
- // LAGASecondaryGroupBox is my implementation of the “Apple Grayscale Appearance for System 7.5”
- // secondary group box, except that is can only have a text title and not a popup menu,
- // or a checkbox in its title.
- //
- // Note : the CPPb declaration of LAGASecondaryGroupBox, as defined in “LAGASeparator CPPb.rsrc”
- // requires that the CPPb declaration of LAGAGroupBox is also present
- //
- // This class requires AGAColors.cp to be present in your project
- // This class requires LGroupBox.cp to be present in your project
- //
- // Version : 1.2
- //
- // Change History (most recent first, date in US form : mm/dd/yy):
- //
- // 06/30/96 ca Public release of version 1.2
- // 06/27/96 ca Changed checks for disabled state (check on triState_On instead of triState_Off)
- // in order that triState_Latent state is drawn as disabled
- // 06/05/96 ca Added RegisterClass method to ease registry
- // Increased version to 1.2
- // 05/17/96 ca Increased version to 1.1
- // Added copy constructor
- // Added "on the fly" constructor
- // Replaced UEnvironment::HasFeature(env_SupportsColor) with PaneInColor
- // Added change history
- // 04/22/96 ca class made available by Christophe ANDRES <chrisoft@calva.net>
- // (version 1.0)
- //
- // To Do:
- //
-
- #include "LAGAGroupBox.h"
-
- #include <UEnvironment.h>
- #include <UTextTraits.h>
- #include "AGAColors.h"
-
- //-------LAGAGroupBox-------------------------------------------------------------------------------------------------
-
- // begin <06/05/96 ca>
- void LAGAGroupBox::RegisterClass ()
-
- {
- URegistrar::RegisterClass(LAGAGroupBox::class_ID, (ClassCreatorFunc)LAGAGroupBox::CreateAGAGroupBoxStream);
- }
- // end <06/05/96 ca>
-
- LAGAGroupBox* LAGAGroupBox::CreateAGAGroupBoxStream (LStream* inStream)
-
- {
- return (new LAGAGroupBox(inStream));
- }
-
-
- LAGAGroupBox::LAGAGroupBox (LStream *inStream) : LGroupBox(inStream)
-
- {
- mFrameColor.red = mFrameColor.blue = mFrameColor.green = 0x8888;
- }
-
- LAGAGroupBox::LAGAGroupBox (const LAGAGroupBox &inOriginal) : LGroupBox(inOriginal)
-
- {
- }
-
- LAGAGroupBox::LAGAGroupBox (const SPaneInfo &inPaneInfo, Str255 inString, ResIDT inTextTraitsID)
- : LGroupBox(inPaneInfo, inString, inTextTraitsID)
-
- {
- }
-
- void LAGAGroupBox::DrawText (const Rect &inRect)
-
- {
- Boolean disabled = (mEnabled != triState_On); // <06/27/96 ca>
- // Retrieve info about font again.
-
- Int16 just = UTextTraits::SetPortTextTraits(mTxtrID);
- FontInfo fInfo;
- ::GetFontInfo(&fInfo);
-
- if (::PaneInColor(this))
- {
- RGBColor textColor;
- ::GetForeColor(&textColor);
-
- ApplyForeAndBackColors();
- if (disabled)
- ::RGBForeColor(&gAGAColorArray[7]);
- else
- ::RGBForeColor(&textColor);
- }
-
- ::MoveTo(inRect.left + 3, inRect.top + fInfo.ascent + (fInfo.leading >> 1));
- ::DrawString(mText);
- }
-
- void LAGAGroupBox::DrawBorder (const Rect &inRect)
-
- {
- StColorPenState theState;
- Rect theFrame = inRect;
- RGBColor saveColor;
- Boolean disabled = (mEnabled != triState_On); // <06/27/96 ca>
-
- // M™H mod: conditional on color
- Boolean hasColor = ::PaneInColor(this);
-
- theFrame.bottom--;
- theFrame.right--;
-
- if (disabled)
- {
- saveColor = mFrameColor;
- if (hasColor)
- mFrameColor = gAGAColorArray[4];
- }
- LGroupBox::DrawBorder(theFrame);
- if (disabled)
- mFrameColor = saveColor;
- if (hasColor)
- {
- // If there is no color, there is no need for this
- if (disabled)
- ::RGBForeColor(&gAGAColorArray[1]);
- else
- ::ForeColor(whiteColor);
- ::MoveTo(theFrame.left + 1, theFrame.bottom - 2);
- ::LineTo(theFrame.left + 1, theFrame.top + 1);
- ::LineTo(theFrame.right - 2, theFrame.top + 1);
- ::MoveTo(theFrame.left , theFrame.bottom);
- ::LineTo(theFrame.right, theFrame.bottom);
- ::LineTo(theFrame.right, theFrame.top);
- }
- }
-
- //-------LAGASecondaryGroupBox-------------------------------------------------------------------------------------------------
-
- // begin <06/05/96 ca>
- void LAGASecondaryGroupBox::RegisterClass ()
-
- {
- URegistrar::RegisterClass(LAGASecondaryGroupBox::class_ID, (ClassCreatorFunc)LAGASecondaryGroupBox::CreateAGASecondaryGroupBoxStream);
- }
- // end <06/05/96 ca>
-
- LAGASecondaryGroupBox* LAGASecondaryGroupBox::CreateAGASecondaryGroupBoxStream (LStream* inStream)
-
- {
- return (new LAGASecondaryGroupBox(inStream));
- }
-
- LAGASecondaryGroupBox::LAGASecondaryGroupBox (LStream *inStream) : LAGAGroupBox(inStream)
-
- {
- }
-
- LAGASecondaryGroupBox::LAGASecondaryGroupBox (const LAGASecondaryGroupBox &inOriginal) : LAGAGroupBox(inOriginal)
-
- {
- }
-
- LAGASecondaryGroupBox::LAGASecondaryGroupBox (const SPaneInfo &inPaneInfo, Str255 inString, ResIDT inTextTraitsID)
- : LAGAGroupBox(inPaneInfo, inString, inTextTraitsID)
-
- {
- }
-
- void LAGASecondaryGroupBox::DrawBorder (const Rect &inRect)
-
- {
- StColorPenState theState;
- Boolean disabled = (mEnabled != triState_On); // <06/27/96 ca>
-
- if (::PaneInColor(this))
- {
- // If there is no color, there is no need for this
- if (disabled)
- ::RGBForeColor(&gAGAColorArray[4]);
- else
- ::RGBForeColor(&mFrameColor);
- ::MoveTo(inRect.left, inRect.bottom - 1);
- ::LineTo(inRect.left, inRect.top);
- ::LineTo(inRect.right - 2, inRect.top);
- if (disabled)
- ::RGBForeColor(&gAGAColorArray[1]);
- else
- ::ForeColor(whiteColor);
- ::MoveTo(inRect.left + 1, inRect.bottom);
- ::LineTo(inRect.right - 1, inRect.bottom);
- ::LineTo(inRect.right - 1, inRect.top + 1);
- }
- else
- LGroupBox::DrawBorder(inRect);
- }
-
-