Subversion Repositories Kolibri OS

Rev

Rev 8868 | Rev 8917 | 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.                 59, "®¢ë© ä ©«", "F9",
  7.                 57, "®¢ ï ¯ ¯ª ", "F7",
  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.                 59, "New file", "F9",
  25.                 57, "New folder", "F7",
  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 DrawSelect();
  47.         void DrawOptions();
  48.         void Click();
  49. } SystemDiscs=0;
  50.  
  51. #define DEV_H 17
  52. #define DEV_H_HOR 20
  53.  
  54. void GetDiskIconAndName(char disk_first_letter, dword dev_icon, disc_name)
  55. {
  56.         switch(disk_first_letter)
  57.         {
  58.                 case 'r':
  59.                         ESBYTE[dev_icon]=0;
  60.                         strcpy(disc_name, T_SYS);
  61.                         break;
  62.                 case 'k':
  63.                         ESBYTE[dev_icon]=1;
  64.                         strcpy(disc_name, T_PROG);
  65.                         break;
  66.                 case 'f':
  67.                         ESBYTE[dev_icon]=2;
  68.                         strcpy(disc_name, T_FD);
  69.                         break;
  70.                 case 'c':
  71.                         ESBYTE[dev_icon]=3;
  72.                         strcpy(disc_name, T_CD);
  73.                         break;
  74.                 case 'h':
  75.                 case 'b':
  76.                         ESBYTE[dev_icon]=4;
  77.                         strcpy(disc_name, T_HD);
  78.                         break;
  79.                 case 's':
  80.                         ESBYTE[dev_icon]=4;
  81.                         strcpy(disc_name, T_SATA);
  82.                         break;
  83.                 case 't':
  84.                         ESBYTE[dev_icon]=5;
  85.                         strcpy(disc_name, T_RAM);
  86.                         break;
  87.                 case 'u':
  88.                         ESBYTE[dev_icon]=6;
  89.                         strcpy(disc_name, T_USB);
  90.                         break;
  91.                 default:
  92.                         ESBYTE[dev_icon]=5;
  93.         }
  94. }
  95.  
  96. void _SystemDiscs::Get()
  97. {
  98.         bool kolibrios_exists=false;
  99.         char dev_name[10], sys_discs[10];
  100.         int i1, j1, dev_num_i, dev_disc_num;
  101.         dword devbuf, diskbuf;
  102.  
  103.         list.drop();
  104.         devbuf = malloc(10000);
  105.         ReadDir(19, devbuf, "/");
  106.         dev_num = dev_num_i = EBX;
  107.         for (i1=0; i1<dev_num_i; i1++)
  108.         {
  109.                 sprintf(#dev_name,"/%s",i1*304+ devbuf+72);
  110.                 GetDir(#diskbuf, #dev_disc_num, #dev_name, DIRS_NOROOT);
  111.                 for (j1=0; j1<dev_disc_num; j1++;)
  112.                 {
  113.                         sprintf(#sys_discs,"%s/%s",#dev_name,j1*304+ diskbuf+72);
  114.                         if (sys_discs[1]=='c') || (dir_exists(#sys_discs)) list.add(#sys_discs);
  115.                 }
  116.                 if (!strcmp(#sys_discs, "/rd/1"))
  117.                 {
  118.                         if (dir_exists("/kolibrios")) && (!kolibrios_exists) {
  119.                                 kolibrios_exists=true;
  120.                                 list.add("/kolibrios");
  121.                                 dev_num++;
  122.                         }
  123.                 }
  124.         }
  125.         free(devbuf);
  126.         free(diskbuf);
  127. }
  128.  
  129. #define DDW 120
  130.  
  131. void _SystemDiscs::Draw()
  132. {    
  133.         char dev_name[15], disc_name[100], i, dev_icon, is_active=0;
  134.         int draw_y, draw_x;
  135.        
  136.         for (i=0; i<30; i++) DeleteButton(100+i);
  137.  
  138.         if (efm) {
  139.                 if (active_panel==1) {
  140.                         DrawSelect(Form.cwidth/2-DDW, 10, #path, KFM_DEV_DROPDOWN_1);
  141.                         DrawSelect(Form.cwidth-DDW-2, 10, #inactive_path, KFM_DEV_DROPDOWN_2);
  142.                 } else {
  143.                         DrawSelect(Form.cwidth/2-DDW, 10, #inactive_path, KFM_DEV_DROPDOWN_1);
  144.                         DrawSelect(Form.cwidth-DDW-2, 10, #path, KFM_DEV_DROPDOWN_2);          
  145.                 }
  146.                 files.y = 40 + 17;
  147.         } else {
  148.                 draw_y = 74;
  149.                 draw_x = 17;
  150.                 for (i=0;i<list.count;i++) {
  151.                         strcpy(#dev_name, list.get(i));
  152.                         GetDiskIconAndName(dev_name[1], #dev_icon, #disc_name);
  153.                         if (strstr(#path, #dev_name)!=0) is_active=true; else is_active=false;
  154.  
  155.                         DrawBar(draw_x,draw_y,6,DEV_H+1,0xFFFFFF);
  156.                         DrawBar(draw_x+6+18,draw_y,160-6-18,DEV_H+1,0xFFFFFF);
  157.                         DefineButton(draw_x,draw_y,159,16,100+i+BT_HIDE,0xFFFFFF);
  158.                         if (show_dev_name.checked)
  159.                         {
  160.                                 strcat(#disc_name, #dev_name);
  161.                                 if (is_active) WriteText(draw_x+30,draw_y+5,0x80,0x555555,#disc_name);
  162.                                 WriteText(draw_x+29,draw_y+5,0x80,0,#disc_name);
  163.                                 //if (is_active) kfont.bold = true;
  164.                                 //kfont.WriteIntoWindow(draw_x + 29, draw_y+2, 0xFFFfff, 0x000000, kfont.size.pt, #disc_name);
  165.                                 //kfont.bold = false;
  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.                 DrawBar(draw_x+6, draw_y, 18, 1, 0xFFFfff);
  174.         }
  175. }
  176.  
  177. void _SystemDiscs::DrawSelect(int draw_x, draw_y, path1, btid)
  178. {
  179.         char dev_name[15], disc_name[100], i, dev_icon, is_active=0;
  180.         if (ESBYTE[path1+1]=='\0') {
  181.                 strcpy(#dev_name, "/root");
  182.                 dev_icon = 0;
  183.         } else if (chrnum(path1, '/')==1) {
  184.                 strcpy(#dev_name, path1);
  185.                 GetDiskIconAndName(dev_name[1], #dev_icon, #disc_name);
  186.         } else for (i=0;i<list.count;i++) {
  187.                 strcpy(#dev_name, list.get(i));
  188.                 GetDiskIconAndName(dev_name[1], #dev_icon, #disc_name);
  189.                 if (strstr(path1, #dev_name)-path1==0) break;
  190.         }
  191.         DrawRectangle(draw_x-1, draw_y-1, DDW+2-DEV_H_HOR, DEV_H_HOR+1, sc.work_graph);
  192.         DrawBar(draw_x, draw_y, DDW+1-DEV_H_HOR, DEV_H_HOR, 0xFFFFFF);
  193.         _PutImage(draw_x + 5, draw_y+2, 18,17, is_active*7+dev_icon*17*18*3+#devices);
  194.         kfont.WriteIntoWindow(draw_x + 24, draw_y+2, 0xFFFfff, 0x000000, kfont.size.pt, #dev_name+1);
  195.         DefineButton(draw_x, draw_y, DDW-1, DEV_H_HOR-1, btid+1+BT_HIDE,0xFFFFFF);
  196.         DrawFlatButtonSmall(draw_x+DDW-DEV_H_HOR+1, draw_y-1, DEV_H_HOR-1, DEV_H_HOR+1, btid, "\x19");
  197.  
  198.         draw_x += DDW + 1;
  199.         //DrawBar(draw_x, draw_y, Form.cwidth - draw_x - 2, DEV_H_HOR, sc.work);
  200. }
  201.  
  202. void _SystemDiscs::DrawOptions(int draw_x, draw_y)
  203. {
  204.         char dev_name[15], disc_name[100], i, dev_icon, is_active=0;
  205.                
  206.         for (i=0; i<30; i++) DeleteButton(100+i);
  207.  
  208.         DrawPopup(draw_x, draw_y, DDW, list.count*DEV_H_HOR, 1, -1, sc.work_graph);
  209.  
  210.         for (i=0;i<list.count;i++) {
  211.                 strcpy(#dev_name, list.get(i));
  212.                 GetDiskIconAndName(dev_name[1], #dev_icon, #disc_name);
  213.                 if (strstr(#path, #dev_name)!=0) is_active=true; else is_active=false;
  214.  
  215.                 DrawBar(draw_x, draw_y, DDW, DEV_H_HOR, 0xFFFFFF);
  216.                 DefineButton(draw_x, draw_y, DDW, DEV_H_HOR-1, 100+i+BT_HIDE,0xFFFFFF);
  217.                 _PutImage(draw_x + 5, draw_y+2, 18,17, is_active*7+dev_icon*17*18*3+#devices);
  218.                 if (is_active) kfont.bold = true;
  219.                 kfont.WriteIntoWindow(draw_x + 24, draw_y+2, 0xFFFfff, 0x000000, kfont.size.pt, #dev_name+1);
  220.                 kfont.bold = false;
  221.                 draw_y += DEV_H_HOR;
  222.         }
  223. }
  224.  
  225. void _SystemDiscs::Click(int n)
  226. {
  227.         strcpy(#path, list.get(n));
  228.         files.KeyHome();
  229.         Open_Dir(#path,WITH_REDRAW);   
  230. }
  231.  
  232.  
  233.  
  234. void DrawDeviceAndActionsLeftPanel()
  235. {
  236.         Tip(56, T_DEVICES, 55, "=");
  237.         SystemDiscs.Draw();
  238.         ActionsDraw();
  239.         DrawLeftPanelBg();
  240. }
  241.  
  242. dword col_palette_inner[14] = {0xD2D3D3,0xD4D4D4,0xD6D5D6,0xD8D7D8,0xDAD8D9,0xDCDADB,
  243.         0xDFDCDD,0xE1DDDE,0xE2DEE0,0xE4DFE1,0xE3DFE1,0xE3DFE1,0xE3DFE1,0xE3DFE1,0xE3DFE1};
  244. void DrawFilledBarInner(dword x, y, w, h)
  245. {
  246.         int i, fill_h;
  247.         if (h <= 14) fill_h = h; else fill_h = 14;
  248.         for (i=0; i<fill_h; i++) DrawBar(x, y+i, w, 1, col_palette_inner[14-i]);
  249.         DrawBar(x, y+i, w, h-fill_h, col_palette_inner[14-i]);
  250. }
  251.  
  252. void Tip(int y, dword caption, id, arrow)
  253. {
  254.         if (col.def) {
  255.                 DrawBar(17,y,160,1,0xEFEDEE);
  256.                 DrawFilledBarInner(17, y+1, 160, 16);
  257.                 DrawBar(17,y+17,160,1,0x7E87A3);
  258.         } else {
  259.                 DrawBar(17,y,160,1,sc.work_graph);
  260.                 DrawBar(17,y+1,160,16,col.list_bg);
  261.                 DrawBar(17,y+17,160,1,sc.work_graph);
  262.         }
  263.         WriteText(25,y+5,0x80,col.list_gb_text,caption);
  264.         if (id) DefineButton(159,y+1,16,16,id+BT_HIDE+BT_NOFRAME,0); //arrow button
  265.         WriteText(165,y+5,0x80,col.list_gb_text,arrow); //arrow
  266. }
  267.  
  268. void ActionsDraw()
  269. {
  270.         int i;
  271.         int actions_y= SystemDiscs.list.count*DEV_H+108;
  272.         Tip(actions_y-18, T_ACTIONS, 77, "");
  273.         for (i=0; actions[i*3]!=0; i++, actions_y+=DEV_H)
  274.         {
  275.                 DrawBar(17,actions_y,160,DEV_H,0xFFFFFF); //áåëîå
  276.                 DefineButton(17,actions_y,159,DEV_H,actions[i*3]+BT_HIDE,0xE4DFE1);
  277.                 WriteText(45,actions_y+4,0x80,0,actions[i*3+1]);
  278.                 WriteText(-strlen(actions[i*3+2])*6+170,actions_y+4,0x80,0x999999,actions[i*3+2]);
  279.                 _PutImage(23,actions_y+2, 14,13, i*14*13*3+#factions);
  280.         }
  281. }
  282.  
  283. void DrawLeftPanelBg()
  284. {
  285.         int actions_y = SystemDiscs.list.count*DEV_H;
  286.         int start_y = actions_y+159;
  287.         int area_h;
  288.         DrawBar(2,41,190,15,waves_pal[0]);                    //above devices block
  289.         DrawBar(17,actions_y+75,160,15,waves_pal[0]); //below devices block
  290.         PutShadow(17,actions_y+75,160,1,1,3);
  291.         PutShadow(18,actions_y+75+1,158,1,1,1);
  292.         DrawBar(2,56,15,actions_y+103,waves_pal[0]);              //on the left
  293.         DrawBar(177,56,15,actions_y+103,waves_pal[0]);            //on the right
  294.         area_h = Form.cheight-start_y-2 - status_bar_h;
  295.         if (area_h < 268){
  296.                 PutPaletteImage(#blue_hl, 190, area_h, 2, start_y, 8, #waves_pal);
  297.         } else {
  298.                 DrawBar(2,start_y,190, area_h-268, waves_pal[0]);
  299.                 PutPaletteImage(#blue_hl, 190, 268, 2, Form.cheight-270-status_bar_h, 8, #waves_pal);
  300.         }
  301.         PutShadow(17,start_y,160,1,1,3);
  302.         PutShadow(18,start_y+1,158,1,1,1);
  303. }