Jay: I hope I am on the mark here with what you are trying to achieve.... I have just constructed a rather tiny app that displays a custom image in the Dock. This custom view is shown in the dock for the app itself when running (not just when minimized). The app icon is *not* shown because I have set a custom content view for the dock tile (nor would any badge be displayed, if set).

The custom view is a class named DockTileView. When the app starts up, I create an instance of this class, and set it as the dockTile's contentView:

DockTileView *myDockTileView = [[[DockTileView alloc] init] autorelease];
        [[NSApp dockTile] setContentView: myDockTileView];
[[NSApp dockTile] display]; // cause the dock tile have the view draw itself


The DockTileView is a trivial subclass of NSView:

@interface DockTileView : NSView {
}

@end


For this proof-of-concept app, the DockTileView just displays some text in the overridden -drawRect method:

@implementation DockTileView

- (void) drawRect:(NSRect)rect
{
        NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
                [NSColor orangeColor], NSForegroundColorAttributeName,
                [NSFont systemFontOfSize:32], NSFontAttributeName,
                nil];
        
        NSString *text = @"Custom\nDock\nTile";
        
NSMutableAttributedString *as = [[NSMutableAttributedString alloc] initWithString:text attributes:attributes];
        
        [as drawInRect:rect];
}

@end

Of course, you can have your custom view draw whatever you'd like (in a 128 x 128 frame).

If the appearance of the view needs to change due to underlying changes in teh state of your app, just issue the -display message to the dockTile:
        [NSApp dockTile] display];
and the contentView object's -drawRect will be called.





_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to