4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
22 #include "bcdisplayinfo.h"
26 #include "preferences.h"
30 WWindow::WWindow(MWindow *mwindow)
33 this->mwindow = mwindow;
42 void WWindow::show_warning(int *do_warning, const char *warn_text)
44 if( running() ) return;
45 this->do_warning = do_warning;
46 this->warn_text = warn_text;
51 void WWindow::handle_close_event(int result)
53 this->result = result;
57 BC_Window* WWindow::new_gui()
59 BC_DisplayInfo display_info;
60 int x = display_info.get_abs_cursor_x();
61 int y = display_info.get_abs_cursor_y();
62 WWindowGUI *gui = new WWindowGUI(this, x, y);
63 gui->create_objects();
67 int WWindow::wait_result()
69 if( !running() ) return -1;
74 WWindowGUI::WWindowGUI(WWindow *thread, int x, int y)
75 : BC_Window(_(PROGRAM_NAME ": Warning"), x, y, 640, 100, 640, 100, 0, 0, 1)
77 this->thread = thread;
80 void WWindowGUI::create_objects()
83 add_subwindow(new BC_TextBox(x, y, get_w()-50, 3, thread->warn_text));
85 add_subwindow(new WDisable(this, x, y));
86 y = get_h() - BC_CancelButton::calculate_h() - 10;
87 x = get_w() - BC_CancelButton::calculate_w() - 10;
88 add_subwindow(new BC_CancelButton(x, y));
92 WDisable::WDisable(WWindowGUI *gui, int x, int y)
93 : BC_CheckBox(x, y, !*gui->thread->do_warning, _("Don't show this warning again."))
98 int WDisable::handle_event()
100 *gui->thread->do_warning = !get_value();