Subversion Repositories Kolibri OS

Rev

Rev 1438 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;*****************************************************************************
  2. ; Macro for use Open Dialog - for Kolibri OS
  3. ; Copyright (c) 2009 2010, Marat Zakiyanov aka Mario79, aka Mario
  4. ; All rights reserved.
  5. ;
  6. ; Redistribution and use in source and binary forms, with or without
  7. ; modification, are permitted provided that the following conditions are met:
  8. ;        * Redistributions of source code must retain the above copyright
  9. ;          notice, this list of conditions and the following disclaimer.
  10. ;        * Redistributions in binary form must reproduce the above copyright
  11. ;          notice, this list of conditions and the following disclaimer in the
  12. ;          documentation and/or other materials provided with the distribution.
  13. ;        * Neither the name of the <organization> nor the
  14. ;          names of its contributors may be used to endorse or promote products
  15. ;          derived from this software without specific prior written permission.
  16. ;
  17. ; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
  18. ; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19. ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20. ; DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
  21. ; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22. ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23. ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24. ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  26. ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. ;*****************************************************************************
  28. ;*****************************************************************************
  29. macro   OpenDialog_exit
  30. {
  31. popa
  32. ret
  33. }
  34. ;*****************************************************************************
  35. macro   use_OpenDialog
  36. {
  37. OpenDialog:
  38. od_type                 equ dword [ebp] ; 0-Open, 1-Save, 2-Dir
  39. od_procinfo             equ dword [ebp+4] ; Process info area for function 9
  40. od_com_area_name        equ dword [ebp+8] ; Name for shared area
  41. od_com_area             equ dword [ebp+12] ; Adress of shared area
  42. od_opendir_pach         equ dword [ebp+16] ; Temp area the directory for show
  43. od_dir_default_pach     equ dword [ebp+20] ; Default path of directory,
  44. od_start_path           equ dword [ebp+24] ; Location path to OpenDialog
  45. od_draw_window          equ dword [ebp+28] ; Adress of procedure - draw_window
  46. od_status               equ dword [ebp+32] ; 0-Cancel, 1-Get path OK, 2-Use alternatives
  47. od_openfile_pach        equ dword [ebp+36] ; Getting path to file
  48. od_filename_area        equ dword [ebp+40] ; Adress of file name area
  49. od_filter_area          equ dword [ebp+44] ; Adress of filter area
  50. ;*****************************************************************************
  51. .init:
  52.         pusha
  53.         mcall   9,od_procinfo,-1
  54.         mov     ebx,[ebx+30]
  55.         mov     edi,od_com_area_name
  56.         add     edi,7
  57.         std
  58.         mov     ecx,4
  59. @@:
  60.         mov     al,bl
  61.         and     al,1111b
  62.         add     al,0x30
  63.         stosb
  64.         mov     al,bl
  65.         shr     al,4
  66.         and     al,1111b
  67.         add     al,0x30
  68.         stosb
  69.         shr     ebx,8
  70.         dec     ecx
  71.         jnz     @r
  72.         cld
  73.        
  74.         mcall   68,22,od_com_area_name,8192,0x09
  75.         mov     od_com_area,eax
  76.        
  77.         mov     esi,od_openfile_pach
  78.         mov     edi,od_opendir_pach
  79.         call    .copy_dir_path
  80.        
  81. OpenDialog_exit
  82. ;*****************************************************************************
  83. ;*****************************************************************************
  84. .start:
  85.         pusha
  86.         mov     eax,od_com_area
  87.         test    eax,eax
  88.         jz      .1
  89.         mov     ebx,od_type
  90.         mov     [eax+2],bx
  91.        
  92.         mov     [eax],word 2    ; folder for open
  93.         mov     edi,eax
  94.         add     edi,4
  95.  
  96.         mov     esi,od_opendir_pach
  97.         xor     eax,eax
  98.         mov     al,[esi]
  99.         test    eax,eax
  100.         jnz     @f
  101.         mov     esi,od_dir_default_pach ;communication_area_default_pach
  102. @@:
  103.         call    .copy
  104. ;----------------------------------------------
  105. ; copy file name to shared area
  106.         cmp     od_type,dword 2
  107.         je      .4
  108.         mov     edi,od_com_area
  109.         add     edi,4096-256
  110.  
  111.         mov     esi,od_filename_area
  112.         test    esi,esi
  113.         jnz     @f
  114.         mov     esi,.null
  115. @@:
  116.         call    .copy
  117. .4:
  118. ;----------------------------------------------
  119.         cmp     od_type,dword 2
  120.         je      @f
  121.         call    .get_filter_data
  122. @@:
  123. ;----------------------------------------------
  124.         mov     eax,od_com_area_name
  125.         mov     [start_open_dialog.parameter],eax
  126.  
  127.         mov     eax,od_start_path
  128.         mov     [start_open_dialog.name],eax
  129.  
  130.         mcall   70,start_open_dialog
  131.         shr     eax,31
  132.         test    eax,eax
  133.         jnz     .1
  134. .still:
  135.         mcall   23,50
  136.         cmp     eax,1
  137.         jne     @f
  138.         pusha
  139.         call    od_draw_window
  140.         popa
  141. @@:
  142.         mov     eax,od_com_area
  143.         movzx   ebx,word [eax]
  144.         test    ebx,ebx
  145.         jz      .still
  146.         cmp     ebx,3
  147.         je      .2
  148.         cmp     ebx,1
  149.         jne     .still
  150.  
  151.         mov     esi,od_com_area
  152.         add     esi,4
  153.         mov     edi,od_openfile_pach
  154.         call    .copy
  155.         mov     od_status,1
  156.         mov     esi,od_openfile_pach
  157.         mov     edi,od_opendir_pach
  158.         call    .copy_dir_path
  159. ;----------------------------------------------
  160. ; copy file name from shared area
  161.         cmp     od_type,dword 2
  162.         je      @f
  163.         mov     esi,od_com_area
  164.         add     esi,4096-256
  165.         mov     edi,od_filename_area
  166. ;       xor     eax,eax
  167. ;       mov     al,[edi]
  168. ;       test    eax,eax
  169.         test    edi,edi
  170.         jz      @f
  171.         call    .copy
  172. @@:
  173. ;----------------------------------------------
  174.         jmp     .3
  175. .2:
  176.         mov     od_status,0
  177.         jmp     .3
  178. .1:
  179.         mov     od_status,2
  180. .3:
  181. OpenDialog_exit
  182. ;----------------------------------------------
  183. .null:
  184.         dd 0
  185. ;----------------------------------------------
  186. .get_filter_data:
  187.         mov     edi,od_com_area
  188.         test    edi,edi
  189.         jnz     @f
  190. ;       add     esp,4
  191. ;       jmp     still
  192.         ret
  193. @@:
  194.         add     edi,4096+4
  195.         mov     esi,od_filter_area
  196.         mov     ecx,[esi]
  197.         test    ecx,ecx
  198.         jnz     @f
  199.         mov     edi,od_com_area
  200.         mov     [edi+4096],dword 0
  201.         ret
  202. @@:
  203.         inc     ecx
  204.         cld
  205.         rep     movsb
  206.         mov     edi,od_com_area
  207.         mov     [edi+4096],dword 1
  208.         ret
  209. ;----------------------------------------------
  210. .copy:
  211.         xor     eax,eax
  212.         cld
  213. @@:
  214.         lodsb
  215.         stosb
  216.         test    eax,eax
  217.         jnz     @b
  218.         ret
  219. ;----------------------------------------------
  220. .copy_dir_path:
  221.         xor     eax,eax
  222.         cmp     [esi],al
  223.         jne     @f
  224.         mov     [edi],al
  225.         mov     [ebx],al
  226.         xor     ebx,ebx
  227.         inc     ebx
  228.         ret
  229. @@:
  230.         cld
  231.         lodsb
  232.         stosb
  233.         test    eax,eax
  234.         jnz     @b
  235.         cmp     od_type,dword 2
  236.         jne     @f
  237.         ret
  238. @@:
  239.         mov     esi,edi
  240.         dec     esi
  241. @@:
  242.         std
  243.         lodsb
  244.         cmp     al,'/'
  245.         jnz     @b
  246.        
  247.         mov     [esi+1],byte 0
  248.         cld
  249.         ret
  250. ;----------------------------------------------
  251. align   4
  252. start_open_dialog:
  253. .subfunction    dd 7
  254. .flags          dd 0
  255. .parameter      dd 0    ;od_com_area_name
  256. .reserved1      dd 0
  257. .reserved2      dd 0
  258.                 db 0
  259. .name:          dd 0    ;od_start_path
  260. }
  261. ;*****************************************************************************
  262. macro   init_OpenDialog od_ptr
  263. {
  264.         mov     ebp,od_ptr
  265.         call    OpenDialog.init
  266. }
  267. ;*****************************************************************************
  268. macro   start_OpenDialog od_ptr
  269. {
  270.         mov     ebp,od_ptr
  271.         call    OpenDialog.start
  272. }
  273. ;*****************************************************************************