Subversion Repositories Kolibri OS

Rev

Rev 3363 | Rev 3434 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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