File: vstgui.h

package info (click to toggle)
audacity 0.98-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,896 kB
  • ctags: 4,089
  • sloc: cpp: 26,099; ansic: 4,961; sh: 2,465; makefile: 156; perl: 23
file content (677 lines) | stat: -rwxr-xr-x 15,041 bytes parent folder | download
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
//-----------------------------------------------------------------------------
// VST Plug-Ins SDK
// User interface framework for VST plugins
//
// Version 1.0
//
// First version       : Wolfgang Kundrus
// Added Motif/Windows version : Yvan Grabit      01.98
// Added Mac version   : Charlie Steinberg        02.98
// Added BeOS version  : Georges-Edouard Berenger 05.99
//
// (c)1999 Steinberg Soft+Hardware GmbH
//-----------------------------------------------------------------------------

#ifndef __vstgui__
#define __vstgui__

// define global defines
#if WIN32
#define WINDOWS 1
#elif SGI | SUN
#define MOTIF 1
#elif __MWERKS__
#define MAC 1
#endif

#ifndef __AEffEditor__
#include "AEffEditor.hpp"
#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
#include <Quickdraw.h>
class CCashedPict;

//----------------------------------------------------
#elif BEOS
#include <View.h>
class PlugView;
class BBitmap;
class BResources;

#endif

//----------------------------------------------------
//----------------------------------------------------
class CFrame;
class CDrawContext;
class COffscreenContext;
class CControl;
class CBitmap;


//-----------------------------------------------------------------------------
// AEffGUIEditor Declaration
//-----------------------------------------------------------------------------
class AEffGUIEditor:public AEffEditor {
   public:AEffGUIEditor(AudioEffect * effect);

   virtual ~ AEffGUIEditor();

   virtual void setParameter(long index, float value) {
      postUpdate();
   } virtual long getRect(ERect ** rect);
   virtual long open(void *ptr);
   virtual void idle();
   virtual void draw(ERect * rect);
#if MAC
   virtual long mouse(long x, long y);
#endif

   // get the current time (in ms)
   long getTicks();

   // feedback to appli.
   void doIdleStuff();

   // get the effect attached to this editor
   AudioEffect *getEffect() {
      return effect;
   }

//---------------------------------------
 protected:
   ERect rect;
   CFrame *frame;

   unsigned long lLastTicks;

 private:
   short sInControlLoop;
};


//-----------------------------------------------------------------------------
// 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;
   }

   long left;
   long top;
   long right;
   long bottom;
   inline long width() {
      return right - left;
   }
   inline long height() {
      return bottom - top;
   }

   void offset(long x, long y) {
      left += x;
      right += x;
      top += y;
      bottom += y;
   }
};

//-----------------------------------------------------------------------------
// 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) {
      return h >= r.left && h <= r.right && v >= r.top && v <= r.bottom;
   }

   long h;
   long v;
};

//-----------------------------------------------------------------------------
// 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;
   }

   bool operator != (CColor newColor) {
      return (red != newColor.red ||
              green != newColor.green || blue != newColor.blue);
   }

   bool operator == (CColor newColor) {
      return (red == newColor.red &&
              green == newColor.green && blue == newColor.blue);
   }

   unsigned char red;
   unsigned char green;
   unsigned char blue;
   unsigned char unused;
};

// define some basic colors
static CColor kTransparentCColor = { 255, 255, 255, 0 };
static CColor kBlackCColor = { 0, 0, 0, 0 };
static CColor kWhiteCColor = { 255, 255, 255, 0 };
static CColor kGreyCColor = { 127, 127, 127, 0 };
static CColor kRedCColor = { 255, 0, 0, 0 };
static CColor kGreenCColor = { 0, 255, 0, 0 };
static CColor kBlueCColor = { 0, 0, 255, 0 };
static CColor kYellowCColor = { 255, 255, 0, 0 };
static CColor kCyanCColor = { 255, 0, 255, 0 };
static CColor kMagentaCColor = { 0, 255, 255, 0 };

//-----------------------------------------------------------------------------
//-----------
// Font type
//-----------
enum CFont {
   kSystemFont = 0,
   kNormalFontVeryBig,
   kNormalFontBig,
   kNormalFont,
   kNormalFontSmall,
   kNormalFontVerySmall,
   kSymbolFont,

   kNumStandardFonts
};

