Subversion Repositories Kolibri OS

Rev

Rev 3045 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. void Tip(int y, dword caption, id, arrow)
  2. {
  3.         DrawBar(17,y,160,1,0xEFEDEE);
  4.         DrawBar(17,y+1,160,16,0xE4DFE1); //ñåðîå ñâåðõó
  5.         WriteText(25,y+5,0x80,0,caption,0);
  6.         IF (id<>0) DefineButton(159,y+1,16,16,id+BT_HIDE+BT_NOFRAME,0xE4DFE1); //êíîïà äëÿ ñòðåëêè
  7.         WriteText(165,y+5,0x80,0,arrow,0); //ñòðåëêà âíèç
  8.         DrawBar(17,y+17,160,1,0x94AECE);                //ïîä÷¸ðêèâàíèå
  9. }
  10.  
  11.  
  12. path_string disk_list[20];
  13. int disc_num;
  14. dword devbuf;
  15.  
  16. void GetSystemDiscs()
  17. {
  18.         unsigned char dev_name[10], sys_discs[10];
  19.         unsigned int i1, j1, dev_num, dev_disc_num;
  20.        
  21.         disc_num=0;
  22.         if (devbuf) free(devbuf);
  23.         devbuf= malloc(3112); //áóôåð ãäå-òî íà 10 äåâàéñîâ â ëåâîé ïàíåëè
  24.         ReadDir(19, devbuf, "/");
  25.         dev_num = EBX;
  26.         for (i1=0; i1<dev_num; i1++)
  27.         {
  28.                 copystr("/", #dev_name);                                 // /
  29.                 copystr(i1*304+ devbuf+72, #dev_name+strlen(#dev_name)); // /rd
  30.                 copystr("/", #dev_name+strlen(#dev_name));               // /rd/
  31.                
  32.                 Open_Dir(#dev_name, ONLY_OPEN);
  33.                 dev_disc_num = count;
  34.                 //if (count<=0) copystr(#dev_name,#disk_list[disc_num].Item); else
  35.                 for (j1=0; j1<dev_disc_num; j1++;)
  36.                 {
  37.                         copystr(#dev_name, #sys_discs);                              // /rd/
  38.                         copystr(j1*304+ buf+72, #sys_discs+strlen(#sys_discs));      // /rd/1
  39.                         copystr("/", #sys_discs+strlen(#sys_discs));                 // /rd/1/
  40.                         copystr(#sys_discs,#disk_list[disc_num].Item);
  41.                         disc_num++;
  42.                 }
  43.         }
  44. }
  45.  
  46.  
  47. void DrawSystemDiscs()
  48. {    
  49.         byte disc_icon;
  50.         char dev_name[10];
  51.         char disc_name[100];
  52.         int i, dev_icon;
  53.        
  54.         for (i=0; i<20; i++) DeleteButton(i);
  55.         //ñïèñîê äèñêîâ
  56.         Tip(56, "Devices", 78, "=");
  57.         for (i=0;i<disc_num;i++)
  58.         {
  59.                 DrawBar(17,i*16+74,160,17,0xFFFFFF); //ôîí
  60.                 DefineButton(17,i*16+74,159,16,100+i+BT_HIDE,0xFFFFFF); //ñîçäà¸ì êíîïêè, à ïîòîì âûâîäèì íàçâàíèÿ äèñêîâ
  61.                 strcpy(#dev_name, #disk_list[i].Item);
  62.                 dev_name[strlen(#dev_name)-1]=NULL;
  63.                 switch(dev_name[1])
  64.                 {
  65.                         case 'r':
  66.                                 dev_icon=0;
  67.                                 strcpy(#disc_name, "RAM disk ");
  68.                                 break;
  69.                         case 'c':
  70.                                 dev_icon=1;
  71.                                 strcpy(#disc_name, "CD-ROM ");
  72.                                 break;
  73.                         case 'f':
  74.                                 dev_icon=2;
  75.                                 strcpy(#disc_name, "Floppy disk ");
  76.                                 break;
  77.                         case 'h':
  78.                         case 'b':
  79.                                 dev_icon=3;
  80.                                 strcpy(#disc_name, "Hard disk ");
  81.                                 break;
  82.                         case 't':
  83.                                 dev_icon=4;
  84.                                 strcpy(#disc_name, "RAM disk ");
  85.                                
  86.                                 DefineButton(17+143,i*16+74,16,16,i+130+BT_HIDE+BT_NOFRAME,0xFFFFFF);
  87.                                 WriteText(45+121,i*16+79,0x80,0xD63535,"-",0);
  88.                                 WriteText(45+121,i*16+79+1,0x80,0xBC2424,"-",0);
  89.                                 break;
  90.                         default:
  91.                                 dev_icon=3; //ïî-óìîë÷àíèþ óñòðîéñòâî âûãëÿäèò êàê æåñòÿê íî ýòî íåïðàâèëüíî
  92.                                 strcpy(#disc_name, "Unknown ");                        
  93.                 }
  94.                 strcat(#disc_name, #dev_name);
  95.                 if (show_dev_name) WriteText(45,i*16+79,0x80,0,#disc_name,0);
  96.                         else WriteText(45,i*16+79,0x80,0,#dev_name,0);
  97.                 PutImage(dev_icon*14*13*3+#devices,14,13,21,i*16+76);
  98.         }
  99. }
  100.  
  101.  
  102. void Actions()
  103. {
  104.         int actions_y=disc_num*16;
  105.        
  106.         DeleteButton(80);
  107.         DeleteButton(81);
  108.         DeleteButton(82);
  109.        
  110.         if (!show_actions)
  111.                 Tip(actions_y+90, "Actions", 77, "\x18");
  112.         else
  113.         {
  114.                 Tip(actions_y+90, "Actions", 77, "\x19"); //çàãîëîâîê
  115.                 DrawBar(17,actions_y+108,160,51,0xFFFFFF); //áåëîå
  116.                 PutImage(#factions,16,44,21,actions_y+113); //èêîíêè
  117.                 //rename file
  118.                 DefineButton(17,actions_y+108,159,16,80+BT_HIDE,0xE4DFE1);
  119.                 WriteText(42,actions_y+113,0x80,0,"Rename file",0);
  120.                 WriteText(150,actions_y+113,0x80,0x999999,"[F2]",0);
  121.                 //delete file
  122.                 DefineButton(17,actions_y+125,159,16,81+BT_HIDE,0xE4DFE1);
  123.                 WriteText(42,actions_y+130,0x80,0,"Delete file",0);
  124.                 WriteText(144,actions_y+130,0x80,0x999999,"[Del]",0);
  125.                 //create folder
  126.                 DefineButton(17,actions_y+142,159,16,82+BT_HIDE,0xE4DFE1);
  127.                 WriteText(42,actions_y+147,0x80,0,"Create folder",0);
  128.                 WriteText(150,actions_y+147,0x80,0x999999,"[F6]",0);
  129.         }
  130. }
  131.  
  132.  
  133. void LeftPanelBackground()
  134. {
  135.         int actions_y=disc_num*16;
  136.         int start_y = show_actions*51+actions_y+108;
  137.         DrawBar(2,41,190,15,lpanel_col);                      //ñèíèé ïðÿìîóãîëüíèê - íàä äåâàéñàìè
  138.         DrawBar(17,actions_y+75,160,15,lpanel_col); //ñèíèé ïðÿìîóãîëüíèê - ïîä äåâàéñàìè
  139.         DrawBar(2,56,15,actions_y+103,lpanel_col);                //ñèíèé ïðÿìîóãîëüíèê - ñëåâà      
  140.         DrawBar(177,56,15,actions_y+103,lpanel_col);            //ñèíèé ïðÿìîóãîëüíèê - ñïðàâà
  141.         if (onTop(start_y, 6) < 268)
  142.                 PutPaletteImage(#blue_hl, 190, onTop(start_y, 6), 2, start_y, #blue_hl_pal);
  143.         else
  144.         {
  145.                 DrawBar(2,start_y,190,onTop(start_y,6+268),lpanel_col);
  146.                 PutPaletteImage(#blue_hl, 190, 268, 2, onTop(268,6), #blue_hl_pal);
  147.                 if (onTop(268,6)>300) PutPaletteImage(#blue_hl, 190, 87, 2, start_y+100, #blue_hl_pal);
  148.         }
  149. }
  150.  
  151.  
  152. void DrawLeftPanel()
  153. {
  154.         DrawSystemDiscs();
  155.         Actions();
  156.         LeftPanelBackground();
  157. }
  158.  
  159.