supernova: allocators - fix construct method
[supercollider.git] / editors / scapp / include / SCView.h
blob1098a51e57a39c5427e376a0a4129cc7f6080139
1 /*
2 SuperCollider real time audio synthesis system
3 Copyright (c) 2002 James McCartney. All rights reserved.
4 http://www.audiosynth.com
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #import "DrawBackground.h"
22 #include "PyrObject.h"
24 enum {
25 layout_NoResize,
26 layout_Resize
29 enum {
30 // mHResize
31 layout_FixedLeft = -1,
32 layout_HElastic,
33 layout_FixedRight,
35 enum {
36 // mVResize
37 layout_FixedTop = -1,
38 layout_VElastic,
39 layout_FixedBottom
42 enum {
43 view_ResizeConstructionMode,
44 view_PositionConstructionMode,
47 struct Layout
49 Layout();
51 // layout params for dynamic layout views
52 float mMinWidth, mMaxWidth, mMinHeight, mMaxHeight;
53 float mWeight;
54 bool mShouldResize;
55 SCRect bounds; //relative Bounds in SCCompositeView
56 // layout params for composite views
57 char mHResize, mVResize;
62 class SCView;
63 class SCContainerView;
64 class SCTopView;
66 typedef SCView* (*SCViewCtor)(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
68 struct SCViewMaker
70 SCViewMaker(const char* inName, SCViewCtor inCtor);
71 static SCView* MakeSCView(PyrObject* inObj, SCContainerView *inParent, SCRect inBounds, const char* classname);
73 SCViewMaker *mNext;
74 SCViewCtor mCtor;
75 const char* mName;
78 extern SCViewMaker *gSCViewMakers;
79 extern SCView *gAnimatedViews;
81 class SCView
83 public:
84 SCView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
85 virtual ~SCView();
87 virtual void draw(SCRect inDamage);
88 virtual void drawFocus(SCRect inDamage);
89 virtual void drawDisabled(SCRect inDamage);
90 virtual void drawDragHilite(SCRect inDamage);
91 virtual void drawIfNecessary(SCRect inDamage);
92 virtual void mouseBeginTrack(SCPoint where, int modifiers,NSEvent *theEvent);
93 virtual void mouseTrack(SCPoint where, int modifiers,NSEvent *theEvent);
94 virtual void mouseEndTrack(SCPoint where, int modifiers,NSEvent *theEvent);
95 virtual void mouseOver(SCPoint where, int modifiers,NSEvent *theEvent);
96 virtual void draggingEntered (SCPoint where);
97 virtual void draggingUpdated (SCPoint where);
98 virtual void keyDown(int character, int modifiers, unsigned short keycode);
99 virtual void keyUp(int character, int modifiers, unsigned short keycode);
100 virtual void keyModifiersChanged(int modifiers);
101 virtual void mouseDownAction(SCPoint where, int modifiers, NSEvent *theEvent);
102 virtual void mouseMoveAction(SCPoint where, int modifiers, NSEvent *theEvent);
103 virtual void mouseUpAction(SCPoint where, int modifiers, NSEvent *theEvent);
104 void doConstructionMove(SCPoint where);
105 void setConstructionModeFromPoint(SCPoint where);
106 virtual bool shouldDim();
107 void beginDrag(SCPoint where);
109 virtual bool canReceiveDrag();
110 virtual void receiveDrag();
112 bool isFocus() const;
113 bool hit(SCPoint p) const;
114 void refresh();
115 virtual void refreshInRect(SCRect b);
116 void refreshFocus();
117 void setDragHilite(bool inFlag);
119 virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
120 virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
122 virtual void setVisibleFromParent() { } // does nothing, needed for Cocoa views
124 virtual bool isDragSource() const;
125 virtual SCView* findView(SCPoint where);
126 virtual SCView* findViewByID(int32 inID);
127 virtual void makeFocus(bool focus);
128 virtual SCView* nextFocus(bool *foundFocus, bool canFocus);
129 virtual SCView* prevFocus(SCView **prevView, bool canFocus);
130 virtual bool canFocus();
131 virtual NSView* focusResponder();
133 void sendMessage(PyrSymbol *method, int numargs, PyrSlot *args, PyrSlot *result);
135 virtual void setBounds(SCRect inBounds);
136 virtual SCRect getBounds();
137 virtual SCRect getDrawBounds(); //relative to ContainerView
138 virtual Layout getLayout();
139 // virtual void setLayout(Layout inLayout);
142 SCView* next() { return mNext; }
143 SCContainerView* parent() { return mParent; }
145 virtual NSMenu* contextMenu(SCPoint inPoint);
147 virtual void setMenuItemChosen(int inItem) {}
149 PyrObject* GetSCObj() { return mObj; }
150 SCView* NextAnimatedView() const { return mNextAnimatedView; }
152 void startAnimation();
153 void stopAnimation();
154 virtual void animate() { refresh(); }
156 virtual bool isScroller() { return false; }
157 virtual bool isSubViewScroller() { return false; }
158 virtual bool isContainer() { return false; }
159 virtual SCRect checkMinimumSize() { return mBounds; }
161 bool isTopContainer(){ return (!mParent);};
163 protected:
164 friend class SCContainerView;
165 friend class SCScrollView;
167 SCView *mNext;
168 SCView *mNextAnimatedView;
169 SCView *mPrevAnimatedView;
170 SCContainerView *mParent;
171 SCTopView *mTop;
172 PyrObject* mObj;
173 SCRect mBounds;
174 Layout mLayout;
175 DrawBackground* mBackground;
176 DrawBackground* mBackgroundImage;
177 bool mVisible;
178 bool mEnabled;
179 bool mCanFocus;
180 bool mDragHilite;
181 int32 mID;
182 int mConstructionMode;
183 SCColor mFocusColor;
184 NSString *mDragLabel;
189 class SCContainerView : public SCView
191 public:
192 SCContainerView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
193 virtual ~SCContainerView();
195 virtual void drawIfNecessary(SCRect inDamage);
197 virtual void add(SCView *inChild);
198 virtual void remove(SCView *inChild);
199 virtual SCView* findView(SCPoint where);
200 virtual SCView* findViewByID(int32 inID);
201 virtual void makeFocus(bool focus);
202 virtual SCView* nextFocus(bool *foundFocus, bool canFocus);
203 virtual SCView* prevFocus(SCView **prevView, bool canFocus);
204 virtual bool canFocus();
205 virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
206 virtual SCRect checkMinimumSize();
207 virtual void setVisibleFromParent();
208 virtual bool isVisible() {return mVisible && mParent->isVisible(); }
209 virtual bool isContainer() { return true; }
211 protected:
212 SCView *mChildren;
213 int mNumChildren;
216 class SCCompositeView : public SCContainerView
218 public:
219 SCCompositeView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
220 virtual ~SCCompositeView();
222 virtual void setBounds(SCRect inBounds);
223 protected:
226 class SCLayoutView : public SCContainerView
228 public:
229 SCLayoutView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
230 virtual ~SCLayoutView();
232 virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
233 virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
234 virtual void add(SCView *inChild);
236 protected:
237 float mSpacing;
240 class SCHLayoutView : public SCLayoutView
242 public:
243 SCHLayoutView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
244 virtual ~SCHLayoutView();
246 virtual void setBounds(SCRect inBounds);
248 protected:
251 class SCVLayoutView : public SCLayoutView
253 public:
254 SCVLayoutView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
255 virtual ~SCVLayoutView();
257 virtual void setBounds(SCRect inBounds);
259 protected:
262 // tell host to draw stuff.
263 typedef void (*DamageCallback)(SCRect inRect, void *inData);
264 typedef void (*DragCallback)(SCPoint where, PyrSlot* inSlot, NSString* inString, NSString* label, void *inData);
266 class SCTopView : public SCCompositeView
268 public:
269 SCTopView(PyrObject* inObj, SCRect inBounds);
271 SCView *focusView() {
272 if(isSubViewScroller()) {
273 return mTop->focusView();
274 } else {
275 return mFocusView;
279 void forgetView(SCView *view);
281 void resetFocus();
282 void addDamage(SCRect inRect);
283 void beginDragCallback(SCPoint where, PyrSlot* slot, NSString* string, NSString* label);
285 void setDamageCallback(DamageCallback inFunc, void *inHostData)
286 { mDamageCallback = inFunc; mHostData = inHostData; }
287 void setDragCallback(DragCallback inFunc)
288 { mDragCallback = inFunc; }
290 void tabNextFocus();
291 void tabPrevFocus();
292 void setDragView(SCView *inView);
294 NSView* GetNSView() { return mNSView; }
295 void SetNSView(NSView* inView) { mNSView = inView; }
297 bool ConstructionMode() { return mConstructionMode; }
298 void SetConstructionMode(bool inFlag) { mConstructionMode = inFlag; }
300 virtual void drawFocus(SCRect inDamage);
301 virtual bool canReceiveDrag();
302 virtual void receiveDrag();
303 virtual void setInternalBounds(SCRect internalBounds);
304 virtual bool isVisible() {return mVisible; }
305 protected:
306 friend class SCView;
307 void focusIs(SCView *inView) {
308 if(isSubViewScroller()) {
309 mTop->focusIs(inView);
310 } else {
311 mFocusView = inView;
315 DamageCallback mDamageCallback;
316 DragCallback mDragCallback;
317 void *mHostData;
318 SCView *mFocusView;
319 SCView *mDragView;
320 NSView *mNSView;
322 bool mConstructionMode;
326 SCScrollTopView and SCScrollView by Scott Wilson
327 Development funded in part by the Arts and Humanites Research Council http://www.ahrc.ac.uk/
330 class SCScrollTopView : public SCTopView
332 public:
333 SCScrollTopView(PyrObject* inObj, SCRect inBounds);
335 NSScrollView* GetScrollView() { return mNSScrollView; }
336 void SetNSScrollView(NSScrollView* inView) { mNSScrollView = inView; }
338 virtual bool isScroller() { return true; }
340 virtual SCRect getDrawBounds();
341 virtual void setInternalBounds(SCRect inBounds);
342 virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
343 virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
344 virtual SCRect checkMinimumSize();
345 virtual void add(SCView *inChild);
346 virtual void remove(SCView *inChild);
347 bool isInSetClipViewOrigin() { return mInSetClipViewOrigin; }
348 void setInSetClipViewOrigin(bool flag) { mInSetClipViewOrigin = flag; }
350 protected:
351 NSScrollView *mNSScrollView;
352 bool mInSetClipViewOrigin;
355 class SCScrollView : public SCScrollTopView
357 public:
358 SCScrollView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
359 virtual ~SCScrollView();
360 virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
361 virtual void setVisibleFromParent();
362 //virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
364 virtual void setBounds(SCRect inBounds);
365 virtual SCRect getBounds();
366 virtual void add(SCView *inChild);
367 // virtual void remove(SCView *inChild);
369 virtual bool isSubViewScroller() { return true; }
371 virtual void drawIfNecessary(SCRect inDamage);
372 virtual void drawSubViewIfNecessary(SCRect inDamage);
373 virtual bool isVisible() {return mVisible && mParent->isVisible(); }
376 inline bool SCView::isFocus() const { return mTop->focusView() == this; }
378 class SCSlider : public SCView
380 public:
381 SCSlider(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
383 virtual void draw(SCRect inDamage);
384 virtual void mouseTrack(SCPoint where, int modifiers,NSEvent *theEvent);
386 double value() { return mValue; }
387 bool setValue(double inValue, bool send);
389 virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
390 virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
392 virtual bool canReceiveDrag();
393 virtual void receiveDrag();
395 protected:
396 virtual void setValueFromPoint(SCPoint point);
397 void calcThumbRect(SCRect bounds);
399 SCRect mThumbRect;
400 double mValue, mStepSize, mStepScale;
401 DrawBackground* mKnob;
402 float mThumbSize;
404 SCView* NewSCSlider(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
407 class SCRangeSlider : public SCView
409 public:
410 SCRangeSlider(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
412 virtual void draw(SCRect inDamage);
413 virtual void mouseBeginTrack(SCPoint where, int modifiers,NSEvent *theEvent);
414 virtual void mouseTrack(SCPoint where, int modifiers,NSEvent *theEvent);
416 bool setValue(double inLo, double inHi, bool send);
418 virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
419 virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
421 virtual bool canReceiveDrag();
422 virtual void receiveDrag();
424 protected:
425 virtual void setValueFromPoint(SCPoint point);
426 // sc.solar addition
427 void moveRangeFromPoint(SCPoint point);
428 void adjustLoFromPoint(SCPoint point);
429 void adjustHiFromPoint(SCPoint point);
430 // sc.solar addition end
431 void calcRangeRect();
433 SCRect mRangeRect;
434 double mLo, mHi, mStepSize, mStepScale;
435 SCPoint mAnchor;
436 DrawBackground* mKnob;
438 SCView* NewSCRangeSlider(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
442 class SC2DSlider : public SCView
444 public:
445 SC2DSlider(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
447 virtual void draw(SCRect inDamage);
448 virtual void mouseTrack(SCPoint where, int modifiers,NSEvent *theEvent);
450 virtual bool setValue(double inLo, double inHi, bool send);
452 virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
453 virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
455 virtual bool canReceiveDrag();
456 virtual void receiveDrag();
458 protected:
459 virtual void setValueFromPoint(SCPoint point);
460 void calcThumbRect();
462 SCRect mThumbRect;
463 double mX, mY;
464 double mStepSize, mStepScale;
465 DrawBackground* mKnob;
467 SCView* NewSC2DSlider(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
470 class SC2DTabletSlider : public SC2DSlider
472 public:
473 SC2DTabletSlider(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
475 virtual void mouseBeginTrack(SCPoint where, int modifiers,NSEvent *theEvent);
476 virtual void mouseTrack(SCPoint where, int modifiers,NSEvent *theEvent);
477 virtual void mouseEndTrack(SCPoint where, int modifiers,NSEvent *theEvent);
478 virtual void mouseDownAction(SCPoint where, int modifiers, NSEvent *theEvent);
479 virtual void mouseMoveAction(SCPoint where, int modifiers, NSEvent *theEvent);
480 virtual void mouseUpAction(SCPoint where, int modifiers, NSEvent *theEvent);
481 virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
483 virtual bool setValue(double inX, double inY,bool send);
485 protected:
486 int mClipInBounds;
489 SCView* NewSC2DTabletSlider(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
492 #include "SC_SndBuf.h"
494 const int kMaxScopeChannels = 128;
495 class SCScope : public SCView
497 public:
498 SCScope(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
499 virtual ~SCScope();
501 virtual void draw(SCRect inDamage);
502 virtual void draw0(CGContextRef cgc);
503 virtual void draw1(CGContextRef cgc);
504 virtual void draw2(CGContextRef cgc);
505 virtual void mouseTrack(SCPoint where, int modifiers,NSEvent *theEvent);
506 virtual void animate();
508 virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
509 virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
511 SCPoint pixelToUnits(SCPoint p, SCRect r)
513 return SCMakePoint(
514 (p.x - r.x) * mZoom.x + mScroll.x,
515 (p.y - r.y) * mZoom.y + mScroll.y);
517 SCPoint unitsToPixel(SCPoint u, SCRect r)
519 return SCMakePoint(
520 (u.x - mScroll.x) * mInvZoom.x + r.x,
521 (u.y - mScroll.y) * mInvZoom.y + r.y);
524 protected:
526 int mBufNum;
527 SndBuf mSndBuf;
528 SCPoint mZoom, mInvZoom, mScroll;
529 int mStyle; // 0 = separate, 1 = overlay, 2 = x,y.
530 SCColor mWaveColors[kMaxScopeChannels];
531 SCColor mGridColor;
532 bool mGridOn;
534 SCView* NewSCScope(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
538 const int kLabelSize = 64;
539 struct SCButtonState
541 char mLabel[kLabelSize];
542 SCColor mLabelColor;
543 SCColor mButtonColor;
546 const int kFontNameSize = 80;
548 class SCButton : public SCView
550 public:
551 SCButton(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
552 virtual ~SCButton();
554 virtual void draw(SCRect inDamage);
555 virtual void mouseTrack(SCPoint where, int modifiers,NSEvent *theEvent);
556 virtual void mouseEndTrack(SCPoint where, int modifiers,NSEvent *theEvent);
558 bool setValue(int inValue, bool send, int modifiers);
560 virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
561 virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
563 virtual bool canReceiveDrag();
564 virtual void receiveDrag();
566 protected:
568 int mValue;
569 char mFontName[kFontNameSize];
570 float mFontSize;
571 int mNumStates;
572 SCButtonState *mStates;
573 bool mPushed;
575 SCView* NewSCButton(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
578 @interface SCNSMenu : NSMenu
580 int current;
582 - (void) selectedItem:(id)item;
583 - (int) current;
584 @end
586 class SCPopUpMenu : public SCView
588 public:
589 SCPopUpMenu(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
590 virtual ~SCPopUpMenu();
592 virtual void draw(SCRect inDamage);
593 virtual void mouseBeginTrack(SCPoint where, int modifiers,NSEvent *theEvent);
595 bool setValue(int inValue, bool send);
596 virtual void setMenuItemChosen(int inItem) { setValue(inItem, true); }
598 virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
599 virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
601 virtual bool canReceiveDrag();
602 virtual void receiveDrag();
604 protected:
606 int mValue;
607 SCNSMenu *mMenu;
608 char mFontName[kFontNameSize];
609 float mFontSize;
610 SCColor mStringColor;
612 SCView* NewSCPopUpMenu(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
615 class SCListView : public SCView
617 public:
618 SCListView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
619 virtual ~SCListView();
621 virtual void draw(SCRect inDamage);
622 virtual void mouseBeginTrack(SCPoint where, int modifiers,NSEvent *theEvent);
623 virtual void mouseTrack(SCPoint where, int modifiers, NSEvent *theEvent);
625 bool setValue(int inValue, bool send);
627 virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
628 virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
630 virtual bool canReceiveDrag();
631 virtual void receiveDrag();
633 void scrollToValue();
635 protected:
637 int mValue;
638 CFMutableArrayRef mArray;
639 char mFontName[kFontNameSize];
640 float mFontSize;
641 float mScroll;
642 float mAnchorScroll;
643 SCPoint mAnchor;
644 SCColor mStringColor;
645 SCColor mSelectedStringColor;
646 SCColor mHiliteColor;
647 SCColor * mItemBackgroundColor;
648 int mAlignment;
649 NSSize mStrSize;
650 bool mScrolling;
652 SCView* NewSCListView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
654 //by jan trutzschler
655 class SCMultiSliderView : public SCView
657 public:
658 SCMultiSliderView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
659 virtual ~SCMultiSliderView();
661 virtual void draw(SCRect inDamage);
662 virtual void mouseBeginTrack(SCPoint where, int modifiers,NSEvent *theEvent);
663 virtual void mouseEndTrack(SCPoint where, int modifiers,NSEvent *theEvent);
664 virtual void mouseTrack(SCPoint where, int modifiers,NSEvent *theEvent);
666 void setSelection(SCPoint where);
667 bool setValue(int inX, double inY, bool send);
668 //virtual void setPoint(int x, double y, bool send);
669 virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
670 virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
671 void setVisibleSize();
672 virtual bool canReceiveDrag();
673 virtual void receiveDrag();
675 protected:
676 int indexFromPoint(SCPoint where);
677 // int getVisibleMax();
679 double valueFromPoint(SCPoint where);
680 void setValueFromPoint(SCPoint point);
681 SCRect calcThumbRect(int xIn, double valIn, double step);
682 float mThumbSize, mThumbSizeY; // size of the rect
683 int mTabSize, mVisibleSize; // size of the table
684 SCColor mFillColor;
685 SCColor mStrokeColor;
686 SCRect mThumbRect;
687 double mCurrentY, mCurrentX;
688 int mCurrentIndex, mStartIndex, mSelectionSize;
689 double mStepSize, mStepScale;
690 double * mYValues;
691 double * mSecYValues;
692 DrawBackground* mKnob;
693 float mXOffset ; //space between points
694 bool mReadOnly, mDrawLinesActive, mShowIndex, mDrawRectsActive, mIsHorizontal, mIsFilled;
695 SCPoint mPrevPoint;
696 int mElasticMode;
697 double mElasticIndexStep;
700 SCView* NewSCMultiSliderView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
701 ////
702 //by jan truetzschler jt[at]kandos[dot]de
704 //enum taken from PyrArrayPrimitives should move to a header file
705 enum {
706 shape_Step,
707 shape_Linear,
708 shape_Exponential,
709 shape_Sine,
710 shape_Welch,
711 shape_Curve,
712 shape_Squared,
713 shape_Cubed
716 struct SCEnvObject {
717 SCColor mColor; //changes between selected and mObjectColor
718 SCColor mObjectColor; //if its not selected
719 SCRect mRect;
720 int mNumConnection;
721 SCPoint mDrawPoint;
722 double * mConnections; //tells to where it is connected
723 int mNumInputs, mNumOutputs;
724 double x, y;
725 bool mIsSelected, mIsVisible, mEditable;
726 char *mString;
727 int shape;
728 float curve;
730 typedef struct SCEnvObject SCEnvObject;
732 class SCEnvelopeView : public SCView
734 public:
735 SCEnvelopeView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
736 virtual ~SCEnvelopeView();
737 virtual void draw(SCRect inDamage);
738 virtual void mouseDownAction(SCPoint where, int modifiers, NSEvent *theEvent);
739 virtual void mouseBeginTrack(SCPoint where, int modifiers,NSEvent *theEvent);
740 virtual void mouseEndTrack(SCPoint where, int modifiers,NSEvent *theEvent);
741 virtual void mouseTrack(SCPoint where, int modifiers,NSEvent *theEvent);
743 void setSelection(SCPoint where, bool fixed, bool checkForConnection);
744 virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
745 virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
746 virtual bool canReceiveDrag();
747 virtual void receiveDrag();
749 protected:
751 void setValueFromPoint(SCPoint point);
752 bool setValue(SCEnvObject * envob, double x, double y, bool send);
753 int allocSlotEnvObjArray(PyrSlot *slot, SCEnvObject **arr);
754 bool setEnvRect(double valX, double valY, SCEnvObject * envobIn);
756 int mThumbSize, mThumbSizeY; // size of the rect
757 int mTabSize, mVisibleSize, mActiveSize; // size of the table
758 SCColor mFillColor, mSelectedColor, mStrokeColor;
759 SCRect mThumbRect;
760 double mCurrentY, mCurrentX, mAbsoluteX;
761 int mCurrentIndex, mStartIndex, mSelectionSize, mLastIndex;
762 double mStepSize, mStepScale;
763 SCEnvObject * mEnvObj;
764 //DrawBackground* mKnob;
765 bool mDrawLinesActive, mShowIndex, mDrawRectsActive, mIsFilled, mIsFixedSelection, mIsEnvView, mIsTracking;
766 int mSelectedIndex;
767 SCPoint mMousePoint;
769 //grid
770 bool mGridOn;
771 SCColor mGridColor;
772 SCPoint mGrid;
774 //draw string in box
775 char mFontName[kFontNameSize];
776 float mFontSize;
777 SCColor mStringColor;
778 int mAlignment;
779 bool mDrawCenteredConnection;
780 int *drawOrder;
781 SCPoint trackOffset;
785 SCView* NewSCEnvelopeView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
790 const char kFrameLastTimes = 10;
791 class SCUserView : public SCView
793 public:
794 SCUserView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
795 virtual ~SCUserView();
797 virtual void draw(SCRect inDamage);
798 virtual void mouseBeginTrack(SCPoint where, int modifiers,NSEvent *theEvent);
799 virtual void mouseTrack(SCPoint where, int modifiers,NSEvent *theEvent);
800 virtual void mouseEndTrack(SCPoint where, int modifiers,NSEvent *theEvent);
801 virtual void mouseMoveAction(SCPoint where, int modifiers, NSEvent *theEvent);
802 virtual void mouseUpAction(SCPoint where, int modifiers, NSEvent *theEvent);
803 virtual void mouseDownAction(SCPoint where, int modifiers, NSEvent *theEvent);
804 virtual void mouseOver(SCPoint where, int modifiers, NSEvent *theEvent);
805 virtual void keyDown(int character, int modifiers);
806 virtual void keyUp(int character, int modifiers);
807 virtual bool canReceiveDrag();
808 virtual void receiveDrag();
809 virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
810 virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
811 virtual void clearDrawing();
812 virtual void refreshInRect(SCRect b);
813 protected:
814 bool mDrawingEnabled;
815 bool mClearOnRefresh;
816 double mFrameLastTimes[kFrameLastTimes];
817 float mFrameRate;
818 int mFrameCounter;
819 SCPoint mRealtiveMousePoint;
821 NSImage* mNSImageForLayering; // offscreen image object
822 NSBitmapImageRep* mImageRep;
823 void mouseAction(PyrSymbol *method, SCPoint where, int modifiers);
825 SCView* NewSCUserView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
830 enum {
831 kSCAlignLeft = -1,
832 kSCAlignCenter,
833 kSCAlignRight
836 class SCStaticText : public SCView
838 public:
839 SCStaticText(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
840 virtual ~SCStaticText();
842 virtual void draw(SCRect inDamage);
843 virtual bool shouldDim();
845 virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
846 virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
848 protected:
849 virtual void drawString(SCRect bounds);
851 char *mString;
852 char mFontName[kFontNameSize];
853 float mFontSize;
854 SCColor mStringColor;
855 int mAlignment;
858 SCView* NewSCStaticText(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
860 class SCNumberBoxOld : public SCStaticText
862 public:
863 SCNumberBoxOld(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
864 virtual ~SCNumberBoxOld();
866 virtual void draw(SCRect inDamage);
867 virtual bool shouldDim();
869 virtual void mouseTrack(SCPoint where, int modifiers,NSEvent *theEvent);
870 //virtual void mouseEndTrack(SCPoint where, int modifiers);
872 //virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
873 //virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
875 virtual bool canReceiveDrag();
876 virtual void receiveDrag();
878 SCView* NewSCNumberBoxOld(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
880 class SCDragSource : public SCStaticText
882 public:
883 SCDragSource(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
884 virtual ~SCDragSource();
886 virtual void draw(SCRect inDamage);
887 virtual bool shouldDim();
888 virtual void mouseBeginTrack(SCPoint where, int modifiers,NSEvent *theEvent);
890 protected:
892 SCView* NewSCDragSource(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
895 class SCDragSink : public SCStaticText
897 public:
898 SCDragSink(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
899 virtual ~SCDragSink();
901 virtual void draw(SCRect inDamage);
902 virtual bool shouldDim();
904 virtual bool canReceiveDrag();
905 virtual void receiveDrag();
907 protected:
909 SCView* NewSCDragSink(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
912 class SCDragBoth : public SCDragSink
914 public:
915 SCDragBoth(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
917 virtual void draw(SCRect inDamage);
919 virtual void mouseBeginTrack(SCPoint where, int modifiers,NSEvent *theEvent);
921 protected:
923 SCView* NewSCDragBoth(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
926 //felix
927 class SCTabletView : public SCView
929 public:
930 SCTabletView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
931 virtual ~SCTabletView();
933 virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
935 virtual void mouseBeginTrack(SCPoint where, int modifiers,NSEvent *theEvent);
936 virtual void mouseTrack(SCPoint where, int modifiers,NSEvent *theEvent);
937 virtual void mouseEndTrack(SCPoint where, int modifiers,NSEvent *theEvent);
938 virtual void mouseDownAction(SCPoint where, int modifiers, NSEvent *theEvent);
939 virtual void mouseMoveAction(SCPoint where, int modifiers, NSEvent *theEvent);
940 virtual void mouseUpAction(SCPoint where, int modifiers, NSEvent *theEvent);
941 protected:
942 int mClipToBounds;
944 SCView* NewSCTabletView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);