Subversion Repositories Kolibri OS

Rev

Rev 7310 | Rev 7422 | 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.         byte 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. dword __countSysDiscs = 0;
  92. byte _SystemDiscs::Get()
  93. {
  94.         byte ret = 0;
  95.         char dev_name[10], sys_discs[10];
  96.         int i1, j1, dev_num, dev_disc_num;
  97.         dword temp_file_count, tempbuf;
  98.         dword devbuf;
  99.  
  100.         list.drop();
  101.         devbuf = malloc(10000);
  102.         ReadDir(19, devbuf, "/");
  103.         dev_num = EBX;
  104.         IF (dev_num != __countSysDiscs)
  105.         {
  106.                 __countSysDiscs = dev_num;
  107.                 ret = 0xFF;
  108.         }
  109.         ELSE ret = 0;
  110.         for (i1=0; i1<dev_num; i1++)
  111.         {
  112.                 sprintf(#dev_name,"/%s",i1*304+ devbuf+72);
  113.                 Open_Dir(#dev_name, ONLY_OPEN);
  114.                 dev_disc_num = files.count;
  115.                 for (j1=0; j1<dev_disc_num; j1++;)
  116.                 {
  117.                         sprintf(#sys_discs,"%s/%s",#dev_name,j1*304+ buf+72);
  118.                         list.add(#sys_discs);
  119.                 }
  120.                 if (!strcmp(#sys_discs, "/rd/1"))
  121.                 {
  122.                         GetDir(#tempbuf, #temp_file_count, "/kolibrios", DIRS_ONLYREAL);
  123.                         if (temp_file_count) list.add("/kolibrios");
  124.                         free(tempbuf);
  125.                 }
  126.         }
  127.         free(devbuf);
  128.         return ret;
  129. }
  130.  
  131. void _SystemDiscs::Draw()
  132. {    
  133.         char dev_name[15], disc_name[100], i, dev_icon, is_active, name_len;
  134.         int draw_y, draw_x, draw_h;
  135.        
  136.         for (i=0; i<30; i++) DeleteButton(100+i);
  137.  
  138.         if ( two_panels.checked) { draw_y = 41; draw_x =  2; draw_h = 21; }
  139.         if (!two_panels.checked) { draw_y = 74; draw_x = 17; draw_h = 16; }
  140.  
  141.         for (i=0;i<list.count;i++)
  142.         {
  143.                 strcpy(#dev_name, list.get(i));
  144.                 GetDiskIconAndName(dev_name[1], #dev_icon, #disc_name);
  145.                 if (strstr(#path, #dev_name)-#path==0) is_active=true; else is_active=false;
  146.                 if (two_panels.checked)
  147.                 {
  148.                         name_len = strlen(#dev_name)-1*8;
  149.                         DrawBar(draw_x, draw_y, name_len + 31, draw_h, 0xFFFFFF);
  150.                         DefineButton(draw_x+2, draw_y, name_len + 27, draw_h-1, 100+i+BT_HIDE,0xFFFFFF);
  151.                         _PutImage(draw_x + 5, draw_y+2, 18,17, is_active*6+dev_icon*17*18*3+#devices);
  152.                         WriteText(draw_x + 24, draw_y+3, 10110000b, 0, #dev_name+1);
  153.                         draw_x += name_len + 31;
  154.                         if (draw_x>=Form.width-35) && (Form.width) {
  155.                                 DrawBar(draw_x, draw_y, Form.cwidth - draw_x - 2, draw_h, 0xFFFFFF);
  156.                                 draw_x = 2;
  157.                                 draw_y += draw_h;
  158.                         }
  159.                 }
  160.                 else
  161.                 {
  162.                         DrawBar(draw_x,draw_y,6,draw_h+1,0xFFFFFF);
  163.                         DrawBar(draw_x+6+18,draw_y,160-6-18,draw_h+1,0xFFFFFF);
  164.                         DefineButton(draw_x,draw_y,159,16,100+i+BT_HIDE,0xFFFFFF);
  165.                         if (show_dev_name.checked)
  166.                         {
  167.                                 strcat(#disc_name, #dev_name);
  168.                                 if (is_active) WriteText(draw_x+30,draw_y+5,0x80,0x555555,#disc_name);
  169.                                 WriteText(draw_x+29,draw_y+5,0x80,0,#disc_name);                        }
  170.                         else
  171.                         {
  172.                                 if (is_active) WriteText(draw_x+30,draw_y+5,0x80,0x555555,#dev_name);
  173.                                 WriteText(draw_x+29,draw_y+5,0x80,0,#dev_name);
  174.                         }
  175.                         _PutImage(draw_x+6,draw_y, 18,17, is_active*6+dev_icon*17*18*3+#devices);
  176.                         draw_y += draw_h;
  177.                 }
  178.         }
  179.         if (two_panels.checked)
  180.         {
  181.                 DrawBar(draw_x, draw_y, Form.cwidth - draw_x - 2, draw_h, 0xFFFFFF);
  182.                 DefineButton(Form.cwidth - 23, draw_y+2, 17,16, 60+BT_HIDE, 0xCCCccc);
  183.                 _PutImage(Form.cwidth - 21, draw_y+4, 14,13, 2*14*13*3+#factions);
  184.                 files.y = draw_y + draw_h + 17;
  185.         }
  186. }
  187.  
  188. void _SystemDiscs::Click(int n)
  189. {
  190.         strcpy(#path, list.get(n));
  191.         files.KeyHome();
  192.         Open_Dir(#path,WITH_REDRAW);   
  193. }
  194.  
  195.  
  196.  
  197. void DrawDeviceAndActionsLeftPanel()
  198. {
  199.         Tip(56, T_DEVICES, 55, "=");
  200.         SystemDiscs.Draw();
  201.         ActionsDraw();
  202.         DrawLeftPanelBg();
  203. }
  204.  
  205. void Tip(int y, dword caption, id, arrow)
  206. {
  207.         DrawBar(17,y,160,1,0xEFEDEE);
  208.         DrawFilledBar(17, y+1, 160, 16);
  209.         WriteText(25,y+5,0x80,0x000000,caption);
  210.         if (id) DefineButton(159,y+1,16,16,id+BT_HIDE+BT_NOFRAME,0); //arrow button
  211.         WriteText(165,y+5,0x80,0x000000,arrow); //arrow
  212.         DrawBar(17,y+17,160,1,col_graph);
  213. }
  214.  
  215. void ActionsDraw()
  216. {
  217.         int actions_y= SystemDiscs.list.count*16+108, lineh=16;
  218.         Tip(actions_y-18, T_ACTIONS, 77, ""); //çàãîëîâîê
  219.         for (i=0; actions[i*3]!=0; i++, actions_y+=lineh)
  220.         {
  221.                 DrawBar(17,actions_y,160,lineh,0xFFFFFF); //áåëîå
  222.                 DefineButton(17,actions_y,159,lineh,actions[i*3]+BT_HIDE,0xE4DFE1);
  223.                 WriteText(45,actions_y+4,0x80,0,actions[i*3+1]);
  224.                 WriteText(-strlen(actions[i*3+2])*6+170,actions_y+4,0x80,0x999999,actions[i*3+2]);
  225.                 _PutImage(23,actions_y+2, 14,13, i*14*13*3+#factions);
  226.         }
  227. }
  228.  
  229. void DrawLeftPanelBg()
  230. {
  231.         int actions_y = SystemDiscs.list.count*16;
  232.         int start_y = actions_y+156;
  233.         int area_h;
  234.         DrawBar(2,41,190,15,col_lpanel);                      //ñèíèé ïðÿìîóãîëüíèê - íàä äåâàéñàìè
  235.         DrawBar(17,actions_y+75,160,15,col_lpanel); //ñèíèé ïðÿìîóãîëüíèê - ïîä äåâàéñàìè
  236.         PutShadow(17,actions_y+75,160,1,1,3);
  237.         PutShadow(18,actions_y+75+1,158,1,1,1);
  238.         DrawBar(2,56,15,actions_y+103,col_lpanel);                //ñèíèé ïðÿìîóãîëüíèê - ñëåâà      
  239.         DrawBar(177,56,15,actions_y+103,col_lpanel);            //ñèíèé ïðÿìîóãîëüíèê - ñïðàâà
  240.         area_h = Form.cheight-start_y-2 - status_bar_h;
  241.         if (area_h < 268)
  242.         {
  243.                 PutPaletteImage(#blue_hl, 190, area_h, 2, start_y, 8, #blue_hl_pal);
  244.         }
  245.         else
  246.         {
  247.                 DrawBar(2,start_y,190, area_h-268, col_lpanel);
  248.                 PutPaletteImage(#blue_hl, 190, 268, 2, Form.cheight-270-status_bar_h, 8, #blue_hl_pal);
  249.         }
  250.         PutShadow(17,start_y,160,1,1,3);
  251.         PutShadow(18,start_y+1,158,1,1,1);
  252. }