Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
nsCursorManager Class Reference

Singleton service provides access to all cursors available in the application. More...

#import <nsCursorManager.h>

List of all members.

Public Member Functions

(void- setCursor:
 setCursor: Sets the current cursor.
(id- init [implementation]
(void- dealloc [implementation]

Static Public Member Functions

(nsCursorManager *) + sharedInstance
 sharedInstance Get the Singleton instance of the cursor manager.
(void+ dispose
 dispose Releases the shared instance of the cursor manager.

Private Member Functions

(nsMacCursor *) - getCursor: [implementation]

Static Private Member Functions

(nsMacCursor *) + createCursor: [implementation]
(nsMacCursor *) + createNSCursor:orThemeCursor: [implementation]
(nsMacCursor *) + createNSCursor:orImageCursor:withHotspot: [implementation]

Private Attributes

NSMutableDictionary * mCursors
nsCursor mCurrentCursor

Detailed Description

Singleton service provides access to all cursors available in the application.

Use nsCusorManager to set the current cursor using an XP nsCusor enum value. nsCursorManager encapsulates the details of setting different types of cursors, animating cursors and cleaning up cursors when they are no longer in use.

Definition at line 46 of file nsCursorManager.h.


Member Function Documentation

+ (nsMacCursor *) createCursor: (enum nsCursor aCursor [implementation]

Definition at line 124 of file nsCursorManager.mm.

                              : (enum nsCursor) aCursor 
{
  switch(aCursor)
  {
    case eCursor_standard:
      return [nsMacCursor cursorWithCursor: [NSCursor arrowCursor]];
    case eCursor_wait:
      return [nsMacCursor cursorWithThemeCursor: kThemeWatchCursor];
    case eCursor_select:              
      return [nsMacCursor cursorWithCursor: [NSCursor IBeamCursor]];
    case eCursor_hyperlink:
      return [nsCursorManager createNSCursor: @selector(pointingHandCursor) orThemeCursor: kThemePointingHandCursor];                  
    case eCursor_crosshair:
      return [nsCursorManager createNSCursor: @selector(crosshairCursor) orThemeCursor: kThemeCrossCursor];                                        
    case eCursor_move:
      return [nsCursorManager createNSCursor: @selector(openHandCursor) orThemeCursor: kThemeOpenHandCursor];                   
    case eCursor_help:
      return [nsMacCursor cursorWithImageNamed: @"help" hotSpot: NSMakePoint(1,1)];        
    case eCursor_copy:
      return [nsMacCursor cursorWithThemeCursor: kThemeCopyArrowCursor];
    case eCursor_alias:
      return [nsMacCursor cursorWithThemeCursor: kThemeAliasArrowCursor];
    case eCursor_context_menu:
      return [nsMacCursor cursorWithThemeCursor: kThemeContextualMenuArrowCursor];

    case eCursor_cell:
      return [nsMacCursor cursorWithThemeCursor: kThemePlusCursor];
    case eCursor_grab:
      return [nsCursorManager createNSCursor: @selector(openHandCursor) orThemeCursor: kThemeOpenHandCursor];
    case eCursor_grabbing:
      return [nsCursorManager createNSCursor: @selector(closedHandCursor) orThemeCursor: kThemeClosedHandCursor];
    case eCursor_spinning:
      return [nsMacCursor cursorWithResources: 200 lastFrame: 203]; // better than kThemeSpinningCursor        
    case eCursor_zoom_in:
      return [nsMacCursor cursorWithImageNamed: @"zoomIn" hotSpot: NSMakePoint(6,6)];
    case eCursor_zoom_out:
      return [nsMacCursor cursorWithImageNamed: @"zoomOut" hotSpot: NSMakePoint(6,6)];
    case eCursor_vertical_text:
      return [nsMacCursor cursorWithImageNamed: @"vtIBeam" hotSpot: NSMakePoint(7,8)];
    case eCursor_all_scroll:
      return [nsCursorManager createNSCursor: @selector(openHandCursor) orThemeCursor: kThemeOpenHandCursor];                   
    case eCursor_not_allowed:
    case eCursor_no_drop:
      return [nsMacCursor cursorWithThemeCursor: kThemeNotAllowedCursor];

    // Resize Cursors:
    //North
    case eCursor_n_resize:
        return [nsCursorManager createNSCursor: @selector(resizeUpCursor) orImageCursor: @"arrowN" withHotspot: NSMakePoint(7,7)];
    //North East
    case eCursor_ne_resize:
        return [nsMacCursor cursorWithImageNamed: @"sizeNE" hotSpot: NSMakePoint(8,7)];
    //East
    case eCursor_e_resize:        
        return [nsCursorManager createNSCursor: @selector(resizeRightCursor) orThemeCursor: kThemeResizeRightCursor];
    //South East
    case eCursor_se_resize:
        return [nsMacCursor cursorWithImageNamed: @"sizeSE" hotSpot: NSMakePoint(8,8)];
    //South
    case eCursor_s_resize:
        return [nsCursorManager createNSCursor: @selector(resizeDownCursor) orImageCursor: @"arrowS" withHotspot: NSMakePoint(7,7)];
    //South West
    case eCursor_sw_resize:
        return [nsMacCursor cursorWithImageNamed: @"sizeSW" hotSpot: NSMakePoint(6,8)];
    //West
    case eCursor_w_resize:
        return [nsCursorManager createNSCursor: @selector(resizeLeftCursor) orThemeCursor: kThemeResizeLeftCursor];
    //North West
    case eCursor_nw_resize:
        return [nsMacCursor cursorWithImageNamed: @"sizeNW" hotSpot: NSMakePoint(7,7)];
    //North & South
    case eCursor_ns_resize:
        return [nsCursorManager createNSCursor: @selector(resizeUpDownCursor) orImageCursor: @"sizeNS" withHotspot: NSMakePoint(7,7)];                         
    //East & West
    case eCursor_ew_resize:
        return [nsCursorManager createNSCursor: @selector(resizeLeftRightCursor) orThemeCursor: kThemeResizeLeftRightCursor];                  
    //North East & South West
    case eCursor_nesw_resize:
        return [nsMacCursor cursorWithImageNamed: @"sizeNESW" hotSpot: NSMakePoint(8,8)];
    //North West & South East        
    case eCursor_nwse_resize:
        return [nsMacCursor cursorWithImageNamed: @"sizeNWSE" hotSpot: NSMakePoint(8,8)];
    //Column Resize
    case eCursor_col_resize:
        return [nsMacCursor cursorWithImageNamed: @"colResize" hotSpot: NSMakePoint(8,8)];
    //Row Resize        
    case eCursor_row_resize:
        return [nsMacCursor cursorWithImageNamed: @"rowResize" hotSpot: NSMakePoint(8,8)];
    default:
      return [nsMacCursor cursorWithCursor: [NSCursor arrowCursor]];
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

+ (nsMacCursor *) createNSCursor: (SEL)  aPantherCursor
orImageCursor: (NSString *)  aImageName
withHotspot: (NSPoint)  aPoint 
[implementation]

Definition at line 223 of file nsCursorManager.mm.

                                : (SEL) aPantherCursor orImageCursor: (NSString *) aImageName withHotspot: (NSPoint) aPoint
{
  return isPantherOrLater() ?      [nsMacCursor cursorWithCursor: [NSCursor performSelector: aPantherCursor]] :
                                [nsMacCursor cursorWithImageNamed: aImageName hotSpot: aPoint];
}

Here is the call graph for this function:

Here is the caller graph for this function:

+ (nsMacCursor *) createNSCursor: (SEL)  aPantherCursor
orThemeCursor: (ThemeCursor)  aJaguarCursor 
[implementation]

Definition at line 217 of file nsCursorManager.mm.

                                : (SEL) aPantherCursor orThemeCursor: (ThemeCursor) aJaguarCursor
{
  return isPantherOrLater() ?   [nsMacCursor cursorWithCursor: [NSCursor performSelector: aPantherCursor]] :
                                [nsMacCursor cursorWithThemeCursor: aJaguarCursor];
}

Here is the call graph for this function:

Here is the caller graph for this function:

- (void) dealloc [implementation]

Definition at line 259 of file nsCursorManager.mm.

{
  [[self getCursor: mCurrentCursor] unset];
  [mCursors release];    
  [super dealloc];    
}

Here is the call graph for this function:

dispose Releases the shared instance of the cursor manager.

Use dispose to clean up the cursor manager and associated cursors.

Definition at line 118 of file nsCursorManager.mm.

{
  [gInstance release];
  gInstance = nil;
}
- (nsMacCursor *) getCursor: (enum nsCursor aCursor [implementation]

Definition at line 248 of file nsCursorManager.mm.

                           : (enum nsCursor) aCursor
{
  nsMacCursor * result = [mCursors objectForKey: [NSNumber numberWithInt: aCursor]];
  if ( result == nil ) 
  {
    result = [nsCursorManager createCursor: aCursor];
    [mCursors setObject: result forKey: [NSNumber numberWithInt: aCursor]];
  }
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

- (id) init [implementation]

Definition at line 229 of file nsCursorManager.mm.

{
  if ( (self = [super init]) ) 
  {
    mCursors = [[NSMutableDictionary alloc] initWithCapacity: 25];
  }
  return self;
}
- (void) setCursor: (nsCursor aCursor

setCursor: Sets the current cursor.

Sets the current cursor to the cursor indicated by the XP cursor constant given as an argument. Resources associated with the previous cursor are cleaned up.

Parameters:
aCursorthe cursor to use

Definition at line 238 of file nsCursorManager.mm.

                  : (enum nsCursor) aCursor
{
  if (aCursor != mCurrentCursor)
  {
    [[self getCursor: mCurrentCursor] unset];
    [[self getCursor: aCursor] set];
    mCurrentCursor = aCursor;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

sharedInstance Get the Singleton instance of the cursor manager.

Use this method to obtain a reference to the cursor manager.

Returns:
a reference to the cursor manager

Definition at line 109 of file nsCursorManager.mm.

{
  if (gInstance == nil)
  {
    gInstance = [[nsCursorManager alloc] init];
  }
  return gInstance;
}

Here is the caller graph for this function:


Member Data Documentation

- (nsCursor) mCurrentCursor [private]

Definition at line 50 of file nsCursorManager.h.

- (NSMutableDictionary*) mCursors [private]

Definition at line 49 of file nsCursorManager.h.


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