Subversion Repositories Kolibri OS

Rev

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

  1. //pay attension: >200 this is only file actions, not supported by folders
  2. #ifdef LANG_RUS
  3. char *file_captions[] = {
  4.         "Žâªàëâì",               "Enter",100,
  5.         "Žâªàëâì á ¯®¬®éìî...",  "CrlEnt",201,
  6.         "Š®¯¨à®¢ âì",            "Crl+C",104,
  7.         "‚ë१ âì",              "Crl+X",105,
  8.         "‚áâ ¢¨âì",              "Crl+V",106,
  9.         "¥à¥¨¬¥­®¢ âì",         "F2",207,
  10.         "“¤ «¨âì",               "Del",108,
  11.         "Ž¡­®¢¨âì ¯ ¯ªã",        "F5",109,
  12.         "‘¢®©á⢠",             "F8",110,
  13.         0, 0, 0};
  14. #elif LANG_EST
  15. char *file_captions[] = {
  16.         "Ava",            "Enter",100,
  17.         "Ava ...",        "CrlEnt",201,
  18.         "Kopeeri",        "Crl+C",104,
  19.         "Lõika",          "Crl+X",105,
  20.         "Aseta",          "Crl+V",106,
  21.         "Nimeta ümber",   "F2",207,
  22.         "Kustuta",        "Del",108,
  23.         "Värskenda",      "F5",109,
  24.         "Properties",     "F8",110,
  25.         0, 0, 0};
  26. #else
  27. char *file_captions[] = {
  28.         "Open",          "Enter",100,
  29.         "Open with...",  "CrlEnt",201,
  30.         "Copy",          "Crl+C",104,
  31.         "Cut",           "Crl+X",105,
  32.         "Paste",         "Crl+V",106,
  33.         "Rename",        "F2",207,
  34.         "Delete",        "Del",108,
  35.         "Refresh",       "F5",109,
  36.         "Properties",    "F8",110,
  37.         0, 0, 0};
  38. #endif
  39.  
  40. llist rbmenu;
  41. int cur_action_buf;
  42.  
  43. void FileMenu()
  44. {
  45.         proc_info MenuForm;
  46.         int index;
  47.  
  48.         rbmenu.ClearList();
  49.         rbmenu.SetFont(6, 9, 0x80);
  50.         rbmenu.SetSizes(0,0,10,0,18);
  51.         for (index=0; file_captions[index]!=0; index+=3)
  52.         {
  53.                 if (selected_count > 0) {
  54.                         //if there are files selected then show only specific menu items
  55.                         if (file_captions[index+2]>=200) continue;
  56.                         if (file_captions[index+2]==100) continue;
  57.                 }
  58.                 else if (itdir) && (file_captions[index+2]>=200) continue;
  59.                 if (strlen(file_captions[index])>rbmenu.w) rbmenu.w = strlen(file_captions[index]);
  60.                 rbmenu.count++;
  61.                 rbmenu.visible++;
  62.         }
  63.         rbmenu.w = rbmenu.w + 3 * rbmenu.font_w + 50;
  64.         rbmenu.h = rbmenu.count * rbmenu.item_h;
  65.         SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE);
  66.         goto _MENU_DRAW;
  67.        
  68.         loop() switch(WaitEvent())
  69.         {
  70.                 case evMouse:
  71.                                 mouse.get();
  72.                                 if (!CheckActiveProcess(MenuForm.ID)){ cmd_free=1; ExitProcess();}
  73.                                 else if (mouse.move)&&(rbmenu.ProcessMouse(mouse.x, mouse.y)) MenuListRedraw();
  74.                                 else if (mouse.key&MOUSE_LEFT)&&(mouse.up) {action_buf = cur_action_buf; cmd_free=1; ExitProcess(); }
  75.                 break;
  76.                                
  77.                 case evKey:
  78.                                 GetKeys();
  79.                                 if (key_scancode == SCAN_CODE_ESC) {cmd_free=1;ExitProcess();}
  80.                                 if (key_scancode == SCAN_CODE_ENTER) {action_buf = cur_action_buf; cmd_free=1; ExitProcess(); }
  81.                                 if (rbmenu.ProcessKey(key_scancode)) MenuListRedraw();
  82.                                 break;
  83.                                
  84.                 case evReDraw: _MENU_DRAW:
  85.                                 if (menu_call_mouse)
  86.                                         DefineAndDrawWindow(mouse.x+Form.left+5, mouse.y+Form.top+skin_height,rbmenu.w+3,rbmenu.h+6,0x01, 0, 0, 0x01fffFFF);
  87.                                 else
  88.                                         DefineAndDrawWindow(Form.left+files.x+15, files.item_h*files.cur_y+files.y+Form.top+30,rbmenu.w+3,rbmenu.h+6,0x01, 0, 0, 0x01fffFFF);
  89.                                 GetProcessInfo(#MenuForm, SelfInfo);
  90.                                 DrawRectangle(0,0,rbmenu.w+1,rbmenu.h+2,col.graph);
  91.                                 DrawBar(1,1,rbmenu.w,1,0xFFFfff);
  92.                                 DrawPopupShadow(1,1,rbmenu.w,rbmenu.h,0);
  93.                                 MenuListRedraw();
  94.         }
  95. }
  96.  
  97. void MenuListRedraw()
  98. {
  99.         int start_y=0;
  100.         int index;
  101.  
  102.         dword m_col_bg;
  103.         dword m_col_text;
  104.         dword m_col_sh_text;
  105.  
  106.         for (index=0; file_captions[index*3]!=0; index++)
  107.         {
  108.                 if (selected_count > 0) {
  109.                         if (file_captions[index*3+2]==100) continue;
  110.                         if (file_captions[index*3+2]>=200) continue;
  111.                 }
  112.                 else if ((itdir) && (file_captions[index*3+2]>=200)) continue;
  113.                 DrawBar(1,start_y+2,1,rbmenu.item_h,0xFFFfff);
  114.                 if (start_y/rbmenu.item_h==rbmenu.cur_y)
  115.                 {
  116.                         cur_action_buf = file_captions[index*3+2];
  117.                         m_col_bg = 0xFFFfff;
  118.                         m_col_sh_text = 0xFAFAFA;
  119.                         m_col_text = 0;
  120.                 }
  121.                 else
  122.                 {
  123.                         m_col_bg = col.work;
  124.                         m_col_text = system.color.work_text;
  125.                         m_col_sh_text = system.color.work_light;
  126.                 }
  127.                 DrawBar(2, start_y+2, rbmenu.w-1, rbmenu.item_h, m_col_bg);
  128.                 WriteText(8, start_y + rbmenu.text_y + 4, rbmenu.font_type, m_col_sh_text, file_captions[index*3]);
  129.                 WriteText(7, start_y + rbmenu.text_y + 3, rbmenu.font_type, m_col_text, file_captions[index*3]);
  130.                 WriteText(-strlen(file_captions[index*3+1])-1*rbmenu.font_w + rbmenu.w, start_y + rbmenu.text_y + 3, rbmenu.font_type, 0x888888, file_captions[index*3+1]);
  131.                 start_y+=rbmenu.item_h;
  132.         }      
  133. }