home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-30 | 33.5 KB | 914 lines | [TEXT/CWIE] |
- // ===========================================================================
- // LAGARadioButton.cp
- // ===========================================================================
- // “Apple Grayscale Appearance” compliant Radio Button
- // 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
- //
- // ===========================================================================
- // LAGARadioButton.h <- double-click + Command-D to see class declaration
- //
- // LAGARadioButton is my implementation of the “Apple Grayscale Appearance for System 7.5”
- // Radio Buttons
- //
- // This class requires AGAColors.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/04/96 ca made CW9 adjustments
- // Increased version to 1.2
- // 05/25/96 ca Relinquish memory used by the static PixMapHandle if no radio button is used anymore
- // 05/23/96 ca Updated the below changes (M™H) to allow the usage of either the standard radio button template
- // or the custom LAGARadioButton template. The standard radio button template is easier for layout
- // because you can see the text, but you cannot define directly a mixed value radio button
- // Defined class_ID1 and CreateAGARadioButtonStream1 to handle the two template possibilities
- // Added a CPPb to "LAGARadioButton CPPb.rsrc" called LAGARadioButton1 to handle the standard
- // radio button template, without having to tinker the class ID
- // Added a static RegisterClass method to simplify the class registration
- // 05/23/96 M™H Changed the stream constructor to use the standard radio button template in Contructor
- // which enables to see the text put in a radio button while defining the view
- // 05/16/96 ca Increased version to 1.1
- // Added copy constructor
- // Added "on the fly" constructor
- // Replaced UEnvironment::HasFeature(env_SupportsColor) with PaneInColor
- // Added GetDescriptor and SetDescriptor
- // Adjusted the clipping region for the radio box, to include some points left out of M™H's
- // implementation
- // Added change history
- // 05/15/96 M™H changes proposed by Michael(tm) Hamel <mhamel@adi.co.nz> (Thanks a lot ;)
- // use a static PixMapHandle for FASTER draw of the button (uses less code too)
- // Note : the previous drawing method is available conditionnaly by defining SLOW_AGA_RADIO_DRAW
- // which uses more code, but less data (we never know who could need this ;)
- // To compare speed, with M™H's method, drawing 135 radio buttons on a 9500/120
- // takes around 0s20 and with the SLOW_AGA_RADIO_DRAW method, the same takes around 1s70
- // 04/22/96 ca class made available by Christophe ANDRES <chrisoft@calva.net>
- // (version 1.0)
- //
- // To Do:
- //
-
- #include "LAGARadioButton.h"
-
- #include "AGAColors.h"
-
- #include <UTextTraits.h>
- #include <UEnvironment.h>
- #include <UDrawingState.h>
- #include <LStream.h>
- #include <PP_Messages.h>
- #include <UDrawingUtils.h>
-
- //-------LAGARadioButton class---------------------------------------------------------------------------------------
-
- #define kRadioWidth 12
- #define kRadioHeight 12
- #define kRadioNImages 9
-
-
- #ifndef SLOW_AGA_RADIO_DRAW
- char LAGARadioButton::mDraw[kRadioNImages][kRadioHeight][kRadioWidth] = {
- // OFF
- {
- { -1, -1, -1, 5, 11, B, B, 11, 5, -1, -1, -1 }, // 0
- { -1, -1, B, 10, 2, 2, 2, 4, 11, B, -1, -1 }, // 1
- { -1, B, 4, 2, 1, W, W, W, 2, 7, B, -1 }, // 2
- { 5, 10, 2, 1, W, W, 1, 1, 2, 4, 11, 5 }, // 3
- { 11, 2, 1, W, W, 1, 1, 2, 2, 4, 7, 11 }, // 4
- { B, 2, W, W, 1, 1, 2, 2, 4, 4, 7, B }, // 5
- { B, 2, W, 1, 1, 2, 2, 4, 4, 5, 7, B }, // 6
- { 11, 4, W, 1, 2, 2, 4, 4, 5, 5, 7, 11 }, // 7
- { 5, 10, 2, 2, 2, 4, 4, 5, 5, 7, 11, 5 }, // 8
- { -1, B, 7, 4, 4, 4, 5, 5, 7, 7, B, -1 }, // 9
- { -1, -1, B, 10, 7, 7, 7, 7, 11, B, -1, -1 }, // 10
- { -1, -1, -1, 5, 11, B, B, 11, 5, -1, -1, -1 }
- },
- // ON
- {
- { -1, -1, -1, 5, 12, B, B, 12, 5, -1, -1, -1 },
- { -1, -1, 12, B, 11, 10, 10, 10, 11, B, -1, -1 },
- { -1, 12, 11, 10, 8, 8, 8, 7, 7, 6, B, -1 },
- { 5, B, 10, 8, B, B, B, B, 6, 6, 11, 5 },
- { 12, 11, 8, B, B, B, B, B, B, 6, 4, 11 },
- { B, 10, 8, B, B, B, B, B, B, 4, 4, B },
- { B, 10, 8, B, B, B, B, B, B, 4, 2, B },
- { 12, 10, 7, B, B, B, B, B, B, 2, W, 11 },
- { 5, 12, 7, 6, B, B, B, B, 2, W, 11, 5 },
- { -1, 12, 6, 6, 6, 4, 4, 2, W, W, B, -1 },
- { -1, -1, 12, 11, 4, 4, 2, W, 11, B, -1, -1 },
- { -1, -1, -1, 5, 11, B, B, 11, 5, -1, -1, -1 }
- },
- // MIXED
- {
- { -1, -1, -1, 5, 11, B, B, 11, 5, -1, -1, -1 },
- { -1, -1, B, 10, 2, 2, 2, 4, 11, B, -1, -1 },
- { -1, B, 4, 2, 1, W, W, W, 2, 7, B, -1 },
- { 5, 10, 2, 1, W, W, 1, 1, 2, 4, 11, 5 },
- { 11, 2, 1, W, W, 1, 1, 2, 2, 4, 7, 11 },
- { B, 2, W, B, B, B, B, B, B, 4, 7, B },
- { B, 2, W, B, B, B, B, B, B, 5, 7, B },
- { 11, 4, W, 1, 2, 2, 4, 4, 5, 5, 7, 11 },
- { 5, 10, 2, 2, 2, 4, 4, 5, 5, 7, 11, 5 },
- { -1, B, 7, 4, 4, 4, 5, 5, 7, 7, B, -1 },
- { -1, -1, B, 10, 7, 7, 7, 7, 11, B, -1, -1 },
- { -1, -1, -1, 5, 11, B, B, 11, 5, -1, -1, -1 }
- },
- // OFF Pushed
- {
- { -1, -1, -1, 5, 12, B, B, 12, 5, -1, -1, -1 },
- { -1, -1, 12, B, 11, 11, 11, 11, 11, B, -1, -1 },
- { -1, 12, 11, 11, 10, 10, 9, 9, 9, 8, B, -1 },
- { 5, B, 11, 10, 10, 9, 9, 8, 8, 8, 11, 5 },
- { 12, 11, 10, 10, 9, 9, 8, 8, 8, 7, 6, 11 },
- { B, 11, 10, 9, 9, 8, 8, 8, 7, 7, 6, B },
- { B, 11, 9, 9, 8, 8, 8, 7, 7, 6, 6, B },
- { 12, 11, 9, 8, 8, 8, 7, 7, 6, 6, 4, 11 },
- { 5, 12, 9, 8, 8, 7, 7, 6, 6, 4, 10, 5 },
- { -1, 11, 8, 8, 7, 7, 6, 6, 4, 4, B, -1 },
- { -1, -1, 12, 11, 6, 6, 6, 4, 10, B, -1, -1 },
- { -1, -1, -1, 5, 11, B, B, 11, 5, -1, -1, -1 }
- },
- // ON Pushed
- {
- { -1, -1, -1, 5, 12, B, B, 12, 5, -1, -1, -1 },
- { -1, -1, 12, B, 11, 11, 11, 11, 11, B, -1, -1 },
- { -1, 12, 11, 11, 10, 10, 9, 9, 9, 8, B, -1 },
- { 5, B, 11, 10, B, B, B, B, 8, 8, 11, 5 },
- { 12, 11, 10, B, B, B, B, B, B, 7, 6, 11 },
- { B, 11, 10, B, B, B, B, B, B, 7, 6, B },
- { B, 11, 9, B, B, B, B, B, B, 6, 6, B },
- { 12, 11, 9, B, B, B, B, B, B, 6, 4, 11 },
- { 5, 12, 9, 8, B, B, B, B, 6, 4, 10, 5 },
- { -1, 11, 8, 8, 7, 7, 6, 6, 4, 4, B, -1 },
- { -1, -1, 12, 11, 6, 6, 6, 4, 10, B, -1, -1 },
- { -1, -1, -1, 5, 11, B, B, 11, 5, -1, -1, -1 }
- },
- // MIXED Pushed
- {
- { -1, -1, -1, 5, 12, B, B, 12, 5, -1, -1, -1 },
- { -1, -1, 12, B, 11, 11, 11, 11, 11, B, -1, -1 },
- { -1, 12, 11, 11, 10, 10, 9, 9, 9, 8, B, -1 },
- { 5, B, 11, 10, 10, 9, 9, 8, 8, 8, 11, 5 },
- { 12, 11, 10, 10, 9, 9, 8, 8, 8, 7, 6, B },
- { B, 11, 10, B, B, B, B, B, B, 7, 6, B },
- { B, 11, 9, B, B, B, B, B, B, 6, 6, B },
- { 12, 11, 9, 8, 8, 8, 7, 7, 6, 6, 4, 11 },
- { 5, 12, 9, 8, 8, 7, 7, 6, 6, 4, 10, 5 },
- { -1, 11, 8, 8, 7, 7, 6, 6, 4, 4, B, -1 },
- { -1, -1, 12, 11, 6, 6, 6, 4, 10, B, -1, -1 },
- { -1, -1, -1, 5, 11, B, B, 11, 5, -1, -1, -1 }
- },
- // OFF Disabled
- {
- { -1, -1, -1, 4, 7, 7, 7, 7, 4, -1, -1, -1 },
- { -1, -1, 7, 7, 1, 1, 1, 3, 7, 7, -1, -1 },
- { -1, 7, 3, 1, W, W, W, W, 1, 5, 7, 2 },
- { 4, 7, 1, W, W, W, W, W, 1, 3, 7, 4 },
- { 7, 1, W, W, W, W, W, 1, 1, 3, 5, 7 },
- { 7, 1, W, W, W, W, 1, 1, 3, 3, 5, 7 },
- { 7, 1, W, W, W, 1, 1, 3, 3, 4, 5, 7 },
- { 7, 3, W, W, 1, 1, 3, 3, 4, 4, 5, 7 },
- { 4, 7, 1, 1, 1, 3, 3, 4, 4, 5, 7, 4 },
- { -1, 7, 5, 3, 3, 3, 4, 4, 5, 5, 7, -1 },
- { -1, -1, 7, 7, 5, 5, 5, 5, 7, 7, -1, -1 },
- { -1, -1, -1, 4, 7, 7, 7, 7, 4, -1, -1, -1 }
- },
- // ON Disabled
- {
- { -1, -1, -1, 2, 7, 7, 7, 7, 2, -1, -1, -1 },
- { -1, -1, 7, 7, 5, 5, 5, 5, 5, 7, -1, -1 },
- { -1, 7, 5, 5, 4, 4, 4, 3, 3, 3, 7, -1 },
- { 2, 7, 5, 4, 8, 8, 8, 8, 3, 3, 5, 2 },
- { 7, 5, 4, 8, 8, 8, 8, 8, 8, 3, 1, 5 },
- { 7, 5, 4, 8, 8, 8, 8, 8, 8, 1, 1, 7 },
- { 7, 5, 4, 8, 8, 8, 8, 8, 8, 1, W, 7 },
- { 7, 5, 3, 8, 8, 8, 8, 8, 8, W, W, 5 },
- { 2, 5, 3, 3, 8, 8, 8, 8, W, W, 5, 2 },
- { -1, 7, 3, 3, 3, 1, 1, W, W, 5, 7, -1 },
- { -1, -1, 7, 7, 1, 1, W, W, 5, 7, -1, -1 },
- { -1, -1, -1, 2, 5, 7, 7, 5, 2, -1, -1, -1 }
- },
- // MIXED Disabled
- {
- { -1, -1, -1, 4, 7, 7, 7, 7, 4, -1, -1, -1 },
- { -1, -1, 7, 7, 1, 1, 1, 3, 7, 7, -1, -1 },
- { -1, 7, 3, 1, W, W, W, W, 1, 5, 7, -1 },
- { 4, 7, 1, W, W, W, W, W, 1, 3, 7, 4 },
- { 7, 1, W, W, W, W, W, 1, 1, 3, 5, 7 },
- { 7, 1, W, 8, 8, 8, 8, 8, 8, 3, 5, 7 },
- { 7, 1, W, 8, 8, 8, 8, 8, 8, 4, 5, 7 },
- { 7, 3, W, W, 1, 1, 3, 3, 4, 4, 5, 7 },
- { 4, 7, 1, 1, 1, 3, 3, 4, 4, 5, 7, 4 },
- { -1, 7, 5, 3, 3, 3, 4, 4, 5, 5, 7, -1 },
- { -1, -1, 7, 7, 5, 5, 5, 5, 7, 7, -1, -1 },
- { -1, -1, -1, 4, 7, 7, 7, 7, 4, -1, -1, -1 }
- }
- };
-
- // begin <05/15/96 M™H>
- RgnHandle LAGARadioButton::mRadioClip = nil;
- PixMapHandle LAGARadioButton::mImages = nil;
- long LAGARadioButton::mUsage = 0; // <05/25/96 ca>
-
- // static
- void LAGARadioButton::Initialise ()
- // Manufacture a 24-bit deep PixMapHandle with the nine radio button images in it
- // and a circular clipping region for use with CopyBits
- {
- Ptr bitsP;
- Int32 n,i,j;
- char color;
- Rect radioSpace;
- PixMapPtr pmp;
- Int32* scanP;
-
- // Make a PixMapHandle for the images
- bitsP = ::NewPtr(kRadioNImages * kRadioWidth * kRadioHeight * 4);
- ThrowIfMemFail_(bitsP);
- mImages = ::NewPixMap();
- ::HLockHi(Handle(mImages));
- pmp = *mImages;
- pmp->baseAddr = bitsP;
- pmp->rowBytes = 0x8000 + kRadioNImages * kRadioWidth * 4;
- pmp->bounds.left = 0;
- pmp->bounds.right = kRadioNImages * kRadioWidth;
- pmp->bounds.top = 0;
- pmp->bounds.bottom = kRadioHeight;
- pmp->pmVersion = 0;
- pmp->pixelType = RGBDirect;
- pmp->pixelSize = 32;
- pmp->cmpCount = 3;
- pmp->cmpSize = 8;
- pmp->planeBytes = 0;
- ::DisposeCTable(pmp->pmTable);
- pmp->pmTable = nil;
- pmp->pmReserved = 0;
-
- // Fill it with the pixel array
- scanP = (Int32*)bitsP;
- for (i=0; i < kRadioHeight; i++)
- for (n=0; n < kRadioNImages; n++)
- for (j=0; j < kRadioWidth; j++)
- {
- color = mDraw[n][i][j];
- if (color == -1)
- *scanP++ = 0; // Clipped anyway
- else
- *scanP++ = ((((Int32)gAGAColorArray[color].red)<<8) & 0xFF0000)
- +((gAGAColorArray[color].green) & 0xFF00)
- +((gAGAColorArray[color].blue>>8) & 0xFF);
- }
-
- // Make a circular clipping region
- ::SetRect(&radioSpace, 0, 0, kRadioWidth, kRadioHeight);
- mRadioClip = ::NewRgn();
- ::OpenRgn();
- ::FrameOval(&radioSpace);
- ::CloseRgn(mRadioClip);
-
- // begin <05/16/96 ca>
- // adjust clipping region to include edge points which if not included make the radio button look ugly
- RgnHandle aRgn = NewRgn();
- ::OpenRgn();
- ::SetRect(&radioSpace, 3, 0, 9, kRadioHeight);
- ::FrameRect(&radioSpace);
- ::SetRect(&radioSpace, 0, 3, kRadioWidth, 9);
- ::FrameRect(&radioSpace);
- ::CloseRgn(aRgn);
- ::UnionRgn(mRadioClip, aRgn, mRadioClip);
- ::DisposeRgn(aRgn);
- // end <05/16/96 ca>
- }
- // end <05/15/96 M™H>
- #endif /*!SLOW_AGA_RADIO_DRAW*/
-
- // begin <05/23/96 ca>
- void LAGARadioButton::RegisterClass ()
-
- {
- // Constructing the class with the LAGARadioButton CPPb
- URegistrar::RegisterClass(LAGARadioButton::class_ID, (ClassCreatorFunc)LAGARadioButton::CreateAGARadioButtonStream);
- // Constructing the class with the standard radio button template or the LAGARadioButton1 CPPb
- URegistrar::RegisterClass(LAGARadioButton::class_ID1, (ClassCreatorFunc)LAGARadioButton::CreateAGARadioButtonStream1);
- }
-
- LAGARadioButton* LAGARadioButton::CreateAGARadioButtonStream (LStream *inStream)
-
- {
- // Constructing from a 'AGA2' template
- return(new LAGARadioButton(inStream));
- }
-
- LAGARadioButton* LAGARadioButton::CreateAGARadioButtonStream1 (LStream *inStream)
-
- {
- // Constructing from a 'AgA2' template
- return(new LAGARadioButton(inStream, true));
- }
- // end <05/23/96 ca>
-
- //-------Constructors-------------------------------------------------------------------------------------------------
-
- LAGARadioButton::LAGARadioButton ()
-
- {
- mTitle = "\p";
- SetMaxValue(2); // 2 is for mixed value Radio buttons
-
- #ifndef SLOW_AGA_RADIO_DRAW
- mUsage++; // <05/25/96 ca>
- if (mImages==nil) // <05/15/96 M™H>
- Initialise();
- #endif /*!SLOW_AGA_RADIO_DRAW*/
- }
-
- LAGARadioButton::LAGARadioButton (LStream *inStream, Boolean inCreateWithRadioButton) : LControl(inStream)
-
- {
- if (inCreateWithRadioButton) // <05/23/96 ca>
- {
- // begin <05/23/96 M™H> mod so we can use standard radio button template
- Int16 controlKind;
- Int32 macRefCon;
-
- inStream->ReadData(&controlKind, sizeof(Int16)); // Ignored
- inStream->ReadData(&mTextTraitsID, sizeof(ResIDT));
- inStream->ReadPString(mTitle);
- inStream->ReadData(&macRefCon, sizeof(Int32)); // Ignored
- // end <05/23/96 M™H> mod
- }
- else
- {
- inStream->ReadData(&mTextTraitsID, sizeof(ResIDT));
- inStream->ReadPString(mTitle);
- }
-
- if (mMaxValue < 2)
- SetMaxValue(2);
-
- #ifndef SLOW_AGA_RADIO_DRAW
- mUsage++; // <05/25/96 ca>
- if (mImages==nil) // <05/15/96 M™H>
- Initialise();
- #endif /*!SLOW_AGA_RADIO_DRAW*/
- }
-
- // begin <05/16/96 ca>
- LAGARadioButton::LAGARadioButton (const LAGARadioButton &inOriginal)
-
- {
- mTextTraitsID = inOriginal.mTextTraitsID;
- mTitle = inOriginal.mTitle;
-
- if (mMaxValue < 2)
- SetMaxValue(2);
-
- #ifndef SLOW_AGA_RADIO_DRAW
- mUsage++; // <05/25/96 ca>
- if (mImages==nil) // But since we copy a LAGARadioButton, mImages MUST already be initialized ;) <05/15/96 M™H>
- Initialise();
- #endif /*!SLOW_AGA_RADIO_DRAW*/
- }
-
- LAGARadioButton::LAGARadioButton (const SPaneInfo &inPaneInfo, MessageT inValueMessage, Int32 inValue,
- ResIDT inTextTraitsID, Str255 inTitle) : LControl(inPaneInfo, inValueMessage, inValue, 0, 2)
- {
- mTextTraitsID = inTextTraitsID;
- mTitle = inTitle;
-
- #ifndef SLOW_AGA_RADIO_DRAW
- mUsage++; // <05/25/96 ca>
- if (mImages==nil) // <05/15/96 M™H>
- Initialise();
- #endif /*!SLOW_AGA_RADIO_DRAW*/
- }
- // end <05/16/96 ca>
-
- LAGARadioButton::~LAGARadioButton ()
-
- {
- #ifndef SLOW_AGA_RADIO_DRAW // begin <05/25/96 ca>
- mUsage--;
- if (!mUsage)
- {
- if (mRadioClip != nil)
- {
- ::DisposeRgn(mRadioClip);
- mRadioClip = nil;
- }
- if (mImages != nil)
- {
- ::DisposePixMap(mImages);
- mImages = nil;
- }
- }
- #endif /*!SLOW_AGA_RADIO_DRAW*/ // end <05/25/96 ca>
- }
-
- //-------Drawers----------------------------------------------------------------------------------------------------
-
- void LAGARadioButton::DrawSelf ()
-
- {
- DrawGraphic();
- DrawText();
- }
-
- void LAGARadioButton::DrawGraphic (Boolean inPushed)
-
- {
- StColorPenState theState;
- Rect frame;
- Boolean hasColor = ::PaneInColor(this);
- Boolean disabled = (mEnabled != triState_On); // <06/27/96 ca>
-
- theState.Normalize();
-
- CalcLocalFrameRect(frame);
- frame.right = frame.left + kRadioWidth;
- frame.bottom = frame.top + kRadioHeight;
-
- if (hasColor)
- {
- #ifndef SLOW_AGA_RADIO_DRAW
- short pattern = (mValue ? (mValue == 1 ? 1 : 2) : 0) + (disabled ? 6 : (inPushed ? 3 : 0));
- // begin <05/15/96 M™H>
- Rect srcRect;
- GrafPtr thisPort;
-
- srcRect.left = pattern*12;
- srcRect.top = 0;
- srcRect.right = srcRect.left + kRadioWidth;
- srcRect.bottom = kRadioHeight;
- ::OffsetRgn(mRadioClip, frame.left-(**mRadioClip).rgnBBox.left, frame.top-(**mRadioClip).rgnBBox.top);
- ::GetPort(&thisPort);
- ::CopyBits((BitMapPtr)*mImages, &thisPort->portBits, &srcRect, &frame, srcCopy, mRadioClip);
- // end <05/15/96 M™H>
- #else /*!SLOW_AGA_RADIO_DRAW*/
- if (!disabled)
- {
- ::MoveTo(frame.left + 6, frame.top);
- ::Line(1, 0);
- ::Move(3, 1); ::Line(1, 1);
- ::Move(1, 3); ::Line(0, 1);
- ::Move(-1, 3); ::Line(-1, 1);
- ::Move(-3, 1); ::Line(-1, 0);
- ::Move(-3, -1); ::Line(-1, -1);
- ::Move(-1, -3); ::Line(0, -1);
- ::Move(1, -3); ::Line(1, -1);
- ::RGBForeColor(&gAGAColorArray[5]);
- ::Move(1, -1); ::Line(0, 0);
- ::Move(5, 0); ::Line(0, 0);
- ::Move(3, 3); ::Line(0, 0);
- ::Move(0, 5); ::Line(0, 0);
- ::Move(-3, 3); ::Line(0, 0);
- ::Move(-5, 0); ::Line(0, 0);
- ::Move(-3, -3); ::Line(0, 0);
- ::Move(0, -5); ::Line(0, 0);
- if (!inPushed)
- {
- if (mValue != 1)
- {
- ::RGBForeColor(&gAGAColorArray[11]);
- ::Move(4, -3); ::Line(0, 0);
- ::Move(3, 0); ::Line(1, 1);
- ::Move(2, 2); ::Line(1, 1);
- ::Move(0, 3); ::Line(-1, 1);
- ::Move(-2, 2); ::Line(-1, 1);
- ::Move(-3, 0); ::Line(0, 0);
- ::Move(-4, -4); ::Line(0, 0);
- ::Move(0, -3); ::Line(0, 0);
- ::RGBForeColor(&gAGAColorArray[2]);
- ::Move(1, 2); ::Line(0, -2);
- ::Line(3, -3); ::Line(2, 0);
- ::Move(2, 1); ::Line(0, 1);
- ::Line(-5, 5);
- ::Move(-1, 0); ::Line(2, 0);
- ::Line(4, -4);
- ::RGBForeColor(&gAGAColorArray[1]);
- ::Move(-1, -1); ::Line(-1, 0);
- ::Move(0, 1); ::Line(-1, 0);
- ::Move(0, 1); ::Line(-1, 0);
- ::Move(0, 1); ::Line(-1, 0);
- ::Move(0, 1); ::Line(0, 0);
- ::Move(-1, -3); ::Line(2, -2);
- ::ForeColor(whiteColor);
- ::Move(3, 0); ::Line(-2, 0);
- ::Move(0, 1); ::Line(-1, 0);
- ::Move(0, 1); ::Line(-1, 0);
- ::Move(0, 1); ::Line(-1, 0);
- ::Line(0, 2);
- ::RGBForeColor(&gAGAColorArray[7]);
- ::Move(0, 2); ::Line(0, 0);
- ::Move(2, 1); ::Line(3, 0);
- ::Move(1, -1); ::Line(1, 0);
- ::Move(0, -1); ::Line(1, -1);
- ::Line(0, -3);
- ::Move(-1, -2); ::Line(0, 0);
- ::RGBForeColor(&gAGAColorArray[4]);
- ::Move(0, 1); ::Line(0, 2);
- ::Line(-4, 4); ::Line(-2, 0);
- ::Move(2, -1); ::Line(3, -3);
- ::Move(-1, -4); ::Line(0, 0);
- ::Move(-5, 1); ::Line(0, 0);
- ::Move(-1, 5); ::Line(0, 0);
- ::RGBForeColor(&gAGAColorArray[10]);
- ::Move(0, 1); ::Line(0, 0);
- ::Move(2, 2); ::Line(0, 0);
- ::Move(-2, -7); ::Line(0, 0);
- ::Move(2, -2); ::Line(0, 0);
- ::RGBForeColor(&gAGAColorArray[5]);
- ::Move(6, 5); ::Line(-3, 3);
- ::Move(1, 0); ::Line(2, -2);
- if (mValue)
- {
- ::ForeColor(blackColor);
- ::Move(-1, -1); ::Line(-5, 0);
- ::Move(0, -1); ::Line(5, 0);
- }
- }
- else
- {
- ::RGBForeColor(&gAGAColorArray[12]);
- ::Move(1, -1); ::Line(1, -1);
- ::Move(2, -1); ::Line(0, 0);
- ::Move(3, 0); ::Line(0, 0);
- ::Move(-5, 10); ::Line(-1, -1);
- ::Line(0, -1); ::Line(-1, -1);
- ::Move(0, -3); ::Line(0, 0);
- ::RGBForeColor(&gAGAColorArray[11]);
- ::Move(1, 0); ::Line(0, 0);
- ::Move(1, -2); ::Line(0, 0);
- ::Move(2, -1); ::Line(0, 0);
- ::Move(4, 0); ::Line(0, 0);
- ::Move(2, 2); ::Line(1, 1);
- ::Move(0, 3); ::Line(-1, 1);
- ::Move(-2, 2); ::Line(-1, 1);
- ::Move(-3, 0); ::Line(-1, -1);
- ::RGBForeColor(&gAGAColorArray[10]);
- ::Move(-2, -3); ::Line(0, -2);
- ::Move(1, -2); ::Line(1, -1);
- ::Move(2, -1); ::Line(2, 0);
- ::RGBForeColor(&gAGAColorArray[8]);
- ::Move(-1, 1); ::Line(-2, 0);
- ::Line(-2, 2); ::Line(0, 2);
- ::RGBForeColor(&gAGAColorArray[7]);
- ::Move(0, 1); ::Line(0, 1);
- ::Move(5, -6); ::Line(1, 0);
- ::RGBForeColor(&gAGAColorArray[6]);
- ::Move(0, 1); ::Line(1, -1);
- ::Line(0, 2);
- ::Move(-5, 5); ::Line(-2, 0);
- ::Line(1, -1);
- ::RGBForeColor(&gAGAColorArray[4]);
- ::Move(1, 2); ::Line(1, 0);
- ::Move(0, -1); ::Line(1, 0);
- ::Move(3, -3); ::Line(0, -1);
- ::Move(1, 0); ::Line(0, -1);
- ::RGBForeColor(&gAGAColorArray[2]);
- ::Move(0, 2); ::Line(-4, 4);
- ::ForeColor(whiteColor);
- ::Move(1, 0); ::Line(3, -3);
- ::Move(-1 ,2); ::Line(0, 0);
- ::ForeColor(blackColor);
- ::Move(-8, -6); ::Line(0, 0);
- ::Move(2, -2); ::Line(0, 0);
- ::Move(0, 3); ::Line(0, 3);
- ::Move(1, 1); ::Line(0, -5);
- ::Move(1, 0); ::Line(0, 5);
- ::Move(1, 0); ::Line(0, -5);
- ::Move(1, 0); ::Line(0, 5);
- ::Move(1, -1); ::Line(0, -3);
- }
- }
- else
- {
- ::RGBForeColor(&gAGAColorArray[12]);
- ::Move(1, -1); ::Line(1, -1);
- ::Move(2, -1); ::Line(0, 0);
- ::Move(3, 0); ::Line(0, 0);
- ::Move(-5, 10); ::Line(0, 0);
- ::Move(-1, -2); ::Line(-1, -1);
- ::Move(0, -3); ::Line(0, 0);
- ::RGBForeColor(&gAGAColorArray[11]);
- ::Move(1, 3); ::Line(0, -3);
- ::Line(1, -1); ::Line(0, -1);
- ::Line(1, 0); ::Line(1, -1);
- ::Line(4, 0);
- ::Move(2, 2); ::Line(1, 1);
- ::Move(0, 3); ::Line(0, 0);
- ::Move(-4, 4); ::Line(0, 0);
- ::Move(-3, 0); ::Line(-1, -1);
- ::Move(-2, -1); ::Line(0, 0);
- ::RGBForeColor(&gAGAColorArray[10]);
- ::Move(1, -4); ::Line(0, -1);
- ::Move(1, 0); ::Line(0, -1);
- ::Move(1, 0); ::Line(0, -1);
- ::Line(1, 0);
- ::Move(5, 6); ::Line(0, 0);
- ::Move(-2, 2); ::Line(0, 0);
- ::RGBForeColor(&gAGAColorArray[9]);
- ::Move(-6, -2); ::Line(0, -1);
- ::Line(5, -5); ::Line(1, 0);
- ::Move(-2, 0); ::Line(-4, 4);
- ::RGBForeColor(&gAGAColorArray[8]);
- ::Move(1, 1); ::Line(4, -4);
- ::Move(2, -1); ::Line(-7, 7);
- ::Move(1, 0); ::Line(6, -6);
- ::RGBForeColor(&gAGAColorArray[7]);
- ::Move(0, 1); ::Line(-5, 5);
- ::Move(1, 0); ::Line(4, -4);
- ::RGBForeColor(&gAGAColorArray[6]);
- ::Move(1, -1); ::Line(0, 2);
- ::Line(-4, 4); ::Line(-2, 0);
- ::Move(1, 0); ::Line(4, -4);
- ::RGBForeColor(&gAGAColorArray[4]);
- ::Move(1, 1); ::Line(-3, 3);
- ::Move(2, -1); ::Line(0, 0);
- ::ForeColor(blackColor);
- ::Move(-8, -6); ::Line(0, 0);
- ::Move(2, -2); ::Line(0, 0);
- if (mValue)
- if (mValue == 1)
- {
- ::Move(0, 3); ::Line(0, 3);
- ::Move(1, 1); ::Line(0, -5);
- ::Move(1, 0); ::Line(0, 5);
- ::Move(1, 0); ::Line(0, -5);
- ::Move(1, 0); ::Line(0, 5);
- ::Move(1, -1); ::Line(0, -3);
- }
- else
- {
- ::Move(0, 4); ::Line(5, 0);
- ::Move(0, 1); ::Line(-5 ,0);
- }
- }
- }
- else
- {
- ::RGBForeColor(&gAGAColorArray[7]);
- ::MoveTo(frame.left + 5, frame.top);
- ::Line(3, 0); ::Line(1, 1);
- ::Line(1, 0); ::Line(1, 1);
- ::Line(0, 1); ::Line(1, 1);
- ::Line(0, 3); ::Line(-1, 1);
- ::Line(0, 1); ::Line(-1, 1);
- ::Line(-1, 0); ::Line(-1, 1);
- ::Line(-3, 0); ::Line(-1, -1);
- ::Line(-1, 0); ::Line(-1, -1);
- ::Line(0, -1); ::Line(-1, -1);
- ::Line(0, -3); ::Line(1, -1);
- ::Line(0, -1); ::Line(1, -1);
- ::Line(1, 0);
- if (mValue != 1)
- {
- ::RGBForeColor(&gAGAColorArray[4]);
- ::Move(0, -1); ::Line(0, 0);
- ::Move(5, 0); ::Line(0, 0);
- ::Move(3, 3); ::Line(0, 0);
- ::Move(0, 5); ::Line(0, 0);
- ::Move(-2, -2); ::Line(-3, 3);
- ::Move(1, 0); ::Line(2, -2);
- ::Move(-1, 4); ::Line(0, 0);
- ::Move(-5, 0); ::Line(0, 0);
- ::Move(-3, -3); ::Line(0, 0);
- ::Move(0, -5); ::Line(0, 0);
- ::RGBForeColor(&gAGAColorArray[3]);
- ::Move(2, -1); ::Line(0, 0);
- ::Move(5, -1); ::Line(0, 0);
- ::Move(2, 2); ::Line(0, 2);
- ::Line(-4, 4); ::Line(-2, 0);
- ::Move(2, -1); ::Line(3, -3);
- ::Move(-7, 2); ::Line(0, 0);
- ::RGBForeColor(&gAGAColorArray[5]);
- ::Move(3, 3); ::Line(3, 0);
- ::Line(3, -3); ::Line(0, -3);
- ::Move(-1, 5); ::Line(0, 0);
- ::Move(0, -7); ::Line(0, 0);
- ::RGBForeColor(&gAGAColorArray[1]);
- ::Move(-1, 0); ::Line(0, 2);
- ::Move(-1, 0); ::Line(0, 1);
- ::Move(-1, 0); ::Line(0, 1);
- ::Move(-1, 0); ::Line(0, 1);
- ::Move(-1, 0); ::Line(0, 1);
- ::Line(-2, 0);
- ::Move(-1, -2); ::Line(0, -2);
- ::Line(3, -3); ::Line(2, 0);
- ::ForeColor(whiteColor);
- ::Move(-2, 1); ::Line(3, 0);
- ::Move(0, 1); ::Line(-4, 0);
- ::Move(-1, 1); ::Line(4, 0);
- ::Move(-1, 1); ::Line(-3, 0);
- ::Move(0, 1); ::Line(2, 0);
- ::Move(-1, 1); ::Line(-1, 0);
- if (mValue)
- {
- ::RGBForeColor(&gAGAColorArray[8]);
- ::Move(1, -1); ::Line(5, 0);
- ::Move(0, -1); ::Line(-5, 0);
- }
- }
- else
- {
- ::RGBForeColor(&gAGAColorArray[2]);
- ::Move(0, -1); ::Line(0, 0);
- ::Move(5, 0); ::Line(0, 0);
- ::Move(3, 3); ::Line(0, 0);
- ::Move(0, 5); ::Line(0, 0);
- ::Move(-3, 3); ::Line(0, 0);
- ::Move(-5, 0); ::Line(0, 0);
- ::Move(-3, -3); ::Line(0, 0);
- ::Move(0, -5); ::Line(0, 0);
- ::RGBForeColor(&gAGAColorArray[5]);
- ::Move(1, 5); ::Line(0, -4);
- ::Line(1, -1); ::Line(0, -1);
- ::Line(1, 0); ::Line(1, -1);
- ::Line(4, 0);
- ::Move(2, 2); ::Line(1, 1);
- ::Move(0, 3); ::Line(-1, 1);
- ::Move(-2, 2); ::Line(-1, 1);
- ::Move(-3, 0); ::Line(0, 0);
- ::RGBForeColor(&gAGAColorArray[4]);
- ::Move(-2, -5); ::Line(0, -2);
- ::Line(2, -2); ::Line(2, 0);
- ::RGBForeColor(&gAGAColorArray[3]);
- ::Move(1, 0); ::Line(2, 0);
- ::Move(-1, 1); ::Line(1, 0);
- ::Move(0, 1); ::Line(0, 0);
- ::Move(-5, 5); ::Line(-2, 0);
- ::Move(0, -1); ::Line(1, 0);
- ::Move(-1, -1); ::Line(0, 0);
- ::RGBForeColor(&gAGAColorArray[1]);
- ::Move(2, 3); ::Line(1, 0);
- ::Move(0, -1); ::Line(1, 0);
- ::Move(3, -3); ::Line(0, -1);
- ::Move(1, 0); ::Line(0, -1);
- ::ForeColor(whiteColor);
- ::Move(0, 2); ::Line(0, 1);
- ::Move(-1, 0); ::Line(0, 2);
- ::Move(-1, -1); ::Line(0, 1);
- ::Move(-1, 0); ::Line(0, 1);
- ::Move(-1, 0); ::Line(0, 0);
- ::RGBForeColor(&gAGAColorArray[8]);
- ::Move(-3, -3); ::Line(0, -3);
- ::Move(1, -1); ::Line(0, 5);
- ::Move(1, 0); ::Line(0, -5);
- ::Move(1, 0); ::Line(0, 5);
- ::Move(1, 0); ::Line(0, -5);
- ::Move(1, 1); ::Line(0, 3);
- }
- }
- #endif /*!SLOW_AGA_RADIO_DRAW*/
- }
- else
- {
- Rect tempRect;
-
- tempRect = frame;
- ::InsetRect(&tempRect, 1, 1);
- ::EraseOval(&tempRect);
-
- if (disabled)
- PenPat(&qd.gray);
- ::FrameOval(&frame);
- if (disabled)
- PenNormal();
- if (inPushed)
- {
- tempRect = frame;
- ::InsetRect(&tempRect, 1, 1);
- ::FrameOval(&tempRect);
- ::PenNormal();
- }
-
- if (mValue)
- {
- if (mValue == 1)
- {
- tempRect = frame;
- ::InsetRect(&tempRect, 3, 3);
- ::FillOval(&tempRect, &qd.black);
- }
- else
- {
- ::MoveTo(frame.left + 3, frame.top + 5);
- ::LineTo(frame.right - 4, frame.top + 5);
- ::MoveTo(frame.left + 3, frame.top + 6);
- ::LineTo(frame.right - 4, frame.top + 6);
- }
- }
- }
- }
-
- void LAGARadioButton::DrawText ()
-
- {
- StColorPenState theState;
- // Retrieve info about font again.
-
- Int16 just = UTextTraits::SetPortTextTraits(mTextTraitsID);
-
- Rect frame;
- CalcLocalFrameRect(frame);
- frame.left += kRadioWidth + 5;
- frame.top -= 2;
- frame.bottom--;
- if (UEnvironment::HasFeature(env_SupportsColor))
- {
- RGBColor textColor;
- ::GetForeColor(&textColor);
-
- ApplyForeAndBackColors();
- if (mEnabled == triState_On) // <06/27/96 ca>
- ::RGBForeColor(&textColor);
- else
- ::RGBForeColor(&gAGAColorArray[7]);
- }
- UTextDrawing::DrawWithJustification((Ptr)&mTitle[1], mTitle[0], frame, just);
- }
-
- //-------Utilities--------------------------------------------------------------------------------------------------
-
- StringPtr LAGARadioButton::GetDescriptor (Str255 outDescriptor) const
-
- {
- return LString::CopyPStr(mTitle, outDescriptor);
- }
-
- void LAGARadioButton::SetDescriptor (ConstStr255Param inDescriptor)
-
- {
- mTitle = inDescriptor;
- Refresh();
- }
-
- void LAGARadioButton::SetValue (Int32 inValue)
-
- {
- if (inValue < mMinValue)
- inValue = mMinValue;
- else
- if (inValue > mMaxValue)
- inValue = mMaxValue;
- mValue = inValue;
- // If turning RadioButton on, broadcast message so that the
- // RadioGroup (if present) will turn off the other RadioButtons
- // in the group.
-
- if (inValue == Button_On)
- {
- BroadcastValueMessage();
- BroadcastMessage(msg_ControlClicked, (void*) this);
- }
- FocusDraw();
- DrawGraphic();
- }
-
- void LAGARadioButton::HotSpotAction (Int16 /*inHotSpot*/, Boolean inCurrInside, Boolean inPrevInside)
-
- {
- // Draw if cursor moved from IN to OUT
- // or from OUT to IN
- if (inCurrInside != inPrevInside)
- {
- FocusDraw();
- DrawGraphic(inCurrInside);
- }
- }
-
- void LAGARadioButton::HotSpotResult (Int16 /*inHotSpot*/)
-
- {
- // In the Mac interface, clicking on a RadioButton always
- // turns it on (or leaves it on). The standard way to turn
- // off a RadioButton is to turn on another one in the
- // same Radio Group. A Radio Group will normally be a
- // Listener of a RadioButton.
-
- SetValue(Button_On);
- }
-
-
-