fbd6b08d709a65818e2af1ab932b3bf73b052666
[goodguy/history.git] / cinelerra-5.0 / 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 }
35
36 void WWindow::show_warning(int *do_warning, const char *warn_text)
37 {
38         if( running() ) return;
39         this->do_warning = do_warning;
40         this->warn_text = warn_text;
41         start();
42 }
43
44 void WWindow::handle_close_event(int result)
45 {
46         gui = 0;
47 }
48
49 BC_Window* WWindow::new_gui()
50 {
51         BC_DisplayInfo display_info;
52         int x = display_info.get_abs_cursor_x();
53         int y = display_info.get_abs_cursor_y();
54         WWindowGUI *gui = new WWindowGUI(this, x, y);
55         gui->create_objects();
56         return gui;
57 }
58
59 WWindowGUI::WWindowGUI(WWindow *thread, int x, int y)
60  : BC_Window(PROGRAM_NAME ": Warning", x, y, 640, 100, 640, 100, 0, 0, 1)
61 {
62         this->thread = thread;
63 }
64
65 void WWindowGUI::create_objects()
66 {
67         int x = 10, y = 10;
68         add_subwindow(new BC_TextBox(x, y, get_w()-50, 3, thread->warn_text));
69         y = get_h() - 30;
70         add_subwindow(new WDisable(this, x, y));
71         y = get_h() - BC_CancelButton::calculate_h() - 10;
72         x = get_w() - BC_CancelButton::calculate_w() - 10;
73         add_subwindow(new BC_CancelButton(x, y));
74         show_window();
75 }
76
77 WDisable::WDisable(WWindowGUI *gui, int x, int y)
78  : BC_CheckBox(x, y, !*gui->thread->do_warning, _("Don't show this warning again."))
79 {
80         this->gui = gui;
81 }
82
83 int WDisable::handle_event()
84 {
85         *gui->thread->do_warning = !get_value();
86         return 1;
87 }
88
89