Subversion Repositories Kolibri OS

Rev

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