Subversion Repositories Kolibri OS

Rev

Rev 1435 | Go to most recent revision | 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. ;       xor     eax,eax
  113. ;       mov     al,[esi]
  114. ;       test    eax,eax
  115.         test    esi,esi
  116.         jnz     @f
  117.         mov     esi,.null
  118. @@:
  119.         call    .copy
  120. .4:
  121. ;----------------------------------------------
  122.         cmp     od_type,dword 2
  123.         je      @f
  124.         call    .get_filter_data
  125. @@:
  126. ;----------------------------------------------
  127.         mov     eax,od_com_area_name
  128.         mov     [start_open_dialog.parameter],eax
  129.  
  130.         mov     eax,od_start_path
  131.         mov     [start_open_dialog.name],eax
  132.  
  133.         mcall   70,start_open_dialog
  134.         shr     eax,31
  135.         test    eax,eax
  136.         jnz     .1
  137.         jmp     .still
  138. .red:
  139.         pusha
  140.         call    od_draw_window
  141.         popa
  142. .still:
  143.         mcall   23,50
  144.         cmp     eax,1
  145.         je      .red
  146.         mov     eax,od_com_area
  147.         movzx   ebx,word [eax]
  148.         test    ebx,ebx
  149.         jz      .still
  150.         cmp     ebx,3
  151.         je      .2
  152.         cmp     ebx,1
  153.         jne     .still
  154.  
  155.         mov     esi,od_com_area
  156.         add     esi,4
  157.         mov     edi,od_openfile_pach
  158.         call    .copy
  159.         mov     od_status,1
  160.         mov     esi,od_openfile_pach
  161.         mov     edi,od_opendir_pach
  162.         call    .copy_dir_path
  163. ;----------------------------------------------
  164. ; copy file name from shared area
  165.         cmp     od_type,dword 2
  166.         je      @f
  167.         mov     esi,od_com_area
  168.         add     esi,4096-256
  169.         mov     edi,od_filename_area
  170. ;       xor     eax,eax
  171. ;       mov     al,[edi]
  172. ;       test    eax,eax
  173.         test    edi,edi
  174.         jz      @f
  175.         call    .copy
  176. @@:
  177. ;----------------------------------------------
  178.         jmp     .3
  179. .2:
  180.         mov     od_status,0
  181.         jmp     .3
  182. .1:
  183.         mov     od_status,2
  184. .3:
  185. OpenDialog_exit
  186. ;----------------------------------------------
  187. .null:
  188.         dd 0
  189. ;----------------------------------------------
  190. .get_filter_data:
  191.         mov     edi,od_com_area
  192.         test    edi,edi
  193.         jnz     @f
  194. ;       add     esp,4
  195. ;       jmp     still
  196.         ret
  197. @@:
  198.         add     edi,4096+4
  199.         mov     esi,od_filter_area
  200.         mov     ecx,[esi]
  201.         test    ecx,ecx
  202.         jnz     @f
  203.         mov     edi,od_com_area
  204.         mov     [edi+4096],dword 0
  205.         ret
  206. @@:
  207.         inc     ecx
  208.         cld
  209.         rep     movsb
  210.         mov     edi,od_com_area
  211.         mov     [edi+4096],dword 1
  212.         ret
  213. ;----------------------------------------------
  214. .copy:
  215.         xor     eax,eax
  216.         cld
  217. @@:
  218.         lodsb
  219.         stosb
  220.         test    eax,eax
  221.         jnz     @b
  222.         ret
  223. ;----------------------------------------------
  224. .copy_dir_path:
  225.         xor     eax,eax
  226.         cmp     [esi],al
  227.         jne     @f
  228.         mov     [edi],al
  229.         mov     [ebx],al
  230.         xor     ebx,ebx
  231.         inc     ebx
  232.         ret
  233. @@:
  234.         cld
  235.         lodsb
  236.         stosb
  237.         test    eax,eax
  238.         jnz     @b
  239.         cmp     od_type,dword 2
  240.         jne     @f
  241.         ret
  242. @@:
  243.         mov     esi,edi
  244.         dec     esi
  245. @@:
  246.         std
  247.         lodsb
  248.         cmp     al,'/'
  249.         jnz     @b
  250.        
  251.         mov     [esi+1],byte 0
  252.         cld
  253.         ret
  254. ;----------------------------------------------
  255. align   4
  256. start_open_dialog:
  257. .subfunction    dd 7
  258. .flags          dd 0
  259. .parameter      dd 0    ;od_com_area_name
  260. .reserved1      dd 0
  261. .reserved2      dd 0
  262.                 db 0
  263. .name:          dd 0    ;od_start_path
  264. }
  265. ;*****************************************************************************
  266. macro   init_OpenDialog od_ptr
  267. {
  268.         mov     ebp,od_ptr
  269.         call    OpenDialog.init
  270. }
  271. ;*****************************************************************************
  272. macro   start_OpenDialog od_ptr
  273. {
  274.         mov     ebp,od_ptr
  275.         call    OpenDialog.start
  276. }
  277. ;*****************************************************************************