Make the filter buttons themselves control when they are active/inactive.

This commit is contained in:
Mitchell Livingston 2006-08-05 13:22:30 +00:00
parent 2ec6ed63eb
commit e4e673df1f
4 changed files with 22 additions and 21 deletions

View File

@ -37,7 +37,7 @@
- (void) resetBounds: (NSNotification *) notification;
- (void) setForActive;
- (void) setForInactive;
- (void) setForActive: (NSNotification *) notification;
- (void) setForInactive: (NSNotification *) notification;
@end

View File

@ -45,7 +45,15 @@
[self setImage: fButtonNormal];
[self setAlternateImage: fButtonPressed];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(resetBounds:)
NSNotificationCenter * nc = [NSNotificationCenter defaultCenter];
[nc addObserver: self selector: @selector(setForActive:)
name: NSWindowDidBecomeKeyNotification object: nil];
[nc addObserver: self selector: @selector(setForInactive:)
name: NSWindowDidResignKeyNotification object: nil];
[nc addObserver: self selector: @selector(resetBounds:)
name: NSViewBoundsDidChangeNotification object: nil];
}
return self;
@ -242,8 +250,12 @@
fTrackingTag = [self addTrackingRect: [self bounds] owner: self userData: nil assumeInside: NO];
}
- (void) setForActive
- (void) setForActive: (NSNotification *) notification
{
NSWindow * window;
if (!(window = [notification object]) || window != [self window])
return;
if ([self image] == fButtonSelectedDim)
[self setImage: fButtonSelected];
else if ([self image] == fButtonNormalDim)
@ -253,8 +265,12 @@
[self resetBounds: nil];
}
- (void) setForInactive
- (void) setForInactive: (NSNotification *) notification
{
NSWindow * window;
if (!(window = [notification object]) || window != [self window])
return;
[self setImage: [self image] == fButtonSelected ? fButtonSelectedDim : fButtonNormalDim];
if (fTrackingTag)

View File

@ -2207,21 +2207,6 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
fCompleted = 0;
[self resetDockBadge: nil];
}
//set filter images as active
[fNoFilterButton setForActive];
[fSeedFilterButton setForActive];
[fDownloadFilterButton setForActive];
[fPauseFilterButton setForActive];
}
- (void) windowDidResignKey: (NSNotification *) notification
{
//set filter images as inactive
[fNoFilterButton setForInactive];
[fSeedFilterButton setForInactive];
[fDownloadFilterButton setForInactive];
[fPauseFilterButton setForInactive];
}
- (NSSize) windowWillResize: (NSWindow *) sender toSize: (NSSize) proposedFrameSize

View File

@ -77,7 +77,7 @@
fDefaults = [NSUserDefaults standardUserDefaults];
fHandle = handle;
[[self window] update]; //makesure nib is loaded right away
[[self window] update]; //make sure nib is loaded right away
}
return self;
}