Subversion Repositories Kolibri OS

Rev

Rev 7244 | Rev 7310 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. #ifdef LANG_RUS
  3.         ?define T_DEVICES "“áâனá⢠"
  4.         ?define T_ACTIONS "„¥©á⢨ï"
  5.         char *actions[] = {
  6.                 57, "®¢ë© ä ©«", "F7",
  7.                 56, "®¢ ï ¯ ¯ª ", "F6",
  8.                 60, " áâனª¨", "F10",
  9.                 0,0,0
  10.         };
  11.         ?define T_PROG "à®£à ¬¬ë "
  12.         ?define T_SYS  "‘¨á⥬  "
  13.         ?define T_UNC  "¥¨§¢¥áâ­® "
  14.         ?define T_CD   "CD-ROM "
  15.         ?define T_FD   "„¨áª¥â  "
  16.         ?define T_HD   "†¥á⪨© ¤¨áª "
  17.         ?define T_SATA "SATA ¤¨áª "
  18.         ?define T_USB  "USB ¤¨áª "
  19.         ?define T_RAM  "RAM ¤¨áª "
  20. #else
  21.         ?define T_DEVICES "Devices"
  22.         ?define T_ACTIONS "Actions"
  23.         char *actions[] = {
  24.                 57, "New file", "F7",
  25.                 56, "New folder", "F6",
  26.                 60, "Settings", "F10",
  27.                 0,0,0
  28.         };
  29.         ?define T_PROG "Programs "
  30.         ?define T_SYS  "System "
  31.         ?define T_UNC  "Unknown "
  32.         ?define T_CD   "CD-ROM "
  33.         ?define T_FD   "Floppy disk "
  34.         ?define T_HD   "Hard disk "
  35.         ?define T_SATA "SATA disk "
  36.         ?define T_USB  "USB disk "
  37.         ?define T_RAM  "RAM disk "
  38. #endif
  39.  
  40. struct _SystemDiscs
  41. {
  42.         collection list;
  43.         void Get();
  44.         void Draw();
  45.         void Click();
  46. } SystemDiscs;
  47.  
  48.  
  49. void GetDiskIconAndName(char disk_first_letter, dword dev_icon, disc_name)
  50. {
  51.         switch(disk_first_letter)
  52.         {
  53.                 case 'k':
  54.                         ESBYTE[dev_icon]=0;
  55.                         strcpy(disc_name, T_PROG);
  56.                         break;
  57.                 case 'r':
  58.                         ESBYTE[dev_icon]=0;
  59.                         strcpy(disc_name, T_SYS);
  60.                         break;
  61.                 case 'c':
  62.                         ESBYTE[dev_icon]=1;
  63.                         strcpy(disc_name, T_CD);
  64.                         break;
  65.                 case 'f':
  66.                         ESBYTE[dev_icon]=2;
  67.                         strcpy(disc_name, T_FD);
  68.                         break;
  69.                 case 'h':
  70.                 case 'b':
  71.                         ESBYTE[dev_icon]=3;
  72.                         strcpy(disc_name, T_HD);
  73.                         break;
  74.                 case 's':
  75.                         ESBYTE[dev_icon]=3;
  76.                         strcpy(disc_name, T_SATA);
  77.                         break;
  78.                 case 'u':
  79.                         ESBYTE[dev_icon]=5;
  80.                         strcpy(disc_name, T_USB);
  81.                         break;
  82.                 case 't':
  83.                         ESBYTE[dev_icon]=4;
  84.                         strcpy(disc_name, T_RAM);
  85.                         break;
  86.                 default:
  87.                         ESBYTE[dev_icon]=3;
  88.                         strcpy(disc_name, T_UNC);                              
  89.         }
  90. }
  91.  
  92. void _SystemDiscs::Get()
  93. {
  94.         char dev_name[10], sys_discs[10];
  95.         int i1, j1, dev_num, dev_disc_num;
  96.         dword temp_file_count, tempbuf;
  97.         dword devbuf;
  98.  
  99.         list.drop();
  100.         devbuf = malloc(10000);
  101.         ReadDir(19, devbuf, "/");
  102.         dev_num = EBX;
  103.         for (i1=0; i1<dev_num; i1++)
  104.         {
  105.                 sprintf(#dev_name,"/%s",i1*304+ devbuf+72);
  106.                 Open_Dir(#dev_name, ONLY_OPEN);
  107.                 dev_disc_num = files.count;
  108.                 for (j1=0; j1<dev_disc_num; j1++;)
  109.                 {
  110.                         sprintf(#sys_discs,"%s/%s",#dev_name,j1*304+ buf+72);
  111.                         list.add(#sys_discs);
  112.                 }
  113.                 if (!strcmp(#sys_discs, "/rd/1"))
  114.                 {
  115.                         GetDir(#tempbuf, #temp_file_count, "/kolibrios", DIRS_ONLYREAL);
  116.                         if (temp_file_count) list.add("/kolibrios");
  117.                         free(tempbuf);
  118.                 }
  119.         }
  120.         free(devbuf);
  121. }
  122.  
  123. void _SystemDiscs::Draw()
  124. {    
  125.         char dev_name[15], disc_name[100], i, dev_icon, is_active, name_len;
  126.         int draw_y, draw_x, draw_h;
  127.        
  128.         for (i=0; i<30; i++) DeleteButton(100+i);
  129.  
  130.         if ( two_panels.checked) { draw_y = 41; draw_x =  2; draw_h = 21; }
  131.         if (!two_panels.checked) { draw_y = 74; draw_x = 17; draw_h = 16; }
  132.  
  133.         for (i=0;i<list.count;i++)
  134.         {
  135.                 strcpy(#dev_name, list.get(i));
  136.                 GetDiskIconAndName(dev_name[1], #dev_icon, #disc_name);
  137.                 if (strstr(#path, #dev_name)-#path==0) is_active=true; else is_active=false;
  138.                 if (two_panels.checked)
  139.                 {
  140.                         name_len = strlen(#dev_name)-1*8;
  141.                         DrawBar(draw_x, draw_y, name_len + 31, draw_h, 0xFFFFFF);
  142.                         DefineButton(draw_x+2, draw_y, name_len + 27, draw_h-1, 100+i+BT_HIDE,0xFFFFFF);
  143.                         _PutImage(draw_x + 5, draw_y+2, 18,17, is_active*6+dev_icon*17*18*3+#devices);
  144.                         WriteText(draw_x + 24, draw_y+3, 10110000b, 0, #dev_name+1);
  145.                         draw_x += name_len + 31;
  146.                         if (draw_x>=Form.width-35) && (Form.width) {
  147.                                 DrawBar(draw_x, draw_y, Form.cwidth - draw_x - 2, draw_h, 0xFFFFFF);
  148.                                 draw_x = 2;
  149.                                 draw_y += draw_h;
  150.                         }
  151.                 }
  152.                 else
  153.                 {
  154.                         DrawBar(draw_x,draw_y,6,draw_h+1,0xFFFFFF);
  155.                         DrawBar(draw_x+6+18,draw_y,160-6-18,draw_h+1,0xFFFFFF);
  156.                         DefineButton(draw_x,draw_y,159,16,100+i+BT_HIDE,0xFFFFFF);
  157.                         if (show_dev_name.checked)
  158.                         {
  159.                                 strcat(#disc_name, #dev_name);
  160.                                 if (is_active) WriteText(draw_x+30,draw_y+5,0x80,0x555555,#disc_name);
  161.                                 WriteText(draw_x+29,draw_y+5,0x80,0,#disc_name);                        }
  162.                         else
  163.                         {
  164.                                 if (is_active) WriteText(draw_x+30,draw_y+5,0x80,0x555555,#dev_name);
  165.                                 WriteText(draw_x+29,draw_y+5,0x80,0,#dev_name);
  166.                         }
  167.                         _PutImage(draw_x+6,draw_y, 18,17, is_active*6+dev_icon*17*18*3+#devices);
  168.                         draw_y += draw_h;
  169.                 }
  170.         }
  171.         if (two_panels.checked)
  172.         {
  173.                 DrawBar(draw_x, draw_y, Form.cwidth - draw_x - 2, draw_h, 0xFFFFFF);
  174.                 DefineButton(Form.cwidth - 23, draw_y+2, 17,16, 60+BT_HIDE, 0xCCCccc);
  175.                 _PutImage(Form.cwidth - 21, draw_y+4, 14,13, 2*14*13*3+#factions);
  176.                 files.y = draw_y + draw_h + 17;
  177.         }
  178. }
  179.  
  180. void _SystemDiscs::Click(int n)
  181. {
  182.         strcpy(#path, list.get(n));
  183.         files.KeyHome();
  184.         Open_Dir(#path,WITH_REDRAW);   
  185. }
  186.  
  187.  
  188.  
  189. void DrawDeviceAndActionsLeftPanel()
  190. {
  191.         Tip(56, T_DEVICES, 55, "=");
  192.         SystemDiscs.Draw();
  193.         ActionsDraw();
  194.         DrawLeftPanelBg();
  195. }
  196.  
  197. void Tip(int y, dword caption, id, arrow)
  198. {
  199.         DrawBar(17,y,160,1,0xEFEDEE);
  200.         DrawFilledBar(17, y+1, 160, 16);
  201.         WriteText(25,y+5,0x80,0x000000,caption);
  202.         if (id) DefineButton(159,y+1,16,16,id+BT_HIDE+BT_NOFRAME,0); //arrow button
  203.         WriteText(165,y+5,0x80,0x000000,arrow); //arrow
  204.         DrawBar(17,y+17,160,1,col_graph);
  205. }
  206.  
  207. void ActionsDraw()
  208. {
  209.         int actions_y= SystemDiscs.list.count*16+108, lineh=16;
  210.         Tip(actions_y-18, T_ACTIONS, 77, ""); //çàãîëîâîê
  211.         for (i=0; actions[i*3]!=0; i++, actions_y+=lineh)
  212.         {
  213.                 DrawBar(17,actions_y,160,lineh,0xFFFFFF); //áåëîå
  214.                 DefineButton(17,actions_y,159,lineh,actions[i*3]+BT_HIDE,0xE4DFE1);
  215.                 WriteText(45,actions_y+4,0x80,0,actions[i*3+1]);
  216.                 WriteText(-strlen(actions[i*3+2])*6+170,actions_y+4,0x80,0x999999,actions[i*3+2]);
  217.                 _PutImage(23,actions_y+2, 14,13, i*14*13*3+#factions);
  218.         }
  219. }
  220.  
  221. void DrawLeftPanelBg()
  222. {
  223.         int actions_y = SystemDiscs.list.count*16;
  224.         int start_y = actions_y+156;
  225.         int area_h;
  226.         DrawBar(2,41,190,15,col_lpanel);                      //ñèíèé ïðÿìîóãîëüíèê - íàä äåâàéñàìè
  227.         DrawBar(17,actions_y+75,160,15,col_lpanel); //ñèíèé ïðÿìîóãîëüíèê - ïîä äåâàéñàìè
  228.         PutShadow(17,actions_y+75,160,1,1,3);
  229.         PutShadow(18,actions_y+75+1,158,1,1,1);
  230.         DrawBar(2,56,15,actions_y+103,col_lpanel);                //ñèíèé ïðÿìîóãîëüíèê - ñëåâà      
  231.         DrawBar(177,56,15,actions_y+103,col_lpanel);            //ñèíèé ïðÿìîóãîëüíèê - ñïðàâà
  232.         area_h = Form.cheight-start_y-2 - status_bar_h;
  233.         if (area_h < 268)
  234.         {
  235.                 PutPaletteImage(#blue_hl, 190, area_h, 2, start_y, 8, #blue_hl_pal);
  236.         }
  237.         else
  238.         {
  239.                 DrawBar(2,start_y,190, area_h-268, col_lpanel);
  240.                 PutPaletteImage(#blue_hl, 190, 268, 2, Form.cheight-270-status_bar_h, 8, #blue_hl_pal);
  241.         }
  242.         PutShadow(17,start_y,160,1,1,3);
  243.         PutShadow(18,start_y+1,158,1,1,1);
  244. }