4 #include "channeledit.h"
5 #include "channelpicker.h"
6 #include "chantables.h"
10 #include "mainprogress.h"
12 #include "mwindowgui.h"
15 #include "recordgui.h"
17 #include "videodevice.h"
23 ChannelEditThread::ChannelEditThread(MWindow *mwindow,
24 ChannelPicker *channel_picker,
29 this->channel_picker = channel_picker;
30 this->mwindow = mwindow;
31 this->channeldb = channeldb;
32 this->record = record;
35 new_channels = new ChannelDB;
36 completion = new Condition(1, "ChannelEditThread::completion");
39 ChannelEditThread::~ChannelEditThread()
41 channel_picker->get_subwindow()->unlock_window();
43 channel_picker->get_subwindow()->lock_window("ChannelEditThread::~ChannelEditThread");
48 void ChannelEditThread::run()
56 window->lock_window("ChannelEditThread::run");
57 window->raise_window(1);
58 window->unlock_window();
63 completion->lock("ChannelEditThread::run");
65 // Copy master channel list to temporary.
66 new_channels->copy_from(channel_picker->channeldb);
67 current_channel = channel_picker->get_current_channel_number();
68 //printf("ChannelEditThread::run 1 %d\n", current_channel);
70 // Run the channel list window using the temporary list.
71 ChannelEditWindow window(mwindow, this, channel_picker);
72 window.create_objects();
73 this->window = &window;
74 int result = window.run_window();
79 // Copy new channels to master list
80 channel_picker->channeldb->clear();
82 channel_picker->channeldb->copy_from(new_channels);
83 channel_picker->update_channel_list();
87 record->record_gui->lock_window("ChannelEditThread::run");
88 record->record_gui->update_batch_sources();
90 record->set_channel(current_channel);
91 record->record_gui->unlock_window();
92 record->save_defaults();
93 record->channeldb->save(record->get_channeldb_prefix());
95 mwindow->save_defaults();
102 record->set_channel(record->get_editing_batch()->channel);
106 window.edit_thread->close_threads();
107 window.picture_thread->close_threads();
109 completion->unlock();
114 int ChannelEditThread::close_threads()
116 if(in_progress && window)
118 window->edit_thread->close_threads();
119 window->picture_thread->close_threads();
121 completion->lock("ChannelEditThread::close_threads");
122 completion->unlock();
126 char *ChannelEditThread::value_to_freqtable(int value)
131 return _("NTSC_BCAST");
134 return _("NTSC_CABLE");
137 return _("NTSC_HRC");
140 return _("NTSC_BCAST_JP");
143 return _("NTSC_CABLE_JP");
146 return _("PAL_AUSTRALIA");
149 return _("PAL_EUROPE");
152 return _("PAL_E_EUROPE");
155 return _("PAL_ITALY");
158 return _("PAL_IRELAND");
161 return _("PAL_NEWZEALAND");
166 char* ChannelEditThread::value_to_norm(int value)
182 char* ChannelEditThread::value_to_input(int value)
184 if(channel_picker->get_video_inputs()->total > value)
185 return channel_picker->get_video_inputs()->values[value]->device_name;
196 ChannelEditWindow::ChannelEditWindow(MWindow *mwindow,
197 ChannelEditThread *thread,
198 ChannelPicker *channel_picker)
199 : BC_Window(PROGRAM_NAME ": Channels",
200 mwindow->gui->get_abs_cursor_x(1) - 330,
201 mwindow->gui->get_abs_cursor_y(1),
210 this->thread = thread;
211 this->channel_picker = channel_picker;
212 this->mwindow = mwindow;
213 scan_confirm_thread = 0;
215 ChannelEditWindow::~ChannelEditWindow()
218 for(i = 0; i < channel_list.total; i++)
220 delete channel_list.values[i];
222 channel_list.remove_all();
224 delete picture_thread;
225 delete scan_confirm_thread;
228 int ChannelEditWindow::create_objects()
230 int x = 10, y = 10, i;
233 // Create channel list
234 for(i = 0; i < thread->new_channels->size(); i++)
236 channel_list.append(new BC_ListBoxItem(thread->new_channels->get(i)->title));
239 add_subwindow(list_box = new ChannelEditList(mwindow, this, x, y));
243 add_subwindow(new ChannelEditSelect(mwindow, this, x, y));
246 add_subwindow(new ChannelEditAdd(mwindow, this, x, y));
248 add_subwindow(new ChannelEdit(mwindow, this, x, y));
250 add_subwindow(new ChannelEditMoveUp(mwindow, this, x, y));
252 add_subwindow(new ChannelEditMoveDown(mwindow, this, x, y));
254 add_subwindow(new ChannelEditSort(mwindow, this, x, y));
257 Channel *channel_usage = channel_picker->get_channel_usage();
258 if(channel_usage->has_scanning)
260 add_subwindow(new ChannelEditScan(mwindow, this, x, y));
263 add_subwindow(new ChannelEditDel(mwindow, this, x, y));
265 add_subwindow(new ChannelEditPicture(mwindow, this, x, y));
268 add_subwindow(new BC_OKButton(this));
270 add_subwindow(new BC_CancelButton(this));
273 edit_thread = new ChannelEditEditThread(this,
276 picture_thread = new ChannelEditPictureThread(channel_picker, this);
281 int ChannelEditWindow::close_event()
286 int ChannelEditWindow::add_channel()
288 Channel *new_channel;
289 Channel *prev_channel = 0;
291 // Create new channel
292 new_channel = new Channel;
294 // Reuse parameters from previous channel
295 if(thread->new_channels->size())
297 prev_channel = thread->new_channels->get(
298 thread->new_channels->size() - 1);
299 new_channel->copy_settings(prev_channel);
302 // Use default channel parameters
305 new_channel->copy_settings(thread->record->master_channel);
308 // Copy device usage. Need the same thing for playback.
311 new_channel->copy_usage(thread->record->master_channel);
314 // Add to channel table
315 channel_list.append(new BC_ListBoxItem(new_channel->title));
316 thread->new_channels->append(new_channel);
319 // Start common routing
320 edit_thread->edit_channel(new_channel, 0);
324 int ChannelEditWindow::update_list()
326 // Create channel list
327 channel_list.remove_all_objects();
328 for(int i = 0; i < thread->new_channels->size(); i++)
332 thread->new_channels->get(i)->title));
335 list_box->update(&channel_list, 0, 0, 1, list_box->get_yposition());
338 int ChannelEditWindow::update_list(Channel *channel)
341 for(i = 0; i < thread->new_channels->size(); i++)
342 if(thread->new_channels->get(i) == channel) break;
344 if(i < thread->new_channels->size())
346 channel_list.values[i]->set_text(channel->title);
353 int ChannelEditWindow::edit_channel()
355 if(list_box->get_selection_number(0, 0) > -1)
357 thread->current_channel = list_box->get_selection_number(0, 0);
358 edit_thread->edit_channel(
359 thread->new_channels->get(
360 list_box->get_selection_number(0, 0)),
365 int ChannelEditWindow::edit_picture()
367 picture_thread->edit_picture();
370 void ChannelEditWindow::scan_confirm()
372 thread->scan_params.load_defaults(mwindow->defaults);
373 if(!scan_confirm_thread) scan_confirm_thread = new ConfirmScanThread(this);
375 scan_confirm_thread->start();
376 lock_window("ChannelEditWindow::scan_confirm");
379 void ChannelEditWindow::scan()
381 thread->new_channels->clear();
384 if(!thread->scan_thread) thread->scan_thread = new ScanThread(thread);
385 thread->scan_thread->start();
389 void ChannelEditWindow::sort()
395 for(int i = 0; i < thread->new_channels->size() - 1; i++)
397 Channel *channel1 = thread->new_channels->get(i);
398 Channel *channel2 = thread->new_channels->get(i + 1);
400 for(int j = 0; j < strlen(channel1->title); j++)
401 if(!isdigit(channel1->title[j])) is_num = 0;
402 for(int j = 0; j < strlen(channel2->title); j++)
403 if(!isdigit(channel2->title[j])) is_num = 0;
404 if(is_num && atoi(channel1->title) > atoi(channel2->title) ||
405 !is_num && strcasecmp(channel2->title, channel1->title) < 0)
407 thread->new_channels->set(i, channel2);
408 thread->new_channels->set(i + 1, channel1);
417 int ChannelEditWindow::delete_channel(int number)
419 delete thread->new_channels->get(number);
420 channel_list.remove_number(number);
421 thread->new_channels->remove_number(number);
425 int ChannelEditWindow::delete_channel(Channel *channel)
428 for(i = 0; i < thread->new_channels->size(); i++)
430 if(thread->new_channels->get(i) == channel)
435 if(i < thread->new_channels->size()) delete_channel(i);
439 int ChannelEditWindow::move_channel_up()
441 if(list_box->get_selection_number(0, 0) > -1)
443 int number2 = list_box->get_selection_number(0, 0);
444 int number1 = number2 - 1;
446 BC_ListBoxItem *temp_text;
448 if(number1 < 0) number1 = thread->new_channels->size() - 1;
450 temp = thread->new_channels->get(number1);
451 thread->new_channels->set(number1, thread->new_channels->get(number2));
452 thread->new_channels->set(number2, temp);
454 temp_text = channel_list.values[number1];
455 channel_list.values[number1] = channel_list.values[number2];
456 channel_list.values[number2] = temp_text;
457 list_box->update(&channel_list,
461 list_box->get_xposition(),
462 list_box->get_yposition(),
469 int ChannelEditWindow::move_channel_down()
471 if(list_box->get_selection_number(0, 0) > -1)
473 int number2 = list_box->get_selection_number(0, 0);
474 int number1 = number2 + 1;
476 BC_ListBoxItem *temp_text;
478 if(number1 > thread->new_channels->size() - 1) number1 = 0;
480 temp = thread->new_channels->get(number1);
481 thread->new_channels->set(number1, thread->new_channels->get(number2));
482 thread->new_channels->set(number2, temp);
483 temp_text = channel_list.values[number1];
484 channel_list.values[number1] = channel_list.values[number2];
485 channel_list.values[number2] = temp_text;
486 list_box->update(&channel_list,
490 list_box->get_xposition(),
491 list_box->get_yposition(),
498 int ChannelEditWindow::change_channel_from_list(int channel_number)
501 if(channel_number > -1 && channel_number < thread->new_channels->size())
503 thread->current_channel = channel_number;
504 channel_picker->set_channel(thread->new_channels->get(channel_number));
508 ChannelEditSelect::ChannelEditSelect(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
509 : BC_GenericButton(x, y, _("Select"))
511 this->window = window;
513 ChannelEditSelect::~ChannelEditSelect()
516 int ChannelEditSelect::handle_event()
518 window->change_channel_from_list(
519 window->list_box->get_selection_number(0, 0));
522 ChannelEditAdd::ChannelEditAdd(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
523 : BC_GenericButton(x, y, _("Add..."))
525 this->window = window;
527 ChannelEditAdd::~ChannelEditAdd()
530 int ChannelEditAdd::handle_event()
532 window->add_channel();
535 ChannelEditList::ChannelEditList(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
539 window->get_h() - BC_OKButton::calculate_h() - y - 10,
541 &(window->channel_list))
543 this->window = window;
545 ChannelEditList::~ChannelEditList()
548 int ChannelEditList::handle_event()
550 window->edit_channel();
553 ChannelEditMoveUp::ChannelEditMoveUp(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
554 : BC_GenericButton(x, y, _("Move up"))
556 this->window = window;
558 ChannelEditMoveUp::~ChannelEditMoveUp()
561 int ChannelEditMoveUp::handle_event()
563 lock_window("ChannelEditMoveUp::handle_event");
564 window->move_channel_up();
568 ChannelEditMoveDown::ChannelEditMoveDown(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
569 : BC_GenericButton(x, y, _("Move down"))
571 this->window = window;
573 ChannelEditMoveDown::~ChannelEditMoveDown()
576 int ChannelEditMoveDown::handle_event()
578 lock_window("ChannelEditMoveDown::handle_event");
579 window->move_channel_down();
583 ChannelEditSort::ChannelEditSort(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
584 : BC_GenericButton(x, y, _("Sort"))
586 this->window = window;
588 int ChannelEditSort::handle_event()
590 lock_window("ChannelEditSort::handle_event");
595 ChannelEditScan::ChannelEditScan(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
596 : BC_GenericButton(x, y, _("Scan"))
598 this->window = window;
600 int ChannelEditScan::handle_event()
602 window->scan_confirm();
605 ChannelEditDel::ChannelEditDel(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
606 : BC_GenericButton(x, y, _("Delete"))
608 this->window = window;
610 ChannelEditDel::~ChannelEditDel()
613 int ChannelEditDel::handle_event()
615 if(window->list_box->get_selection_number(0, 0) > -1) window->delete_channel(window->list_box->get_selection_number(0, 0));
618 ChannelEdit::ChannelEdit(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
619 : BC_GenericButton(x, y, _("Edit..."))
621 this->window = window;
623 ChannelEdit::~ChannelEdit()
626 int ChannelEdit::handle_event()
628 window->edit_channel();
631 ChannelEditPicture::ChannelEditPicture(MWindow *mwindow, ChannelEditWindow *window, int x, int y)
632 : BC_GenericButton(x, y, _("Picture..."))
634 this->window = window;
636 ChannelEditPicture::~ChannelEditPicture()
639 int ChannelEditPicture::handle_event()
641 window->edit_picture();
655 // ========================= confirm overwrite by channel scannin
658 ConfirmScan::ConfirmScan(ChannelEditWindow *gui, int x, int y)
659 : BC_Window(PROGRAM_NAME ": Scan confirm",
663 BC_OKButton::calculate_h() + 130,
673 void ConfirmScan::create_objects()
678 add_subwindow(title = new BC_Title(x, y, _("Set parameters for channel scanning.")));
679 y += title->get_h() + 10;
682 add_subwindow(title = new BC_Title(x, y, _("Frequency table:")));
684 y += BC_PopupMenu::calculate_h();
685 add_subwindow(title = new BC_Title(x, y, _("Norm:")));
686 x2 = MAX(x2, title->get_w());
687 y += BC_PopupMenu::calculate_h();
688 add_subwindow(title = new BC_Title(x, y, _("Input:")));
689 x2 = MAX(x2, title->get_w());
690 y += BC_PopupMenu::calculate_h();
695 ChannelEditEditFreqtable *table;
696 add_subwindow(table = new ChannelEditEditFreqtable(x,
701 y += table->get_h() + 10;
703 ChannelEditEditNorm *norm;
704 add_subwindow(norm = new ChannelEditEditNorm(x,
709 y += norm->get_h() + 10;
711 ChannelEditEditInput *input;
712 add_subwindow(input = new ChannelEditEditInput(x,
719 add_subwindow(new BC_OKButton(this));
720 add_subwindow(new BC_CancelButton(this));
730 ConfirmScanThread::ConfirmScanThread(ChannelEditWindow *gui)
736 void ConfirmScanThread::handle_done_event(int result)
738 gui->thread->scan_params.save_defaults(gui->thread->mwindow->defaults);
741 get_gui()->hide_window();
742 gui->lock_window("ConfirmScanThread::handle_done_event");
744 gui->unlock_window();
748 BC_Window* ConfirmScanThread::new_gui()
750 int x = gui->get_abs_cursor_x(1);
751 int y = gui->get_abs_cursor_y(1);
752 ConfirmScan *result = new ConfirmScan(gui, x, y);
753 result->create_objects();
762 ScanThread::ScanThread(ChannelEditThread *edit)
770 ScanThread::~ScanThread()
779 void ScanThread::start()
781 // Cancel previous job
788 progress = edit->mwindow->mainprogress->start_progress("Scanning",
789 chanlists[edit->scan_params.freqtable].count,
794 void ScanThread::run()
797 i < chanlists[edit->scan_params.freqtable].count &&
799 !progress->is_cancelled();
802 edit->scan_params.entry = i;
803 char string[BCTEXTLEN];
804 sprintf(edit->scan_params.title,
806 chanlists[edit->scan_params.freqtable].list[i].name);
809 edit->scan_params.title);
810 progress->update_title(string);
812 edit->channel_picker->set_channel(&edit->scan_params);
817 int got_signal = edit->channel_picker->has_signal();
820 Channel *new_channel = new Channel;
821 new_channel->copy_usage(&edit->scan_params);
822 new_channel->copy_settings(&edit->scan_params);
823 edit->window->lock_window("ScanThread::run");
824 edit->new_channels->append(new_channel);
825 edit->window->update_list();
826 edit->window->unlock_window();
839 // ================================= Edit a single channel
843 ChannelEditEditThread::ChannelEditEditThread(ChannelEditWindow *window,
844 ChannelPicker *channel_picker,
848 this->window = window;
849 this->channel_picker = channel_picker;
850 this->record = record;
854 completion = new Condition(1, "ChannelEditEditThread::completion");
857 ChannelEditEditThread::~ChannelEditEditThread()
862 int ChannelEditEditThread::close_threads()
866 edit_window->set_done(1);
867 completion->lock("ChannelEditEditThread::close_threads");
868 completion->unlock();
872 int ChannelEditEditThread::edit_channel(Channel *channel, int editing)
876 edit_window->lock_window("ChannelEditEditThread::edit_channel");
877 edit_window->raise_window(1);
878 edit_window->unlock_window();
883 // Copy the channel to edit into a temporary
884 completion->lock("ChannelEditEditThread::edit_channel");
885 this->editing = editing;
886 this->output_channel = channel;
887 new_channel.copy_settings(output_channel);
888 new_channel.copy_usage(output_channel);
890 if(editing && new_channel.title[0])
899 void ChannelEditEditThread::set_device()
901 channel_picker->set_channel(&new_channel);
904 int ChannelEditEditThread::change_source(char *source_name)
907 for(i = 0; i < chanlists[new_channel.freqtable].count; i++)
909 if(!strcasecmp(chanlists[new_channel.freqtable].list[i].name, source_name))
911 new_channel.entry = i;
912 i = chanlists[new_channel.freqtable].count;
918 strcpy(new_channel.title, source_name);
919 if(edit_window->title_text)
921 edit_window->title_text->update(source_name);
926 int ChannelEditEditThread::source_up()
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 int ChannelEditEditThread::source_down()
937 if(new_channel.entry < 0) new_channel.entry = chanlists[new_channel.freqtable].count - 1;
938 source_text->update(chanlists[new_channel.freqtable].list[new_channel.entry].name);
942 int ChannelEditEditThread::set_input(int value)
944 new_channel.input = value;
948 int ChannelEditEditThread::set_norm(int value)
950 new_channel.norm = value;
954 int ChannelEditEditThread::set_freqtable(int value)
956 new_channel.freqtable = value;
957 if(new_channel.entry > chanlists[new_channel.freqtable].count - 1) new_channel.entry = 0;
958 source_text->update(chanlists[new_channel.freqtable].list[new_channel.entry].name);
962 void ChannelEditEditThread::run()
964 ChannelEditEditWindow edit_window(this, window, channel_picker);
965 edit_window.create_objects(&new_channel);
966 this->edit_window = &edit_window;
967 int result = edit_window.run_window();
968 this->edit_window = 0;
970 // Done editing channel. Keep channel.
973 output_channel->copy_settings(&new_channel);
974 window->lock_window();
975 window->update_list(output_channel);
976 window->unlock_window();
983 window->lock_window();
984 window->delete_channel(output_channel);
985 window->unlock_window();
989 completion->unlock();
993 ChannelEditEditWindow::ChannelEditEditWindow(ChannelEditEditThread *thread,
994 ChannelEditWindow *window,
995 ChannelPicker *channel_picker)
996 : BC_Window(PROGRAM_NAME ": Edit Channel",
997 channel_picker->mwindow->gui->get_abs_cursor_x(1),
998 channel_picker->mwindow->gui->get_abs_cursor_y(1),
1007 this->channel_picker = channel_picker;
1008 this->window = window;
1009 this->thread = thread;
1011 ChannelEditEditWindow::~ChannelEditEditWindow()
1014 int ChannelEditEditWindow::create_objects(Channel *channel)
1016 this->new_channel = channel;
1017 Channel *channel_usage = channel_picker->get_channel_usage();
1021 if(!channel_usage ||
1022 (!channel_usage->use_frequency &&
1023 !channel_usage->use_fine &&
1024 !channel_usage->use_norm &&
1025 !channel_usage->use_input))
1027 add_subwindow(new BC_Title(x, y, "Device has no input selection."));
1032 add_subwindow(new BC_Title(x, y, _("Title:")));
1033 add_subwindow(title_text = new ChannelEditEditTitle(x, y + 20, thread));
1037 if(channel_usage->use_frequency)
1039 add_subwindow(new BC_Title(x, y, _("Channel:")));
1041 add_subwindow(thread->source_text = new ChannelEditEditSource(x, y, thread));
1042 add_subwindow(new ChannelEditEditSourceTumbler(x + 160, y, thread));
1045 add_subwindow(new BC_Title(x, y, _("Frequency table:")));
1046 ChannelEditEditFreqtable *table;
1047 add_subwindow(table = new ChannelEditEditFreqtable(x + 130,
1055 if(channel_usage->use_fine)
1057 add_subwindow(new BC_Title(x, y, _("Fine:")));
1058 add_subwindow(new ChannelEditEditFine(x + 130, y, thread));
1062 if(channel_usage->use_norm)
1064 add_subwindow(new BC_Title(x, y, _("Norm:")));
1065 ChannelEditEditNorm *norm;
1066 add_subwindow(norm = new ChannelEditEditNorm(x + 130,
1074 if(channel_usage->use_input)
1076 add_subwindow(new BC_Title(x, y, _("Input:")));
1077 ChannelEditEditInput *input;
1078 add_subwindow(input = new ChannelEditEditInput(x + 130,
1086 add_subwindow(new BC_OKButton(this));
1088 add_subwindow(new BC_CancelButton(this));
1093 ChannelEditEditTitle::ChannelEditEditTitle(int x,
1095 ChannelEditEditThread *thread)
1096 : BC_TextBox(x, y, 150, 1, thread->new_channel.title)
1098 this->thread = thread;
1100 ChannelEditEditTitle::~ChannelEditEditTitle()
1103 int ChannelEditEditTitle::handle_event()
1105 if(strlen(get_text()) < 1024)
1107 strcpy(thread->new_channel.title, get_text());
1110 thread->user_title = 1;
1112 thread->user_title = 0;
1117 ChannelEditEditSource::ChannelEditEditSource(int x, int y, ChannelEditEditThread *thread)
1118 : BC_TextBox(x, y, 150, 1, chanlists[thread->new_channel.freqtable].list[thread->new_channel.entry].name)
1120 this->thread = thread;
1123 ChannelEditEditSource::~ChannelEditEditSource()
1126 int ChannelEditEditSource::handle_event()
1128 thread->change_source(get_text());
1132 ChannelEditEditSourceTumbler::ChannelEditEditSourceTumbler(int x, int y, ChannelEditEditThread *thread)
1135 this->thread = thread;
1137 ChannelEditEditSourceTumbler::~ChannelEditEditSourceTumbler()
1140 int ChannelEditEditSourceTumbler::handle_up_event()
1142 thread->source_up();
1144 int ChannelEditEditSourceTumbler::handle_down_event()
1146 thread->source_down();
1149 ChannelEditEditInput::ChannelEditEditInput(int x,
1151 ChannelEditEditThread *thread,
1152 ChannelEditThread *edit)
1156 edit->value_to_input(thread ? thread->new_channel.input : edit->scan_params.input))
1158 this->thread = thread;
1161 ChannelEditEditInput::~ChannelEditEditInput()
1164 int ChannelEditEditInput::add_items()
1166 ArrayList<Channel*> *inputs;
1167 inputs = edit->channel_picker->get_video_inputs();
1170 for(int i = 0; i < inputs->total; i++)
1172 add_item(new ChannelEditEditInputItem(thread,
1174 inputs->values[i]->device_name,
1178 int ChannelEditEditInput::handle_event()
1183 ChannelEditEditInputItem::ChannelEditEditInputItem(ChannelEditEditThread *thread,
1184 ChannelEditThread *edit,
1189 this->thread = thread;
1191 this->value = value;
1193 ChannelEditEditInputItem::~ChannelEditEditInputItem()
1196 int ChannelEditEditInputItem::handle_event()
1198 get_popup_menu()->set_text(get_text());
1199 if(thread && !thread->user_title)
1201 strcpy(thread->new_channel.title, get_text());
1202 if(thread->edit_window->title_text)
1204 thread->edit_window->title_text->update(get_text());
1208 thread->set_input(value);
1210 edit->scan_params.input = value;
1213 ChannelEditEditNorm::ChannelEditEditNorm(int x,
1215 ChannelEditEditThread *thread,
1216 ChannelEditThread *edit)
1220 edit->value_to_norm(thread ? thread->new_channel.norm : edit->scan_params.norm))
1222 this->thread = thread;
1225 ChannelEditEditNorm::~ChannelEditEditNorm()
1228 int ChannelEditEditNorm::add_items()
1230 add_item(new ChannelEditEditNormItem(thread,
1232 edit->value_to_norm(NTSC), NTSC));
1233 add_item(new ChannelEditEditNormItem(thread,
1235 edit->value_to_norm(PAL), PAL));
1236 add_item(new ChannelEditEditNormItem(thread,
1238 edit->value_to_norm(SECAM), SECAM));
1243 ChannelEditEditNormItem::ChannelEditEditNormItem(ChannelEditEditThread *thread,
1244 ChannelEditThread *edit,
1249 this->value = value;
1251 this->thread = thread;
1253 ChannelEditEditNormItem::~ChannelEditEditNormItem()
1256 int ChannelEditEditNormItem::handle_event()
1258 get_popup_menu()->set_text(get_text());
1260 thread->set_norm(value);
1262 edit->scan_params.norm = value;
1266 ChannelEditEditFreqtable::ChannelEditEditFreqtable(int x,
1268 ChannelEditEditThread *thread,
1269 ChannelEditThread *edit)
1273 edit->value_to_freqtable(thread ? thread->new_channel.freqtable : edit->scan_params.freqtable))
1275 this->thread = thread;
1278 ChannelEditEditFreqtable::~ChannelEditEditFreqtable()
1281 int ChannelEditEditFreqtable::add_items()
1283 add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(NTSC_BCAST), NTSC_BCAST));
1284 add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(NTSC_CABLE), NTSC_CABLE));
1285 add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(NTSC_HRC), NTSC_HRC));
1286 add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(NTSC_BCAST_JP), NTSC_BCAST_JP));
1287 add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(NTSC_CABLE_JP), NTSC_CABLE_JP));
1288 add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(PAL_AUSTRALIA), PAL_AUSTRALIA));
1289 add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(PAL_EUROPE), PAL_EUROPE));
1290 add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(PAL_E_EUROPE), PAL_E_EUROPE));
1291 add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(PAL_ITALY), PAL_ITALY));
1292 add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(PAL_IRELAND), PAL_IRELAND));
1293 add_item(new ChannelEditEditFreqItem(thread, edit, edit->value_to_freqtable(PAL_NEWZEALAND), PAL_NEWZEALAND));
1297 ChannelEditEditFreqItem::ChannelEditEditFreqItem(ChannelEditEditThread *thread,
1298 ChannelEditThread *edit,
1299 char *text, int value)
1302 this->value = value;
1304 this->thread = thread;
1306 ChannelEditEditFreqItem::~ChannelEditEditFreqItem()
1309 int ChannelEditEditFreqItem::handle_event()
1311 get_popup_menu()->set_text(get_text());
1313 thread->set_freqtable(value);
1315 edit->scan_params.freqtable = value;
1320 ChannelEditEditFine::ChannelEditEditFine(int x,
1322 ChannelEditEditThread *thread)
1330 thread->new_channel.fine_tune)
1332 this->thread = thread;
1334 ChannelEditEditFine::~ChannelEditEditFine()
1337 int ChannelEditEditFine::handle_event()
1339 thread->new_channel.fine_tune = get_value();
1340 thread->set_device();
1344 // ========================== picture quality
1346 ChannelEditPictureThread::ChannelEditPictureThread(ChannelPicker *channel_picker, ChannelEditWindow *window)
1349 this->channel_picker = channel_picker;
1350 this->window = window;
1353 completion = new Condition(1, "ChannelEditPictureThread::completion");
1355 ChannelEditPictureThread::~ChannelEditPictureThread()
1360 int ChannelEditPictureThread::edit_picture()
1364 edit_window->lock_window("ChannelEditPictureThread::edit_picture");
1365 edit_window->raise_window(1);
1366 edit_window->unlock_window();
1370 completion->lock("ChannelEditPictureThread::edit_picture");
1375 void ChannelEditPictureThread::run()
1377 ChannelEditPictureWindow edit_window(this,
1379 edit_window.create_objects();
1380 this->edit_window = &edit_window;
1381 int result = edit_window.run_window();
1382 this->edit_window = 0;
1383 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->mwindow->gui->get_abs_cursor_x(1) - 200,
1402 channel_picker->mwindow->gui->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();
1419 int result = 20 + BC_OKButton::calculate_h();
1421 if(picture_usage->use_brightness)
1423 if(picture_usage->use_contrast)
1425 if(picture_usage->use_color)
1427 if(picture_usage->use_hue)
1429 if(picture_usage->use_whiteness)
1431 result += channel_picker->get_controls() * pad;
1435 int ChannelEditPictureWindow::create_objects()
1438 int x1 = 110, x2 = 145;
1439 int pad = BC_Pot::calculate_h();
1440 #define SWAP_X x1 ^= x2; x2 ^= x1; x1 ^= x2;
1442 PictureConfig *picture_usage = channel_picker->get_picture_usage();
1444 if(!picture_usage ||
1445 (!picture_usage->use_brightness &&
1446 !picture_usage->use_contrast &&
1447 !picture_usage->use_color &&
1448 !picture_usage->use_hue &&
1449 !picture_usage->use_whiteness &&
1450 !channel_picker->get_controls()))
1452 add_subwindow(new BC_Title(x, y, "Device has no picture controls."));
1456 if(picture_usage->use_brightness)
1458 add_subwindow(new BC_Title(x, y + 10, _("Brightness:")));
1459 add_subwindow(new ChannelEditBright(x1, y, channel_picker, channel_picker->get_brightness()));
1465 if(picture_usage->use_contrast)
1467 add_subwindow(new BC_Title(x, y + 10, _("Contrast:")));
1468 add_subwindow(new ChannelEditContrast(x1, y, channel_picker, channel_picker->get_contrast()));
1473 if(picture_usage->use_color)
1475 add_subwindow(new BC_Title(x, y + 10, _("Color:")));
1476 add_subwindow(new ChannelEditColor(x1, y, channel_picker, channel_picker->get_color()));
1481 if(picture_usage->use_hue)
1483 add_subwindow(new BC_Title(x, y + 10, _("Hue:")));
1484 add_subwindow(new ChannelEditHue(x1, y, channel_picker, channel_picker->get_hue()));
1489 if(picture_usage->use_whiteness)
1491 add_subwindow(new BC_Title(x, y + 10, _("Whiteness:")));
1492 add_subwindow(new ChannelEditWhiteness(x1, y, channel_picker, channel_picker->get_whiteness()));
1497 for(int i = 0; i < channel_picker->get_controls(); i++)
1499 add_subwindow(new BC_Title(x,
1501 _(channel_picker->get_control(i)->name)));
1502 add_subwindow(new ChannelEditCommon(x1,
1505 channel_picker->get_control(i)));
1512 add_subwindow(new BC_OKButton(this));
1518 ChannelEditBright::ChannelEditBright(int x, int y, ChannelPicker *channel_picker, int value)
1525 this->channel_picker = channel_picker;
1527 ChannelEditBright::~ChannelEditBright() {}
1528 int ChannelEditBright::handle_event()
1532 int ChannelEditBright::button_release_event()
1534 if(BC_Pot::button_release_event())
1536 channel_picker->set_brightness(get_value());
1542 ChannelEditContrast::ChannelEditContrast(int x, int y, ChannelPicker *channel_picker, int value)
1549 this->channel_picker = channel_picker;
1551 ChannelEditContrast::~ChannelEditContrast() {}
1552 int ChannelEditContrast::handle_event()
1556 int ChannelEditContrast::button_release_event()
1558 if(BC_Pot::button_release_event())
1560 channel_picker->set_contrast(get_value());
1567 ChannelEditColor::ChannelEditColor(int x, int y, ChannelPicker *channel_picker, int value)
1574 this->channel_picker = channel_picker;
1576 ChannelEditColor::~ChannelEditColor() {}
1577 int ChannelEditColor::handle_event()
1581 int ChannelEditColor::button_release_event()
1583 if(BC_Pot::button_release_event())
1585 channel_picker->set_color(get_value());
1591 ChannelEditHue::ChannelEditHue(int x, int y, ChannelPicker *channel_picker, int value)
1598 this->channel_picker = channel_picker;
1600 ChannelEditHue::~ChannelEditHue() {}
1601 int ChannelEditHue::handle_event()
1605 int ChannelEditHue::button_release_event()
1607 if(BC_Pot::button_release_event())
1609 channel_picker->set_hue(get_value());
1615 ChannelEditWhiteness::ChannelEditWhiteness(int x, int y, ChannelPicker *channel_picker, int value)
1622 this->channel_picker = channel_picker;
1624 ChannelEditWhiteness::~ChannelEditWhiteness()
1627 int ChannelEditWhiteness::handle_event()
1631 int ChannelEditWhiteness::button_release_event()
1633 if(BC_Pot::button_release_event())
1635 channel_picker->set_whiteness(get_value());
1643 ChannelEditCommon::ChannelEditCommon(int x,
1645 ChannelPicker *channel_picker,
1653 this->channel_picker = channel_picker;
1654 this->device_id = item->device_id;
1657 ChannelEditCommon::~ChannelEditCommon()
1661 int ChannelEditCommon::handle_event()
1666 int ChannelEditCommon::button_release_event()
1668 if(BC_Pot::button_release_event())
1670 channel_picker->set_picture(device_id, get_value());