diff --git a/.gitignore b/.gitignore index c66bc35..260e5e3 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,7 @@ EDSidebar.xcodeproj/ernesto.mode1v3 *.xcuserstate project.xcworkspace/ xcuserdata/ - +DerivedData/ # Generated files *.[oa] *.pyc @@ -28,4 +28,5 @@ dist/ build/ # Backup files -*~.nib \ No newline at end of file +*~.nib + diff --git a/BlackCell.h b/BlackCell.h index 5bc71b6..df06eb3 100644 --- a/BlackCell.h +++ b/BlackCell.h @@ -11,6 +11,7 @@ @interface BlackCell : NSButtonCell { + NSShadow *_shadow; } @end diff --git a/BlackCell.m b/BlackCell.m index 9c9f0aa..bf03b06 100644 --- a/BlackCell.m +++ b/BlackCell.m @@ -18,17 +18,26 @@ -(id)init self = [super init]; if ( self ) { + _shadow = [[NSShadow alloc] init] ; + [self setHighlightsBy:NSContentsCellMask]; + } return self; } +#if !__has_feature(objc_arc) +-(void)dealloc +{ + + [_shadow release]; +} +#endif - (void)drawWithFrame:(NSRect)frame inView:(NSView *)view { [[NSColor blackColor] setFill]; NSRectFill(frame); NSImage *img = nil; - NSShadow *shadow = nil; // Just a test. Should handle highlight better if( [self state] == NSOnState ) @@ -43,11 +52,10 @@ - (void)drawWithFrame:(NSRect)frame inView:(NSView *)view { { img = [self image]; // simulate outer glow using a shadow - shadow = [[[NSShadow alloc] init] autorelease]; - [shadow setShadowColor:[NSColor colorWithDeviceRed:115.0/225.0 green:215.0/225.0 blue:245.0/225.0 alpha:1.0] ]; - [shadow setShadowBlurRadius:5]; - [shadow setShadowOffset:NSMakeSize(0, 0)]; //[NSColor colorWithDeviceRed:0.0 green:0.0 blue:0.0 alpha:1.0]; - [shadow set]; + [_shadow setShadowColor:[NSColor colorWithDeviceRed:115.0/225.0 green:215.0/225.0 blue:245.0/225.0 alpha:1.0] ]; + [_shadow setShadowBlurRadius:5]; + [_shadow setShadowOffset:NSMakeSize(0, 0)]; //[NSColor colorWithDeviceRed:0.0 green:0.0 blue:0.0 alpha:1.0]; + [_shadow set]; } NSRect imgRect = NSInsetRect(frame, ( NSWidth(frame) -[img size].width)/2.0, ( NSHeight(frame) -[img size].height)/2.0); [img drawInRect:imgRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0 respectFlipped:YES hints:nil] ; diff --git a/EDSideBar.h b/EDSideBar/EDSideBar.h similarity index 67% rename from EDSideBar.h rename to EDSideBar/EDSideBar.h index cdee74b..448c346 100644 --- a/EDSideBar.h +++ b/EDSideBar/EDSideBar.h @@ -10,7 +10,13 @@ @class EDSideBar; - +#if __has_feature(objc_arc) +#define EDSideBarRetain nonatomic, strong +#define EDSideBarAssign nonatomic, unsafe_unretained +#else +#define EDSideBarRetain nonatomic, retain +#define EDSideBarAssign nonatomic, assign +#endif @protocol EDSideBarDelegate @required @@ -47,11 +53,11 @@ typedef NSUInteger ECSideBarLayoutMode; -(void)setSelectionImage:(NSImage*)image; -(id)cellForItem:(NSInteger)index; -@property (nonatomic,retain) NSColor *backgroundColor; -@property (nonatomic,retain) idsidebarDelegate; -@property (nonatomic,retain,setter=setCellClass:) Class cellClass; -@property (setter=setLayoutMode:) ECSideBarLayoutMode layoutMode; -@property (setter=setButtonsHeight:) CGFloat buttonsHeight; +@property (EDSideBarRetain) NSColor *backgroundColor; +@property (EDSideBarRetain) idsidebarDelegate; +@property (EDSideBarAssign,setter=setCellClass:) Class cellClass; +@property (nonatomic, setter=setLayoutMode:) ECSideBarLayoutMode layoutMode; +@property (nonatomic, setter=setButtonsHeight:) CGFloat buttonsHeight; @property BOOL animateSelection; @property NSTimeInterval animationDuration; @end diff --git a/EDSideBar.m b/EDSideBar/EDSideBar.m similarity index 98% rename from EDSideBar.m rename to EDSideBar/EDSideBar.m index 0137f26..2001b1d 100644 --- a/EDSideBar.m +++ b/EDSideBar/EDSideBar.m @@ -30,7 +30,9 @@ - (void)setTextColor:(NSColor *)textColor range:range]; [attrTitle fixAttributesInRange:range]; [self setAttributedTitle:attrTitle]; +#if !__has_feature(objc_arc) [attrTitle release]; +#endif } -(id)init { @@ -111,9 +113,9 @@ - (void)drawBezelWithFrame:(NSRect)frame inView:(NSView *)view { NSRect rectGradient = NSMakeRect(0-0.5, NSMinY(frame)-1-0.5, NSWidth(frame)-1, 4.0); NSBezierPath *path = [NSBezierPath bezierPathWithRect:rectGradient]; [gradient drawInBezierPath:path angle:90]; - +#if !__has_feature(objc_arc) [gradient release]; - +#endif } // Inset in the right @@ -180,13 +182,14 @@ - (id)initWithFrame:(NSRect)frame { } return self; } - -(void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; +#if !__has_feature(objc_arc) [_backgroundColor dealloc]; [_matrix dealloc]; [super dealloc]; +#endif } -(void)drawBackground:(NSRect)rect @@ -205,8 +208,8 @@ - (void)drawRect:(NSRect)dirtyRect { -(void)selectButtonAtRow:(NSUInteger)row { - int rowToSelect = row; - if( row <0 || [_matrix numberOfRows]< row ) + NSUInteger rowToSelect = row; + if( [_matrix numberOfRows]< row ) rowToSelect =0; [_matrix setState:(NSInteger)NSOnState atRow:(NSInteger)rowToSelect column:(NSInteger)0]; [self moveSelectionImage]; diff --git a/EDSidebar.xcodeproj/project.pbxproj b/EDSidebar.xcodeproj/project.pbxproj index 9bb6b12..f150ff3 100644 --- a/EDSidebar.xcodeproj/project.pbxproj +++ b/EDSidebar.xcodeproj/project.pbxproj @@ -8,16 +8,16 @@ /* Begin PBXBuildFile section */ 1DDD58160DA1D0A300B32029 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDD58140DA1D0A300B32029 /* MainMenu.xib */; }; - 256AC3DA0F4B6AC300CF3369 /* EDSidebarAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 256AC3D90F4B6AC300CF3369 /* EDSidebarAppDelegate.m */; }; + 256AC3DA0F4B6AC300CF3369 /* EDSidebarAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 256AC3D90F4B6AC300CF3369 /* EDSidebarAppDelegate.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; }; - 8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; }; + 8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); COMPILER_FLAGS = "-fno-objc-arc"; }; }; 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; - 94B2BB8C14235019000FACDD /* EDSideBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 94B2BB8B14235019000FACDD /* EDSideBar.m */; }; 94B2BE9F1423BD86000FACDD /* icon1-white.png in Resources */ = {isa = PBXBuildFile; fileRef = 94B2BE9D1423BD86000FACDD /* icon1-white.png */; }; 94B2BEA01423BD86000FACDD /* icon1-gray.png in Resources */ = {isa = PBXBuildFile; fileRef = 94B2BE9E1423BD86000FACDD /* icon1-gray.png */; }; 94B2BF231423C272000FACDD /* BlackCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 94B2BF221423C272000FACDD /* BlackCell.m */; }; 94B2BF371423C4BB000FACDD /* blue.png in Resources */ = {isa = PBXBuildFile; fileRef = 94B2BF361423C4BB000FACDD /* blue.png */; }; 94B2BF431423C574000FACDD /* icon1-blue.png in Resources */ = {isa = PBXBuildFile; fileRef = 94B2BF421423C574000FACDD /* icon1-blue.png */; }; + 94E699161467F4BD00AFBE8A /* EDSideBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 94E699151467F4BD00AFBE8A /* EDSideBar.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -33,14 +33,14 @@ 29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; 8D1107310486CEB800E47090 /* EDSidebar-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "EDSidebar-Info.plist"; sourceTree = ""; }; 8D1107320486CEB800E47090 /* EDSidebar.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = EDSidebar.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 94B2BB8A14235019000FACDD /* EDSideBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EDSideBar.h; sourceTree = ""; }; - 94B2BB8B14235019000FACDD /* EDSideBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EDSideBar.m; sourceTree = ""; }; 94B2BE9D1423BD86000FACDD /* icon1-white.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon1-white.png"; sourceTree = ""; }; 94B2BE9E1423BD86000FACDD /* icon1-gray.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon1-gray.png"; sourceTree = ""; }; 94B2BF211423C272000FACDD /* BlackCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlackCell.h; sourceTree = ""; }; 94B2BF221423C272000FACDD /* BlackCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BlackCell.m; sourceTree = ""; }; 94B2BF361423C4BB000FACDD /* blue.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = blue.png; sourceTree = ""; }; 94B2BF421423C574000FACDD /* icon1-blue.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon1-blue.png"; sourceTree = ""; }; + 94E699141467F4BD00AFBE8A /* EDSideBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EDSideBar.h; sourceTree = ""; }; + 94E699151467F4BD00AFBE8A /* EDSideBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EDSideBar.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -95,7 +95,7 @@ 29B97314FDCFA39411CA2CEA /* EDSidebar */ = { isa = PBXGroup; children = ( - 94B2BB891423500E000FACDD /* Sidebar */, + 94E699131467F4BD00AFBE8A /* EDSideBar */, 080E96DDFE201D6D7F000001 /* Classes */, 29B97315FDCFA39411CA2CEA /* Other Sources */, 29B97317FDCFA39411CA2CEA /* Resources */, @@ -137,13 +137,13 @@ name = Frameworks; sourceTree = ""; }; - 94B2BB891423500E000FACDD /* Sidebar */ = { + 94E699131467F4BD00AFBE8A /* EDSideBar */ = { isa = PBXGroup; children = ( - 94B2BB8A14235019000FACDD /* EDSideBar.h */, - 94B2BB8B14235019000FACDD /* EDSideBar.m */, + 94E699141467F4BD00AFBE8A /* EDSideBar.h */, + 94E699151467F4BD00AFBE8A /* EDSideBar.m */, ); - name = Sidebar; + path = EDSideBar; sourceTree = ""; }; /* End PBXGroup section */ @@ -214,8 +214,8 @@ files = ( 8D11072D0486CEB800E47090 /* main.m in Sources */, 256AC3DA0F4B6AC300CF3369 /* EDSidebarAppDelegate.m in Sources */, - 94B2BB8C14235019000FACDD /* EDSideBar.m in Sources */, 94B2BF231423C272000FACDD /* BlackCell.m in Sources */, + 94E699161467F4BD00AFBE8A /* EDSideBar.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -245,6 +245,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ENABLE_OBJC_ARC = YES; COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_FIX_AND_CONTINUE = YES; @@ -252,8 +253,10 @@ GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = EDSidebar_Prefix.pch; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; INFOPLIST_FILE = "EDSidebar-Info.plist"; INSTALL_PATH = "$(HOME)/Applications"; + MACOSX_DEPLOYMENT_TARGET = 10.6; PRODUCT_NAME = EDSidebar; }; name = Debug; @@ -262,12 +265,15 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ENABLE_OBJC_ARC = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = EDSidebar_Prefix.pch; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; INFOPLIST_FILE = "EDSidebar-Info.plist"; INSTALL_PATH = "$(HOME)/Applications"; + MACOSX_DEPLOYMENT_TARGET = 10.6; PRODUCT_NAME = EDSidebar; }; name = Release; @@ -282,7 +288,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; ONLY_ACTIVE_ARCH = YES; PREBINDING = NO; - SDKROOT = macosx10.6; + SDKROOT = macosx; }; name = Debug; }; @@ -294,7 +300,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PREBINDING = NO; - SDKROOT = macosx10.6; + SDKROOT = macosx; }; name = Release; }; diff --git a/EDSidebarAppDelegate.m b/EDSidebarAppDelegate.m index 0114af7..c9f420f 100644 --- a/EDSidebarAppDelegate.m +++ b/EDSidebarAppDelegate.m @@ -69,9 +69,9 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { } -(void)sideBar:(EDSideBar*)tabBar didSelectButton:(NSInteger)button { - NSString *str = [NSString stringWithFormat:@"Selected button #%d in %@", + NSString *str = [NSString stringWithFormat:@"Selected button #%lu in %@", button, [tabBar isEqualTo:sideBarBlack]?@"Right sidebar":@"Left sidebar"]; - NSLog(@"Button selected: %d", button ); + NSLog(@"Button selected: %lu", button ); [textField setStringValue:str]; }