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 #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
37 @interface SCCocoaTextViewResponder
: NSResponder
<NSTextViewDelegate
>
39 @interface SCCocoaTextViewResponder
: NSResponder
43 //struct PyrObject *mSCObject;
44 struct SCCocoaTextView
*mSCViewObject
;
45 BOOL usesTabToFocusNextView
;
46 BOOL enterExecutesSelection
;
51 //- (void)setSCObject: (struct PyrObject*)inObject;
52 - (struct PyrObject
*)getSCObject
;
53 - (void)textDidEndEditing
:(NSNotification
*)aNotification
;
54 - (void)textDidBeginEditing
:(NSNotification
*)aNotification
;
55 - (void)setSCView
: (struct SCCocoaTextView
*)inObject
;
56 - (IBAction
) executeSelection
: (id
) sender
;
57 - (void)sendSelection
: (char*) methodName
;
58 - (void) keyUp
: (NSEvent
*) event
;
59 - (BOOL
) handleKeyDown
: (NSEvent
*) event
;
60 - (void) mouseDown
: (NSEvent
*) event
;
61 - (void) setUsesTabToFocusNextView
: (BOOL
) flag
;
62 - (void) setEnterExecutesSelection
: (BOOL
) flag
;
63 - (BOOL
) textView
: (NSTextView
*) textView
64 clickedOnLink
: (id
) link
65 atIndex
: (unsigned) charIndex
;
66 - (void) loadHTMLToTextView
:(NSURL
*)url
;
67 - (void)setActiveTextView
:(SCTextView
*)aTextView
;
70 #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
71 @interface SCTextFieldResponder
: NSTextField
<NSTextFieldDelegate
>
73 @interface SCTextFieldResponder
: NSTextField
76 struct SCTextField
*mSCViewObject
;
78 BOOL mAcceptsFirstResponder
;
79 BOOL mEditingInactive
; // we use this to determine if editing is not active when keyDown is received
80 NSNumberFormatter
*mFormatter
; // for numbox
83 - (struct PyrObject
*)getSCObject
;
84 - (void)setSCView
: (struct SCTextField
*)inObject
;
85 - (void) setAcceptsFirstResponder
: (BOOL
) flag
;
86 - (void) addNumberFormatter
;
87 - (void) setEditingInactive
: (BOOL
)flag
;
88 - (BOOL
) editingInactive
;
91 @interface SCNSMenuItem
: NSMenuItem
{
92 struct PyrObject
*mMenuItemObj
;
95 - (void)setSCObject
: (struct PyrObject
*)inObject
;
96 - (struct PyrObject
*)getSCObject
;
97 - (void)doAction
: (id
)sender
;
101 @interface SCNSLevelIndicator
: NSLevelIndicator
{
102 BOOL drawPeak
, isVertical
, criticalAboveWarning
;
103 float peakSubtract
, peakLevel
, peakY
, peakHeight
;
104 double value
, peakValue
;
105 double warning
, critical
;
108 - (void)setDrawPeak
:(BOOL
)flag
;
109 - (void)setIsVertical
:(BOOL
)flag
;
110 - (void)setPeakSubtract
:(float)val
;
111 - (void)setPeakLevel
:(float)val
;
112 - (void)prepPeakBounds
;
113 - (void)setUpWarning
:(double)val
;
114 - (void)setUpCritical
:(double)val
;
118 @interface SCNSFlippedView
: NSView
{
124 @interface SCNSWebView
: WebView
{
125 struct SCWebView
*mSCWebView
;
128 BOOL enterExecutesSelection
;
132 - (void) setHandleLinks
: (bool)handle
;
133 - (void)resetLoadCount
;
134 - (void)setSCObject
: (struct SCWebView
*)inObject
;
135 - (struct SCWebView
*)getSCObject
;
136 - (void)webView
:(WebView
*)sender didStartProvisionalLoadForFrame
:(WebFrame
*)frame
;
137 - (void)webView
:(WebView
*)sender didFailProvisionalLoadWithError
:(NSError
*)error forFrame
:(WebFrame
*)frame
;
138 - (void)doFailAction
;
139 - (void)doLoadAction
;
140 - (void)webView
:(WebView
*)sender didFailLoadWithError
:(NSError
*)error
;
141 - (BOOL
)webView
:(WebView
*)webView shouldInsertText
:(NSString
*)text replacingDOMRange
:(DOMRange
*)range givenAction
:(WebViewInsertAction
)action
;
142 - (void)webView
:(WebView
*)webView decidePolicyForNavigationAction
:(NSDictionary
*)actionInformation request
:(NSURLRequest
*)request frame
:(WebFrame
*)frame decisionListener
:(id
)listener
;
143 - (void)webView
:(WebView
*)webView unableToImplementPolicyWithError
:(NSError
*)error frame
:(WebFrame
*)frame
;
144 - (void)doLinkAction
:(NSString
*)urlString
;
145 - (void) setEnterExecutesSelection
: (BOOL
) flag
;
146 - (void)sendSelection
: (char*) methodName
;
147 - (void)setSelection
;
148 - (IBAction
)openCode
:(id
)sender
;
149 - (IBAction
) showHelpFor
: (id
) sender
;
150 - (IBAction
)showHelpSearch
:(id
)sender
;
152 - (IBAction
)methodTemplates
: (id
)sender
;
153 - (IBAction
)methodReferences
: (id
)sender
;
154 - (IBAction
)executeSelection
: (id
) sender
;
155 - (void)cmdF
:(id
)sender
;
159 class SCCocoaTextView
: public SCView
162 SCCocoaTextView(SCContainerView
*inParent
, PyrObject
* inObj
, SCRect inBounds
);
163 virtual ~SCCocoaTextView();
164 virtual void makeFocus(bool focus
);
165 virtual void setBounds(SCRect inBounds
);
166 virtual int setProperty(PyrSymbol
*symbol
, PyrSlot
*slot
);
167 virtual int getProperty(PyrSymbol
*symbol
, PyrSlot
*slot
);
168 virtual void keyDown(int character
, int modifiers
, unsigned short keycode
);
169 virtual void keyUp(int character
, int modifiers
, unsigned short keycode
);
171 SCTextView
* getTextView(){return mTextView
;};
174 virtual void setVisibleFromParent();
175 void setLoadLinkInView(bool flag
){mLoadLinkInView
= flag
;};
176 bool getLoadLinkInView(){return mLoadLinkInView
;};
178 int open(NSString
*path
);
179 NSURL
* getLastURL() {return mLastURL
;};
180 bool linkAction(NSString
*path
);
182 virtual NSView
* focusResponder() { return mTextView
; }
185 SCTextView
*mTextView
;
186 NSScrollView
*mScrollView
;
187 SCCocoaTextViewResponder
*mCocoaToLangAction
;
188 bool mLoadLinkInView
;
192 class SCMovieView
: public SCView
195 SCMovieView(SCContainerView
*inParent
, PyrObject
* inObj
, SCRect inBounds
);
196 virtual ~SCMovieView();
197 virtual void setBounds(SCRect inBounds
);
198 virtual int setProperty(PyrSymbol
*symbol
, PyrSlot
*slot
);
199 virtual int getProperty(PyrSymbol
*symbol
, PyrSlot
*slot
);
200 virtual void setVisibleFromParent();
201 virtual NSView
* focusResponder() { return mMovieView
; }
204 QTMovieView
*mMovieView
;
209 class SCWebView
: public SCView
212 SCWebView(SCContainerView
*inParent
, PyrObject
* inObj
, SCRect inBounds
);
213 virtual ~SCWebView();
214 virtual void setBounds(SCRect inBounds
);
215 virtual int setProperty(PyrSymbol
*symbol
, PyrSlot
*slot
);
216 virtual int getProperty(PyrSymbol
*symbol
, PyrSlot
*slot
);
217 virtual void setVisibleFromParent();
218 //virtual void keyDown(int character, int modifiers, unsigned short keycode);
221 virtual void doOnLoadAction();
222 virtual void doLoadFailedAction();
223 virtual void doLinkClickedAction(PyrString
* pstring
);
224 virtual NSView
* focusResponder() { return mWebView
; }
225 SCTopView
* getTop() { return mTop
; }
226 virtual void mouseTrack(SCPoint where
, int modifiers
, NSEvent
*theEvent
);
229 SCNSWebView
*mWebView
;
230 SCNSFlippedView
*flipView
;
233 //class SCTextField : public SCStaticText
234 class SCTextField
: public SCView
237 SCTextField(SCContainerView
*inParent
, PyrObject
* inObj
, SCRect inBounds
);
238 virtual ~SCTextField();
239 virtual void setBounds(SCRect inBounds
);
240 virtual int setProperty(PyrSymbol
*symbol
, PyrSlot
*slot
);
241 virtual int getProperty(PyrSymbol
*symbol
, PyrSlot
*slot
);
242 virtual void setVisibleFromParent();
243 virtual void makeFocus(bool focus
);
244 virtual void keyDown(int character
, int modifiers
, unsigned short keycode
);
247 virtual NSView
* focusResponder() { return mTextField
; }
249 NSDragOperation
draggingEntered();
250 virtual bool canReceiveDrag();
251 SCTopView
* getTop() { return mTop
; }
252 virtual void mouseTrack(SCPoint where
, int modifiers
, NSEvent
*theEvent
);
253 virtual void beginDrag(SCPoint where
);
256 SCTextFieldResponder
*mTextField
;
258 //SCTextFieldResponder *mCocoaToLangAction;
260 SCColor mStringColor
;
263 class SCNumberBox
: public SCTextField
266 SCNumberBox(SCContainerView
*inParent
, PyrObject
* inObj
, SCRect inBounds
);
267 virtual ~SCNumberBox();
268 virtual int setProperty(PyrSymbol
*symbol
, PyrSlot
*slot
);
269 virtual int getProperty(PyrSymbol
*symbol
, PyrSlot
*slot
);
270 virtual void keyDown(int character
, int modifiers
, unsigned short keycode
);
273 //////////////////////////////////////
275 SCQuartzComposerView by Scott Wilson
276 Copyright (c) 2007 Scott Wilson. All rights reserved.
277 Development funded in part by the Arts and Humanites Research Council http://www.ahrc.ac.uk/
280 class SCQuartzComposerView
: public SCView
283 SCQuartzComposerView(SCContainerView
*inParent
, PyrObject
* inObj
, SCRect inBounds
);
284 virtual ~SCQuartzComposerView();
285 virtual void setBounds(SCRect inBounds
);
286 virtual int setProperty(PyrSymbol
*symbol
, PyrSlot
*slot
);
287 virtual int getProperty(PyrSymbol
*symbol
, PyrSlot
*slot
);
288 virtual id
getNSObjectForSCObject(PyrSlot
*scobject
, int *returnErr
);
289 virtual int getSCObjectForNSObject(PyrSlot
*slot
, id nsObject
, NSString
*type
);
290 virtual void setVisibleFromParent();
291 virtual NSView
* focusResponder() { return mQCView
; }
297 class SCLevelIndicator
: public SCView
300 SCLevelIndicator(SCContainerView
*inParent
, PyrObject
* inObj
, SCRect inBounds
);
301 virtual ~SCLevelIndicator();
302 virtual void setBounds(SCRect inBounds
);
305 virtual int setProperty(PyrSymbol
*symbol
, PyrSlot
*slot
);
306 virtual int getProperty(PyrSymbol
*symbol
, PyrSlot
*slot
);
307 virtual void setVisibleFromParent();
310 virtual NSView
* focusResponder() { return mLevelIndicator
; }
313 SCNSLevelIndicator
*mLevelIndicator
;
316 double mNumSteps
, mWarning
, mCritical
;
321 SCView
* NewSCCocoaTextView(SCContainerView
*inParent
, PyrObject
* inObj
, SCRect inBounds
);
322 SCView
* NewSCMovieView(SCContainerView
*inParent
, PyrObject
* inObj
, SCRect inBounds
);
323 SCView
* NewSCQuartzComposerView(SCContainerView
*inParent
, PyrObject
* inObj
, SCRect inBounds
);
324 SCView
* NewSCTextField(SCContainerView
*inParent
, PyrObject
* inObj
, SCRect inBounds
);
325 SCView
* NewSCLevelIndicator(SCContainerView
*inParent
, PyrObject
* inObj
, SCRect inBounds
);