Subversion Repositories Kolibri OS

Rev

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

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