Subversion Repositories Kolibri OS

Rev

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

  1. #ifdef LANG_RUS
  2.         ?define WINDOW_TITLE_PROPERTIES "‘¢®©á⢠"
  3.         ?define BTN_CLOSE "‡ ªàëâì"
  4.         ?define BTN_APPLY "à¨¬¥­¨âì"
  5.         ?define QUEST_1 "à¨¬¥­¨âì ª® ¢á¥¬ ¢«®¦¥­­ë¬"
  6.         ?define QUEST_2 "ä ©« ¬ ¨ ¯ ¯ª ¬"
  7.         ?define PR_T_NAME "ˆ¬ï:"
  8.         ?define PR_T_DEST " á¯®«®¦¥­¨¥:"
  9.         ?define PR_T_SIZE " §¬¥à:"
  10.         ?define SET_3 "‘®§¤ ­:"
  11.         ?define SET_4 "Žâªàëâ:"
  12.         ?define SET_5 "ˆ§¬¥­¥­:"
  13.         ?define SET_6 "” ©«®¢: "
  14.         ?define SET_7 "  ¯®ª: "
  15.         ?define PR_T_CONTAINS "‘®¤¥à¦¨â: "
  16.         ?define FLAGS " €ââਡãâë "
  17.         ?define PR_T_HIDDEN "‘ªàëâë©"
  18.         ?define PR_T_SYSTEM "‘¨á⥬­ë©"
  19.         ?define PR_T_ONLY_READ "’®«ìª® ç⥭¨¥"
  20.         ?define SET_BYTE_LANG "¡ ©â"
  21. #else
  22.         ?define WINDOW_TITLE_PROPERTIES "Properties"
  23.         ?define BTN_CLOSE "Close"
  24.         ?define BTN_APPLY "Apply"
  25.         ?define QUEST_1 "à¨¬¥­¨âì ª® ¢á¥¬ ¢«®¦¥­­ë¬"
  26.         ?define QUEST_2 "ä ©« ¬ ¨ ¯ ¯ª ¬"
  27.         ?define PR_T_NAME "Name:"
  28.         ?define PR_T_DEST "Destination:"
  29.         ?define PR_T_SIZE "Size:"
  30.         ?define SET_3 "Created:"
  31.         ?define SET_4 "Opened:"
  32.         ?define SET_5 "Modified:"
  33.         ?define SET_6 "Files: "
  34.         ?define SET_7 " Folders: "
  35.         ?define PR_T_CONTAINS "Contains: "
  36.         ?define FLAGS " Attributes "
  37.         ?define PR_T_HIDDEN "Hidden"
  38.         ?define PR_T_SYSTEM "System"
  39.         ?define PR_T_ONLY_READ "Read-only"
  40.         ?define SET_BYTE_LANG "byte"
  41. #endif
  42.  
  43. dword mouse_ddd2;
  44. char path_to_file[4096]="\0";
  45. char file_name2[4096]="\0";
  46. edit_box file_name_ed = {195,50,25,0xffffff,0x94AECE,0x000000,0xffffff,2,4098,#file_name2,#mouse_ddd2, 1000000000000000b,2,2};
  47. edit_box path_to_file_ed = {145,100,46,0xffffff,0x94AECE,0x000000,0xffffff,2,4098,#path_to_file,#mouse_ddd2, 1000000000000000b,2,2};
  48. frame flags_frame = { 0, 280, 10, 83, 151, 0x000111, 0xFFFfff, 1, FLAGS, 0, 0, 6, 0x000111, 0xFFFFFF };
  49.  
  50. int file_count, dir_count, size_dir;
  51. char folder_info[200];
  52. dword element_size;
  53. char element_size_label[32];
  54. BDVK file_info_general;
  55. BDVK file_info_dirsize;
  56.  
  57. proc_info settings_form;
  58. byte quest_active, atr_readonly, atr_hidden, atr_system;
  59.  
  60. void SetPropertiesDir(dword way)
  61. {
  62.         dword dirbuf, fcount, i, filename;
  63.         dword cur_file;
  64.         if (isdir(way))
  65.         {
  66.                 cur_file = malloc(4096);
  67.                 GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL);
  68.                 for (i=0; i<fcount; i++)
  69.                 {
  70.                         filename = i*304+dirbuf+72;
  71.                         strcpy(cur_file, way);
  72.                         chrcat(cur_file, '/');
  73.                         strcat(cur_file, filename);
  74.                         if ( TestBit(ESDWORD[filename-40], 4) )
  75.                         {
  76.                                 SetPropertiesDir(cur_file);
  77.                         }
  78.                         GetFileInfo(cur_file, #file_info_dirsize);
  79.                         file_info_dirsize.readonly = atr_readonly;
  80.                         file_info_dirsize.hidden = atr_hidden;
  81.                         file_info_dirsize.system = atr_system;
  82.                         SetFileInfo(cur_file, #file_info_dirsize);
  83.                 }
  84.                 free(cur_file);
  85.         }
  86. }
  87.  
  88. void SetProperties(byte prop)
  89. {
  90.         dword cur_file;
  91.         dword selected_offset2;
  92.  
  93.         if (prop==1) || (prop==2)
  94.         {
  95.                 if (selected_count)
  96.                 {
  97.                         cur_file = malloc(4096);
  98.                         for (i=0; i<files.count; i++)
  99.                         {
  100.                                 selected_offset2 = file_mas[i]*304 + buf+32 + 7;
  101.                                 if (ESBYTE[selected_offset2])
  102.                                 {
  103.                                         strcpy(cur_file, #path);
  104.                                         strcat(cur_file, file_mas[i]*304+buf+72);
  105.                                         GetFileInfo(cur_file, #file_info_general);
  106.                                         file_info_general.readonly = atr_readonly;
  107.                                         file_info_general.hidden = atr_hidden;
  108.                                         file_info_general.system = atr_system;
  109.                                         SetFileInfo(cur_file, #file_info_general);
  110.                                         if (prop==2)
  111.                                         {
  112.                                                 if (isdir(cur_file))
  113.                                                 {
  114.                                                         SetPropertiesDir(cur_file);
  115.                                                 }
  116.                                         }
  117.                                 }
  118.                         }
  119.                         free(cur_file);
  120.                 }
  121.                 else
  122.                 {
  123.                         GetFileInfo(#file_path, #file_info_general);
  124.                         file_info_general.readonly = atr_readonly;
  125.                         file_info_general.hidden = atr_hidden;
  126.                         file_info_general.system = atr_system;
  127.                         SetFileInfo(#file_path, #file_info_general);
  128.                         if (prop==2) SetPropertiesDir(#file_path);
  129.                 }
  130.                 quest_active = 0;
  131.                 DrawPropertiesWindow();
  132.         }
  133.         else
  134.         {
  135.                 GetFileInfo(#file_path, #file_info_general);
  136.                 file_info_general.readonly = atr_readonly;
  137.                 file_info_general.hidden = atr_hidden;
  138.                 file_info_general.system = atr_system;
  139.                 SetFileInfo(#file_path, #file_info_general);
  140.         }
  141.         cmd_free=3;
  142.         _not_draw = true;
  143.     Open_Dir(#path,WITH_REDRAW);
  144.     _not_draw = false;
  145.     EventRedrawWindow(Form.left,Form.top);
  146.         ExitProcess();
  147. }
  148.  
  149. void Quest()
  150. {
  151.         DrawPopup(30,80,200,90,1,system.color.work, system.color.work_graph);
  152.         WriteText(50, 100, 0x80, 0x000000, QUEST_1);
  153.         WriteText(80, 115, 0x80, 0x000000, QUEST_2);
  154.         DrawFlatButton(52,138,70,20,301,0xFFB6B5,T_YES);
  155.         DrawFlatButton(145,138,70,20,302,0xC6DFC6,T_NO);
  156. }
  157.  
  158. void GetSizeDir(dword way)
  159. {
  160.         dword dirbuf, fcount, i, filename;
  161.         dword cur_file;
  162.         if (isdir(way))
  163.         {
  164.                 cur_file = malloc(4096);
  165.                 // In the process of recursive descent, memory must be allocated dynamically, because the static memory -> was a bug !!! But unfortunately pass away to sacrifice speed.
  166.                 GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL);
  167.                 for (i=0; i<fcount; i++)
  168.                 {
  169.                         filename = i*304+dirbuf+72;
  170.                         sprintf(cur_file,"%s/%s",way,filename);
  171.                        
  172.                         if (TestBit(ESDWORD[filename-40], 4) )
  173.                         {
  174.                                 dir_count++;
  175.                                 GetSizeDir(cur_file);
  176.                         }
  177.                         else
  178.                         {
  179.                                 GetFileInfo(cur_file, #file_info_dirsize);
  180.                                 size_dir += file_info_dirsize.sizelo;
  181.                                 file_count++;
  182.                         }
  183.                 }
  184.                 free(cur_file);
  185.         }
  186. }
  187.  
  188. void GetSizeMoreFiles(dword way)
  189. {
  190.         char cur_file[4096];
  191.         dword selected_offset2;
  192.        
  193.         for (i=0; i<files.count; i++)
  194.     {
  195.         selected_offset2 = file_mas[i]*304 + buf+32 + 7;
  196.         if (ESBYTE[selected_offset2]) {
  197.                         sprintf(#cur_file,"%s%s",way,file_mas[i]*304+buf+72);
  198.                         if (TestBit(ESDWORD[file_mas[i]*304+buf+32], 4) )
  199.                         {
  200.                                 debugln(#cur_file);
  201.                                 GetSizeDir(#cur_file);
  202.                                 dir_count++;
  203.                         }
  204.                         else
  205.                         {
  206.                                 GetFileInfo(#cur_file, #file_info_dirsize);
  207.                                 size_dir += file_info_dirsize.sizelo;
  208.                                 file_count++;
  209.                         }
  210.         }
  211.         }  
  212. }
  213.  
  214. void properties_dialog()
  215. {
  216.         byte id;
  217.         dword file_name_off;
  218.         dword selected_offset2;
  219.        
  220.         DSBYTE[#folder_info]=0;
  221.         file_count = 0;
  222.         dir_count = 0; 
  223.         size_dir = 0;
  224.                        
  225.         if (selected_count)
  226.         {
  227.                 GetSizeMoreFiles(#path);
  228.                 debugi(size_dir);
  229.                 atr_readonly = 0;
  230.                 atr_hidden = 0;
  231.                 atr_system = 0;
  232.         }
  233.         else
  234.         {
  235.                 GetFileInfo(#file_path, #file_info_general);
  236.                 strcpy(#file_name2, #file_name);
  237.                 file_name_ed.size = strlen(#file_name2);  
  238.                 if(itdir) GetSizeDir(#file_path);
  239.                 atr_readonly = file_info_general.readonly;
  240.                 atr_hidden = file_info_general.hidden;
  241.                 atr_system = file_info_general.system;
  242.         }
  243.         strcpy(#path_to_file, #path);
  244.         path_to_file_ed.size = strlen(#path_to_file);
  245.        
  246.         SetEventMask(0x27);
  247.         loop() switch(WaitEvent())
  248.         {
  249.                 case evButton:
  250.                                 id=GetButtonID();
  251.                                 if (quest_active)
  252.                                 {
  253.                                         IF (id==301) SetProperties(2);
  254.                                         IF (id==302) SetProperties(1);
  255.                                         break;
  256.                                 }
  257.                                 if (id==1) || (id==10)
  258.                                 {
  259.                                         cmd_free=3;
  260.                                         ExitProcess();
  261.                                 }
  262.                                 IF (id==11)
  263.                                 {
  264.                                         if (selected_count) || (itdir)
  265.                                         {
  266.                                                 quest_active = 1;
  267.                                                 Quest();
  268.                                         }
  269.                                         else
  270.                                         {
  271.                                                 SetProperties(0);
  272.                                         }
  273.                                         break;
  274.                                 }
  275.                                 if (id==20) atr_readonly ^= 1;
  276.                                 if (id==21) atr_hidden ^= 1;
  277.                                 if (id==22) atr_system ^= 1;
  278.                                 DrawPropertiesCheckBoxes();
  279.                                 break;
  280.                                
  281.                 case evMouse:
  282.                                 edit_box_mouse stdcall (#file_name_ed);
  283.                                 edit_box_mouse stdcall (#path_to_file_ed);
  284.                                 break;
  285.                        
  286.                 case evKey:
  287.                                 GetKeys();
  288.                                
  289.                                 if (quest_active)
  290.                                 {
  291.                                         IF (key_scancode==SCAN_CODE_ENTER) SetProperties(2);
  292.                                         IF (key_scancode==SCAN_CODE_ESC) SetProperties(1);
  293.                                         break;
  294.                                 }
  295.                                 if (key_scancode==SCAN_CODE_ESC)
  296.                                 {
  297.                                         cmd_free=3;
  298.                                         ExitProcess();
  299.                                 }
  300.                                 if (key_scancode==SCAN_CODE_ENTER)
  301.                                 {
  302.                                         if (selected_count) || (itdir)
  303.                                         {
  304.                                                 quest_active = 1;
  305.                                                 Quest();
  306.                                         }
  307.                                         else
  308.                                         {
  309.                                                 SetProperties(0);
  310.                                         }
  311.                                         break;
  312.                                 }
  313.                                 EAX = key_ascii << 8;
  314.                                 edit_box_key stdcall(#file_name_ed);
  315.                                 edit_box_key stdcall(#path_to_file_ed);
  316.                                 break;
  317.                                
  318.                 case evReDraw:
  319.                                 DrawPropertiesWindow();
  320.         }
  321. }
  322.  
  323. void DrawPropertiesWindow()
  324. {
  325.         DefineAndDrawWindow(Form.left + 150,150,270,285+GetSkinHeight(),0x34,0xFFFFFF,WINDOW_TITLE_PROPERTIES);
  326.         GetProcessInfo(#settings_form, SelfInfo);
  327.         DrawFlatButton(settings_form.cwidth - 70 - 13, settings_form.cheight - 34, 70, 22, 10, 0xE4DFE1, BTN_CLOSE);
  328.         DrawFlatButton(settings_form.cwidth - 150 - 13, settings_form.cheight - 34, 70, 22, 11, 0xE4DFE1, BTN_APPLY);
  329.         DrawBar(10, 10, 32, 32, 0xFFFfff);
  330.        
  331.         WriteText(10, 50, 0x80, 0x000000, PR_T_DEST);
  332.         edit_box_draw stdcall (#path_to_file_ed);
  333.  
  334.         WriteText(10, 65, 0x80, 0x000000, PR_T_SIZE);
  335.        
  336.         if (selected_count)
  337.         {
  338.                 Put_icon('', 18, 19, 0xFFFfff, 0);
  339.                 sprintf(#folder_info,"%s%d%s%d",SET_6,file_count,SET_7,dir_count);
  340.                 WriteText(50, 23, 0x80, 0x000000, #folder_info);
  341.                 sprintf(#element_size_label,"%s (%d %s)",ConvertSize(size_dir),size_dir,SET_BYTE_LANG);
  342.                 WriteText(100, 65, 0x80, 0x000000, #element_size_label);
  343.         }
  344.         else
  345.         {
  346.                 if ( file_info_general.isfolder )
  347.                                 Put_icon("<DIR>", 18, 19, 0xFFFfff, 0);
  348.                 else
  349.                                 Put_icon(#file_name2+strrchr(#file_name2,'.'), 18, 19, 0xFFFfff, 0);
  350.  
  351.                 WriteText(50, 13, 0x80, 0x000000, PR_T_NAME);                          
  352.                 edit_box_draw stdcall (#file_name_ed);
  353.                
  354.                 if (!itdir) element_size = file_info_general.sizelo;
  355.                 else
  356.                 {
  357.                         WriteText(10, 80, 0x80, 0x000000, PR_T_CONTAINS);                              
  358.                         sprintf(#folder_info,"%s%d%s%d",SET_6,file_count,SET_7,dir_count);
  359.                         WriteText(100, 80, 0x80, 0x000000, #folder_info);
  360.                         element_size = size_dir;
  361.                 }
  362.                 WriteText(10,  95, 0x80, 0x000000, SET_3);
  363.         WriteText(10, 110, 0x80, 0x000000, SET_4);
  364.         WriteText(10, 125, 0x80, 0x000000, SET_5);
  365.                 DrawDate(100,  95, 0, #file_info_general.datecreate);
  366.         DrawDate(100, 110, 0, #file_info_general.datelastaccess);
  367.         DrawDate(100, 125, 0, #file_info_general.datelastedit);
  368.  
  369.                 sprintf(#element_size_label,"%s (%d %s)",ConvertSize(element_size),element_size,SET_BYTE_LANG);
  370.                 WriteText(100, 65, 0x80, 0x000000, #element_size_label);
  371.         }
  372.         flags_frame.size_x = - flags_frame.start_x * 2 + settings_form.cwidth - 2;
  373.         flags_frame.font_color = system.color.work_text;
  374.         flags_frame.ext_col = system.color.work_graph;
  375.         frame_draw stdcall (#flags_frame);
  376.         DrawPropertiesCheckBoxes();
  377. }
  378.  
  379. void DrawPropertiesCheckBoxes()
  380. {
  381.         CheckBox2(22, flags_frame.start_y + 14, 20, PR_T_ONLY_READ, atr_readonly);
  382.         CheckBox2(22, flags_frame.start_y + 36, 21, PR_T_HIDDEN, atr_hidden);
  383.         CheckBox2(22, flags_frame.start_y + 58, 22, PR_T_SYSTEM, atr_system);
  384. }