diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0b627ca --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.DS_Store +build +*.mode1v3 +*.pbxuser +project.xcworkspace +xcuserdata +.svn diff --git a/DMTabBar/DMTabBar/DMTabBar.m b/DMTabBar/DMTabBar/DMTabBar.m index cf63abb..d0bcf97 100644 --- a/DMTabBar/DMTabBar/DMTabBar.m +++ b/DMTabBar/DMTabBar/DMTabBar.m @@ -140,7 +140,7 @@ - (void) setTabBarItems:(NSArray *)newTabBarItems { [self.tabBarItems enumerateObjectsUsingBlock:^(DMTabBarItem * tabBarItem, NSUInteger idx, BOOL *stop) { NSButton *itemButton = tabBarItem.tabBarItemButton; itemButton.frame = NSMakeRect(0.0f, 0.0f, kDMTabBarItemWidth, NSHeight(self.bounds)); - itemButton.state = (itemIndex == selectedItemIndex ? NSOnState : NSOffState); + itemButton.state = (itemIndex == selectedItemIndex ? NSControlStateValueOn : NSControlStateValueOff); itemButton.action = @selector(selectTabBarItem:); itemButton.target = self; [self addSubview:itemButton]; @@ -164,7 +164,7 @@ - (void) setSelectedTabBarItem:(DMTabBarItem *)newSelectedTabBarItem { __block NSUInteger buttonIndex = 0; [self.tabBarItems enumerateObjectsUsingBlock:^(DMTabBarItem* tabBarItem, NSUInteger idx, BOOL *stop) { - tabBarItem.state = (buttonIndex == selectedItemIndex ? NSOnState : NSOffState); + tabBarItem.state = (buttonIndex == selectedItemIndex ? NSControlStateValueOn : NSControlStateValueOff); ++buttonIndex; }]; } diff --git a/DMTabBar/DMTabBar/DMTabBarItem.h b/DMTabBar/DMTabBar/DMTabBarItem.h index 56352ef..2052f86 100644 --- a/DMTabBar/DMTabBar/DMTabBarItem.h +++ b/DMTabBar/DMTabBar/DMTabBarItem.h @@ -11,13 +11,13 @@ @interface DMTabBarItem : NSButtonCell { } -@property (nonatomic,assign) BOOL enabled; // YES or NO to enable or disable the item +@property (getter=isEnabled) BOOL enabled; // YES or NO to enable or disable the item @property (nonatomic,strong) NSImage* icon; // That's the image of the item @property (nonatomic,strong) NSString* toolTip; // Tool tip message -@property (nonatomic,strong) NSString* keyEquivalent; // Shortcut key equivalent -@property (nonatomic,assign) NSUInteger keyEquivalentModifierMask; // Shortcut modifier key (keyEquivalentModifierMask+keyEquivalent = event) -@property (nonatomic,assign) NSUInteger tag; // Tag of the item -@property (nonatomic,assign) NSInteger state; // Current state (NSOnState = selected) +@property (copy) NSString *keyEquivalent; // Shortcut key equivalent +@property NSEventModifierFlags keyEquivalentModifierMask; // Shortcut modifier key (keyEquivalentModifierMask+keyEquivalent = event) +@property NSInteger tag; // Tag of the item +@property NSControlStateValue state; // Current state (NSOnState = selected) // Internal use // We'll use a customized NSButton (+NSButtonCell) and apply it inside the bar for each item. diff --git a/DMTabBar/DMTabBar/DMTabBarItem.m b/DMTabBar/DMTabBar/DMTabBarItem.m index 1e40021..6960441 100644 --- a/DMTabBar/DMTabBar/DMTabBarItem.m +++ b/DMTabBar/DMTabBar/DMTabBarItem.m @@ -44,12 +44,12 @@ - (id)initWithIcon:(NSImage *) iconImage tag:(NSUInteger) itemTag { self = [super init]; if (self) { // Create associated NSButton to place inside the bar (it's customized by DMTabBarButtonCell with a special gradient for selected state) - tabBarItemButton = [[NSButton alloc] initWithFrame:NSZeroRect]; + tabBarItemButton = [[NSButton alloc] initWithFrame:NSZeroRect]; tabBarItemButton.cell = [[DMTabBarButtonCell alloc] init]; tabBarItemButton.image = iconImage; - [tabBarItemButton setEnabled:YES]; + tabBarItemButton.enabled = YES; tabBarItemButton.tag = itemTag; - [tabBarItemButton sendActionOn:NSLeftMouseDownMask]; + [tabBarItemButton sendActionOn:NSEventMaskLeftMouseDown]; } return self; } @@ -70,11 +70,11 @@ - (NSImage *) icon { return tabBarItemButton.image; } -- (void) setTag:(NSUInteger)newTag { +- (void) setTag:(NSInteger)newTag { tabBarItemButton.tag = newTag; } -- (NSUInteger) tag { +- (NSInteger) tag { return tabBarItemButton.tag; } @@ -86,11 +86,11 @@ - (NSString *) toolTip { return tabBarItemButton.toolTip; } -- (void) setKeyEquivalentModifierMask:(NSUInteger)newKeyEquivalentModifierMask { - tabBarItemButton.keyEquivalentModifierMask = newKeyEquivalentModifierMask; +- (void) setKeyEquivalentModifierMask:(NSEventModifierFlags)newKeyEquivalentModifierMask { + tabBarItemButton.keyEquivalentModifierMask = newKeyEquivalentModifierMask; } -- (NSUInteger) keyEquivalentModifierMask { +- (NSEventModifierFlags) keyEquivalentModifierMask { return tabBarItemButton.keyEquivalentModifierMask; } @@ -120,7 +120,7 @@ @implementation DMTabBarButtonCell - (id)init { self = [super init]; if (self) { - self.bezelStyle = NSTexturedRoundedBezelStyle; + self.bezelStyle = NSBezelStyleToolbar; } return self; } @@ -130,7 +130,7 @@ - (NSInteger) nextState { } - (void) drawBezelWithFrame:(NSRect)frame inView:(NSView *)controlView { - if (self.state == NSOnState) { + if (self.state == NSControlStateValueOn) { // If selected we need to draw the border new background for selection (otherwise we will use default back color) // Save current context [[NSGraphicsContext currentContext] saveGraphicsState];