Subversion Repositories Kolibri OS

Rev

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

  1. //Leency 2008-2013
  2.  
  3. char *captions[] = {
  4.         "Open",          "Enter",
  5.         "Open with...",  "CrlEnt",
  6.         "View as text",  "F3",
  7.         "View as HEX",   "F4",
  8.         //
  9.         "Copy",          "Crl+C",
  10.         "Cut",           "Crl+X",
  11.         "Paste",         "Crl+V",
  12.         "Rename",        "F2",
  13.         "Delete",        "Del",
  14.         //"Refresh",       "F5",
  15.         0, 0};
  16.  
  17. proc_info MenuForm;
  18.  
  19. void FileMenu()
  20. {
  21.         mouse mm;
  22.         word id, key, slot, index;
  23.         int ccount=0, cur, newi, linew=10, lineh=18, texty;
  24.         for (index=0; captions[index]!=0; index+=2)
  25.         {
  26.                 ccount++;
  27.                 if (strlen(captions[index])>linew) linew = strlen(captions[index]);
  28.         }
  29.         linew = linew + 3 * 6 + 50;
  30.         texty = lineh/2-4;
  31.         SetEventMask(100111b);
  32.  
  33.         goto _MENU_DRAW;
  34.         loop() switch(WaitEvent())
  35.         {
  36.                 case evMouse:
  37.                                 slot = GetProcessSlot(MenuForm.ID);
  38.                                 if (slot != GetActiveProcess()) ExitProcess();
  39.                                 mm.get();
  40.                                 newi = mm.y - 1 / lineh;
  41.                                 if (mm.y<=0) || (mm.y>ccount*lineh+5) || (mm.x<0) || (mm.x>linew) newi=-1;
  42.                                 if (cur<>newi)
  43.                                 {
  44.                                         cur=newi;
  45.                                         goto _ITEMS_DRAW;
  46.                                 }
  47.                                 break;
  48.  
  49.                 case evButton:
  50.                                 id=GetButtonID();
  51.                                 if (id==100) Open();
  52.                                 if (id==101) notify("Not compleated yet");
  53.                                 if (id==102) FnProcess(3); //F3
  54.                                 if (id==103) FnProcess(4); //F4
  55.                                 if (id==104) Copy(#file_path, NOCUT);
  56.                                 if (id==105) Copy(#file_path, CUT);
  57.                                 if (id==106) CreateThread(#Paste,#copy_stak);
  58.                                 if (id==107) FnProcess(2);
  59.                                 if (id==108) Del_Form();
  60.                                 if (id==109) FnProcess(5);
  61.                                 ExitProcess();
  62.                                 break;
  63.                                
  64.                 case evKey:
  65.                                 IF (GetKey()==27) ExitProcess();
  66.                                 break;
  67.                                
  68.                 case evReDraw: _MENU_DRAW:
  69.                                 DefineAndDrawWindow(m.x+Form.left+5,m.y+Form.top+GetSkinHeight(),linew+3,ccount*lineh+6,0x01, 0, 0, 0x01fffFFF);
  70.                                 GetProcessInfo(#MenuForm, SelfInfo);
  71.                                 DrawRectangle(0,0,linew+1,ccount*lineh+2,col_border);
  72.                                 DrawBar(1,1,linew,1,0xFFFfff);
  73.                                 PutShadow(linew+2,1,1,ccount*lineh+2,0,2);
  74.                                 PutShadow(linew+3,2,1,ccount*lineh+2,0,1);
  75.                                 PutShadow(1,ccount*lineh+3,linew+2,1,0,2);
  76.                                 PutShadow(2,ccount*lineh+4,linew+1,1,0,1);
  77.  
  78.                                 _ITEMS_DRAW:
  79.                                 for (index=0; captions[index*2]!=0; index++)
  80.                                 {
  81.                                         DefineButton(1,index*lineh+1,linew,lineh-1,index+100+BT_HIDE+BT_NOFRAME,0xFFFFFF);
  82.                                         DrawBar(1,index*lineh+2,1,lineh,0xFFFfff);
  83.                                         if (index==cur)
  84.                                         {
  85.                                                 DrawBar(2,index*lineh+2,linew-1,lineh,0xFFFfff);
  86.                                         }
  87.                                         else
  88.                                         {
  89.                                                 DrawBar(2,index*lineh+2,linew-1,lineh,col_work);
  90.                                                 WriteText(8,index*lineh+texty+3,0x80,0xf2f2f2,captions[index*2]);
  91.                                         }
  92.                                         WriteText(7,index*lineh+texty+2,0x80,0x000000,captions[index*2]);
  93.                                         WriteText(-strlen(captions[index*2+1])*6-6+linew,index*lineh+texty+2,0x80,0x888888,captions[index*2+1]);
  94.                                 }
  95.         }
  96. }