textbox focus policy preference
[goodguy/history.git] / cinelerra-5.1 / cinelerra / interfaceprefs.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #include "deleteallindexes.h"
23 #include "edl.h"
24 #include "edlsession.h"
25 #include "language.h"
26 #include "mwindow.h"
27 #include "preferences.h"
28 #include "preferencesthread.h"
29 #include "interfaceprefs.h"
30 #include "shbtnprefs.h"
31 #include "theme.h"
32
33 #if 0
34 N_("Drag all following edits")
35 N_("Drag only one edit")
36 N_("Drag source only")
37 N_("No effect")
38 #endif
39
40 #define MOVE_ALL_EDITS_TITLE "Drag all following edits"
41 #define MOVE_ONE_EDIT_TITLE "Drag only one edit"
42 #define MOVE_NO_EDITS_TITLE "Drag source only"
43 #define MOVE_EDITS_DISABLED_TITLE "No effect"
44
45 InterfacePrefs::InterfacePrefs(MWindow *mwindow, PreferencesWindow *pwindow)
46  : PreferencesDialog(mwindow, pwindow)
47 {
48         hms = 0;
49         hmsf = 0;
50         samples = 0;
51         frames = 0;
52         hex = 0;
53         feet = 0;
54         min_db = 0;
55         max_db = 0;
56 //      vu_db = 0;
57 //      vu_int = 0;
58         thumbnails = 0;
59         shbtn_dialog = 0;
60 }
61
62 InterfacePrefs::~InterfacePrefs()
63 {
64         delete hms;
65         delete hmsf;
66         delete samples;
67         delete frames;
68         delete hex;
69         delete feet;
70         delete min_db;
71         delete max_db;
72 //      delete vu_db;
73 //      delete vu_int;
74         delete thumbnails;
75         delete shbtn_dialog;
76 }
77
78
79 void InterfacePrefs::create_objects()
80 {
81         int x, y;
82         BC_Resources *resources = BC_WindowBase::get_resources();
83         int margin = mwindow->theme->widget_border;
84         char string[BCTEXTLEN];
85         x = mwindow->theme->preferencesoptions_x;
86         y = mwindow->theme->preferencesoptions_y;
87
88         add_subwindow(new BC_Title(x, y, _("Time Format"), LARGEFONT,
89                 resources->text_default));
90         int x1 = get_w()/2;
91         add_subwindow(new BC_Title(x1, y, _("Flags"), LARGEFONT,
92                 resources->text_default));
93
94         y += get_text_height(LARGEFONT) + 5;
95         int y1 = y;
96
97         add_subwindow(hms = new TimeFormatHMS(pwindow, this,
98                 pwindow->thread->edl->session->time_format == TIME_HMS,
99                 x, y));
100         y += 20;
101         add_subwindow(hmsf = new TimeFormatHMSF(pwindow, this,
102                 pwindow->thread->edl->session->time_format == TIME_HMSF,
103                 x, y));
104         y += 20;
105         add_subwindow(samples = new TimeFormatSamples(pwindow, this,
106                 pwindow->thread->edl->session->time_format == TIME_SAMPLES,
107                 x, y));
108         y += 20;
109         add_subwindow(hex = new TimeFormatHex(pwindow, this,
110                 pwindow->thread->edl->session->time_format == TIME_SAMPLES_HEX,
111                 x, y));
112         y += 20;
113         add_subwindow(frames = new TimeFormatFrames(pwindow, this,
114                 pwindow->thread->edl->session->time_format == TIME_FRAMES,
115                 x, y));
116         y += 20;
117         int x0 = x;
118         add_subwindow(feet = new TimeFormatFeet(pwindow, this,
119                 pwindow->thread->edl->session->time_format == TIME_FEET_FRAMES,
120                 x0, y));
121         x0 += feet->get_w() + 15;
122         BC_Title *title;
123         add_subwindow(title = new BC_Title(x0, y, _("Frames per foot:")));
124         x0 += title->get_w() + margin;
125         sprintf(string, "%0.2f", pwindow->thread->edl->session->frames_per_foot);
126         add_subwindow(new TimeFormatFeetSetting(pwindow,
127                 x0, y - 5,      string));
128         y += 20;
129         add_subwindow(seconds = new TimeFormatSeconds(pwindow, this,
130                 pwindow->thread->edl->session->time_format == TIME_SECONDS,
131                 x, y));
132         y += 35;
133
134         UseTipWindow *tip_win = new UseTipWindow(pwindow, x1, y1);
135         add_subwindow(tip_win);
136         y1 += tip_win->get_h() + 5;
137         UseWarnIndecies *idx_win = new UseWarnIndecies(pwindow, x1, y1);
138         add_subwindow(idx_win);
139         y1 += idx_win->get_h() + 5;
140         UseWarnVersion *ver_win = new UseWarnVersion(pwindow, x1, y1);
141         add_subwindow(ver_win);
142         y1 += ver_win->get_h() + 5;
143         BD_WarnRoot *bdwr_win = new BD_WarnRoot(pwindow, x1, y1);
144         add_subwindow(bdwr_win);
145         y1 += bdwr_win->get_h() + 5;
146         PopupMenuBtnup *pop_win = new PopupMenuBtnup(pwindow, x1, y1);
147         add_subwindow(pop_win);
148         y1 += pop_win->get_h() + 5;
149         TextboxFocusPolicy *focus_policy = new TextboxFocusPolicy(pwindow, x1, y1);
150         add_subwindow(focus_policy);
151         y1 += focus_policy->get_h() + 5;
152
153         if( y < y1 ) y = y1;
154         y += 10;
155
156         add_subwindow(new BC_Bar(5, y,  get_w() - 10));
157         y += 5;
158
159         add_subwindow(new BC_Title(x, y, _("Index files"), LARGEFONT, resources->text_default));
160
161
162         y += 25;
163         add_subwindow(new BC_Title(x, y + 5,
164                 _("Index files go here:"), MEDIUMFONT, resources->text_default));
165         add_subwindow(ipathtext = new IndexPathText(x + 230, y,
166                 pwindow,
167                 pwindow->thread->preferences->index_directory));
168         add_subwindow(ipath = new BrowseButton(mwindow->theme, this, ipathtext,
169                 x + 230 + ipathtext->get_w(), y,
170                 pwindow->thread->preferences->index_directory,
171                 _("Index Path"),
172                 _("Select the directory for index files"),
173                 1));
174
175         y += 30;
176         add_subwindow(new BC_Title(x, y + 5,
177                 _("Size of index file:"),
178                 MEDIUMFONT,
179                 resources->text_default));
180         sprintf(string, "%jd", pwindow->thread->preferences->index_size);
181         add_subwindow(isize = new IndexSize(x + 230, y, pwindow, string));
182         add_subwindow(new ScanCommercials(pwindow, 350,y));
183         y += 30;
184         add_subwindow(new BC_Title(x, y + 5, _("Number of index files to keep:"), MEDIUMFONT, resources->text_default));
185         sprintf(string, "%ld", (long)pwindow->thread->preferences->index_count);
186         add_subwindow(icount = new IndexCount(x + 230, y, pwindow, string));
187         add_subwindow(deleteall = new DeleteAllIndexes(mwindow, pwindow, 350, y));
188
189
190
191
192
193         y += 35;
194         add_subwindow(new BC_Bar(5, y,  get_w() - 10));
195         y += 5;
196
197         add_subwindow(new BC_Title(x, y, _("Editing"), LARGEFONT, resources->text_default));
198
199         y1 = y + 5;
200         y += 35;
201         add_subwindow(title = new BC_Title(x, y, _("Keyframe reticle:")));
202         x1 = x + title->get_w() + 10;
203         keyframe_reticle = new KeyframeReticle(x1, y, &pwindow->thread->preferences->keyframe_reticle);
204         add_subwindow(keyframe_reticle);
205         keyframe_reticle->create_objects();
206
207         int x2 = x + 400, y2 = y;
208         add_subwindow(thumbnails = new ViewThumbnails(x2, y1, pwindow));
209         AndroidRemote *android_remote = new AndroidRemote(pwindow, x2, y2);
210         add_subwindow(android_remote);
211         y2 += android_remote->get_h() + 10;
212         add_subwindow(title = new BC_Title(x2, y2, _("Port:")));
213         int x3 = x2 + title->get_w() + margin;
214         AndroidPort *android_port = new AndroidPort(pwindow, x3, y2);
215         add_subwindow(android_port);
216         y2 += title->get_h() + 10;
217         add_subwindow(title = new BC_Title(x2, y2, _("PIN:")));
218         AndroidPIN *android_pin = new AndroidPIN(pwindow, x3, y2);
219         add_subwindow(android_pin);
220
221         y2 += title->get_h() + 30;
222         ShBtnPrefs *shbtn_prefs = new ShBtnPrefs(pwindow, this, x2, y2);
223         add_subwindow(shbtn_prefs);
224
225         y2 += shbtn_prefs->get_h() + 30;
226         StillImageUseDuration *use_stduration = new StillImageUseDuration(pwindow,
227                 pwindow->thread->edl->session->si_useduration, x2, y2);
228         add_subwindow(use_stduration);
229         int tw = 0, th = 0;
230         BC_CheckBox::calculate_extents(this, &tw, &th, 0, 0);
231         x2 += tw + 3;
232         y2 += use_stduration->get_h() + 3;
233         StillImageDuration *stduration = new StillImageDuration(pwindow, x2, y2);
234         add_subwindow(stduration);
235         x2 += stduration->get_w() + 10;
236         y2 += 3;
237         add_subwindow(new BC_Title(x2, y2, _("Seconds")));
238
239         y += 35;
240         add_subwindow(new BC_Title(x, y, _("Clicking on edit boundaries does what:")));
241         y += 25;
242         add_subwindow(new BC_Title(x, y, _("Button 1:")));
243
244         ViewBehaviourText *text;
245         add_subwindow(text = new ViewBehaviourText(80, y - 5,
246                 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[0]),
247                         pwindow,
248                         &(pwindow->thread->edl->session->edit_handle_mode[0])));
249         text->create_objects();
250         y += 30;
251         add_subwindow(new BC_Title(x, y, _("Button 2:")));
252         add_subwindow(text = new ViewBehaviourText(80,
253                 y - 5,
254                 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[1]),
255                         pwindow,
256                         &(pwindow->thread->edl->session->edit_handle_mode[1])));
257         text->create_objects();
258         y += 30;
259         add_subwindow(new BC_Title(x, y, _("Button 3:")));
260         add_subwindow(text = new ViewBehaviourText(80,
261                 y - 5,
262                 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[2]),
263                         pwindow,
264                         &(pwindow->thread->edl->session->edit_handle_mode[2])));
265         text->create_objects();
266
267         y += 40;
268         x1 = x;
269         add_subwindow(title = new BC_Title(x, y + 5, _("Min DB for meter:")));
270         x += title->get_w() + 10;
271         sprintf(string, "%d", pwindow->thread->edl->session->min_meter_db);
272         add_subwindow(min_db = new MeterMinDB(pwindow, string, x, y));
273
274         x += min_db->get_w() + 10;
275         add_subwindow(title = new BC_Title(x, y + 5, _("Max DB:")));
276         x += title->get_w() + 10;
277         sprintf(string, "%d", pwindow->thread->edl->session->max_meter_db);
278         add_subwindow(max_db = new MeterMaxDB(pwindow, string, x, y));
279
280         x = x1;
281         y += 30;
282         ViewTheme *theme;
283         add_subwindow(new BC_Title(x, y, _("Theme:")));
284         x += 60;
285         add_subwindow(theme = new ViewTheme(x, y, pwindow));
286         theme->create_objects();
287
288 }
289
290 const char* InterfacePrefs::behavior_to_text(int mode)
291 {
292         switch(mode)
293         {
294                 case MOVE_ALL_EDITS:
295                         return _(MOVE_ALL_EDITS_TITLE);
296                         break;
297                 case MOVE_ONE_EDIT:
298                         return _(MOVE_ONE_EDIT_TITLE);
299                         break;
300                 case MOVE_NO_EDITS:
301                         return _(MOVE_NO_EDITS_TITLE);
302                         break;
303                 case MOVE_EDITS_DISABLED:
304                         return _(MOVE_EDITS_DISABLED_TITLE);
305                         break;
306                 default:
307                         return "";
308                         break;
309         }
310 }
311
312 int InterfacePrefs::update(int new_value)
313 {
314         pwindow->thread->redraw_times = 1;
315         pwindow->thread->edl->session->time_format = new_value;
316         hms->update(new_value == TIME_HMS);
317         hmsf->update(new_value == TIME_HMSF);
318         samples->update(new_value == TIME_SAMPLES);
319         hex->update(new_value == TIME_SAMPLES_HEX);
320         frames->update(new_value == TIME_FRAMES);
321         feet->update(new_value == TIME_FEET_FRAMES);
322         seconds->update(new_value == TIME_SECONDS);
323         return 0;
324 }
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340 IndexPathText::IndexPathText(int x,
341         int y,
342         PreferencesWindow *pwindow,
343         char *text)
344  : BC_TextBox(x, y, 240, 1, text)
345 {
346         this->pwindow = pwindow;
347 }
348
349 IndexPathText::~IndexPathText() {}
350
351 int IndexPathText::handle_event()
352 {
353         strcpy(pwindow->thread->preferences->index_directory, get_text());
354         return 1;
355 }
356
357
358
359
360 IndexSize::IndexSize(int x,
361         int y,
362         PreferencesWindow *pwindow,
363         char *text)
364  : BC_TextBox(x, y, 100, 1, text)
365 {
366         this->pwindow = pwindow;
367 }
368
369 int IndexSize::handle_event()
370 {
371         long result;
372
373         result = atol(get_text());
374         if(result < 64000) result = 64000;
375         //if(result < 500000) result = 500000;
376         pwindow->thread->preferences->index_size = result;
377         return 0;
378 }
379
380
381
382 IndexCount::IndexCount(int x,
383         int y,
384         PreferencesWindow *pwindow,
385         char *text)
386  : BC_TextBox(x, y, 100, 1, text)
387 {
388         this->pwindow = pwindow;
389 }
390
391 int IndexCount::handle_event()
392 {
393         long result;
394
395         result = atol(get_text());
396         if(result < 1) result = 1;
397         pwindow->thread->preferences->index_count = result;
398         return 0;
399 }
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415 TimeFormatHMS::TimeFormatHMS(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
416  : BC_Radial(x, y, value, TIME_HMS_TEXT)
417 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
418
419 int TimeFormatHMS::handle_event()
420 {
421         tfwindow->update(TIME_HMS);
422         return 1;
423 }
424
425 TimeFormatHMSF::TimeFormatHMSF(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
426  : BC_Radial(x, y, value, TIME_HMSF_TEXT)
427 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
428
429 int TimeFormatHMSF::handle_event()
430 {
431         tfwindow->update(TIME_HMSF);
432         return 1;
433 }
434
435 TimeFormatSamples::TimeFormatSamples(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
436  : BC_Radial(x, y, value, TIME_SAMPLES_TEXT)
437 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
438
439 int TimeFormatSamples::handle_event()
440 {
441         tfwindow->update(TIME_SAMPLES);
442         return 1;
443 }
444
445 TimeFormatFrames::TimeFormatFrames(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
446  : BC_Radial(x, y, value, TIME_FRAMES_TEXT)
447 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
448
449 int TimeFormatFrames::handle_event()
450 {
451         tfwindow->update(TIME_FRAMES);
452         return 1;
453 }
454
455 TimeFormatHex::TimeFormatHex(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
456  : BC_Radial(x, y, value, TIME_SAMPLES_HEX_TEXT)
457 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
458
459 int TimeFormatHex::handle_event()
460 {
461         tfwindow->update(TIME_SAMPLES_HEX);
462         return 1;
463 }
464
465 TimeFormatSeconds::TimeFormatSeconds(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
466  : BC_Radial(x, y, value, TIME_SECONDS_TEXT)
467 {
468         this->pwindow = pwindow;
469         this->tfwindow = tfwindow;
470 }
471
472 int TimeFormatSeconds::handle_event()
473 {
474         tfwindow->update(TIME_SECONDS);
475         return 1;
476 }
477
478 TimeFormatFeet::TimeFormatFeet(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
479  : BC_Radial(x, y, value, TIME_FEET_FRAMES_TEXT)
480 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
481
482 int TimeFormatFeet::handle_event()
483 {
484         tfwindow->update(TIME_FEET_FRAMES);
485         return 1;
486 }
487
488 TimeFormatFeetSetting::TimeFormatFeetSetting(PreferencesWindow *pwindow, int x, int y, char *string)
489  : BC_TextBox(x, y, 90, 1, string)
490 { this->pwindow = pwindow; }
491
492 int TimeFormatFeetSetting::handle_event()
493 {
494         pwindow->thread->edl->session->frames_per_foot = atof(get_text());
495         if(pwindow->thread->edl->session->frames_per_foot < 1) pwindow->thread->edl->session->frames_per_foot = 1;
496         return 0;
497 }
498
499
500
501
502 ViewBehaviourText::ViewBehaviourText(int x,
503         int y,
504         const char *text,
505         PreferencesWindow *pwindow,
506         int *output)
507  : BC_PopupMenu(x, y, 200, text)
508 {
509         this->output = output;
510 }
511
512 ViewBehaviourText::~ViewBehaviourText()
513 {
514 }
515
516 int ViewBehaviourText::handle_event()
517 {
518         return 0;
519 }
520
521 void ViewBehaviourText::create_objects()
522 {
523 // Video4linux versions are automatically detected
524         add_item(new ViewBehaviourItem(this, _(MOVE_ALL_EDITS_TITLE), MOVE_ALL_EDITS));
525         add_item(new ViewBehaviourItem(this, _(MOVE_ONE_EDIT_TITLE), MOVE_ONE_EDIT));
526         add_item(new ViewBehaviourItem(this, _(MOVE_NO_EDITS_TITLE), MOVE_NO_EDITS));
527         add_item(new ViewBehaviourItem(this, _(MOVE_EDITS_DISABLED_TITLE), MOVE_EDITS_DISABLED));
528 }
529
530
531 ViewBehaviourItem::ViewBehaviourItem(ViewBehaviourText *popup, char *text, int behaviour)
532  : BC_MenuItem(text)
533 {
534         this->popup = popup;
535         this->behaviour = behaviour;
536 }
537
538 ViewBehaviourItem::~ViewBehaviourItem()
539 {
540 }
541
542 int ViewBehaviourItem::handle_event()
543 {
544         popup->set_text(get_text());
545         *(popup->output) = behaviour;
546         return 1;
547 }
548
549
550
551
552 MeterMinDB::MeterMinDB(PreferencesWindow *pwindow, char *text, int x, int y)
553  : BC_TextBox(x, y, 50, 1, text)
554 {
555         this->pwindow = pwindow;
556 }
557
558 int MeterMinDB::handle_event()
559 {
560         pwindow->thread->redraw_meters = 1;
561         pwindow->thread->edl->session->min_meter_db = atol(get_text());
562         return 0;
563 }
564
565
566
567
568 MeterMaxDB::MeterMaxDB(PreferencesWindow *pwindow, char *text, int x, int y)
569  : BC_TextBox(x, y, 50, 1, text)
570 {
571         this->pwindow = pwindow;
572 }
573
574 int MeterMaxDB::handle_event()
575 {
576         pwindow->thread->redraw_meters = 1;
577         pwindow->thread->edl->session->max_meter_db = atol(get_text());
578         return 0;
579 }
580
581
582
583
584
585 MeterVUDB::MeterVUDB(PreferencesWindow *pwindow, char *text, int y)
586  : BC_Radial(145, y, pwindow->thread->edl->session->meter_format == METER_DB, text)
587 {
588         this->pwindow = pwindow;
589 }
590
591 int MeterVUDB::handle_event()
592 {
593         pwindow->thread->redraw_meters = 1;
594 //      vu_int->update(0);
595         pwindow->thread->edl->session->meter_format = METER_DB;
596         return 1;
597 }
598
599 MeterVUInt::MeterVUInt(PreferencesWindow *pwindow, char *text, int y)
600  : BC_Radial(205, y, pwindow->thread->edl->session->meter_format == METER_INT, text)
601 {
602         this->pwindow = pwindow;
603 }
604
605 int MeterVUInt::handle_event()
606 {
607         pwindow->thread->redraw_meters = 1;
608         vu_db->update(0);
609         pwindow->thread->edl->session->meter_format = METER_INT;
610         return 1;
611 }
612
613
614
615
616 ViewTheme::ViewTheme(int x, int y, PreferencesWindow *pwindow)
617  : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->theme, 1)
618 {
619         this->pwindow = pwindow;
620 }
621 ViewTheme::~ViewTheme()
622 {
623 }
624
625 void ViewTheme::create_objects()
626 {
627         ArrayList<PluginServer*> themes;
628         MWindow::search_plugindb(0,
629                 0,
630                 0,
631                 0,
632                 1,
633                 themes);
634
635         for(int i = 0; i < themes.total; i++)
636         {
637                 add_item(new ViewThemeItem(this, themes.values[i]->title));
638         }
639 }
640
641 int ViewTheme::handle_event()
642 {
643         return 1;
644 }
645
646
647
648
649
650 ViewThemeItem::ViewThemeItem(ViewTheme *popup, char *text)
651  : BC_MenuItem(text)
652 {
653         this->popup = popup;
654 }
655
656 int ViewThemeItem::handle_event()
657 {
658         popup->set_text(get_text());
659         strcpy(popup->pwindow->thread->preferences->theme, get_text());
660         popup->handle_event();
661         return 1;
662 }
663
664 ViewThumbnails::ViewThumbnails(int x,
665         int y,
666         PreferencesWindow *pwindow)
667  : BC_CheckBox(x,
668         y,
669         pwindow->thread->preferences->use_thumbnails, _("Use thumbnails in resource window"))
670 {
671         this->pwindow = pwindow;
672 }
673
674 int ViewThumbnails::handle_event()
675 {
676         pwindow->thread->preferences->use_thumbnails = get_value();
677         return 1;
678 }
679
680
681
682 UseTipWindow::UseTipWindow(PreferencesWindow *pwindow, int x, int y)
683  : BC_CheckBox(x,
684         y,
685         pwindow->thread->preferences->use_tipwindow,
686         _("Show tip of the day"))
687 {
688         this->pwindow = pwindow;
689 }
690 int UseTipWindow::handle_event()
691 {
692         pwindow->thread->preferences->use_tipwindow = get_value();
693         return 1;
694 }
695
696
697 UseWarnIndecies::UseWarnIndecies(PreferencesWindow *pwindow, int x, int y)
698  : BC_CheckBox(x, y, pwindow->thread->preferences->warn_indexes,
699         _("ffmpeg probe warns rebuild indexes"))
700 {
701         this->pwindow = pwindow;
702 }
703
704 int UseWarnIndecies::handle_event()
705 {
706         pwindow->thread->preferences->warn_indexes = get_value();
707         return 1;
708 }
709
710 UseWarnVersion::UseWarnVersion(PreferencesWindow *pwindow, int x, int y)
711  : BC_CheckBox(x, y, pwindow->thread->preferences->warn_version,
712         _("EDL version warns if mismatched"))
713 {
714         this->pwindow = pwindow;
715 }
716
717 int UseWarnVersion::handle_event()
718 {
719         pwindow->thread->preferences->warn_version = get_value();
720         return 1;
721 }
722
723 BD_WarnRoot::BD_WarnRoot(PreferencesWindow *pwindow, int x, int y)
724  : BC_CheckBox(x, y, pwindow->thread->preferences->bd_warn_root,
725         _("Create Bluray warns if not root"))
726 {
727         this->pwindow = pwindow;
728 }
729
730 int BD_WarnRoot::handle_event()
731 {
732         pwindow->thread->preferences->bd_warn_root = get_value();
733         return 1;
734 }
735
736 PopupMenuBtnup::PopupMenuBtnup(PreferencesWindow *pwindow, int x, int y)
737  : BC_CheckBox(x, y, pwindow->thread->preferences->popupmenu_btnup,
738         _("Popups activate on button up"))
739 {
740         this->pwindow = pwindow;
741 }
742
743 int PopupMenuBtnup::handle_event()
744 {
745         pwindow->thread->preferences->popupmenu_btnup = get_value();
746         return 1;
747 }
748
749 TextboxFocusPolicy::TextboxFocusPolicy(PreferencesWindow *pwindow, int x, int y)
750  : BC_CheckBox(x, y, pwindow->thread->preferences->textbox_focus_policy,
751         _("Click to deactivate text focus"))
752 {
753         this->pwindow = pwindow;
754 }
755
756 int TextboxFocusPolicy::handle_event()
757 {
758         pwindow->thread->preferences->textbox_focus_policy = get_value();
759         return 1;
760 }
761
762
763
764 ScanCommercials::ScanCommercials(PreferencesWindow *pwindow, int x, int y)
765  : BC_CheckBox(x,
766         y,
767         pwindow->thread->preferences->scan_commercials,
768         _("Scan for commercials during toc build"))
769 {
770         this->pwindow = pwindow;
771 }
772 int ScanCommercials::handle_event()
773 {
774         pwindow->thread->preferences->scan_commercials = get_value();
775         return 1;
776 }
777
778
779 AndroidRemote::AndroidRemote(PreferencesWindow *pwindow, int x, int y)
780  : BC_CheckBox(x, y,
781         pwindow->thread->preferences->android_remote,
782         _("Android Remote Control"))
783 {
784         this->pwindow = pwindow;
785 }
786 int AndroidRemote::handle_event()
787 {
788         pwindow->thread->preferences->android_remote = get_value();
789         return 1;
790 }
791
792 AndroidPIN::AndroidPIN(PreferencesWindow *pwindow, int x, int y)
793  : BC_TextBox(x, y, 240, 1, pwindow->thread->preferences->android_pin)
794 {
795         this->pwindow = pwindow;
796 }
797
798 int AndroidPIN::handle_event()
799 {
800         char *txt = pwindow->thread->preferences->android_pin;
801         int len = sizeof(pwindow->thread->preferences->android_pin);
802         strncpy(txt, get_text(), len);
803         return 1;
804 }
805
806
807 AndroidPort::AndroidPort(PreferencesWindow *pwindow, int x, int y)
808  : BC_TextBox(x, y, 72, 1, pwindow->thread->preferences->android_port)
809 {
810         this->pwindow = pwindow;
811 }
812
813 int AndroidPort::handle_event()
814 {
815         unsigned short port = atoi(get_text());
816         if( port < 1024 ) port = 1024;
817         pwindow->thread->preferences->android_port = port;
818         char str[BCSTRLEN];
819         sprintf(str,"%u",port);
820         update(str);
821         return 1;
822 }
823
824 int InterfacePrefs::start_shbtn_dialog()
825 {
826         if( !shbtn_dialog )
827                 shbtn_dialog = new ShBtnEditDialog(pwindow);
828         shbtn_dialog->start();
829         return 1;
830 }
831
832 ShBtnPrefs::ShBtnPrefs(PreferencesWindow *pwindow, InterfacePrefs *iface_prefs, int x, int y)
833  : BC_GenericButton(x, y, _("Shell Commands"))
834 {
835         this->pwindow = pwindow;
836         this->iface_prefs = iface_prefs;
837         set_tooltip(_("Main Menu Shell Commands"));
838 }
839
840 int ShBtnPrefs::handle_event()
841 {
842         return iface_prefs->start_shbtn_dialog();
843 }
844
845
846 StillImageUseDuration::StillImageUseDuration(PreferencesWindow *pwindow, int value, int x, int y)
847  : BC_CheckBox(x, y, value, _("Import images with a duration of"))
848 {
849         this->pwindow = pwindow;
850 }
851
852 int StillImageUseDuration::handle_event()
853 {
854         pwindow->thread->edl->session->si_useduration = get_value();
855         return 1;
856 }
857
858 StillImageDuration::StillImageDuration(PreferencesWindow *pwindow, int x, int y)
859  : BC_TextBox(x, y, 70, 1, pwindow->thread->edl->session->si_duration)
860 {
861         this->pwindow = pwindow;
862 }
863 int StillImageDuration::handle_event()
864 {
865         pwindow->thread->edl->session->si_duration = atof(get_text());
866         return 1;
867 }
868
869
870 HairlineItem::HairlineItem(KeyframeReticle *popup, int hairline)
871  : BC_MenuItem(popup->hairline_to_string(hairline))
872 {
873         this->popup = popup;
874         this->hairline = hairline;
875 }
876
877 HairlineItem::~HairlineItem()
878 {
879 }
880
881 int HairlineItem::handle_event()
882 {
883         popup->set_text(get_text());
884         *(popup->output) = hairline;
885         return 1;
886 }
887
888
889 KeyframeReticle::KeyframeReticle(int x, int y, int *output)
890  : BC_PopupMenu(x, y, 175, hairline_to_string(*output))
891 {
892         this->output = output;
893 }
894
895 KeyframeReticle::~KeyframeReticle()
896 {
897 }
898
899 const char *KeyframeReticle::hairline_to_string(int type)
900 {
901         switch( type ) {
902         case HAIRLINE_NEVER:    return _("Never");
903         case HAIRLINE_DRAGGING: return _("Dragging");
904         case HAIRLINE_ALWAYS:   return _("Always");
905         }
906         return _("Unknown");
907 }
908
909 void KeyframeReticle::create_objects()
910 {
911         add_item(new HairlineItem(this, HAIRLINE_NEVER));
912         add_item(new HairlineItem(this, HAIRLINE_DRAGGING));
913         add_item(new HairlineItem(this, HAIRLINE_ALWAYS));
914 }
915