class library: Spawner - don't access PriorityQueue-array
[supercollider.git] / editors / scapp / include / SCCocoaView.h
blob1f03e588e2db5de0d2cf78f4da9ff822f810b7ae
1 /*
2 SCCocoaView.M
5 Created by falkenst on Tue Feb 08 2005.
6 Copyright (c) 2005 jan truetzschler. All rights reserved.
8 SuperCollider real time audio synthesis system
9 Copyright (c) 2002 James McCartney. All rights reserved.
10 http://www.audiosynth.com
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27 #include "SCView.h"
28 #import "SCCocoaView.h"
29 #import "SCTextView.h"
30 #import "SCVirtualMachine.h"
31 #include "QTKit/QTKit.h"
32 #include <Quartz/Quartz.h>
33 #include <WebKit/WebView.h>
34 #import <WebKit/WebEditingDelegate.h>
36 @interface SCCocoaTextViewResponder : NSResponder
38 //struct PyrObject *mSCObject;
39 struct SCCocoaTextView *mSCViewObject;
40 BOOL usesTabToFocusNextView;
41 BOOL enterExecutesSelection;
44 //- (void) keyDown;
45 //- (void) keyUp;
46 //- (void)setSCObject: (struct PyrObject*)inObject;
47 - (struct PyrObject*)getSCObject;
48 - (void)textDidEndEditing:(NSNotification *)aNotification;
49 - (void)textDidBeginEditing:(NSNotification *)aNotification;
50 - (void)setSCView: (struct SCCocoaTextView*)inObject;
51 - (IBAction) executeSelection: (id) sender;
52 - (void)sendSelection: (char*) methodName;
53 - (void) keyUp: (NSEvent*) event;
54 - (BOOL) handleKeyDown: (NSEvent*) event;
55 - (void) mouseDown: (NSEvent*) event;
56 - (void) setUsesTabToFocusNextView: (BOOL) flag;
57 - (void) setEnterExecutesSelection: (BOOL) flag;
58 - (BOOL) textView: (NSTextView *) textView
59 clickedOnLink: (id) link
60 atIndex: (unsigned) charIndex;
61 - (void) loadHTMLToTextView:(NSURL *)url;
62 - (void)setActiveTextView:(SCTextView*)aTextView;
63 @end
65 @interface SCTextFieldResponder : NSTextField
67 struct SCTextField *mSCViewObject;
68 BOOL mDragStarted;
69 BOOL mAcceptsFirstResponder;
70 BOOL mEditingInactive; // we use this to determine if editing is not active when keyDown is received
71 NSNumberFormatter *mFormatter; // for numbox
74 - (struct PyrObject*)getSCObject;
75 - (void)setSCView: (struct SCTextField*)inObject;
76 - (void) setAcceptsFirstResponder: (BOOL) flag;
77 - (void) addNumberFormatter;
78 - (void) setEditingInactive: (BOOL)flag;
79 - (BOOL) editingInactive;
80 @end
82 @interface SCNSMenuItem : NSMenuItem {
83 struct PyrObject *mMenuItemObj;
86 - (void)setSCObject: (struct PyrObject*)inObject;
87 - (struct PyrObject*)getSCObject;
88 - (void)doAction: (id)sender;
90 @end
92 @interface SCNSLevelIndicator : NSLevelIndicator {
93 BOOL drawPeak, isVertical, criticalAboveWarning;
94 float peakSubtract, peakLevel, peakY, peakHeight;
95 double value, peakValue;
96 double warning, critical;
99 - (void)setDrawPeak:(BOOL)flag;
100 - (void)setIsVertical:(BOOL)flag;
101 - (void)setPeakSubtract:(float)val;
102 - (void)setPeakLevel:(float)val;
103 - (void)prepPeakBounds;
104 - (void)setUpWarning:(double)val;
105 - (void)setUpCritical:(double)val;
107 @end
109 @interface SCNSFlippedView : NSView {
113 @end
115 @interface SCNSWebView : WebView {
116 struct SCWebView *mSCWebView;
117 int loadCount;
118 bool handleLinks;
119 BOOL enterExecutesSelection;
122 - (void)initVars;
123 - (void) setHandleLinks: (bool)handle;
124 - (void)resetLoadCount;
125 - (void)setSCObject: (struct SCWebView*)inObject;
126 - (struct SCWebView*)getSCObject;
127 - (void)webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame;
128 - (void)webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame;
129 - (void)doFailAction;
130 - (void)doLoadAction;
131 - (void)webView:(WebView *)sender didFailLoadWithError:(NSError *)error;
132 - (BOOL)webView:(WebView *)webView shouldInsertText:(NSString *)text replacingDOMRange:(DOMRange *)range givenAction:(WebViewInsertAction)action;
133 - (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id )listener;
134 - (void)webView:(WebView *)webView unableToImplementPolicyWithError:(NSError *)error frame:(WebFrame *)frame;
135 - (void)doLinkAction:(NSString *)urlString;
136 - (void) setEnterExecutesSelection: (BOOL) flag;
137 - (void)sendSelection: (char*) methodName;
138 - (void)setSelection;
139 - (IBAction)openCode:(id)sender;
140 - (IBAction) showHelpFor: (id) sender;
141 - (IBAction)showHelpSearch:(id)sender;
143 - (IBAction)methodTemplates: (id)sender;
144 - (IBAction)methodReferences: (id)sender;
145 - (IBAction)executeSelection: (id) sender;
147 @end
149 class SCCocoaTextView : public SCView
151 public:
152 SCCocoaTextView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
153 virtual ~SCCocoaTextView();
154 virtual void makeFocus(bool focus);
155 virtual void setBounds(SCRect inBounds);
156 virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
157 virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
158 virtual void keyDown(int character, int modifiers, unsigned short keycode);
159 virtual void keyUp(int character, int modifiers, unsigned short keycode);
161 SCTextView* getTextView(){return mTextView;};
162 void tabPrevFocus();
163 void tabNextFocus();
164 virtual void setVisibleFromParent();
165 void setLoadLinkInView(bool flag){mLoadLinkInView = flag;};
166 bool getLoadLinkInView(){return mLoadLinkInView;};
168 int open(NSString *path);
169 NSURL* getLastURL() {return mLastURL;};
170 bool linkAction(NSString *path);
172 virtual NSView* focusResponder() { return mTextView; }
174 protected:
175 SCTextView *mTextView;
176 NSScrollView *mScrollView;
177 SCCocoaTextViewResponder *mCocoaToLangAction;
178 bool mLoadLinkInView;
179 NSURL *mLastURL;
182 class SCMovieView : public SCView
184 public:
185 SCMovieView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
186 virtual ~SCMovieView();
187 virtual void setBounds(SCRect inBounds);
188 virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
189 virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
190 virtual void setVisibleFromParent();
191 virtual NSView* focusResponder() { return mMovieView; }
193 protected:
194 QTMovieView *mMovieView;
195 QTTime mTime;
196 QTMovie *mMovie;
199 class SCWebView : public SCView
201 public:
202 SCWebView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
203 virtual ~SCWebView();
204 virtual void setBounds(SCRect inBounds);
205 virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
206 virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
207 virtual void setVisibleFromParent();
208 virtual void makeFocus(bool focus);
209 //virtual void keyDown(int character, int modifiers, unsigned short keycode);
210 void tabPrevFocus();
211 void tabNextFocus();
212 virtual void doOnLoadAction();
213 virtual void doLoadFailedAction();
214 virtual void doLinkClickedAction(PyrString* pstring);
215 virtual NSView* focusResponder() { return mWebView; }
216 SCTopView* getTop() { return mTop; }
217 virtual void mouseTrack(SCPoint where, int modifiers, NSEvent *theEvent);
219 protected:
220 SCNSWebView *mWebView;
221 SCNSFlippedView *flipView;
224 //class SCTextField : public SCStaticText
225 class SCTextField : public SCView
227 public:
228 SCTextField(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
229 virtual ~SCTextField();
230 virtual void setBounds(SCRect inBounds);
231 virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
232 virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
233 virtual void setVisibleFromParent();
234 virtual void makeFocus(bool focus);
235 virtual void keyDown(int character, int modifiers, unsigned short keycode);
236 void tabPrevFocus();
237 void tabNextFocus();
238 virtual NSView* focusResponder() { return mTextField; }
239 BOOL performDrag();
240 NSDragOperation draggingEntered();
241 virtual bool canReceiveDrag();
242 SCTopView* getTop() { return mTop; }
243 virtual void mouseTrack(SCPoint where, int modifiers, NSEvent *theEvent);
244 virtual void beginDrag(SCPoint where);
246 protected:
247 SCTextFieldResponder *mTextField;
248 SCColor mBoxColor;
249 //SCTextFieldResponder *mCocoaToLangAction;
251 SCColor mStringColor;
254 class SCNumberBox : public SCTextField
256 public:
257 SCNumberBox(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
258 virtual ~SCNumberBox();
259 virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
260 virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
261 virtual void keyDown(int character, int modifiers, unsigned short keycode);
264 //////////////////////////////////////
266 SCQuartzComposerView by Scott Wilson
267 Copyright (c) 2007 Scott Wilson. All rights reserved.
268 Development funded in part by the Arts and Humanites Research Council http://www.ahrc.ac.uk/
271 class SCQuartzComposerView : public SCView
273 public:
274 SCQuartzComposerView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
275 virtual ~SCQuartzComposerView();
276 virtual void setBounds(SCRect inBounds);
277 virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
278 virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
279 virtual id getNSObjectForSCObject(PyrSlot *scobject, int *returnErr);
280 virtual int getSCObjectForNSObject(PyrSlot *slot, id nsObject, NSString *type);
281 virtual void setVisibleFromParent();
282 virtual NSView* focusResponder() { return mQCView; }
284 protected:
285 QCView *mQCView;
288 class SCLevelIndicator : public SCView
290 public:
291 SCLevelIndicator(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
292 virtual ~SCLevelIndicator();
293 virtual void setBounds(SCRect inBounds);
294 void setImage();
295 void resetParams();
296 virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
297 virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
298 virtual void setVisibleFromParent();
299 void tabPrevFocus();
300 void tabNextFocus();
301 virtual NSView* focusResponder() { return mLevelIndicator; }
303 protected:
304 SCNSLevelIndicator *mLevelIndicator;
305 NSImage *mImage;
306 int mStyle;
307 double mNumSteps, mWarning, mCritical;
308 float mTickHeight;
309 bool mIsVertical;
312 SCView* NewSCCocoaTextView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
313 SCView* NewSCMovieView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
314 SCView* NewSCQuartzComposerView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
315 SCView* NewSCTextField(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
316 SCView* NewSCLevelIndicator(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);