improve resize flash operation, fixup xv grab/ungrab, fixup label updates
[goodguy/history.git] / cinelerra-5.1 / cinelerra / swindow.h
1 #ifndef __SWINDOW_H__
2 #define __SWINDOW_H__
3
4 #include <stdio.h>
5 #include <stdint.h>
6
7 #include "arraylist.h"
8 #include "guicast.h"
9 #include "mwindow.inc"
10 #include "swindow.inc"
11
12 class SWindow : public Thread
13 {
14 public:
15         MWindow *mwindow;
16         Mutex *window_lock;
17         Condition *swin_lock;
18         SWindowGUI *gui;
19
20         void start();
21         void stop();
22         void run();
23         void run_swin();
24         void paste_subttl();
25         int update_selection();
26         int done, gui_done;
27
28         SWindow(MWindow *mwindow);
29         ~SWindow();
30 };
31
32
33 class SWindowOK : public BC_OKButton
34 {
35 public:
36         SWindowGUI *gui;
37
38         int button_press_event();
39         int keypress_event();
40
41         SWindowOK(SWindowGUI *gui, int x, int y);
42         ~SWindowOK();
43 };
44
45 class SWindowCancel : public BC_CancelButton
46 {
47 public:
48         SWindowGUI *gui;
49
50         int button_press_event();
51
52         SWindowCancel(SWindowGUI *gui, int x, int y);
53         ~SWindowCancel();
54 };
55
56 class SWindowLoadPath : public BC_TextBox
57 {
58 public:
59         SWindowGUI *sw_gui;
60         ArrayList<BC_ListBoxItem*> *file_entries;
61
62         SWindowLoadPath(SWindowGUI *gui, int x, int y, char *path);
63         ~SWindowLoadPath();
64
65         int handle_event();
66 };
67
68 class SWindowLoadFile : public BC_GenericButton
69 {
70 public:
71         SWindowGUI *sw_gui;
72
73         int handle_event();
74
75         SWindowLoadFile(SWindowGUI *gui, int x, int y);
76         ~SWindowLoadFile();
77 };
78
79 class SWindowSaveFile : public BC_GenericButton
80 {
81 public:
82         SWindowGUI *sw_gui;
83
84         int handle_event();
85
86         SWindowSaveFile(SWindowGUI *gui, int x, int y);
87         ~SWindowSaveFile();
88 };
89
90
91 class ScriptLines
92 {
93         int allocated, used;
94 public:
95         int lines;
96         char *text;
97         void append(char *cp);
98         int size() { return used; }
99         int break_lines();
100         int get_text_rows();
101         char *get_text_row(int n);
102
103         ScriptLines();
104         ~ScriptLines();
105 };
106
107 class ScriptScroll : public BC_ScrollBar
108 {
109 public:
110         SWindowGUI *sw_gui;
111
112         int handle_event();
113
114         ScriptScroll(SWindowGUI *gui, int x, int y, int w);
115         ~ScriptScroll();
116 };
117
118 class ScriptPosition : public BC_TumbleTextBox
119 {
120 public:
121         SWindowGUI *sw_gui;
122
123         int handle_event();
124
125         ScriptPosition(SWindowGUI *gui, int x, int y, int w, int v=0, int mn=0, int mx=0);
126         ~ScriptPosition();
127 };
128
129 class ScriptEntry : public BC_ScrollTextBox
130 {
131 public:
132         SWindowGUI *sw_gui;
133
134         char *ttext;
135         void set_text(char *text, int isz=-1);
136         int handle_event();
137
138         ScriptEntry(SWindowGUI *gui, int x, int y, int w, int rows, char *text);
139         ScriptEntry(SWindowGUI *gui, int x, int y, int w, int rows);
140         ~ScriptEntry();
141 };
142
143 class ScriptPrev : public BC_GenericButton
144 {
145 public:
146         SWindowGUI *sw_gui;
147
148         int handle_event();
149         ScriptPrev(SWindowGUI *gui, int x, int y);
150         ~ScriptPrev();
151 };
152
153 class ScriptNext : public BC_GenericButton
154 {
155 public:
156         SWindowGUI *sw_gui;
157
158         int handle_event();
159         ScriptNext(SWindowGUI *gui, int x, int y);
160         ~ScriptNext();
161 };
162
163 class ScriptPaste : public BC_GenericButton
164 {
165 public:
166         SWindowGUI *sw_gui;
167
168         int handle_event();
169         ScriptPaste(SWindowGUI *gui, int x, int y);
170         ~ScriptPaste();
171 };
172
173 class ScriptClear : public BC_GenericButton
174 {
175 public:
176         SWindowGUI *sw_gui;
177
178         int handle_event();
179         ScriptClear(SWindowGUI *gui, int x, int y);
180         ~ScriptClear();
181 };
182
183 class SWindowGUI : public BC_Window
184 {
185         static int max(int a,int b) { return a>b ? a : b; }
186 public:
187         SWindow *swindow;
188         BC_OKButton *ok;
189         BC_CancelButton *cancel;
190         SWindowLoadPath *load_path;
191         SWindowLoadFile *load_file;
192         SWindowSaveFile *save_file;
193         BC_Title *script_filesz;
194         BC_Title *script_lines;
195         BC_Title *script_entries;
196         BC_Title *script_texts;
197         BC_Title *script_title;
198         BC_Title *line_title;
199         ScriptPrev *prev_script;
200         ScriptNext *next_script;
201         ScriptPaste *paste_script;
202         ScriptClear *clear_script;
203         ScriptPosition *script_position;
204         ScriptEntry *script_entry;
205         ScriptEntry *line_entry;
206         ScriptScroll *script_scroll;
207         int pad;
208         char *blank_line;
209
210         char script_path[BCTEXTLEN];
211         ArrayList<ScriptLines *> script;
212
213         void create_objects();
214         void load();
215         void stop(int v);
216         int translation_event();
217         int resize_event(int w, int h);
218         void load_defaults();
219         void save_defaults();
220         void load_script();
221         void load_script(FILE *fp);
222         int load_script_line(FILE *fp);
223         void set_script_pos(int64_t entry_no, int text_no=0);
224         int load_selection();
225         int load_selection(int pos, int row);
226         int load_prev_selection();
227         int load_next_selection();
228         int update_selection();
229         int paste_text(const char *text, double start, double end);
230         int paste_selection();
231         int clear_selection();
232         void save_spumux_data();
233
234         int ok_x, ok_y, ok_w, ok_h;
235         int cancel_x, cancel_y, cancel_w, cancel_h;
236         int64_t script_entry_no, script_text_no;
237         int64_t script_line_no, script_text_lines;
238         int text_font, text_rowsz;
239
240         SWindowGUI(SWindow *swindow, int x, int y, int w, int h);
241         ~SWindowGUI();
242
243 };
244
245
246 class SubttlSWin : public BC_MenuItem
247 {
248 public:
249         MWindow *mwindow;
250         int handle_event();
251
252         SubttlSWin(MWindow *mwindow);
253         ~SubttlSWin();
254 };
255
256
257 #endif