File: winFLTK.h

package info (click to toggle)
csound-plugins 1.0.2~dfsg1-5
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,960 kB
  • sloc: cpp: 16,586; ansic: 7,522; python: 458; sh: 94; makefile: 25
file content (140 lines) | stat: -rw-r--r-- 3,601 bytes parent folder | download | duplicates (5)
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
/*
    winFLTK.h:

    Copyright (C) 2006 Istvan Varga

    This file is part of Csound.

    The Csound Library is free software; you can redistribute it
    and/or modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    Csound is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with Csound; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
    02110-1301 USA
*/

#ifndef CSOUND_WINFLTK_H
#define CSOUND_WINFLTK_H

#include "csdl.h"
#ifdef __cplusplus
#include <FL/Fl.H>
#endif

/**
 * FLTK flags is the sum of any of the following values:
 *   1 (input):  disable widget opcodes by setting up dummy opcodes instead
 *   2 (input):  disable FLTK graphs
 *   4 (input):  disable the use of a separate thread for widget opcodes
 *   8 (input):  disable the use of Fl::lock() and Fl::unlock()
 *  16 (input):  disable the use of Fl::awake()
 *  32 (output): widget opcodes are used
 *  64 (output): FLTK graphs are used
 * 128 (input):  disable widget opcodes by not registering any opcodes
 * 256 (input):  disable the use of Fl::wait() (implies no widget thread)
 */

static inline int getFLTKFlags(CSOUND *csound)
{
    return (*((int*) csound->QueryGlobalVariableNoCheck(csound, "FLTK_Flags")));
}

static inline int *getFLTKFlagsPtr(CSOUND *csound)
{
    return ((int*) csound->QueryGlobalVariableNoCheck(csound, "FLTK_Flags"));
}

#ifdef __cplusplus

static inline void Fl_lock(CSOUND *csound)
{
#ifdef NO_FLTK_THREADS
    (void) csound;
#else
    if (!(getFLTKFlags(csound) & 8)) {
      Fl::lock();
    }
#endif
}

static inline void Fl_unlock(CSOUND *csound)
{
#ifdef NO_FLTK_THREADS
    (void) csound;
#else
    if (!(getFLTKFlags(csound) & 8)) {
      Fl::unlock();
    }
#endif
}

static inline void Fl_awake(CSOUND *csound)
{
#ifdef NO_FLTK_THREADS
    (void) csound;
#else
    if (!(getFLTKFlags(csound) & 16)) {
      Fl::awake();
    }
#endif
}

static inline void Fl_wait(CSOUND *csound, double seconds)
{
    if (!(getFLTKFlags(csound) & 256))
      Fl::wait(seconds);
}

static inline void Fl_wait_locked(CSOUND *csound, double seconds)
{
    int     fltkFlags;

    fltkFlags = getFLTKFlags(csound);
    if (!(fltkFlags & 256)) {
#ifndef NO_FLTK_THREADS
      if (!(fltkFlags & 8))
        Fl::lock();
#endif
      Fl::wait(seconds);
#ifndef NO_FLTK_THREADS
      if (!(fltkFlags & 8))
        Fl::unlock();
#endif
    }
}

#endif  /* __cplusplus */

#ifdef __cplusplus
extern "C" {
#endif

extern  int       CsoundYield_FLTK(CSOUND *);
extern  void      DrawGraph_FLTK(CSOUND *, WINDAT *);
extern  int       ExitGraph_FLTK(CSOUND *);
extern  void      kill_graph(CSOUND *, uintptr_t);
extern  void      KillXYin_FLTK(CSOUND *, XYINDAT *);
extern  uintptr_t MakeWindow_FLTK(CSOUND *, char *);
extern  void      MakeXYin_FLTK(CSOUND *, XYINDAT *, MYFLT, MYFLT);
extern  int       myFLwait(void);
extern  void      ReadXYin_FLTK(CSOUND *, XYINDAT *);
  extern  void      flgraph_init(CSOUND *csound);
extern  void      widget_init(CSOUND *);
extern  int       widget_reset(CSOUND *, void *);

extern const OENTRY widgetOpcodes_[];

#ifdef __cplusplus
}       /* extern "C" */
#endif

#endif  /* CSOUND_WINFLTK_H */