deprecate SCViewHolder-layRight
[supercollider.git] / SCClassLibrary / Common / GUI / osx / scide_scapp / Base / SCCocoaView.sc
blob5f35a66b1c770ac679dcf07009b93ee5784c7fa2
1 SCTextView : SCView{
2         var <stringColor, <font, <editable;
3         var     <autohidesScrollers, <hasHorizontalScroller, <hasVerticalScroller, <textBounds;
4         var <usesTabToFocusNextView=true, <enterInterpretsSelection=true;
5         var <>linkAction;
7         mouseUp {arg x, y, modifiers, buttonNumber, clickCount, clickPos;
8                 mouseUpAction.value(this, x, y, modifiers, buttonNumber, clickCount, clickPos); }
10         doLinkAction { arg url, description;
11                 linkAction.value(this, url, description);
12         }
14         string{
15                 ^this.getProperty(\string);
16         }
18         string_{|str|
19                 ^this.setString(str, -1);
20         }
22         selectedString {
23                 ^this.getProperty(\selectedString);
24         }
26         selectedString_{|str|
27                 this.setProperty(\selectedString, str);
28         }
30         selectionStart {
31                 ^this.getProperty(\selectedRangeLocation);
32         }
34         selectionSize {
35                 ^this.getProperty(\selectedRange);
36         }
38         path {
39                 ^this.getProperty(\path);
40         }
42         stringColor_ {arg color;
43                 stringColor = color;
44                 this.setStringColor(color,-1, 0);
45         }
47         setStringColor{arg color, rangeStart = -1, rangeSize = 0;
48                 this.setProperty(\setTextColor, [color,rangeStart, rangeSize]);
49         }
51         syntaxColorize {
52                 this.setProperty(\setSyntaxColors);
53         }
55         font_ {arg afont;
56                 font = afont;
57                 this.setFont(font, -1, 0)
58         }
60         setFont{|       font, rangestart = -1, rangesize=0|
61                 this.setProperty(\setFont, [font, rangestart, rangesize]);
62         }
64         usesAutoInOutdent_{|bool|
65                 this.setProperty(\setUsesAutoInOutdent, bool);
66         }
68         setString{|string, rangestart=0, rangesize=0|
69                 this.setProperty(\insertStringInRange, [string, rangestart, rangesize]);
70         }
72         editable_{|bool|
73                 editable = bool;
74                 this.setProperty(\setEditable, bool);
75         }
77         enabled_{|bool|
78                 this.editable_(bool);
79         }
80         usesTabToFocusNextView_{|bool|
81                 usesTabToFocusNextView=bool;
82                 this.setProperty(\usesTabToFocusNextView, bool);
83         }
84         enterInterpretsSelection_{|bool|
85                 enterInterpretsSelection=bool;
86                 this.setProperty(\enterExecutesSelection, bool);
87         }
88         autohidesScrollers_{|bool|
89                 autohidesScrollers = bool;
90                 this.setProperty(\setAutohidesScrollers, bool);
91         }
92         hasHorizontalScroller_{|bool|
93                 hasHorizontalScroller = bool;
94                 this.setProperty(\setHasHorizontalScroller, bool);
95         }
96         hasVerticalScroller_{|bool|
97                 hasVerticalScroller = bool;
98                 this.setProperty(\setHasVerticalScroller, bool);
99         }
101         textBounds_{|rect|
102                 textBounds = rect;
103                 this.setProperty(\textBounds, rect);
104         }
106         open {|path|
107                 if ( path.contains( "SC://"), {
108                         path = Help.findHelpFile( path.asRelativePath( "SC:/") );
109                 });
111                 if ( path.contains( "://" ).not, {
112                 if ( path.first.asString != "/" ) { path = String.scDir +/+ path; };
113                 path = "file://"++path;
114                 });
115                 path = path.replace(" ", "%20");
116                 this.setProperty(\open, path);
117         }
119         *paletteExample{ arg parent, bounds;
120                 ^this.new(parent, bounds).string_("The quick brown fox jumps over the lazy dog.");
121         }
124 SCMovieView : SCView{
125         var <rate, <loopMode, <muted, <path, <editable;
127         /*
128         loop modes
129         0 Playback runs forward and backward between both endpoints.
130         1 Restarts playback at beginning when end is reached.
131         2 Playback stops when end is reached.
132         */
134         start{
135                 this.setProperty(\start);
136         }
138         stop{
139                 this.setProperty(\stop);
140         }
142         path_{|moviePath|
143                 path = moviePath;
144                 this.setProperty(\setMovie, moviePath);
145         }
147         muted_{|bool|
148                 muted = bool;
149                 this.setProperty(\setMuted, bool);
150         }
152         playSelectionOnly_{|bool|
153                 this.setProperty(\setPlaysSelectionOnly, bool);
154         }
156         rate_{|ratein|
157                 rate = ratein;
158                 this.setProperty(\setRate, ratein);
159         }
161         loopMode_{|mode|
162                 loopMode = mode;
163                 this.setProperty(\setLoopMode, mode);
164         }
166         gotoEnd{
167                 this.setProperty(\gotoEnd);
168         }
169         stepForward{
170                 this.setProperty(\stepForward);
171         }
173         stepBack{
174                 this.setProperty(\stepBack);
175         }
177         gotoBeginning{
178                 this.setProperty(\gotoBeginning);
179         }
181         currentTime_{|time|
182                 this.setProperty(\setCurrentTime, time);
183         }
185         currentTime{
186                 //"SCMovieView-currentTime is not implemented".warn;
187                 ^this.getProperty(\getCurrentTime);
188         }
190         editable_{|bool|
191                 editable = bool;
192                 this.setProperty(\setEditable, bool);
193         }
195         showControllerAndAdjustSize{|show, adjust|
196                 this.setProperty(\showControllerAndAdjustSize, [show, adjust]);
197         }
199         resizeWithMagnification{|size|
200                 this.setProperty(\resizeWithMagnification, size)
201         }
203         copy{
204                 this.setProperty(\copy);
205         }
206         clear{
207                 this.setProperty(\clear);
208         }
209         cut{
210                 this.setProperty(\cut);
211         }
212         paste{
213                 this.setProperty(\paste);
214         }
216         *paletteExample{ arg parent, bounds;
217                 ^this.new(parent, bounds).path_("Help/GUI/Cocoa-GUI/SCImage/flowers2.jpg");
218         }
222 SCWebView : SCView{
224         var <>onLoadFinished, <>onLoadFailed, <onLinkActivated, <enterInterpretsSelection=true;
226         url_ {|path|
227                 if ( path.contains( "SC://"), {
228                         path = Help.findHelpFile( path.asRelativePath( "SC:/") );
229                 });
231                 if ( path.contains( "://" ).not, {
232                 if ( path.first.asString != "/" ) { path = String.scDir +/+ path; };
233                 path = "file://"++path;
234                 });
235                 path = path.replace(" ", "%20");
236                 this.setProperty(\url, path);
237         }
239         url { ^this.getProperty(\url);}
241         title { ^this.getProperty(\title);}
243         forward { this.setProperty(\forward);}
245         back { this.setProperty(\back);}
247         reload { this.setProperty(\reload);}
249         didLoad { onLoadFinished.value(this); }
251         didFail { onLoadFailed.value(this); }
253         // Get the displayed content in html form.
254         html { ^this.getProperty(\html); }
256         // Set html content.
257         html_ { arg htmlString;
258                 this.setProperty(\html, htmlString);
259         }
261         editable_ { arg bool;
262                 this.setProperty(\editable, bool);
263         }
265         selectedText { ^this.getProperty(\selectedText); }
267         // Try to extract plain text from html content and return it.
268         plainText { ^this.getProperty(\plainText); }
270         onLinkActivated_{|func|
271                 onLinkActivated = func;
272                 this.setProperty(\handleLinks, func.isNil);
273         }
275         linkActivated {|linkString| onLinkActivated.value(this, linkString) }
277         findText { arg string, reverse = false;
278                 this.setProperty( \findText, [string, reverse] );
279         }
281         enterInterpretsSelection_{|bool|
282                 enterInterpretsSelection=bool;
283                 this.setProperty(\enterExecutesSelection, bool);
284         }
286         setFontFamily { arg generic, specific;
287                 this.setProperty(\fontFamily, [generic, specific]);
288         }
290         *paletteExample{ arg parent, bounds;
291                 ^this.new(parent, bounds).url_("http://supercollider.sourceforge.net");
292         }