2
Copyright (C) 2003-2005 Fons Adriaensen <fons.adriaensen@skynet.be>
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.
21
#include "callbacks.h"
25
Instrwin::Instrwin (X_window *parent, X_callback *callb, int xp, int yp, X_resman *xresm) :
26
X_window (parent, xp, yp, XSIZE, YSIZE, Colors.main_bg),
31
_atom = XInternAtom (dpy (), "WM_DELETE_WINDOW", True);
32
XSetWMProtocols (dpy (), win (), &_atom, 1);
33
_atom = XInternAtom (dpy (), "WM_PROTOCOLS", True);
37
Instrwin::~Instrwin (void)
42
void Instrwin::handle_event (XEvent *E)
47
handle_xmesg ((XClientMessageEvent *) E);
53
void Instrwin::handle_xmesg (XClientMessageEvent *E)
55
if (E->message_type == _atom) x_unmap ();
59
void Instrwin::handle_callb (int k, X_window *W, XEvent *E)
65
case SLIDER | X_slider::MOVE:
66
case SLIDER | X_slider::STOP:
68
X_slider *X = (X_slider *) W;
70
_divis = (c >> DIVIS_BIT0) - 1;
71
_parid = c & DIVIS_MASK;
72
_value = X->get_val ();
73
_final = k == (SLIDER | X_slider::STOP);
74
_callb->handle_callb (CB_DIVIS_ACT, this, E);
78
case BUTTON | X_button::PRESS:
80
X_button *B = (X_button *) W;
86
incdec_temp (k == TEMP_DEC ? -1 : 1);
91
incdec_freq (k == FREQ_DEC ? -1 : 1);
95
_callb->handle_callb (CB_RETUNE, this, E);
109
void Instrwin::setup (M_ifc_init *M)
111
int i, k, n1, n2, x1, x2, y;
117
add_text (100, 5, 60, 20, "Tuning", &text0, -1);
120
_temp_txt = new X_textip (this, 0, &text0, 15, 41, 150, 20, 31);
121
_temp_txt->set_align (1);
123
_freq_txt = new X_textip (this, 0, &text0, 105, 65, 60, 20, 7);
124
_freq_txt->set_align (1);
126
(_dec_temp = new X_ibutton (this, this, &but2, 170, 41, disp ()->image1515 (X_display::IMG_LT), TEMP_DEC))->x_map ();
127
(_inc_temp = new X_ibutton (this, this, &but2, 187, 41, disp ()->image1515 (X_display::IMG_RT), TEMP_INC))->x_map ();
128
(_dec_freq = new X_ibutton (this, this, &but2, 170, 65, disp ()->image1515 (X_display::IMG_LT), FREQ_DEC))->x_map ();
129
(_inc_freq = new X_ibutton (this, this, &but2, 187, 65, disp ()->image1515 (X_display::IMG_RT), FREQ_INC))->x_map ();
132
(_tune_exe = new X_tbutton (this, this, &but1, 70, 100, "Retune", 0, TUNE_EXE))->x_map ();
133
(_tune_can = new X_tbutton (this, this, &but1, 135, 100, "Cancel", 0, TUNE_CAN))->x_map ();
135
for (i = n1 = n2 = 0; i < M->_ndivis; i++)
137
if (M->_divisd [i]._flags & 1) n1++;
138
if (M->_divisd [i]._flags & 2) n2++;
144
for (i = 0; i < M->_ndivis; i++)
146
k = DIVIS_STEP * (i + 1);
147
if (M->_divisd [i]._flags & 1)
149
(D->_slid [0] = new X_hslider (this, this, &sli1, &sca_Swl, x2, y, 20, k))->x_map ();
150
(new X_hscale (this, &sca_Swl, x2, y + 20, 10))->x_map ();
152
else D->_slid [0] = 0;
153
if (M->_divisd [i]._flags & 2)
155
(D->_slid [1] = new X_hslider (this, this, &sli1, &sca_Tfr, x1, y, 20, k + 1))->x_map ();
156
(D->_slid [2] = new X_hslider (this, this, &sli1, &sca_Tmd, x1 + 160, y, 20, k + 2))->x_map ();
157
(new X_hscale (this, &sca_Tfr, x1, y + 20, 10))->x_map ();
158
(new X_hscale (this, &sca_Tmd, x1 + 160, y + 20, 10))->x_map ();
160
else D->_slid [1] = D->_slid [2] = 0;
161
if (D->_slid [0] || D->_slid [1])
163
add_text (x1 - 90, y, 80, 20, M->_divisd [i]._label, &text0, 1);
170
add_text (x1, 5, 80, 20, "Trem freq", &text0, -1);
171
add_text (x1 + 160, 5, 80, 20, "Trem amp", &text0, -1);
173
if (n2) add_text (x2, 5, 80, 20, "Swell", &text0, -1);
176
if (y < YSIZE) y = YSIZE;
177
sprintf (s, "%s Aeolus-%s Instrument settings", M->_appid, VERSION);
180
_ntempe = M->_ntempe;
181
if (_ntempe > NTEMPE) _ntempe = NTEMPE;
182
for (i = 0; i < _ntempe; i++) _temped [i] = M->_temped [i]._label;
184
H.position (_xp, _yp);
185
H.minsize (200, 100);
186
H.maxsize (XSIZE, y);
187
H.rname (_xresm->rname ());
188
H.rclas (_xresm->rclas ());
194
void Instrwin::set_dipar (M_ifc_dipar *M)
198
if ((M->_divis >= 0) && (M->_divis < NDIVIS))
200
if ((M->_parid >= 0) && (M->_parid < 3))
202
S = _divisd [M->_divis]._slid [M->_parid];
203
if (S) S->set_val (M->_value);
209
void Instrwin::set_tuning (M_ifc_retune *M)
211
_freq = _freq1 = M->_freq;
212
_temp = _temp1 = M->_temp;
217
void Instrwin::show_tuning (int b)
221
sprintf (s, "%3.1lf", _freq);
222
_freq_txt->set_text (s);
223
_temp_txt->set_text (_temped [_temp] );
224
_tune_exe->set_stat (b);
225
_tune_can->set_stat (b);
228
void Instrwin::incdec_temp (int d)
230
_temp += d + _ntempe;
236
void Instrwin::incdec_freq (int d)
239
if (_freq < 400) _freq = 400;
240
if (_freq > 480) _freq = 480;
245
void Instrwin::add_text (int xp, int yp, int xs, int ys, const char *text, X_textln_style *style, int align)
247
(new X_textln (this, style, xp, yp, xs, ys, text, align))->x_map ();