Subversion Repositories Kolibri OS

Rev

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

  1.  
  2. struct _SystemDiscs
  3. {
  4.         collection list;
  5.         int dev_num;
  6.         void Get();
  7.         void Draw();
  8.         void DrawSelect();
  9.         void DrawOptions();
  10. } SystemDiscs=0;
  11.  
  12. void _SystemDiscs::Get()
  13. {
  14.         char dev_name[10], sys_discs[10];
  15.         int i1, j1, dev_disc_num, real_dev_num;
  16.         dword devbuf, diskbuf;
  17.  
  18.         list.drop();
  19.         devbuf = malloc(10000);
  20.         ReadDir(19, devbuf, "/");
  21.         dev_num = real_dev_num = EBX;
  22.  
  23.         list.add("/sys");
  24.         dev_num++;
  25.  
  26.         if (dir_exists("/kolibrios")) {
  27.                 //need to check that /sys != /kolibrios
  28.                 list.add("/kolibrios");
  29.                 dev_num++;
  30.         }
  31.  
  32.         for (i1=0; i1<real_dev_num; i1++)
  33.         {
  34.                 sprintf(#dev_name,"/%s",i1*304+ devbuf+72);
  35.                 GetDir(#diskbuf, #dev_disc_num, #dev_name, DIRS_NOROOT);
  36.                 for (j1=0; j1<dev_disc_num; j1++;)
  37.                 {
  38.                         sprintf(#sys_discs,"%s/%s",#dev_name,j1*304+ diskbuf+72);
  39.                         if (sys_discs[1]=='r') {
  40.                                 dev_num--;
  41.                                 continue;
  42.                         }
  43.                         if (sys_discs[1]=='c') || (sys_discs[1]=='f') || (dir_exists(#sys_discs)) {
  44.                                 list.add(#sys_discs);
  45.                         }
  46.                 }
  47.         }
  48.         free(devbuf);
  49.         free(diskbuf);
  50. }
  51.  
  52. void GetDiskIconAndName(dword dev_name, dev_icon, disc_name)
  53. {
  54.         int i;
  55.         for (i=0; devinfo[i]!=0; i+=3) {
  56.                 if (!strncmp(dev_name+1, devinfo[i], 2)) {
  57.                         ESBYTE[dev_icon] = devinfo[i+1];
  58.                         strcpy(disc_name, devinfo[i+2]);
  59.                         return;
  60.                 }
  61.         }
  62.         ESBYTE[dev_icon]=5;
  63.         strcpy(disc_name, T_UNC);
  64. }
  65.  
  66. void _SystemDiscs::Draw()
  67. {    
  68.         char dev_name[15], disc_name[100], i, dev_icon;
  69.         bool is_active=0;
  70.         int draw_y, draw_x;
  71.        
  72.         if (efm) {
  73.                 DrawSelect(2, KFM_DEV_DROPDOWN_1, location[0]);
  74.                 DrawSelect(Form.cwidth/2, KFM_DEV_DROPDOWN_2, location[sizeof(dword)]);
  75.                 files.y = 40 + 17;
  76.         } else {
  77.                 Tip(56, T_DEVICES, 55, "=");
  78.                 for (i=0; i<30; i++) DeleteButton(100+i);
  79.  
  80.                 draw_y = 74;
  81.                 draw_x = 17;
  82.                 for (i=0;i<list.count;i++) {
  83.                         strcpy(#dev_name, list.get(i));
  84.                         GetDiskIconAndName(#dev_name, #dev_icon, #disc_name);
  85.                         if (strstr(path, #dev_name)==path) is_active=true; else is_active=false;
  86.  
  87.                         DrawBar(draw_x,draw_y,6,DEV_H+1,0xFFFFFF);
  88.                         DrawBar(draw_x+6+18,draw_y,160-6-18,DEV_H+1,0xFFFFFF);
  89.                         DefineHiddenButton(draw_x,draw_y,159,16,100+i);
  90.                         if (show_dev_name.checked)
  91.                         {
  92.                                 strcat(#disc_name, #dev_name);
  93.                                 if (is_active) WriteText(draw_x+30,draw_y+5,0x80,0x555555,#disc_name);
  94.                                 WriteText(draw_x+29,draw_y+5,0x80,0,#disc_name);
  95.                                 //if (is_active) kfont.bold = true;
  96.                                 //kfont.WriteIntoWindow(draw_x + 29, draw_y+2, 0xFFFfff, 0x000000, kfont.size.pt, #disc_name);
  97.                                 //kfont.bold = false;
  98.                         } else {
  99.                                 if (is_active) WriteText(draw_x+30,draw_y+5,0x80,0x555555,#dev_name);
  100.                                 WriteText(draw_x+29,draw_y+5,0x80,0,#dev_name);
  101.                         }
  102.                         _PutImage(draw_x+6,draw_y, 18,17, is_active*7+dev_icon*17*18*3+#devices);
  103.                         draw_y += DEV_H;                       
  104.                 }
  105.                 DrawBar(draw_x+6, draw_y, 18, 1, 0xFFFfff);
  106.                 ActionsDraw(list.count*DEV_H+108);
  107.                 DrawLeftPanelBg(list.count*DEV_H);
  108.         }
  109. }
  110.  
  111. void _SystemDiscs::DrawSelect(int draw_x, btid, dword _path)
  112. {
  113.         char dev_name[15], disc_name[100], i, dev_icon;
  114.  
  115.         if (ESBYTE[_path+1]=='\0') {
  116.                 strcpy(#dev_name, "/root");
  117.                 dev_icon = 0;
  118.         } else if (chrnum(_path, '/')==1) {
  119.                 strcpy(#dev_name, _path);
  120.                 GetDiskIconAndName(#dev_name, #dev_icon, #disc_name);
  121.         } else for (i=0;i<list.count;i++) {
  122.                 strcpy(#dev_name, list.get(i));
  123.                 GetDiskIconAndName(#dev_name, #dev_icon, #disc_name);
  124.                 if (strstr(_path, #dev_name)-_path==0) break;
  125.         }
  126.         DrawRectangle(draw_x-1, SELECTY-1, DDW+2-KFM2_DEVH, KFM2_DEVH+1, sc.work_graph);
  127.         DrawBar(draw_x, SELECTY, DDW+1-KFM2_DEVH, KFM2_DEVH, 0xFFFFFF);
  128.         _PutImage(draw_x + 5, SELECTY+2, 18,17, dev_icon*17*18*3+#devices);
  129.         kfont.WriteIntoWindow(draw_x + 24, math.max(KFM2_DEVH-kfont.height/2+SELECTY,0), 0xFFFfff, 0x000000, kfont.size.pt, #dev_name+1);
  130.         DefineHiddenButton(draw_x, SELECTY, DDW-1, KFM2_DEVH-1, btid);
  131.         DrawFlatButtonSmall(draw_x+DDW-KFM2_DEVH+1, SELECTY-1, KFM2_DEVH-1, KFM2_DEVH+1, NULL, "\x19");
  132. }
  133.  
  134. void _SystemDiscs::DrawOptions(int draw_x)
  135. {
  136.         int optionsy = SELECTY+KFM2_DEVH+1;
  137.         char dev_name[15], disc_name[100], i, dev_icon, is_active=0;
  138.                
  139.         for (i=0; i<30; i++) DeleteButton(100+i);
  140.  
  141.         DrawPopup(draw_x, optionsy, DDW, list.count*KFM2_DEVH, 1, -1, sc.work_graph);
  142.  
  143.         for (i=0;i<list.count;i++) {
  144.                 strcpy(#dev_name, list.get(i));
  145.                 GetDiskIconAndName(#dev_name, #dev_icon, #disc_name);
  146.                 if (strstr(path, #dev_name)!=0) is_active=true; else is_active=false;
  147.  
  148.                 DrawBar(draw_x, optionsy, DDW, KFM2_DEVH, 0xFFFFFF);
  149.                 DefineButton(draw_x, optionsy, DDW, KFM2_DEVH-1, 100+i+BT_HIDE,0xFFFFFF);
  150.                 _PutImage(draw_x + 5, optionsy+2, 18,17, is_active*7+dev_icon*17*18*3+#devices);
  151.                 if (is_active) kfont.bold = true;
  152.                 kfont.WriteIntoWindow(draw_x + 24, optionsy+2, 0xFFFfff, 0x000000, kfont.size.pt, #dev_name+1);
  153.                 kfont.bold = false;
  154.                 optionsy += KFM2_DEVH;
  155.         }
  156. }
  157.  
  158.  
  159.