PageRenderTime 21ms CodeModel.GetById 18ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/Polish/CPWindowAdditions.j

http://github.com/polymar/polish
Unknown | 76 lines | 65 code | 11 blank | 0 comment | 0 complexity | 9a51b12f37fcc5bd27408478caa92a64 MD5 | raw file
 1/*
 2 * CPWindowAdditions.j
 3 *
 4 * Created by Roberto Gamboni on 02/17/2009.
 5 * Copyright 2008 Roberto Gamboni. All rights reserved.
 6 */
 7
 8@import <AppKit/CPWindow.j>
 9@import "CPObjectAdditions.j"
10@import "POColor.j"
11
12@implementation CPWindow (Polish) 
13
14/*
15* Set the dimension of the main window.
16*/
17- (void) width:(CGFloat) width height:(CGFloat) height {
18	var f = [self frame];
19	[self setFrame:CGRectMake(f.origin.x, f.origin.y, width, height) display:YES animate:NO];
20}
21
22/*
23* this are boring but they get handy when performing selectors created from parameters list.
24*/
25- (void) width:(CGFloat) width {
26	var f = [self frame];
27	[self setFrame:CGRectMake(f.origin.x, f.origin.y, width, f.size.height) display:NO animate:NO];
28}
29
30- (void) height:(CGFloat) height {
31	var f = [self frame];
32	[self setFrame:CGRectMake(f.origin.x, f.origin.y, f.size.width, height) display:NO animate:NO];
33}
34
35/*
36* Forces the content of the window to redraw.
37*/
38- (void) display {
39	cv = [self contentView];
40	[cv setNeedsDisplayInRect:[cv frame]];
41}
42
43/*
44* Set the title of the window.
45*/
46- (void) title:(CPString) title {
47	[self setTitle:title];
48}
49
50/*
51* Set YES and the the window will show the resizable indicator on the right-bottom.
52*/
53- (void) resizable:(BOOL) flag {
54	[self setShowsResizeIndicator:flag];
55}
56
57/*
58* Change the background color of the main window.
59*/
60- (void) color:(CPString) colorName {
61	c = [POColor color:colorName];
62	if(c != nil)
63		[self setBackgroundColor:c];
64	else
65		console.log(color + ' is not a supported color.');
66}
67
68/*
69* !!!Debugging - Error handling
70*/
71- (void)forward:(SEL)aSelector :(marg_list)args
72{
73	console.warn('@#!Polish Warning - app does not support '+aSelector);
74}
75
76@end