home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-14 | 6.5 KB | 204 lines | [TEXT/CWIE] |
- // ===========================================================================
- // File: LEnhancedIconPane.cp
- // Version: 1.0 - Feb 08, 1995
- // Author: Mike Shields (mshields@inconnect.com)
- //
- // Copyright ©1994-1996 Mike Shields. All rights reserved.
- // I hereby grant users of LEnhancedIconPane permission to use it (or any modified
- // version of it) in applications (or any other type of Macintosh software
- // like extensions -- freeware, shareware, commercial, or other) for free,
- // subject to the terms that:
- //
- // (1) This agreement is non-exclusive.
- //
- // (2) I, Mike Shields, retain the copyright to the original source code.
- //
- // These two items are the only required conditions for use. However, I do have
- // an additional request. Note, however, that this is only a request, and
- // that it is not a required condition for use of this code.
- //
- // (1) That I be given credit for LEnhancedIconPane code in the copyrights or
- // acknowledgements section of your manual or other appropriate documentation.
- //
- //
- // I would like to repeat that this last item is only a request. You are prefectly
- // free to choose not to do any or all of them.
- //
- // 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.
- // ===========================================================================
- // LEnhancedIconPane.h <- double-click + Command-D to see class declaration
- //
- //
- // LEnhancedIconPane is an enhancement to the PP supplied LIconPane Class. This
- // subclass give the user the ability to specify all of the parameters in the call
- // to PlotIconID. Namely the alignment, label and selection property.
- //
- // Note: For more info on the PlotIconID calls see TN QD 18 -
- // Drawing Icons the System 7 Way
- //
- #include "LEnhancedIconPane.h"
-
- #include <LStream.h>
-
- #ifndef __ICONS__
- #include <Icons.h>
- #endif
-
- // ---------------------------------------------------------------------------
- // • CreateFromStream
- // ---------------------------------------------------------------------------
- // Create a new IconPane object from the data in a Stream
-
- LEnhancedIconPane* LEnhancedIconPane::CreateFromStream(LStream *inStream)
- {
- return (new LEnhancedIconPane(inStream));
- }
-
- // ---------------------------------------------------------------------------
- // • LEnhancedIconPane
- // ---------------------------------------------------------------------------
- // Default Constructor
-
- LEnhancedIconPane::LEnhancedIconPane()
- : mAlignment(atNone), mState(ttNone), mLabel(ttNone)
- {
- }
-
-
- // ---------------------------------------------------------------------------
- // • LEnhancedIconPane(const LEnhancedIconPane&)
- // ---------------------------------------------------------------------------
- // Copy Constructor
-
- LEnhancedIconPane::LEnhancedIconPane(const LEnhancedIconPane &inOriginal)
- : LIconPane(inOriginal)
- {
- SetAlignment(inOriginal.GetAlignment());
- SetIconState(inOriginal.GetIconState());
- SetIconLabel(inOriginal.GetIconLabel());
- }
-
-
- // ---------------------------------------------------------------------------
- // • LEnhancedIconPane(SPaneInfo&, Str255, ResIDT)
- // ---------------------------------------------------------------------------
- // Construct from parameters. Use this constructor to create a IconPane
- // from runtime data.
-
- LEnhancedIconPane::LEnhancedIconPane(const SPaneInfo &inPaneInfo,
- ResIDT inIconID, Int16 inAlignment,
- Int16 inState, Int16 inLabel)
- : LIconPane(inPaneInfo, inIconID), mAlignment(inAlignment), mState(inState),
- mLabel(inLabel)
-
- {
- }
-
-
- // ---------------------------------------------------------------------------
- // • LEnhancedIconPane(LStream*)
- // ---------------------------------------------------------------------------
- // Construct from data in a Stream
-
- LEnhancedIconPane::LEnhancedIconPane(LStream *inStream)
- : LIconPane(inStream)
- {
- inStream->ReadData(&mAlignment, sizeof(Int16));
- inStream->ReadData(&mState, sizeof(Int16));
- inStream->ReadData(&mLabel, sizeof(Int16));
- }
-
-
- // ---------------------------------------------------------------------------
- // • ~LEnhancedIconPane
- // ---------------------------------------------------------------------------
- // Destructor
-
- LEnhancedIconPane::~LEnhancedIconPane()
- {
- }
-
- // ---------------------------------------------------------------------------
- // • GetAlignment
- // ---------------------------------------------------------------------------
- // Get the alignment to draw the icon with
-
- Int16 LEnhancedIconPane::GetAlignment() const
- {
- return mAlignment;
- }
-
-
- // ---------------------------------------------------------------------------
- // • SetAlignment
- // ---------------------------------------------------------------------------
- // Set the alignment to draw the icon with
-
- void LEnhancedIconPane::SetAlignment(Int16 inAlignment)
- {
- mAlignment = inAlignment;
- }
-
-
- // ---------------------------------------------------------------------------
- // • GetIconState
- // ---------------------------------------------------------------------------
- // Get the icon state (ie. enable, disabled, selected, etc) to draw the icon as
-
- Int16 LEnhancedIconPane::GetIconState() const
- {
- return mState;
- }
-
-
- // ---------------------------------------------------------------------------
- // • SetIconState
- // ---------------------------------------------------------------------------
- // Set the icon state (ie. enable, disabled, selected, etc) to draw the icon as
-
- void LEnhancedIconPane::SetIconState(Int16 inIconState)
- {
- mState = inIconState;
- }
-
-
- // ---------------------------------------------------------------------------
- // • GetIconLabel
- // ---------------------------------------------------------------------------
- // Get the icon finder label (ie. none(0), 1, 2, 3, etc) to draw the icon as
-
- Int16 LEnhancedIconPane::GetIconLabel() const
- {
- return mLabel;
- }
-
-
- // ---------------------------------------------------------------------------
- // • SetIconLabel
- // ---------------------------------------------------------------------------
- // Set the icon finder label (ie. none(0), 1, 2, 3, etc) to draw the icon as
-
- void LEnhancedIconPane::SetIconLabel(Int16 inIconLabel)
- {
- mLabel = inIconLabel;
- }
-
-
- // ---------------------------------------------------------------------------
- // • DrawSelf
- // ---------------------------------------------------------------------------
- // Draw the IconPane
-
- void LEnhancedIconPane::DrawSelf()
- {
- Rect frame;
-
- CalcLocalFrameRect(frame);
-
- ::PlotIconID(&frame, mAlignment, mState + (mLabel << 8), mIconID);
- }
-
-
-