r717: Made the highlighted text color of the menus WHITE
[cinelerra_cv/mob.git] / guicast / bcresources.C
blobd4c45c460edb037d57a267a09ab7663648be0d95
1 #include "bcdisplayinfo.h"
2 #include "bcipc.h"
3 #include "bclistbox.inc"
4 #include "bcresources.h"
5 #include "bcsignals.h"
6 #include "bcwindowbase.h"
7 #include "colors.h"
8 #include "colormodels.h"
9 #include "fonts.h"
10 #include "language.h"
11 #include "vframe.h"
13 #include <string.h>
14 #include <sys/ipc.h>
15 #include <sys/shm.h>
16 #include <X11/extensions/XShm.h>
17 #include <unistd.h>
23 int BC_Resources::error = 0;
25 VFrame* BC_Resources::bg_image = 0;
26 VFrame* BC_Resources::menu_bg = 0;
28 #include "images/file_film_png.h"
29 #include "images/file_folder_png.h"
30 #include "images/file_sound_png.h"
31 #include "images/file_unknown_png.h"
32 #include "images/file_column_png.h"
33 VFrame* BC_Resources::type_to_icon[] = 
35         new VFrame(file_folder_png),
36         new VFrame(file_unknown_png),
37         new VFrame(file_film_png),
38         new VFrame(file_sound_png),
39         new VFrame(file_column_png)
42 char* BC_Resources::small_font = N_("-*-helvetica-medium-r-normal-*-10-*");
43 char* BC_Resources::small_font2 = N_("-*-helvetica-medium-r-normal-*-11-*");
44 char* BC_Resources::medium_font = N_("-*-helvetica-bold-r-normal-*-14-*");
45 char* BC_Resources::medium_font2 = N_("-*-helvetica-bold-r-normal-*-14-*");
46 char* BC_Resources::large_font = N_("-*-helvetica-bold-r-normal-*-18-*");
47 char* BC_Resources::large_font2 = N_("-*-helvetica-bold-r-normal-*-20-*");
49 char* BC_Resources::small_fontset = "6x12,*";
50 char* BC_Resources::medium_fontset = "7x14,*";
51 char* BC_Resources::large_fontset = "8x16,*";
53 char* BC_Resources::small_font_xft = N_("-microsoft-verdana-*-*-*-*-*-*-*-*-*-*-*-*");
54 char* BC_Resources::medium_font_xft = N_("-microsoft-verdana-*-*-*-*-*-*-*-*-*-*-*-*");
55 char* BC_Resources::large_font_xft = N_("-microsoft-verdana-*-*-*-*-*-*-*-*-*-*-*-*");
57 suffix_to_type_t BC_Resources::suffix_to_type[] = 
59         { "m2v", ICON_FILM },
60         { "mov", ICON_FILM },
61         { "mp2", ICON_SOUND },
62         { "mp3", ICON_SOUND },
63         { "mpg", ICON_FILM },
64         { "vob", ICON_FILM },
65         { "wav", ICON_SOUND }
68 BC_Signals* BC_Resources::signal_handler = 0;
70 int BC_Resources::x_error_handler(Display *display, XErrorEvent *event)
72         char string[1024];
73         XGetErrorText(event->display, event->error_code, string, 1024);
74 //      printf("BC_Resources::x_error_handler: %s\n", string);
75         BC_Resources::error = 1;
76         return 0;
81 BC_Resources::BC_Resources()
83         display_info = new BC_DisplayInfo("", 0);
85         for(int i = 0; i < FILEBOX_HISTORY_SIZE; i++)
86                 filebox_history[i][0] = 0;
88 #ifdef HAVE_XFT
89         XftInitFtLibrary();
90 #endif
92         use_xvideo = 1;
95 #include "images/bar_png.h"
96         static VFrame* default_bar = new VFrame(bar_png);
97         bar_data = default_bar;
101 #include "images/cancel_up_png.h"
102 #include "images/cancel_hi_png.h"
103 #include "images/cancel_dn_png.h"
104         static VFrame* default_cancel_images[] = 
105         {
106                 new VFrame(cancel_up_png),
107                 new VFrame(cancel_hi_png),
108                 new VFrame(cancel_dn_png)
109         };
111 #include "images/ok_up_png.h"
112 #include "images/ok_hi_png.h"
113 #include "images/ok_dn_png.h"
114         static VFrame* default_ok_images[] = 
115         {
116                 new VFrame(ok_up_png),
117                 new VFrame(ok_hi_png),
118                 new VFrame(ok_dn_png)
119         };
121 #include "images/usethis_up_png.h"
122 #include "images/usethis_uphi_png.h"
123 #include "images/usethis_dn_png.h"
124         static VFrame* default_usethis_images[] = 
125         {
126                 new VFrame(usethis_up_png),
127                 new VFrame(usethis_uphi_png),
128                 new VFrame(usethis_dn_png)
129         };
132 #include "images/checkbox_checked_png.h"
133 #include "images/checkbox_dn_png.h"
134 #include "images/checkbox_checkedhi_png.h"
135 #include "images/checkbox_up_png.h"
136 #include "images/checkbox_hi_png.h"
137         static VFrame* default_checkbox_images[] =  
138         {
139                 new VFrame(checkbox_up_png),
140                 new VFrame(checkbox_hi_png),
141                 new VFrame(checkbox_checked_png),
142                 new VFrame(checkbox_dn_png),
143                 new VFrame(checkbox_checkedhi_png)
144         };
146 #include "images/radial_checked_png.h"
147 #include "images/radial_dn_png.h"
148 #include "images/radial_checkedhi_png.h"
149 #include "images/radial_up_png.h"
150 #include "images/radial_hi_png.h"
151         static VFrame* default_radial_images[] =  
152         {
153                 new VFrame(radial_up_png),
154                 new VFrame(radial_hi_png),
155                 new VFrame(radial_checked_png),
156                 new VFrame(radial_dn_png),
157                 new VFrame(radial_checkedhi_png)
158         };
160         static VFrame* default_label_images[] =  
161         {
162                 new VFrame(radial_up_png),
163                 new VFrame(radial_hi_png),
164                 new VFrame(radial_checked_png),
165                 new VFrame(radial_dn_png),
166                 new VFrame(radial_checkedhi_png)
167         };
170 #include "images/file_text_up_png.h"
171 #include "images/file_text_hi_png.h"
172 #include "images/file_text_dn_png.h"
173 #include "images/file_icons_up_png.h"
174 #include "images/file_icons_hi_png.h"
175 #include "images/file_icons_dn_png.h"
176 #include "images/file_newfolder_up_png.h"
177 #include "images/file_newfolder_hi_png.h"
178 #include "images/file_newfolder_dn_png.h"
179 #include "images/file_updir_up_png.h"
180 #include "images/file_updir_hi_png.h"
181 #include "images/file_updir_dn_png.h"
182 #include "images/file_delete_up_png.h"
183 #include "images/file_delete_hi_png.h"
184 #include "images/file_delete_dn_png.h"
185 #include "images/file_reload_up_png.h"
186 #include "images/file_reload_hi_png.h"
187 #include "images/file_reload_dn_png.h"
188         static VFrame* default_filebox_text_images[] = 
189         {
190                 new VFrame(file_text_up_png),
191                 new VFrame(file_text_hi_png),
192                 new VFrame(file_text_dn_png)
193         };
195         static VFrame* default_filebox_icons_images[] = 
196         {
197                 new VFrame(file_icons_up_png),
198                 new VFrame(file_icons_hi_png),
199                 new VFrame(file_icons_dn_png)
200         };
202         static VFrame* default_filebox_updir_images[] =  
203         {
204                 new VFrame(file_updir_up_png),
205                 new VFrame(file_updir_hi_png),
206                 new VFrame(file_updir_dn_png)
207         };
209         static VFrame* default_filebox_newfolder_images[] = 
210         {
211                 new VFrame(file_newfolder_up_png),
212                 new VFrame(file_newfolder_hi_png),
213                 new VFrame(file_newfolder_dn_png)
214         };
216         static VFrame* default_filebox_delete_images[] = 
217         {
218                 new VFrame(file_delete_up_png),
219                 new VFrame(file_delete_hi_png),
220                 new VFrame(file_delete_dn_png)
221         };
223         static VFrame* default_filebox_reload_images[] =
224         {
225                 new VFrame(file_reload_up_png),
226                 new VFrame(file_reload_hi_png),
227                 new VFrame(file_reload_dn_png)
228         };
230 #include "images/listbox_button_dn_png.h"
231 #include "images/listbox_button_hi_png.h"
232 #include "images/listbox_button_up_png.h"
233 #include "images/listbox_button_disabled_png.h"\r
234         static VFrame* default_listbox_button[] = 
235         {
236                 new VFrame(listbox_button_up_png),
237                 new VFrame(listbox_button_hi_png),
238                 new VFrame(listbox_button_dn_png),
239                 new VFrame(listbox_button_disabled_png)
240         };
241         listbox_button = default_listbox_button;
243 #include "images/list_bg_png.h"
244         static VFrame* default_listbox_bg = new VFrame(list_bg_png);
245         listbox_bg = default_listbox_bg;
247 #include "images/listbox_expandchecked_png.h"
248 #include "images/listbox_expandcheckedhi_png.h"
249 #include "images/listbox_expanddn_png.h"
250 #include "images/listbox_expandup_png.h"
251 #include "images/listbox_expanduphi_png.h"
252         static VFrame* default_listbox_expand[] = 
253         {
254                 new VFrame(listbox_expandup_png),
255                 new VFrame(listbox_expanduphi_png),
256                 new VFrame(listbox_expandchecked_png),
257                 new VFrame(listbox_expanddn_png),
258                 new VFrame(listbox_expandcheckedhi_png),
259         };
260         listbox_expand = default_listbox_expand;
262 #include "images/listbox_columnup_png.h"
263 #include "images/listbox_columnhi_png.h"
264 #include "images/listbox_columndn_png.h"
265         static VFrame* default_listbox_column[] = 
266         {
267                 new VFrame(listbox_columnup_png),
268                 new VFrame(listbox_columnhi_png),
269                 new VFrame(listbox_columndn_png)
270         };
271         listbox_column = default_listbox_column;
274 #include "images/listbox_up_png.h"
275 #include "images/listbox_dn_png.h"
276         listbox_up = new VFrame(listbox_up_png);
277         listbox_dn = new VFrame(listbox_dn_png);
278         listbox_title_margin = 0;
279         listbox_title_color = BLACK;
280         listbox_title_hotspot = 5;
281         
282         listbox_border1 = DKGREY;
283         listbox_border2_hi = RED;
284         listbox_border2 = BLACK;
285         listbox_border3_hi = RED;
286         listbox_border3 = MEGREY;
287         listbox_border4 = WHITE;
288         listbox_selected = BLUE;
289         listbox_highlighted = LTGREY;
290         listbox_inactive = WHITE;
291         listbox_text = BLACK;
293 #include "images/pot_hi_png.h"
294 #include "images/pot_up_png.h"
295 #include "images/pot_dn_png.h"
296         static VFrame *default_pot_images[] = 
297         {
298                 new VFrame(pot_up_png),
299                 new VFrame(pot_hi_png),
300                 new VFrame(pot_dn_png)
301         };
303  #include "images/progress_up_png.h"
304  #include "images/progress_hi_png.h"
305         static VFrame* default_progress_images[] = 
306         {
307                 new VFrame(progress_up_png),
308                 new VFrame(progress_hi_png)
309         };
311         pan_data = 0;
312         pan_text_color = YELLOW;
314 #include "images/7seg_small/0_png.h"
315 #include "images/7seg_small/1_png.h"
316 #include "images/7seg_small/2_png.h"
317 #include "images/7seg_small/3_png.h"
318 #include "images/7seg_small/4_png.h"
319 #include "images/7seg_small/5_png.h"
320 #include "images/7seg_small/6_png.h"
321 #include "images/7seg_small/7_png.h"
322 #include "images/7seg_small/8_png.h"
323 #include "images/7seg_small/9_png.h"
324 #include "images/7seg_small/colon_png.h"
325 #include "images/7seg_small/period_png.h"
326 #include "images/7seg_small/a_png.h"
327 #include "images/7seg_small/b_png.h"
328 #include "images/7seg_small/c_png.h"
329 #include "images/7seg_small/d_png.h"
330 #include "images/7seg_small/e_png.h"
331 #include "images/7seg_small/f_png.h"
332 #include "images/7seg_small/space_png.h"
333 #include "images/7seg_small/dash_png.h"
334         static VFrame* default_medium_7segment[] = 
335         {
336                 new VFrame(_0_png),
337                 new VFrame(_1_png),
338                 new VFrame(_2_png),
339                 new VFrame(_3_png),
340                 new VFrame(_4_png),
341                 new VFrame(_5_png),
342                 new VFrame(_6_png),
343                 new VFrame(_7_png),
344                 new VFrame(_8_png),
345                 new VFrame(_9_png),
346                 new VFrame(colon_png),
347                 new VFrame(period_png),
348                 new VFrame(a_png),
349                 new VFrame(b_png),
350                 new VFrame(c_png),
351                 new VFrame(d_png),
352                 new VFrame(e_png),
353                 new VFrame(f_png),
354                 new VFrame(space_png),
355                 new VFrame(dash_png)
356         };
358         generic_button_margin = 15;
359         draw_clock_background=1;
361         use_shm = -1;
363 // Initialize
364         bg_color = ORANGE;
365         bg_shadow1 = DKGREY;
366         bg_shadow2 = BLACK;
367         bg_light1 = WHITE;
368         bg_light2 = bg_color;
370         default_text_color = BLACK;
371         disabled_text_color = MEGREY;
373         button_light = WHITE;           // bright corner
374         button_highlighted = 0xffe000;  // face when highlighted
375         button_down = MDGREY;         // face when down
376         button_up = 0xffc000;           // face when up
377         button_shadow = DKGREY;       // dark corner
378         button_uphighlighted = RED;   // upper side when highlighted
380         tumble_data = 0;
381         tumble_duration = 150;
383         ok_images = default_ok_images;
384         cancel_images = default_cancel_images;
385         usethis_button_images = default_usethis_images;
386         filebox_descend_images = default_ok_images;
388         menu_light = LTCYAN;
389         menu_highlighted = LTBLUE;
390         menu_down = MDCYAN;
391         menu_up = MECYAN;
392         menu_shadow = DKCYAN;
393         menu_popup_bg = 0;
394         menu_title_bg = 0;
395         menu_item_bg = 0;
396         menu_bar_bg = 0;
397         menu_title_bg = 0;
398         popupmenu_images = 0;
399         popupmenu_margin = 10;
400         popupmenu_triangle_margin = 10;
402         min_menu_w = 0;
403         menu_title_text = BLACK;
404         popup_title_text = BLACK;
405         menu_item_text = BLACK;
406         menu_highlighted_fontcolor = BLACK;
407         progress_text = BLACK;
411         text_default = BLACK;
412         highlight_inverse = WHITE ^ BLUE;
413         text_background = WHITE;
414         text_background_hi = LTYELLOW;
415         text_background_noborder_hi = LTGREY;
416         text_background_noborder = -1;
417         text_border1 = DKGREY;
418         text_border2 = BLACK;
419         text_border2_hi = RED;
420         text_border3 = MEGREY;
421         text_border3_hi = LTPINK;
422         text_border4 = WHITE;
423         text_highlight = BLUE;
424         text_inactive_highlight = MEGREY;
426         toggle_highlight_bg = 0;
427         toggle_text_margin = 0;
429 // Delays must all be different for repeaters
430         double_click = 300;
431         blink_rate = 250;
432         scroll_repeat = 150;
433         tooltip_delay = 1000;
434         tooltip_bg_color = YELLOW;
435         tooltips_enabled = 1;
437         filebox_margin = 110;
438         dirbox_margin = 90;
439         filebox_mode = LISTBOX_TEXT;
440         sprintf(filebox_filter, "*");
441         filebox_w = 640;
442         filebox_h = 480;
443         filebox_columntype[0] = FILEBOX_NAME;
444         filebox_columntype[1] = FILEBOX_SIZE;
445         filebox_columntype[2] = FILEBOX_DATE;
446         filebox_columntype[3] = FILEBOX_EXTENSION;
447         filebox_columnwidth[0] = 200;
448         filebox_columnwidth[1] = 100;
449         filebox_columnwidth[2] = 100;
450         filebox_columnwidth[3] = 100;
451         dirbox_columntype[0] = FILEBOX_NAME;
452         dirbox_columntype[1] = FILEBOX_DATE;
453         dirbox_columnwidth[0] = 200;
454         dirbox_columnwidth[1] = 100;
456         filebox_text_images = default_filebox_text_images;
457         filebox_icons_images = default_filebox_icons_images;
458         filebox_updir_images = default_filebox_updir_images;
459         filebox_newfolder_images = default_filebox_newfolder_images;
460         filebox_delete_images = default_filebox_delete_images;
461         filebox_reload_images = default_filebox_reload_images;
462         directory_color = BLUE;
463         file_color = BLACK;
465         filebox_sortcolumn = 0;
466         filebox_sortorder = BC_ListBox::SORT_ASCENDING;
467         dirbox_sortcolumn = 0;
468         dirbox_sortorder = BC_ListBox::SORT_ASCENDING;
470         pot_images = default_pot_images;
471         pot_offset = 2;
472         pot_x1 = pot_images[0]->get_w() / 2 - pot_offset;
473         pot_y1 = pot_images[0]->get_h() / 2 - pot_offset;
474         pot_r = pot_x1;
475         pot_needle_color = BLACK;
477         progress_images = default_progress_images;
479         xmeter_images = 0;
480         ymeter_images = 0;
481         meter_font = SMALLFONT_3D;
482         meter_font_color = RED;
483         meter_title_w = 20;
484         meter_3d = 1;
485         medium_7segment = default_medium_7segment;
487         audiovideo_color = RED;
489         use_fontset = 0;
491 // Xft has priority over font set
492 #ifdef HAVE_XFT
493         use_xft = 1;
494 #else
495         use_xft = 0;
496 #endif
499         drag_radius = 10;
500         recursive_resizing = 1;
502         
505 BC_Resources::~BC_Resources()
509 int BC_Resources::initialize_display(BC_WindowBase *window)
511 // Set up IPC cleanup handlers
512         bc_init_ipc();
514 // Test for shm.  Must come before yuv test
515         init_shm(window);
516         return 0;
520 int BC_Resources::init_shm(BC_WindowBase *window)
522         use_shm = 1;
523         XSetErrorHandler(BC_Resources::x_error_handler);
525         if(!XShmQueryExtension(window->display)) use_shm = 0;
526         else
527         {
528                 XShmSegmentInfo test_shm;
529                 XImage *test_image;
530                 unsigned char *data;
531                 test_image = XShmCreateImage(window->display, window->vis, window->default_depth,
532                 ZPixmap, (char*)NULL, &test_shm, 5, 5);
534                 test_shm.shmid = shmget(IPC_PRIVATE, 5 * test_image->bytes_per_line, (IPC_CREAT | 0777 ));
535                 data = (unsigned char *)shmat(test_shm.shmid, NULL, 0);
536         shmctl(test_shm.shmid, IPC_RMID, 0);
537                 BC_Resources::error = 0;
538                 XShmAttach(window->display, &test_shm);
539         XSync(window->display, False);
540                 if(BC_Resources::error) use_shm = 0;
541                 XDestroyImage(test_image);
542                 shmdt(test_shm.shmaddr);
543         }
544 //      XSetErrorHandler(0);
545         return 0;
548 int BC_Resources::get_top_border()
550         return display_info->get_top_border();
553 int BC_Resources::get_left_border()
555         return display_info->get_left_border();
558 int BC_Resources::get_right_border()
560         return display_info->get_right_border();
563 int BC_Resources::get_bottom_border()
565         return display_info->get_bottom_border();
569 int BC_Resources::get_bg_color() { return bg_color; }
571 int BC_Resources::get_bg_shadow1() { return bg_shadow1; }
573 int BC_Resources::get_bg_shadow2() { return bg_shadow2; }
575 int BC_Resources::get_bg_light1() { return bg_light1; }
577 int BC_Resources::get_bg_light2() { return bg_light2; }