Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
CThrobber Class Reference

#include <CThrobber.h>

List of all members.

Public Types

enum  { class_ID = FOUR_CHAR_CODE('Thrb') }

Public Member Functions

 CThrobber ()
 CThrobber (LStream *inStream)
virtual ~CThrobber ()
virtual void FinishCreateSelf ()
virtual void ShowSelf ()
virtual void HideSelf ()
virtual void DrawSelf ()
void ResizeFrameBy (SInt16 inWidthDelta, SInt16 inHeightDelta, Boolean inRefresh)
void MoveBy (SInt32 inHorizDelta, SInt32 inVertDelta, Boolean inRefresh)
virtual void SpendTime (const EventRecord &inMacEvent)
virtual void Start ()
virtual void Stop ()

Protected Member Functions

void CreateMovie ()

Protected Attributes

SInt16 mMovieResID
Handle mMovieHandle
Movie mMovie
MovieController mMovieController

Detailed Description

Definition at line 49 of file CThrobber.h.


Member Enumeration Documentation

anonymous enum
Enumerator:
class_ID 

Definition at line 53 of file CThrobber.h.

{ class_ID = FOUR_CHAR_CODE('Thrb') };

Constructor & Destructor Documentation

Definition at line 53 of file CThrobber.cpp.

CThrobber::CThrobber ( LStream *  inStream)

Definition at line 60 of file CThrobber.cpp.

                                      :
   LControl(inStream),
   mMovieResID(-1), mMovieHandle(nil),
   mMovie(nil), mMovieController(nil)
{
   *inStream >> mMovieResID;
}
CThrobber::~CThrobber ( ) [virtual]

Definition at line 69 of file CThrobber.cpp.

{
    if (mMovieController)
        ::DisposeMovieController(mMovieController);
    if (mMovieHandle)
        ::DisposeHandle(mMovieHandle);   
}

Member Function Documentation

void CThrobber::CreateMovie ( ) [protected]

Definition at line 180 of file CThrobber.cpp.

{
    OSErr err;
    Handle dataRef = NULL;
        
    try {
        // Get the movie from our resource
        StApplicationContext appResContext;
        
        mMovieHandle = ::Get1Resource('GIF ', 128);
        ThrowIfResFail_(mMovieHandle);
        ::DetachResource(mMovieHandle);
        
        // Create a dataRef handle - from TN2018
       err = ::PtrToHand(&mMovieHandle, &dataRef, sizeof(Handle));
       ThrowIfError_(err);
       err = ::PtrAndHand("\p", dataRef, 1); 
       ThrowIfError_(err);
        long  fileTypeAtom[3];
       fileTypeAtom[0] = sizeof(long) * 3;
       fileTypeAtom[1] = kDataRefExtensionMacOSFileType;
       fileTypeAtom[2] = kQTFileTypeGIF;
       err = ::PtrAndHand(fileTypeAtom, dataRef, sizeof(long) * 3);
       ThrowIfError_(err);
       
       err = ::NewMovieFromDataRef(&mMovie, newMovieActive, NULL, dataRef, HandleDataHandlerSubType);
        ThrowIfError_(err);
       DisposeHandle(dataRef);
       dataRef = NULL;
       
       // Make a controller for the movie
       Rect   movieBounds;
       ::GetMovieBox(mMovie, &movieBounds);
       ::MacOffsetRect(&movieBounds, (SInt16) -movieBounds.left, (SInt16) -movieBounds.top);
       ::SetMovieBox(mMovie, &movieBounds);

       ::SetMovieGWorld(mMovie, (CGrafPtr) GetMacPort(), nil);

       Rect   frame;
       CalcLocalFrameRect(frame);
       mMovieController = ::NewMovieController(mMovie, &frame, mcTopLeftMovie + mcNotVisible);
        
       ::MCDoAction(mMovieController, mcActionSetLooping, (void *)1);
       ::MCMovieChanged(mMovieController, mMovie);
    }
    catch (...) {
        if (dataRef)
            DisposeHandle(dataRef);
        
        // Don't rethrow
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CThrobber::DrawSelf ( ) [virtual]

Definition at line 107 of file CThrobber.cpp.

{
    if (mMovieController)
        ::MCDraw(mMovieController, GetMacWindow());
}

Definition at line 78 of file CThrobber.cpp.

{
   CreateMovie();
}

Here is the call graph for this function:

void CThrobber::HideSelf ( ) [virtual]

Definition at line 95 of file CThrobber.cpp.

{
    LControl::HideSelf();
    
    if (!mMovieController)
        return;    
    
    StRegion emptyRgn;
    ::MCSetClip(mMovieController, NULL, emptyRgn);
}
void CThrobber::MoveBy ( SInt32  inHorizDelta,
SInt32  inVertDelta,
Boolean  inRefresh 
)

Definition at line 133 of file CThrobber.cpp.

{
       LControl::MoveBy(inHorizDelta, inVertDelta, inRefresh);

       if (!mMovieController)
           return;
 
       FocusDraw();
 
       Rect newFrame;       
       ::MCGetControllerBoundsRect(mMovieController, &newFrame);
       ::OffsetRect(&newFrame, inHorizDelta, inVertDelta);
       ::MCSetControllerBoundsRect(mMovieController, &newFrame);
}
void CThrobber::ResizeFrameBy ( SInt16  inWidthDelta,
SInt16  inHeightDelta,
Boolean  inRefresh 
)

Definition at line 114 of file CThrobber.cpp.

{
       LControl::ResizeFrameBy(inWidthDelta, inHeightDelta, inRefresh);
       
       if (!mMovieController)
           return;
           
       FocusDraw();

       Rect newFrame;
       ::MCGetControllerBoundsRect(mMovieController, &newFrame);
       newFrame.right += inWidthDelta;
       newFrame.bottom += inHeightDelta;
       ::MCSetControllerBoundsRect(mMovieController, &newFrame);
}
void CThrobber::ShowSelf ( ) [virtual]

Definition at line 84 of file CThrobber.cpp.

{
    LControl::ShowSelf();
    
    if (!mMovieController)
        return;
    
    ::MCSetClip(mMovieController, NULL, NULL);
}
void CThrobber::SpendTime ( const EventRecord &  inMacEvent) [virtual]

Definition at line 151 of file CThrobber.cpp.

{
       FocusDraw();
       ::MCIsPlayerEvent(mMovieController, &inMacEvent);
}
void CThrobber::Start ( ) [virtual]

Definition at line 158 of file CThrobber.cpp.

{
       if (!mMovieController)
           return;
 
    ::StartMovie(mMovie);
    StartRepeating();
}
void CThrobber::Stop ( void  ) [virtual]

Definition at line 168 of file CThrobber.cpp.

{
       if (!mMovieController)
           return;
 
    StopRepeating();
    ::StopMovie(mMovie);
    ::GoToBeginningOfMovie(mMovie);
    Refresh();
}

Member Data Documentation

Movie CThrobber::mMovie [protected]

Definition at line 86 of file CThrobber.h.

MovieController CThrobber::mMovieController [protected]

Definition at line 87 of file CThrobber.h.

Handle CThrobber::mMovieHandle [protected]

Definition at line 85 of file CThrobber.h.

SInt16 CThrobber::mMovieResID [protected]

Definition at line 84 of file CThrobber.h.


The documentation for this class was generated from the following files: