Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

fileformat.C

Go to the documentation of this file.
00001 #include "asset.h"
00002 #include "assets.h"
00003 #include "bitspopup.h"
00004 #include "fileformat.h"
00005 #include "language.h"
00006 #include "mwindow.h"
00007 #include "mwindowgui.h"
00008 #include "new.h"
00009 
00010 
00011 
00012 FileFormat::FileFormat(MWindow *mwindow)
00013  : BC_Window(PROGRAM_NAME ": File Format", 
00014                 mwindow->gui->get_abs_cursor_x(1),
00015                 mwindow->gui->get_abs_cursor_y(1),
00016                 375, 
00017                 300, 
00018                 375, 
00019                 300)
00020 {
00021         this->mwindow = mwindow;
00022 }
00023 
00024 FileFormat::~FileFormat()
00025 {
00026         delete lohi;
00027         delete hilo;
00028         delete signed_button;
00029         delete header_button;
00030         delete rate_button;
00031         delete channels_button;
00032         delete bitspopup;
00033 }
00034 
00035 int FileFormat::create_objects(Asset *asset, char *string2)
00036 {
00037 // ================================= copy values
00038         this->asset = asset;
00039         create_objects_(string2);
00040 }
00041 
00042 int FileFormat::create_objects_(char *string2)
00043 {
00044         char string[1024];
00045         int x1 = 10, x2 = 180;
00046         int x = x1, y = 10;
00047         add_subwindow(new BC_Title(x, y, string2));
00048         y += 20;
00049         add_subwindow(new BC_Title(x, y, _("Assuming raw PCM:")));
00050 
00051         y += 30;
00052         add_subwindow(new BC_Title(x, y, _("Channels:")));
00053         sprintf(string, "%d", asset->channels);
00054         channels_button = new FileFormatChannels(x2, y, this, string);
00055         channels_button->create_objects();
00056 
00057         y += 30;
00058         add_subwindow(new BC_Title(x, y, _("Sample rate:")));
00059         sprintf(string, "%d", asset->sample_rate);
00060         add_subwindow(rate_button = new FileFormatRate(x2, y, this, string));
00061         add_subwindow(new SampleRatePulldown(mwindow, rate_button, x2 + 100, y));
00062         
00063         y += 30;
00064         add_subwindow(new BC_Title(x, y, _("Bits:")));
00065         bitspopup = new BitsPopup(this, 
00066                 x2, 
00067                 y, 
00068                 &asset->bits, 
00069                 0, 
00070                 1, 
00071                 1, 
00072                 0, 
00073                 1);
00074         bitspopup->create_objects();
00075         
00076         y += 30;
00077         add_subwindow(new BC_Title(x, y, _("Header length:")));
00078         sprintf(string, "%d", asset->header);
00079         add_subwindow(header_button = new FileFormatHeader(x2, y, this, string));
00080         
00081         y += 30;
00082 
00083 //printf("FileFormat::create_objects_ 1 %d\n", asset->byte_order);
00084         add_subwindow(new BC_Title(x, y, _("Byte order:")));
00085         add_subwindow(lohi = new FileFormatByteOrderLOHI(x2, y, this, asset->byte_order));
00086         add_subwindow(hilo = new FileFormatByteOrderHILO(x2 + 70, y, this, !asset->byte_order));
00087         
00088         y += 30;
00089         add_subwindow(signed_button = new FileFormatSigned(x, y, this, asset->signed_));
00090         
00091         add_subwindow(new BC_OKButton(this));
00092         add_subwindow(new BC_CancelButton(this));
00093         return 0;
00094 }
00095 
00096 FileFormatChannels::FileFormatChannels(int x, int y, FileFormat *fwindow, char *text)
00097  : BC_TumbleTextBox(fwindow, 
00098         (int)atol(text), 
00099         (int)1, 
00100         (int)MAXCHANNELS, 
00101         x, 
00102         y, 
00103         50)
00104 {
00105         this->fwindow = fwindow;
00106 }
00107 
00108 int FileFormatChannels::handle_event()
00109 {
00110         fwindow->asset->channels = atol(get_text());
00111         return 0;
00112 }
00113 
00114 FileFormatRate::FileFormatRate(int x, int y, FileFormat *fwindow, char *text)
00115  : BC_TextBox(x, y, 100, 1, text)
00116 {
00117         this->fwindow = fwindow;
00118 }
00119 
00120 int FileFormatRate::handle_event()
00121 {
00122         fwindow->asset->sample_rate = atol(get_text());
00123         return 0;
00124 }
00125 
00126 FileFormatHeader::FileFormatHeader(int x, int y, FileFormat *fwindow, char *text)
00127  : BC_TextBox(x, y, 100, 1, text)
00128 {
00129         this->fwindow = fwindow;
00130 }
00131 
00132 int FileFormatHeader::handle_event()
00133 {
00134         fwindow->asset->header = atol(get_text());
00135         return 0;
00136 }
00137 
00138 FileFormatByteOrderLOHI::FileFormatByteOrderLOHI(int x, int y, FileFormat *fwindow, int value)
00139  : BC_Radial(x, y, value, _("Lo Hi"))
00140 {
00141         this->fwindow = fwindow;
00142 }
00143 
00144 int FileFormatByteOrderLOHI::handle_event()
00145 {
00146         update(1);
00147         fwindow->asset->byte_order = 1;
00148         fwindow->hilo->update(0);
00149         return 1;
00150 }
00151 
00152 FileFormatByteOrderHILO::FileFormatByteOrderHILO(int x, int y, FileFormat *fwindow, int value)
00153  : BC_Radial(x, y, value, _("Hi Lo"))
00154 {
00155         this->fwindow = fwindow;
00156 }
00157 
00158 int FileFormatByteOrderHILO::handle_event()
00159 {
00160         update(1);
00161         fwindow->asset->byte_order = 0;
00162         fwindow->lohi->update(0);
00163         return 1;
00164 }
00165 
00166 FileFormatSigned::FileFormatSigned(int x, int y, FileFormat *fwindow, int value)
00167  : BC_CheckBox(x, y, value, _("Values are signed"))
00168 {
00169         this->fwindow = fwindow;
00170 }
00171 
00172 int FileFormatSigned::handle_event()
00173 {
00174         fwindow->asset->signed_ = get_value();
00175         return 1;
00176 }

Generated on Sun Jan 8 13:38:54 2006 for Cinelerra-svn by  doxygen 1.4.4