3 * Copyright (C) 2006 Pierre Dumuid
4 * Copyright (C) 1997-2012 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
23 #include "awindowgui.h"
25 #include "labeledit.h"
28 #include "mwindowgui.h"
30 #include "vwindowgui.h"
33 LabelEdit::LabelEdit(MWindow *mwindow, AWindow *awindow, VWindow *vwindow)
36 this->mwindow = mwindow;
37 this->awindow = awindow;
38 this->vwindow = vwindow;
40 label_edit_window = 0;
43 LabelEdit::~LabelEdit()
48 void LabelEdit::start(Label *label, int x, int y)
51 this->x = x; this->y = y;
53 BC_DialogThread::start();
56 void LabelEdit::handle_close_event(int result)
58 label_edit_window = 0;
62 void LabelEdit::handle_done_event(int result)
65 strcpy(label->textstr, label_edit_window->textbox->get_text());
66 awindow->gui->async_update_assets();
70 BC_Window *LabelEdit::new_gui()
72 label_edit_window = new LabelEditWindow(mwindow, this);
73 label_edit_window->create_objects();
74 return label_edit_window;
77 LabelEditWindow::LabelEditWindow(MWindow *mwindow, LabelEdit *thread)
78 : BC_Window(_(PROGRAM_NAME ": Label Info"),
79 thread->x - 400/2, thread->y - 350/2,
80 400, 350, 400, 430, 0, 0, 1)
82 this->mwindow = mwindow;
83 this->thread = thread;
86 LabelEditWindow::~LabelEditWindow()
90 void LabelEditWindow::create_objects()
92 lock_window("LabelEditWindow::create_objects");
93 this->label = thread->label;
99 add_subwindow(title = new BC_Title(x1, y, _("Label Text:")));
100 y += title->get_h() + 5;
101 add_subwindow(textbox = new LabelEditComments(this, x1, y, get_w() - x1 * 2,
102 BC_TextBox::pixels_to_rows(this, MEDIUMFONT, get_h() - 10 - 40 - y)));
104 add_subwindow(new BC_OKButton(this));
105 add_subwindow(new BC_CancelButton(this));
111 LabelEditComments::LabelEditComments(LabelEditWindow *window, int x, int y, int w, int rows)
112 : BC_TextBox(x, y, w, rows, window->label->textstr, 1, MEDIUMFONT, 1)
114 this->window = window;
117 int LabelEditComments::handle_event()