3 * Copyright (C) 2016-2020 William Morrow
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published
7 * by the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
27 #include "channel.inc"
28 #include "channeldb.h"
29 #include "channelinfo.inc"
30 #include "devicedvbinput.h"
32 #include "mwindow.inc"
34 #include "recordbatches.h"
35 #include "signalstatus.h"
36 #include "videodevice.inc"
37 #include "vdevicempeg.inc"
39 #define LTBLACK 0x001c1c1c
42 class ChanSearch : public Thread
53 ChanSearch(ChannelInfo *iwindow);
57 class ChanSearchGUI : public BC_Window
63 ChanSearchText *search_text;
64 ChanSearchTitleText *title_text;
65 ChanSearchInfoText *info_text;
66 ChanSearchMatchCase *match_case;
67 ChanSearchStart *search_start;
68 ChanSearchCancel *cancel;
69 ChanSearchList *search_list;
73 int title_text_enable;
75 int match_case_enable;
76 ChannelEvent *highlighted_event;
77 int search_x, search_y, text_x, text_y;
78 int cancel_x, cancel_y, cancel_w, cancel_h;
79 int list_x, list_y, list_w, list_h;
80 int results_x, results_y;
81 int sort_column, sort_order;
83 const char *search_column_titles[3];
84 int search_column_widths[3];
85 int search_columns[3];
86 ArrayList<BC_ListBoxItem*> search_items[3];
87 ArrayList<ChannelEvent*> search_results;
89 void create_objects();
91 int resize_event(int x, int y);
93 int search(const char *);
95 static int cmpr_text_dn(const void *a, const void *b);
96 static int cmpr_Text_dn(const void *a, const void *b);
97 static int cmpr_text_up(const void *a, const void *b);
98 static int cmpr_Text_up(const void *a, const void *b);
99 static int cmpr_time_dn(const void *a, const void *b);
100 static int cmpr_time_up(const void *a, const void *b);
101 static int cmpr_title_dn(const void *a, const void *b);
102 static int cmpr_Title_dn(const void *a, const void *b);
103 static int cmpr_title_up(const void *a, const void *b);
104 static int cmpr_Title_up(const void *a, const void *b);
105 void sort_events(int column, int order);
106 void move_column(int src, int dst);
108 ChanSearchGUI(ChanSearch *cswindow);
112 class ChanSearchTitleText : public BC_CheckBox
118 void update(int v) { set_value(gui->title_text_enable = v); }
120 ChanSearchTitleText(ChanSearchGUI *gui, int x, int y);
121 ~ChanSearchTitleText();
124 class ChanSearchInfoText : public BC_CheckBox
130 void update(int v) { set_value(gui->info_text_enable = v); }
132 ChanSearchInfoText(ChanSearchGUI *gui, int x, int y);
133 ~ChanSearchInfoText();
136 class ChanSearchMatchCase : public BC_CheckBox
143 ChanSearchMatchCase(ChanSearchGUI *gui, int x, int y);
144 ~ChanSearchMatchCase();
147 class ChanSearchText : public BC_TextBox
153 int keypress_event();
155 ChanSearchText(ChanSearchGUI *gui, int x, int y, int w);
159 class ChanSearchStart : public BC_GenericButton
166 ChanSearchStart(ChanSearchGUI *gui, int x, int y);
170 class ChanSearchCancel : public BC_CancelButton
177 ChanSearchCancel(ChanSearchGUI *gui, int x, int y);
181 class ChanSearchList : public BC_ListBox
187 int sort_order_event();
188 int move_column_event();
190 ChanSearchList(ChanSearchGUI *gui, int x, int y, int w, int h);
195 class ChannelProgress : public Thread, public BC_SubWindow
201 double length, value;
204 void create_objects();
209 void set_value(int v) { value = v; }
211 ChannelProgress(ChannelInfoGUI *gui, int x, int y, int w, int h, int len);
217 class ChannelPanel : public BC_SubWindow
222 ChannelData *channel_data;
223 ChannelFrame *channel_frame;
224 ChannelScroll *channel_scroll;
225 TimeLineScroll *time_line_scroll;
226 ArrayList<TimeLineItem*> time_line_items;
227 ArrayList<ChannelDataItem*> channel_data_items;
228 ArrayList<ChannelEventLine *> channel_line_items;
229 ArrayList<ChannelEvent*> channel_event_items;
231 int x0, y0, x1, y1, t0, t1;
233 int x_moved, y_moved;
234 int iwindow_w, iwindow_h;
235 int path_w, path_h, hhr_w, x_now;
236 int frame_x, frame_y;
237 int frame_w, frame_h;
238 int x_scroll, y_scroll;
243 void create_objects();
244 ChannelEventLine *NewChannelLine(int y, int h, int color);
245 ChannelEventLine *NewChannelLine(int y) {
246 return NewChannelLine(y, path_h, LTBLACK);
248 int separator(int y) {
249 NewChannelLine(y+path_h/8, path_h/4, BLACK);
252 void resize(int w, int h);
253 void bounding_box(int ix0, int iy0, int ix1, int iy1);
254 void set_x_scroll(int v);
255 void set_y_scroll(int v);
257 void get_xtime(int x, char *text);
258 void time_line_update(int ix0, int ix1);
259 int button_press_event();
261 ChannelPanel(ChannelInfoGUI *gui, int x, int y, int w, int h);
265 class TimeLineItem : public BC_Title
271 TimeLineItem(ChannelPanel *panel, int x, int y, char *text);
275 class TimeLine : public BC_SubWindow
279 int resize_event(int w, int h);
281 TimeLine(ChannelPanel *panel);
285 class ChannelDataItem : public BC_Title
290 const char *tip_info;
292 int repeat_event(int64_t duration);
293 void set_tooltip(const char *tip);
295 ChannelDataItem(ChannelPanel *panel, int x, int y, int w,
296 int color, const char *text);
300 class ChannelData : public BC_SubWindow
305 int resize_event(int w, int h);
307 ChannelData(ChannelPanel *panel, int x, int y, int w, int h);
311 class ChannelScroll : public BC_ScrollBar
318 ChannelScroll(ChannelPanel *panel, int x, int y, int h);
322 class TimeLineScroll : public BC_ScrollBar
329 TimeLineScroll(ChannelPanel *panel, int x, int y, int w);
335 class ChannelEvent : public BC_GenericButton
338 ChannelEventLine *channel_line;
339 time_t start_time, end_time;
342 const char *tip_info;
345 void set_tooltip(const char *tip);
347 ChannelEvent(ChannelEventLine *channel_line, Channel *channel,
348 time_t start_time, time_t end_time, int x, int y, int w,
353 class ChannelEventLine : public BC_SubWindow
359 void resize(int w, int h);
361 ChannelEventLine(ChannelPanel *panel, int x, int y, int w, int h, int color);
365 class ChannelFrame : public BC_SubWindow
370 void resize(int w, int h);
372 ChannelFrame(ChannelPanel *panel);
378 class ChannelInfoGUI : public BC_Window
381 ChannelInfo *iwindow;
382 ChanSearch *channel_search;
384 ChannelProgress *progress;
385 ChannelStatus *channel_status;
386 ChannelInfoGUIBatches *batch_bay;
387 ChannelDir *channel_dir;
388 ChannelPath *channel_path;
389 ChannelStart *channel_start;
390 ChannelDuration *channel_duration;
391 ChannelSource *channel_source;
392 ChannelClearBatch *channel_clear_batch;
393 ChannelNewBatch *channel_new_batch;
394 ChannelDeleteBatch *channel_delete_batch;
395 TimeEntryTumbler *early_time, *late_time;
396 BC_Title *directory_title;
397 BC_Title *path_title;
398 BC_Title *start_title;
399 BC_Title *duration_title;
400 BC_Title *source_title;
402 BC_CancelButton *cancel;
403 ChannelInfoCron *channel_cron;
404 ChannelInfoPowerOff *channel_poweroff;
405 ChannelInfoFind *channel_find;
406 int x0, y0, title_w, data_w, pad;
407 int path_w, path_h, status_w;
408 int panel_w, panel_h, max_bay_w;
409 int bay_x, bay_y, bay_w, bay_h;
410 const char *cron_caption, *power_caption;
411 int cron_x, cron_y, cron_w, cron_h;
412 int power_x, power_y, power_w, power_h;
413 int find_x, find_y, find_h;
414 int ok_x, ok_y, ok_w, ok_h;
415 int cancel_x, cancel_y, cancel_w, cancel_h;
417 void create_objects();
419 int translation_event();
420 int resize_event(int w, int h);
422 void update_channel_tools();
423 void incr_event(int start_time_incr, int duration_incr);
424 void update_progress(int n) { progress->set_value(n); }
426 ChannelInfoGUI(ChannelInfo *iwindow, int x, int y, int w, int h);
430 class ChannelInfoOK : public BC_OKButton
435 int button_press_event();
436 int keypress_event();
438 ChannelInfoOK(ChannelInfoGUI *gui, int x, int y);
442 class ChannelInfoCancel : public BC_CancelButton
447 int button_press_event();
449 ChannelInfoCancel(ChannelInfoGUI *gui, int x, int y);
450 ~ChannelInfoCancel();
453 class ChannelInfoCron : public BC_CheckBox
459 ChannelInfoCron(ChannelInfoGUI *gui, int x, int y, int *value);
463 class ChannelInfoPowerOff : public BC_CheckBox
470 ChannelInfoPowerOff(ChannelInfoGUI *gui, int x, int y, int *value);
471 ~ChannelInfoPowerOff();
474 class ChannelInfoFind : public BC_GenericButton
480 ChannelInfoFind(ChannelInfoGUI *gui, int x, int y);
485 class ChannelInfoGUIBatches : public RecordBatchesGUI
491 int selection_changed();
493 ChannelInfoGUIBatches(ChannelInfoGUI *gui,
494 int x, int y, int w, int h);
495 ~ChannelInfoGUIBatches();
498 class ChannelDir : public RecordBatchesGUI::Dir
503 ChannelDir(ChannelInfoGUI *gui, const char *dir, int x, int y);
506 class ChannelPath : public RecordBatchesGUI::Path
511 ChannelPath(ChannelInfoGUI *gui, int x, int y);
514 class ChannelStart : public RecordBatchesGUI::StartTime
519 ChannelStart(ChannelInfoGUI *gui, int x, int y);
522 class ChannelDuration : public RecordBatchesGUI::Duration
527 ChannelDuration(ChannelInfoGUI *gui, int x, int y, int w);
530 class ChannelEarlyTime : public TimeEntryTumbler
535 int handle_up_event();
536 int handle_down_event();
538 ChannelEarlyTime(ChannelInfoGUI *gui, int x, int y,
539 double *output_time);
542 class ChannelLateTime : public TimeEntryTumbler
547 int handle_up_event();
548 int handle_down_event();
550 ChannelLateTime(ChannelInfoGUI *gui, int x, int y,
551 double *output_time);
554 class ChannelSource : public RecordBatchesGUI::Source
558 void create_objects();
560 ChannelSource(ChannelInfoGUI *gui, int x, int y);
564 class ChannelNewBatch : public RecordBatchesGUI::NewBatch
569 ChannelNewBatch(ChannelInfoGUI *gui, int x, int y);
573 class ChannelDeleteBatch : public RecordBatchesGUI::DeleteBatch
578 ChannelDeleteBatch(ChannelInfoGUI *gui, int x, int y);
581 class ChannelClearBatch : public RecordBatchesGUI::ClearBatch
586 ChannelClearBatch(ChannelInfoGUI *gui, int x, int y);
591 class ChannelInfo : public Thread
596 VideoDevice *vdevice;
599 Mutex *progress_lock;
600 DeviceDVBInput *dvb_input;
601 RecordBatches record_batches;
603 ChannelThread *thread;
604 ChannelDB *channeldb;
605 Condition *scan_lock;
606 int cron_enable, poweroff_enable;
615 void close_vdevice();
618 int current_batch() { return gui->batch_bay->current_batch(); }
619 int editing_batch() { return gui->batch_bay->editing_batch(); }
620 bool is_active() { return gui != 0; }
622 ChannelInfo(MWindow *mwindow);
626 class ChannelThread : public Thread
629 ChannelInfo *iwindow;
635 int load_ident(int n, int y, char *ident);
636 int load_info(Channel *channel, ChannelEventLine *channel_line);
640 int total_channels() { return iwindow->channeldb->size(); }
641 Channel *get_channel(int ch) { return iwindow->channeldb->get(ch); }
642 int set_channel(Channel *chan);
644 ChannelThread(ChannelInfoGUI *gui);
648 class ChannelScan : public BC_MenuItem
654 ChannelScan(MWindow *mwindow);
658 class ChannelStatus : public SignalStatus
663 ChannelStatus(ChannelInfoGUI *gui, int x, int y) :
664 SignalStatus(gui, x, y) { this->gui = gui; }