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

View File

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

View File

@ -249,12 +249,6 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
//set filter //set filter
fFilterType = [[fDefaults stringForKey: @"Filter"] retain]; 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; BarButton * currentFilterButton;
if ([fFilterType isEqualToString: @"Pause"]) if ([fFilterType isEqualToString: @"Pause"])
currentFilterButton = fPauseFilterButton; currentFilterButton = fPauseFilterButton;

View File

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

View File

@ -11,7 +11,7 @@
<key>1480</key> <key>1480</key>
<string>366 546 420 63 0 0 1152 842 </string> <string>366 546 420 63 0 0 1152 842 </string>
<key>1603</key> <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> <key>29</key>
<string>9 780 451 44 0 0 1152 842 </string> <string>9 780 451 44 0 0 1152 842 </string>
<key>456</key> <key>456</key>
@ -31,7 +31,7 @@
<integer>3</integer> <integer>3</integer>
<key>IBOpenObjects</key> <key>IBOpenObjects</key>
<array> <array>
<integer>1480</integer> <integer>1603</integer>
<integer>29</integer> <integer>29</integer>
<integer>21</integer> <integer>21</integer>
</array> </array>

Binary file not shown.

View File

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