r827: Fix a crash when no audio output device can be opened.
[cinelerra_cv.git] / cinelerra / bitspopup.C
blob5f39e83253d45277e38b3fb55729d5df562c3005
1 #include "bitspopup.h"
2 #include "file.h"
5 BitsPopup::BitsPopup(BC_WindowBase *parent_window, 
6         int x, 
7         int y, 
8         int *output, 
9         int use_ima4, 
10         int use_ulaw,
11         int use_adpcm, 
12         int use_float,
13         int use_32linear)
15         this->parent_window = parent_window;
16         this->output = output;
17         this->x = x;
18         this->y = y;
19         this->use_ima4 = use_ima4;
20         this->use_ulaw = use_ulaw;
21         this->use_adpcm = use_adpcm;
22         this->use_float = use_float;
23         this->use_32linear = use_32linear;
26 BitsPopup::~BitsPopup()
28         delete menu;
29         delete textbox;
30         for(int i = 0; i < bits_items.total; i++)
31                 delete bits_items.values[i];
34 int BitsPopup::create_objects()
36         bits_items.append(new BC_ListBoxItem(File::bitstostr(BITSLINEAR8)));
37         bits_items.append(new BC_ListBoxItem(File::bitstostr(BITSLINEAR16)));
38         bits_items.append(new BC_ListBoxItem(File::bitstostr(BITSLINEAR24)));
39         if(use_32linear) bits_items.append(new BC_ListBoxItem(File::bitstostr(BITSLINEAR32)));
40         if(use_ima4) bits_items.append(new BC_ListBoxItem(File::bitstostr(BITSIMA4)));
41         if(use_ulaw) bits_items.append(new BC_ListBoxItem(File::bitstostr(BITSULAW)));
42         if(use_adpcm) bits_items.append(new BC_ListBoxItem(File::bitstostr(BITS_ADPCM)));
43         if(use_float) bits_items.append(new BC_ListBoxItem(File::bitstostr(BITSFLOAT)));
45         parent_window->add_subwindow(textbox = new BitsPopupText(this, x, y));
46         x += textbox->get_w();
47         parent_window->add_subwindow(menu = new BitsPopupMenu(this, x, y));
48         return 0;
51 int BitsPopup::get_w()
53         return menu->get_w() + textbox->get_w();
56 BitsPopupMenu::BitsPopupMenu(BitsPopup *popup, int x, int y)
57  : BC_ListBox(x,
58         y,
59         120,
60         100,
61         LISTBOX_TEXT,
62         &popup->bits_items,
63         0,
64         0,
65         1,
66         0,
67         1)
69         this->popup = popup;
72 int BitsPopupMenu::handle_event()
74         popup->textbox->update(get_selection(0, 0)->get_text());
75         popup->textbox->handle_event();
76         return 1;
79 BitsPopupText::BitsPopupText(BitsPopup *popup, int x, int y)
80  : BC_TextBox(x, y, 120, 1, File::bitstostr(*popup->output))
82         this->popup = popup;
85 int BitsPopupText::handle_event()
87         *popup->output = File::strtobits(get_text());
88         return 1;