home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-30 | 4.6 KB | 152 lines | [TEXT/CWIE] |
- // ===========================================================================
- // LAGAStateIconButton.cp
- // ===========================================================================
- // “Apple Grayscale Appearance” compliant (almost) state icon 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
- //
- // ===========================================================================
- // LAGAStateIconButton.h <- double-click + Command-D to see class declaration
- //
- // LAGAStateIconButton is a subclass of LAGAIconButton, and enables the button to use
- // up to three different icons (states), and to use them in a standard way (pushed,
- // disabled, radio behavior)
- //
- // see the comments in LAGAIconButton.h
- //
- // 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/04/96 ca Added static RegisterClass for easier class registration
- // Increased version to 1.2
- // 06/01/96 ms Changes brought by Marco Sandri <msandri@mbox.vol.it>
- // Changes made to avoid icon "flicker" during pressing
- // 05/15/96 ca Increased version to 1.1
- // Added change history
- // 04/22/96 ca class made available by Christophe ANDRES <chrisoft@calva.net>
- // (version 1.0)
- //
- // To Do:
- //
-
- #include "LAGAStateIconButton.h"
-
- // begin <06/04/96 ca>
- void LAGAStateIconButton::RegisterClass ()
-
- {
- URegistrar::RegisterClass(LAGAStateIconButton::class_ID, (ClassCreatorFunc)LAGAStateIconButton::CreateAGAStateIconButtonStream);
- }
- // end <06/04/96 ca>
-
- LAGAStateIconButton* LAGAStateIconButton::CreateAGAStateIconButtonStream (LStream *inStream)
-
- {
- return(new LAGAStateIconButton(inStream));
- }
-
- //-------Constructors-------------------------------------------------------------------------------------------------
-
- LAGAStateIconButton::LAGAStateIconButton ()
-
- {
- mState = 0;
- mIconID2 = mIconID3 = resID_Undefined;
- }
-
- LAGAStateIconButton::LAGAStateIconButton (LStream *inStream) : LAGAIconButton(inStream)
-
- {
- mState = 0;
- inStream->ReadData(&mIconID2, sizeof(ResIDT));
- inStream->ReadData(&mIconID3, sizeof(ResIDT));
- }
-
- // begin <0515/96 ca>
- LAGAStateIconButton::LAGAStateIconButton (const LAGAStateIconButton &inOriginal) : LAGAIconButton(inOriginal)
-
- {
- mState = 0;
- mIconID2 = inOriginal.mIconID2;
- mIconID3 = inOriginal.mIconID3;
- }
-
- LAGAStateIconButton::LAGAStateIconButton (const SPaneInfo &inPaneInfo, MessageT inClickedMessage, OSType inIconType,
- ResIDT inIconState1, ResIDT inIconState2, ResIDT inIconState3,
- Boolean inRadioButtonBehavior)
- : LAGAIconButton(inPaneInfo, inClickedMessage, inIconType, inIconState1,
- inRadioButtonBehavior)
- {
- mState = 0;
- mIconID2 = inIconState2;
- mIconID3 = inIconState3;
- }
- // end <0515/96 ca>
-
- LAGAStateIconButton::~LAGAStateIconButton ()
-
- {
- }
-
- //-------Drawers----------------------------------------------------------------------------------------------------
-
- short LAGAStateIconButton::GetIconID ()
-
- {
- short outIconID;
-
- switch(mState)
- {
- case 0 :
- outIconID = mIconID;
- break;
- case 1 :
- outIconID = mIconID2;
- break;
- case 2 :
- outIconID = mIconID3;
- break;
- dafault :
- outIconID = resID_Undefined;
- break;
- }
-
- return(outIconID);
- }
-
- void LAGAStateIconButton::SetState (Int32 inValue)
-
- {
- if ((inValue != mState) && (inValue < 3))
- {
- mState = inValue;
- if (mIcon != nil)
- {
- DisposeCIcon(mIcon);
- mIcon = nil;
- }
- Draw(nil); // <06/01/96 ms>
- }
- }
-
-
-