Subversion Repositories Kolibri OS

Rev

Rev 8946 | Rev 8951 | 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. #define DEV_H 17
  61. #define DDW 120
  62. #define KFM2_DEVH 20
  63.  
  64. void _SystemDiscs::Draw()
  65. {    
  66.         char dev_name[15], disc_name[100], i, dev_icon;
  67.         bool is_active=0;
  68.         int draw_y, draw_x;
  69.        
  70.         for (i=0; i<30; i++) DeleteButton(100+i);
  71.  
  72.         if (efm) {
  73.                 DrawSelect(Form.cwidth/2-DDW, KFM_DEV_DROPDOWN_1, location[0]);
  74.                 DrawSelect(Form.cwidth-DDW-2, KFM_DEV_DROPDOWN_2, location[sizeof(dword)]);
  75.                 files.y = 40 + 17;
  76.         } else {
  77.                 draw_y = 74;
  78.                 draw_x = 17;
  79.                 for (i=0;i<list.count;i++) {
  80.                         strcpy(#dev_name, list.get(i));
  81.                         GetDiskIconAndName(dev_name[1], #dev_icon, #disc_name);
  82.                         if (strstr(path, #dev_name)==path) is_active=true; else is_active=false;
  83.  
  84.                         DrawBar(draw_x,draw_y,6,DEV_H+1,0xFFFFFF);
  85.                         DrawBar(draw_x+6+18,draw_y,160-6-18,DEV_H+1,0xFFFFFF);
  86.                         DefineHiddenButton(draw_x,draw_y,159,16,100+i);
  87.                         if (show_dev_name.checked)
  88.                         {
  89.                                 strcat(#disc_name, #dev_name);
  90.                                 if (is_active) WriteText(draw_x+30,draw_y+5,0x80,0x555555,#disc_name);
  91.                                 WriteText(draw_x+29,draw_y+5,0x80,0,#disc_name);
  92.                                 //if (is_active) kfont.bold = true;
  93.                                 //kfont.WriteIntoWindow(draw_x + 29, draw_y+2, 0xFFFfff, 0x000000, kfont.size.pt, #disc_name);
  94.                                 //kfont.bold = false;
  95.                         } else {
  96.                                 if (is_active) WriteText(draw_x+30,draw_y+5,0x80,0x555555,#dev_name);
  97.                                 WriteText(draw_x+29,draw_y+5,0x80,0,#dev_name);
  98.                         }
  99.                         _PutImage(draw_x+6,draw_y, 18,17, is_active*7+dev_icon*17*18*3+#devices);
  100.                         draw_y += DEV_H;                       
  101.                 }
  102.                 DrawBar(draw_x+6, draw_y, 18, 1, 0xFFFfff);
  103.         }
  104. }
  105.  
  106. void _SystemDiscs::DrawSelect(int draw_x, btid, dword _path)
  107. {
  108.         #define SELECTY 10
  109.         char dev_name[15], disc_name[100], i, dev_icon;
  110.  
  111.         if (ESBYTE[_path+1]=='\0') {
  112.                 strcpy(#dev_name, "/root");
  113.                 dev_icon = 0;
  114.         } else if (chrnum(_path, '/')==1) {
  115.                 strcpy(#dev_name, _path);
  116.                 GetDiskIconAndName(dev_name[1], #dev_icon, #disc_name);
  117.         } else for (i=0;i<list.count;i++) {
  118.                 strcpy(#dev_name, list.get(i));
  119.                 GetDiskIconAndName(dev_name[1], #dev_icon, #disc_name);
  120.                 if (strstr(_path, #dev_name)-_path==0) break;
  121.         }
  122.         DrawRectangle(draw_x-1, SELECTY-1, DDW+2-KFM2_DEVH, KFM2_DEVH+1, sc.work_graph);
  123.         DrawBar(draw_x, SELECTY, DDW+1-KFM2_DEVH, KFM2_DEVH, 0xFFFFFF);
  124.         _PutImage(draw_x + 5, SELECTY+2, 18,17, dev_icon*17*18*3+#devices);
  125.         kfont.WriteIntoWindow(draw_x + 24, math.max(KFM2_DEVH-kfont.height/2+SELECTY,0), 0xFFFfff, 0x000000, kfont.size.pt, #dev_name+1);
  126.         DefineHiddenButton(draw_x, SELECTY, DDW-1, KFM2_DEVH-1, btid+1);
  127.         DrawFlatButtonSmall(draw_x+DDW-KFM2_DEVH+1, SELECTY-1, KFM2_DEVH-1, KFM2_DEVH+1, btid, "\x19");
  128. }
  129.  
  130. void _SystemDiscs::DrawOptions(int draw_x)
  131. {
  132.         int optionsy = SELECTY+KFM2_DEVH+1;
  133.         char dev_name[15], disc_name[100], i, dev_icon, is_active=0;
  134.                
  135.         for (i=0; i<30; i++) DeleteButton(100+i);
  136.  
  137.         DrawPopup(draw_x, optionsy, DDW, list.count*KFM2_DEVH, 1, -1, sc.work_graph);
  138.  
  139.         for (i=0;i<list.count;i++) {
  140.                 strcpy(#dev_name, list.get(i));
  141.                 GetDiskIconAndName(dev_name[1], #dev_icon, #disc_name);
  142.                 if (strstr(path, #dev_name)!=0) is_active=true; else is_active=false;
  143.  
  144.                 DrawBar(draw_x, optionsy, DDW, KFM2_DEVH, 0xFFFFFF);
  145.                 DefineButton(draw_x, optionsy, DDW, KFM2_DEVH-1, 100+i+BT_HIDE,0xFFFFFF);
  146.                 _PutImage(draw_x + 5, optionsy+2, 18,17, is_active*7+dev_icon*17*18*3+#devices);
  147.                 if (is_active) kfont.bold = true;
  148.                 kfont.WriteIntoWindow(draw_x + 24, optionsy+2, 0xFFFfff, 0x000000, kfont.size.pt, #dev_name+1);
  149.                 kfont.bold = false;
  150.                 optionsy += KFM2_DEVH;
  151.         }
  152. }
  153.  
  154. void _SystemDiscs::Click(int n)
  155. {
  156.         strcpy(path, list.get(n));
  157.         files.KeyHome();
  158.         Open_Dir(path,WITH_REDRAW);    
  159. }
  160.  
  161.  
  162.  
  163. void DrawDeviceAndActionsLeftPanel()
  164. {
  165.         Tip(56, T_DEVICES, 55, "=");
  166.         SystemDiscs.Draw();
  167.         ActionsDraw();
  168.         DrawLeftPanelBg();
  169. }
  170.  
  171. dword col_palette_inner[14] = {0xD2D3D3,0xD4D4D4,0xD6D5D6,0xD8D7D8,0xDAD8D9,0xDCDADB,
  172.         0xDFDCDD,0xE1DDDE,0xE2DEE0,0xE4DFE1,0xE3DFE1,0xE3DFE1,0xE3DFE1,0xE3DFE1,0xE3DFE1};
  173. void DrawFilledBarInner(dword x, y, w, h)
  174. {
  175.         int i, fill_h;
  176.         if (h <= 14) fill_h = h; else fill_h = 14;
  177.         for (i=0; i<fill_h; i++) DrawBar(x, y+i, w, 1, col_palette_inner[14-i]);
  178.         DrawBar(x, y+i, w, h-fill_h, col_palette_inner[14-i]);
  179. }
  180.  
  181. void Tip(int y, dword caption, id, arrow)
  182. {
  183.         if (col.def) {
  184.                 DrawBar(17,y,160,1,0xEFEDEE);
  185.                 DrawFilledBarInner(17, y+1, 160, 16);
  186.                 DrawBar(17,y+17,160,1,0x7E87A3);
  187.         } else {
  188.                 DrawBar(17,y,160,1,sc.work_graph);
  189.                 DrawBar(17,y+1,160,16,col.list_bg);
  190.                 DrawBar(17,y+17,160,1,sc.work_graph);
  191.         }
  192.         WriteText(25,y+5,0x80,col.list_gb_text,caption);
  193.         if (id) DefineButton(159,y+1,16,16,id+BT_HIDE+BT_NOFRAME,0); //arrow button
  194.         WriteText(165,y+5,0x80,col.list_gb_text,arrow); //arrow
  195. }
  196.  
  197. void ActionsDraw()
  198. {
  199.         int i;
  200.         int actions_y= SystemDiscs.list.count*DEV_H+108;
  201.         Tip(actions_y-18, T_ACTIONS, 77, "");
  202.         for (i=0; actions[i*3]!=0; i++, actions_y+=DEV_H)
  203.         {
  204.                 DrawBar(17,actions_y,160,DEV_H,0xFFFFFF); //áåëîå
  205.                 DefineButton(17,actions_y,159,DEV_H,actions[i*3]+BT_HIDE,0xE4DFE1);
  206.                 WriteText(45,actions_y+4,0x80,0,actions[i*3+1]);
  207.                 WriteText(-strlen(actions[i*3+2])*6+170,actions_y+4,0x80,0x999999,actions[i*3+2]);
  208.                 _PutImage(23,actions_y+2, 14,13, i*14*13*3+#factions);
  209.         }
  210. }
  211.  
  212. void DrawLeftPanelBg()
  213. {
  214.         int actions_y = SystemDiscs.list.count*DEV_H;
  215.         int start_y = actions_y+159;
  216.         int area_h;
  217.         DrawBar(2,41,190,15,waves_pal[0]);             //above devices block
  218.         DrawBar(17,actions_y+75,160,15,EDX);  //below devices block
  219.         DrawBar(2,56,15,actions_y+103,EDX);   //on the left
  220.         DrawBar(177,56,15,actions_y+103,EDX); //on the right
  221.         area_h = Form.cheight-start_y-2 - status_bar_h;
  222.         if (area_h < 268){
  223.                 PutPaletteImage(#blue_hl, 190, area_h, 2, start_y, 8, #waves_pal);
  224.         } else {
  225.                 DrawBar(2,start_y,190, area_h-268, waves_pal[0]);
  226.                 PutPaletteImage(#blue_hl, 190, 268, 2, Form.cheight-270-status_bar_h, 8, #waves_pal);
  227.         }
  228.         PutShadow(17,actions_y+75,160,1,1,3);
  229.         PutShadow(18,actions_y+75+1,158,1,1,1);
  230.         PutShadow(17,start_y,160,1,1,3);
  231.         PutShadow(18,start_y+1,158,1,1,1);
  232. }