Skip to content

Instantly share code, notes, and snippets.

@saikat
Created February 23, 2010 06:29
Show Gist options
  • Select an option

  • Save saikat/311931 to your computer and use it in GitHub Desktop.

Select an option

Save saikat/311931 to your computer and use it in GitHub Desktop.
/*
* AppController.j
* TestLargeView
*
* Created by You on February 22, 2010.
* Copyright 2010, Your Company All rights reserved.
*/
@import <Foundation/CPObject.j>
@import <AppKit/CGContext.j>
@import <AppKit/CPColor.j>
@implementation LargeView : CPView
{
}
- (void)drawRect:(CPRect)aRect
{
var context = [[CPGraphicsContext currentContext] graphicsPort];
CGContextSaveGState(context);
CGContextSetStrokeColor(context,[CPColor blackColor]);
CGContextSetLineWidth(context, 1.0);
CGContextStrokeRect(context,CPRectInset([self bounds],1.0, 1.0));
CGContextRestoreGState(context);
}
@end
@implementation AppController : CPObject
{
LargeView bigView;
}
- (void)applicationDidFinishLaunching :(CPNotification)aNotification
{
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
contentView = [theWindow contentView],
label = [CPTextField labelWithTitle:"Some text"];
[label setEditable:YES];
[label setTarget:self];
[label setAction:@selector(setSize:)];
bigView = [[LargeView alloc] initWithFrame:CGRectMake(1, 1, 1000, 1000)];
[bigView setFrameSize:CGSizeMake(10000, 10000)];
[contentView addSubview:bigView];
[contentView addSubview:label];
[theWindow orderFront:self];
}
- (void)setSize:(CPTextField)textField
{
var size = [textField floatValue];
[bigView setFrameSize:CGSizeMake(size, size)];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment