Skip to content

Instantly share code, notes, and snippets.

@glejeune
Created June 4, 2009 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glejeune/123554 to your computer and use it in GitHub Desktop.
Save glejeune/123554 to your computer and use it in GitHub Desktop.
// Usage :
//
// @import "BrowserWindow.j"
// ...
// [BrowserWindow show];
@import <AppKit/CPWindowController.j>
@import <AppKit/CPWebView.j>
@implementation BrowserWindow : CPWindowController
{
CPWindow theWindow;
CPWebView documentArea;
}
+ (void)show
{
var docWindow = [[BrowserWindow alloc] init];
[docWindow showWindow:self];
}
- (id)init
{
theWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(0, 0, 340, 300.0) styleMask:CPClosableWindowMask|CPResizableWindowMask|CPTexturedBackgroundWindowMask];
self = [super initWithWindow:theWindow];
resultSets = [CPDictionary dictionary];
if (self)
{
[theWindow setTitle:@"Cappuccino"];
[theWindow setLevel:CPFloatingWindowLevel];
[theWindow setDelegate:self];
[CPApp runModalForWindow:theWindow];
var contentView = [theWindow contentView];
[contentView setBackgroundColor:[CPColor colorWithHexString:@"D1D1D1"]];
// Document Area ----------------------------------------------------------
documentArea = [[CPWebView alloc] initWithFrame:
CGRectMake(5.0, 5.0, CGRectGetWidth([contentView bounds])-10.0, CGRectGetHeight([contentView bounds])-49.0)];
[documentArea setAutoresizingMask:CPViewHeightSizable | CPViewWidthSizable];
[contentView addSubview:documentArea];
// Quit Button ------------------------------------------------------------
var button = [[CPButton alloc] initWithFrame:CGRectMake(CGRectGetWidth([contentView bounds])-55, CGRectGetHeight([contentView bounds])-34, 50.0, 24.0)];
[button setTitle:@"close"];
[button setBezelStyle:CPHUDBezelStyle];
[button setTarget:self];
[button setAction:@selector(closeWindow:)];
[button setAutoresizingMask:CPViewMinXMargin | CPViewMinYMargin];
[contentView addSubview:button];
// Load URL ---------------------------------------------------------------
[documentArea setMainFrameURL:@"http://cappuccino.org"];
}
return( self );
}
- (void)closeWindow:(id)sender
{
[CPApp abortModal];
[theWindow close];
}
- (void)removeFromOrdo:(id)sender
{
[prescription removeMedicationWithIdentifier:medication.name];
[self closeWindow:sender];
}
- (BOOL)windowShouldClose:(id)window
{
[CPApp abortModal];
[theWindow close];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment