4 #include "filesystem.h"
5 #include "fileformat.h"
7 #include "mwindowgui.h"
11 #define _(String) gettext(String)
12 #define gettext_noop(String) String
13 #define N_(String) gettext_noop (String)
16 FileFormat::FileFormat(MWindow *mwindow)
17 : BC_Window(PROGRAM_NAME ": File Format",
18 mwindow->gui->get_abs_cursor_x(),
19 mwindow->gui->get_abs_cursor_y(),
25 this->mwindow = mwindow;
28 FileFormat::~FileFormat()
35 delete channels_button;
39 int FileFormat::create_objects(Asset *asset, char *string2)
41 // ================================= copy values
43 create_objects_(string2);
46 int FileFormat::create_objects_(char *string2)
51 int x1 = 10, x2 = 180;
53 add_subwindow(new BC_Title(x, y, string2));
55 add_subwindow(new BC_Title(x, y, _("Assuming raw PCM:")));
58 add_subwindow(new BC_Title(x, y, _("Channels:")));
59 sprintf(string, "%d", asset->channels);
60 channels_button = new FileFormatChannels(x2, y, this, string);
61 channels_button->create_objects();
64 add_subwindow(new BC_Title(x, y, _("Sample rate:")));
65 sprintf(string, "%d", asset->sample_rate);
66 add_subwindow(rate_button = new FileFormatRate(x2, y, this, string));
67 add_subwindow(new SampleRatePulldown(mwindow, rate_button, x2 + 100, y));
70 add_subwindow(new BC_Title(x, y, _("Bits:")));
71 bitspopup = new BitsPopup(this,
80 bitspopup->create_objects();
83 add_subwindow(new BC_Title(x, y, _("Header length:")));
84 sprintf(string, "%d", asset->header);
85 add_subwindow(header_button = new FileFormatHeader(x2, y, this, string));
88 add_subwindow(new BC_Title(x, y, _("Byte order:")));
89 add_subwindow(lohi = new FileFormatByteOrderLOHI(x2, y, this, asset->byte_order));
90 add_subwindow(hilo = new FileFormatByteOrderHILO(x2 + 70, y, this, asset->byte_order ^ 1));
93 add_subwindow(signed_button = new FileFormatSigned(x, y, this, asset->signed_));
95 add_subwindow(new BC_OKButton(this));
96 add_subwindow(new BC_CancelButton(this));
100 FileFormatChannels::FileFormatChannels(int x, int y, FileFormat *fwindow, char *text)
101 : BC_TumbleTextBox(fwindow,
109 this->fwindow = fwindow;
112 int FileFormatChannels::handle_event()
114 fwindow->asset->channels = atol(get_text());
118 FileFormatRate::FileFormatRate(int x, int y, FileFormat *fwindow, char *text)
119 : BC_TextBox(x, y, 100, 1, text)
121 this->fwindow = fwindow;
124 int FileFormatRate::handle_event()
126 fwindow->asset->sample_rate = atol(get_text());
130 FileFormatHeader::FileFormatHeader(int x, int y, FileFormat *fwindow, char *text)
131 : BC_TextBox(x, y, 100, 1, text)
133 this->fwindow = fwindow;
136 int FileFormatHeader::handle_event()
138 fwindow->asset->header = atol(get_text());
142 FileFormatByteOrderLOHI::FileFormatByteOrderLOHI(int x, int y, FileFormat *fwindow, int value)
143 : BC_Radial(x, y, value, _("Lo Hi"))
145 this->fwindow = fwindow;
148 int FileFormatByteOrderLOHI::handle_event()
150 fwindow->asset->byte_order = get_value();
151 fwindow->hilo->update(get_value() ^ 1);
154 FileFormatByteOrderHILO::FileFormatByteOrderHILO(int x, int y, FileFormat *fwindow, int value)
155 : BC_Radial(x, y, value, _("Hi Lo"))
157 this->fwindow = fwindow;
160 int FileFormatByteOrderHILO::handle_event()
162 fwindow->asset->byte_order = get_value() ^ 1;
163 fwindow->lohi->update(get_value() ^ 1);
166 FileFormatSigned::FileFormatSigned(int x, int y, FileFormat *fwindow, int value)
167 : BC_CheckBox(x, y, value, _("Values are signed"))
169 this->fwindow = fwindow;
172 int FileFormatSigned::handle_event()
174 fwindow->asset->signed_ = get_value();