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 void handle_done_event(int result);
214 BC_Window* new_gui();
215 ChannelEditWindow *gui;
222 // ============================= Scan
224 class ScanThread : public Thread
227 ScanThread(ChannelEditThread *edit);
233 ChannelEditThread *edit;
235 BC_ProgressBox *progress;
244 // ============================= Edit a single channel
246 class ChannelEditEditSource;
247 class ChannelEditEditWindow;
249 class ChannelEditEditThread : public Thread
252 ChannelEditEditThread(ChannelEditWindow *window,
253 ChannelPicker *channel_picker);
254 ~ChannelEditEditThread();
257 int edit_channel(Channel *channel, int editing);
258 void set_device(); // Set the device to the new channel
259 void change_source(const char *source_name); // Change to the source matching the name
260 void change_source(char *source_name); // Change to the source matching the name
263 void set_input(int value);
264 void set_norm(int value);
265 void set_freqtable(int value);
266 void close_threads();
269 Channel *output_channel;
270 ChannelPicker *channel_picker;
271 ChannelEditWindow *window;
272 ChannelEditEditSource *source_text;
273 ChannelEditEditWindow *edit_window;
274 int editing; // Tells whether or not to delete the channel on cancel
275 int in_progress; // Allow only 1 thread at a time
277 Condition *completion;
280 class ChannelEditEditTitle;
283 class ChannelEditEditWindow : public BC_Window
286 ChannelEditEditWindow(ChannelEditEditThread *thread,
287 ChannelEditWindow *window,
288 ChannelPicker *channel_picker);
289 ~ChannelEditEditWindow();
290 void create_objects(Channel *channel);
292 ChannelEditEditThread *thread;
293 ChannelEditWindow *window;
294 ChannelEditEditTitle *title_text;
295 Channel *new_channel;
296 ChannelPicker *channel_picker;
299 class ChannelEditEditTitle : public BC_TextBox
302 ChannelEditEditTitle(int x, int y, ChannelEditEditThread *thread);
303 ~ChannelEditEditTitle();
305 ChannelEditEditThread *thread;
308 class ChannelEditEditSource : public BC_TextBox
311 ChannelEditEditSource(int x, int y, ChannelEditEditThread *thread);
312 ~ChannelEditEditSource();
314 ChannelEditEditThread *thread;
317 class ChannelEditEditSourceTumbler : public BC_Tumbler
320 ChannelEditEditSourceTumbler(int x, int y, ChannelEditEditThread *thread);
321 ~ChannelEditEditSourceTumbler();
322 int handle_up_event();
323 int handle_down_event();
324 ChannelEditEditThread *thread;
327 class ChannelEditEditInput : public BC_PopupMenu
330 ChannelEditEditInput(int x,
332 ChannelEditEditThread *thread,
333 ChannelEditThread *edit);
334 ~ChannelEditEditInput();
337 ChannelEditEditThread *thread;
338 ChannelEditThread *edit;
341 class ChannelEditEditInputItem : public BC_MenuItem
344 ChannelEditEditInputItem(ChannelEditEditThread *thread,
345 ChannelEditThread *edit,
348 ~ChannelEditEditInputItem();
350 ChannelEditEditThread *thread;
351 ChannelEditThread *edit;
355 class ChannelEditEditNorm : public BC_PopupMenu
358 ChannelEditEditNorm(int x,
360 ChannelEditEditThread *thread,
361 ChannelEditThread *edit);
362 ~ChannelEditEditNorm();
364 ChannelEditEditThread *thread;
365 ChannelEditThread *edit;
368 class ChannelEditEditNormItem : public BC_MenuItem
371 ChannelEditEditNormItem(ChannelEditEditThread *thread,
372 ChannelEditThread *edit,
375 ~ChannelEditEditNormItem();
377 ChannelEditEditThread *thread;
378 ChannelEditThread *edit;
382 class ChannelEditEditFreqtable : public BC_PopupMenu
385 ChannelEditEditFreqtable(int x,
387 ChannelEditEditThread *thread,
388 ChannelEditThread *edit);
389 ~ChannelEditEditFreqtable();
393 ChannelEditEditThread *thread;
394 ChannelEditThread *edit;
397 class ChannelEditEditFreqItem : public BC_MenuItem
400 ChannelEditEditFreqItem(ChannelEditEditThread *thread,
401 ChannelEditThread *edit,
404 ~ChannelEditEditFreqItem();
407 ChannelEditEditThread *thread;
408 ChannelEditThread *edit;
412 class ChannelEditEditFine : public BC_ISlider
415 ChannelEditEditFine(int x, int y, ChannelEditEditThread *thread);
416 ~ChannelEditEditFine();
418 int button_release_event();
419 ChannelEditEditThread *thread;
422 // =================== Edit the picture quality
425 class ChannelEditPictureWindow;
427 class ChannelEditPictureThread : public BC_DialogThread
430 ChannelEditPictureThread(ChannelPicker *channel_picker);
431 ~ChannelEditPictureThread();
433 void handle_done_event(int result);
434 BC_Window* new_gui();
437 ChannelPicker *channel_picker;
440 class ChannelEditPictureWindow : public BC_Window
443 ChannelEditPictureWindow(ChannelEditPictureThread *thread,
444 ChannelPicker *channel_picker);
445 ~ChannelEditPictureWindow();
447 int calculate_h(ChannelPicker *channel_picker);
448 int calculate_w(ChannelPicker *channel_picker);
449 void create_objects();
450 int translation_event();
452 ChannelEditPictureThread *thread;
453 ChannelPicker *channel_picker;
456 class ChannelEditBright : public BC_IPot
459 ChannelEditBright(int x, int y, ChannelPicker *channel_picker, int value);
460 ~ChannelEditBright();
462 int button_release_event();
463 ChannelPicker *channel_picker;
466 class ChannelEditContrast : public BC_IPot
469 ChannelEditContrast(int x, int y, ChannelPicker *channel_picker, int value);
470 ~ChannelEditContrast();
472 int button_release_event();
473 ChannelPicker *channel_picker;
476 class ChannelEditColor : public BC_IPot
479 ChannelEditColor(int x, int y, ChannelPicker *channel_picker, int value);
482 int button_release_event();
483 ChannelPicker *channel_picker;
486 class ChannelEditHue : public BC_IPot
489 ChannelEditHue(int x, int y, ChannelPicker *channel_picker, int value);
492 int button_release_event();
493 ChannelPicker *channel_picker;
496 class ChannelEditWhiteness : public BC_IPot
499 ChannelEditWhiteness(int x, int y, ChannelPicker *channel_picker, int value);
500 ~ChannelEditWhiteness();
502 int button_release_event();
503 ChannelPicker *channel_picker;
508 class ChannelEditCommon : public BC_IPot
511 ChannelEditCommon(int x,
513 ChannelPicker *channel_picker,
515 ~ChannelEditCommon();
517 int button_release_event();
518 int keypress_event();
519 ChannelPicker *channel_picker;