Subversion Repositories Kolibri OS

Rev

Rev 1417 | 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. ;*****************************************************************************
  49. .init:
  50.         pusha
  51.         mcall   9, od_procinfo, -1
  52.         mov     ebx,[ebx+30]
  53.         mov     edi,od_com_area_name
  54.         add     edi,7
  55.         std
  56.         mov     ecx,4
  57. @@:
  58.         mov     al,bl
  59.         and     al,1111b
  60.         add     al,0x30
  61.         stosb
  62.         mov     al,bl
  63.         shr     al,4
  64.         and     al,1111b
  65.         add     al,0x30
  66.         stosb
  67.         shr     ebx,8
  68.         dec     ecx
  69.         jnz     @r
  70.         cld
  71.        
  72.         mcall   68,22,od_com_area_name,8192,0x09
  73.         mov     od_com_area,eax
  74.        
  75.     mov   esi,od_openfile_pach
  76.     mov   edi,od_opendir_pach
  77.         call    .copy_dir_path
  78.        
  79. OpenDialog_exit
  80. ;*****************************************************************************
  81. ;*****************************************************************************
  82. .start:
  83.         pusha
  84.         mov     eax,od_com_area
  85.         test    eax,eax
  86.         jz      .1
  87.         mov ebx,od_type
  88.         mov [eax+2],bx
  89.        
  90.         mov     [eax],word 2 ; folder for open
  91.         mov     edi,eax
  92.         add     edi,4
  93.  
  94.         mov     esi,od_opendir_pach
  95.         xor     eax,eax
  96.         mov     al,[esi]
  97.         test    eax,eax
  98.         jnz     @f
  99.         mov     esi,od_dir_default_pach ;communication_area_default_pach
  100. @@:
  101.         call    .copy
  102.  
  103.         mov     eax,od_com_area_name
  104.         mov     [start_open_dialog.parameter],eax
  105.  
  106.         mov     eax,od_start_path
  107.         mov     [start_open_dialog.name],eax
  108.  
  109.         mcall   70, start_open_dialog
  110.         shr     eax,31
  111.         test    eax,eax
  112.         jnz     .1
  113.         jmp     .still
  114. .red:
  115.         pusha
  116.         call    od_draw_window
  117.         popa
  118. .still:
  119.         mcall   23, 50
  120.         cmp     eax,1
  121.         je      .red
  122.         mov     eax,od_com_area
  123.         movzx   ebx,word [eax]
  124.         test    ebx,ebx
  125.         jz      .still
  126.         cmp     ebx,3
  127.         je      .2 ;still
  128.         cmp     ebx,1
  129.         jne     .still
  130.  
  131.         mov     esi,od_com_area
  132.         add     esi,4
  133.         mov     edi,od_openfile_pach ;string
  134.         call    .copy
  135.         mov     od_status,1
  136.     mov   esi,od_openfile_pach
  137.     mov   edi,od_opendir_pach
  138.         call    .copy_dir_path
  139.         jmp     .3  ;kopen_1
  140. .2:
  141.         mov     od_status,0
  142.         jmp     .3 ; still
  143. .1:
  144.         mov     od_status,2 ; thread1
  145. .3:
  146. OpenDialog_exit
  147. ;----------------------------------------------
  148. .copy:
  149.         xor     eax,eax
  150.         cld
  151. @@:
  152.         lodsb
  153.         stosb
  154.         test    eax,eax
  155.         jnz     @b
  156.         ret
  157. ;----------------------------------------------
  158. .copy_dir_path:
  159.     xor   eax,eax
  160.         cmp  [esi],al
  161.         jne  @f
  162.         mov  [edi],al
  163.         mov  [ebx],al
  164.         xor  ebx,ebx
  165.         inc  ebx
  166.         ret
  167. @@:
  168.     cld
  169.     lodsb
  170.     stosb
  171.     test  eax,eax
  172.     jnz   @b
  173.     mov   esi,edi
  174.         dec   esi
  175. @@:
  176.     std
  177.     lodsb
  178.     cmp   al,'/'
  179.     jnz   @b
  180.        
  181. ;       push  esi
  182. ;       add  esi,2
  183. ;;      mov  edi,ebx  ;file_name
  184. ;;      xor  ebx,ebx
  185. ;@@:
  186. ;    cld
  187. ;    lodsb
  188. ;;   stosb
  189. ;       inc   ebx
  190. ;    test  eax,eax
  191. ;    jnz   @b
  192. ;       pop   esi
  193.        
  194.     mov  [esi+1], byte 0
  195.     cld
  196.         ret
  197. ;----------------------------------------------
  198. align 4
  199. start_open_dialog:
  200. .subfunction    dd 7
  201. .flags          dd 0
  202. .parameter      dd 0 ;od_com_area_name
  203. .reserved1      dd 0
  204. .reserved2      dd 0
  205.                 db 0
  206. .name:          dd 0 ;od_start_path
  207. }
  208. ;*****************************************************************************
  209. macro   init_OpenDialog od_ptr
  210. {
  211.         mov     ebp,od_ptr
  212.         call    OpenDialog.init
  213. }
  214. ;*****************************************************************************
  215. macro   start_OpenDialog od_ptr
  216. {
  217.         mov     ebp,od_ptr
  218.         call    OpenDialog.start
  219. }
  220. ;*****************************************************************************