Revision: 49
                            
                                                            
                                    
                                        
Updated Code
                                    
                                    
                                                    
                        at June 29, 2006 04:42 by xaviaracil
                            
                            Updated Code
-(void) updateApplicationIcon:(int) theNumber:(NSRect) theRect{
	// get the current app icon
	NSImage *appImage = [NSImage imageNamed:@"NSApplicationIcon"];
	
	// create a new image and draw the app icon onto it
	NSImage *image = [[NSImage alloc] initWithSize:[appImage size]];
	
	// lock focus on the new image and draw the app icon onto it.
	// you'll want the image flipped so text shows up correctly
	[image setFlipped:TRUE];
	[image lockFocus];
	NSSize appSize = [appImage size];	
	[appImage compositeToPoint:NSMakePoint(0, appSize.height) 
					 operation:NSCompositeSourceOver];
	
	// draw red circle
	NSBezierPath *redCircle = [NSBezierPath bezierPathWithOvalInRect:NSMakeRect(8,43,45,45)];
	[[NSColor redColor] setFill];
	[redCircle fill];
	
	// draw whatever else you want onto the image
	NSArray *values = [NSArray arrayWithObjects:[NSColor whiteColor], [NSFont fontWithName:@"Tahoma" size:32], nil];
	NSArray *keys = [NSArray arrayWithObjects:NSForegroundColorAttributeName, NSFontAttributeName, nil];
	
	NSDictionary *attrs = [NSDictionary dictionaryWithObjects:values forKeys:keys];
	NSString *caption= [NSString stringWithFormat:@"%d", theNumber];
	NSAttributedString *text= [[NSAttributedString alloc] initWithString:caption attributes:attrs];
	[text drawInRect:theRect];
	
	// unlock focus and set the new image as the dock icon
	[image unlockFocus];
	[NSApp setApplicationIconImage:image];
}
                                
                            Revision: 48
                            
                                                            
                                    
                                        
Initial Code
                                    
                                    
                                                            
                                    
                                        
Initial URL
                                    
                                    
                                
                                                            
                                    
                                        
Initial Description
                                    
                                    
                                                            
                                    
                                        
Initial Title
                                    
                                    
                                                            
                                    
                                        
Initial Tags
                                    
                                    
                                
                                                            
                                    
                                        
Initial Language
                                    
                                    
                                                    
                        at June 29, 2006 04:15 by xaviaracil
                            
                            Initial Code
-(void) updateApplicationIcon{
	// get the current app icon
	NSImage *appImage = [NSImage imageNamed:@"NSApplicationIcon"];
	
	// create a new image and draw the app icon onto it
	NSImage *image = [[NSImage alloc] initWithSize:[appImage size]];
	
	// lock focus on the new image and draw the app icon onto it.
	// you'll want the image flipped so text shows up correctly
	[image setFlipped:TRUE];
	[image lockFocus];
	NSSize appSize = [appImage size];	
	[appImage compositeToPoint:NSMakePoint(0, appSize.height) 
					 operation:NSCompositeSourceOver];
	
	// draw red circle
	NSBezierPath *redCircle = [NSBezierPath bezierPathWithOvalInRect:NSMakeRect(8,43,45,45)];
	[[NSColor redColor] setFill];
	[redCircle fill];
	
	// draw whatever else you want onto the image
	NSArray *values = [NSArray arrayWithObjects:[NSColor whiteColor], [NSFont fontWithName:@"Tahoma" size:32], nil];
	NSArray *keys = [NSArray arrayWithObjects:NSForegroundColorAttributeName, NSFontAttributeName, nil];
	
	NSDictionary *attrs = [NSDictionary dictionaryWithObjects:values forKeys:keys];
	NSString *caption= [NSString stringWithFormat:@"%d", newMessages];
	NSAttributedString *text= [[NSAttributedString alloc] initWithString:caption attributes:attrs];
	NSRect theRect = NSMakeRect(22,36,50,50);
	if (newMessages > 9){
		theRect = NSMakeRect(13,36,50,50);
	}
	[text drawInRect:theRect];
	
	// unlock focus and set the new image as the dock icon
	[image unlockFocus];
	[NSApp setApplicationIconImage:image];
}
                                Initial URL
Initial Description
El texto en blanco viene definido por el parámetro theNumber. La posición del texto viene definido por el parámetro theRect
Initial Title
Añade un cÃrculo rojo con un texto en blanco al icono de la aplicación en el dock
Initial Tags
Initial Language
Objective C