2 #include "bcprogressbox.h"
6 #include "channeledit.h"
7 #include "channelpicker.h"
8 #include "chantables.h"
10 #include "condition.h"
14 #include "videodevice.h"
20 ChannelEditThread::ChannelEditThread(ChannelPicker *channel_picker,
24 this->channel_picker = channel_picker;
25 this->channeldb = channeldb;
28 new_channels = new ChannelDB;
29 completion = new Condition(1, "ChannelEditThread::completion");
32 ChannelEditThread::~ChannelEditThread()
34 channel_picker->get_subwindow()->unlock_window();
36 channel_picker->get_subwindow()->lock_window("ChannelEditThread::~ChannelEditThread");
41 void ChannelEditThread::run()
49 window->lock_window("ChannelEditThread::run");
50 window->raise_window(1);
51 window->unlock_window();
56 completion->lock("ChannelEditThread::run");
58 // Copy master channel list to temporary.
59 new_channels->copy_from(channel_picker->channeldb);
60 current_channel = channel_picker->get_current_channel_number();
61 //printf("ChannelEditThread::run 1 %d\n", current_channel);
63 // Run the channel list window using the temporary list.
64 ChannelEditWindow window(this, channel_picker);
65 window.create_objects();
66 this->window = &window;
67 int result = window.run_window();
72 // Copy new channels to master list
73 channel_picker->channeldb->clear();
75 channel_picker->channeldb->copy_from(new_channels);
76 channel_picker->update_channel_list();
80 channel_picker->handle_channel_edit(result);
82 window.edit_thread->close_threads();
83 window.picture_thread->close_threads();
90 int ChannelEditThread::close_threads()
92 if(in_progress && window)
94 window->edit_thread->close_threads();
95 window->picture_thread->close_threads();
97 completion->lock("ChannelEditThread::close_threads");
102 char *ChannelEditThread::value_to_freqtable(int value)
107 return _("NTSC_BCAST");
110 return _("NTSC_CABLE");
113 return _("NTSC_HRC");
116 return _("NTSC_BCAST_JP");
119 return _("NTSC_CABLE_JP");
122 return _("PAL_AUSTRALIA");
125 return _("PAL_EUROPE");
128 return _("PAL_E_EUROPE");
131 return _("PAL_ITALY");
134 return _("PAL_IRELAND");
137 return _("PAL_NEWZEALAND");
142 char* ChannelEditThread::value_to_norm(int value)
158 char* ChannelEditThread::value_to_input(int value)
160 if(channel_picker->get_video_inputs()->total > value)
161 return channel_picker->get_video_inputs()->values[value]->device_name;
172 ChannelEditWindow::ChannelEditWindow(ChannelEditThread *thread,
173 ChannelPicker *channel_picker)
174 : BC_Window(PROGRAM_NAME ": Channels",
175 channel_picker->parent_window->get_abs_cursor_x(1) - 330,
176 channel_picker->parent_window->get_abs_cursor_y(1),
185 this->thread = thread;
186 this->channel_picker = channel_picker;
187 scan_confirm_thread = 0;
189 ChannelEditWindow::~ChannelEditWindow()
192 for(i = 0; i < channel_list.total; i++)
194 delete channel_list.values[i];
196 channel_list.remove_all();
198 delete picture_thread;
199 delete scan_confirm_thread;
202 int ChannelEditWindow::create_objects()
204 int x = 10, y = 10, i;
207 // Create channel list
208 for(i = 0; i < thread->new_channels->size(); i++)
210 channel_list.append(new BC_ListBoxItem(thread->new_channels->get(i)->title));
213 add_subwindow(list_box = new ChannelEditList(this, x, y));
215 if(channel_picker->use_select())
217 add_subwindow(new ChannelEditSelect(this, x, y));
220 add_subwindow(new ChannelEditAdd(this, x, y));
222 add_subwindow(new ChannelEdit(this, x, y));
224 add_subwindow(new ChannelEditMoveUp(this, x, y));
226 add_subwindow(new ChannelEditMoveDown(this, x, y));
228 add_subwindow(new ChannelEditSort(this, x, y));
231 Channel *channel_usage = channel_picker->get_channel_usage();
232 if(channel_usage && channel_usage->has_scanning)
234 add_subwindow(new ChannelEditScan(this, x, y));
237 add_subwindow(new ChannelEditDel(this, x, y));
239 add_subwindow(new ChannelEditPicture(this, x, y));
242 add_subwindow(new BC_OKButton(this));
244 add_subwindow(new BC_CancelButton(this));
247 edit_thread = new ChannelEditEditThread(this,
249 picture_thread = new ChannelEditPictureThread(channel_picker, this);
254 int ChannelEditWindow::close_event()
259 int ChannelEditWindow::add_channel()
261 Channel *new_channel;
262 Channel *prev_channel = 0;
264 // Create new channel
265 new_channel = new Channel;
267 // Reuse parameters from previous channel
268 if(thread->new_channels->size())
270 prev_channel = thread->new_channels->get(
271 thread->new_channels->size() - 1);
272 new_channel->copy_settings(prev_channel);
275 // Use default channel parameters
276 if(channel_picker->get_master_channel())
278 new_channel->copy_settings(channel_picker->get_master_channel());
281 // Copy device usage. Need the same thing for playback.
282 if(channel_picker->get_master_channel())
284 new_channel->copy_usage(channel_picker->get_master_channel());
287 // Add to channel table
288 channel_list.append(new BC_ListBoxItem(new_channel->title));
289 thread->new_channels->append(new_channel);
292 // Start common routing
293 edit_thread->edit_channel(new_channel, 0);
297 int ChannelEditWindow::update_list()
299 // Create channel list
300 channel_list.remove_all_objects();
301 for(int i = 0; i < thread->new_channels->size(); i++)
305 thread->new_channels->get(i)->title));
308 list_box->update(&channel_list, 0, 0, 1, list_box->get_yposition());
311 int ChannelEditWindow::update_list(Channel *channel)
314 for(i = 0; i < thread->new_channels->size(); i++)
315 if(thread->new_channels->get(i) == channel) break;
317 if(i < thread->new_channels->size())
319 channel_list.values[i]->set_text(channel->title);
326 int ChannelEditWindow::edit_channel()
328 if(list_box->get_selection_number(0, 0) > -1)
330 thread->current_channel = list_box->get_selection_number(0, 0);
331 edit_thread->edit_channel(
332 thread->new_channels->get(
333 list_box->get_selection_number(0, 0)),
338 int ChannelEditWindow::edit_picture()
340 picture_thread->edit_picture();
343 void ChannelEditWindow::scan_confirm()
345 channel_picker->load_scan_defaults(&thread->scan_params);
346 if(!scan_confirm_thread) scan_confirm_thread = new ConfirmScanThread(this);
348 scan_confirm_thread->start();
349 lock_window("ChannelEditWindow::scan_confirm");
352 void ChannelEditWindow::scan()
354 thread->new_channels->clear();
357 if(!thread->scan_thread) thread->scan_thread = new ScanThread(thread);
358 thread->scan_thread->start();
362 void ChannelEditWindow::sort()
368 for(int i = 0; i < thread->new_channels->size() - 1; i++)
370 Channel *channel1 = thread->new_channels->get(i);
371 Channel *channel2 = thread->new_channels->get(i + 1);
373 for(int j = 0; j < strlen(channel1->title); j++)
374 if(!isdigit(channel1->title[j])) is_num = 0;
375 for(int j = 0; j < strlen(channel2->title); j++)
376 if(!isdigit(channel2->title[j])) is_num = 0;
377 if(is_num && atoi(channel1->title) > atoi(channel2->title) ||
378 !is_num && strcasecmp(channel2->title, channel1->title) < 0)
380 thread->new_channels->set(i, channel2);
381 thread->new_channels->set(i + 1, channel1);
390 int ChannelEditWindow::delete_channel(int number)
392 delete thread->new_channels->get(number);
393 channel_list.remove_number(number);
394 thread->new_channels->remove_number(number);
398 int ChannelEditWindow::delete_channel(Channel *channel)
401 for(i = 0; i < thread->new_channels->size(); i++)
403 if(thread->new_channels->get(i) == channel)
408 if(i < thread->new_channels->size()) delete_channel(i);
412 int ChannelEditWindow::move_channel_up()
414 if(list_box->get_selection_number(0, 0) > -1)
416 int number2 = list_box->get_selection_number(0, 0);
417 int number1 = number2 - 1;
419 BC_ListBoxItem *temp_text;
421 if(number1 < 0) number1 = thread->new_channels->size() - 1;
423 temp = thread->new_channels->get(number1);
424 thread->new_channels->set(number1, thread->new_channels->get(number2));
425 thread->new_channels->set(number2, temp);
427 temp_text = channel_list.values[number1];
428 channel_list.values[number1] = channel_list.values[number2];
429 channel_list.values[number2] = temp_text;
430 list_box->update(&channel_list,
434 list_box->get_xposition(),
435 list_box->get_yposition(),
442 int ChannelEditWindow::move_channel_down()
444 if(list_box->get_selection_number(0, 0) > -1)
446 int number2 = list_box->get_selection_number(0, 0);
447 int number1 = number2 + 1;
449 BC_ListBoxItem *temp_text;
451 if(number1 > thread->new_channels->size() - 1) number1 = 0;
453 temp = thread->new_channels->get(number1);
454 thread->new_channels->set(number1, thread->new_channels->get(number2));
455 thread->new_channels->set(number2, temp);
456 temp_text = channel_list.values[number1];
457 channel_list.values[number1] = channel_list.values[number2];
458 channel_list.values[number2] = temp_text;
459 list_box->update(&channel_list,
463 list_box->get_xposition(),
464 list_box->get_yposition(),
471 int ChannelEditWindow::change_channel_from_list(int channel_number)
474 if(channel_number > -1 && channel_number < thread->new_channels->size())
476 thread->current_channel = channel_number;
477 channel_picker->set_channel(thread->new_channels->get(channel_number));
481 ChannelEditSelect::ChannelEditSelect(ChannelEditWindow *window, int x, int y)
482 : BC_GenericButton(x, y, _("Select"))
485 ChannelEditSelect::~ChannelEditSelect()
488 int ChannelEditSelect::handle_event()
490 window->change_channel_from_list(
491 window->list_box->get_selection_number(0, 0));
494 ChannelEditAdd::ChannelEditAdd(ChannelEditWindow *window, int x, int y)
495 : BC_GenericButton(x, y, _("Add..."))
497 this->window = window;
499 ChannelEditAdd::~ChannelEditAdd()
502 int ChannelEditAdd::handle_event()
504 window->add_channel();
507 ChannelEditList::ChannelEditList(ChannelEditWindow *window, int x, int y)
511 window->get_h() - BC_OKButton::calculate_h() - y - 10,
513 &(window->channel_list))
515 this->window = window;
517 ChannelEditList::~ChannelEditList()
520 int ChannelEditList::handle_event()
522 window->edit_channel();
525 ChannelEditMoveUp::ChannelEditMoveUp(ChannelEditWindow *window, int x, int y)
526 : BC_GenericButton(x, y, _("Move up"))
528 this->window = window;
530 ChannelEditMoveUp::~ChannelEditMoveUp()
533 int ChannelEditMoveUp::handle_event()
535 lock_window("ChannelEditMoveUp::handle_event");
536 window->move_channel_up();
540 ChannelEditMoveDown::ChannelEditMoveDown(ChannelEditWindow *window, int x, int y)
541 : BC_GenericButton(x, y, _("Move down"))
543 this->window = window;
545 ChannelEditMoveDown::~ChannelEditMoveDown()
548 int ChannelEditMoveDown::handle_event()
550 lock_window("ChannelEditMoveDown::handle_event");
551 window->move_channel_down();
555 ChannelEditSort::ChannelEditSort(ChannelEditWindow *window, int x, int y)
556 : BC_GenericButton(x, y, _("Sort"))
558 this->window = window;
560 int ChannelEditSort::handle_event()
562 lock_window("ChannelEditSort::handle_event");
567 ChannelEditScan::ChannelEditScan(ChannelEditWindow *window, int x, int y)
568 : BC_GenericButton(x, y, _("Scan"))
570 this->window = window;
572 int ChannelEditScan::handle_event()
574 window->scan_confirm();
577 ChannelEditDel::ChannelEditDel(ChannelEditWindow *window, int x, int y)
578 : BC_GenericButton(x, y, _("Delete"))
580 this->window = window;
582 ChannelEditDel::~ChannelEditDel()
585 int ChannelEditDel::handle_event()
587 if(window->list_box->get_selection_number(0, 0) > -1) window->delete_channel(window->list_box->get_selection_number(0, 0));
590 ChannelEdit::ChannelEdit(ChannelEditWindow *window, int x, int y)
591 : BC_GenericButton(x, y, _("Edit..."))
593 this->window = window;
595 ChannelEdit::~ChannelEdit()
598 int ChannelEdit::handle_event()
600 window->edit_channel();
603 ChannelEditPicture::ChannelEditPicture(ChannelEditWindow *window, int x, int y)
604 : BC_GenericButton(x, y, _("Picture..."))
606 this->window = window;
608 ChannelEditPicture::~ChannelEditPicture()
611 int ChannelEditPicture::handle_event()
613 window->edit_picture();
627 // ========================= confirm overwrite by channel scannin
630 ConfirmScan::ConfirmScan(ChannelEditWindow *gui, int x, int y)
631 : BC_Window(PROGRAM_NAME ": Scan confirm",
635 BC_OKButton::calculate_h() + 130,
645 void ConfirmScan::create_objects()
650 add_subwindow(title = new BC_Title(x, y, _("Set parameters for channel scanning.")));
651 y += title->get_h() + 10;
654 add_subwindow(title = new BC_Title(x, y, _("Frequency table:")));
656 y += BC_PopupMenu::calculate_h();
657 add_subwindow(title = new BC_Title(x, y, _("Norm:")));
658 x2 = MAX(x2, title->get_w());
659 y += BC_PopupMenu::calculate_h();
660 add_subwindow(title = new BC_Title(x, y, _("Input:")));
661 x2 = MAX(x2, title->get_w());
662 y += BC_PopupMenu::calculate_h();
667 ChannelEditEditFreqtable *table;
668 add_subwindow(table = new ChannelEditEditFreqtable(x,
673 y += table->get_h() + 10;
675 ChannelEditEditNorm *norm;
676 add_subwindow(norm = new ChannelEditEditNorm(x,
681 y += norm->get_h() + 10;
683 ChannelEditEditInput *input;
684 add_subwindow(input = new ChannelEditEditInput(x,
691 add_subwindow(new BC_OKButton(this));
692 add_subwindow(new BC_CancelButton(this));
702 ConfirmScanThread::ConfirmScanThread(ChannelEditWindow *gui)
708 void ConfirmScanThread::handle_done_event(int result)
710 gui->channel_picker->save_scan_defaults(&gui->thread->scan_params);
713 get_gui()->hide_window();
714 gui->lock_window("ConfirmScanThread::handle_done_event");
716 gui->unlock_window();
720 BC_Window* ConfirmScanThread::new_gui()
722 int x = gui->get_abs_cursor_x(1);
723 int y = gui->get_abs_cursor_y(1);
724 ConfirmScan *result = new ConfirmScan(gui, x, y);
725 result->create_objects();
734 ScanThread::ScanThread(ChannelEditThread *edit)
742 ScanThread::~ScanThread()
751 void ScanThread::start()
753 // Cancel previous job
760 progress = new BC_ProgressBox(
761 edit->channel_picker->parent_window->get_abs_cursor_x(1),
762 edit->channel_picker->parent_window->get_abs_cursor_y(1),
764 chanlists[edit->scan_params.freqtable].count);
768 void ScanThread::run()
771 i < chanlists[edit->scan_params.freqtable].count &&
773 !progress->is_cancelled();
776 edit->scan_params.entry = i;
777 char string[BCTEXTLEN];
778 sprintf(edit->scan_params.title,
780 chanlists[edit->scan_params.freqtable].list[i].name);
783 edit->scan_params.title);
784 progress->update_title(string, 1);
785 progress->update(i, 1);
786 edit->channel_picker->set_channel(&edit->scan_params);
791 int got_signal = edit->channel_picker->has_signal();
794 Channel *new_channel = new Channel;
795 new_channel->copy_usage(&edit->scan_params);
796 new_channel->copy_settings(&edit->scan_params);
797 edit->window->lock_window("ScanThread::run");
798 edit->new_channels->append(new_channel);
799 edit->window->update_list();
800 edit->window->unlock_window();
813 // ================================= Edit a single channel
817 ChannelEditEditThread::ChannelEditEditThread(ChannelEditWindow *window,
818 ChannelPicker *channel_picker)
821 this->window = window;
822 this->channel_picker = channel_picker;
826 completion = new Condition(1, "ChannelEditEditThread::completion");
829 ChannelEditEditThread::~ChannelEditEditThread()
834 int ChannelEditEditThread::close_threads()
838 edit_window->set_done(1);
839 completion->lock("ChannelEditEditThread::close_threads");
840 completion->unlock();
844 int ChannelEditEditThread::edit_channel(Channel *channel, int editing)
848 edit_window->lock_window("ChannelEditEditThread::edit_channel");
849 edit_window->raise_window(1);
850 edit_window->unlock_window();
855 // Copy the channel to edit into a temporary
856 completion->lock("ChannelEditEditThread::edit_channel");
857 this->editing = editing;
858 this->output_channel = channel;
859 new_channel.copy_settings(output_channel);
860 new_channel.copy_usage(output_channel);
862 if(editing && new_channel.title[0])
871 void ChannelEditEditThread::set_device()
873 channel_picker->set_channel(&new_channel);
876 int ChannelEditEditThread::change_source(char *source_name)
879 for(i = 0; i < chanlists[new_channel.freqtable].count; i++)
881 if(!strcasecmp(chanlists[new_channel.freqtable].list[i].name, source_name))
883 new_channel.entry = i;
884 i = chanlists[new_channel.freqtable].count;
890 strcpy(new_channel.title, source_name);
891 if(edit_window->title_text)
893 edit_window->title_text->update(source_name);
898 int ChannelEditEditThread::source_up()
901 if(new_channel.entry > chanlists[new_channel.freqtable].count - 1) new_channel.entry = 0;
902 source_text->update(chanlists[new_channel.freqtable].list[new_channel.entry].name);
906 int ChannelEditEditThread::source_down()
909 if(new_channel.entry < 0) new_channel.entry = chanlists[new_channel.freqtable].count - 1;
910 source_text->update(chanlists[new_channel.freqtable].list[new_channel.entry].name);
914 int ChannelEditEditThread::set_input(int value)
916 new_channel.input = value;
920 int ChannelEditEditThread::set_norm(int value)
922 new_channel.norm = value;
926 int ChannelEditEditThread::set_freqtable(int value)
928 new_channel.freqtable = value;
929 if(new_channel.entry > chanlists[new_channel.freqtable].count - 1) new_channel.entry = 0;
930 source_text->update(chanlists[new_channel.freqtable].list[new_channel.entry].name);
934 void ChannelEditEditThread::run()
937 ChannelEditEditWindow edit_window(this, window, channel_picker);
939 edit_window.create_objects(&new_channel);
941 this->edit_window = &edit_window;
943 int result = edit_window.run_window();
944 this->edit_window = 0;
946 // Done editing channel. Keep channel.
949 output_channel->copy_settings(&new_channel);
950 window->lock_window();
951 window->update_list(output_channel);
952 window->unlock_window();
959 window->lock_window();
960 window->delete_channel(output_channel);
961 window->unlock_window();
965 completion->unlock();
969 ChannelEditEditWindow::ChannelEditEditWindow(ChannelEditEditThread *thread,
970 ChannelEditWindow *window,
971 ChannelPicker *channel_picker)
972 : BC_Window(PROGRAM_NAME ": Edit Channel",
973 channel_picker->parent_window->get_abs_cursor_x(1),
974 channel_picker->parent_window->get_abs_cursor_y(1),
983 this->channel_picker = channel_picker;
984 this->window = window;
985 this->thread = thread;
987 ChannelEditEditWindow::~ChannelEditEditWindow()
990 int ChannelEditEditWindow::create_objects(Channel *channel)
992 this->new_channel = channel;
993 Channel *channel_usage = channel_picker->get_channel_usage();
998 // if(!channel_usage ||
999 // (!channel_usage->use_frequency &&
1000 // !channel_usage->use_fine &&
1001 // !channel_usage->use_norm &&
1002 // !channel_usage->use_input))
1004 // add_subwindow(new BC_Title(x, y, "Device has no input selection."));
1009 add_subwindow(new BC_Title(x, y, _("Title:")));
1010 add_subwindow(title_text = new ChannelEditEditTitle(x, y + 20, thread));
1014 if(channel_usage && channel_usage->use_frequency)
1017 add_subwindow(new BC_Title(x, y, _("Channel:")));
1019 add_subwindow(thread->source_text = new ChannelEditEditSource(x, y, thread));
1020 add_subwindow(new ChannelEditEditSourceTumbler(x + 160, y, thread));
1023 add_subwindow(new BC_Title(x, y, _("Frequency table:")));
1024 ChannelEditEditFreqtable *table;
1025 add_subwindow(table = new ChannelEditEditFreqtable(x + 130,
1034 if(channel_usage && channel_usage->use_fine)
1036 add_subwindow(new BC_Title(x, y, _("Fine:")));
1037 add_subwindow(new ChannelEditEditFine(x + 130, y, thread));
1042 if(channel_usage && channel_usage->use_norm)
1044 add_subwindow(new BC_Title(x, y, _("Norm:")));
1045 ChannelEditEditNorm *norm;
1046 add_subwindow(norm = new ChannelEditEditNorm(x + 130,
1055 if(channel_usage && channel_usage->use_input ||
1058 add_subwindow(new BC_Title(x, y, _("Input:")));
1059 ChannelEditEditInput *input;
1060 add_subwindow(input = new ChannelEditEditInput(x + 130,
1069 add_subwindow(new BC_OKButton(this));
1071 add_subwindow(new BC_CancelButton(this));
1077 ChannelEditEditTitle::ChannelEditEditTitle(int x,
1079 ChannelEditEditThread *thread)
1080 : BC_TextBox(x, y, 150, 1, thread->new_channel.title)
1082 this->thread = thread;
1084 ChannelEditEditTitle::~ChannelEditEditTitle()
1087 int ChannelEditEditTitle::handle_event()
1089 if(strlen(get_text()) < 1024)
1091 strcpy(thread->new_channel.title, get_text());
1094 thread->user_title = 1;
1096 thread->user_title = 0;
1101 ChannelEditEditSource::ChannelEditEditSource(int x, int y, ChannelEditEditThread *thread)
1102 : BC_TextBox(x, y, 150, 1, chanlists[thread->new_channel.freqtable].list[thread->new_channel.entry].name)
1104 this->thread = thread;
1107 ChannelEditEditSource::~ChannelEditEditSource()
1110 int ChannelEditEditSource::handle_event()
1112 thread->change_source(get_text());
1116 ChannelEditEditSourceTumbler::ChannelEditEditSourceTumbler(int x, int y, ChannelEditEditThread *thread)
1119 this->thread = thread;
1121 ChannelEditEditSourceTumbler::~ChannelEditEditSourceTumbler()
1124 int ChannelEditEditSourceTumbler::handle_up_event()
1126 thread->source_up();
1128 int ChannelEditEditSourceTumbler::handle_down_event()
1130 thread->source_down();
1133 ChannelEditEditInput::ChannelEditEditInput(int x,
1135 ChannelEditEditThread *thread,
1136 ChannelEditThread *edit)
1140 edit->value_to_input(thread ? thread->new_channel.input : edit->scan_params.input))
1142 this->thread = thread;
1145 ChannelEditEditInput::~ChannelEditEditInput()
1148 int ChannelEditEditInput::add_items()
1150 ArrayList<Channel*> *inputs;
1151 inputs = edit->channel_picker->get_video_inputs();
1154 for(int i = 0; i < inputs->total; i++)
1156 add_item(new ChannelEditEditInputItem(thread,
1158 inputs->values[i]->device_name,
1162 int ChannelEditEditInput::handle_event()
1167 ChannelEditEditInputItem::ChannelEditEditInputItem(ChannelEditEditThread *thread,
1168 ChannelEditThread *edit,
1173 this->thread = thread;
1175 this->value = value;
1177 ChannelEditEditInputItem::~ChannelEditEditInputItem()
1180 int ChannelEditEditInputItem::handle_event()
1182 get_popup_menu()->set_text(get_text());
1183 if(thread && !thread->user_title)
1185 strcpy(thread->new_channel.title, get_text());
1186 if(thread->edit_window->title_text)
1188 thread->edit_window->title_text->update(get_text());
1192 thread->set_input(value);
1194 edit->scan_params.input = value;
1197 ChannelEditEditNorm::ChannelEditEditNorm(int x,
1199 ChannelEditEditThread *thread,
1200 ChannelEditThread *edit)
1204 edit->value_to_norm(thread ? thread->new_channel.norm : edit->scan_params.norm))
1206 this->thread = thread;
1209 ChannelEditEditNorm::~ChannelEditEditNorm()
1212 int ChannelEditEditNorm::add_items()
1214 add_item(new ChannelEditEditNormItem(thread,
1216 edit->value_to_norm(NTSC), NTSC));
1217 add_item(new ChannelEditEditNormItem(thread,
1219 edit->value_to_norm(PAL), PAL));
1220 add_item(new ChannelEditEditNormItem(thread,
1222 edit->value_to_norm(SECAM), SECAM));
1227 ChannelEditEditNormItem::ChannelEditEditNormItem(ChannelEditEditThread *thread,
1228 ChannelEditThread *edit,
1233 this->value = value;
1235 this->thread = thread;
1237 ChannelEditEditNormItem::~ChannelEditEditNormItem()
1240 int ChannelEditEditNormItem::handle_event()
1242 get_popup_menu()->set_text(get_text());
1244 thread->set_norm(value);
1246 edit->scan_params.norm = value;
1250 ChannelEditEditFreqtable::ChannelEditEditFreqtable(int x,
1252 ChannelEditEditThread *thread,
1253 ChannelEditThread *edit)
1257 edit->value_to_freqtable(thread ? thread->new_channel.freqtable : edit->scan_params.freqtable))
1259 this->thread = thread;
1262 ChannelEditEditFreqtable::~ChannelEditEditFreqtable()
1265 int ChannelEditEditFreqtable::add_items()
1267 add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(NTSC_BCAST), NTSC_BCAST));
1268 add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(NTSC_CABLE), NTSC_CABLE));
1269 add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(NTSC_HRC), NTSC_HRC));
1270 add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(NTSC_BCAST_JP), NTSC_BCAST_JP));
1271 add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(NTSC_CABLE_JP), NTSC_CABLE_JP));
1272 add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(PAL_AUSTRALIA), PAL_AUSTRALIA));
1273 add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(PAL_EUROPE), PAL_EUROPE));
1274 add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(PAL_E_EUROPE), PAL_E_EUROPE));
1275 add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(PAL_ITALY), PAL_ITALY));
1276 add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(PAL_IRELAND), PAL_IRELAND));
1277 add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(PAL_NEWZEALAND), PAL_NEWZEALAND));
1281 ChannelEditEditFreqItem::ChannelEditEditFreqItem(ChannelEditEditThread *thread,
1282 ChannelEditThread *edit,
1283 char *text, int value)
1286 this->value = value;
1288 this->thread = thread;
1290 ChannelEditEditFreqItem::~ChannelEditEditFreqItem()
1293 int ChannelEditEditFreqItem::handle_event()
1295 get_popup_menu()->set_text(get_text());
1297 thread->set_freqtable(value);
1299 edit->scan_params.freqtable = value;
1304 ChannelEditEditFine::ChannelEditEditFine(int x,
1306 ChannelEditEditThread *thread)
1314 thread->new_channel.fine_tune)
1316 this->thread = thread;
1318 ChannelEditEditFine::~ChannelEditEditFine()
1321 int ChannelEditEditFine::handle_event()
1325 int ChannelEditEditFine::button_release_event()
1327 if(BC_Slider::button_release_event())
1329 thread->new_channel.fine_tune = get_value();
1330 thread->set_device();
1337 // ========================== picture quality
1339 ChannelEditPictureThread::ChannelEditPictureThread(ChannelPicker *channel_picker, ChannelEditWindow *window)
1342 this->channel_picker = channel_picker;
1343 this->window = window;
1346 completion = new Condition(1, "ChannelEditPictureThread::completion");
1348 ChannelEditPictureThread::~ChannelEditPictureThread()
1353 int ChannelEditPictureThread::edit_picture()
1357 edit_window->lock_window("ChannelEditPictureThread::edit_picture");
1358 edit_window->raise_window(1);
1359 edit_window->unlock_window();
1363 completion->lock("ChannelEditPictureThread::edit_picture");
1368 void ChannelEditPictureThread::run()
1371 ChannelEditPictureWindow edit_window(this,
1374 edit_window.create_objects();
1376 this->edit_window = &edit_window;
1378 int result = edit_window.run_window();
1380 this->edit_window = 0;
1382 completion->unlock();
1387 int ChannelEditPictureThread::close_threads()
1391 edit_window->set_done(1);
1392 completion->lock("ChannelEditPictureThread::close_threads");
1393 completion->unlock();
1398 ChannelEditPictureWindow::ChannelEditPictureWindow(ChannelEditPictureThread *thread,
1399 ChannelPicker *channel_picker)
1400 : BC_Window(PROGRAM_NAME ": Picture",
1401 channel_picker->parent_window->get_abs_cursor_x(1) - 200,
1402 channel_picker->parent_window->get_abs_cursor_y(1) - 220,
1404 calculate_h(channel_picker),
1406 calculate_h(channel_picker))
1408 this->thread = thread;
1409 this->channel_picker = channel_picker;
1411 ChannelEditPictureWindow::~ChannelEditPictureWindow()
1415 int ChannelEditPictureWindow::calculate_h(ChannelPicker *channel_picker)
1417 PictureConfig *picture_usage = channel_picker->get_picture_usage();
1418 int pad = BC_Pot::calculate_h();
1420 channel_picker->parent_window->get_text_height(MEDIUMFONT) + 5 +
1421 BC_OKButton::calculate_h();
1425 if(picture_usage->use_brightness)
1427 if(picture_usage->use_contrast)
1429 if(picture_usage->use_color)
1431 if(picture_usage->use_hue)
1433 if(picture_usage->use_whiteness)
1436 result += channel_picker->get_controls() * pad;
1440 int ChannelEditPictureWindow::create_objects()
1443 int x1 = 110, x2 = 145;
1444 int pad = BC_Pot::calculate_h();
1445 #define SWAP_X x1 ^= x2; x2 ^= x1; x1 ^= x2;
1448 PictureConfig *picture_usage = channel_picker->get_picture_usage();
1451 if(!picture_usage ||
1452 (!picture_usage->use_brightness &&
1453 !picture_usage->use_contrast &&
1454 !picture_usage->use_color &&
1455 !picture_usage->use_hue &&
1456 !picture_usage->use_whiteness &&
1457 !channel_picker->get_controls()))
1459 add_subwindow(new BC_Title(x, y, "Device has no picture controls."));
1464 if(picture_usage && picture_usage->use_brightness)
1466 add_subwindow(new BC_Title(x, y + 10, _("Brightness:")));
1467 add_subwindow(new ChannelEditBright(x1, y, channel_picker, channel_picker->get_brightness()));
1474 if(picture_usage && picture_usage->use_contrast)
1476 add_subwindow(new BC_Title(x, y + 10, _("Contrast:")));
1477 add_subwindow(new ChannelEditContrast(x1, y, channel_picker, channel_picker->get_contrast()));
1483 if(picture_usage && picture_usage->use_color)
1485 add_subwindow(new BC_Title(x, y + 10, _("Color:")));
1486 add_subwindow(new ChannelEditColor(x1, y, channel_picker, channel_picker->get_color()));
1492 if(picture_usage && picture_usage->use_hue)
1494 add_subwindow(new BC_Title(x, y + 10, _("Hue:")));
1495 add_subwindow(new ChannelEditHue(x1, y, channel_picker, channel_picker->get_hue()));
1501 if(picture_usage && picture_usage->use_whiteness)
1503 add_subwindow(new BC_Title(x, y + 10, _("Whiteness:")));
1504 add_subwindow(new ChannelEditWhiteness(x1, y, channel_picker, channel_picker->get_whiteness()));
1510 for(int i = 0; i < channel_picker->get_controls(); i++)
1512 add_subwindow(new BC_Title(x,
1514 _(channel_picker->get_control(i)->name)));
1515 add_subwindow(new ChannelEditCommon(x1,
1518 channel_picker->get_control(i)));
1526 add_subwindow(new BC_OKButton(this));
1532 ChannelEditBright::ChannelEditBright(int x, int y, ChannelPicker *channel_picker, int value)
1539 this->channel_picker = channel_picker;
1541 ChannelEditBright::~ChannelEditBright() {}
1542 int ChannelEditBright::handle_event()
1546 int ChannelEditBright::button_release_event()
1548 if(BC_Pot::button_release_event())
1550 channel_picker->set_brightness(get_value());
1556 ChannelEditContrast::ChannelEditContrast(int x, int y, ChannelPicker *channel_picker, int value)
1563 this->channel_picker = channel_picker;
1565 ChannelEditContrast::~ChannelEditContrast() {}
1566 int ChannelEditContrast::handle_event()
1570 int ChannelEditContrast::button_release_event()
1572 if(BC_Pot::button_release_event())
1574 channel_picker->set_contrast(get_value());
1581 ChannelEditColor::ChannelEditColor(int x, int y, ChannelPicker *channel_picker, int value)
1588 this->channel_picker = channel_picker;
1590 ChannelEditColor::~ChannelEditColor() {}
1591 int ChannelEditColor::handle_event()
1595 int ChannelEditColor::button_release_event()
1597 if(BC_Pot::button_release_event())
1599 channel_picker->set_color(get_value());
1605 ChannelEditHue::ChannelEditHue(int x, int y, ChannelPicker *channel_picker, int value)
1612 this->channel_picker = channel_picker;
1614 ChannelEditHue::~ChannelEditHue() {}
1615 int ChannelEditHue::handle_event()
1619 int ChannelEditHue::button_release_event()
1621 if(BC_Pot::button_release_event())
1623 channel_picker->set_hue(get_value());
1629 ChannelEditWhiteness::ChannelEditWhiteness(int x, int y, ChannelPicker *channel_picker, int value)
1636 this->channel_picker = channel_picker;
1638 ChannelEditWhiteness::~ChannelEditWhiteness()
1641 int ChannelEditWhiteness::handle_event()
1645 int ChannelEditWhiteness::button_release_event()
1647 if(BC_Pot::button_release_event())
1649 channel_picker->set_whiteness(get_value());
1657 ChannelEditCommon::ChannelEditCommon(int x,
1659 ChannelPicker *channel_picker,
1667 this->channel_picker = channel_picker;
1668 this->device_id = item->device_id;
1671 ChannelEditCommon::~ChannelEditCommon()
1675 int ChannelEditCommon::handle_event()
1680 int ChannelEditCommon::button_release_event()
1682 if(BC_Pot::button_release_event())
1684 channel_picker->set_picture(device_id, get_value());
1695 // c-file-style: "linux"