1 #include "bcdisplayinfo.h"
3 #include "bclistbox.inc"
4 #include "bcresources.h"
6 #include "bcwindowbase.h"
8 #include "colormodels.h"
16 #include <X11/extensions/XShm.h>
20 #define _(String) gettext(String)
21 #define gettext_noop(String) String
22 #define N_(String) gettext_noop (String)
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 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)
41 char* BC_Resources::small_font = N_("-*-helvetica-medium-r-normal-*-10-*");
42 char* BC_Resources::medium_font = N_("-*-helvetica-bold-r-normal-*-14-*");
43 char* BC_Resources::large_font = N_("-*-helvetica-bold-r-normal-*-18-*");
44 char* BC_Resources::small_fontset = "6x12,*";
45 char* BC_Resources::medium_fontset = "7x14,*";
46 char* BC_Resources::large_fontset = "8x16,*";
48 suffix_to_type_t BC_Resources::suffix_to_type[] =
52 { "mp2", ICON_SOUND },
53 { "mp3", ICON_SOUND },
59 BC_Signals* BC_Resources::signal_handler = 0;
61 int BC_Resources::x_error_handler(Display *display, XErrorEvent *event)
64 XGetErrorText(event->display, event->error_code, string, 1024);
65 // printf("BC_Resources::x_error_handler: %s\n", string);
66 BC_Resources::error = 1;
72 BC_Resources::BC_Resources()
74 display_info = new BC_DisplayInfo("", 0);
76 #include "images/cancel_up_png.h"
77 #include "images/cancel_hi_png.h"
78 #include "images/cancel_dn_png.h"
79 static VFrame* default_cancel_images[] =
81 new VFrame(cancel_up_png),
82 new VFrame(cancel_hi_png),
83 new VFrame(cancel_dn_png)
86 #include "images/ok_up_png.h"
87 #include "images/ok_hi_png.h"
88 #include "images/ok_dn_png.h"
89 static VFrame* default_ok_images[] =
91 new VFrame(ok_up_png),
92 new VFrame(ok_hi_png),
96 #include "images/usethis_up_png.h"
97 #include "images/usethis_uphi_png.h"
98 #include "images/usethis_dn_png.h"
99 static VFrame* default_usethis_images[] =
101 new VFrame(usethis_up_png),
102 new VFrame(usethis_uphi_png),
103 new VFrame(usethis_dn_png)
106 #include "images/checkbox_checked_png.h"
107 #include "images/checkbox_down_png.h"
108 #include "images/checkbox_checkedhi_png.h"
109 #include "images/checkbox_up_png.h"
110 #include "images/checkbox_uphi_png.h"
111 static VFrame* default_checkbox_images[] =
113 new VFrame(checkbox_up_png),
114 new VFrame(checkbox_uphi_png),
115 new VFrame(checkbox_checked_png),
116 new VFrame(checkbox_down_png),
117 new VFrame(checkbox_checkedhi_png)
120 #include "images/radial_checked_png.h"
121 #include "images/radial_down_png.h"
122 #include "images/radial_checkedhi_png.h"
123 #include "images/radial_up_png.h"
124 #include "images/radial_uphi_png.h"
125 static VFrame* default_radial_images[] =
127 new VFrame(radial_up_png),
128 new VFrame(radial_uphi_png),
129 new VFrame(radial_checked_png),
130 new VFrame(radial_down_png),
131 new VFrame(radial_checkedhi_png)
134 static VFrame* default_label_images[] =
136 new VFrame(radial_up_png),
137 new VFrame(radial_uphi_png),
138 new VFrame(radial_checked_png),
139 new VFrame(radial_down_png),
140 new VFrame(radial_checkedhi_png)
144 #include "images/file_text_up_png.h"
145 #include "images/file_text_uphi_png.h"
146 #include "images/file_text_dn_png.h"
147 #include "images/file_icons_up_png.h"
148 #include "images/file_icons_uphi_png.h"
149 #include "images/file_icons_dn_png.h"
150 #include "images/file_newfolder_up_png.h"
151 #include "images/file_newfolder_uphi_png.h"
152 #include "images/file_newfolder_dn_png.h"
153 #include "images/file_updir_up_png.h"
154 #include "images/file_updir_uphi_png.h"
155 #include "images/file_updir_dn_png.h"
156 static VFrame* default_filebox_text_images[] =
158 new VFrame(file_text_up_png),
159 new VFrame(file_text_uphi_png),
160 new VFrame(file_text_dn_png)
163 static VFrame* default_filebox_icons_images[] =
165 new VFrame(file_icons_up_png),
166 new VFrame(file_icons_uphi_png),
167 new VFrame(file_icons_dn_png)
170 static VFrame* default_filebox_updir_images[] =
172 new VFrame(file_updir_up_png),
173 new VFrame(file_updir_uphi_png),
174 new VFrame(file_updir_dn_png)
177 static VFrame* default_filebox_newfolder_images[] =
179 new VFrame(file_newfolder_up_png),
180 new VFrame(file_newfolder_uphi_png),
181 new VFrame(file_newfolder_dn_png)
184 #include "images/listbox_button_dn_png.h"
185 #include "images/listbox_button_hi_png.h"
186 #include "images/listbox_button_up_png.h"
187 static VFrame* default_listbox_button[] =
189 new VFrame(listbox_button_up_png),
190 new VFrame(listbox_button_hi_png),
191 new VFrame(listbox_button_dn_png)
193 listbox_button = default_listbox_button;
195 #include "images/list_bg_png.h"
196 static VFrame* default_listbox_bg = new VFrame(list_bg_png);
197 listbox_bg = default_listbox_bg;
199 #include "images/listbox_expandchecked_png.h"
200 #include "images/listbox_expandcheckedhi_png.h"
201 #include "images/listbox_expanddn_png.h"
202 #include "images/listbox_expandup_png.h"
203 #include "images/listbox_expanduphi_png.h"
204 static VFrame* default_listbox_expand[] =
206 new VFrame(listbox_expandup_png),
207 new VFrame(listbox_expanduphi_png),
208 new VFrame(listbox_expandchecked_png),
209 new VFrame(listbox_expanddn_png),
210 new VFrame(listbox_expandcheckedhi_png),
212 listbox_expand = default_listbox_expand;
215 #include "images/horizontal_slider_bg_up_png.h"
216 #include "images/horizontal_slider_bg_hi_png.h"
217 #include "images/horizontal_slider_bg_dn_png.h"
218 #include "images/horizontal_slider_fg_up_png.h"
219 #include "images/horizontal_slider_fg_hi_png.h"
220 #include "images/horizontal_slider_fg_dn_png.h"
221 static VFrame *default_horizontal_slider_data[] =
223 new VFrame(horizontal_slider_fg_up_png),
224 new VFrame(horizontal_slider_fg_hi_png),
225 new VFrame(horizontal_slider_fg_dn_png),
226 new VFrame(horizontal_slider_bg_up_png),
227 new VFrame(horizontal_slider_bg_hi_png),
228 new VFrame(horizontal_slider_bg_dn_png),
231 #include "images/vertical_slider_bg_up_png.h"
232 #include "images/vertical_slider_bg_hi_png.h"
233 #include "images/vertical_slider_bg_dn_png.h"
234 #include "images/vertical_slider_fg_up_png.h"
235 #include "images/vertical_slider_fg_hi_png.h"
236 #include "images/vertical_slider_fg_dn_png.h"
237 static VFrame *default_vertical_slider_data[] =
239 new VFrame(vertical_slider_fg_up_png),
240 new VFrame(vertical_slider_fg_hi_png),
241 new VFrame(vertical_slider_fg_dn_png),
242 new VFrame(vertical_slider_bg_up_png),
243 new VFrame(vertical_slider_bg_hi_png),
244 new VFrame(vertical_slider_bg_dn_png),
246 horizontal_slider_data = default_horizontal_slider_data;
247 vertical_slider_data = default_vertical_slider_data;
249 #include "images/pot_hi_png.h"
250 #include "images/pot_up_png.h"
251 #include "images/pot_dn_png.h"
252 static VFrame *default_pot_images[] =
254 new VFrame(pot_up_png),
255 new VFrame(pot_hi_png),
256 new VFrame(pot_dn_png)
259 #include "images/progress_up_png.h"
260 #include "images/progress_hi_png.h"
261 static VFrame* default_progress_images[] =
263 new VFrame(progress_up_png),
264 new VFrame(progress_hi_png)
268 #include "images/pan_up_png.h"
269 #include "images/pan_hi_png.h"
270 #include "images/pan_popup_png.h"
271 #include "images/pan_channel_png.h"
272 #include "images/pan_stick_png.h"
273 #include "images/pan_channel_small_png.h"
274 #include "images/pan_stick_small_png.h"
275 static VFrame* default_pan_data[] =
277 new VFrame(pan_up_png),
278 new VFrame(pan_hi_png),
279 new VFrame(pan_popup_png),
280 new VFrame(pan_channel_png),
281 new VFrame(pan_stick_png),
282 new VFrame(pan_channel_small_png),
283 new VFrame(pan_stick_small_png)
285 pan_data = default_pan_data;
286 pan_text_color = YELLOW;
288 #include "images/7seg_small/0_png.h"
289 #include "images/7seg_small/1_png.h"
290 #include "images/7seg_small/2_png.h"
291 #include "images/7seg_small/3_png.h"
292 #include "images/7seg_small/4_png.h"
293 #include "images/7seg_small/5_png.h"
294 #include "images/7seg_small/6_png.h"
295 #include "images/7seg_small/7_png.h"
296 #include "images/7seg_small/8_png.h"
297 #include "images/7seg_small/9_png.h"
298 #include "images/7seg_small/colon_png.h"
299 #include "images/7seg_small/period_png.h"
300 #include "images/7seg_small/a_png.h"
301 #include "images/7seg_small/b_png.h"
302 #include "images/7seg_small/c_png.h"
303 #include "images/7seg_small/d_png.h"
304 #include "images/7seg_small/e_png.h"
305 #include "images/7seg_small/f_png.h"
306 #include "images/7seg_small/space_png.h"
307 #include "images/7seg_small/dash_png.h"
308 static VFrame* default_medium_7segment[] =
320 new VFrame(colon_png),
321 new VFrame(period_png),
328 new VFrame(space_png),
332 #include "images/tumble_bottomdn_png.h"
333 #include "images/tumble_topdn_png.h"
334 #include "images/tumble_hi_png.h"
335 #include "images/tumble_up_png.h"
336 static VFrame* default_tumbler_data[] =
338 new VFrame(tumble_up_png),
339 new VFrame(tumble_hi_png),
340 new VFrame(tumble_bottomdn_png),
341 new VFrame(tumble_topdn_png)
344 #include "images/xmeter_normal_png.h"
345 #include "images/xmeter_green_png.h"
346 #include "images/xmeter_red_png.h"
347 #include "images/xmeter_yellow_png.h"
348 #include "images/over_horiz_png.h"
349 #include "images/ymeter_normal_png.h"
350 #include "images/ymeter_green_png.h"
351 #include "images/ymeter_red_png.h"
352 #include "images/ymeter_yellow_png.h"
353 #include "images/over_vertical_png.h"
354 static VFrame* default_xmeter_data[] =
356 new VFrame(xmeter_normal_png),
357 new VFrame(xmeter_green_png),
358 new VFrame(xmeter_red_png),
359 new VFrame(xmeter_yellow_png),
360 new VFrame(over_horiz_png)
363 static VFrame* default_ymeter_data[] =
365 new VFrame(ymeter_normal_png),
366 new VFrame(ymeter_green_png),
367 new VFrame(ymeter_red_png),
368 new VFrame(ymeter_yellow_png),
369 new VFrame(over_vertical_png)
372 #include "images/generic_up_png.h"
373 #include "images/generic_hi_png.h"
374 #include "images/generic_dn_png.h"
376 static VFrame* default_generic_button_data[] =
378 new VFrame(generic_up_png),
379 new VFrame(generic_hi_png),
380 new VFrame(generic_dn_png)
383 generic_button_images = default_generic_button_data;
388 #include "images/hscroll_handle_up_png.h"
389 #include "images/hscroll_handle_hi_png.h"
390 #include "images/hscroll_handle_dn_png.h"
391 #include "images/hscroll_handle_bg_png.h"
392 #include "images/hscroll_left_up_png.h"
393 #include "images/hscroll_left_hi_png.h"
394 #include "images/hscroll_left_dn_png.h"
395 #include "images/hscroll_right_up_png.h"
396 #include "images/hscroll_right_hi_png.h"
397 #include "images/hscroll_right_dn_png.h"
398 #include "images/vscroll_handle_up_png.h"
399 #include "images/vscroll_handle_hi_png.h"
400 #include "images/vscroll_handle_dn_png.h"
401 #include "images/vscroll_handle_bg_png.h"
402 #include "images/vscroll_left_up_png.h"
403 #include "images/vscroll_left_hi_png.h"
404 #include "images/vscroll_left_dn_png.h"
405 #include "images/vscroll_right_up_png.h"
406 #include "images/vscroll_right_hi_png.h"
407 #include "images/vscroll_right_dn_png.h"
408 static VFrame *default_hscroll_data[] =
410 new VFrame(hscroll_handle_up_png),
411 new VFrame(hscroll_handle_hi_png),
412 new VFrame(hscroll_handle_dn_png),
413 new VFrame(hscroll_handle_bg_png),
414 new VFrame(hscroll_left_up_png),
415 new VFrame(hscroll_left_hi_png),
416 new VFrame(hscroll_left_dn_png),
417 new VFrame(hscroll_right_up_png),
418 new VFrame(hscroll_right_hi_png),
419 new VFrame(hscroll_right_dn_png)
421 static VFrame *default_vscroll_data[] =
423 new VFrame(vscroll_handle_up_png),
424 new VFrame(vscroll_handle_hi_png),
425 new VFrame(vscroll_handle_dn_png),
426 new VFrame(vscroll_handle_bg_png),
427 new VFrame(vscroll_left_up_png),
428 new VFrame(vscroll_left_hi_png),
429 new VFrame(vscroll_left_dn_png),
430 new VFrame(vscroll_right_up_png),
431 new VFrame(vscroll_right_hi_png),
432 new VFrame(vscroll_right_dn_png)
434 hscroll_data = default_hscroll_data;
435 vscroll_data = default_vscroll_data;
447 bg_light2 = bg_color;
449 button_light = WHITE; // bright corner
450 button_highlighted = LTGREY; // face when highlighted
451 button_down = MDGREY; // face when down
452 button_up = MEGREY; // face when up
453 button_shadow = DKGREY; // dark corner
455 tumble_data = default_tumbler_data;
456 tumble_duration = 150;
458 ok_images = default_ok_images;
459 cancel_images = default_cancel_images;
460 usethis_button_images = default_usethis_images;
462 filebox_text_images = default_filebox_text_images;
463 filebox_icons_images = default_filebox_icons_images;
464 filebox_updir_images = default_filebox_updir_images;
465 filebox_newfolder_images = default_filebox_newfolder_images;
467 checkbox_images = default_checkbox_images;
468 radial_images = default_radial_images;
469 label_images = default_label_images;
472 menu_highlighted = LTBLUE;
475 menu_shadow = DKCYAN;
477 text_default = BLACK;
478 text_background = WHITE;
479 highlight_inverse = WHITE ^ BLUE;
480 text_highlight = BLUE;
482 // Delays must all be different for repeaters
486 tooltip_delay = 1000;
487 tooltip_bg_color = YELLOW;
488 tooltips_enabled = 1;
490 filebox_mode = LISTBOX_TEXT;
491 sprintf(filebox_filter, "*");
496 pot_images = default_pot_images;
497 pot_x1 = pot_images[0]->get_w() / 2 - 2;
498 pot_y1 = pot_images[0]->get_h() / 2 - 2;;
501 progress_images = default_progress_images;
503 xmeter_images = default_xmeter_data;
504 ymeter_images = default_ymeter_data;
505 meter_font = SMALLFONT_3D;
506 meter_font_color = RED;
509 medium_7segment = default_medium_7segment;
511 if(use_fontset) setlocale(LC_ALL, "");
513 recursive_resizing = 1;
518 BC_Resources::~BC_Resources()
522 int BC_Resources::initialize_display(BC_WindowBase *window)
524 // Set up IPC cleanup handlers
527 // Test for shm. Must come before yuv test
533 int BC_Resources::init_shm(BC_WindowBase *window)
536 XSetErrorHandler(BC_Resources::x_error_handler);
538 if(!XShmQueryExtension(window->display)) use_shm = 0;
541 XShmSegmentInfo test_shm;
544 test_image = XShmCreateImage(window->display, window->vis, window->default_depth,
545 ZPixmap, (char*)NULL, &test_shm, 5, 5);
547 test_shm.shmid = shmget(IPC_PRIVATE, 5 * test_image->bytes_per_line, (IPC_CREAT | 0777 ));
548 data = (unsigned char *)shmat(test_shm.shmid, NULL, 0);
549 shmctl(test_shm.shmid, IPC_RMID, 0);
550 BC_Resources::error = 0;
551 XShmAttach(window->display, &test_shm);
552 XSync(window->display, False);
553 if(BC_Resources::error) use_shm = 0;
554 XDestroyImage(test_image);
555 shmdt(test_shm.shmaddr);
557 // XSetErrorHandler(0);
561 int BC_Resources::get_top_border()
563 return display_info->get_top_border();
566 int BC_Resources::get_left_border()
568 return display_info->get_left_border();
571 int BC_Resources::get_right_border()
573 return display_info->get_right_border();
576 int BC_Resources::get_bottom_border()
578 return display_info->get_bottom_border();
582 int BC_Resources::get_bg_color() { return bg_color; }
584 int BC_Resources::get_bg_shadow1() { return bg_shadow1; }
586 int BC_Resources::get_bg_shadow2() { return bg_shadow2; }
588 int BC_Resources::get_bg_light1() { return bg_light1; }
590 int BC_Resources::get_bg_light2() { return bg_light2; }