home *** CD-ROM | disk | FTP | other *** search
/ Geek 6 / Geek-006.iso / linux / video / xmovie-1.5.3.tar.gz / xmovie-1.5.3.tar / xmovie-1.5.3 / guicast / bcresources.C < prev    next >
C/C++ Source or Header  |  2000-11-29  |  13KB  |  465 lines

  1. #include "bcipc.h"
  2. #include "bclistbox.inc"
  3. #include "bcresources.h"
  4. #include "bcwindowbase.h"
  5. #include "colors.h"
  6. #include "colormodels.h"
  7.  
  8. #include "images/folder_png.h"
  9. #include "images/heroine_file_png.h"
  10. #include "images/list_bg_png.h"
  11. #include "images/listbox_button_dn_png.h"
  12. #include "images/listbox_button_hi_png.h"
  13. #include "images/listbox_button_up_png.h"
  14. #include "images/menu_bg_png.h"
  15. #include "images/window_bg_png.h"
  16. #include "vframe.h"
  17.  
  18. #include <locale.h>
  19. #include <sys/ipc.h>
  20. #include <sys/shm.h>
  21. #include <X11/extensions/XShm.h>
  22.  
  23. int BC_Resources::error = 0;
  24.  
  25. VFrame* BC_Resources::bg_image = new VFrame(window_bg_png);
  26. VFrame* BC_Resources::menu_bg = new VFrame(menu_bg_png);
  27.  
  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. VFrame* BC_Resources::type_to_icon[] = 
  33. {
  34.     new VFrame(file_folder_png),
  35.     new VFrame(file_unknown_png),
  36.     new VFrame(file_film_png),
  37.     new VFrame(file_sound_png)
  38. };
  39.  
  40. char* BC_Resources::small_font = "-*-helvetica-medium-r-normal-*-10-*";
  41. char* BC_Resources::medium_font = "-*-helvetica-bold-r-normal-*-14-*";
  42. char* BC_Resources::large_font = "-*-helvetica-bold-r-normal-*-18-*";
  43. char* BC_Resources::small_fontset = "6x12,*";
  44. char* BC_Resources::medium_fontset = "7x14,*";
  45. char* BC_Resources::large_fontset = "8x16,*";
  46.  
  47. suffix_to_type_t BC_Resources::suffix_to_type[] = 
  48. {
  49.     { "m2v", ICON_FILM },
  50.     { "mov", ICON_FILM },
  51.     { "mp2", ICON_SOUND },
  52.     { "mp3", ICON_SOUND },
  53.     { "mpg", ICON_FILM },
  54.     { "vob", ICON_FILM },
  55.     { "wav", ICON_SOUND }
  56. };
  57.  
  58.  
  59. int BC_Resources::x_error_handler(Display *display, XErrorEvent *event)
  60. {
  61.     char string[1024];
  62.     XGetErrorText(event->display, event->error_code, string, 1024);
  63. //    printf("BC_Resources::x_error_handler: %s\n", string);
  64.     BC_Resources::error = 1;
  65.     return 0;
  66. }
  67.  
  68. BC_Resources::BC_Resources()
  69. {
  70. #include "images/cancel_up_png.h"
  71. #include "images/cancel_uphi_png.h"
  72. #include "images/cancel_downhi_png.h"
  73.     static VFrame* default_cancel_images[] = 
  74.     {
  75.         new VFrame(cancel_up_png),
  76.         new VFrame(cancel_uphi_png),
  77.         new VFrame(cancel_downhi_png)
  78.     };
  79.  
  80. #include "images/ok_up_png.h"
  81. #include "images/ok_uphi_png.h"
  82. #include "images/ok_downhi_png.h"
  83.     static VFrame* default_ok_images[] = 
  84.     {
  85.         new VFrame(ok_up_png),
  86.         new VFrame(ok_uphi_png),
  87.         new VFrame(ok_downhi_png)
  88.     };
  89.  
  90. #include "images/checkbox_checked_png.h"
  91. #include "images/checkbox_down_png.h"
  92. #include "images/checkbox_checkedhi_png.h"
  93. #include "images/checkbox_up_png.h"
  94. #include "images/checkbox_uphi_png.h"
  95.     static VFrame* default_checkbox_images[] =  
  96.     {
  97.         new VFrame(checkbox_up_png),
  98.         new VFrame(checkbox_uphi_png),
  99.         new VFrame(checkbox_checked_png),
  100.         new VFrame(checkbox_down_png),
  101.         new VFrame(checkbox_checkedhi_png)
  102.     };
  103.  
  104. #include "images/radial_checked_png.h"
  105. #include "images/radial_down_png.h"
  106. #include "images/radial_checkedhi_png.h"
  107. #include "images/radial_up_png.h"
  108. #include "images/radial_uphi_png.h"
  109.     static VFrame* default_radial_images[] =  
  110.     {
  111.         new VFrame(radial_up_png),
  112.         new VFrame(radial_uphi_png),
  113.         new VFrame(radial_checked_png),
  114.         new VFrame(radial_down_png),
  115.         new VFrame(radial_checkedhi_png)
  116.     };
  117.  
  118.     static VFrame* default_label_images[] =  
  119.     {
  120.         new VFrame(radial_up_png),
  121.         new VFrame(radial_uphi_png),
  122.         new VFrame(radial_checked_png),
  123.         new VFrame(radial_down_png),
  124.         new VFrame(radial_checkedhi_png)
  125.     };
  126.  
  127.  
  128. #include "images/file_text_up_png.h"
  129. #include "images/file_text_uphi_png.h"
  130. #include "images/file_text_dn_png.h"
  131. #include "images/file_icons_up_png.h"
  132. #include "images/file_icons_uphi_png.h"
  133. #include "images/file_icons_dn_png.h"
  134. #include "images/file_newfolder_up_png.h"
  135. #include "images/file_newfolder_uphi_png.h"
  136. #include "images/file_newfolder_dn_png.h"
  137. #include "images/file_updir_up_png.h"
  138. #include "images/file_updir_uphi_png.h"
  139. #include "images/file_updir_dn_png.h"
  140.     static VFrame* default_filebox_text_images[] = 
  141.     {
  142.         new VFrame(file_text_up_png),
  143.         new VFrame(file_text_uphi_png),
  144.         new VFrame(file_text_dn_png)
  145.     };
  146.  
  147.     static VFrame* default_filebox_icons_images[] = 
  148.     {
  149.         new VFrame(file_icons_up_png),
  150.         new VFrame(file_icons_uphi_png),
  151.         new VFrame(file_icons_dn_png)
  152.     };
  153.  
  154.     static VFrame* default_filebox_updir_images[] =  
  155.     {
  156.         new VFrame(file_updir_up_png),
  157.         new VFrame(file_updir_uphi_png),
  158.         new VFrame(file_updir_dn_png)
  159.     };
  160.  
  161.     static VFrame* default_filebox_newfolder_images[] = 
  162.     {
  163.         new VFrame(file_newfolder_up_png),
  164.         new VFrame(file_newfolder_uphi_png),
  165.         new VFrame(file_newfolder_dn_png)
  166.     };
  167.  
  168.     static VFrame* default_listbox_button[] = 
  169.     {
  170.         new VFrame(listbox_button_up_png),
  171.         new VFrame(listbox_button_hi_png),
  172.         new VFrame(listbox_button_dn_png)
  173.     };
  174.  
  175.     static VFrame* default_listbox_bg = new VFrame(list_bg_png);
  176.  
  177. #include "images/slider_left_png.h"
  178. #include "images/slider_mid_png.h"
  179. #include "images/slider_right_png.h"
  180. #include "images/slider_dn_png.h"
  181. #include "images/slider_up_png.h"
  182. #include "images/slider_uphi_png.h"
  183.     static VFrame* default_horizontal_slider[] = 
  184.     {
  185.         new VFrame(slider_up_png),
  186.         new VFrame(slider_uphi_png),
  187.         new VFrame(slider_dn_png),
  188.         new VFrame(slider_left_png),
  189.         new VFrame(slider_mid_png),
  190.         new VFrame(slider_right_png)
  191.     };
  192.  
  193. #include "images/fadevertical_left_png.h"
  194. #include "images/fadevertical_mid_png.h"
  195. #include "images/fadevertical_right_png.h"
  196. #include "images/fadevertical_up_png.h"
  197. #include "images/fadevertical_uphi_png.h"
  198.     static VFrame* default_vertical_slider[] = 
  199.     {
  200.         new VFrame(fadevertical_up_png),
  201.         new VFrame(fadevertical_uphi_png),
  202.         new VFrame(fadevertical_left_png),
  203.         new VFrame(fadevertical_mid_png),
  204.         new VFrame(fadevertical_right_png)
  205.     };
  206.  
  207. #include "images/pot_hi_png.h"
  208. #include "images/pot_up_png.h"
  209. #include "images/pot_dn_png.h"
  210.     static VFrame *default_pot_images[] = 
  211.     {
  212.         new VFrame(pot_up_png),
  213.         new VFrame(pot_hi_png),
  214.         new VFrame(pot_dn_png)
  215.     };
  216.  
  217. #include "images/progress_hi_left_png.h"
  218. #include "images/progress_hi_mid_png.h"
  219. #include "images/progress_hi_right_png.h"
  220. #include "images/progress_left_png.h"
  221. #include "images/progress_mid_png.h"
  222. #include "images/progress_right_png.h"
  223.     static VFrame* default_progress_images[] = 
  224.     {
  225.         new VFrame(progress_left_png),
  226.         new VFrame(progress_mid_png),
  227.         new VFrame(progress_right_png),
  228.         new VFrame(progress_hi_left_png),
  229.         new VFrame(progress_hi_mid_png),
  230.         new VFrame(progress_hi_right_png)
  231.     };
  232.  
  233.  
  234. #include "images/pan_bg_png.h"
  235. #include "images/pan_bg_hi_png.h"
  236. #include "images/pan_channel_png.h"
  237. #include "images/pan_stick_png.h"
  238.     static VFrame* default_pan_bg = new VFrame(pan_bg_png);
  239.     static VFrame* default_pan_bg_hi = new VFrame(pan_bg_hi_png);
  240.     static VFrame* default_pan_channel = new VFrame(pan_channel_png);
  241.     static VFrame* default_pan_stick = new VFrame(pan_stick_png);
  242.  
  243. #include "images/7seg_small/0_png.h"
  244. #include "images/7seg_small/1_png.h"
  245. #include "images/7seg_small/2_png.h"
  246. #include "images/7seg_small/3_png.h"
  247. #include "images/7seg_small/4_png.h"
  248. #include "images/7seg_small/5_png.h"
  249. #include "images/7seg_small/6_png.h"
  250. #include "images/7seg_small/7_png.h"
  251. #include "images/7seg_small/8_png.h"
  252. #include "images/7seg_small/9_png.h"
  253. #include "images/7seg_small/colon_png.h"
  254. #include "images/7seg_small/space_png.h"
  255.     static VFrame* default_medium_7segment[] = 
  256.     {
  257.         new VFrame(_0_png),
  258.         new VFrame(_1_png),
  259.         new VFrame(_2_png),
  260.         new VFrame(_3_png),
  261.         new VFrame(_4_png),
  262.         new VFrame(_5_png),
  263.         new VFrame(_6_png),
  264.         new VFrame(_7_png),
  265.         new VFrame(_8_png),
  266.         new VFrame(_9_png),
  267.         new VFrame(colon_png),
  268.         new VFrame(space_png)
  269.     };
  270.  
  271. #include "images/tumblerbottom_dn_png.h"
  272. #include "images/tumblertop_dn_png.h"
  273. #include "images/tumbler_hi_png.h"
  274. #include "images/tumbler_up_png.h"
  275.     static VFrame* default_tumbler_data[] = 
  276.     {
  277.         new VFrame(tumbler_up_png),
  278.         new VFrame(tumbler_hi_png),
  279.         new VFrame(tumblerbottom_dn_png),
  280.         new VFrame(tumblertop_dn_png)
  281.     };
  282.  
  283. #include "images/meterleft_bg_png.h"
  284. #include "images/meterleft_green_png.h"
  285. #include "images/meterleft_red_png.h"
  286. #include "images/meterleft_yellow_png.h"
  287. #include "images/metermid_bg_png.h"
  288. #include "images/metermid_green_png.h"
  289. #include "images/metermid_red_png.h"
  290. #include "images/metermid_yellow_png.h"
  291. #include "images/meterright_bg_png.h"
  292. #include "images/meterright_green_png.h"
  293. #include "images/meterright_red_png.h"
  294. #include "images/meterright_yellow_png.h"
  295.  
  296.     static VFrame* default_meter_data[] =
  297.     {
  298.         new VFrame(meterleft_bg_png),
  299.         new VFrame(meterleft_green_png),
  300.         new VFrame(meterleft_red_png),
  301.         new VFrame(meterleft_yellow_png),
  302.         new VFrame(metermid_bg_png),
  303.         new VFrame(metermid_green_png),
  304.         new VFrame(metermid_red_png),
  305.         new VFrame(metermid_yellow_png),
  306.         new VFrame(meterright_bg_png),
  307.         new VFrame(meterright_green_png),
  308.         new VFrame(meterright_red_png),
  309.         new VFrame(meterright_yellow_png)
  310.     };
  311.  
  312. #include "images/generic_button_leftdn_png.h"
  313. #include "images/generic_button_lefthi_png.h"
  314. #include "images/generic_button_leftup_png.h"
  315. #include "images/generic_button_middn_png.h"
  316. #include "images/generic_button_midhi_png.h"
  317. #include "images/generic_button_midup_png.h"
  318. #include "images/generic_button_rightdn_png.h"
  319. #include "images/generic_button_righthi_png.h"
  320. #include "images/generic_button_rightup_png.h"
  321.     
  322.     static VFrame* default_generic_button_data[] = 
  323.     {
  324.         new VFrame(generic_button_leftdn_png),
  325.         new VFrame(generic_button_lefthi_png),
  326.         new VFrame(generic_button_leftup_png),
  327.         new VFrame(generic_button_middn_png),
  328.         new VFrame(generic_button_midhi_png),
  329.         new VFrame(generic_button_midup_png),
  330.         new VFrame(generic_button_rightdn_png),
  331.         new VFrame(generic_button_righthi_png),
  332.         new VFrame(generic_button_rightup_png),
  333.     };
  334.     
  335.     generic_button_images = default_generic_button_data;
  336.  
  337.     use_shm = -1;
  338.  
  339. // Initialize
  340.     bg_color = MEGREY;
  341.     bg_shadow1 = DKGREY;
  342.     bg_shadow2 = BLACK;
  343.     bg_light1 = WHITE;
  344.     bg_light2 = bg_color;
  345.  
  346.     button_light = WHITE;           // bright corner
  347.     button_highlighted = LTGREY;  // face when highlighted
  348.     button_down = MDGREY;         // face when down
  349.     button_up = MEGREY;           // face when up
  350.     button_shadow = DKGREY;       // dark corner
  351.  
  352.     tumble_data = default_tumbler_data;
  353.     tumble_duration = 150;
  354.  
  355.     ok_images = default_ok_images;
  356.     cancel_images = default_cancel_images;
  357.     filebox_text_images = default_filebox_text_images;
  358.     filebox_icons_images = default_filebox_icons_images;
  359.     filebox_updir_images = default_filebox_updir_images;
  360.     filebox_newfolder_images = default_filebox_newfolder_images;
  361.  
  362.     checkbox_images = default_checkbox_images;
  363.     radial_images = default_radial_images;
  364.     label_images = default_label_images;
  365.     horizontal_slider = default_horizontal_slider;
  366.  
  367.     menu_light = LTCYAN;
  368.     menu_highlighted = LTBLUE;
  369.     menu_down = MDCYAN;
  370.     menu_up = MECYAN;
  371.     menu_shadow = DKCYAN;
  372.  
  373.     text_default = BLACK;
  374.     text_background = WHITE;
  375.     highlight_inverse = WHITE ^ BLUE;
  376.     text_highlight = BLUE;
  377.  
  378. // Delays must all be different for repeaters
  379.     double_click = 300;
  380.     blink_rate = 250;
  381.     scroll_repeat = 150;
  382.     tooltip_delay = 1000;
  383.     tooltip_bg_color = YELLOW;
  384.     tooltips_enabled = 1;
  385.     
  386.     filebox_mode = LISTBOX_TEXT;
  387.     sprintf(filebox_filter, "*");
  388.     filebox_w = 640;
  389.     filebox_h = 480;
  390.     
  391.     listbox_button = default_listbox_button;
  392.     listbox_bg = default_listbox_bg;
  393.  
  394.     pot_images = default_pot_images;
  395.     pot_x1 = pot_images[0]->get_w() / 2 - 2;
  396.     pot_y1 = pot_images[0]->get_h() / 2 - 2;;
  397.     pot_r = pot_x1;
  398.  
  399.     pan_bg = default_pan_bg;
  400.     pan_bg_hi = default_pan_bg_hi;
  401.     pan_channel = default_pan_channel;
  402.     pan_stick = default_pan_stick;
  403.  
  404.     progress_images = default_progress_images;
  405.  
  406.     meter_images = default_meter_data;
  407.     medium_7segment = default_medium_7segment;
  408.     use_fontset = 0;
  409.     if(use_fontset) setlocale(LC_ALL, "");
  410.     drag_radius = 10;
  411.     recursive_resizing = 1;
  412. }
  413.  
  414. BC_Resources::~BC_Resources()
  415. {
  416. }
  417.  
  418. int BC_Resources::initialize_display(BC_WindowBase *window)
  419. {
  420. // Set up IPC cleanup handlers
  421.     bc_init_ipc();
  422.  
  423. // Test for shm.  Must come before yuv test
  424.     init_shm(window);
  425.     return 0;
  426. }
  427.  
  428. int BC_Resources::init_shm(BC_WindowBase *window)
  429. {
  430.     use_shm = 1;
  431.     XSetErrorHandler(BC_Resources::x_error_handler);
  432.  
  433.     if(!XShmQueryExtension(window->display)) use_shm = 0;
  434.     else
  435.     {
  436.         XShmSegmentInfo test_shm;
  437.         XImage *test_image;
  438.         unsigned char *data;
  439.         test_image = XShmCreateImage(window->display, window->vis, window->default_depth,
  440.                 ZPixmap, (char*)NULL, &test_shm, 5, 5);
  441.  
  442.         test_shm.shmid = shmget(IPC_PRIVATE, 5 * test_image->bytes_per_line, (IPC_CREAT | 0777 ));
  443.         data = (unsigned char *)shmat(test_shm.shmid, NULL, 0);
  444.         shmctl(test_shm.shmid, IPC_RMID, 0);
  445.         BC_Resources::error = 0;
  446.             XShmAttach(window->display, &test_shm);
  447.         XSync(window->display, False);
  448.         if(BC_Resources::error) use_shm = 0;
  449.         XDestroyImage(test_image);
  450.         shmdt(test_shm.shmaddr);
  451.     }
  452.     return 0;
  453. }
  454.  
  455. int BC_Resources::get_bg_color() { return bg_color; }
  456.  
  457. int BC_Resources::get_bg_shadow1() { return bg_shadow1; }
  458.  
  459. int BC_Resources::get_bg_shadow2() { return bg_shadow2; }
  460.  
  461. int BC_Resources::get_bg_light1() { return bg_light1; }
  462.  
  463. int BC_Resources::get_bg_light2() { return bg_light2; }
  464.  
  465.