fix segv for plugin render_gui when plugin moved up/dn, opencv build fixes, opts...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / bitspopup.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #include "bitspopup.h"
23 #include "clip.h"
24 #include "file.h"
25
26
27 BitsPopup::BitsPopup(BC_WindowBase *parent_window, int x, int y, int *output,
28                 int use_ulaw, int use_adpcm, int use_float, int use_32linear,
29                 int use_8linear)
30 {
31         this->parent_window = parent_window;
32         this->output = output;
33         this->x = x;
34         this->y = y;
35         this->use_ulaw = use_ulaw;
36         this->use_adpcm = use_adpcm;
37         this->use_float = use_float;
38         this->use_32linear = use_32linear;
39         this->use_8linear = use_8linear;
40 }
41
42 BitsPopup::~BitsPopup()
43 {
44         delete menu;
45         delete textbox;
46         for(int i = 0; i < bits_items.total; i++)
47                 delete bits_items.values[i];
48 }
49
50 void BitsPopup::create_objects()
51 {
52         if(use_8linear) bits_items.append(new BC_ListBoxItem(File::bitstostr(BITSLINEAR8)));
53         bits_items.append(new BC_ListBoxItem(File::bitstostr(BITSLINEAR16)));
54         bits_items.append(new BC_ListBoxItem(File::bitstostr(BITSLINEAR24)));
55         if(use_32linear) bits_items.append(new BC_ListBoxItem(File::bitstostr(BITSLINEAR32)));
56         if(use_ulaw) bits_items.append(new BC_ListBoxItem(File::bitstostr(BITSULAW)));
57         if(use_adpcm) bits_items.append(new BC_ListBoxItem(File::bitstostr(BITS_ADPCM)));
58         if(use_float) bits_items.append(new BC_ListBoxItem(File::bitstostr(BITSFLOAT)));
59
60         parent_window->add_subwindow(textbox = new BitsPopupText(this, x, y));
61         x += textbox->get_w();
62         parent_window->add_subwindow(menu = new BitsPopupMenu(this, x, y));
63 }
64
65 int BitsPopup::get_w()
66 {
67         return menu->get_w() + textbox->get_w();
68 }
69
70 int BitsPopup::get_h()
71 {
72         return MAX(menu->get_h(), textbox->get_h());
73 }
74
75 BitsPopupMenu::BitsPopupMenu(BitsPopup *popup, int x, int y)
76  : BC_ListBox(x, y, xS(120), yS(100), LISTBOX_TEXT,
77         &popup->bits_items, 0, 0, 1, 0, 1)
78 {
79         this->popup = popup;
80 }
81
82 int BitsPopupMenu::handle_event()
83 {
84         popup->textbox->update(get_selection(0, 0)->get_text());
85         popup->textbox->handle_event();
86         return 1;
87 }
88
89 BitsPopupText::BitsPopupText(BitsPopup *popup, int x, int y)
90  : BC_TextBox(x, y, xS(120), 1, File::bitstostr(*popup->output))
91 {
92         this->popup = popup;
93 }
94
95 int BitsPopupText::handle_event()
96 {
97         *popup->output = File::strtobits(get_text());
98         return 1;
99 }