diff --git a/IGKMatteSegmentedControl.m b/IGKMatteSegmentedControl.m index ffae458..d367867 100644 --- a/IGKMatteSegmentedControl.m +++ b/IGKMatteSegmentedControl.m @@ -145,10 +145,11 @@ - (float)igk_drawSegment:(NSUInteger)segment runningY:(float)runningY selected:( if (image) { + NSLog(@"[self isEnabledForSegment:segment] = %d", [self isEnabledForSegment:segment]); [image drawAtPoint:NSMakePoint(floor(runningY + width / 2.0 - [image size].width / 2.0 - 1.0 + segment), ceil([self bounds].size.height / 2.0 - [image size].height / 2.0 + 1.0)) fromRect:NSZeroRect operation:NSCompositeSourceOver - fraction:1.0]; + fraction:([self isEnabledForSegment:segment] ? 1.0 : 0.5)]; } } @@ -194,182 +195,4 @@ + (NSBezierPath *)roundedBezierInRect:(NSRect)rect radius:(float)radius hasLeft: return b; } - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#if 0 -- (void)drawSegmentDivider:(NSUInteger)segmentIndex isSelected:(BOOL)isSelected runningX:(float)runningX -{ - NSRect rect = [self bounds]; - - NSRect dividerRect = NSMakeRect(runningX, 0, 1.0, [self bounds].size.height); - - NSGradient *gradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithCalibratedWhite:0.867 alpha:1.0] endingColor:[NSColor colorWithCalibratedRed:0.98 green:0.98 blue:0.98 alpha:1.00]]; - NSColor *boxShadowColor = [NSColor colorWithCalibratedWhite:1.0 alpha:0.6]; - NSColor *borderColor = [NSColor colorWithCalibratedWhite:0.55 alpha:0.75]; - NSColor *textColor = [NSColor colorWithCalibratedWhite:0.05 alpha:1.0]; - NSColor *shadowColor = [NSColor colorWithCalibratedWhite:1.0 alpha:0.75]; - - NSRect gradientRect = dividerRect; - gradientRect.size.height -= 1.0; - gradientRect.origin.y += 1.0; - - [gradient drawInRect:gradientRect angle:90]; - - if (!isSelected) - { - [borderColor set]; - NSRectFillUsingOperation(gradientRect, NSCompositeSourceOver); - } - else - { - [[NSColor colorWithCalibratedWhite:0.5 alpha:1.0] set]; - NSRectFillUsingOperation(gradientRect, NSCompositeSourceOver); - - /* - [borderColor set]; - NSRectFillUsingOperation(NSMakeRect(gradientRect.origin.x, 1, 1, 1), NSCompositeSourceOver); - NSRectFillUsingOperation(NSMakeRect(gradientRect.origin.x, gradientRect.size.height, 1, 1), NSCompositeSourceOver); - */ - } - - NSRect shadowRect = dividerRect; - shadowRect.size.height = 1.0; - [shadowColor set]; - NSRectFillUsingOperation(shadowRect, NSCompositeSourceOver); -} -- (float)drawSegmentSegment:(NSUInteger)segmentIndex isSelected:(BOOL)isSelected runningX:(float)runningX -{ - NSRect rect = [self bounds]; - - NSRect segmentRect = NSMakeRect(runningX, 0, floor((rect.size.width - 1) / 2.0), [self bounds].size.height); - [NSGraphicsContext saveGraphicsState]; - [[NSBezierPath bezierPathWithRect:segmentRect] addClip]; - - NSGradient *gradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithCalibratedWhite:0.867 alpha:1.0] endingColor:[NSColor colorWithCalibratedRed:0.98 green:0.98 blue:0.98 alpha:1.00]]; - NSColor *boxShadowColor = [NSColor colorWithCalibratedWhite:1.0 alpha:0.6]; - NSColor *borderColor = [NSColor colorWithCalibratedWhite:0.55 alpha:0.75]; - NSColor *textColor = [NSColor colorWithCalibratedWhite:0.05 alpha:1.0]; - NSColor *shadowColor = [NSColor colorWithCalibratedWhite:1.0 alpha:0.75]; - - const double radius = 3.0; - - NSBezierPath *bp = [NSBezierPath bezierPathWithRoundedRect:rect xRadius:radius yRadius:radius]; - - if (isSelected) - { - //Box Shadow - NSRect boxShadowRect = rect; - boxShadowRect.size.height -= 1.0; - NSBezierPath *boxShadowPath = [NSBezierPath bezierPathWithRoundedRect:rect xRadius:radius yRadius:radius]; - - [boxShadowColor set]; - [boxShadowPath fill]; - - //Outside Stroke - NSRect boxRect = rect; - boxRect.size.height -= 1.0; - boxRect.origin.y += 1.0; - NSGradient *strokeGradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithCalibratedWhite:0.27 alpha:1.0] endingColor:[NSColor colorWithCalibratedWhite:0.51 alpha:1.0]]; - NSBezierPath *strokeShadowPath = [NSBezierPath bezierPathWithRoundedRect:boxRect xRadius:radius yRadius:radius]; - - [strokeGradient drawInBezierPath:strokeShadowPath angle:270]; - - //Inside Fill - NSGradient *insideGradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithCalibratedWhite:0.75 alpha:1.0] endingColor:[NSColor colorWithCalibratedWhite:0.655 alpha:1.0]]; - NSBezierPath *insidePath = [NSBezierPath bezierPathWithRoundedRect:NSInsetRect(boxRect, 1.0, 1.0) xRadius:radius - 1.0 yRadius:radius - 1.0]; - - [insideGradient drawInBezierPath:insidePath angle:90]; - - //Inner Shadow - NSShadow *insideShadow = [[NSShadow alloc] initWithColor:[NSColor colorWithCalibratedWhite:0.0 alpha:0.4] offset:NSMakeSize(0.0, -1.0) blurRadius:3.0];//; - [insidePath fillWithInnerShadow:insideShadow]; - - rect.origin.x += 0.5; - rect.origin.y += 0.5; - rect.size.width -= 1.0; - rect.size.height -= 1.0; - } - else - { - rect.origin.x += 0.5; - rect.origin.y += 0.5; - rect.size.width -= 1.0; - rect.size.height -= 1.0; - - //Box shadow - NSRect boxShadowRect = rect; - boxShadowRect.size.height -= 1.0; - NSBezierPath *boxShadowPath = [NSBezierPath bezierPathWithRoundedRect:rect xRadius:radius yRadius:radius]; - - [boxShadowColor set]; - [boxShadowPath stroke]; - - //Normal Fill - NSRect boxRect = rect; - boxRect.size.height -= 1.0; - boxRect.origin.y += 1.0; - NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:boxRect xRadius:radius yRadius:radius]; - - [gradient drawInBezierPath:path angle:(isSelected ? 270 : 90)]; - - [borderColor set]; - [path stroke]; - } - - [NSGraphicsContext restoreGraphicsState]; - return segmentRect.size.width; -} -- (void)drawBackground:(BOOL)selected -{ - NSRect rect = [self bounds]; - - NSUInteger segCount = [self segmentCount]; - NSInteger selSeg = [self selectedSegment]; - NSUInteger i = 0; - - float runningX = 0.0; - for (i = 0; i < segCount; i++) - { - runningX += [self drawSegmentSegment:i isSelected:i == selSeg runningX:runningX]; - - if (i < segCount) - { - BOOL isSelected = YES; - if (selSeg == -1) - isSelected = NO; - - [self drawSegmentDivider:i isSelected:isSelected runningX:runningX]; - } - - runningX += 1.0; - } -} -#endif - @end diff --git a/IGKWindowController.m b/IGKWindowController.m index 579cc75..5492470 100644 --- a/IGKWindowController.m +++ b/IGKWindowController.m @@ -86,6 +86,7 @@ - (void)setUpBackMenu NSArray *backList = [backForwardManager backList]; if (![backList count]) { + [backForwardButton setEnabled:NO forSegment:0]; [backForwardButton setMenu:nil forSegment:0]; return; } @@ -99,12 +100,15 @@ - (void)setUpBackMenu } [backForwardButton setMenu:newBackMenu forSegment:0]; + + [backForwardButton setEnabled:YES forSegment:0]; } - (void)setUpForwardMenu { NSArray *forwardList = [backForwardManager forwardList]; if (![forwardList count]) { + [backForwardButton setEnabled:NO forSegment:1]; [backForwardButton setMenu:nil forSegment:1]; return; } @@ -118,6 +122,8 @@ - (void)setUpForwardMenu } [backForwardButton setMenu:newForwardMenu forSegment:1]; + + [backForwardButton setEnabled:YES forSegment:1]; } - (void)backMenuItem:(NSMenuItem *)sender { @@ -169,7 +175,10 @@ - (void)windowDidLoad didIndex = NO; [self loadNoSelectionRecordHistory:YES]; } - + + [backForwardButton setEnabled:NO forSegment:0]; + [backForwardButton setEnabled:NO forSegment:1]; + [searchViewTable setTarget:self]; [searchViewTable setDoubleAction:@selector(advancedSearchDoubleAction:)];