1 #include "bcdisplayinfo.h"
3 #include "bclistbox.inc"
4 #include "bcresources.h"
6 #include "bcsynchronous.h"
7 #include "bcwindowbase.h"
9 #include "colormodels.h"
17 #include <X11/extensions/XShm.h>
24 int BC_Resources::error = 0;
26 VFrame* BC_Resources::bg_image = 0;
27 VFrame* BC_Resources::menu_bg = 0;
29 #include "images/file_film_png.h"
30 #include "images/file_folder_png.h"
31 #include "images/file_sound_png.h"
32 #include "images/file_unknown_png.h"
33 #include "images/file_column_png.h"
34 VFrame* BC_Resources::type_to_icon[] =
36 new VFrame(file_folder_png),
37 new VFrame(file_unknown_png),
38 new VFrame(file_film_png),
39 new VFrame(file_sound_png),
40 new VFrame(file_column_png)
43 char* BC_Resources::small_font = N_("-*-helvetica-medium-r-normal-*-10-*");
44 char* BC_Resources::small_font2 = N_("-*-helvetica-medium-r-normal-*-11-*");
45 char* BC_Resources::medium_font = N_("-*-helvetica-bold-r-normal-*-14-*");
46 char* BC_Resources::medium_font2 = N_("-*-helvetica-bold-r-normal-*-14-*");
47 char* BC_Resources::large_font = N_("-*-helvetica-bold-r-normal-*-18-*");
48 char* BC_Resources::large_font2 = N_("-*-helvetica-bold-r-normal-*-20-*");
50 char* BC_Resources::small_fontset = "6x12,*";
51 char* BC_Resources::medium_fontset = "7x14,*";
52 char* BC_Resources::large_fontset = "8x16,*";
54 char* BC_Resources::small_font_xft = N_("-*-luxi sans-*-r-*-*-12-*-*-*-*-*-*-*");
55 char* BC_Resources::small_font_xft2 = N_("-microsoft-verdana-*-*-*-*-*-*-*-*-*-*-*-*");
56 char* BC_Resources::medium_font_xft = N_("-*-luxi sans-*-r-*-*-16-*-*-*-*-*-*-*");
57 char* BC_Resources::medium_font_xft2 = N_("-microsoft-verdana-*-*-*-*-*-*-*-*-*-*-*-*");
58 char* BC_Resources::large_font_xft = N_("-*-luxi sans-bold-r-*-*-20-*-*-*-*-*-*-*");
59 char* BC_Resources::large_font_xft2 = N_("-microsoft-verdana-*-*-*-*-*-*-*-*-*-*-*-*");
61 suffix_to_type_t BC_Resources::suffix_to_type[] =
65 { "mp2", ICON_SOUND },
66 { "mp3", ICON_SOUND },
72 BC_Signals* BC_Resources::signal_handler = 0;
75 int BC_Resources::x_error_handler(Display *display, XErrorEvent *event)
78 // XGetErrorText(event->display, event->error_code, string, 1024);
79 // printf("BC_Resources::x_error_handler: error_code=%d opcode=%d,%d %s\n",
81 // event->request_code,
86 BC_Resources::error = 1;
87 // This bug only happens in 32 bit mode.
89 BC_WindowBase::get_resources()->use_xft = 0;
95 BC_Resources::BC_Resources()
98 display_info = new BC_DisplayInfo("", 0);
99 id_lock = new Mutex("BC_Resources::id_lock");
100 create_window_lock = new Mutex("BC_Resources::create_window_lock", 1);
103 for(int i = 0; i < FILEBOX_HISTORY_SIZE; i++)
104 filebox_history[i][0] = 0;
113 #include "images/bar_png.h"
114 static VFrame* default_bar = new VFrame(bar_png);
115 bar_data = default_bar;
119 #include "images/cancel_up_png.h"
120 #include "images/cancel_hi_png.h"
121 #include "images/cancel_dn_png.h"
122 static VFrame* default_cancel_images[] =
124 new VFrame(cancel_up_png),
125 new VFrame(cancel_hi_png),
126 new VFrame(cancel_dn_png)
129 #include "images/ok_up_png.h"
130 #include "images/ok_hi_png.h"
131 #include "images/ok_dn_png.h"
132 static VFrame* default_ok_images[] =
134 new VFrame(ok_up_png),
135 new VFrame(ok_hi_png),
136 new VFrame(ok_dn_png)
139 #include "images/usethis_up_png.h"
140 #include "images/usethis_uphi_png.h"
141 #include "images/usethis_dn_png.h"
142 static VFrame* default_usethis_images[] =
144 new VFrame(usethis_up_png),
145 new VFrame(usethis_uphi_png),
146 new VFrame(usethis_dn_png)
150 #include "images/checkbox_checked_png.h"
151 #include "images/checkbox_dn_png.h"
152 #include "images/checkbox_checkedhi_png.h"
153 #include "images/checkbox_up_png.h"
154 #include "images/checkbox_hi_png.h"
155 static VFrame* default_checkbox_images[] =
157 new VFrame(checkbox_up_png),
158 new VFrame(checkbox_hi_png),
159 new VFrame(checkbox_checked_png),
160 new VFrame(checkbox_dn_png),
161 new VFrame(checkbox_checkedhi_png)
164 #include "images/radial_checked_png.h"
165 #include "images/radial_dn_png.h"
166 #include "images/radial_checkedhi_png.h"
167 #include "images/radial_up_png.h"
168 #include "images/radial_hi_png.h"
169 static VFrame* default_radial_images[] =
171 new VFrame(radial_up_png),
172 new VFrame(radial_hi_png),
173 new VFrame(radial_checked_png),
174 new VFrame(radial_dn_png),
175 new VFrame(radial_checkedhi_png)
178 static VFrame* default_label_images[] =
180 new VFrame(radial_up_png),
181 new VFrame(radial_hi_png),
182 new VFrame(radial_checked_png),
183 new VFrame(radial_dn_png),
184 new VFrame(radial_checkedhi_png)
188 #include "images/file_text_up_png.h"
189 #include "images/file_text_hi_png.h"
190 #include "images/file_text_dn_png.h"
191 #include "images/file_icons_up_png.h"
192 #include "images/file_icons_hi_png.h"
193 #include "images/file_icons_dn_png.h"
194 #include "images/file_newfolder_up_png.h"
195 #include "images/file_newfolder_hi_png.h"
196 #include "images/file_newfolder_dn_png.h"
197 #include "images/file_updir_up_png.h"
198 #include "images/file_updir_hi_png.h"
199 #include "images/file_updir_dn_png.h"
200 #include "images/file_delete_up_png.h"
201 #include "images/file_delete_hi_png.h"
202 #include "images/file_delete_dn_png.h"
203 #include "images/file_reload_up_png.h"
204 #include "images/file_reload_hi_png.h"
205 #include "images/file_reload_dn_png.h"
206 static VFrame* default_filebox_text_images[] =
208 new VFrame(file_text_up_png),
209 new VFrame(file_text_hi_png),
210 new VFrame(file_text_dn_png)
213 static VFrame* default_filebox_icons_images[] =
215 new VFrame(file_icons_up_png),
216 new VFrame(file_icons_hi_png),
217 new VFrame(file_icons_dn_png)
220 static VFrame* default_filebox_updir_images[] =
222 new VFrame(file_updir_up_png),
223 new VFrame(file_updir_hi_png),
224 new VFrame(file_updir_dn_png)
227 static VFrame* default_filebox_newfolder_images[] =
229 new VFrame(file_newfolder_up_png),
230 new VFrame(file_newfolder_hi_png),
231 new VFrame(file_newfolder_dn_png)
234 static VFrame* default_filebox_delete_images[] =
236 new VFrame(file_delete_up_png),
237 new VFrame(file_delete_hi_png),
238 new VFrame(file_delete_dn_png)
241 static VFrame* default_filebox_reload_images[] =
243 new VFrame(file_reload_up_png),
244 new VFrame(file_reload_hi_png),
245 new VFrame(file_reload_dn_png)
248 #include "images/listbox_button_dn_png.h"
249 #include "images/listbox_button_hi_png.h"
250 #include "images/listbox_button_up_png.h"
251 #include "images/listbox_button_disabled_png.h"
\r
252 static VFrame* default_listbox_button[] =
254 new VFrame(listbox_button_up_png),
255 new VFrame(listbox_button_hi_png),
256 new VFrame(listbox_button_dn_png),
257 new VFrame(listbox_button_disabled_png)
259 listbox_button = default_listbox_button;
261 #include "images/list_bg_png.h"
262 static VFrame* default_listbox_bg = new VFrame(list_bg_png);
263 listbox_bg = default_listbox_bg;
265 #include "images/listbox_expandchecked_png.h"
266 #include "images/listbox_expandcheckedhi_png.h"
267 #include "images/listbox_expanddn_png.h"
268 #include "images/listbox_expandup_png.h"
269 #include "images/listbox_expanduphi_png.h"
270 static VFrame* default_listbox_expand[] =
272 new VFrame(listbox_expandup_png),
273 new VFrame(listbox_expanduphi_png),
274 new VFrame(listbox_expandchecked_png),
275 new VFrame(listbox_expanddn_png),
276 new VFrame(listbox_expandcheckedhi_png),
278 listbox_expand = default_listbox_expand;
280 #include "images/listbox_columnup_png.h"
281 #include "images/listbox_columnhi_png.h"
282 #include "images/listbox_columndn_png.h"
283 static VFrame* default_listbox_column[] =
285 new VFrame(listbox_columnup_png),
286 new VFrame(listbox_columnhi_png),
287 new VFrame(listbox_columndn_png)
289 listbox_column = default_listbox_column;
292 #include "images/listbox_up_png.h"
293 #include "images/listbox_dn_png.h"
294 listbox_up = new VFrame(listbox_up_png);
295 listbox_dn = new VFrame(listbox_dn_png);
296 listbox_title_margin = 0;
297 listbox_title_color = BLACK;
298 listbox_title_hotspot = 5;
300 listbox_border1 = DKGREY;
301 listbox_border2_hi = RED;
302 listbox_border2 = BLACK;
303 listbox_border3_hi = RED;
304 listbox_border3 = MEGREY;
305 listbox_border4 = WHITE;
306 listbox_selected = BLUE;
307 listbox_highlighted = LTGREY;
308 listbox_inactive = WHITE;
309 listbox_text = BLACK;
311 #include "images/pot_hi_png.h"
312 #include "images/pot_up_png.h"
313 #include "images/pot_dn_png.h"
314 static VFrame *default_pot_images[] =
316 new VFrame(pot_up_png),
317 new VFrame(pot_hi_png),
318 new VFrame(pot_dn_png)
321 #include "images/progress_up_png.h"
322 #include "images/progress_hi_png.h"
323 static VFrame* default_progress_images[] =
325 new VFrame(progress_up_png),
326 new VFrame(progress_hi_png)
330 pan_text_color = YELLOW;
332 #include "images/7seg_small/0_png.h"
333 #include "images/7seg_small/1_png.h"
334 #include "images/7seg_small/2_png.h"
335 #include "images/7seg_small/3_png.h"
336 #include "images/7seg_small/4_png.h"
337 #include "images/7seg_small/5_png.h"
338 #include "images/7seg_small/6_png.h"
339 #include "images/7seg_small/7_png.h"
340 #include "images/7seg_small/8_png.h"
341 #include "images/7seg_small/9_png.h"
342 #include "images/7seg_small/colon_png.h"
343 #include "images/7seg_small/period_png.h"
344 #include "images/7seg_small/a_png.h"
345 #include "images/7seg_small/b_png.h"
346 #include "images/7seg_small/c_png.h"
347 #include "images/7seg_small/d_png.h"
348 #include "images/7seg_small/e_png.h"
349 #include "images/7seg_small/f_png.h"
350 #include "images/7seg_small/space_png.h"
351 #include "images/7seg_small/dash_png.h"
352 static VFrame* default_medium_7segment[] =
364 new VFrame(colon_png),
365 new VFrame(period_png),
372 new VFrame(space_png),
376 generic_button_margin = 15;
377 draw_clock_background=1;
386 bg_light2 = bg_color;
388 default_text_color = BLACK;
389 disabled_text_color = MEGREY;
391 button_light = WHITE; // bright corner
392 button_highlighted = 0xffe000; // face when highlighted
393 button_down = MDGREY; // face when down
394 button_up = 0xffc000; // face when up
395 button_shadow = DKGREY; // dark corner
396 button_uphighlighted = RED; // upper side when highlighted
399 tumble_duration = 150;
401 ok_images = default_ok_images;
402 cancel_images = default_cancel_images;
403 usethis_button_images = default_usethis_images;
404 filebox_descend_images = default_ok_images;
407 menu_highlighted = LTBLUE;
410 menu_shadow = DKCYAN;
416 popupmenu_images = 0;
417 popupmenu_margin = 10;
418 popupmenu_triangle_margin = 10;
421 menu_title_text = BLACK;
422 popup_title_text = BLACK;
423 menu_item_text = BLACK;
424 menu_highlighted_fontcolor = BLACK;
425 progress_text = BLACK;
429 text_default = BLACK;
430 highlight_inverse = WHITE ^ BLUE;
431 text_background = WHITE;
432 text_background_hi = LTYELLOW;
433 text_background_noborder_hi = LTGREY;
434 text_background_noborder = -1;
435 text_border1 = DKGREY;
436 text_border2 = BLACK;
437 text_border2_hi = RED;
438 text_border3 = MEGREY;
439 text_border3_hi = LTPINK;
440 text_border4 = WHITE;
441 text_highlight = BLUE;
442 text_inactive_highlight = MEGREY;
444 toggle_highlight_bg = 0;
445 toggle_text_margin = 0;
447 // Delays must all be different for repeaters
451 tooltip_delay = 1000;
452 tooltip_bg_color = YELLOW;
453 tooltips_enabled = 1;
455 filebox_margin = 110;
457 filebox_mode = LISTBOX_TEXT;
458 sprintf(filebox_filter, "*");
461 filebox_columntype[0] = FILEBOX_NAME;
462 filebox_columntype[1] = FILEBOX_SIZE;
463 filebox_columntype[2] = FILEBOX_DATE;
464 filebox_columntype[3] = FILEBOX_EXTENSION;
465 filebox_columnwidth[0] = 200;
466 filebox_columnwidth[1] = 100;
467 filebox_columnwidth[2] = 100;
468 filebox_columnwidth[3] = 100;
469 dirbox_columntype[0] = FILEBOX_NAME;
470 dirbox_columntype[1] = FILEBOX_DATE;
471 dirbox_columnwidth[0] = 200;
472 dirbox_columnwidth[1] = 100;
474 filebox_text_images = default_filebox_text_images;
475 filebox_icons_images = default_filebox_icons_images;
476 filebox_updir_images = default_filebox_updir_images;
477 filebox_newfolder_images = default_filebox_newfolder_images;
478 filebox_delete_images = default_filebox_delete_images;
479 filebox_reload_images = default_filebox_reload_images;
480 directory_color = BLUE;
483 filebox_sortcolumn = 0;
484 filebox_sortorder = BC_ListBox::SORT_ASCENDING;
485 dirbox_sortcolumn = 0;
486 dirbox_sortorder = BC_ListBox::SORT_ASCENDING;
489 pot_images = default_pot_images;
491 pot_x1 = pot_images[0]->get_w() / 2 - pot_offset;
492 pot_y1 = pot_images[0]->get_h() / 2 - pot_offset;
494 pot_needle_color = BLACK;
496 progress_images = default_progress_images;
500 meter_font = SMALLFONT_3D;
501 meter_font_color = RED;
504 medium_7segment = default_medium_7segment;
506 audiovideo_color = RED;
510 // Xft has priority over font set
512 // But Xft dies in 32 bit mode after some amount of drawing.
520 recursive_resizing = 1;
525 BC_Resources::~BC_Resources()
529 int BC_Resources::initialize_display(BC_WindowBase *window)
531 // Set up IPC cleanup handlers
534 // Test for shm. Must come before yuv test
540 int BC_Resources::init_shm(BC_WindowBase *window)
543 XSetErrorHandler(BC_Resources::x_error_handler);
545 if(!XShmQueryExtension(window->display)) use_shm = 0;
548 XShmSegmentInfo test_shm;
551 test_image = XShmCreateImage(window->display, window->vis, window->default_depth,
552 ZPixmap, (char*)NULL, &test_shm, 5, 5);
554 test_shm.shmid = shmget(IPC_PRIVATE, 5 * test_image->bytes_per_line, (IPC_CREAT | 0777 ));
555 data = (unsigned char *)shmat(test_shm.shmid, NULL, 0);
556 shmctl(test_shm.shmid, IPC_RMID, 0);
557 BC_Resources::error = 0;
558 XShmAttach(window->display, &test_shm);
559 XSync(window->display, False);
560 if(BC_Resources::error) use_shm = 0;
561 XDestroyImage(test_image);
562 shmdt(test_shm.shmaddr);
564 // XSetErrorHandler(0);
571 BC_Synchronous* BC_Resources::get_synchronous()
576 void BC_Resources::set_synchronous(BC_Synchronous *synchronous)
578 this->synchronous = synchronous;
587 int BC_Resources::get_top_border()
589 return display_info->get_top_border();
592 int BC_Resources::get_left_border()
594 return display_info->get_left_border();
597 int BC_Resources::get_right_border()
599 return display_info->get_right_border();
602 int BC_Resources::get_bottom_border()
604 return display_info->get_bottom_border();
608 int BC_Resources::get_bg_color() { return bg_color; }
610 int BC_Resources::get_bg_shadow1() { return bg_shadow1; }
612 int BC_Resources::get_bg_shadow2() { return bg_shadow2; }
614 int BC_Resources::get_bg_light1() { return bg_light1; }
616 int BC_Resources::get_bg_light2() { return bg_light2; }
619 int BC_Resources::get_id()
621 id_lock->lock("BC_Resources::get_id");
628 void BC_Resources::set_signals(BC_Signals *signal_handler)
630 BC_Resources::signal_handler = signal_handler;
633 BC_Signals* BC_Resources::get_signals()
635 return BC_Resources::signal_handler;