Subversion Repositories Kolibri OS

Rev

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