00001 #include "bitspopup.h"
00002 #include "file.h"
00003
00004
00005 BitsPopup::BitsPopup(BC_WindowBase *parent_window,
00006 int x,
00007 int y,
00008 int *output,
00009 int use_ima4,
00010 int use_ulaw,
00011 int use_adpcm,
00012 int use_float,
00013 int use_32linear)
00014 {
00015 this->parent_window = parent_window;
00016 this->output = output;
00017 this->x = x;
00018 this->y = y;
00019 this->use_ima4 = use_ima4;
00020 this->use_ulaw = use_ulaw;
00021 this->use_adpcm = use_adpcm;
00022 this->use_float = use_float;
00023 this->use_32linear = use_32linear;
00024 }
00025
00026 BitsPopup::~BitsPopup()
00027 {
00028 delete menu;
00029 delete textbox;
00030 for(int i = 0; i < bits_items.total; i++)
00031 delete bits_items.values[i];
00032 }
00033
00034 int BitsPopup::create_objects()
00035 {
00036 bits_items.append(new BC_ListBoxItem(File::bitstostr(BITSLINEAR8)));
00037 bits_items.append(new BC_ListBoxItem(File::bitstostr(BITSLINEAR16)));
00038 bits_items.append(new BC_ListBoxItem(File::bitstostr(BITSLINEAR24)));
00039 if(use_32linear) bits_items.append(new BC_ListBoxItem(File::bitstostr(BITSLINEAR32)));
00040 if(use_ima4) bits_items.append(new BC_ListBoxItem(File::bitstostr(BITSIMA4)));
00041 if(use_ulaw) bits_items.append(new BC_ListBoxItem(File::bitstostr(BITSULAW)));
00042 if(use_adpcm) bits_items.append(new BC_ListBoxItem(File::bitstostr(BITS_ADPCM)));
00043 if(use_float) bits_items.append(new BC_ListBoxItem(File::bitstostr(BITSFLOAT)));
00044
00045 parent_window->add_subwindow(textbox = new BitsPopupText(this, x, y));
00046 x += textbox->get_w();
00047 parent_window->add_subwindow(menu = new BitsPopupMenu(this, x, y));
00048 return 0;
00049 }
00050
00051 int BitsPopup::get_w()
00052 {
00053 return menu->get_w() + textbox->get_w();
00054 }
00055
00056 BitsPopupMenu::BitsPopupMenu(BitsPopup *popup, int x, int y)
00057 : BC_ListBox(x,
00058 y,
00059 120,
00060 100,
00061 LISTBOX_TEXT,
00062 &popup->bits_items,
00063 0,
00064 0,
00065 1,
00066 0,
00067 1)
00068 {
00069 this->popup = popup;
00070 }
00071
00072 int BitsPopupMenu::handle_event()
00073 {
00074 popup->textbox->update(get_selection(0, 0)->get_text());
00075 popup->textbox->handle_event();
00076 return 1;
00077 }
00078
00079 BitsPopupText::BitsPopupText(BitsPopup *popup, int x, int y)
00080 : BC_TextBox(x, y, 120, 1, File::bitstostr(*popup->output))
00081 {
00082 this->popup = popup;
00083 }
00084
00085 int BitsPopupText::handle_event()
00086 {
00087 *popup->output = File::strtobits(get_text());
00088 return 1;
00089 }