home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-20 | 1.6 KB | 118 lines | [TEXT/CWIE] |
- #pragma once
- /*
- File: LCursor.cp
-
- Contains: Base cursor class.
- LCursor framework.
-
- Copyright: ©1995 Chris K. Thomas. All Rights Reserved.
-
- Version: 2.1
- */
-
- #include "LCursor.h"
-
- //
- // • static member variables
- //
-
- Boolean LCursor::sCursorLocked = false;
- LCursor *LCursor::sCurrentCursor = NULL;
-
- //
- // construct
- //
- LCursor::LCursor(UInt16 inCursorID)
- {
- mIsColor = false;
- if(inCursorID == 0)
- {
- mCursorHandle = NULL;
- }
- else
- {
- short resLoad = ::LMGetResLoad();
-
- //
- // ≠ mess to check whether or not a color version of the
- // cursor exists
- //
-
- ::SetResLoad(false);
- mCursorHandle = ::GetResource('crsr', inCursorID);
- ::SetResLoad(resLoad);
- if(mCursorHandle)
- {
- mIsColor = true;
- ::ReleaseResource(mCursorHandle);
- //
- // ≠ end mess
- //
-
- mCursorHandle = (Handle)::GetCCursor(inCursorID);
- }
- else
- mCursorHandle = ::GetResource('CURS', inCursorID);
-
- ThrowIfResError_();
- Assert_(mCursorHandle);
- }
-
- }
-
- LCursor::~LCursor()
- {
- if(mCursorHandle)
- {
- if(!mIsColor)
- ::ReleaseResource(mCursorHandle);
- else
- ::DisposeCCursor((CCrsrHandle)mCursorHandle);
- }
-
- if(sCurrentCursor == this)
- {
- sCurrentCursor = NULL;
- }
- }
-
-
- //
- // use
- //
-
- void
- LCursor::Set()
- {
- if(mCursorHandle)
- {
- HLockHi((Handle)mCursorHandle);
-
- //
- // take care of the previously current cursor
- //
- if(sCurrentCursor)
- sCurrentCursor->Unset();
-
- sCurrentCursor = this;
-
- if(!mIsColor)
- SetCursor(*(CursHandle)mCursorHandle);
- else
- SetCCursor((CCrsrHandle)mCursorHandle);
- }
- else
- {
- InitCursor();
- }
- }
-
- void
- LCursor::Unset()
- {
- if(mCursorHandle)
- {
- HUnlock((Handle)mCursorHandle);
- }
- }
-