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