Subversion Repositories Kolibri OS

Rev

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