//-----------
// Line style
//-----------
enum CLineStyle {
   kLineSolid = 0,
   kLineOnOffDash
};

//----------------------------
// 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
};

//-----------------------------------------------------------------------------
// CDrawContext Declaration
//-----------------------------------------------------------------------------
class CDrawContext {
 public:
   CDrawContext(CFrame * frame, void *systemContext, void *window = 0);
    virtual ~ CDrawContext();

   void moveTo(CPoint & point);
   void lineTo(CPoint & point);

   void polyLine(CPoint * point, int numberOfPoints);
   void fillPolygon(CPoint * point, int numberOfPoints);

   void drawRect(CRect & rect);
   void fillRect(CRect & rect);

   void drawArc(CRect & rect, CPoint & point1, CPoint & point2);
   void fillArc(CRect & rect, CPoint & point1, CPoint & point2);

   void drawEllipse(CRect & rect);
   void fillEllipse(CRect & rect);

   void drawPoint(CPoint & point, CColor color);

   void setLineStyle(CLineStyle style);
   CLineStyle getLineStyle() {
      return lineStyle;
   } void setLineWidth(int width);
   int getLineWidth() {
      return frameWidth;
   }

   void setFillColor(CColor color);
   CColor getFillColor() {
      return fillColor;
   }

   void setFrameColor(CColor color);
   CColor getFrameColor() {
      return frameColor;
   }

   void setFontColor(CColor color);
   CColor getFontColor() {
      return fontColor;
   }
   void setFont(CFont fontID, const int size = 0);

   void drawString(const char *string, CRect & rect, const short opaque =
                   false, const CHoriTxtAlign hAlign = kCenterText);

   int getMouseButtons();
   void getMouseLocation(CPoint & point);

#if MOTIF
   int getIndexColor(CColor color);
   Colormap getColormap();
   Visual *getVisual();
   unsigned int getDepth();

   static int nbNewColor;
#endif

   void *getWindow() {
      return window;
   }
   void setWindow(void *ptr) {
      window = ptr;
   }
   void getLoc(CPoint & where) {
      where = penLoc;
   }

   //-------------------------------------------
 protected:

   friend class CBitmap;
   friend class COffscreenContext;

   void *getSystemContext() {
      return systemContext;
   }

   void *systemContext;
   void *window;
   CFrame *frame;

   int fontSize;
   CColor fontColor;
   CPoint penLoc;

   int frameWidth;
   CColor frameColor;
   CColor fillColor;
   CLineStyle lineStyle;

#if WINDOWS
   void *brush;
   void *pen;
   void *font;
   void *oldbrush;
   void *oldpen;
   void *oldfont;
   int iPenStyle;

#elif MAC
   FontInfo fontInfoStruct;
   Pattern fillPattern;

#elif MOTIF
   Display *display;

   XFontStruct *fontInfoStruct;
   CFont fontInfoId;

#elif BEOS
   BView *plugView;
   BFont font;
   void lineFromTo(CPoint & cstart, CPoint & cend);

#endif
};

//-----------------------------------------------------------------------------
// COffscreenContext Declaration
//-----------------------------------------------------------------------------
class COffscreenContext:public CDrawContext {
 public:
   COffscreenContext(CDrawContext * context, CBitmap * bitmap);
   COffscreenContext(CFrame * frame, long width, long height,
                     const CColor backgroundColor = kBlackCColor);

    virtual ~ COffscreenContext();

   void transfert(CDrawContext * context, CRect destRect,
                  CPoint srcOffset = CPoint(0, 0));
   inline int getWidth() {
      return width;
   } inline int getHeight() {
      return height;
   }

   //-------------------------------------------
 protected:
   bool destroyPixmap;
   CBitmap *bitmap;

   long height;
   long width;

   CColor backgroundColor;

#if MOTIF
   Display *xdisplay;

#elif BEOS
   BBitmap *offscreenBitmap;
#endif
};


//-----------------------------------------------------------------------------
// CBitmap Declaration
//-----------------------------------------------------------------------------
class CBitmap {
 public:
   CBitmap(int resourceID);
    CBitmap(CFrame & frame, int width, int height);
   ~CBitmap();

   void draw(CDrawContext *, CRect & rect, const CPoint & offset =
             CPoint(0, 0));
   void drawTransparent(CDrawContext * context, CRect & rect,
                        const CPoint & offset = CPoint(0, 0));

