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
|
/*
Copyright (C) 2006-2009 Fons Adriaensen <fons@kokkinizita.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdlib.h>
#include <stdio.h>
#include "styles.h"
#include "global.h"
#include "typewin.h"
Typewin::Typewin (X_rootwin *parent, X_callback *callb, X_resman *xres, int xp, int yp) :
X_window (parent, xp, yp, XSIZE, YSIZE, XftColors [C_MAIN_BG]->pixel),
_callb (callb),
_rcoeff (this, this),
_rh_ord (this, this),
_rv_ord (this, this),
_rnband (this, this)
{
X_hints hints;
_atom = XInternAtom (dpy (), "WM_DELETE_WINDOW", True);
XSetWMProtocols (dpy (), win (), &_atom, 1);
_atom = XInternAtom (dpy (), "WM_PROTOCOLS", True);
hints.position (xp, yp);
hints.minsize (XSIZE, YSIZE);
hints.maxsize (XSIZE, YSIZE);
x_apply (&hints);
x_set_title (xres->get (".title", "AmbDec - New configuration"));
(new X_textln (this, &Tst2, 20, 15, 115, 18, "Matrix scaling", -1))->x_map ();
(new X_textln (this, &Tst2, 150, 15, 115, 18, "Horizontal. order", -1))->x_map ();
(new X_textln (this, &Tst2, 280, 15, 115, 18, "Vertical. order", -1))->x_map ();
(new X_textln (this, &Tst2, 410, 15, 115, 18, "Frequency bands", -1))->x_map ();
_rcoeff.init (&Bst1, &Tst1, _rcoeff_text, 3, 20, 37, 115, 18, 0);
_rh_ord.init (&Bst1, &Tst1, _rh_ord_text, 3, 150, 37, 115, 18, 0);
_rv_ord.init (&Bst1, &Tst1, _rv_ord_text, 3, 280, 37, 115, 18, 0);
_rnband.init (&Bst1, &Tst1, _rbands_text, 2, 410, 37, 115, 18, 0);
_rcoeff.set_stat (2);
_rh_ord.set_stat (0);
_rv_ord.set_stat (0);
_rnband.set_stat (0);
(new X_textln (this, &Tst1, 20, 110, 80, 17, "Speakers", 0))->x_map ();
_tnspkr = new X_textip (this, this, &Tst0, 105, 110, 40, 17, 3);
_tnspkr->set_text ("4");
_tnspkr->x_map ();
Bst0.size.x = 70;
Bst0.size.y = 18;
_bcancel = new X_tbutton (this, this, &Bst0, 330, 125, "Cancel", 0, B_CANCEL);
_bcancel->x_map ();
_bcreate = new X_tbutton (this, this, &Bst0, 400, 125, "Create", 0, B_CREATE);
_bcreate->x_map ();
}
Typewin::~Typewin (void)
{
}
void Typewin::handle_event (XEvent *E)
{
switch (E->type)
{
case ClientMessage:
clmesg ((XClientMessageEvent *) E);
break;
}
}
void Typewin::clmesg (XClientMessageEvent *E)
{
if (E->message_type == _atom) x_unmap ();
}
void Typewin::handle_callb (int type, X_window *W, XEvent */*E*/)
{
X_button *B;
switch (type)
{
case X_callback::TEXTIP | X_textip::BUT:
_tnspkr->enable ();
break;
case X_callback::BUTTON | X_button::RELSE:
B = (X_button *) W;
switch (B->cbid ())
{
case B_CANCEL:
x_unmap ();
break;
case B_CREATE:
checkpar ();
break;
}
break;
}
}
void Typewin::checkpar (void)
{
if (_rv_ord.stat () > _rh_ord.stat () + 1)
{
_rv_ord.set_stat (_rh_ord.stat () + 1);
return;
}
if ((_rh_ord.stat () == 2) && (_rv_ord.stat () > 1))
{
_rv_ord.set_stat (1);
return;
}
if ((sscanf (_tnspkr->text (), "%d", &_nspkr) != 1) || (_nspkr < 4) || (_nspkr > 24))
{
_tnspkr->set_text ("???");
_tnspkr->enable ();
return;
}
if (_callb) _callb->handle_callb (CB_CONF_NEW, this, 0);
x_unmap ();
}
const char *Typewin::_rcoeff_text [3] =
{
"N3D",
"SN3D",
"Furse-Malham"
};
const char *Typewin::_rh_ord_text [3] =
{
"First order",
"Second order",
"Third order"
};
const char *Typewin::_rv_ord_text [3] =
{
"Horizontal only",
"First order",
"Second order"
};
const char *Typewin::_rbands_text [2] =
{
"Single band",
"Dual band"
};
|