-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added window menu support and fixed display bugs
- Loading branch information
Wade Cosgrove
authored and
Wade Cosgrove
committed
Jul 5, 2011
1 parent
5acf06a
commit b0e78c0
Showing
2 changed files
with
55 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
#define CORNER_CLIP_RADIUS 4.0 | ||
|
||
@interface INAppStoreWindow () | ||
@property (copy) NSString *windowMenuTitle; | ||
- (void)_doInitialWindowSetup; | ||
- (void)_createTitlebarView; | ||
- (void)_setupTrafficLightsTrackingArea; | ||
|
@@ -62,7 +63,7 @@ - (void)drawRect:(NSRect)dirtyRect | |
// Uses code from NSBezierPath+PXRoundedRectangleAdditions by Andy Matuschak | ||
// <http://code.andymatuschak.org/pixen/trunk/NSBezierPath+PXRoundedRectangleAdditions.m> | ||
|
||
- (NSBezierPath*)clippingPathWithRect:(NSRect)aRect cornerRadius:(float)radius | ||
- (NSBezierPath*)clippingPathWithRect:(NSRect)aRect cornerRadius:(CGFloat)radius | ||
{ | ||
NSBezierPath *path = [NSBezierPath bezierPath]; | ||
NSRect rect = NSInsetRect(aRect, radius, radius); | ||
|
@@ -80,6 +81,8 @@ - (NSBezierPath*)clippingPathWithRect:(NSRect)aRect cornerRadius:(float)radius | |
|
||
@implementation INAppStoreWindow | ||
|
||
@synthesize windowMenuTitle = _windowMenuTitle; | ||
|
||
#pragma mark - | ||
#pragma mark Initialization | ||
|
||
|
@@ -104,6 +107,7 @@ - (void)dealloc | |
{ | ||
[[NSNotificationCenter defaultCenter] removeObserver:self]; | ||
[_titleBarView release]; | ||
[_windowMenuTitle release]; | ||
[super dealloc]; | ||
} | ||
|
||
|
@@ -117,11 +121,41 @@ - (NSString*)title | |
return @""; | ||
} | ||
|
||
- (void)setTitle:(NSString *)aString | ||
- (void)setTitle:(NSString*)title | ||
{ | ||
self.windowMenuTitle = title; | ||
if ( ![self isExcludedFromWindowsMenu] ) | ||
[NSApp changeWindowsItem:self title:self.windowMenuTitle filename:NO]; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
kgn
Contributor
|
||
} | ||
|
||
- (void)setRepresentedURL:(NSURL *)url | ||
{ | ||
// do nothing, don't want to show document icon in menu bar | ||
} | ||
|
||
- (void)makeKeyAndOrderFront:(id)sender | ||
{ | ||
return; | ||
[super makeKeyAndOrderFront:sender]; | ||
if ( ![self isExcludedFromWindowsMenu] ) | ||
[NSApp addWindowsItem:self title:self.windowMenuTitle filename:NO]; | ||
} | ||
|
||
|
||
- (void)orderFront:(id)sender | ||
{ | ||
[super orderFront:sender]; | ||
if ( ![self isExcludedFromWindowsMenu] ) | ||
[NSApp addWindowsItem:self title:self.windowMenuTitle filename:NO]; | ||
} | ||
|
||
|
||
- (void)orderOut:(id)sender | ||
{ | ||
[super orderOut:sender]; | ||
[NSApp removeWindowsItem:self]; | ||
} | ||
|
||
|
||
#pragma mark - | ||
#pragma mark Accessors | ||
|
||
|
@@ -149,19 +183,23 @@ - (NSView*)titleBarView | |
return _titleBarView; | ||
} | ||
|
||
- (void)setTitleBarHeight:(float)newTitleBarHeight | ||
- (void)setTitleBarHeight:(CGFloat)newTitleBarHeight | ||
{ | ||
float minTitleHeight = [self _minimumTitlebarHeight]; | ||
if (newTitleBarHeight < minTitleHeight) { | ||
newTitleBarHeight = minTitleHeight; | ||
} | ||
_titleBarHeight = newTitleBarHeight; | ||
[self _recalculateFrameForTitleBarView]; | ||
[self _layoutTrafficLightsAndContent]; | ||
[self _displayWindowAndTitlebar]; | ||
|
||
if ( _titleBarHeight != newTitleBarHeight ) | ||
{ | ||
_titleBarHeight = newTitleBarHeight; | ||
[self _recalculateFrameForTitleBarView]; | ||
[self _layoutTrafficLightsAndContent]; | ||
[self _displayWindowAndTitlebar]; | ||
} | ||
} | ||
|
||
- (float)titleBarHeight | ||
- (CGFloat)titleBarHeight | ||
{ | ||
return _titleBarHeight; | ||
} | ||
|
@@ -184,6 +222,10 @@ - (void)_doInitialWindowSetup | |
[nc addObserver:self selector:@selector(_displayWindowAndTitlebar) name:NSWindowDidResignKeyNotification object:self]; | ||
[nc addObserver:self selector:@selector(_displayWindowAndTitlebar) name:NSWindowDidBecomeKeyNotification object:self]; | ||
[nc addObserver:self selector:@selector(_setupTrafficLightsTrackingArea) name:NSWindowDidBecomeKeyNotification object:self]; | ||
|
||
[nc addObserver:self selector:@selector(_displayWindowAndTitlebar) name:NSApplicationDidBecomeActiveNotification object:nil]; | ||
[nc addObserver:self selector:@selector(_displayWindowAndTitlebar) name:NSApplicationDidResignActiveNotification object:nil]; | ||
|
||
[self _createTitlebarView]; | ||
[self _layoutTrafficLightsAndContent]; | ||
[self _setupTrafficLightsTrackingArea]; | ||
|
@@ -264,7 +306,6 @@ - (float)_minimumTitlebarHeight | |
- (void)_displayWindowAndTitlebar | ||
{ | ||
// Redraw the window and titlebar | ||
[self display]; | ||
[_titleBarView setNeedsDisplay:YES]; | ||
} | ||
@end |
Isn't it a default behavior?