-
Notifications
You must be signed in to change notification settings - Fork 1
/
EditingWindow.j
75 lines (64 loc) · 2.79 KB
/
EditingWindow.j
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
@import <Foundation/CPObject.j>
editingWindow = nil;
@implementation EditingWindow : CPObject
{
int returnCode;
id childView @accessors;
CPSCrollView scrollView;
}
+ (CPWindow) showEditingWindowWithView:(CPView)aView delegate:(id)aDelegate endSelector:(SEL)aSelector
{
var application = [CPApplication sharedApplication];
if( !editingWindow )
{
editingWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(0, 0, 500, 350) styleMask:CPDocModalWindowMask | CPClosableWindowMask];
var contentView = [editingWindow contentView];
[contentView setBackgroundColor:[CPColor whiteColor]];
var bounds = [contentView bounds];
var okButton = [[CPButton alloc] initWithFrame: CGRectMake(380, 307, 100, 24)];
[okButton setAutoresizingMask:CPViewMinXMargin | CPViewMinYMargin];
[okButton setTitle:"OK"];
[okButton setTarget:self];
[okButton setBezelStyle:CPRoundedBezelStyle];
[okButton setAction:@selector(okAction:)];
[contentView addSubview:okButton];
var cancelButton = [[CPButton alloc] initWithFrame: CGRectMake(260, 307, 100, 24)];
[cancelButton setAutoresizingMask:CPViewMinXMargin | CPViewMinYMargin];
[cancelButton setTitle:"Annulla"];
[cancelButton setTarget:self];
[cancelButton setBezelStyle:CPRoundedBezelStyle];
[cancelButton setAction:@selector(cancelAction:)];
[contentView addSubview:cancelButton];
scrollView = [[CPScrollView alloc] initWithFrame:CGRectMakeZero()];
[scrollView setAutohidesScrollers:YES];
[contentView addSubview:scrollView];
childView = nil;
}
var bounds = [aView bounds];
var width = bounds.size.width+60;
var height = bounds.size.height+100;
[editingWindow setFrameSize:CGSizeMake(width, height)];
[scrollView setFrame:CGRectMake(20,20,bounds.size.width+20, bounds.size.height+20)];
[scrollView setDocumentView:aView];
//[aView setFrameOrigin:CGPointMake(20,20)];
//[[editingWindow contentView] addSubview:aView];
editingWindow.childView = aView;
editingWindow.returnCode = 0;
[application beginSheet:editingWindow modalForWindow:[application mainWindow] modalDelegate:aDelegate didEndSelector:aSelector contextInfo:nil];
return editingWindow;
}
+ (void) cancelAction:(id) sender
{
[editingWindow.childView removeFromSuperview];
editingWindow.returnCode=0;
var application = [CPApplication sharedApplication];
[application endSheet:editingWindow];
}
+ (void) okAction:(id) sender
{
[editingWindow.childView removeFromSuperview];
editingWindow.returnCode=1;
var application = [CPApplication sharedApplication];
[application endSheet:editingWindow];
}
@end