2 #include "channeledit.h"
3 #include "channelpicker.h"
4 #include "chantables.h"
8 #include "playbackconfig.h"
9 #include "preferencesthread.h"
11 #include "recordmonitor.h"
13 #include "vdevicebuz.h"
14 #include "vdeviceprefs.h"
17 #define _(String) gettext(String)
18 #define gettext_noop(String) String
19 #define N_(String) gettext_noop (String)
22 PrefsChannelPicker::PrefsChannelPicker(MWindow *mwindow,
24 ArrayList<Channel*> *channeldb,
27 : ChannelPicker(mwindow,
34 // printf("PrefsChannelPicker::PrefsChannelPicker 1\n");
36 VDeviceBUZ::get_inputs(&input_sources);
39 PrefsChannelPicker::~PrefsChannelPicker()
41 input_sources.remove_all_objects();
44 BC_WindowBase* PrefsChannelPicker::get_subwindow()
49 Channel* PrefsChannelPicker::get_current_channel_struct()
51 int number = get_current_channel_number();
53 if(number >= 0 && number < channeldb->total)
55 return channeldb->values[number];
60 int PrefsChannelPicker::get_current_channel_number()
62 return prefs->out_config->buz_out_channel;
65 ArrayList<char*>* PrefsChannelPicker::get_video_inputs()
67 return &input_sources;
70 void PrefsChannelPicker::set_channel(Channel *channel)
73 channel_text->update(channel->title);
76 void PrefsChannelPicker::set_channel_number(int number)
79 CLAMP(number, 0, channeldb->total - 1);
80 //printf("PrefsChannelPicker::set_channel_number %d\n", number);
81 prefs->out_config->buz_out_channel = number;
82 set_channel(get_current_channel_struct());
85 int PrefsChannelPicker::set_brightness(int value)
87 prefs->out_config->brightness = value;
90 int PrefsChannelPicker::set_hue(int value)
92 prefs->out_config->hue = value;
95 int PrefsChannelPicker::set_color(int value)
97 prefs->out_config->color = value;
100 int PrefsChannelPicker::set_contrast(int value)
102 prefs->out_config->contrast = value;
105 int PrefsChannelPicker::set_whiteness(int value)
107 prefs->out_config->whiteness = value;
110 int PrefsChannelPicker::get_brightness()
112 return prefs->out_config->brightness;
115 int PrefsChannelPicker::get_hue()
117 return prefs->out_config->hue;
120 int PrefsChannelPicker::get_color()
122 return prefs->out_config->color;
125 int PrefsChannelPicker::get_contrast()
127 return prefs->out_config->contrast;
130 int PrefsChannelPicker::get_whiteness()
132 return prefs->out_config->whiteness;
144 ChannelPicker::ChannelPicker(MWindow *mwindow,
146 RecordMonitor *record_monitor,
147 ArrayList<Channel*> *channeldb,
151 this->mwindow = mwindow;
152 this->record = record;
153 this->record_monitor = record_monitor;
156 this->channeldb = channeldb;
157 current_channel = new Channel;
159 update_channel_list();
162 ChannelPicker::~ChannelPicker()
165 delete channel_select;
166 delete channel_button;
167 delete current_channel;
168 channel_listitems.remove_all_objects();
171 void ChannelPicker::update_channel_list()
173 //printf("ChannelPicker::update_channel_list 1\n");
174 channel_listitems.remove_all_objects();
175 for(int i = 0; i < channeldb->total; i++)
177 channel_listitems.append(new BC_ListBoxItem(channeldb->values[i]->title));
181 channel_text->update_list(&channel_listitems);
182 //printf("ChannelPicker::update_channel_list 2\n");
192 BC_WindowBase* ChannelPicker::get_subwindow()
194 return record_monitor->window;
197 Channel* ChannelPicker::get_current_channel_struct()
199 //printf("ChannelPicker::get_current_channel_struct 1\n");
200 return record->get_current_channel_struct();
203 int ChannelPicker::get_current_channel_number()
205 return record->get_editing_channel();
208 ArrayList<char*>* ChannelPicker::get_video_inputs()
210 return record->get_video_inputs();
213 void ChannelPicker::set_channel_number(int number)
215 record->set_channel(number);
218 void ChannelPicker::set_channel(Channel *channel)
220 record->set_channel(channel);
223 int ChannelPicker::set_brightness(int value)
225 record->video_brightness = value;
226 record->set_video_picture();
230 int ChannelPicker::set_hue(int value)
232 record->video_hue = value;
233 record->set_video_picture();
237 int ChannelPicker::set_color(int value)
239 record->video_color = value;
240 record->set_video_picture();
244 int ChannelPicker::set_contrast(int value)
246 record->video_contrast = value;
247 record->set_video_picture();
251 int ChannelPicker::set_whiteness(int value)
253 record->video_whiteness = value;
254 record->set_video_picture();
258 int ChannelPicker::get_brightness()
260 return record->video_brightness;
263 int ChannelPicker::get_hue()
265 return record->video_hue;
268 int ChannelPicker::get_color()
270 return record->video_color;
273 int ChannelPicker::get_contrast()
275 return record->video_contrast;
278 int ChannelPicker::get_whiteness()
280 return record->video_whiteness;
289 int ChannelPicker::create_objects()
292 update_channel_list();
293 //printf("ChannelPicker::create_objects 1\n");
294 channel_text = new ChannelText(mwindow, this, x, y);
295 //printf("ChannelPicker::create_objects 1\n");
296 channel_text->create_objects();
297 //printf("ChannelPicker::create_objects 1\n");
298 x += channel_text->get_w();
299 get_subwindow()->add_subwindow(channel_select = new ChannelTumbler(mwindow, this, x, y));
300 //printf("ChannelPicker::create_objects 1\n");
301 x += channel_select->get_w() + 5;
302 get_subwindow()->add_subwindow(channel_button = new ChannelButton(mwindow, this, x, y - 1));
303 //printf("ChannelPicker::create_objects 2\n");
307 int ChannelPicker::reposition()
309 channel_text->reposition_window(channel_text->get_x(),
310 channel_text->get_y());
311 channel_select->reposition_window(channel_select->get_x(),
312 channel_select->get_y());
313 channel_button->reposition_window(channel_button->get_x(),
314 channel_button->get_y());
318 int ChannelPicker::close_threads()
320 channel_button->thread->close_threads();
324 char* ChannelPicker::get_source_name(Channel *channel)
326 if(channel->entry < chanlists[channel->freqtable].count)
327 return chanlists[channel->freqtable].list[channel->entry].name;
329 return chanlists[channel->freqtable].list[0].name;
332 char* ChannelPicker::current_channel_name()
334 if(get_current_channel_struct())
336 return get_current_channel_struct()->title;
342 int ChannelPicker::channel_down()
344 int number = get_current_channel_number() - 1;
345 if(number < 0) number = 0;
346 CLAMP(number, 0, channeldb->total - 1);
347 set_channel_number(number);
351 int ChannelPicker::channel_up()
353 int number = get_current_channel_number() + 1;
354 if(number >= channeldb->total) number = channeldb->total - 1;
355 CLAMP(number, 0, channeldb->total - 1);
356 set_channel_number(number);
362 ChannelButton::ChannelButton(MWindow *mwindow, ChannelPicker *channel_picker, int x, int y)
363 : BC_Button(x, y, mwindow->theme->channel_data)
365 this->channel_picker = channel_picker;
366 this->mwindow = mwindow;
367 thread = new ChannelEditThread(mwindow,
369 channel_picker->channeldb,
370 channel_picker->record);
371 set_tooltip(_("Edit channels"));
374 ChannelButton::~ChannelButton()
379 int ChannelButton::handle_event()
386 ChannelText::ChannelText(MWindow *mwindow,
387 ChannelPicker *channel_picker,
390 : BC_PopupTextBox(channel_picker->get_subwindow(),
391 &channel_picker->channel_listitems,
392 channel_picker->current_channel_name(),
398 this->channel_picker = channel_picker;
399 this->mwindow = mwindow;
402 ChannelText::~ChannelText()
406 int ChannelText::handle_event()
408 channel_picker->set_channel_number(get_number());
415 ChannelList::ChannelList(MWindow *mwindow, ChannelPicker *channel_picker, int x, int y)
420 LISTBOX_TEXT, // Display text list or icons
421 &channel_picker->channel_listitems, // Each column has an ArrayList of BC_ListBoxItems.
422 0, // Titles for columns. Set to 0 for no titles
423 0, // width of each column
425 0, // Pixel of top of window.
426 1) // If this listbox is a popup window
428 this->mwindow = mwindow;
429 this->channel_picker = channel_picker;
432 ChannelList::~ChannelList()
436 int ChannelList::handle_event()
443 ChannelTumbler::ChannelTumbler(MWindow *mwindow,
444 ChannelPicker *channel_picker,
449 this->mwindow = mwindow;
450 this->channel_picker = channel_picker;
452 ChannelTumbler::~ChannelTumbler()
455 int ChannelTumbler::handle_up_event()
457 channel_picker->channel_up();
460 int ChannelTumbler::handle_down_event()
462 channel_picker->channel_down();
465 int ChannelTumbler::keypress_event()
467 if(get_keypress() == PGUP)
473 if(get_keypress() == PGDN)