-
-
Save BlairDuncan/333334 to your computer and use it in GitHub Desktop.
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
@import <Foundation/CPObject.j> | |
@implementation AppController : CPObject | |
{ | |
@outlet CPWindow theWindow; //this "outlet" is connected automatically by the Cib | |
} | |
- (void)applicationDidFinishLaunching:(CPNotification)aNotification | |
{ | |
[CPMenu setMenuBarVisible:YES]; | |
var theSize = [theWindow frame].size; | |
theRect = CGRectMake(0, 0, theSize.width-40, theSize.height-40); | |
var anotherWindow = [[CPWindow alloc] initWithContentRect:theRect styleMask:CPClosableWindowMask]; | |
[anotherWindow orderFront:self]; | |
[anotherWindow center] | |
} | |
@end | |
@implementation CPWindow(fix_center) // takes into account the menubar | |
- (void)center | |
{ | |
var size = [self frame].size, | |
containerSize = [CPPlatform isBrowser] ? [_platformWindow contentBounds].size : [[self screen] visibleFrame].size, | |
menuHeight = [CPMenu menuBarVisible] ? [CPMenu menuBarHeight] : 0; | |
[self setFrameOrigin:CGPointMake((containerSize.width - size.width) / 2.0, (containerSize.height - size.height + menuHeight) / 2.0)]; | |
} | |
@end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment