Reordered code a little.
This commit is contained in:
parent
b8cf664d01
commit
028a5d5daa
|
@ -26,7 +26,7 @@
|
|||
|
||||
@interface BarButton (Private)
|
||||
|
||||
- (void) setText;
|
||||
- (void) createButtons;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -40,6 +40,20 @@
|
|||
fEnabled = NO;
|
||||
fTrackingTag = 0;
|
||||
|
||||
[self createButtons];
|
||||
|
||||
[self setImage: fButtonNormal];
|
||||
[self setAlternateImage: fButtonPressed];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(resetBounds:)
|
||||
name: NSViewBoundsDidChangeNotification object: nil];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
//call only once
|
||||
- (void) createButtons
|
||||
{
|
||||
NSSize buttonSize = [self frame].size;
|
||||
fButtonNormal = [[NSImage alloc] initWithSize: buttonSize];
|
||||
fButtonNormalDim = [[NSImage alloc] initWithSize: buttonSize];
|
||||
|
@ -99,20 +113,7 @@
|
|||
//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;
|
||||
}
|
||||
|
||||
//call only once to avoid overlapping text
|
||||
- (void) setText
|
||||
{
|
||||
//create button text
|
||||
NSString * text = [self title];
|
||||
|
||||
NSFont * boldFont = [[NSFontManager sharedFontManager] convertFont:
|
||||
|
@ -154,8 +155,7 @@
|
|||
shadowHighlighted, NSShadowAttributeName, nil];
|
||||
|
||||
NSSize textSizeNormal = [text sizeWithAttributes: normalAttributes],
|
||||
textSizeBold = [text sizeWithAttributes: highlightedAttributes],
|
||||
buttonSize = [self frame].size;
|
||||
textSizeBold = [text sizeWithAttributes: highlightedAttributes];
|
||||
|
||||
NSRect textRect = NSMakeRect((buttonSize.width - textSizeNormal.width) * 0.5,
|
||||
(buttonSize.height - textSizeNormal.height) * 0.5 + 1.5, textSizeNormal.width, textSizeNormal.height);
|
||||
|
|
Loading…
Reference in New Issue