| 1 |
// ---------------------------------------------------------------------------- |
| 2 |
// |
| 3 |
// Copyright (C) 2003-2013 Fons Adriaensen <[email protected]> |
| 4 |
// |
| 5 |
// This program is free software; you can redistribute it and/or modify |
| 6 |
// it under the terms of the GNU General Public License as published by |
| 7 |
// the Free Software Foundation; either version 3 of the License, or |
| 8 |
// (at your option) any later version. |
| 9 |
// |
| 10 |
// This program is distributed in the hope that it will be useful, |
| 11 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
// GNU General Public License for more details. |
| 14 |
// |
| 15 |
// You should have received a copy of the GNU General Public License |
| 16 |
// along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
// |
| 18 |
// ---------------------------------------------------------------------------- |
| 19 |
|
| 20 |
|
| 21 |
#include <stdio.h> |
| 22 |
#include "styles.h" |
| 23 |
#include "exptwin.h" |
| 24 |
#include "global.h" |
| 25 |
|
| 26 |
|
| 27 |
const char *Exptwin::_rtype_text [4] = |
| 28 |
{ |
| 29 |
"Single-channel raw (pcm)", |
| 30 |
"Single-channel wav (wav)", |
| 31 |
"Mult-channel wavex (wav)", |
| 32 |
"Ambisonic wavex (amb)" |
| 33 |
}; |
| 34 |
|
| 35 |
|
| 36 |
const char *Exptwin::_rchan_text [2] = |
| 37 |
{ |
| 38 |
"Selected channels", |
| 39 |
"All channels" |
| 40 |
}; |
| 41 |
|
| 42 |
|
| 43 |
const char *Exptwin::_rsect_text [3] = |
| 44 |
{ |
| 45 |
"Current section", |
| 46 |
"All sections in one file", |
| 47 |
"All sections in separate files" |
| 48 |
}; |
| 49 |
|
| 50 |
|
| 51 |
const char *Exptwin::_rform_text [3] = |
| 52 |
{ |
| 53 |
"16 bit", |
| 54 |
"24 bit", |
| 55 |
"Float" |
| 56 |
}; |
| 57 |
|
| 58 |
|
| 59 |
Exptwin::Exptwin (X_window *parent, X_resman *resman, X_callback *callb) : |
| 60 |
X_window (parent, XPOS, YPOS, XDEF, YDEF, XftColors.main_bg->pixel), |
| 61 |
_callb (callb), |
| 62 |
_rtype (this, 0), |
| 63 |
_rchan (this, 0), |
| 64 |
_rsect (this, 0), |
| 65 |
_rform (this, 0) |
| 66 |
{ |
| 67 |
char s [1024]; |
| 68 |
X_hints H; |
| 69 |
|
| 70 |
_xatom = XInternAtom (dpy (), "WM_DELETE_WINDOW", True); |
| 71 |
XSetWMProtocols (dpy (), win (), &_xatom, 1); |
| 72 |
_xatom = XInternAtom (dpy (), "WM_PROTOCOLS", True); |
| 73 |
|
| 74 |
H.rname (resman->rname ()); |
| 75 |
H.rclas (resman->rclas ()); |
| 76 |
H.size (XDEF, YDEF); |
| 77 |
H.minsize (XDEF, YDEF); |
| 78 |
H.maxsize (XDEF, YDEF); |
| 79 |
H.position (XPOS, YPOS); |
| 80 |
x_apply (&H); |
| 81 |
sprintf (s, "%s-%s [%s] Export", PROGNAME, VERSION, resman->rname ()); |
| 82 |
x_set_title (s); |
| 83 |
|
| 84 |
makewin (); |
| 85 |
_rtype.set_stat (EXP_TYPE_WAV); |
| 86 |
_rchan.set_stat (EXP_CHAN_ALL); |
| 87 |
_rsect.set_stat (EXP_SECT_COMB); |
| 88 |
_rform.set_stat (EXP_FORM_FLT); |
| 89 |
} |
| 90 |
|
| 91 |
|
| 92 |
Exptwin::~Exptwin (void) |
| 93 |
{ |
| 94 |
} |
| 95 |
|
| 96 |
|
| 97 |
void Exptwin::show (void) |
| 98 |
{ |
| 99 |
x_mapraised (); |
| 100 |
} |
| 101 |
|
| 102 |
|
| 103 |
void Exptwin::hide (int cbarg) |
| 104 |
{ |
| 105 |
_callb->handle_callb (cbarg, this, 0); |
| 106 |
x_unmap (); |
| 107 |
} |
| 108 |
|
| 109 |
|
| 110 |
void Exptwin::handle_event (XEvent *E) |
| 111 |
{ |
| 112 |
switch (E->type) |
| 113 |
{ |
| 114 |
case ClientMessage: |
| 115 |
xcmesg ((XClientMessageEvent *) E); |
| 116 |
break; |
| 117 |
} |
| 118 |
} |
| 119 |
|
| 120 |
|
| 121 |
void Exptwin::xcmesg (XClientMessageEvent *E) |
| 122 |
{ |
| 123 |
if (E->message_type == _xatom) hide (CB_FILE_CANC); |
| 124 |
} |
| 125 |
|
| 126 |
|
| 127 |
void Exptwin::handle_callb (int k, X_window *W, _XEvent *E ) |
| 128 |
{ |
| 129 |
X_button *B; |
| 130 |
|
| 131 |
switch (k) |
| 132 |
{ |
| 133 |
case X_callback::BUTTON | X_button::RELSE: |
| 134 |
{ |
| 135 |
B = (X_button *) W; |
| 136 |
switch (B->cbid ()) |
| 137 |
{ |
| 138 |
case B_FILE: |
| 139 |
break; |
| 140 |
|
| 141 |
case B_EXPT: |
| 142 |
hide (CB_FILE_EXPT); |
| 143 |
break; |
| 144 |
|
| 145 |
case B_CANC: |
| 146 |
hide (CB_FILE_CANC); |
| 147 |
break; |
| 148 |
} |
| 149 |
break; |
| 150 |
} |
| 151 |
case X_callback::TEXTIP | X_textip::BUT: |
| 152 |
{ |
| 153 |
XSetInputFocus (dpy (), W->win (), RevertToPointerRoot, CurrentTime); |
| 154 |
break; |
| 155 |
} |
| 156 |
default: |
| 157 |
; |
| 158 |
} |
| 159 |
} |
| 160 |
|
| 161 |
|
| 162 |
void Exptwin::makewin (void) |
| 163 |
{ |
| 164 |
_rtype.init (&Bst2, &Tst0, _rtype_text, 4, 25, 20, 200, 20, 0); |
| 165 |
_rchan.init (&Bst2, &Tst0, _rchan_text, 2, 25, 125, 200, 20, 0); |
| 166 |
_rsect.init (&Bst2, &Tst0, _rsect_text, 3, 250, 105, 200, 20, 0); |
| 167 |
_rform.init (&Bst2, &Tst0, _rform_text, 3, 320, 20, 200, 20, 0); |
| 168 |
add_text (15, 190, 95, 17, "Base name", 1); |
| 169 |
_tfile = new X_textip (this, this, &Tst1, 115, 190, 250, 17, 1023); |
| 170 |
_tfile->x_map (); |
| 171 |
// Bst0.size.x = 17; |
| 172 |
// Bst0.size.y = 17; |
| 173 |
// _bfile = new X_ibutton (this, this, &Bst0, 370, 190, disp ()->image1515 (X_display::IMG_DN), B_FILE); |
| 174 |
// _bfile->x_map (); |
| 175 |
Bst0.size.x = 60; |
| 176 |
Bst0.size.y = 18; |
| 177 |
_bexpt = new X_tbutton (this, this, &Bst0, 360, 220, "Export", 0, B_EXPT); |
| 178 |
_bexpt->set_stat (2); |
| 179 |
_bexpt->x_map (); |
| 180 |
_bcanc = new X_tbutton (this, this, &Bst0, 425, 220, "Cancel", 0, B_CANC); |
| 181 |
_bcanc->set_stat (1); |
| 182 |
_bcanc->x_map (); |
| 183 |
} |
| 184 |
|
| 185 |
|
| 186 |
void Exptwin::add_text (int xp, int yp, int xs, int ys, const char *text, int align) |
| 187 |
{ |
| 188 |
(new X_textln (this, &Tst0, xp, yp, xs, ys, text, align))->x_map (); |
| 189 |
} |