add more build controls
[goodguy/history.git] / cinelerra-5.1 / cinelerra / channelinfo.h
1 #ifndef CHANNELINFO_H
2 #define CHANNELINFO_H
3
4 #ifdef HAVE_DVB
5
6 #include "channel.inc"
7 #include "channeldb.h"
8 #include "channelinfo.inc"
9 #include "devicedvbinput.h"
10 #include "guicast.h"
11 #include "mwindow.inc"
12 #include "record.inc"
13 #include "recordbatches.h"
14 #include "signalstatus.h"
15 #include "videodevice.inc"
16 #include "vdevicempeg.inc"
17
18 #define LTBLACK 0x001c1c1c
19
20
21 class ChanSearch : public Thread
22 {
23 public:
24         ChannelInfo *iwindow;
25         ChanSearchGUI *gui;
26         Mutex *window_lock;
27
28         void start();
29         void stop();
30         void run();
31
32         ChanSearch(ChannelInfo *iwindow);
33         ~ChanSearch();
34 };
35
36 class ChanSearchGUI : public BC_Window
37 {
38 public:
39         ChanSearch *cswindow;
40         ChannelInfo *iwindow;
41         ChannelPanel *panel;
42         ChanSearchText *search_text;
43         ChanSearchTitleText *title_text;
44         ChanSearchInfoText *info_text;
45         ChanSearchMatchCase *match_case;
46         ChanSearchStart *search_start;
47         ChanSearchCancel *cancel;
48         ChanSearchList *search_list;
49         BC_Title *click_tip;
50         BC_Title *results;
51
52         int title_text_enable;
53         int info_text_enable;
54         int match_case_enable;
55         ChannelEvent *highlighted_event;
56         int search_x, search_y, text_x, text_y;
57         int cancel_x, cancel_y, cancel_w, cancel_h;
58         int list_x, list_y, list_w, list_h;
59         int results_x, results_y;
60         int sort_column, sort_order;
61
62         const char *search_column_titles[3];
63         int search_column_widths[3];
64         int search_columns[3];
65         ArrayList<BC_ListBoxItem*> search_items[3];
66         ArrayList<ChannelEvent*> search_results;
67
68         void create_objects();
69         int close_event();
70         int resize_event(int x, int y);
71         void update();
72         int search(const char *);
73         void search();
74         static int cmpr_text_dn(const void *a, const void *b);
75         static int cmpr_Text_dn(const void *a, const void *b);
76         static int cmpr_text_up(const void *a, const void *b);
77         static int cmpr_Text_up(const void *a, const void *b);
78         static int cmpr_time_dn(const void *a, const void *b);
79         static int cmpr_time_up(const void *a, const void *b);
80         static int cmpr_title_dn(const void *a, const void *b);
81         static int cmpr_Title_dn(const void *a, const void *b);
82         static int cmpr_title_up(const void *a, const void *b);
83         static int cmpr_Title_up(const void *a, const void *b);
84         void sort_events(int column, int order);
85         void move_column(int src, int dst);
86
87         ChanSearchGUI(ChanSearch *cswindow);
88         ~ChanSearchGUI();
89 };
90
91 class ChanSearchTitleText : public BC_CheckBox
92 {
93 public:
94         ChanSearchGUI *gui;
95
96         int handle_event();
97         void update(int v) { set_value(gui->title_text_enable = v); }
98
99         ChanSearchTitleText(ChanSearchGUI *gui, int x, int y);
100         ~ChanSearchTitleText();
101 };
102
103 class ChanSearchInfoText : public BC_CheckBox
104 {
105 public:
106         ChanSearchGUI *gui;
107
108         int handle_event();
109         void update(int v) { set_value(gui->info_text_enable = v); }
110
111         ChanSearchInfoText(ChanSearchGUI *gui, int x, int y);
112         ~ChanSearchInfoText();
113 };
114
115 class ChanSearchMatchCase : public BC_CheckBox
116 {
117 public:
118         ChanSearchGUI *gui;
119
120         int handle_event();
121
122         ChanSearchMatchCase(ChanSearchGUI *gui, int x, int y);
123         ~ChanSearchMatchCase();
124 };
125
126 class ChanSearchText : public BC_TextBox
127 {
128 public:
129         ChanSearchGUI *gui;
130
131         int handle_event();
132         int keypress_event();
133
134         ChanSearchText(ChanSearchGUI *gui, int x, int y, int w);
135         ~ChanSearchText();
136 };
137
138 class ChanSearchStart : public BC_GenericButton
139 {
140 public:
141         ChanSearchGUI *gui;
142
143         int handle_event();
144
145         ChanSearchStart(ChanSearchGUI *gui, int x, int y);
146         ~ChanSearchStart();
147 };
148
149 class ChanSearchCancel : public BC_CancelButton
150 {
151 public:
152         ChanSearchGUI *gui;
153
154         int handle_event();
155
156         ChanSearchCancel(ChanSearchGUI *gui, int x, int y);
157         ~ChanSearchCancel();
158 };
159
160 class ChanSearchList : public BC_ListBox
161 {
162 public:
163         ChanSearchGUI *gui;
164
165         int handle_event();
166         int sort_order_event();
167         int move_column_event();
168
169         ChanSearchList(ChanSearchGUI *gui, int x, int y, int w, int h);
170         ~ChanSearchList();
171 };
172
173
174 class ChannelProgress : public Thread, public BC_SubWindow
175 {
176         ChannelInfoGUI *gui;
177         BC_Title *eta;
178         BC_ProgressBar *bar;
179         Timer *eta_timer;
180         double length, value;
181         int done;
182 public:
183         void create_objects();
184         void run();
185         void start();
186         void stop();
187         int update();
188         void set_value(int v) { value = v; }
189
190         ChannelProgress(ChannelInfoGUI *gui, int x, int y, int w, int h, int len);
191         ~ChannelProgress();
192 };
193
194
195
196 class ChannelPanel : public BC_SubWindow
197 {
198 public:
199         ChannelInfoGUI *gui;
200         TimeLine *time_line;
201         ChannelData *channel_data;
202         ChannelFrame *channel_frame;
203         ChannelScroll *channel_scroll;
204         TimeLineScroll *time_line_scroll;
205         ArrayList<TimeLineItem*> time_line_items;
206         ArrayList<ChannelDataItem*> channel_data_items;
207         ArrayList<ChannelEventLine *> channel_line_items;
208         ArrayList<ChannelEvent*> channel_event_items;
209
210         int x0, y0, x1, y1, t0, t1;
211         int iwd, iht;
212         int x_moved, y_moved;
213         int iwindow_w, iwindow_h;
214         int path_w, path_h, hhr_w, x_now;
215         int frame_x, frame_y;
216         int frame_w, frame_h;
217         int x_scroll, y_scroll;
218         struct timeval tv;
219         struct timezone tz;
220         time_t st_org;
221
222         void create_objects();
223         ChannelEventLine *NewChannelLine(int y, int h, int color);
224         ChannelEventLine *NewChannelLine(int y) {
225                 return NewChannelLine(y, path_h, LTBLACK);
226         }
227         int separator(int y) {
228                 NewChannelLine(y+path_h/8, path_h/4, BLACK);
229                 return path_h/2;
230         }
231         void resize(int w, int h);
232         void bounding_box(int ix0, int iy0, int ix1, int iy1);
233         void set_x_scroll(int v);
234         void set_y_scroll(int v);
235         void reposition();
236         void get_xtime(int x, char *text);
237         void time_line_update(int ix0, int ix1);
238         int button_press_event();
239
240         ChannelPanel(ChannelInfoGUI *gui, int x, int y, int w, int h);
241         ~ChannelPanel();
242 };
243
244 class TimeLineItem : public BC_Title
245 {
246 public:
247         ChannelPanel *panel;
248         int x0, y0;
249
250         TimeLineItem(ChannelPanel *panel, int x, int y, char *text);
251         ~TimeLineItem();
252 };
253
254 class TimeLine : public BC_SubWindow
255 {
256 public:
257         ChannelPanel *panel;
258         int resize_event(int w, int h);
259
260         TimeLine(ChannelPanel *panel);
261         ~TimeLine();
262 };
263
264 class ChannelDataItem : public BC_Title
265 {
266 public:
267         ChannelPanel *panel;
268         int x0, y0;
269         const char *tip_info;
270         int in_window, tooltip_done;
271
272         int cursor_enter_event();
273         int cursor_leave_event();
274         int repeat_event(int64_t duration);
275         void set_tooltip(const char *tip);
276
277         ChannelDataItem(ChannelPanel *panel, int x, int y, int w,
278                 int color, const char *text);
279         ~ChannelDataItem();
280 };
281
282 class ChannelData : public BC_SubWindow
283 {
284 public:
285         ChannelPanel *panel;
286
287         int resize_event(int w, int h);
288
289         ChannelData(ChannelPanel *panel, int x, int y, int w, int h);
290         ~ChannelData();
291 };
292
293 class ChannelScroll : public BC_ScrollBar
294 {
295 public:
296         ChannelPanel *panel;
297
298         int handle_event();
299
300         ChannelScroll(ChannelPanel *panel, int x, int y, int h);
301         ~ChannelScroll();
302 };
303
304 class TimeLineScroll : public BC_ScrollBar
305 {
306 public:
307         ChannelPanel *panel;
308
309         int handle_event();
310
311         TimeLineScroll(ChannelPanel *panel, int x, int y, int w);
312         ~TimeLineScroll();
313 };
314
315
316
317 class ChannelEvent : public BC_GenericButton
318 {
319 public:
320         ChannelEventLine *channel_line;
321         time_t start_time, end_time;
322         Channel *channel;
323         int x0, y0, no;
324         const char *tip_info;
325
326         int handle_event();
327         void set_tooltip(const char *tip);
328
329         ChannelEvent(ChannelEventLine *channel_line, Channel *channel,
330                 time_t start_time, time_t end_time, int x, int y, int w,
331                 const char *text);
332         ~ChannelEvent();
333 };
334
335 class ChannelEventLine : public BC_SubWindow
336 {
337 public:
338         ChannelPanel *panel;
339         int x0, y0;
340
341         void resize(int w, int h);
342
343         ChannelEventLine(ChannelPanel *panel, int x, int y, int w, int h, int color);
344         ~ChannelEventLine();
345 };
346
347 class ChannelFrame : public BC_SubWindow
348 {
349 public:
350         ChannelPanel *panel;
351
352         void resize(int w, int h);
353
354         ChannelFrame(ChannelPanel *panel);
355         ~ChannelFrame();
356 };
357
358
359
360 class ChannelInfoGUI : public BC_Window
361 {
362 public:
363         ChannelInfo *iwindow;
364         ChanSearch *channel_search;
365         ChannelPanel *panel;
366         ChannelProgress *progress;
367         ChannelStatus *channel_status;
368         ChannelInfoGUIBatches *batch_bay;
369         ChannelDir *channel_dir;
370         ChannelPath *channel_path;
371         ChannelStart *channel_start;
372         ChannelDuration *channel_duration;
373         ChannelSource *channel_source;
374         ChannelClearBatch *channel_clear_batch;
375         ChannelNewBatch *channel_new_batch;
376         ChannelDeleteBatch *channel_delete_batch;
377         TimeEntryTumbler *early_time, *late_time;
378         BC_Title *directory_title;
379         BC_Title *path_title;
380         BC_Title *start_title;
381         BC_Title *duration_title;
382         BC_Title *source_title;
383         BC_OKButton *ok;
384         BC_CancelButton *cancel;
385         ChannelInfoCron *channel_cron;
386         ChannelInfoPowerOff *channel_poweroff;
387         ChannelInfoFind *channel_find;
388         int x0, y0, title_w, data_w, pad;
389         int path_w, path_h, status_w;
390         int panel_w, panel_h, max_bay_w;
391         int bay_x, bay_y, bay_w, bay_h;
392         const char *cron_caption, *power_caption;
393         int cron_x, cron_y, cron_w, cron_h;
394         int power_x, power_y, power_w, power_h;
395         int find_x, find_y, find_h;
396         int ok_x, ok_y, ok_w, ok_h;
397         int cancel_x, cancel_y, cancel_w, cancel_h;
398
399         void create_objects();
400         void stop(int v);
401         int translation_event();
402         int resize_event(int w, int h);
403         int close_event();
404         void update_channel_tools();
405         void incr_event(int start_time_incr, int duration_incr);
406         void update_progress(int n) { progress->set_value(n); }
407
408         ChannelInfoGUI(ChannelInfo *iwindow, int x, int y, int w, int h);
409         ~ChannelInfoGUI();
410 };
411
412 class ChannelInfoOK : public BC_OKButton
413 {
414 public:
415         ChannelInfoGUI *gui;
416
417         int button_press_event();
418         int keypress_event();
419
420         ChannelInfoOK(ChannelInfoGUI *gui, int x, int y);
421         ~ChannelInfoOK();
422 };
423
424 class ChannelInfoCancel : public BC_CancelButton
425 {
426 public:
427         ChannelInfoGUI *gui;
428
429         int button_press_event();
430
431         ChannelInfoCancel(ChannelInfoGUI *gui, int x, int y);
432         ~ChannelInfoCancel();
433 };
434
435 class ChannelInfoCron : public BC_CheckBox
436 {
437 public:
438         ChannelInfoGUI *gui;
439
440         int handle_event();
441         ChannelInfoCron(ChannelInfoGUI *gui, int x, int y, int *value);
442         ~ChannelInfoCron();
443 };
444
445 class ChannelInfoPowerOff : public BC_CheckBox
446 {
447 public:
448         ChannelInfoGUI *gui;
449
450         int handle_event();
451
452         ChannelInfoPowerOff(ChannelInfoGUI *gui, int x, int y, int *value);
453         ~ChannelInfoPowerOff();
454 };
455
456 class ChannelInfoFind : public BC_GenericButton
457 {
458 public:
459         ChannelInfoGUI *gui;
460
461         int handle_event();
462         ChannelInfoFind(ChannelInfoGUI *gui, int x, int y);
463         ~ChannelInfoFind();
464 };
465
466
467 class ChannelInfoGUIBatches : public RecordBatchesGUI
468 {
469 public:
470         ChannelInfoGUI *gui;
471
472         int handle_event();
473         int selection_changed();
474
475         ChannelInfoGUIBatches(ChannelInfoGUI *gui,
476                 int x, int y, int w, int h);
477         ~ChannelInfoGUIBatches();
478 };
479
480 class ChannelDir : public RecordBatchesGUI::Dir
481 {
482 public:
483         ChannelInfoGUI *gui;
484
485         ChannelDir(ChannelInfoGUI *gui, const char *dir, int x, int y);
486 };
487
488 class ChannelPath : public RecordBatchesGUI::Path
489 {
490 public:
491         ChannelInfoGUI *gui;
492
493         ChannelPath(ChannelInfoGUI *gui, int x, int y);
494 };
495
496 class ChannelStart : public RecordBatchesGUI::StartTime
497 {
498 public:
499         ChannelInfoGUI *gui;
500
501         ChannelStart(ChannelInfoGUI *gui, int x, int y);
502 };
503
504 class ChannelDuration : public RecordBatchesGUI::Duration
505 {
506 public:
507         ChannelInfoGUI *gui;
508
509         ChannelDuration(ChannelInfoGUI *gui, int x, int y, int w);
510 };
511
512 class ChannelEarlyTime : public TimeEntryTumbler
513 {
514 public:
515         ChannelInfoGUI *gui;
516
517         int handle_up_event();
518         int handle_down_event();
519
520         ChannelEarlyTime(ChannelInfoGUI *gui, int x, int y,
521                 double *output_time);
522 };
523
524 class ChannelLateTime : public TimeEntryTumbler
525 {
526 public:
527         ChannelInfoGUI *gui;
528
529         int handle_up_event();
530         int handle_down_event();
531
532         ChannelLateTime(ChannelInfoGUI *gui, int x, int y,
533                 double *output_time);
534 };
535
536 class ChannelSource : public RecordBatchesGUI::Source
537 {
538 public:
539         ChannelInfoGUI *gui;
540         void create_objects();
541         int handle_event();
542         ChannelSource(ChannelInfoGUI *gui, int x, int y);
543 };
544
545
546 class ChannelNewBatch : public RecordBatchesGUI::NewBatch
547 {
548 public:
549         ChannelInfoGUI *gui;
550         int handle_event();
551         ChannelNewBatch(ChannelInfoGUI *gui, int x, int y);
552 };
553
554
555 class ChannelDeleteBatch : public RecordBatchesGUI::DeleteBatch
556 {
557 public:
558         ChannelInfoGUI *gui;
559         int handle_event();
560         ChannelDeleteBatch(ChannelInfoGUI *gui, int x, int y);
561 };
562
563 class ChannelClearBatch : public RecordBatchesGUI::ClearBatch
564 {
565 public:
566         ChannelInfoGUI *gui;
567         int handle_event();
568         ChannelClearBatch(ChannelInfoGUI *gui, int x, int y);
569 };
570
571
572
573 class ChannelInfo : public Thread
574 {
575 public:
576         MWindow *mwindow;
577         Record *record;
578         VideoDevice *vdevice;
579         Mutex *window_lock;
580         Mutex *vdevice_lock;
581         Mutex *progress_lock;
582         DeviceDVBInput *dvb_input;
583         RecordBatches record_batches;
584         ChannelInfoGUI *gui;
585         ChannelThread *thread;
586         ChannelDB *channeldb;
587         Condition *scan_lock;
588         int cron_enable, poweroff_enable;
589         int item;
590         int done, gui_done;
591
592         void run_scan();
593         void toggle_scan();
594         void start();
595         void stop();
596         void run();
597         void close_vdevice();
598         Batch *new_batch();
599         void delete_batch();
600         int current_batch() { return gui->batch_bay->current_batch(); }
601         int editing_batch() { return gui->batch_bay->editing_batch(); }
602         bool is_active() { return gui != 0; }
603
604         ChannelInfo(MWindow *mwindow);
605         ~ChannelInfo();
606 };
607
608 class ChannelThread : public Thread
609 {
610 public:
611         ChannelInfo *iwindow;
612         ChannelInfoGUI *gui;
613         ChannelPanel *panel;
614         zmpeg3_t *fd;
615         int done;
616
617         int load_ident(int n, int y, char *ident);
618         int load_info(Channel *channel, ChannelEventLine *channel_line);
619         void start();
620         void stop();
621         void run();
622         int total_channels() { return iwindow->channeldb->size(); }
623         Channel *get_channel(int ch) { return iwindow->channeldb->get(ch); }
624         int set_channel(Channel *chan);
625
626         ChannelThread(ChannelInfoGUI *gui);
627         ~ChannelThread();
628 };
629
630 class ChannelScan : public BC_MenuItem
631 {
632 public:
633         MWindow *mwindow;
634         int handle_event();
635
636         ChannelScan(MWindow *mwindow);
637         ~ChannelScan();
638 };
639
640 class ChannelStatus : public SignalStatus
641 {
642 public:
643         ChannelInfoGUI *gui;
644
645         ChannelStatus(ChannelInfoGUI *gui, int x, int y) :
646                 SignalStatus(gui, x, y) { this->gui = gui; }
647         ~ChannelStatus() {}
648 };
649
650
651 #endif
652 #endif