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
26 #include "bcprogressbox.inc"
28 #include "channel.inc"
29 #include "channeldb.inc"
30 #include "channelpicker.inc"
31 #include "condition.inc"
33 #include "picture.inc"
36 class ChannelEditWindow;
39 class ChannelEditThread : public Thread
42 ChannelEditThread(ChannelPicker *channel_picker,
43 ChannelDB *channeldb);
47 char* value_to_freqtable(int value);
48 char* value_to_norm(int value);
49 char* value_to_input(int value);
51 Condition *completion;
55 ChannelPicker *channel_picker;
57 ChannelDB *new_channels;
58 ChannelEditWindow *window;
59 ScanThread *scan_thread;
62 class ChannelEditList;
63 class ChannelEditEditThread;
64 class ChannelEditPictureThread;
65 class ConfirmScanThread;
67 class ChannelEditWindow : public BC_Window
70 ChannelEditWindow(ChannelEditThread *thread,
71 ChannelPicker *channel_picker);
74 void create_objects();
75 int translation_event();
77 int add_channel(); // Start the thread for adding a channel
78 void delete_channel(int channel);
79 void delete_channel(Channel *channel);
82 void update_list(); // Synchronize the list box with the channel arrays
83 void update_list(Channel *channel); // Synchronize the list box and the channel
85 int move_channel_up();
86 int move_channel_down();
87 int change_channel_from_list(int channel_number);
88 void get_chan_num(Channel *channel, int &chan, int &stream);
94 ArrayList<BC_ListBoxItem*> channel_list;
95 ChannelEditList *list_box;
96 ChannelEditThread *thread;
97 ChannelPicker *channel_picker;
98 ChannelEditEditThread *edit_thread;
99 ChannelEditPictureThread *picture_thread;
100 ConfirmScanThread *scan_confirm_thread;
103 class ChannelEditSelect : public BC_GenericButton
106 ChannelEditSelect(ChannelEditWindow *window, int x, int y);
107 ~ChannelEditSelect();
109 ChannelEditWindow *window;
113 class ChannelEditAdd : public BC_GenericButton
116 ChannelEditAdd(ChannelEditWindow *window, int x, int y);
119 ChannelEditWindow *window;
122 class ChannelEditList : public BC_ListBox
125 ChannelEditList(ChannelEditWindow *window, int x, int y);
128 ChannelEditWindow *window;
129 static char *column_titles[2];
132 class ChannelEditMoveUp : public BC_GenericButton
135 ChannelEditMoveUp(ChannelEditWindow *window, int x, int y);
136 ~ChannelEditMoveUp();
138 ChannelEditWindow *window;
141 class ChannelEditMoveDown : public BC_GenericButton
144 ChannelEditMoveDown(ChannelEditWindow *window, int x, int y);
145 ~ChannelEditMoveDown();
147 ChannelEditWindow *window;
150 class ChannelEditSort : public BC_GenericButton
153 ChannelEditSort(ChannelEditWindow *window, int x, int y);
155 ChannelEditWindow *window;
158 class ChannelEditScan : public BC_GenericButton
161 ChannelEditScan(ChannelEditWindow *window, int x, int y);
163 ChannelEditWindow *window;
166 class ChannelEditDel : public BC_GenericButton
169 ChannelEditDel(ChannelEditWindow *window, int x, int y);
172 ChannelEditWindow *window;
175 class ChannelEdit : public BC_GenericButton
178 ChannelEdit(ChannelEditWindow *window, int x, int y);
181 ChannelEditWindow *window;
184 class ChannelEditPicture : public BC_GenericButton
187 ChannelEditPicture(ChannelEditWindow *window, int x, int y);
188 ~ChannelEditPicture();
190 ChannelEditWindow *window;
199 // ============================== Confirm overwrite with scanning
201 class ConfirmScan : public BC_Window
204 ConfirmScan(ChannelEditWindow *gui, int x, int y);
205 void create_objects();
206 ChannelEditWindow *gui;
209 class ConfirmScanThread : public BC_DialogThread
212 ConfirmScanThread(ChannelEditWindow *gui);
213 ~ConfirmScanThread();
214 void handle_done_event(int result);
215 BC_Window* new_gui();
216 ChannelEditWindow *gui;
223 // ============================= Scan
225 class ScanThread : public Thread
228 ScanThread(ChannelEditThread *edit);
234 ChannelEditThread *edit;
236 BC_ProgressBox *progress;
245 // ============================= Edit a single channel
247 class ChannelEditEditSource;
248 class ChannelEditEditWindow;
250 class ChannelEditEditThread : public Thread
253 ChannelEditEditThread(ChannelEditWindow *window,
254 ChannelPicker *channel_picker);
255 ~ChannelEditEditThread();
258 int edit_channel(Channel *channel, int editing);
259 void set_device(); // Set the device to the new channel
260 void change_source(const char *source_name); // Change to the source matching the name
261 void change_source(char *source_name); // Change to the source matching the name
264 void set_input(int value);
265 void set_norm(int value);
266 void set_freqtable(int value);
267 void close_threads();
270 Channel *output_channel;
271 ChannelPicker *channel_picker;
272 ChannelEditWindow *window;
273 ChannelEditEditSource *source_text;
274 ChannelEditEditWindow *edit_window;
275 int editing; // Tells whether or not to delete the channel on cancel
276 int in_progress; // Allow only 1 thread at a time
278 Condition *completion;
281 class ChannelEditEditTitle;
284 class ChannelEditEditWindow : public BC_Window
287 ChannelEditEditWindow(ChannelEditEditThread *thread,
288 ChannelEditWindow *window,
289 ChannelPicker *channel_picker);
290 ~ChannelEditEditWindow();
291 void create_objects(Channel *channel);
293 ChannelEditEditThread *thread;
294 ChannelEditWindow *window;
295 ChannelEditEditTitle *title_text;
296 Channel *new_channel;
297 ChannelPicker *channel_picker;
300 class ChannelEditEditTitle : public BC_TextBox
303 ChannelEditEditTitle(int x, int y, ChannelEditEditThread *thread);
304 ~ChannelEditEditTitle();
306 ChannelEditEditThread *thread;
309 class ChannelEditEditSource : public BC_TextBox
312 ChannelEditEditSource(int x, int y, ChannelEditEditThread *thread);
313 ~ChannelEditEditSource();
315 ChannelEditEditThread *thread;
318 class ChannelEditEditSourceTumbler : public BC_Tumbler
321 ChannelEditEditSourceTumbler(int x, int y, ChannelEditEditThread *thread);
322 ~ChannelEditEditSourceTumbler();
323 int handle_up_event();
324 int handle_down_event();
325 ChannelEditEditThread *thread;
328 class ChannelEditEditInput : public BC_PopupMenu
331 ChannelEditEditInput(int x,
333 ChannelEditEditThread *thread,
334 ChannelEditThread *edit);
335 ~ChannelEditEditInput();
338 ChannelEditEditThread *thread;
339 ChannelEditThread *edit;
342 class ChannelEditEditInputItem : public BC_MenuItem
345 ChannelEditEditInputItem(ChannelEditEditThread *thread,
346 ChannelEditThread *edit,
349 ~ChannelEditEditInputItem();
351 ChannelEditEditThread *thread;
352 ChannelEditThread *edit;
356 class ChannelEditEditNorm : public BC_PopupMenu
359 ChannelEditEditNorm(int x,
361 ChannelEditEditThread *thread,
362 ChannelEditThread *edit);
363 ~ChannelEditEditNorm();
365 ChannelEditEditThread *thread;
366 ChannelEditThread *edit;
369 class ChannelEditEditNormItem : public BC_MenuItem
372 ChannelEditEditNormItem(ChannelEditEditThread *thread,
373 ChannelEditThread *edit,
376 ~ChannelEditEditNormItem();
378 ChannelEditEditThread *thread;
379 ChannelEditThread *edit;
383 class ChannelEditEditFreqtable : public BC_PopupMenu
386 ChannelEditEditFreqtable(int x,
388 ChannelEditEditThread *thread,
389 ChannelEditThread *edit);
390 ~ChannelEditEditFreqtable();
394 ChannelEditEditThread *thread;
395 ChannelEditThread *edit;
398 class ChannelEditEditFreqItem : public BC_MenuItem
401 ChannelEditEditFreqItem(ChannelEditEditThread *thread,
402 ChannelEditThread *edit,
405 ~ChannelEditEditFreqItem();
408 ChannelEditEditThread *thread;
409 ChannelEditThread *edit;
413 class ChannelEditEditFine : public BC_ISlider
416 ChannelEditEditFine(int x, int y, ChannelEditEditThread *thread);
417 ~ChannelEditEditFine();
419 int button_release_event();
420 ChannelEditEditThread *thread;
423 // =================== Edit the picture quality
426 class ChannelEditPictureWindow;
428 class ChannelEditPictureThread : public BC_DialogThread
431 ChannelEditPictureThread(ChannelPicker *channel_picker);
432 ~ChannelEditPictureThread();
434 void handle_done_event(int result);
435 BC_Window* new_gui();
438 ChannelPicker *channel_picker;
441 class ChannelEditPictureWindow : public BC_Window
444 ChannelEditPictureWindow(ChannelEditPictureThread *thread,
445 ChannelPicker *channel_picker);
446 ~ChannelEditPictureWindow();
448 int calculate_h(ChannelPicker *channel_picker);
449 int calculate_w(ChannelPicker *channel_picker);
450 void create_objects();
451 int translation_event();
453 ChannelEditPictureThread *thread;
454 ChannelPicker *channel_picker;
457 class ChannelEditBright : public BC_IPot
460 ChannelEditBright(int x, int y, ChannelPicker *channel_picker, int value);
461 ~ChannelEditBright();
463 int button_release_event();
464 ChannelPicker *channel_picker;
467 class ChannelEditContrast : public BC_IPot
470 ChannelEditContrast(int x, int y, ChannelPicker *channel_picker, int value);
471 ~ChannelEditContrast();
473 int button_release_event();
474 ChannelPicker *channel_picker;
477 class ChannelEditColor : public BC_IPot
480 ChannelEditColor(int x, int y, ChannelPicker *channel_picker, int value);
483 int button_release_event();
484 ChannelPicker *channel_picker;
487 class ChannelEditHue : public BC_IPot
490 ChannelEditHue(int x, int y, ChannelPicker *channel_picker, int value);
493 int button_release_event();
494 ChannelPicker *channel_picker;
497 class ChannelEditWhiteness : public BC_IPot
500 ChannelEditWhiteness(int x, int y, ChannelPicker *channel_picker, int value);
501 ~ChannelEditWhiteness();
503 int button_release_event();
504 ChannelPicker *channel_picker;
509 class ChannelEditCommon : public BC_IPot
512 ChannelEditCommon(int x,
514 ChannelPicker *channel_picker,
516 ~ChannelEditCommon();
518 int button_release_event();
519 int keypress_event();
520 ChannelPicker *channel_picker;