deprecate SCViewHolder-layRight
[supercollider.git] / SCClassLibrary / Common / osx / scide_scapp / Cocoa.sc
blobe4ed2308a102ff17bbbd1e98472ab3b029f91ff8
1 CocoaDialog {
2         classvar result, ok, cancel;
4         *initClass {
5                 OnError.add({ this.clear })
6         }
8         *getPaths { arg okFunc, cancelFunc, allowsMultiple=true;
9                 if(result.notNil,{
10                         "A CocoaDialog is already in progress.  do: [CocoaDialog.clear]".warn;
11                         ^nil
12                 });
14                 //result = Array.new(maxSize);
15                 ok = okFunc;
16                 cancel = cancelFunc;
17                 this.prGetPathsDialog(allowsMultiple);
18         }
20         *openPanel { arg okFunc, cancelFunc, multipleSelection=false;
21                 if(result.notNil,{
22                         "A CocoaDialog is already in progress.  do: [CocoaDialog.clear]".warn;
23                         ^nil
24                 });
26                 //result = Array.new(maxSize);
27                 ok = if(multipleSelection){okFunc}{ {|res| okFunc.value(res[0])} };
28                 cancel = cancelFunc;
29                 this.prGetPathsDialog(multipleSelection);
30         }
32         *prGetPathsDialog { arg allowsMultiple;
33                 _Cocoa_GetPathsDialog
34                 ^this.primitiveFailed
35         }
36         *savePanel { arg okFunc,cancelFunc;
37                 if(result.notNil,{
38                         "A CocoaDialog is already in progress.  do: [CocoaDialog.clear]".warn;
39                         ^nil
40                 });
41                 result = String.new(512);
42                 ok = okFunc;
43                 cancel = cancelFunc;
44                 this.prSavePanel(result);
45         }
46         *prSavePanel { arg argResult;
47                 _Cocoa_SavePanel
48                 ^this.primitiveFailed
49         }
51         *ok {
52                 var res;
53                 res = result;
54                 cancel = result = nil;
55                 ok.value(res);
56                 ok = nil;
57         }
58         *cancel {
59                 var res;
60                 res = result;
61                 ok = result = nil;
62                 cancel.value(res);
63                 cancel = nil;
64         }
65         *error {
66                 this.clear;
67                 "An error has occured during a CocoaDialog".error;
68         }
69         *clear { // in case of errors, invalidate any previous dialogs
70                 ok = cancel = result = nil;
71         }
74 Cocoa {
76         *getPathsInDirectory { arg directoryPath,extension,maxItems=1000;
77                 ^this.prGetPathsInDirectory(directoryPath,extension,Array.new(maxItems));
78                 //throws an index out of range if more than maxItems items are in the directory
80                 //extension matching not yet implemented
81         }
82         *prGetPathsInDirectory { arg dir,ext,arr;
83                 _Cocoa_GetPathsInDirectory;
84                 ^this.primitiveFailed
85         }