Filter buttons now actually are buttons, meaning their behavior matches more to Mail.app's

This commit is contained in:
Mitchell Livingston 2006-07-23 22:23:59 +00:00
parent 5c1b9771d7
commit 53039b2074
7 changed files with 32 additions and 29 deletions

View File

@ -24,7 +24,7 @@
#import <Cocoa/Cocoa.h>
@interface BarButton : NSImageView
@interface BarButton : NSButton
{
NSImage * fButtonNormal, * fButtonNormalDim, * fButtonOver,
* fButtonPressed, * fButtonSelected, * fButtonSelectedDim;
@ -33,7 +33,6 @@
NSTrackingRectTag fTrackingTag;
}
- (void) setText: (NSString *) text;
- (void) setEnabled: (BOOL) enable;
- (void) resetBounds: (NSNotification *) notification;

View File

@ -24,6 +24,12 @@
#import "BarButton.h"
@interface BarButton (Private)
- (void) setText;
@end
@implementation BarButton
//height of button should be 17.0
@ -93,26 +99,22 @@
//selected and dimmed button
fButtonSelectedDim = [fButtonSelected copy];
[self setText];
[self setImage: fButtonNormal];
[self setAlternateImage: fButtonPressed];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(resetBounds:)
name: NSViewBoundsDidChangeNotification object: nil];
}
return self;
}
- (void) dealloc
{
[fButtonNormal release];
[fButtonOver release];
[fButtonPressed release];
[fButtonSelected release];
[fButtonSelectedDim release];
[super dealloc];
}
//call only once to avoid overlapping text
- (void) setText: (NSString *) text
- (void) setText
{
NSString * text = [self title];
NSFont * boldFont = [[NSFontManager sharedFontManager] convertFont:
[NSFont fontWithName: @"Lucida Grande" size: 12.0] toHaveTrait: NSBoldFontMask];
@ -192,14 +194,23 @@
[text drawInRect: textRect withAttributes: highlightedDimAttributes];
[fButtonSelectedDim unlockFocus];
[self setImage: fButtonNormal];
[normalAttributes release];
[normalDimAttributes release];
[highlightedAttributes release];
[highlightedDimAttributes release];
}
- (void) dealloc
{
[fButtonNormal release];
[fButtonOver release];
[fButtonPressed release];
[fButtonSelected release];
[fButtonSelectedDim release];
[super dealloc];
}
- (void) mouseEntered: (NSEvent *) event
{
if (!fEnabled)
@ -216,7 +227,7 @@
[super mouseExited: event];
}
- (void) mouseDown: (NSEvent *) event
/*- (void) mouseDown: (NSEvent *) event
{
[self setImage: fButtonPressed];
@ -228,7 +239,7 @@
[NSApp sendAction: [self action] to: [self target] from: self];
[self setImage: fEnabled ? fButtonSelected : fButtonOver];
}
}*/
- (void) setEnabled: (BOOL) enable
{

View File

@ -249,12 +249,6 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
//set filter
fFilterType = [[fDefaults stringForKey: @"Filter"] retain];
//button width should be 9 pixels surrounding text length
[fNoFilterButton setText: @"All"]; //16.64
[fDownloadFilterButton setText: @"Downloading"]; //81.69
[fSeedFilterButton setText: @"Seeding"]; //48.57
[fPauseFilterButton setText: @"Paused"]; //44.06
BarButton * currentFilterButton;
if ([fFilterType isEqualToString: @"Pause"])
currentFilterButton = fPauseFilterButton;

View File

@ -1,6 +1,6 @@
{
IBClasses = (
{CLASS = BarButton; LANGUAGE = ObjC; SUPERCLASS = NSImageView; },
{CLASS = BarButton; LANGUAGE = ObjC; SUPERCLASS = NSButton; },
{
ACTIONS = {
applyFilter = id;

View File

@ -11,7 +11,7 @@
<key>1480</key>
<string>366 546 420 63 0 0 1152 842 </string>
<key>1603</key>
<string>360 371 477 67 0 0 1152 842 </string>
<string>337 544 477 67 0 0 1152 842 </string>
<key>29</key>
<string>9 780 451 44 0 0 1152 842 </string>
<key>456</key>
@ -31,7 +31,7 @@
<integer>3</integer>
<key>IBOpenObjects</key>
<array>
<integer>1480</integer>
<integer>1603</integer>
<integer>29</integer>
<integer>21</integer>
</array>

Binary file not shown.

View File

@ -422,8 +422,7 @@
NSIndexSet * indexSet = [fFileTable selectedRowIndexes];
unsigned int i;
for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
[[NSWorkspace sharedWorkspace] selectFile: [fFiles objectAtIndex: i]
inFileViewerRootedAtPath: nil];
[[NSWorkspace sharedWorkspace] selectFile: [fFiles objectAtIndex: i] inFileViewerRootedAtPath: nil];
}
- (void) setRatioCheck: (id) sender