add 1:1 convert, add es.po: thx sergio, cwdw zoom tweak, add done beep pots, bd forma...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / labeledit.C
1 /*
2  * CINELERRA
3  * Copyright (C) 2006 Pierre Dumuid
4  * Copyright (C) 1997-2012 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 "awindow.h"
23 #include "awindowgui.h"
24 #include "bcdialog.h"
25 #include "labeledit.h"
26 #include "language.h"
27 #include "mwindow.h"
28 #include "mwindowgui.h"
29 #include "vwindow.h"
30 #include "vwindowgui.h"
31
32
33 LabelEdit::LabelEdit(MWindow *mwindow, AWindow *awindow, VWindow *vwindow)
34  : BC_DialogThread()
35 {
36         this->mwindow = mwindow;
37         this->awindow = awindow;
38         this->vwindow = vwindow;
39         label = 0;
40         label_edit_window = 0;
41 }
42
43 LabelEdit::~LabelEdit()
44 {
45         close_window();
46 }
47
48 void LabelEdit::start(Label *label, int x, int y)
49 {
50         this->label = label;
51         this->x = x;  this->y = y;
52
53         BC_DialogThread::start();
54 }
55
56 void LabelEdit::handle_close_event(int result)
57 {
58         label_edit_window = 0;
59 }
60
61
62 void LabelEdit::handle_done_event(int result)
63 {
64         if( !result ) {
65                 strcpy(label->textstr, label_edit_window->textbox->get_text());
66                 awindow->gui->async_update_assets();
67         }
68 }
69
70 BC_Window *LabelEdit::new_gui()
71 {
72         label_edit_window = new LabelEditWindow(mwindow, this);
73         label_edit_window->create_objects();
74         return label_edit_window;
75 }
76
77 #define LEW_W xS(400)
78 #define LEW_H yS(350)
79
80 LabelEditWindow::LabelEditWindow(MWindow *mwindow, LabelEdit *thread)
81  : BC_Window(_(PROGRAM_NAME ": Label Info"),
82         thread->x - LEW_W/2, thread->y - LEW_H/2,
83         LEW_W, LEW_H, xS(400), yS(430), 0, 0, 1)
84 {
85         this->mwindow = mwindow;
86         this->thread = thread;
87 }
88
89 LabelEditWindow::~LabelEditWindow()
90 {
91 }
92
93 void LabelEditWindow::create_objects()
94 {
95         lock_window("LabelEditWindow::create_objects");
96         this->label = thread->label;
97
98         int x = xS(10), y = yS(10);
99         int x1 = x;
100         BC_Title *title;
101
102         add_subwindow(title = new BC_Title(x1, y, _("Label Text:")));
103         y += title->get_h() + 5;
104         add_subwindow(textbox = new LabelEditComments(this, x1, y, get_w() - x1 * 2,
105                 BC_TextBox::pixels_to_rows(this, MEDIUMFONT, get_h() - y - yS(10 + 40))));
106
107         add_subwindow(new BC_OKButton(this));
108         add_subwindow(new BC_CancelButton(this));
109         show_window();
110         textbox->activate();
111         unlock_window();
112 }
113
114 LabelEditComments::LabelEditComments(LabelEditWindow *window, int x, int y, int w, int rows)
115  : BC_TextBox(x, y, w, rows, window->label->textstr,  1, MEDIUMFONT, 1)
116 {
117         this->window = window;
118 }
119
120 int LabelEditComments::handle_event()
121 {
122         return 1;
123 }
124