fix awdw solo vicon crash, fix nested clip for binfolders, open edit edl
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / wwindow.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 "bcdisplayinfo.h"
23 #include "bcbutton.h"
24 #include "language.h"
25 #include "mwindow.h"
26 #include "preferences.h"
27 #include "wwindow.h"
28
29
30 WWindow::WWindow(MWindow *mwindow)
31  : BC_DialogThread()
32 {
33         this->mwindow = mwindow;
34         this->result = 0;
35         this->gui = 0;
36 }
37
38 WWindow::~WWindow()
39 {
40         close_window();
41 }
42
43 void WWindow::show_warning(int *do_warning, const char *warn_text)
44 {
45         if( running() ) return;
46         this->do_warning = do_warning;
47         this->warn_text = warn_text;
48         this->result = 0;
49         start();
50 }
51
52 void WWindow::handle_close_event(int result)
53 {
54         this->result = result;
55         gui = 0;
56 }
57
58 BC_Window* WWindow::new_gui()
59 {
60         BC_DisplayInfo display_info;
61         int x = display_info.get_abs_cursor_x();
62         int y = display_info.get_abs_cursor_y();
63         gui = new WWindowGUI(this, x, y);
64         gui->create_objects();
65         return gui;
66 }
67
68 int WWindow::wait_result()
69 {
70         if( !running() ) return -1;
71         join();
72         return result;
73 }
74
75 WWindowGUI::WWindowGUI(WWindow *thread, int x, int y)
76  : BC_Window(_(PROGRAM_NAME ": Warning"), x, y,
77                 xS(640), yS(100), xS(640), yS(100), 0, 0, 1)
78 {
79         this->thread = thread;
80 }
81
82 void WWindowGUI::create_objects()
83 {
84         lock_window("WWindowGUI::create_objects");
85         int x = xS(10), y = yS(10);
86         add_subwindow(new BC_TextBox(x, y, get_w()-xS(50), 3, thread->warn_text));
87         y = get_h() - yS(30);
88         if( thread->do_warning )
89                 add_subwindow(new WDisable(this, x, y));
90         y = get_h() - BC_CancelButton::calculate_h() - yS(10);
91         x = get_w() - BC_CancelButton::calculate_w() - xS(10);
92         add_subwindow(new BC_CancelButton(x, y));
93         show_window();
94         raise_window();
95         unlock_window();
96 }
97
98 WDisable::WDisable(WWindowGUI *gui, int x, int y)
99  : BC_CheckBox(x, y, !*gui->thread->do_warning, _("Don't show this warning again."))
100 {
101         this->gui = gui;
102 }
103
104 int WDisable::handle_event()
105 {
106         *gui->thread->do_warning = !get_value();
107         return 1;
108 }
109
110