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
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
;
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
;
65 @interface SCTextFieldResponder
: NSTextField
67 struct SCTextField
*mSCViewObject
;
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
;
82 @interface SCNSMenuItem
: NSMenuItem
{
83 struct PyrObject
*mMenuItemObj
;
86 - (void)setSCObject
: (struct PyrObject
*)inObject
;
87 - (struct PyrObject
*)getSCObject
;
88 - (void)doAction
: (id
)sender
;
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
;
109 @interface SCNSFlippedView
: NSView
{
115 @interface SCNSWebView
: WebView
{
116 struct SCWebView
*mSCWebView
;
119 BOOL enterExecutesSelection
;
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
;
149 class SCCocoaTextView
: public SCView
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
;};
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
; }
175 SCTextView
*mTextView
;
176 NSScrollView
*mScrollView
;
177 SCCocoaTextViewResponder
*mCocoaToLangAction
;
178 bool mLoadLinkInView
;
182 class SCMovieView
: public SCView
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
; }
194 QTMovieView
*mMovieView
;
199 class SCWebView
: public SCView
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);
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
);
220 SCNSWebView
*mWebView
;
221 SCNSFlippedView
*flipView
;
224 //class SCTextField : public SCStaticText
225 class SCTextField
: public SCView
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
);
238 virtual NSView
* focusResponder() { return mTextField
; }
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
);
247 SCTextFieldResponder
*mTextField
;
249 //SCTextFieldResponder *mCocoaToLangAction;
251 SCColor mStringColor
;
254 class SCNumberBox
: public SCTextField
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
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
; }
288 class SCLevelIndicator
: public SCView
291 SCLevelIndicator(SCContainerView
*inParent
, PyrObject
* inObj
, SCRect inBounds
);
292 virtual ~SCLevelIndicator();
293 virtual void setBounds(SCRect inBounds
);
296 virtual int setProperty(PyrSymbol
*symbol
, PyrSlot
*slot
);
297 virtual int getProperty(PyrSymbol
*symbol
, PyrSlot
*slot
);
298 virtual void setVisibleFromParent();
301 virtual NSView
* focusResponder() { return mLevelIndicator
; }
304 SCNSLevelIndicator
*mLevelIndicator
;
307 double mNumSteps
, mWarning
, mCritical
;
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
);