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);
235 ChannelEditThread *edit;
237 BC_ProgressBox *progress;
246 // ============================= Edit a single channel
248 class ChannelEditEditSource;
249 class ChannelEditEditWindow;
251 class ChannelEditEditThread : public Thread
254 ChannelEditEditThread(ChannelEditWindow *window,
255 ChannelPicker *channel_picker);
256 ~ChannelEditEditThread();
259 int edit_channel(Channel *channel, int editing);
260 void set_device(); // Set the device to the new channel
261 void change_source(const char *source_name); // Change to the source matching the name
262 void change_source(char *source_name); // Change to the source matching the name
265 void set_input(int value);
266 void set_norm(int value);
267 void set_freqtable(int value);
268 void close_threads();
271 Channel *output_channel;
272 ChannelPicker *channel_picker;
273 ChannelEditWindow *window;
274 ChannelEditEditSource *source_text;
275 ChannelEditEditWindow *edit_window;
276 int editing; // Tells whether or not to delete the channel on cancel
277 int in_progress; // Allow only 1 thread at a time
279 Condition *completion;
282 class ChannelEditEditTitle;
285 class ChannelEditEditWindow : public BC_Window
288 ChannelEditEditWindow(ChannelEditEditThread *thread,
289 ChannelEditWindow *window,
290 ChannelPicker *channel_picker);
291 ~ChannelEditEditWindow();
292 void create_objects(Channel *channel);
294 ChannelEditEditThread *thread;
295 ChannelEditWindow *window;
296 ChannelEditEditTitle *title_text;
297 Channel *new_channel;
298 ChannelPicker *channel_picker;
301 class ChannelEditEditTitle : public BC_TextBox
304 ChannelEditEditTitle(int x, int y, ChannelEditEditThread *thread);
305 ~ChannelEditEditTitle();
307 ChannelEditEditThread *thread;
310 class ChannelEditEditSource : public BC_TextBox
313 ChannelEditEditSource(int x, int y, ChannelEditEditThread *thread);
314 ~ChannelEditEditSource();
316 ChannelEditEditThread *thread;
319 class ChannelEditEditSourceTumbler : public BC_Tumbler
322 ChannelEditEditSourceTumbler(int x, int y, ChannelEditEditThread *thread);
323 ~ChannelEditEditSourceTumbler();
324 int handle_up_event();
325 int handle_down_event();
326 ChannelEditEditThread *thread;
329 class ChannelEditEditInput : public BC_PopupMenu
332 ChannelEditEditInput(int x,
334 ChannelEditEditThread *thread,
335 ChannelEditThread *edit);
336 ~ChannelEditEditInput();
339 ChannelEditEditThread *thread;
340 ChannelEditThread *edit;
343 class ChannelEditEditInputItem : public BC_MenuItem
346 ChannelEditEditInputItem(ChannelEditEditThread *thread,
347 ChannelEditThread *edit,
350 ~ChannelEditEditInputItem();
352 ChannelEditEditThread *thread;
353 ChannelEditThread *edit;
357 class ChannelEditEditNorm : public BC_PopupMenu
360 ChannelEditEditNorm(int x,
362 ChannelEditEditThread *thread,
363 ChannelEditThread *edit);
364 ~ChannelEditEditNorm();
366 ChannelEditEditThread *thread;
367 ChannelEditThread *edit;
370 class ChannelEditEditNormItem : public BC_MenuItem
373 ChannelEditEditNormItem(ChannelEditEditThread *thread,
374 ChannelEditThread *edit,
377 ~ChannelEditEditNormItem();
379 ChannelEditEditThread *thread;
380 ChannelEditThread *edit;
384 class ChannelEditEditFreqtable : public BC_PopupMenu
387 ChannelEditEditFreqtable(int x,
389 ChannelEditEditThread *thread,
390 ChannelEditThread *edit);
391 ~ChannelEditEditFreqtable();
395 ChannelEditEditThread *thread;
396 ChannelEditThread *edit;
399 class ChannelEditEditFreqItem : public BC_MenuItem
402 ChannelEditEditFreqItem(ChannelEditEditThread *thread,
403 ChannelEditThread *edit,
406 ~ChannelEditEditFreqItem();
409 ChannelEditEditThread *thread;
410 ChannelEditThread *edit;
414 class ChannelEditEditFine : public BC_ISlider
417 ChannelEditEditFine(int x, int y, ChannelEditEditThread *thread);
418 ~ChannelEditEditFine();
420 int button_release_event();
421 ChannelEditEditThread *thread;
424 // =================== Edit the picture quality
427 class ChannelEditPictureWindow;
429 class ChannelEditPictureThread : public BC_DialogThread
432 ChannelEditPictureThread(ChannelPicker *channel_picker);
433 ~ChannelEditPictureThread();
435 void handle_done_event(int result);
436 BC_Window* new_gui();
439 ChannelPicker *channel_picker;
440 void close_threads();
443 class ChannelEditPictureWindow : public BC_Window
446 ChannelEditPictureWindow(ChannelEditPictureThread *thread,
447 ChannelPicker *channel_picker);
448 ~ChannelEditPictureWindow();
450 int calculate_h(ChannelPicker *channel_picker);
451 int calculate_w(ChannelPicker *channel_picker);
452 void create_objects();
453 int translation_event();
455 ChannelEditPictureThread *thread;
456 ChannelPicker *channel_picker;
459 class ChannelEditBright : public BC_IPot
462 ChannelEditBright(int x, int y, ChannelPicker *channel_picker, int value);
463 ~ChannelEditBright();
465 int button_release_event();
466 ChannelPicker *channel_picker;
469 class ChannelEditContrast : public BC_IPot
472 ChannelEditContrast(int x, int y, ChannelPicker *channel_picker, int value);
473 ~ChannelEditContrast();
475 int button_release_event();
476 ChannelPicker *channel_picker;
479 class ChannelEditColor : public BC_IPot
482 ChannelEditColor(int x, int y, ChannelPicker *channel_picker, int value);
485 int button_release_event();
486 ChannelPicker *channel_picker;
489 class ChannelEditHue : public BC_IPot
492 ChannelEditHue(int x, int y, ChannelPicker *channel_picker, int value);
495 int button_release_event();
496 ChannelPicker *channel_picker;
499 class ChannelEditWhiteness : public BC_IPot
502 ChannelEditWhiteness(int x, int y, ChannelPicker *channel_picker, int value);
503 ~ChannelEditWhiteness();
505 int button_release_event();
506 ChannelPicker *channel_picker;
511 class ChannelEditCommon : public BC_IPot
514 ChannelEditCommon(int x,
516 ChannelPicker *channel_picker,
518 ~ChannelEditCommon();
520 int button_release_event();
521 int keypress_event();
522 ChannelPicker *channel_picker;