Subversion Repositories Kolibri OS

Rev

Rev 5691 | Rev 5707 | 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.         byte key,key2;
  218.         dword file_name_off;
  219.         dword selected_offset2;
  220.        
  221.         DSBYTE[#folder_info]=0;
  222.         file_count = 0;
  223.         dir_count = 0; 
  224.         size_dir = 0;
  225.                        
  226.         if (selected_count)
  227.         {
  228.                 GetSizeMoreFiles(#path);
  229.                 debugi(size_dir);
  230.                 atr_readonly = 0;
  231.                 atr_hidden = 0;
  232.                 atr_system = 0;
  233.         }
  234.         else
  235.         {
  236.                 GetFileInfo(#file_path, #file_info_general);
  237.                 strcpy(#file_name2, #file_name);
  238.                 file_name_ed.size = strlen(#file_name2);  
  239.                 if(itdir) GetSizeDir(#file_path);
  240.                 atr_readonly = file_info_general.readonly;
  241.                 atr_hidden = file_info_general.hidden;
  242.                 atr_system = file_info_general.system;
  243.         }
  244.         strcpy(#path_to_file, #path);
  245.         path_to_file_ed.size = strlen(#path_to_file);
  246.        
  247.         SetEventMask(0x27);
  248.         loop() switch(WaitEvent())
  249.         {
  250.                 case evButton:
  251.                                 id=GetButtonID();
  252.                                 if (quest_active)
  253.                                 {
  254.                                         IF (id==301) SetProperties(2);
  255.                                         IF (id==302) SetProperties(1);
  256.                                         break;
  257.                                 }
  258.                                 if (id==1) || (id==10)
  259.                                 {
  260.                                         cmd_free=3;
  261.                                         ExitProcess();
  262.                                 }
  263.                                 IF (id==11)
  264.                                 {
  265.                                         if (selected_count) || (itdir)
  266.                                         {
  267.                                                 quest_active = 1;
  268.                                                 Quest();
  269.                                         }
  270.                                         else
  271.                                         {
  272.                                                 SetProperties(0);
  273.                                         }
  274.                                         break;
  275.                                 }
  276.                                 if (id==20) atr_readonly ^= 1;
  277.                                 if (id==21) atr_hidden ^= 1;
  278.                                 if (id==22) atr_system ^= 1;
  279.                                 DrawPropertiesCheckBoxes();
  280.                                 break;
  281.                                
  282.                 case evMouse:
  283.                                 edit_box_mouse stdcall (#file_name_ed);
  284.                                 edit_box_mouse stdcall (#path_to_file_ed);
  285.                                 break;
  286.                        
  287.                 case evKey:
  288.                                 GetFullKey();
  289.                                 key = AH;
  290.                                 $shr  eax,16
  291.                                 key2 = AL;
  292.                                
  293.                                 if (quest_active)
  294.                                 {
  295.                                         IF (key2==SCAN_CODE_ENTER) SetProperties(2);
  296.                                         IF (key2==SCAN_CODE_ESC) SetProperties(1);
  297.                                         break;
  298.                                 }
  299.                                 if (key2==SCAN_CODE_ESC)
  300.                                 {
  301.                                         cmd_free=3;
  302.                                         ExitProcess();
  303.                                 }
  304.                                 if (key2==SCAN_CODE_ENTER)
  305.                                 {
  306.                                         if (selected_count) || (itdir)
  307.                                         {
  308.                                                 quest_active = 1;
  309.                                                 Quest();
  310.                                         }
  311.                                         else
  312.                                         {
  313.                                                 SetProperties(0);
  314.                                         }
  315.                                         break;
  316.                                 }
  317.                                 EAX=key<<8;
  318.                                 edit_box_key stdcall(#file_name_ed);
  319.                                 edit_box_key stdcall(#path_to_file_ed);
  320.                                 break;
  321.                                
  322.                 case evReDraw:
  323.                                 DrawPropertiesWindow();
  324.         }
  325. }
  326.  
  327. void DrawPropertiesWindow()
  328. {
  329.         DefineAndDrawWindow(Form.left + 150,150,270,285+GetSkinHeight(),0x34,0xFFFFFF,WINDOW_TITLE_PROPERTIES);
  330.         GetProcessInfo(#settings_form, SelfInfo);
  331.         DrawFlatButton(settings_form.cwidth - 70 - 13, settings_form.cheight - 34, 70, 22, 10, 0xE4DFE1, BTN_CLOSE);
  332.         DrawFlatButton(settings_form.cwidth - 150 - 13, settings_form.cheight - 34, 70, 22, 11, 0xE4DFE1, BTN_APPLY);
  333.         DrawBar(10, 10, 32, 32, 0xFFFfff);
  334.        
  335.         WriteText(10, 50, 0x80, 0x000000, PR_T_DEST);
  336.         edit_box_draw stdcall (#path_to_file_ed);
  337.  
  338.         WriteText(10, 65, 0x80, 0x000000, PR_T_SIZE);
  339.        
  340.         if (selected_count)
  341.         {
  342.                 Put_icon('', 18, 19, 0xFFFfff, 0);
  343.                 sprintf(#folder_info,"%s%d%s%d",SET_6,file_count,SET_7,dir_count);
  344.                 WriteText(50, 23, 0x80, 0x000000, #folder_info);
  345.                 sprintf(#element_size_label,"%s (%d %s)",ConvertSize(size_dir),size_dir,SET_BYTE_LANG);
  346.                 WriteText(100, 65, 0x80, 0x000000, #element_size_label);
  347.         }
  348.         else
  349.         {
  350.                 if ( file_info_general.isfolder )
  351.                                 Put_icon("<DIR>", 18, 19, 0xFFFfff, 0);
  352.                 else
  353.                                 Put_icon(#file_name2+strrchr(#file_name2,'.'), 18, 19, 0xFFFfff, 0);
  354.  
  355.                 WriteText(50, 13, 0x80, 0x000000, PR_T_NAME);                          
  356.                 edit_box_draw stdcall (#file_name_ed);
  357.                
  358.                 if (!itdir) element_size = file_info_general.sizelo;
  359.                 else
  360.                 {
  361.                         WriteText(10, 80, 0x80, 0x000000, PR_T_CONTAINS);                              
  362.                         sprintf(#folder_info,"%s%d%s%d",SET_6,file_count,SET_7,dir_count);
  363.                         WriteText(100, 80, 0x80, 0x000000, #folder_info);
  364.                         element_size = size_dir;
  365.                 }
  366.                 WriteText(10,  95, 0x80, 0x000000, SET_3);
  367.         WriteText(10, 110, 0x80, 0x000000, SET_4);
  368.         WriteText(10, 125, 0x80, 0x000000, SET_5);
  369.                 DrawDate(100,  95, 0, #file_info_general.datecreate);
  370.         DrawDate(100, 110, 0, #file_info_general.datelastaccess);
  371.         DrawDate(100, 125, 0, #file_info_general.datelastedit);
  372.  
  373.                 sprintf(#element_size_label,"%s (%d %s)",ConvertSize(element_size),element_size,SET_BYTE_LANG);
  374.                 WriteText(100, 65, 0x80, 0x000000, #element_size_label);
  375.         }
  376.         flags_frame.size_x = - flags_frame.start_x * 2 + settings_form.cwidth - 2;
  377.         flags_frame.font_color = system.color.work_text;
  378.         flags_frame.ext_col = system.color.work_graph;
  379.         frame_draw stdcall (#flags_frame);
  380.         DrawPropertiesCheckBoxes();
  381. }
  382.  
  383. void DrawPropertiesCheckBoxes()
  384. {
  385.         CheckBox2(22, flags_frame.start_y + 14, 20, PR_T_ONLY_READ, atr_readonly);
  386.         CheckBox2(22, flags_frame.start_y + 36, 21, PR_T_HIDDEN, atr_hidden);
  387.         CheckBox2(22, flags_frame.start_y + 58, 22, PR_T_SYSTEM, atr_system);
  388. }