Back to index

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

#include <CIconServicesIcon.h>

List of all members.

Public Types

enum  { class_ID = FOUR_CHAR_CODE('CISC') }

Public Member Functions

 CIconServicesIcon (const SPaneInfo &inPaneInfo, MessageT inValueMessage, OSType inIconType, SInt16 inIconResID)
 CIconServicesIcon (LStream *inStream)
virtual ~CIconServicesIcon ()
virtual void DrawSelf ()
virtual void EnableSelf ()
virtual void DisableSelf ()
SInt16 FindHotSpot (Point inPoint) const
Boolean PointInHotSpot (Point inPoint, SInt16 inHotSpot) const
void HotSpotAction (SInt16 inHotSpot, Boolean inCurrInside, Boolean inPrevInside)
void HotSpotResult (SInt16 inHotSpot)

Protected Member Functions

void Init ()
void AdjustIconRect (Rect &ioRect) const
void GetIconRef ()
void ReleaseIconRef ()

Protected Attributes

OSType mIconType
SInt16 mIconResID
IconAlignmentType mAlignmentType
IconRef mIconRef
bool mbIsPressed

Static Protected Attributes

static OSType mgAppCreator
static FSSpec mgIconFileSpec

Detailed Description

Definition at line 45 of file CIconServicesIcon.h.


Member Enumeration Documentation

anonymous enum
Enumerator:
class_ID 

Definition at line 48 of file CIconServicesIcon.h.

{ class_ID = FOUR_CHAR_CODE('CISC') };

Constructor & Destructor Documentation

CIconServicesIcon::CIconServicesIcon ( const SPaneInfo &  inPaneInfo,
MessageT  inValueMessage,
OSType  inIconType,
SInt16  inIconResID 
)

Definition at line 54 of file CIconServicesIcon.cpp.

                                                                     :
    LControl(inPaneInfo, inValueMessage),
    mIconType(inIconType), mIconResID(inIconResID),
    mAlignmentType(kAlignAbsoluteCenter), mIconRef(nil),
    mbIsPressed(false)
{
    Init();
}

Here is the call graph for this function:

CIconServicesIcon::CIconServicesIcon ( LStream *  inStream)

Definition at line 67 of file CIconServicesIcon.cpp.

                                                           :
    LControl(inStream),
    mAlignmentType(kAlignAbsoluteCenter), mIconRef(nil),
    mbIsPressed(false)
{
    *inStream >> mIconType;
    *inStream >> mIconResID;
    
    Init();
}

Here is the call graph for this function:

Definition at line 79 of file CIconServicesIcon.cpp.

Here is the call graph for this function:


Member Function Documentation

void CIconServicesIcon::AdjustIconRect ( Rect &  ioRect) const [protected]

Definition at line 220 of file CIconServicesIcon.cpp.

{
    SDimension16 frameSize;
    GetFrameSize(frameSize);
    SInt16 iconSize = (frameSize.width <= 16 && frameSize.height <= 16) ? 16 : 32;
    
       ioRect.top += ((ioRect.bottom - ioRect.top) - iconSize) / 2;
       ioRect.left += ((ioRect.right - ioRect.left) - iconSize) / 2;
    ioRect.right = ioRect.left + iconSize;
    ioRect.bottom = ioRect.top + iconSize;
}

Here is the caller graph for this function:

Definition at line 124 of file CIconServicesIcon.cpp.

{
    Refresh();
}

Definition at line 84 of file CIconServicesIcon.cpp.

{
  if (!mIconRef)
    return;
    
       Rect   iconRect;
       CalcLocalFrameRect(iconRect);
    AdjustIconRect(iconRect);
       
       IconTransformType transform;
       if (mbIsPressed)
           transform = kTransformSelected;
       else if (mEnabled != triState_On)
           transform = kTransformDisabled;
       else
           transform = kTransformNone;
       
       // Because the icon may be translucent, clear out the
       // region under it. The icon will draw differently
       // depending on the background. This makes it consistent.
       StRegion cleanRgn;
       if (::IconRefToRgn(cleanRgn,
                          &iconRect,
                          mAlignmentType,
                          kIconServicesNormalUsageFlag,
                       mIconRef) == noErr)
        ::EraseRgn(cleanRgn);
    
    ::PlotIconRef(&iconRect,
                  mAlignmentType,
                  transform,
                  kIconServicesNormalUsageFlag,
                  mIconRef);
}

Here is the call graph for this function:

Definition at line 119 of file CIconServicesIcon.cpp.

