Subversion Repositories Kolibri OS

Rev

Rev 3440 | 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.         "Rename",        "F2",
  9.         "Delete",        "Del",
  10.         //"Refresh",       "F5",
  11.         0};
  12.  
  13. void FileMenu()
  14. {
  15.         proc_info MenuForm;
  16.         mouse mm;
  17.         word id, key, slot;
  18.         int ccount=0, cur, newi, linew=10, lineh=18, texty;
  19.         for (i=0; captions[i]!=0; i+=2)
  20.         {
  21.                 ccount++;
  22.                 if (strlen(captions[i])>linew) linew = strlen(captions[i]);
  23.         }
  24.         linew = linew + 3 * 6 + 50;
  25.         texty = lineh/2-4;
  26.         SetEventMask(100111b);
  27.  
  28.         goto _MENU_DRAW;
  29.         loop() switch(WaitEvent())
  30.         {
  31.                 case evMouse:
  32.                                 slot = GetProcessSlot(MenuForm.ID);
  33.                                 if (slot != GetActiveProcess()) ExitProcess();
  34.                                 mm.get();
  35.                                 newi = mm.y - 1 / lineh;
  36.                                 if (mm.y<=0) || (mm.y>ccount*lineh+5) || (mm.x<0) || (mm.x>linew) newi=-1;
  37.                                 if (cur<>newi)
  38.                                 {
  39.                                         cur=newi;
  40.                                         goto _ITEMS_DRAW;
  41.                                 }
  42.                                 break;
  43.  
  44.                 case evButton:
  45.                                 id=GetButtonID();
  46.                                 if (id==100) Open();
  47.                                 if (id==101) notify("Not compleated yet");
  48.                                 if (id==102) FnProcess(3);
  49.                                 if (id==103) FnProcess(4);
  50.                                 if (id==104) FnProcess(2);
  51.                                 if (id==105) Del_Form();
  52.                                 if (id==106) FnProcess(5);
  53.                                 ExitProcess();
  54.                                 break;
  55.                                
  56.                 case evKey:
  57.                                 IF (GetKey()==27) ExitProcess();
  58.                                 break;
  59.                                
  60.                 case evReDraw: _MENU_DRAW:
  61.                                 DefineAndDrawWindow(m.x+Form.left+5,m.y+Form.top+GetSkinHeight(),linew+3,ccount*lineh+6,0x01, 0, 0, 0x01fffFFF);
  62.                                 GetProcessInfo(#MenuForm, SelfInfo);
  63.                                 /* _PutImage(1,23, 16,44, #factions); //èêîíêè  */
  64.                                 DrawRectangle(0,0,linew+1,ccount*lineh+2,col_border);
  65.                                 DrawBar(1,1,linew,1,0xFFFfff);
  66.                                 PutShadow(linew+2,1,1,ccount*lineh+2,0,2);
  67.                                 PutShadow(linew+3,2,1,ccount*lineh+2,0,1);
  68.                                 PutShadow(1,ccount*lineh+3,linew+2,1,0,2);
  69.                                 PutShadow(2,ccount*lineh+4,linew+1,1,0,1);
  70.  
  71.                                 _ITEMS_DRAW:
  72.                                 for (i=0; captions[i*2]!=0; i++)
  73.                                 {
  74.                                         DefineButton(1,i*lineh+1,linew,lineh-1,i+100+BT_HIDE+BT_NOFRAME,0xFFFFFF);
  75.                                         DrawBar(1,i*lineh+2,1,lineh,0xFFFfff);
  76.                                         if (i==cur) DrawBar(2,i*lineh+2,linew-1,lineh,0xFFFfff); else DrawBar(2,i*lineh+2,linew-1,lineh,col_work);
  77.                                         WriteText(7,i*lineh+texty+2,0x80,0x000000,captions[i*2]);
  78.                                         WriteText(-strlen(captions[i*2+1])*6-6+linew,i*lineh+texty+2,0x80,0x999999,captions[i*2+1]);
  79.                                 }
  80.         }
  81. }