2
Copyright (C) 2003-2010 Fons Adriaensen <fons@kokkinizita.net>
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation; either version 2 of the License, or
7
(at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
#include <clthreads.h>
25
#include "callbacks.h"
29
extern "C" Iface *create_iface (int ac, char *av [])
31
return new Xiface (ac, av);
36
Xiface::Xiface (int ac, char *av [])
38
_xresm.init (&ac, av, (char *)"aeolus", 0, 0);
39
_disp = new X_display (_xresm.get (".display", 0));
40
if (_disp->dpy () == 0)
42
fprintf (stderr, "Can't open display !\n");
46
init_styles (_disp, &_xresm);
47
_root = new X_rootwin (_disp);
48
_xhan = new X_handler (_disp, this, EV_XWIN);
56
Xiface::~Xiface (void)
68
void Xiface::stop (void)
74
void Xiface::thr_main (void)
82
switch (get_event_timed ())
86
XFlush (_disp->dpy ());
91
handle_mesg (get_message ());
92
XFlush (_disp->dpy ());
96
_root->handle_event ();
104
send_event (EV_EXIT, 1);
108
void Xiface::handle_time (void)
112
_mainwin->handle_time ();
113
_editwin->handle_time ();
117
send_event (TO_MODEL, _aupar);
122
send_event (TO_MODEL, _dipar);
128
void Xiface::handle_mesg (ITC_mesg *M)
134
M_ifc_init *X = (M_ifc_init *) M;
135
_mainwin = new Mainwin (_root, this, 100, 100, &_xresm);
136
_midiwin = new Midiwin (_root, this, 120, 120, &_xresm);
137
_audiowin = new Audiowin (_root, this, 140, 140, &_xresm);
138
_instrwin = new Instrwin (_root, this, 160, 160, &_xresm);
139
_editwin = new Editwin (_root, this, 180, 180, &_xresm);
142
_audiowin->setup (X);
143
_instrwin->setup (X);
144
_editwin->sdir (X->_stops);
145
_editwin->wdir (X->_waves);
150
_mainwin->set_ready ();
159
M_ifc_ifelm *X = (M_ifc_ifelm *) M;
160
_mainwin->set_ifelm (X);
165
M_ifc_preset *X = (M_ifc_preset *) M;
166
_mainwin->set_state (X);
171
M_ifc_aupar *X = (M_ifc_aupar *) M;
172
if (X->_srcid != SRC_GUI_DRAG) _audiowin->set_aupar (X);
177
M_ifc_dipar *X = (M_ifc_dipar *) M;
178
if (X->_srcid != SRC_GUI_DRAG) _instrwin->set_dipar (X);
182
_instrwin->set_tuning ((M_ifc_retune *) M);
188
_editp = (M_ifc_edit *) M;
189
_editwin->init (_editp->_synth);
190
_editwin->x_mapraised ();
196
_midiwin->setconf ((M_ifc_chconf *) M);
202
if (M) M->recover ();
206
void Xiface::handle_callb (int k, X_window *W, XEvent *E)
211
_audiowin->x_mapraised ();
215
_midiwin->x_mapraised ();
219
_instrwin->x_mapraised ();
223
send_event (TO_MODEL, new ITC_mesg (MT_IFC_SAVE));
227
send_event (TO_MODEL, new M_ifc_anoff (127));
231
send_event (TO_MODEL, _mainwin->mesg ());
239
if (_aupar) _aupar->_value = _audiowin->value ();
240
else _aupar = new M_ifc_aupar (SRC_GUI_DRAG, _audiowin->asect (), _audiowin->parid (), _audiowin->value ());
241
if (_audiowin->final ())
243
_aupar->_srcid = SRC_GUI_DONE;
244
send_event (TO_MODEL, _aupar);
250
if (_dipar) _dipar->_value = _instrwin->value ();
251
else _dipar = new M_ifc_dipar (SRC_GUI_DRAG, _instrwin->divis (), _instrwin->parid (), _instrwin->value ());
252
if (_instrwin->final ())
254
_dipar->_srcid = SRC_GUI_DONE;
255
send_event (TO_MODEL, _dipar);
261
send_event (TO_MODEL, new M_ifc_retune (_instrwin->freq (), _instrwin->temp ()));
264
case CB_MIDI_SETCONF:
265
send_event (TO_MODEL, new M_ifc_chconf (MT_IFC_MCSET, _midiwin->preset (), _midiwin->chconf ()));
268
case CB_MIDI_GETCONF:
269
send_event (TO_MODEL, new M_ifc_chconf (MT_IFC_MCGET, _midiwin->preset (), 0));
273
send_event (TO_MODEL, new M_ifc_edit (MT_IFC_APPLY, _editp->_group, _editp->_ifelm, 0));
274
_mainwin->set_label (_editp->_group, _editp->_ifelm, _editp->_synth->_stopname);
275
_editwin->lock (true);
279
_editwin->x_unmap ();