Merge branch 'master' of git://git.pipapo.org/cinelerra/svn into ct
[cinelerra_cv/ct.git] / cinelerra / bitspopup.C
blob5e7fd8d3e88de8d4768c476cad22d95c29a84eb5
1 #include "bitspopup.h"
2 #include "clip.h"
3 #include "file.h"
6 BitsPopup::BitsPopup(BC_WindowBase *parent_window, 
7         int x, 
8         int y, 
9         int *output, 
10         int use_ima4, 
11         int use_ulaw,
12         int use_adpcm, 
13         int use_float,
14         int use_32linear)
15   : BC_RelocatableWidget()
17         this->parent_window = parent_window;
18         this->output = output;
19         this->x = x;
20         this->y = y;
21         this->use_ima4 = use_ima4;
22         this->use_ulaw = use_ulaw;
23         this->use_adpcm = use_adpcm;
24         this->use_float = use_float;
25         this->use_32linear = use_32linear;
28 BitsPopup::~BitsPopup()
30         delete menu;
31         delete textbox;
32         for(int i = 0; i < bits_items.total; i++)
33                 delete bits_items.values[i];
36 int BitsPopup::create_objects()
38         bits_items.append(new BC_ListBoxItem(File::bitstostr(BITSLINEAR8)));
39         bits_items.append(new BC_ListBoxItem(File::bitstostr(BITSLINEAR16)));
40         bits_items.append(new BC_ListBoxItem(File::bitstostr(BITSLINEAR24)));
41         if(use_32linear) bits_items.append(new BC_ListBoxItem(File::bitstostr(BITSLINEAR32)));
42         if(use_ima4) bits_items.append(new BC_ListBoxItem(File::bitstostr(BITSIMA4)));
43         if(use_ulaw) bits_items.append(new BC_ListBoxItem(File::bitstostr(BITSULAW)));
44         if(use_adpcm) bits_items.append(new BC_ListBoxItem(File::bitstostr(BITS_ADPCM)));
45         if(use_float) bits_items.append(new BC_ListBoxItem(File::bitstostr(BITSFLOAT)));
47         parent_window->add_subwindow(textbox = new BitsPopupText(this, x, y));
48         x += textbox->get_w();
49         parent_window->add_subwindow(menu = new BitsPopupMenu(this, x, y));
50         return 0;
53 int BitsPopup::get_w()
55         return menu->get_w() + textbox->get_w();
58 int BitsPopup::get_h()
60         return MAX(menu->get_h(), textbox->get_h());
63 BitsPopupMenu::BitsPopupMenu(BitsPopup *popup, int x, int y)
64  : BC_ListBox(x,
65         y,
66         120,
67         100,
68         LISTBOX_TEXT,
69         &popup->bits_items,
70         0,
71         0,
72         1,
73         0,
74         1)
76         this->popup = popup;
79 int BitsPopupMenu::handle_event()
81         popup->textbox->update(get_selection(0, 0)->get_text());
82         popup->textbox->handle_event();
83         return 1;
86 int BitsPopup::reposition_widget(int x, int y, int w, int h)
88         textbox->reposition_window(x, y);
89         menu->reposition_window(x + textbox->get_w(), y);
90         return 1;
93 BitsPopupText::BitsPopupText(BitsPopup *popup, int x, int y)
94  : BC_TextBox(x, y, 120, 1, File::bitstostr(*popup->output))
96         this->popup = popup;
99 int BitsPopupText::handle_event()
101         *popup->output = File::strtobits(get_text());
102         return 1;
105 //      Local Variables:
106 //      mode: C++
107 //      c-file-style: "linux"
108 //      End: