add missing GPL information in guicast program files
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / statusbar.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
23 #include "bcsignals.h"
24 #include "language.h"
25 #include "mainprogress.h"
26 #include "mwindow.h"
27 #include "statusbar.h"
28 #include "theme.h"
29 #include "vframe.h"
30
31
32
33 StatusBar::StatusBar(MWindow *mwindow, MWindowGUI *gui)
34  : BC_SubWindow(mwindow->theme->mstatus_x,
35         mwindow->theme->mstatus_y,
36         mwindow->theme->mstatus_w,
37         mwindow->theme->mstatus_h)
38 {
39         this->mwindow = mwindow;
40         this->gui = gui;
41 }
42
43 StatusBar::~StatusBar()
44 {
45 }
46
47
48
49 void StatusBar::create_objects()
50 {
51 //printf("StatusBar::create_objects 1\n");
52         int x = xS(10); //int y = 5;
53 //printf("StatusBar::create_objects 1\n");
54         draw_top_background(get_parent(), 0, 0, get_w(), get_h());
55         add_subwindow(status_text = new BC_Title(mwindow->theme->mstatus_message_x,
56                 mwindow->theme->mstatus_message_y,
57                 "",
58                 MEDIUMFONT,
59                 mwindow->theme->message_normal));
60         x = get_w() - xS(290);
61 // printf("StatusBar::create_objects %d: 0x%08x\n",
62 // __LINE__, mwindow->theme->message_normal);
63         add_subwindow(main_progress =
64                 new BC_ProgressBar(mwindow->theme->mstatus_progress_x,
65                         mwindow->theme->mstatus_progress_y,
66                         mwindow->theme->mstatus_progress_w,
67                         mwindow->theme->mstatus_progress_w));
68         x += main_progress->get_w() + xS(5);
69 //printf("StatusBar::create_objects 1\n");
70         add_subwindow(main_progress_cancel =
71                 new StatusBarCancel(mwindow,
72                         mwindow->theme->mstatus_cancel_x,
73                         mwindow->theme->mstatus_cancel_y));
74 //printf("StatusBar::create_objects 1\n");
75         reset_default_message();
76         flash();
77 }
78
79 void StatusBar::resize_event()
80 {
81         int x = xS(10); //int y = 1;
82         reposition_window(mwindow->theme->mstatus_x,
83                 mwindow->theme->mstatus_y,
84                 mwindow->theme->mstatus_w,
85                 mwindow->theme->mstatus_h);
86
87         draw_top_background(get_parent(), 0, 0, get_w(), get_h());
88
89
90         status_text->reposition_window(mwindow->theme->mstatus_message_x,
91                 mwindow->theme->mstatus_message_y);
92
93         x = get_w() - xS(290);
94         main_progress->reposition_window(mwindow->theme->mstatus_progress_x,
95                 mwindow->theme->mstatus_progress_y);
96
97         x += main_progress->get_w() + xS(5);
98         main_progress_cancel->reposition_window(mwindow->theme->mstatus_cancel_x,
99                 mwindow->theme->mstatus_cancel_y);
100
101         flash(0);
102 }
103
104 void StatusBar::show_message(const char *text, int msg_color, int box_color)
105 {
106         int mx = mwindow->theme->mstatus_message_x;
107         int my = mwindow->theme->mstatus_message_y;
108         int tx = status_text->get_x(), th = status_text->get_h();
109         if( box_color >= 0 ) {
110                 set_color(box_color);
111                 int bb = th/4, bh = th - bb*2;
112                 draw_box(mx+bb,my+bb, bh,bh);
113                 flash(mx,my, th,th);  mx += xS(5);
114                 if( (mx+=th) != tx )
115                         status_text->reposition_window(mx, my);
116         }
117         else if( tx != mx ) {
118                 draw_top_background(get_parent(), mx,my, th,th);
119                 flash(mx,my, th,th);
120                 status_text->reposition_window(mx, my);
121         }
122         if( msg_color < 0 )
123                 msg_color = mwindow->theme->message_normal;
124         status_text->set_color(msg_color);
125         status_text->update(text);
126 }
127
128 void StatusBar::reset_default_message()
129 {
130         status_color = -1;
131         strcpy(default_msg, _("Welcome to CinGG - use ALT+h for context HELP."));
132 }
133 void StatusBar::update_default_message()
134 {
135         status_color = status_text->get_color();
136         strcpy(default_msg, status_text->get_text());
137 }
138 void StatusBar::default_message()
139 {
140         show_message(default_msg, status_color);
141 }
142
143 StatusBarCancel::StatusBarCancel(MWindow *mwindow, int x, int y)
144  : BC_Button(x, y, mwindow->theme->statusbar_cancel_data)
145 {
146         this->mwindow = mwindow;
147         set_tooltip(_("Cancel operation"));
148 }
149 int StatusBarCancel::handle_event()
150 {
151         mwindow->mainprogress->cancelled = 1;
152         return 1;
153 }