X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fmacosx%2Fmisc.m;h=3a033f820aed22e43137cceaba0b5a8dbccd8d9e;hb=8a5d95d032dd1d3773858ece1d5efe2f970d6bab;hp=a4deccee74cebd3275c120d88890ece52ddb6af2;hpb=f2b2e37c04b2921e29daa3260dc696646ad4f10c;p=vlc diff --git a/modules/gui/macosx/misc.m b/modules/gui/macosx/misc.m index a4deccee74..3a033f820a 100644 --- a/modules/gui/macosx/misc.m +++ b/modules/gui/macosx/misc.m @@ -30,6 +30,59 @@ #import "playlist.h" #import "controls.h" +/***************************************************************************** + * NSImage (VLCAdditions) + * + * Addition to NSImage + *****************************************************************************/ +@implementation NSImage (VLCAdditions) ++ (id)imageWithSystemName:(int)name +{ + /* ugly Carbon stuff following... + * regrettably, you can't get the icons through clean Cocoa */ + + /* retrieve our error icon */ + NSImage * icon; + IconRef ourIconRef; + int returnValue; + returnValue = GetIconRef(kOnSystemDisk, 'macs', name, &ourIconRef); + icon = [[[NSImage alloc] initWithSize:NSMakeSize(32,32)] autorelease]; + [icon lockFocus]; + CGRect rect = CGRectMake(0,0,32,32); + PlotIconRefInContext((CGContextRef)[[NSGraphicsContext currentContext] + graphicsPort], + &rect, + kAlignNone, + kTransformNone, + NULL /*inLabelColor*/, + kPlotIconRefNormalFlags, + (IconRef)ourIconRef); + [icon unlockFocus]; + returnValue = ReleaseIconRef(ourIconRef); + return icon; +} + ++ (id)imageWithWarningIcon +{ + static NSImage * imageWithWarningIcon = nil; + if( !imageWithWarningIcon ) + { + imageWithWarningIcon = [[[self class] imageWithSystemName:'caut'] retain]; + } + return imageWithWarningIcon; +} + ++ (id)imageWithErrorIcon +{ + static NSImage * imageWithErrorIcon = nil; + if( !imageWithErrorIcon ) + { + imageWithErrorIcon = [[[self class] imageWithSystemName:'stop'] retain]; + } + return imageWithErrorIcon; +} + +@end /***************************************************************************** * NSAnimation (VLCAdditions) *