forked from cgestes/multifxvst
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvstgui.h
1014 lines (817 loc) · 26.8 KB
/
vstgui.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//-----------------------------------------------------------------------------
// VST Plug-Ins SDK
// VSTGUI: Graphical User Interface Framework for VST plugins :
//
// Version 2.2 Date : 25/03/03
//
//-----------------------------------------------------------------------------
// VSTGUI LICENSE
// © 2003, Steinberg Media Technologies, All Rights Reserved
//-----------------------------------------------------------------------------
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of the Steinberg Media Technologies nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGE.
//-----------------------------------------------------------------------------
#ifndef __vstgui__
#define __vstgui__
// define global defines
#if WIN32
#define WINDOWS 1
#elif SGI | SUN
#define MOTIF 1
#elif __MWERKS__
#define MAC 1
#elif __BEOS__
#define BEOS 1
#endif
#if WINDOWS
#define USE_NAMESPACE 1
#endif
#if USE_NAMESPACE
#define BEGIN_NAMESPACE_VSTGUI namespace VSTGUI {
#define END_NAMESPACE_VSTGUI }
#define USING_NAMESPACE_VSTGUI using namespace VSTGUI;
#else
#define BEGIN_NAMESPACE_VSTGUI
#define END_NAMESPACE_VSTGUI
#define USING_NAMESPACE_VSTGUI
#endif
// VSTGUI Version
#define VSTGUI_VERSION_MAJOR 2
#define VSTGUI_VERSION_MINOR 2
//----------------------------------------------------
//----------------------------------------------------
BEGIN_NAMESPACE_VSTGUI
class CFrame;
class CDrawContext;
class COffscreenContext;
class CControl;
class CBitmap;
END_NAMESPACE_VSTGUI
#if PLUGGUI
#ifndef __plugguieditor__
#include "plugguieditor.h"
#endif
#else
#ifndef __aeffguieditor__
#include "aeffguieditor.h"
#endif
#endif
//----------------------------------------------------
#if WINDOWS
#include <windows.h>
//----------------------------------------------------
#elif MOTIF
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
#ifdef NOBOOL
#ifndef bool
typedef short bool;
#endif
#ifndef false
static const bool false = 0;
#endif
#ifndef true
static const bool true = 1;
#endif
#endif
// definition of struct for XPixmap resources
struct CResTableEntry {
int id;
char **xpm;
};
typedef CResTableEntry CResTable[];
extern CResTable xpmResources;
//----------------------------------------------------
#elif MAC
#if MACX
#include <Carbon/Carbon.h>
//macho VST's set gBundleRef which is a CFBundleRef
extern void* gBundleRef;
#else
#include <Quickdraw.h>
#include <Menus.h>
#include <Windows.h>
#include <TextUtils.h>
#include <TextEdit.h>
#include <ToolUtils.h>
#include <Resources.h>
#include <Dialogs.h>
#endif
//----------------------------------------------------
#elif BEOS
#include <Font.h>
class BView;
class PlugView;
class BBitmap;
class BResources;
#endif
struct VstKeyCode;
BEGIN_NAMESPACE_VSTGUI
struct CPoint;
//-----------------------------------------------------------------------------
// Structure CRect
//-----------------------------------------------------------------------------
struct CRect
{
CRect (long left = 0, long top = 0, long right = 0, long bottom = 0)
: left (left), top (top), right (right), bottom (bottom) {}
CRect (const CRect& r)
: left (r.left), top (r.top), right (r.right), bottom (r.bottom) {}
CRect& operator () (long left, long top, long right, long bottom)
{
if (left < right)
this->left = left, this->right = right;
else
this->left = right, this->right = left;
if (top < bottom)
this->top = top, this->bottom = bottom;
else
this->top = bottom, this->bottom = top;
return *this;
}
bool operator != (const CRect& other) const
{ return (left != other.left || right != other.right ||
top != other.top || bottom != other.bottom); }
bool operator == (const CRect& other) const
{ return (left == other.left && right == other.right &&
top == other.top && bottom == other.bottom); }
inline long width () const { return right - left; }
inline long height () const { return bottom - top; }
CRect &offset (long x, long y)
{ left += x; right += x; top += y; bottom += y; return *this; }
CRect &inset (long deltaX, long deltaY)
{ left += deltaX; right -= deltaX; top += deltaY; bottom -= deltaY;
return *this; }
CRect &moveTo (long x, long y)
{ long vDiff = y - top; long hDiff = x - left;
top += vDiff; bottom += vDiff; left += hDiff; right += hDiff;
return *this; }
bool pointInside (const CPoint& where) const; // Checks if point is inside this rect
bool isEmpty () const;
bool rectOverlap (const CRect& rect) const
{
if (right < rect.left) return false;
if (left > rect.right) return false;
if (bottom < rect.top) return false;
if (top > rect.bottom) return false;
return true;
}
void bound (const CRect& rect);
union
{ long left; long x;};
union
{ long top; long y;};
union
{ long right; long x2;};
union
{ long bottom; long y2;};
};
//-----------------------------------------------------------------------------
// Structure CPoint
//-----------------------------------------------------------------------------
struct CPoint
{
CPoint (long h = 0, long v = 0) : h (h), v (v) {}
CPoint& operator () (long h, long v)
{ this->h = h; this->v = v; return *this; }
bool isInside (CRect& r) const
{ return h >= r.left && h <= r.right && v >= r.top && v <= r.bottom; }
bool operator != (const CPoint &other) const
{ return (h != other.h || v != other.v); }
bool operator == (const CPoint &other) const
{ return (h == other.h && v == other.v); }
CPoint &offset (long h, long v)
{ this->h += h; this->v += v; return *this; }
union
{ long h; long x;};
union
{ long v; long y;};
};
//-----------------------------------------------------------------------------
// Structure CColor
//-----------------------------------------------------------------------------
struct CColor
{
CColor& operator () (unsigned char red,
unsigned char green,
unsigned char blue,
unsigned char unused)
{
this->red = red;
this->green = green;
this->blue = blue;
this->unused = unused;
return *this;
}
CColor& operator = (CColor newColor)
{
red = newColor.red;
green = newColor.green;
blue = newColor.blue;
unused = newColor.unused;
return *this;
}
CColor operator ~ ()
{
CColor c;
c.red = ~red;
c.green = ~green;
c.blue = ~blue;
c.unused = ~unused;
return c;
}
bool operator != (const CColor &other) const
{ return (red != other.red || green != other.green || blue != other.blue); }
bool operator == (const CColor &other) const
{ return (red == other.red && green == other.green && blue == other.blue); }
unsigned char red;
unsigned char green;
unsigned char blue;
unsigned char unused;
};
// define some basic colors
extern CColor kTransparentCColor;
extern CColor kBlackCColor;
extern CColor kWhiteCColor;
extern CColor kGreyCColor;
extern CColor kRedCColor;
extern CColor kGreenCColor;
extern CColor kBlueCColor;
extern CColor kYellowCColor;
extern CColor kCyanCColor;
extern CColor kMagentaCColor;
//-----------------------------------------------------------------------------
// Definitions of special characters in a platform independent way
#if WINDOWS || MOTIF
#define kDegreeSymbol "\xB0"
#define kInfiniteSymbol "oo"
#define kCopyrightSymbol "\xA9"
#define kTrademarkSymbol "\x99"
#define kRegisteredSymbol "\xAE"
#define kMicroSymbol "\x85"
#define kPerthousandSymbol "\x89"
#elif BEOS
#define kDegreeSymbol "\xC2\xB0"
#define kInfiniteSymbol "\xE2\x88\x9E"
#define kCopyrightSymbol "\xC2\xA9"
#define kTrademarkSymbol "\xE2\x84\xA2"
#define kRegisteredSymbol "\xC2\xAE"
#define kMicroSymbol "\xC2\xB5"
#define kPerthousandSymbol "\xE2\x80\xB0"
#elif MAC
#define kDegreeSymbol "\xA1"
#define kInfiniteSymbol "\xB0"
#define kCopyrightSymbol "\xA9"
#define kTrademarkSymbol "\xAA"
#define kRegisteredSymbol "\xA8"
#define kMicroSymbol "\xB5"
#define kPerthousandSymbol "\xE4"
#endif
//-----------------------------------------------------------------------------
//-----------
// Font Type
//-----------
enum CFont
{
kSystemFont = 0,
kNormalFontVeryBig,
kNormalFontBig,
kNormalFont,
kNormalFontSmall,
kNormalFontSmaller,
kNormalFontVerySmall,
kSymbolFont,
kNumStandardFonts
};
//-----------
// Text Face
//-----------
enum CTxtFace
{
kNormalFace = 0,
kBoldFace = 1,
kItalicFace = 2,
kUnderlineFace = 4
};
//-----------
// Line Style
//-----------
enum CLineStyle
{
kLineSolid = 0,
kLineOnOffDash
};
//-----------
// Draw Mode
//-----------
enum CDrawMode
{
kCopyMode = 0,
kOrMode,
kXorMode
};
//----------------------------
// Text Alignment (Horizontal)
//----------------------------
enum CHoriTxtAlign
{
kLeftText = 0,
kCenterText,
kRightText
};
//----------------------------
// Buttons Type (+modifiers)
//----------------------------
enum CButton
{
kLButton = 1,
kMButton = 2,
kRButton = 4,
kShift = 8,
kControl = 16,
kAlt = 32,
kApple = 64
};
//----------------------------
// Drop Type
//----------------------------
enum CDropType
{
kDropFiles = 0,
kDropText,
kDropUser = 1000
};
//----------------------------
// Cursor Type
//----------------------------
enum CCursorType
{
kCursorDefault = 0,
kCursorWait,
kCursorHSize,
kCursorVSize,
kCursorSizeAll,
kCursorNESWSize,
kCursorNWSESize
};
//----------------------------
// Knob Mode
//----------------------------
enum CKnobMode
{
kCircularMode = 0,
kRelativCircularMode,
kLinearMode
};
//-----------------------------------------------------------------------------
// CDrawContext Declaration
//-----------------------------------------------------------------------------
class CDrawContext
{
public:
CDrawContext (CFrame *pFrame, void *pSystemContext, void *pWindow = 0);
virtual ~CDrawContext ();
void moveTo (const CPoint &point);
void lineTo (const CPoint &point);
void polyLine (const CPoint *pPoint, long numberOfPoints);
void fillPolygon (const CPoint *pPoint, long numberOfPoints);
void drawRect (const CRect &rect);
void fillRect (const CRect &rect);
void drawArc (const CRect &rect, const CPoint &point1, const CPoint &point2);
void fillArc (const CRect &rect, const CPoint &point1, const CPoint &point2);
void drawEllipse (const CRect &rect);
void fillEllipse (const CRect &rect);
void drawPoint (const CPoint &point, CColor color);
CColor getPoint (const CPoint& point);
void floodFill (const CPoint& start);
void setLineStyle (CLineStyle style);
CLineStyle getLineStyle () { return lineStyle; }
void setLineWidth (long width);
long getLineWidth () { return frameWidth; }
void setDrawMode (CDrawMode mode);
CDrawMode getDrawMode () { return drawMode; }
void setClipRect (const CRect &clip);
CRect &getClipRect (CRect &clip) { clip = clipRect; return clip; }
void resetClipRect ();
void setFillColor (const CColor color);
CColor getFillColor () { return fillColor; }
void setFrameColor (const CColor color);
CColor getFrameColor () { return frameColor; }
void setFontColor (const CColor color);
CColor getFontColor () { return fontColor; }
void setFont (CFont fontID, const long size = 0, long style = 0);
CFont getFont () { return fontId; }
long getStringWidth (const char* pStr);
void drawString (const char *pString, const CRect &rect, const short opaque = false,
const CHoriTxtAlign hAlign = kCenterText);
long getMouseButtons ();
void getMouseLocation (CPoint &point);
bool waitDoubleClick ();
bool waitDrag ();
#if MOTIF
long getIndexColor (CColor color);
Colormap getColormap ();
Visual *getVisual ();
unsigned int getDepth ();
static long nbNewColor;
#endif
void *getWindow () { return pWindow; }
void setWindow (void *ptr) { pWindow = ptr; }
void getLoc (CPoint &where) { where = penLoc; }
CFrame* getFrame () { return pFrame; }
CPoint offsetScreen;
CPoint offset;
void *getSystemContext () { return pSystemContext; }
//-------------------------------------------
protected:
friend class CBitmap;
friend class COffscreenContext;
void *pSystemContext;
void *pWindow;
CFrame *pFrame;
long fontSize;
CFont fontId;
CColor fontColor;
CPoint penLoc;
long frameWidth;
CColor frameColor;
CColor fillColor;
CLineStyle lineStyle;
CDrawMode drawMode;
CRect clipRect;
#if WINDOWS
void *pBrush;
void *pPen;
void *pFont;
void *pOldBrush;
void *pOldPen;
void *pOldFont;
long iPenStyle;
#elif MAC
FontInfo fontInfoStruct;
Pattern fillPattern;
bool bInitialized;
virtual BitMapPtr getBitmap ();
virtual void releaseBitmap ();
virtual CGrafPtr getPort ();
#elif MOTIF
Display *pDisplay;
XFontStruct *pFontInfoStruct;
#elif BEOS
BView* pView;
BFont font;
void lineFromTo (CPoint& cstart, CPoint& cend);
#endif
};
//-----------------------------------------------------------------------------
// COffscreenContext Declaration
//-----------------------------------------------------------------------------
class COffscreenContext : public CDrawContext
{
public:
COffscreenContext (CDrawContext *pContext, CBitmap *pBitmap, bool drawInBitmap = false);
COffscreenContext (CFrame *pFrame, long width, long height, const CColor backgroundColor = kBlackCColor);
virtual ~COffscreenContext ();
void copyFrom (CDrawContext *pContext, CRect destRect, CPoint srcOffset = CPoint (0, 0));
void copyTo (CDrawContext* pContext, CRect& srcRect, CPoint destOffset = CPoint (0, 0));
inline long getWidth () { return width; }
inline long getHeight () { return height; }
//-------------------------------------------
protected:
CBitmap *pBitmap;
CBitmap *pBitmapBg;
long height;
long width;
bool bDestroyPixmap;
CColor backgroundColor;
#if WINDOWS
void* oldBitmap;
#elif MOTIF
Display *pXdisplay;
#elif BEOS
BBitmap *offscreenBitmap;
#elif MAC
BitMapPtr getBitmap ();
void releaseBitmap ();
CGrafPtr getPort ();
#endif
};
//-----------------------------------------------------------------------------
// CBitmap Declaration
//-----------------------------------------------------------------------------
class CBitmap
{
public:
CBitmap (long resourceID);
CBitmap (CFrame &frame, long width, long height);
~CBitmap ();
void draw (CDrawContext *pContext, CRect &rect, const CPoint &offset = CPoint (0, 0));
void drawTransparent (CDrawContext *pContext, CRect &rect, const CPoint &offset = CPoint (0, 0));
void drawAlphaBlend (CDrawContext *pContext, CRect &rect, const CPoint &offset = CPoint (0, 0), unsigned char alpha = 128);
inline long getWidth () { return width; }
inline long getHeight () { return height; }
void forget ();
void remember ();
long getNbReference () { return nbReference; }
bool isLoaded ();
void *getHandle ();
void setTransparentColor (const CColor color);
CColor getTransparentColor () { return transparentCColor; }
void setTransparencyMask (CDrawContext* pContext, const CPoint& offset = CPoint (0, 0));
#if BEOS
static void closeResource ();
#endif
//-------------------------------------------
protected:
long resourceID;
long nbReference;
long width;
long height;
CColor transparentCColor;
#if WINDOWS
void *pHandle;
void *pMask;
#elif MOTIF
void *createPixmapFromXpm (CDrawContext *pContext);
char **ppDataXpm;
Display *pXdisplay;
void *pHandle;
void *pMask;
#elif MAC
void* pHandle;
void* pMask;
#elif BEOS
static BResources *resourceFile;
BBitmap *bbitmap;
bool transparencySet;
#endif
};
enum {
kMessageUnknown = 0,
kMessageNotified = 1
};
//-----------------------------------------------------------------------------
// CView Declaration
//-----------------------------------------------------------------------------
class CView
{
public:
CView (const CRect &size);
virtual ~CView ();
void redraw ();
virtual void draw (CDrawContext *pContext);
virtual void drawRect (CDrawContext *pContext, CRect& updateRect) { draw (pContext); }
virtual bool checkUpdate (CRect& updateRect) { return updateRect.rectOverlap (size); }
virtual void mouse (CDrawContext *pContext, CPoint &where);
virtual void update (CDrawContext *pContext);
virtual long notify (CView* sender, const char* message);
virtual long onKeyDown (VstKeyCode& keyCode);
virtual long onKeyUp (VstKeyCode& keyCode);
virtual bool onDrop (void **ptrItems, long nbItems, long type, CPoint &where);
virtual bool onWheel (CDrawContext *pContext, const CPoint &where, float distance);
virtual void looseFocus (CDrawContext *pContext = 0);
virtual void takeFocus (CDrawContext *pContext = 0);
virtual bool isDirty () { return bDirty; }
virtual void setDirty (const bool val = true) { bDirty = val; }
virtual void setMouseEnabled (const bool bEnable = true) { bMouseEnabled = bEnable; }
virtual bool getMouseEnabled () { return bMouseEnabled; }
virtual void setMouseableArea (const CRect &rect) { mouseableArea = rect; }
virtual CRect &getMouseableArea (CRect &rect) { rect = mouseableArea; return rect;}
virtual bool hitTest (const CPoint& where, const long buttons = -1) { return where.isInside (size); }
virtual void setTransparency (bool val) { bTransparencyEnabled = val; }
virtual bool getTransparency () { return bTransparencyEnabled; }
long getHeight () { return size.height (); }
long getWidth () { return size.width (); }
virtual void setViewSize (CRect &rect);
virtual CRect &getViewSize (CRect &rect) { rect = size; return rect; }
virtual void setParentView (CView *pParentView) { this->pParentView = pParentView; }
CView *getParentView () { return pParentView; }
virtual void setParent (CFrame *pParent) { this->pParent = pParent; }
CFrame *getParent () { return pParent; }
virtual void *getEditor ();
virtual bool removed (CView* parent) { return true; } // it has have been removed from parent view
virtual bool attached (CView* view) { return true; } // it has been attached to a view
virtual void forget ();
virtual void remember ();
virtual long getNbReference () { return nbReference; }
//-------------------------------------------
protected:
friend class CControl;
friend class CFrame;
friend class CViewContainer;
long nbReference;
CRect size;
CRect mouseableArea;
CFrame *pParent;
CView *pParentView;
bool bDirty;
bool bMouseEnabled;
bool bTransparencyEnabled;
};
//-----------------------------------------------------------------------------
// CFrame Declaration
//-----------------------------------------------------------------------------
class CFrame : public CView
{
public:
CFrame (const CRect &size, void *pSystemWindow, void *pEditor);
CFrame (const CRect &size, char *pTitle, void *pEditor, const long style = 0);
~CFrame ();
bool open (CPoint *pPoint = 0);
bool close ();
bool isOpen () { return bOpenFlag; }
void draw (CDrawContext *pContext);
void drawRect (CDrawContext *pContext, CRect& updateRect);
void draw (CView *pView = 0);
void mouse (CDrawContext *pContext, CPoint &where);
bool onDrop (void **ptrItems, long nbItems, long type, CPoint &where);
bool onWheel (CDrawContext *pContext, const CPoint &where, float distance);
long onKeyDown (VstKeyCode& keyCode);
long onKeyUp (VstKeyCode& keyCode);
void update (CDrawContext *pContext);
void idle ();
void doIdleStuff ();
// get the current time (in ms)
unsigned long getTicks ();
long getKnobMode ();
bool getPosition (long &x, long &y);
bool setSize (long width, long height);
bool getSize (CRect *pSize);
void setBackground (CBitmap *pBackground);
CBitmap *getBackground () { return pBackground; }
virtual bool addView (CView *pView);
virtual bool removeView (CView *pView, const bool &withForget = false);
virtual bool removeAll (const bool &withForget = true);
virtual bool isChild (CView *pView);
virtual long getNbViews () { return viewCount; }
virtual CView *getView (long index);
long setModalView (CView *pView);
CView *getModalView () { return pModalView; }
void beginEdit (long index);
void endEdit (long index);
bool getCurrentLocation (CPoint &where);
void setCursor (CCursorType type);
CView *getCurrentView ();
#if WINDOWS
HWND getOuterWindow ();
void *getSystemWindow () { return pHwnd; }
#elif BEOS
void *getSystemWindow () { return pPlugView; }
#else
void *getSystemWindow () { return pSystemWindow; }
#endif
void *getParentSystemWindow () { return pSystemWindow; }
void setParentSystemWindow (void *val) { pSystemWindow = val; }
virtual void *getEditor () { return pEditor; }
void setEditView (CView *pView);
CView *getEditView () { return pEditView; }
bool setDropActive (bool val);
bool isDropActive () { return bDropActive; };
void invalidate (const CRect &rect);
#if MOTIF
Colormap getColormap () { return colormap; }
Visual *getVisual () { return pVisual; }
unsigned int getDepth () { return depth; }
Display *getDisplay () { return pDisplay; }
Window getWindow () { return window; }
void freeGc ();
Region region;
GC gc;
GC getGC () { return gc; }
#endif
void setOpenFlag (bool val) { bOpenFlag = val;};
bool getOpenFlag () { return bOpenFlag; };
//-------------------------------------------
protected:
bool initFrame (void *pSystemWin);
bool isSomethingDirty ();
void *pEditor;
void *pSystemWindow;
CBitmap *pBackground;
long viewCount;
long maxViews;
CView **ppViews;
CView *pModalView;
CView *pEditView;
bool bFirstDraw;
bool bOpenFlag;
bool bDropActive;
#if WINDOWS
void *pHwnd;
HDC hdc;
HINSTANCE hInstMsimg32dll;
#elif MOTIF
Colormap colormap;
Display *pDisplay;
Visual *pVisual;
Window window;
unsigned int depth;
friend void _destroyCallback (Widget, XtPointer, XtPointer);
#elif BEOS
PlugView *pPlugView;
#endif
//-------------------------------------------
private:
CDrawContext *pFrameContext;
bool bAddedWindow;
void *pVstWindow;
void *defaultCursor;
};
//-----------------------------------------------------------------------------
// CCView Declaration
//-----------------------------------------------------------------------------
class CCView
{
public:
CCView (CView *pView);
~CCView ();
CView *pView;
CCView *pNext;
CCView *pPrevious;
};
//-----------------------------------------------------------------------------
// CViewContainer Declaration
//-----------------------------------------------------------------------------
class CViewContainer : public CView
{
public:
CViewContainer (const CRect &size, CFrame *pParent, CBitmap *pBackground = 0);
~CViewContainer ();
virtual void addView (CView *pView);
virtual void addView (CView *pView, CRect &mouseableArea, bool mouseEnabled = true);
virtual void removeView (CView *pView, const bool &withForget = true);
virtual void removeAll (const bool &withForget = true);
virtual bool isChild (CView *pView);
virtual long getNbViews ();
virtual CView *getView (long index);
virtual long notify (CView* sender, const char* message);
virtual void draw (CDrawContext *pContext);
virtual void drawRect (CDrawContext *pContext, CRect& updateRect);
virtual void mouse (CDrawContext *pContext, CPoint &where);
virtual bool onDrop (void **ptrItems, long nbItems, long type, CPoint &where);
virtual bool onWheel (CDrawContext *pContext, const CPoint &where, float distance);
virtual void update (CDrawContext *pContext);
virtual bool hitTest (const CPoint& where, const long buttons = -1);
virtual long onKeyDown (VstKeyCode& keyCode);
virtual long onKeyUp (VstKeyCode& keyCode);
virtual void looseFocus (CDrawContext *pContext = 0);
virtual void takeFocus (CDrawContext *pContext = 0);
virtual bool isDirty ();
virtual void setBackgroundColor (const CColor color);
virtual CColor getBackgroundColor () { return backgroundColor; }
virtual void setViewSize (CRect &rect);
virtual void setBackground (CBitmap *background);
virtual CBitmap *getBackground () { return pBackground; }
virtual void setBackgroundOffset (const CPoint &p) { backgroundOffset = p; }
virtual const CPoint& getBackgroundOffset () { return backgroundOffset; }
void drawBackgroundRect (CDrawContext *pContext, CRect& _updateRect);
enum {
kNormalUpdate = 0,
kOnlyDirtyUpdate
};
virtual void setMode (long val) { mode = val; }
virtual long getMode () { return mode; }
virtual void useOffscreen (bool b);
virtual bool removed (CView* parent);
virtual bool attached (CView* view);
CView *getCurrentView ();
//-------------------------------------------
protected:
bool hitTestSubViews (const CPoint& where, const long buttons = -1);
CCView *pFirstView;
CCView *pLastView;
CBitmap *pBackground;
long mode;
COffscreenContext *pOffscreenContext;
CColor backgroundColor;
CPoint backgroundOffset;