{
    Refresh();
}
SInt16 CIconServicesIcon::FindHotSpot ( Point  inPoint) const

Definition at line 129 of file CIconServicesIcon.cpp.

{
         Boolean inHotSpot = PointInHotSpot(inPoint, 0);
         return inHotSpot ? 1 : 0;
}

Here is the call graph for this function:

Definition at line 232 of file CIconServicesIcon.cpp.

{
    // We would like to first see if the icon is already registered
    // But, for some reason, the following call always returns noErr and the wrong icon.
    // err = ::GetIconRef(mgIconFileSpec.vRefNum, mgAppCreator, mIconType, &iconRef);    
    // if (err != noErr)
    ::RegisterIconRefFromResource(mgAppCreator, mIconType, &mgIconFileSpec, mIconResID, &mIconRef);
}

Here is the caller graph for this function:

void CIconServicesIcon::HotSpotAction ( SInt16  inHotSpot,
Boolean  inCurrInside,
Boolean  inPrevInside 
)

Definition at line 148 of file CIconServicesIcon.cpp.

{
       if (inCurrInside != inPrevInside)
       {
           mbIsPressed = inCurrInside;
           Draw(nil);       
    }
}

Here is the call graph for this function:

void CIconServicesIcon::HotSpotResult ( SInt16  inHotSpot)

Definition at line 159 of file CIconServicesIcon.cpp.

{
       BroadcastValueMessage();
}
void CIconServicesIcon::Init ( void  ) [protected]

Definition at line 164 of file CIconServicesIcon.cpp.

{
    static bool gInitialized;
    
    if (!gInitialized)
    {
        OSErr err;
        
        // Since this a part of mozilla, which requires System 8.6,
        // we can be sure of having this. Just in case...
        long response;
        err = ::Gestalt(gestaltIconUtilitiesAttr, &response);
        ThrowIfError_(err);
        if (!(response & gestaltIconUtilitiesHasIconServices))
            Throw_(-12345);
        
        ProcessSerialNumber psn;
        err = ::GetCurrentProcess(&psn);
        ThrowIfError_(err);
        
        ProcessInfoRec info;
        info.processInfoLength = sizeof(info);
        info.processName = nil;
        info.processAppSpec = nil;
        err = ::GetProcessInformation(&psn, &info);
        ThrowIfError_(err);
        mgAppCreator = info.processSignature;
        
        // RegisterIconRefFromResource() needs to be given an FSSpec of
        // the file containing the 'icns' resource of the icon being
        // registered. The following will track down the file no matter
        // how our application is packaged.
        
        StResLoad resLoadState(false);
        StResource resHandle('icns', mIconResID); // throws if N/A
        SInt16 resRefNum = ::HomeResFile(resHandle);
        if (resRefNum != -1)
        {
          FCBPBRec pb;
      
          pb.ioNamePtr = mgIconFileSpec.name;
          pb.ioVRefNum = 0;
          pb.ioRefNum = resRefNum;
          pb.ioFCBIndx = 0;
          err = PBGetFCBInfoSync(&pb);
          if (err == noErr)
          {
              mgIconFileSpec.vRefNum = pb.ioFCBVRefNum;
              mgIconFileSpec.parID = pb.ioFCBParID;
          }
        }
        gInitialized = true;
    }
    GetIconRef();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Boolean CIconServicesIcon::PointInHotSpot ( Point  inPoint,
SInt16  inHotSpot 
) const

Definition at line 135 of file CIconServicesIcon.cpp.

{
  if (!mIconRef)
    return false;
    
       Rect   iconRect;
       CalcLocalFrameRect(iconRect);
    AdjustIconRect(iconRect);

    return ::PtInIconRef(&inPoint, &iconRect, mAlignmentType, kIconServicesNormalUsageFlag, mIconRef);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 241 of file CIconServicesIcon.cpp.

Here is the caller graph for this function:


Member Data Documentation

IconAlignmentType CIconServicesIcon::mAlignmentType [protected]

Definition at line 84 of file CIconServicesIcon.h.

Definition at line 87 of file CIconServicesIcon.h.

Definition at line 89 of file CIconServicesIcon.h.

Definition at line 90 of file CIconServicesIcon.h.

IconRef CIconServicesIcon::mIconRef [protected]

Definition at line 86 of file CIconServicesIcon.h.

SInt16 CIconServicesIcon::mIconResID [protected]

Definition at line 83 of file CIconServicesIcon.h.

Definition at line 82 of file CIconServicesIcon.h.


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