Subversion Repositories Kolibri OS

Rev

Rev 3399 | Go to most recent revision | Blame | Compare with Previous | 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);
  7.         IF (id<>0) DefineButton(159,y+1,16,16,id+BT_HIDE+BT_NOFRAME,0xE4DFE1); //êíîïà äëÿ ñòðåëêè
  8.         WriteText(165,y+5,0x80,0,arrow); //ñòðåëêà âíèç
  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.                 strcpy(#dev_name, "/");                                 // /
  30.                 strcat(#dev_name, i1*304+ devbuf+72); // /rd
  31.                 strcat(#dev_name, "/");               // /rd/
  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.                         strcpy(#sys_discs, #dev_name);                              // /rd/
  38.                         strcat(#sys_discs, j1*304+ buf+72);      // /rd/1
  39.                         strcat(#sys_discs, "/");                 // /rd/1/
  40.                         strcpy(#disk_list[disc_num].Item, #sys_discs);
  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(100+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 'u':
  83.                                 dev_icon=5;
  84.                                 strcpy(#disc_name, "USB flash ");
  85.                                 break;
  86.                         case 't':
  87.                                 dev_icon=4;
  88.                                 strcpy(#disc_name, "RAM disk ");                               
  89.                                 DefineButton(17+143,i*16+74,16,16,i+130+BT_HIDE+BT_NOFRAME,0xFFFFFF);
  90.                                 WriteText(45+121,i*16+79,0x80,0xD63535,"-");
  91.                                 WriteText(45+121,i*16+79+1,0x80,0xBC2424,"-");
  92.                                 break;
  93.                         default:
  94.                                 dev_icon=3; //ïî-óìîë÷àíèþ óñòðîéñòâî âûãëÿäèò êàê æåñòÿê íî ýòî íåïðàâèëüíî
  95.                                 strcpy(#disc_name, "Unknown ");                        
  96.                 }
  97.                 strcat(#disc_name, #dev_name);
  98.                 if (show_dev_name) WriteText(45,i*16+79,0x80,0,#disc_name);
  99.                         else WriteText(45,i*16+79,0x80,0,#dev_name);
  100.                 _PutImage(21,i*16+76, 14,13, dev_icon*14*13*3+#devices);
  101.         }
  102. }
  103.  
  104. void FileMenu()
  105. {
  106.         word id, key;
  107.         loop() switch(WaitEvent())
  108.         {
  109.                 case evButton:
  110.                                 id=GetButtonID();
  111.                                 ExitProcess();
  112.                                 break;
  113.                                
  114.                 case evKey:
  115.                                 IF (GetKey()==27) ExitProcess();
  116.                                 break;
  117.                                
  118.                 case evReDraw:
  119.                         DefineAndDrawWindow(m.x+1+Form.left,m.y+Form.top,159,90,0x01,0xEEEeee,0x01fffFFF);
  120.                         DrawBar(1,18,160,51,0xFFFFFF); //áåëîå
  121.                         _PutImage(1,23, 16,44, #factions); //èêîíêè
  122.                         //rename file
  123.                         DefineButton(1,18,159,16,80+BT_HIDE,0xE4DFE1);
  124.                         WriteText(26,23,0x80,0,"Rename file");
  125.                         WriteText(134,23,0x80,0x999999,"[F2]");
  126.                         //delete file
  127.                         DefineButton(1,35,159,16,81+BT_HIDE,0xE4DFE1);
  128.                         WriteText(26,40,0x80,0,"Delete file");
  129.                         WriteText(144,40,0x80,0x999999,"[Del]");
  130.                         //create folder
  131.                         DefineButton(1,52,159,16,82+BT_HIDE,0xE4DFE1);
  132.                         WriteText(26,57,0x80,0,"Create folder");
  133.                         WriteText(134,57,0x80,0x999999,"[F6]");
  134.         }
  135. }
  136.  
  137. void Actions()
  138. {
  139.         int actions_y=disc_num*16;
  140.        
  141.         DeleteButton(80);
  142.         DeleteButton(81);
  143.         DeleteButton(82);
  144.        
  145.         if (!show_actions)
  146.                 Tip(actions_y+90, "Actions", 77, "\x18");
  147.         else
  148.         {
  149.                 Tip(actions_y+90, "Actions", 77, "\x19"); //çàãîëîâîê
  150.                 DrawBar(17,actions_y+108,160,51,0xFFFFFF); //áåëîå
  151.                 _PutImage(21,actions_y+113, 16,44, #factions); //èêîíêè
  152.                 //rename file
  153.                 DefineButton(17,actions_y+108,159,16,80+BT_HIDE,0xE4DFE1);
  154.                 WriteText(42,actions_y+113,0x80,0,"Rename file");
  155.                 WriteText(150,actions_y+113,0x80,0x999999,"[F2]");
  156.                 //delete file
  157.                 DefineButton(17,actions_y+125,159,16,81+BT_HIDE,0xE4DFE1);
  158.                 WriteText(42,actions_y+130,0x80,0,"Delete file");
  159.                 WriteText(144,actions_y+130,0x80,0x999999,"[Del]");
  160.                 //create folder
  161.                 DefineButton(17,actions_y+142,159,16,82+BT_HIDE,0xE4DFE1);
  162.                 WriteText(42,actions_y+147,0x80,0,"Create folder");
  163.                 WriteText(150,actions_y+147,0x80,0x999999,"[F6]");
  164.         }
  165. }
  166.  
  167.  
  168. void LeftPanelBackground()
  169. {
  170.         int actions_y=disc_num*16;
  171.         int start_y = show_actions*51+actions_y+108;
  172.         DrawBar(2,41,190,15,col_lpanel);                      //ñèíèé ïðÿìîóãîëüíèê - íàä äåâàéñàìè
  173.         DrawBar(17,actions_y+75,160,15,col_lpanel); //ñèíèé ïðÿìîóãîëüíèê - ïîä äåâàéñàìè
  174.         DrawBar(2,56,15,actions_y+103,col_lpanel);                //ñèíèé ïðÿìîóãîëüíèê - ñëåâà      
  175.         DrawBar(177,56,15,actions_y+103,col_lpanel);            //ñèíèé ïðÿìîóãîëüíèê - ñïðàâà
  176.         if (onTop(start_y, 6) < 268)
  177.                 PutPaletteImage(#blue_hl, 190, onTop(start_y, 6), 2, start_y, 8, #blue_hl_pal);
  178.         else
  179.         {
  180.                 DrawBar(2,start_y,190,onTop(start_y,6+268),col_lpanel);
  181.                 PutPaletteImage(#blue_hl, 190, 268, 2, onTop(268,6), 8, #blue_hl_pal);
  182.         }
  183. }
  184.  
  185.  
  186. void DrawLeftPanel()
  187. {
  188.         DrawSystemDiscs();
  189.         Actions();
  190.         LeftPanelBackground();
  191. }
  192.  
  193.