00001 #include "bcdisplayinfo.h"
00002 #include "bcipc.h"
00003 #include "bclistbox.inc"
00004 #include "bcresources.h"
00005 #include "bcsignals.h"
00006 #include "bcsynchronous.h"
00007 #include "bcwindowbase.h"
00008 #include "colors.h"
00009 #include "colormodels.h"
00010 #include "fonts.h"
00011 #include "language.h"
00012 #include "vframe.h"
00013
00014 #include <string.h>
00015 #include <sys/ipc.h>
00016 #include <sys/shm.h>
00017 #include <X11/extensions/XShm.h>
00018 #include <unistd.h>
00019
00020
00021
00022
00023
00024 int BC_Resources::error = 0;
00025
00026 VFrame* BC_Resources::bg_image = 0;
00027 VFrame* BC_Resources::menu_bg = 0;
00028
00029 #include "images/file_film_png.h"
00030 #include "images/file_folder_png.h"
00031 #include "images/file_sound_png.h"
00032 #include "images/file_unknown_png.h"
00033 #include "images/file_column_png.h"
00034 VFrame* BC_Resources::type_to_icon[] =
00035 {
00036 new VFrame(file_folder_png),
00037 new VFrame(file_unknown_png),
00038 new VFrame(file_film_png),
00039 new VFrame(file_sound_png),
00040 new VFrame(file_column_png)
00041 };
00042
00043 char* BC_Resources::small_font = N_("-*-helvetica-medium-r-normal-*-10-*");
00044 char* BC_Resources::small_font2 = N_("-*-helvetica-medium-r-normal-*-11-*");
00045 char* BC_Resources::medium_font = N_("-*-helvetica-bold-r-normal-*-14-*");
00046 char* BC_Resources::medium_font2 = N_("-*-helvetica-bold-r-normal-*-14-*");
00047 char* BC_Resources::large_font = N_("-*-helvetica-bold-r-normal-*-18-*");
00048 char* BC_Resources::large_font2 = N_("-*-helvetica-bold-r-normal-*-20-*");
00049
00050 char* BC_Resources::small_fontset = "6x12,*";
00051 char* BC_Resources::medium_fontset = "7x14,*";
00052 char* BC_Resources::large_fontset = "8x16,*";
00053
00054 char* BC_Resources::small_font_xft = N_("-*-luxi sans-*-r-*-*-12-*-*-*-*-*-*-*");
00055 char* BC_Resources::small_font_xft2 = N_("-microsoft-verdana-*-*-*-*-*-*-*-*-*-*-*-*");
00056 char* BC_Resources::medium_font_xft = N_("-*-luxi sans-*-r-*-*-16-*-*-*-*-*-*-*");
00057 char* BC_Resources::medium_font_xft2 = N_("-microsoft-verdana-*-*-*-*-*-*-*-*-*-*-*-*");
00058 char* BC_Resources::large_font_xft = N_("-*-luxi sans-bold-r-*-*-20-*-*-*-*-*-*-*");
00059 char* BC_Resources::large_font_xft2 = N_("-microsoft-verdana-*-*-*-*-*-*-*-*-*-*-*-*");
00060
00061 suffix_to_type_t BC_Resources::suffix_to_type[] =
00062 {
00063 { "m2v", ICON_FILM },
00064 { "mov", ICON_FILM },
00065 { "mp2", ICON_SOUND },
00066 { "mp3", ICON_SOUND },
00067 { "mpg", ICON_FILM },
00068 { "vob", ICON_FILM },
00069 { "wav", ICON_SOUND }
00070 };
00071
00072 BC_Signals* BC_Resources::signal_handler = 0;
00073
00074
00075 int BC_Resources::x_error_handler(Display *display, XErrorEvent *event)
00076 {
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 BC_Resources::error = 1;
00087
00088 if(sizeof(long) == 4)
00089 BC_WindowBase::get_resources()->use_xft = 0;
00090 return 0;
00091 }
00092
00093
00094
00095 BC_Resources::BC_Resources()
00096 {
00097 synchronous = 0;
00098 display_info = new BC_DisplayInfo("", 0);
00099 id_lock = new Mutex("BC_Resources::id_lock");
00100 create_window_lock = new Mutex("BC_Resources::create_window_lock", 1);
00101 id = 0;
00102
00103 for(int i = 0; i < FILEBOX_HISTORY_SIZE; i++)
00104 filebox_history[i][0] = 0;
00105
00106 #ifdef HAVE_XFT
00107 XftInitFtLibrary();
00108 #endif
00109
00110 use_xvideo = 1;
00111
00112
00113 #include "images/bar_png.h"
00114 static VFrame* default_bar = new VFrame(bar_png);
00115 bar_data = default_bar;
00116
00117
00118
00119 #include "images/cancel_up_png.h"
00120 #include "images/cancel_hi_png.h"
00121 #include "images/cancel_dn_png.h"
00122 static VFrame* default_cancel_images[] =
00123 {
00124 new VFrame(cancel_up_png),
00125 new VFrame(cancel_hi_png),
00126 new VFrame(cancel_dn_png)
00127 };
00128
00129 #include "images/ok_up_png.h"
00130 #include "images/ok_hi_png.h"
00131 #include "images/ok_dn_png.h"
00132 static VFrame* default_ok_images[] =
00133 {
00134 new VFrame(ok_up_png),
00135 new VFrame(ok_hi_png),
00136 new VFrame(ok_dn_png)
00137 };
00138
00139 #include "images/usethis_up_png.h"
00140 #include "images/usethis_uphi_png.h"
00141 #include "images/usethis_dn_png.h"
00142 static VFrame* default_usethis_images[] =
00143 {
00144 new VFrame(usethis_up_png),
00145 new VFrame(usethis_uphi_png),
00146 new VFrame(usethis_dn_png)
00147 };
00148
00149
00150 #include "images/checkbox_checked_png.h"
00151 #include "images/checkbox_dn_png.h"
00152 #include "images/checkbox_checkedhi_png.h"
00153 #include "images/checkbox_up_png.h"
00154 #include "images/checkbox_hi_png.h"
00155 static VFrame* default_checkbox_images[] =
00156 {
00157 new VFrame(checkbox_up_png),
00158 new VFrame(checkbox_hi_png),
00159 new VFrame(checkbox_checked_png),
00160 new VFrame(checkbox_dn_png),
00161 new VFrame(checkbox_checkedhi_png)
00162 };
00163
00164 #include "images/radial_checked_png.h"
00165 #include "images/radial_dn_png.h"
00166 #include "images/radial_checkedhi_png.h"
00167 #include "images/radial_up_png.h"
00168 #include "images/radial_hi_png.h"
00169 static VFrame* default_radial_images[] =
00170 {
00171 new VFrame(radial_up_png),
00172 new VFrame(radial_hi_png),
00173 new VFrame(radial_checked_png),
00174 new VFrame(radial_dn_png),
00175 new VFrame(radial_checkedhi_png)
00176 };
00177
00178 static VFrame* default_label_images[] =
00179 {
00180 new VFrame(radial_up_png),
00181 new VFrame(radial_hi_png),
00182 new VFrame(radial_checked_png),
00183 new VFrame(radial_dn_png),
00184 new VFrame(radial_checkedhi_png)
00185 };
00186
00187
00188 #include "images/file_text_up_png.h"
00189 #include "images/file_text_hi_png.h"
00190 #include "images/file_text_dn_png.h"
00191 #include "images/file_icons_up_png.h"
00192 #include "images/file_icons_hi_png.h"
00193 #include "images/file_icons_dn_png.h"
00194 #include "images/file_newfolder_up_png.h"
00195 #include "images/file_newfolder_hi_png.h"
00196 #include "images/file_newfolder_dn_png.h"
00197 #include "images/file_updir_up_png.h"
00198 #include "images/file_updir_hi_png.h"
00199 #include "images/file_updir_dn_png.h"
00200 #include "images/file_delete_up_png.h"
00201 #include "images/file_delete_hi_png.h"
00202 #include "images/file_delete_dn_png.h"
00203 #include "images/file_reload_up_png.h"
00204 #include "images/file_reload_hi_png.h"
00205 #include "images/file_reload_dn_png.h"
00206 static VFrame* default_filebox_text_images[] =
00207 {
00208 new VFrame(file_text_up_png),
00209 new VFrame(file_text_hi_png),
00210 new VFrame(file_text_dn_png)
00211 };
00212
00213 static VFrame* default_filebox_icons_images[] =
00214 {
00215 new VFrame(file_icons_up_png),
00216 new VFrame(file_icons_hi_png),
00217 new VFrame(file_icons_dn_png)
00218 };
00219
00220 static VFrame* default_filebox_updir_images[] =
00221 {
00222 new VFrame(file_updir_up_png),
00223 new VFrame(file_updir_hi_png),
00224 new VFrame(file_updir_dn_png)
00225 };
00226
00227 static VFrame* default_filebox_newfolder_images[] =
00228 {
00229 new VFrame(file_newfolder_up_png),
00230 new VFrame(file_newfolder_hi_png),
00231 new VFrame(file_newfolder_dn_png)
00232 };
00233
00234 static VFrame* default_filebox_delete_images[] =
00235 {
00236 new VFrame(file_delete_up_png),
00237 new VFrame(file_delete_hi_png),
00238 new VFrame(file_delete_dn_png)
00239 };
00240
00241 static VFrame* default_filebox_reload_images[] =
00242 {
00243 new VFrame(file_reload_up_png),
00244 new VFrame(file_reload_hi_png),
00245 new VFrame(file_reload_dn_png)
00246 };
00247
00248 #include "images/listbox_button_dn_png.h"
00249 #include "images/listbox_button_hi_png.h"
00250 #include "images/listbox_button_up_png.h"
00251 #include "images/listbox_button_disabled_png.h"
00252 static VFrame* default_listbox_button[] =
00253 {
00254 new VFrame(listbox_button_up_png),
00255 new VFrame(listbox_button_hi_png),
00256 new VFrame(listbox_button_dn_png),
00257 new VFrame(listbox_button_disabled_png)
00258 };
00259 listbox_button = default_listbox_button;
00260
00261 #include "images/list_bg_png.h"
00262 static VFrame* default_listbox_bg = new VFrame(list_bg_png);
00263 listbox_bg = default_listbox_bg;
00264
00265 #include "images/listbox_expandchecked_png.h"
00266 #include "images/listbox_expandcheckedhi_png.h"
00267 #include "images/listbox_expanddn_png.h"
00268 #include "images/listbox_expandup_png.h"
00269 #include "images/listbox_expanduphi_png.h"
00270 static VFrame* default_listbox_expand[] =
00271 {
00272 new VFrame(listbox_expandup_png),
00273 new VFrame(listbox_expanduphi_png),
00274 new VFrame(listbox_expandchecked_png),
00275 new VFrame(listbox_expanddn_png),
00276 new VFrame(listbox_expandcheckedhi_png),
00277 };
00278 listbox_expand = default_listbox_expand;
00279
00280 #include "images/listbox_columnup_png.h"
00281 #include "images/listbox_columnhi_png.h"
00282 #include "images/listbox_columndn_png.h"
00283 static VFrame* default_listbox_column[] =
00284 {
00285 new VFrame(listbox_columnup_png),
00286 new VFrame(listbox_columnhi_png),
00287 new VFrame(listbox_columndn_png)
00288 };
00289 listbox_column = default_listbox_column;
00290
00291
00292 #include "images/listbox_up_png.h"
00293 #include "images/listbox_dn_png.h"
00294 listbox_up = new VFrame(listbox_up_png);
00295 listbox_dn = new VFrame(listbox_dn_png);
00296 listbox_title_margin = 0;
00297 listbox_title_color = BLACK;
00298 listbox_title_hotspot = 5;
00299
00300 listbox_border1 = DKGREY;
00301 listbox_border2_hi = RED;
00302 listbox_border2 = BLACK;
00303 listbox_border3_hi = RED;
00304 listbox_border3 = MEGREY;
00305 listbox_border4 = WHITE;
00306 listbox_selected = BLUE;
00307 listbox_highlighted = LTGREY;
00308 listbox_inactive = WHITE;
00309 listbox_text = BLACK;
00310
00311 #include "images/pot_hi_png.h"
00312 #include "images/pot_up_png.h"
00313 #include "images/pot_dn_png.h"
00314 static VFrame *default_pot_images[] =
00315 {
00316 new VFrame(pot_up_png),
00317 new VFrame(pot_hi_png),
00318 new VFrame(pot_dn_png)
00319 };
00320
00321 #include "images/progress_up_png.h"
00322 #include "images/progress_hi_png.h"
00323 static VFrame* default_progress_images[] =
00324 {
00325 new VFrame(progress_up_png),
00326 new VFrame(progress_hi_png)
00327 };
00328
00329 pan_data = 0;
00330 pan_text_color = YELLOW;
00331
00332 #include "images/7seg_small/0_png.h"
00333 #include "images/7seg_small/1_png.h"
00334 #include "images/7seg_small/2_png.h"
00335 #include "images/7seg_small/3_png.h"
00336 #include "images/7seg_small/4_png.h"
00337 #include "images/7seg_small/5_png.h"
00338 #include "images/7seg_small/6_png.h"
00339 #include "images/7seg_small/7_png.h"
00340 #include "images/7seg_small/8_png.h"
00341 #include "images/7seg_small/9_png.h"
00342 #include "images/7seg_small/colon_png.h"
00343 #include "images/7seg_small/period_png.h"
00344 #include "images/7seg_small/a_png.h"
00345 #include "images/7seg_small/b_png.h"
00346 #include "images/7seg_small/c_png.h"
00347 #include "images/7seg_small/d_png.h"
00348 #include "images/7seg_small/e_png.h"
00349 #include "images/7seg_small/f_png.h"
00350 #include "images/7seg_small/space_png.h"
00351 #include "images/7seg_small/dash_png.h"
00352 static VFrame* default_medium_7segment[] =
00353 {
00354 new VFrame(_0_png),
00355 new VFrame(_1_png),
00356 new VFrame(_2_png),
00357 new VFrame(_3_png),
00358 new VFrame(_4_png),
00359 new VFrame(_5_png),
00360 new VFrame(_6_png),
00361 new VFrame(_7_png),
00362 new VFrame(_8_png),
00363 new VFrame(_9_png),
00364 new VFrame(colon_png),
00365 new VFrame(period_png),
00366 new VFrame(a_png),
00367 new VFrame(b_png),
00368 new VFrame(c_png),
00369 new VFrame(d_png),
00370 new VFrame(e_png),
00371 new VFrame(f_png),
00372 new VFrame(space_png),
00373 new VFrame(dash_png)
00374 };
00375
00376 generic_button_margin = 15;
00377 draw_clock_background=1;
00378
00379 use_shm = -1;
00380
00381
00382 bg_color = ORANGE;
00383 bg_shadow1 = DKGREY;
00384 bg_shadow2 = BLACK;
00385 bg_light1 = WHITE;
00386 bg_light2 = bg_color;
00387
00388 default_text_color = BLACK;
00389 disabled_text_color = MEGREY;
00390
00391 button_light = WHITE;
00392 button_highlighted = 0xffe000;
00393 button_down = MDGREY;
00394 button_up = 0xffc000;
00395 button_shadow = DKGREY;
00396 button_uphighlighted = RED;
00397
00398 tumble_data = 0;
00399 tumble_duration = 150;
00400
00401 ok_images = default_ok_images;
00402 cancel_images = default_cancel_images;
00403 usethis_button_images = default_usethis_images;
00404 filebox_descend_images = default_ok_images;
00405
00406 menu_light = LTCYAN;
00407 menu_highlighted = LTBLUE;
00408 menu_down = MDCYAN;
00409 menu_up = MECYAN;
00410 menu_shadow = DKCYAN;
00411 menu_popup_bg = 0;
00412 menu_title_bg = 0;
00413 menu_item_bg = 0;
00414 menu_bar_bg = 0;
00415 menu_title_bg = 0;
00416 popupmenu_images = 0;
00417 popupmenu_margin = 10;
00418 popupmenu_triangle_margin = 10;
00419
00420 min_menu_w = 0;
00421 menu_title_text = BLACK;
00422 popup_title_text = BLACK;
00423 menu_item_text = BLACK;
00424 menu_highlighted_fontcolor = BLACK;
00425 progress_text = BLACK;
00426
00427
00428
00429 text_default = BLACK;
00430 highlight_inverse = WHITE ^ BLUE;
00431 text_background = WHITE;
00432 text_background_hi = LTYELLOW;
00433 text_background_noborder_hi = LTGREY;
00434 text_background_noborder = -1;
00435 text_border1 = DKGREY;
00436 text_border2 = BLACK;
00437 text_border2_hi = RED;
00438 text_border3 = MEGREY;
00439 text_border3_hi = LTPINK;
00440 text_border4 = WHITE;
00441 text_highlight = BLUE;
00442 text_inactive_highlight = MEGREY;
00443
00444 toggle_highlight_bg = 0;
00445 toggle_text_margin = 0;
00446
00447
00448 double_click = 300;
00449 blink_rate = 250;
00450 scroll_repeat = 150;
00451 tooltip_delay = 1000;
00452 tooltip_bg_color = YELLOW;
00453 tooltips_enabled = 1;
00454
00455 filebox_margin = 110;
00456 dirbox_margin = 90;
00457 filebox_mode = LISTBOX_TEXT;
00458 sprintf(filebox_filter, "*");
00459 filebox_w = 640;
00460 filebox_h = 480;
00461 filebox_columntype[0] = FILEBOX_NAME;
00462 filebox_columntype[1] = FILEBOX_SIZE;
00463 filebox_columntype[2] = FILEBOX_DATE;
00464 filebox_columntype[3] = FILEBOX_EXTENSION;
00465 filebox_columnwidth[0] = 200;
00466 filebox_columnwidth[1] = 100;
00467 filebox_columnwidth[2] = 100;
00468 filebox_columnwidth[3] = 100;
00469 dirbox_columntype[0] = FILEBOX_NAME;
00470 dirbox_columntype[1] = FILEBOX_DATE;
00471 dirbox_columnwidth[0] = 200;
00472 dirbox_columnwidth[1] = 100;
00473
00474 filebox_text_images = default_filebox_text_images;
00475 filebox_icons_images = default_filebox_icons_images;
00476 filebox_updir_images = default_filebox_updir_images;
00477 filebox_newfolder_images = default_filebox_newfolder_images;
00478 filebox_delete_images = default_filebox_delete_images;
00479 filebox_reload_images = default_filebox_reload_images;
00480 directory_color = BLUE;
00481 file_color = BLACK;
00482
00483 filebox_sortcolumn = 0;
00484 filebox_sortorder = BC_ListBox::SORT_ASCENDING;
00485 dirbox_sortcolumn = 0;
00486 dirbox_sortorder = BC_ListBox::SORT_ASCENDING;
00487
00488
00489 pot_images = default_pot_images;
00490 pot_offset = 2;
00491 pot_x1 = pot_images[0]->get_w() / 2 - pot_offset;
00492 pot_y1 = pot_images[0]->get_h() / 2 - pot_offset;
00493 pot_r = pot_x1;
00494 pot_needle_color = BLACK;
00495
00496 progress_images = default_progress_images;
00497
00498 xmeter_images = 0;
00499 ymeter_images = 0;
00500 meter_font = SMALLFONT_3D;
00501 meter_font_color = RED;
00502 meter_title_w = 20;
00503 meter_3d = 1;
00504 medium_7segment = default_medium_7segment;
00505
00506 audiovideo_color = RED;
00507
00508 use_fontset = 0;
00509
00510
00511 #ifdef HAVE_XFT
00512
00513 use_xft = 1;
00514 #else
00515 use_xft = 0;
00516 #endif
00517
00518
00519 drag_radius = 10;
00520 recursive_resizing = 1;
00521
00522
00523 }
00524
00525 BC_Resources::~BC_Resources()
00526 {
00527 }
00528
00529 int BC_Resources::initialize_display(BC_WindowBase *window)
00530 {
00531
00532
00533
00534
00535 init_shm(window);
00536 return 0;
00537 }
00538
00539
00540 int BC_Resources::init_shm(BC_WindowBase *window)
00541 {
00542 use_shm = 1;
00543 XSetErrorHandler(BC_Resources::x_error_handler);
00544
00545 if(!XShmQueryExtension(window->display)) use_shm = 0;
00546 else
00547 {
00548 XShmSegmentInfo test_shm;
00549 XImage *test_image;
00550 unsigned char *data;
00551 test_image = XShmCreateImage(window->display, window->vis, window->default_depth,
00552 ZPixmap, (char*)NULL, &test_shm, 5, 5);
00553
00554 test_shm.shmid = shmget(IPC_PRIVATE, 5 * test_image->bytes_per_line, (IPC_CREAT | 0777 ));
00555 data = (unsigned char *)shmat(test_shm.shmid, NULL, 0);
00556 shmctl(test_shm.shmid, IPC_RMID, 0);
00557 BC_Resources::error = 0;
00558 XShmAttach(window->display, &test_shm);
00559 XSync(window->display, False);
00560 if(BC_Resources::error) use_shm = 0;
00561 XDestroyImage(test_image);
00562 shmdt(test_shm.shmaddr);
00563 }
00564
00565 return 0;
00566 }
00567
00568
00569
00570
00571 BC_Synchronous* BC_Resources::get_synchronous()
00572 {
00573 return synchronous;
00574 }
00575
00576 void BC_Resources::set_synchronous(BC_Synchronous *synchronous)
00577 {
00578 this->synchronous = synchronous;
00579 }
00580
00581
00582
00583
00584
00585
00586
00587 int BC_Resources::get_top_border()
00588 {
00589 return display_info->get_top_border();
00590 }
00591
00592 int BC_Resources::get_left_border()
00593 {
00594 return display_info->get_left_border();
00595 }
00596
00597 int BC_Resources::get_right_border()
00598 {
00599 return display_info->get_right_border();
00600 }
00601
00602 int BC_Resources::get_bottom_border()
00603 {
00604 return display_info->get_bottom_border();
00605 }
00606
00607
00608 int BC_Resources::get_bg_color() { return bg_color; }
00609
00610 int BC_Resources::get_bg_shadow1() { return bg_shadow1; }
00611
00612 int BC_Resources::get_bg_shadow2() { return bg_shadow2; }
00613
00614 int BC_Resources::get_bg_light1() { return bg_light1; }
00615
00616 int BC_Resources::get_bg_light2() { return bg_light2; }
00617
00618
00619 int BC_Resources::get_id()
00620 {
00621 id_lock->lock("BC_Resources::get_id");
00622 int result = id++;
00623 id_lock->unlock();
00624 return result;
00625 }
00626
00627
00628 void BC_Resources::set_signals(BC_Signals *signal_handler)
00629 {
00630 BC_Resources::signal_handler = signal_handler;
00631 }
00632
00633 BC_Signals* BC_Resources::get_signals()
00634 {
00635 return BC_Resources::signal_handler;
00636 }