Subversion Repositories Kolibri OS

Rev

Rev 1219 | Rev 1418 | 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. OpenDialog_exit
  75. ;*****************************************************************************
  76. ;*****************************************************************************
  77. .start:
  78.         pusha
  79.         mov     eax,od_com_area
  80.         test    eax,eax
  81.         jz      .1
  82.         mov ebx,od_type
  83.         mov [eax+2],bx
  84.        
  85.         mov     [eax],word 2 ; folder for open
  86.         mov     edi,eax
  87.         add     edi,4
  88.  
  89.         mov     esi,od_opendir_pach
  90.         xor     eax,eax
  91.         mov     al,[esi]
  92.         test    eax,eax
  93.         jnz     @f
  94.         mov     esi,od_dir_default_pach ;communication_area_default_pach
  95. @@:
  96.         call    .copy
  97.  
  98.         mov     eax,od_com_area_name
  99.         mov     [start_open_dialog.parameter],eax
  100.  
  101.         mov     eax,od_start_path
  102.         mov     [start_open_dialog.name],eax
  103.  
  104.         mcall   70, start_open_dialog
  105.         shr     eax,31
  106.         test    eax,eax
  107.         jnz     .1
  108.         jmp     .still
  109. .red:
  110.         pusha
  111.         call    od_draw_window
  112.         popa
  113. .still:
  114.         mcall   23, 50
  115.         cmp     eax,1
  116.         je      .red
  117.         mov     eax,od_com_area
  118.         movzx   ebx,word [eax]
  119.         test    ebx,ebx
  120.         jz      .still
  121.         cmp     ebx,3
  122.         je      .2 ;still
  123.         cmp     ebx,1
  124.         jne     .still
  125.  
  126.         mov     esi,od_com_area
  127.         add     esi,4
  128.         mov     edi,od_openfile_pach ;string
  129.         call    .copy
  130.         mov     od_status,1
  131.         jmp     .3  ;kopen_1
  132. .2:
  133.         mov     od_status,0
  134.         jmp     .3 ; still
  135. .1:
  136.         mov     od_status,2 ; thread1
  137. .3:
  138. OpenDialog_exit
  139. ;----------------------------------------------
  140. .copy:
  141.         xor     eax,eax
  142.         cld
  143. @@:
  144.         lodsb
  145.         stosb
  146.         test    eax,eax
  147.         jnz     @b
  148.         ret
  149. ;----------------------------------------------
  150. align 4
  151. start_open_dialog:
  152. .subfunction    dd 7
  153. .flags          dd 0
  154. .parameter      dd 0 ;od_com_area_name
  155. .reserved1      dd 0
  156. .reserved2      dd 0
  157.                 db 0
  158. .name:          dd 0 ;od_start_path
  159. }
  160. ;*****************************************************************************
  161. macro   init_OpenDialog od_ptr
  162. {
  163.         mov     ebp,od_ptr
  164.         call    OpenDialog.init
  165. }
  166. ;*****************************************************************************
  167. macro   start_OpenDialog od_ptr
  168. {
  169.         mov     ebp,od_ptr
  170.         call    OpenDialog.start
  171. }
  172. ;*****************************************************************************