Subversion Repositories Kolibri OS

Rev

Rev 7611 | Rev 7647 | 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.         int dev_num;
  44.         void Get();
  45.         void Draw();
  46.         void Click();
  47. } SystemDiscs;
  48.  
  49.  
  50. void GetDiskIconAndName(char disk_first_letter, dword dev_icon, disc_name)
  51. {
  52.         switch(disk_first_letter)
  53.         {
  54.                 case 'k':
  55.                         ESBYTE[dev_icon]=0;
  56.                         strcpy(disc_name, T_PROG);
  57.                         break;
  58.                 case 'r':
  59.                         ESBYTE[dev_icon]=0;
  60.                         strcpy(disc_name, T_SYS);
  61.                         break;
  62.                 case 'c':
  63.                         ESBYTE[dev_icon]=1;
  64.                         strcpy(disc_name, T_CD);
  65.                         break;
  66.                 case 'f':
  67.                         ESBYTE[dev_icon]=2;
  68.                         strcpy(disc_name, T_FD);
  69.                         break;
  70.                 case 'h':
  71.                 case 'b':
  72.                         ESBYTE[dev_icon]=3;
  73.                         strcpy(disc_name, T_HD);
  74.                         break;
  75.                 case 's':
  76.                         ESBYTE[dev_icon]=3;
  77.                         strcpy(disc_name, T_SATA);
  78.                         break;
  79.                 case 'u':
  80.                         ESBYTE[dev_icon]=5;
  81.                         strcpy(disc_name, T_USB);
  82.                         break;
  83.                 case 't':
  84.                         ESBYTE[dev_icon]=4;
  85.                         strcpy(disc_name, T_RAM);
  86.                         break;
  87.                 default:
  88.                         ESBYTE[dev_icon]=3;
  89.                         strcpy(disc_name, T_UNC);                              
  90.         }
  91. }
  92.  
  93. void _SystemDiscs::Get()
  94. {
  95.         bool kolibrios_exists=false;
  96.         char dev_name[10], sys_discs[10];
  97.         int i1, j1, dev_num_i, dev_disc_num;
  98.         dword devbuf;
  99.  
  100.         list.drop();
  101.         devbuf = malloc(10000);
  102.         ReadDir(19, devbuf, "/");
  103.         dev_num = dev_num_i = EBX;
  104.         for (i1=0; i1<dev_num_i; i1++)
  105.         {
  106.                 sprintf(#dev_name,"/%s",i1*304+ devbuf+72);
  107.                 Open_Dir(#dev_name, ONLY_OPEN);
  108.                 dev_disc_num = files.count;
  109.                 for (j1=0; j1<dev_disc_num; j1++;)
  110.                 {
  111.                         sprintf(#sys_discs,"%s/%s",#dev_name,j1*304+ buf+72);
  112.                         list.add(#sys_discs);
  113.                 }
  114.                 if (!strcmp(#sys_discs, "/rd/1"))
  115.                 {
  116.                         if (dir_exists("/kolibrios")) && (!kolibrios_exists) {
  117.                                 kolibrios_exists=true;
  118.                                 list.add("/kolibrios");
  119.                                 dev_num++;
  120.                         }
  121.                 }
  122.         }
  123.         free(devbuf);
  124. }
  125.  
  126. void _SystemDiscs::Draw()
  127. {    
  128.         char dev_name[15], disc_name[100], i, dev_icon, is_active, name_len;
  129.         int draw_y, draw_x, draw_h;
  130.        
  131.         for (i=0; i<30; i++) DeleteButton(100+i);
  132.  
  133.         if ( two_panels.checked) { draw_y = 41; draw_x =  2; draw_h = 21; }
  134.         if (!two_panels.checked) { draw_y = 74; draw_x = 17; draw_h = 16; }
  135.  
  136.         for (i=0;i<list.count;i++)
  137.         {
  138.                 strcpy(#dev_name, list.get(i));
  139.                 GetDiskIconAndName(dev_name[1], #dev_icon, #disc_name);
  140.                 if (strstr(#path, #dev_name)-#path==0) is_active=true; else is_active=false;
  141.                 if (two_panels.checked)
  142.                 {
  143.                         name_len = strlen(#dev_name)-1*8;
  144.                         DrawBar(draw_x, draw_y, name_len + 31, draw_h, 0xFFFFFF);
  145.                         DefineButton(draw_x+2, draw_y, name_len + 27, draw_h-1, 100+i+BT_HIDE,0xFFFFFF);
  146.                         _PutImage(draw_x + 5, draw_y+2, 18,17, is_active*6+dev_icon*17*18*3+#devices);
  147.                         WriteText(draw_x + 24, draw_y+3, 10110000b, 0, #dev_name+1);
  148.                         draw_x += name_len + 31;
  149.                         if (draw_x>=Form.cwidth-100) && (Form.cwidth) {
  150.                                 DrawBar(draw_x, draw_y, Form.cwidth - draw_x - 2, draw_h, 0xFFFFFF);
  151.                                 draw_x = 2;
  152.                                 draw_y += draw_h;
  153.                         }
  154.                 }
  155.                 else
  156.                 {
  157.                         DrawBar(draw_x,draw_y,6,draw_h+1,0xFFFFFF);
  158.                         DrawBar(draw_x+6+18,draw_y,160-6-18,draw_h+1,0xFFFFFF);
  159.                         DefineButton(draw_x,draw_y,159,16,100+i+BT_HIDE,0xFFFFFF);
  160.                         if (show_dev_name.checked)
  161.                         {
  162.                                 strcat(#disc_name, #dev_name);
  163.                                 if (is_active) WriteText(draw_x+30,draw_y+5,0x80,0x555555,#disc_name);
  164.                                 WriteText(draw_x+29,draw_y+5,0x80,0,#disc_name);                        }
  165.                         else
  166.                         {
  167.                                 if (is_active) WriteText(draw_x+30,draw_y+5,0x80,0x555555,#dev_name);
  168.                                 WriteText(draw_x+29,draw_y+5,0x80,0,#dev_name);
  169.                         }
  170.                         _PutImage(draw_x+6,draw_y, 18,17, is_active*6+dev_icon*17*18*3+#devices);
  171.                         draw_y += draw_h;
  172.                 }
  173.         }
  174.         if (two_panels.checked)
  175.         {
  176.                 DrawBar(draw_x, draw_y, Form.cwidth - draw_x - 2, draw_h, 0xFFFFFF);
  177.                 DefineButton(Form.cwidth - 23, draw_y+2, 17,16, 60+BT_HIDE, 0xCCCccc);
  178.                 _PutImage(Form.cwidth - 21, draw_y+4, 14,13, 2*14*13*3+#factions);
  179.                 files.y = draw_y + draw_h + 17;
  180.         }
  181. }
  182.  
  183. void _SystemDiscs::Click(int n)
  184. {
  185.         strcpy(#path, list.get(n));
  186.         files.KeyHome();
  187.         Open_Dir(#path,WITH_REDRAW);   
  188. }
  189.  
  190.  
  191.  
  192. void DrawDeviceAndActionsLeftPanel()
  193. {
  194.         Tip(56, T_DEVICES, 55, "=");
  195.         SystemDiscs.Draw();
  196.         ActionsDraw();
  197.         DrawLeftPanelBg();
  198. }
  199.  
  200. dword col_palette_inner[14] = {0xD2D3D3,0xD4D4D4,0xD6D5D6,0xD8D7D8,0xDAD8D9,0xDCDADB,
  201.         0xDFDCDD,0xE1DDDE,0xE2DEE0,0xE4DFE1,0xE3DFE1,0xE3DFE1,0xE3DFE1,0xE3DFE1,0xE3DFE1};
  202. void DrawFilledBarInner(dword x, y, w, h)
  203. {
  204.         int i, fill_h;
  205.         if (h <= 14) fill_h = h; else fill_h = 14;
  206.         for (i=0; i<fill_h; i++) DrawBar(x, y+i, w, 1, col_palette_inner[14-i]);
  207.         DrawBar(x, y+i, w, h-fill_h, col_palette_inner[14-i]);
  208. }
  209.  
  210. void Tip(int y, dword caption, id, arrow)
  211. {
  212.         DrawBar(17,y,160,1,0xEFEDEE);
  213.         DrawFilledBarInner(17, y+1, 160, 16);
  214.         WriteText(25,y+5,0x80,0x000000,caption);
  215.         if (id) DefineButton(159,y+1,16,16,id+BT_HIDE+BT_NOFRAME,0); //arrow button
  216.         WriteText(165,y+5,0x80,0x000000,arrow); //arrow
  217.         DrawBar(17,y+17,160,1,0x7E87A3);
  218. }
  219.  
  220. void ActionsDraw()
  221. {
  222.         int i;
  223.         int actions_y= SystemDiscs.list.count*16+108, lineh=16;
  224.         Tip(actions_y-18, T_ACTIONS, 77, ""); //çàãîëîâîê
  225.         for (i=0; actions[i*3]!=0; i++, actions_y+=lineh)
  226.         {
  227.                 DrawBar(17,actions_y,160,lineh,0xFFFFFF); //áåëîå
  228.                 DefineButton(17,actions_y,159,lineh,actions[i*3]+BT_HIDE,0xE4DFE1);
  229.                 WriteText(45,actions_y+4,0x80,0,actions[i*3+1]);
  230.                 WriteText(-strlen(actions[i*3+2])*6+170,actions_y+4,0x80,0x999999,actions[i*3+2]);
  231.                 _PutImage(23,actions_y+2, 14,13, i*14*13*3+#factions);
  232.         }
  233. }
  234.  
  235. void DrawLeftPanelBg()
  236. {
  237.         int actions_y = SystemDiscs.list.count*16;
  238.         int start_y = actions_y+156;
  239.         int area_h;
  240.         DrawBar(2,41,190,15,col.lpanel);                      //ñèíèé ïðÿìîóãîëüíèê - íàä äåâàéñàìè
  241.         DrawBar(17,actions_y+75,160,15,col.lpanel); //ñèíèé ïðÿìîóãîëüíèê - ïîä äåâàéñàìè
  242.         PutShadow(17,actions_y+75,160,1,1,3);
  243.         PutShadow(18,actions_y+75+1,158,1,1,1);
  244.         DrawBar(2,56,15,actions_y+103,col.lpanel);                //ñèíèé ïðÿìîóãîëüíèê - ñëåâà      
  245.         DrawBar(177,56,15,actions_y+103,col.lpanel);            //ñèíèé ïðÿìîóãîëüíèê - ñïðàâà
  246.         area_h = Form.cheight-start_y-2 - status_bar_h;
  247.         if (col.lpanel == 0x00699C)
  248.         {
  249.                 if (area_h < 268){
  250.                         PutPaletteImage(#blue_hl, 190, area_h, 2, start_y, 8, #blue_hl_pal);
  251.                 } else {
  252.                         DrawBar(2,start_y,190, area_h-268, col.lpanel);
  253.                         PutPaletteImage(#blue_hl, 190, 268, 2, Form.cheight-270-status_bar_h, 8, #blue_hl_pal);
  254.                 }
  255.         }
  256.         else {
  257.                 DrawBar(2,start_y,190, area_h, col.lpanel);
  258.         }
  259.         PutShadow(17,start_y,160,1,1,3);
  260.         PutShadow(18,start_y+1,158,1,1,1);
  261. }