4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "bitspopup.h"
25 #include "fileformat.h"
28 #include "mwindowgui.h"
33 FileFormat::FileFormat(MWindow *mwindow)
34 : BC_Window(_(PROGRAM_NAME ": File Format"),
35 mwindow->gui->get_abs_cursor_x(0),
36 mwindow->gui->get_abs_cursor_y(0),
37 xS(375), yS(300), xS(375), yS(300))
39 this->mwindow = mwindow;
40 // *** CONTEXT_HELP ***
41 context_help_set_keyword("Single File Rendering");
44 FileFormat::~FileFormat()
46 lock_window("FileFormat::~FileFormat");
52 delete channels_button;
57 void FileFormat::create_objects(Asset *asset, char *string2)
59 // ================================= copy values
61 create_objects_(string2);
64 void FileFormat::create_objects_(char *string2)
67 int ys20 = yS(20), ys30 = yS(30);
69 int x1 = xs10, x2 = xS(180);
72 lock_window("FileFormat::create_objects_");
73 add_subwindow(new BC_Title(x, y, string2));
75 add_subwindow(new BC_Title(x, y, _("Assuming raw PCM:")));
78 add_subwindow(new BC_Title(x, y, _("Channels:")));
79 sprintf(string, "%d", asset->channels);
80 channels_button = new FileFormatChannels(x2, y, this, string);
81 channels_button->create_objects();
84 add_subwindow(new BC_Title(x, y, _("Sample rate:")));
85 sprintf(string, "%d", asset->sample_rate);
86 add_subwindow(rate_button = new FileFormatRate(x2, y, this, string));
87 add_subwindow(new SampleRatePulldown(mwindow, rate_button, x2 + yS(100), y));
90 add_subwindow(new BC_Title(x, y, _("Bits:")));
91 bitspopup = new BitsPopup(this, x2, y,
92 &asset->bits, 0, 1, 1, 0, 1);
93 bitspopup->create_objects();
96 add_subwindow(new BC_Title(x, y, _("Header length:")));
97 sprintf(string, "%d", asset->header);
98 add_subwindow(header_button = new FileFormatHeader(x2, y, this, string));
102 //printf("FileFormat::create_objects_ 1 %d\n", asset->byte_order);
103 add_subwindow(new BC_Title(x, y, _("Byte order:")));
104 add_subwindow(lohi = new FileFormatByteOrderLOHI(x2, y, this, asset->byte_order));
105 add_subwindow(hilo = new FileFormatByteOrderHILO(x2 + 70, y, this, !asset->byte_order));
108 add_subwindow(signed_button = new FileFormatSigned(x, y, this, asset->signed_));
110 add_subwindow(new BC_OKButton(this));
111 add_subwindow(new BC_CancelButton(this));
117 FileFormatChannels::FileFormatChannels(int x, int y, FileFormat *fwindow, char *text)
118 : BC_TumbleTextBox(fwindow, (int)atol(text), (int)1, (int)MAXCHANNELS, x, y, 50)
120 this->fwindow = fwindow;
123 int FileFormatChannels::handle_event()
125 fwindow->asset->channels = atol(get_text());
129 FileFormatRate::FileFormatRate(int x, int y, FileFormat *fwindow, char *text)
130 : BC_TextBox(x, y, 100, 1, text)
132 this->fwindow = fwindow;
135 int FileFormatRate::handle_event()
137 fwindow->asset->sample_rate = atol(get_text());
141 FileFormatHeader::FileFormatHeader(int x, int y, FileFormat *fwindow, char *text)
142 : BC_TextBox(x, y, 100, 1, text)
144 this->fwindow = fwindow;
147 int FileFormatHeader::handle_event()
149 fwindow->asset->header = atol(get_text());
153 FileFormatByteOrderLOHI::FileFormatByteOrderLOHI(int x, int y, FileFormat *fwindow, int value)
154 : BC_Radial(x, y, value, _("Lo Hi"))
156 this->fwindow = fwindow;
159 int FileFormatByteOrderLOHI::handle_event()
162 fwindow->asset->byte_order = 1;
163 fwindow->hilo->update(0);
167 FileFormatByteOrderHILO::FileFormatByteOrderHILO(int x, int y, FileFormat *fwindow, int value)
168 : BC_Radial(x, y, value, _("Hi Lo"))
170 this->fwindow = fwindow;
173 int FileFormatByteOrderHILO::handle_event()
176 fwindow->asset->byte_order = 0;
177 fwindow->lohi->update(0);
181 FileFormatSigned::FileFormatSigned(int x, int y, FileFormat *fwindow, int value)
182 : BC_CheckBox(x, y, value, _("Values are signed"))
184 this->fwindow = fwindow;
187 int FileFormatSigned::handle_event()
189 fwindow->asset->signed_ = get_value();