home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-12 | 3.7 KB | 153 lines | [TEXT/CWIE] |
- // ===========================================================================
- // LCicnCheck.cp ©1996 Gregory S. Combs <combs@io.com>
- //
- // ===========================================================================
- //
- // An LCicnButton that works as a checkbox.
- //
- // (License mumbo-jumbo "borrowed" from Christophe ANDRES, chrisoft@calva.net)
- //
- // 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,
- // Gregory S. Combs.
- //
- // 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 : combs@io.com
- //
-
- #ifdef PowerPlant_PCH
- #include PowerPlant_PCH
- #endif
-
- #include "LCicnCheck.h"
- #include <LStream.h>
- #include <UDrawingState.h>
-
-
- // ---------------------------------------------------------------------------
- // • CreateCicnCheckStream
- // ---------------------------------------------------------------------------
- // Create a new CicnCheck object from the data in a Stream
-
- LCicnCheck*
- LCicnCheck::CreateCicnCheckStream(
- LStream *inStream)
- {
- return (new LCicnCheck(inStream));
- }
-
-
- // ---------------------------------------------------------------------------
- // • LCicnCheck
- // ---------------------------------------------------------------------------
- // Default Constructor
-
- LCicnCheck::LCicnCheck()
- {
- SetMaxValue(1);
- }
-
-
- // ---------------------------------------------------------------------------
- // • LCicnCheck(const LCicnButton&)
- // ---------------------------------------------------------------------------
- // Copy Constructor
-
- LCicnCheck::LCicnCheck(
- const LCicnCheck &inOriginal)
- : LCicnButton(inOriginal)
- {
- SetMaxValue(1);
- }
-
-
-
- // ---------------------------------------------------------------------------
- // • LCicnCheck(LStream*)
- // ---------------------------------------------------------------------------
- // Construct a new CicnCheck from the data in a Stream
- //
-
- LCicnCheck::LCicnCheck(
- LStream *inStream)
- : LCicnButton(inStream)
- {
-
- SetMaxValue(1);
- if ((GetValue() != 1) && (GetValue() != 0)) {
- SetValue(1);
- }
- }
-
-
- // ---------------------------------------------------------------------------
- // • ~LCicnCheck
- // ---------------------------------------------------------------------------
- // Destructor
-
- LCicnCheck::~LCicnCheck()
- {
-
- }
-
-
-
- // ---------------------------------------------------------------------------
- // • DrawSelf
- // ---------------------------------------------------------------------------
- // Draw the CicnCheck
-
- void
- LCicnCheck::DrawSelf()
- {
- Rect frame;
- StColorPenState theState;
-
- CalcLocalFrameRect(frame);
-
- theState.Normalize();
-
- if ( GetValue() == 1 ) {
- if (mPushedCicnH == nil) { // Load 'cicn' if necessary
- mPushedCicnH = ::GetCIcon(mPushedID);
- }
-
- if (mPushedCicnH != nil) {
- ::PlotCIcon(&frame, mPushedCicnH);
- }
- }
- else if ( GetValue() == 0 ) {
- if (mNormalCicnH == nil) { // Load 'cicn' if necessary
- mNormalCicnH = ::GetCIcon(mNormalID);
- }
-
- if (mNormalCicnH != nil) {
- ::PlotCIcon(&frame, mNormalCicnH);
- }
- }
- }
-
- void
- LCicnCheck::HotSpotResult(
- short inHotSpot)
- {
- LCicnButton::HotSpotResult( inHotSpot );
- if (GetValue() == 1)
- SetValue(0);
- else if (GetValue() == 0)
- SetValue(1);
- else
- SetValue(1);
-
- Refresh();
-
- }
-