   inline int getWidth() {
      return width;
   } inline int getHeight() {
      return height;
   }

   void forget();
   void remember();

   void *getHandle() {
      return handle;
   }

#if BEOS
   static void closeResource();
#endif

   //-------------------------------------------
 protected:
   int resourceID;
   void *handle;
   void *mask;
   int width;
   int height;

   int nbReference;

#if MOTIF
   void *createPixmapFromXpm(CDrawContext * context);

   char **dataXpm;
   Display *xdisplay;

#elif MAC
   CCashedPict *pPict;

#elif BEOS
   static BResources *resourceFile;
   BBitmap *bbitmap;
   bool transparencySet;
#endif
};

//-----------------------------------------------------------------------------
// CView Declaration
//-----------------------------------------------------------------------------
class CView {
 public:
   CView(CRect & size);
   virtual ~ CView();

   void redraw();
   virtual void draw(CDrawContext * context);
   virtual void mouse(CDrawContext * context, CPoint & where);
   virtual void update(CDrawContext * context);

   virtual void looseFocus();
   virtual void takeFocus();

   virtual void setTempOffscreen(COffscreenContext * tempOffscr);

   int getHeight() {
      return size.height();
   } int getWidth() {
      return size.width();
   }

   CFrame *getParent() {
      return parent;
   }

   //-------------------------------------------
 protected:
   friend class CControl;
   friend class CFrame;
   CRect size;
   CFrame *parent;
   COffscreenContext *tempOffscreen;
};

//-----------------------------------------------------------------------------
// CFrame Declaration
//-----------------------------------------------------------------------------
class CFrame:public CView {
 public:
   CFrame(CRect & size, void *systemWindow, AEffGUIEditor * editor);
   CFrame(CRect & size, char *title, AEffGUIEditor * editor,
          const int style = 0);

   ~CFrame();

   bool open(CPoint * point = 0);
   bool close();
   bool isOpen() {
      return openFlag;
   } void draw(CDrawContext * context);
   void draw(CView * view = 0);
   void mouse(CDrawContext * context, CPoint & where);

   void update(CDrawContext * context);
   void idle();
   void doIdleStuff() {
      if (editor)
         editor->doIdleStuff();
   }

   bool getPosition(int &x, int &y);
   bool setSize(int width, int height);
   bool getSize(CRect * size);

   void setBackground(CBitmap * background);
   CBitmap *getBackground() {
      return background;
   }

   virtual bool addView(CView * view);
   virtual bool removeView(CView * view);

   int setModalView(CView * view);

#if WINDOWS
   void *getSystemWindow() {
      return hwnd;
   }
#elif BEOS
   void *getSystemWindow() {
      return plugView;
   }
#else
   void *getSystemWindow() {
      return systemWindow;
   }
#endif

   AEffGUIEditor *getEditor() {
      return editor;
   }

   void setEditView(CView * view) {
      editView = view;
   }
   CView *getEditView() {
      return editView;
   }

#if MOTIF
   Colormap getColormap() {
      return colormap;
   }
   Visual *getVisual() {
      return visual;
   }
   unsigned int getDepth() {
      return depth;
   }
   Display *getDisplay() {
      return display;
   }
   Window getWindow() {
      return window;
   }
   void freeGc();

   Region region;

   GC gc;
   GC getGC() {
      return gc;
   }
#else
   void *getGC() {
      return 0;
   }
#endif

   //-------------------------------------------
 protected:
   bool initFrame(void *systemWin);

   AEffGUIEditor *editor;

   void *systemWindow;
   CBitmap *background;
   int viewCount;
   int maxViews;
   CView **views;
   CView *modalView;
   CView *editView;

   bool firstDraw;
   bool openFlag;

#if WINDOWS
   void *hwnd;
   friend LONG WINAPI WindowProc(HWND hwnd, UINT message, WPARAM wParam,
                                 LPARAM lParam);

#elif MOTIF
   Colormap colormap;
   Display *display;
   Visual *visual;
   Window window;
   unsigned int depth;

   friend void _destroyCallback(Widget, XtPointer, XtPointer);

#elif BEOS
   PlugView *plugView;
#endif

   //-------------------------------------------
 private:
   bool addedWindow;
   void *vstWindow;
};


// include the control object
#ifndef __vstcontrols__
#include "vstcontrols.h"
#endif


//-End--------------------------------------
#endif