Subversion Repositories Kolibri OS

Rev

Rev 1219 | Rev 1433 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;*****************************************************************************
  2. ; Example for Box_lib: scrollbar, menubar, dinamic_button
  3. ; Copyright (c) 2009, 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. ; import_boxlib procedure written by <Lrz>
  29. ;---------------------------------------------------------------------
  30.  
  31.         use32
  32.         org     0x0
  33.  
  34.         db      'MENUET01'
  35.         dd      0x01
  36.         dd      START
  37.         dd      IM_END
  38.         dd      I_END
  39.         dd      stacktop
  40.         dd      0x0
  41.         dd      path
  42.  
  43. include '../../../../../macros.inc'
  44. include '../../load_lib.mac'
  45. ;include 'macros.inc'
  46. ;include 'load_lib.mac'
  47.         @use_library
  48. include 'opendial.mac'
  49.         use_OpenDialog
  50. ;---------------------------------------------------------------------
  51. ;---    Start of program        ----------------------------------------------
  52. ;---------------------------------------------------------------------
  53. START:
  54.         mcall 68, 11
  55.         mcall 66, 1, 1
  56.         mcall 40, 0x27
  57. ;---------------------------------------------------------------------  
  58.  
  59. load_libraries l_libs_start,end_l_libs
  60.  
  61.         test  eax,eax
  62.         jnz    button.exit
  63.  
  64. ; unpack deflate
  65.         mov   eax,[unpack_DeflateUnpack2]
  66.         mov  [deflate_unpack],eax
  67.  
  68. ;OpenDialog initialisation
  69. init_OpenDialog OpenDialog_data
  70.  
  71.  
  72. ;        mov     ebx,icons_file_name
  73. ;        mov     esi,path
  74. ;        mov     edi,file_name
  75.  
  76.         copy_path    icons_file_name,path,library_path,0
  77.        
  78.         mcall 70, fileinfo
  79.  
  80.         mov     [fileinfo+0],dword 0
  81.  
  82.         mov     ecx,[file_info+32]
  83.         mov     [fileinfo+12],ecx
  84.         mov [img_size],ecx
  85.        
  86.  
  87.         mcall 68, 12
  88.  
  89.  
  90.         mov     [fileinfo+16],eax
  91.         mov     [image_file],eax
  92.  
  93.  
  94.         mcall 70, fileinfo
  95.        
  96.         xor     eax,eax
  97.         mov     [return_code],eax
  98.         mov     eax,image_file
  99.         call    [cnv_png_import.Start]
  100.        
  101.         mov     ecx,[image_file]
  102.         mcall 68, 13,
  103.        
  104.         cmp     [return_code],dword 0
  105.         jne     button.exit
  106.        
  107.         mov     ebx,[raw_pointer]
  108.         mov     eax,[ebx+4]
  109.         ; set of button size
  110.         mov     [dinamic_button_data_1.size_x],ax
  111.         mov     [dinamic_button_data_1.size_y],ax
  112.         mov     [dinamic_button_data_2.size_x],ax
  113.         mov     [dinamic_button_data_2.size_y],ax
  114.         mov     eax,[ebx+12]
  115.         ; set of RAW resolution to pixel
  116.         mov     [dinamic_button_data_1.resolution_raw],eax
  117.         mov     [dinamic_button_data_2.resolution_raw],eax
  118.         mov     eax,[ebx+20]
  119.         add     eax,ebx
  120.         ; set RAW palette, use else resolution 8bit or less
  121.         mov     [dinamic_button_data_1.palette_raw],eax
  122.         mov     [dinamic_button_data_2.palette_raw],eax
  123.         mov     eax,[ebx+28]
  124.         add     eax,ebx
  125.         ; set RAW area for passive button
  126.         mov     [dinamic_button_data_1.passive_raw],eax
  127.         mov     [dinamic_button_data_2.passive_raw],eax
  128.         mov     ecx,[ebx+4]
  129.         imul ecx,[ebx+4]
  130.         imul ecx,[ebx+12]
  131.         shr     ecx,3
  132.         add     eax,ecx
  133.         ; set  RAW area for active button
  134.         mov     [dinamic_button_data_1.active_raw],eax
  135.         mov     [dinamic_button_data_2.active_raw],eax
  136.         add     eax,ecx
  137.         ; RAW area for click button
  138.         mov     [dinamic_button_data_1.click_raw],eax
  139.         mov     [dinamic_button_data_2.click_raw],eax
  140. ;---------------------------------------------------------------------  
  141. red:
  142.         call draw_window
  143. still:
  144.         mcall 10
  145.  
  146.         cmp     eax,1
  147.         je      red
  148.         cmp     eax,2
  149.         je      key
  150.         cmp     eax,3
  151.         je      button
  152.         cmp     eax,6
  153.         je      mouse
  154.         jmp     still
  155.  
  156.  
  157. ;---------------------------------------------------------------------
  158.         key:
  159.         mcall 2
  160.         jmp     still
  161. ;---------------------------------------------------------------------
  162.         button:
  163.         mcall 17
  164.         cmp     ah, 1
  165.         jne     still
  166.         .exit:
  167.         mcall -1
  168. ;---------------------------------------------------------------------
  169. mouse:
  170. ;-----------------------------------------------
  171.         cmp     [scroll_bar_data_horizontal.delta2],0
  172.         jne     .horizontal
  173. .vertical:
  174.     mov   eax,[scroll_bar_data_vertical.max_area]
  175.     cmp   eax,[scroll_bar_data_vertical.cur_area]
  176.     jbe   .horizontal
  177. ; mouse event for Vertical ScrollBar
  178.         push dword scroll_bar_data_vertical
  179.         call [scrollbar_ver_mouse]
  180.         mov  eax,scroll_bar_data_vertical.redraw
  181.         xor  ebx,ebx
  182.         cmp     [eax],ebx
  183.         je      @f
  184.         mov     [eax],ebx
  185.         jmp     .draw_cube
  186. @@:
  187.         cmp     [scroll_bar_data_vertical.delta2],0
  188.         jne     still
  189. .horizontal:
  190.     mov   eax,[scroll_bar_data_horizontal.max_area]
  191.     cmp   eax,[scroll_bar_data_horizontal.cur_area]
  192.     jbe   .other
  193. ; mouse event for Horizontal ScrollBar
  194.         push dword scroll_bar_data_horizontal
  195.         call [scrollbar_hor_mouse]
  196.         mov  eax,scroll_bar_data_horizontal.redraw
  197.         xor  ebx,ebx
  198.         cmp     [eax],ebx      
  199.         je      .other
  200.         mov     [eax],ebx
  201. .draw_cube:
  202.         call draw_cube
  203.         jmp     still
  204. .other:
  205.         cmp  [scroll_bar_data_vertical.delta2],0
  206.         jne   still
  207.         cmp  [scroll_bar_data_horizontal.delta2],0
  208.         jne   still
  209. ;-----------------------------------------------
  210. .menu_bar_1:
  211.         call   .set_mouse_flag
  212. @@:
  213. ; mouse event for Menu 1
  214.         push    dword menu_data_1
  215.         call    [menu_bar_mouse]
  216.     cmp   [menu_data_1.click],dword 1
  217.         jne   .menu_bar_2
  218.         cmp   [menu_data_1.cursor_out],dword 0
  219.         jne    analyse_out_menu_1
  220.         jmp    .menu_bar_1
  221. ;--------------------------------------------
  222. .menu_bar_2:
  223. ; mouse event for Menu 2
  224.         push    dword menu_data_2
  225.         call    [menu_bar_mouse]
  226.     cmp   [menu_data_2.click],dword 1
  227.         jne   .mouse_dinamic_button
  228.         cmp   [menu_data_2.cursor_out],dword 0
  229.         jne    analyse_out_menu_2
  230.     jmp    .menu_bar_1
  231. ;--------------------------------------------
  232. .mouse_dinamic_button:
  233. ; mouse event for Dinamic Button 1
  234.         push    dword dinamic_button_data_1
  235.         call    [dinamic_button_mouse]
  236.         mov   eax,dinamic_button_data_1.click
  237.     cmp   [eax],dword 1
  238.         jne   @f
  239.     mov   [eax],dword 0
  240.         jmp   about
  241. @@:
  242. ; mouse event for Dinamic Button 2
  243.         push    dword dinamic_button_data_2
  244.         call    [dinamic_button_mouse]
  245.         mov   eax,dinamic_button_data_2.click
  246.     cmp   [eax],dword 1
  247.         jne   still  ;@f
  248.     mov   [eax],dword 0
  249.         jmp   button.exit
  250. ;---------------------------------------------------------------------
  251. .set_mouse_flag:        
  252.         xor   eax,eax
  253.         inc   eax
  254.         mov   [menu_data_1.get_mouse_flag],eax
  255.         mov   [menu_data_2.get_mouse_flag],eax
  256.         ret
  257. ;---------------------------------------------------------------------
  258. analyse_out_menu_1:
  259. ; analyse result of Menu 1
  260.         mov     eax,[menu_data_1.cursor_out]
  261.         cmp     eax,dword 1
  262.         je      OpenDialog_start_0
  263.         cmp     eax,dword 2
  264.         je      OpenDialog_start_1
  265.         cmp     eax,dword 3
  266.         je      OpenDialog_start_2
  267.     cmp eax,dword 4
  268.     je      button.exit    
  269.     jmp     still
  270.        
  271. analyse_out_menu_2:
  272. ; analyse result of Menu 2
  273.         cmp [menu_data_2.cursor_out],dword 2
  274.         je      about
  275.         jmp     still
  276. ;---------------------------------------------------------------------
  277.         about:
  278.         mcall 51,1,thread3,thread
  279.         jmp     still
  280. ;---------------------------------------------------------------------
  281. OpenDialog_start_0:
  282.         mov     [OpenDialog_data.type],0
  283.         jmp     OpenDialog_start
  284. OpenDialog_start_1:
  285.         mov     [OpenDialog_data.type],1
  286.         jmp     OpenDialog_start
  287. OpenDialog_start_2:
  288.         mov     [OpenDialog_data.type],2
  289. OpenDialog_start:
  290. ;       mov     ebx,open_dialog_name
  291. ;       mov     esi,path
  292. ;       mov     edi,library_path
  293. ;       call    copy_file_path
  294.         call    get_filter_data
  295.  
  296.         copy_path       open_dialog_name,path,library_path,0
  297.  
  298.  
  299. start_OpenDialog        OpenDialog_data
  300.  
  301.         cmp     [OpenDialog_data.status],2 ; OpenDialog does not start
  302.         je      still  ;        some kind of alternative, instead OpenDialog
  303.         cmp     [OpenDialog_data.status],1
  304.         jne     still ; OpenDialog user say cancel
  305. ;       copy path
  306.         call    draw_window
  307.         jmp     still ; OpenDialog user selected the target file
  308.         ; [OpenDialog_data.openfile_pach] pointer of area the target file
  309. ;---------------------------------------------------------------------
  310. get_filter_data:
  311.         mov     edi,[OpenDialog_data.com_area]
  312.         test    edi,edi
  313.         jnz     @f
  314.         add     esp,4
  315.         jmp     still
  316. @@:
  317.         add     edi,4096+4
  318.         mov     esi,Filter
  319.         mov     ecx,[esi]
  320.         inc     ecx
  321.         cld
  322.         rep     movsb
  323.         mov     edi,[OpenDialog_data.com_area]
  324.         mov     [edi+4096],dword 1
  325.         ret
  326. ;---------------------------------------------------------------------
  327. draw_window:
  328.         mcall 12, 1
  329.         mcall 0, <0,400>, <0,400>, 0x03AABBCC, 0x805080D0, 0x005080D0
  330.         mcall 71, 1, header_1
  331. ;---------------------------------------------
  332. ; draw for Menu 1
  333.         push    dword menu_data_1
  334.         call    [menu_bar_draw]
  335. ; draw for Menu 2
  336.         push    dword menu_data_2
  337.         call    [menu_bar_draw]
  338. ;---------------------------------------------
  339. ; draw for Dinamic Button 1
  340.         push    dword dinamic_button_data_1
  341.         call    [dinamic_button_draw]
  342. ; draw for Dinamic Button 2
  343.         push    dword dinamic_button_data_2
  344.         call    [dinamic_button_draw]
  345. ;---------------------------------------------
  346.         mcall   13,<170,200>,<25,15>,0xffffb0
  347.         mov     bx,28
  348.         add     ebx,2 shl 16
  349.         mcall   4,,0xC0000000,openfile_pach,,0xffffb0
  350. ;---------------------------------------------
  351. ; set all_redraw flag for draw all ScrollBar
  352. ; In some cases it is necessity to draw only the area
  353. ; of moving of a "runner", for acceleration of output -
  354. ; in this case the flag needs to be reset to 0 (zero).
  355.         xor     eax,eax
  356.         inc     eax
  357.         mov     [scroll_bar_data_vertical.all_redraw],eax
  358.         mov     [scroll_bar_data_horizontal.all_redraw],eax
  359.        
  360. ; draw for Vertical ScrollBar
  361.         push     dword scroll_bar_data_vertical
  362.         call     [scrollbar_ver_draw]
  363. ; draw for Horizontal ScrollBar
  364.         push     dword scroll_bar_data_horizontal
  365.         call     [scrollbar_hor_draw]
  366. ; reset all_redraw flag
  367.         xor     eax,eax
  368.         mov     [scroll_bar_data_vertical.all_redraw],eax
  369.         mov     [scroll_bar_data_horizontal.all_redraw],eax
  370. ;---------------------------------------------
  371.         call draw_cube
  372.         mcall 12, 2
  373.         ret
  374. ;---------------------------------------------------------------------
  375. draw_cube:
  376.         mcall 13,<30,301>,<50,301>,0xafafaf
  377.         mov     ecx,[scroll_bar_data_vertical.position]
  378.         add     ecx,50
  379.         shl     ecx,16
  380.         mov     cx,30
  381.         mov     ebx,[scroll_bar_data_horizontal.position]
  382.         add     ebx,30
  383.         shl     ebx,16
  384.         mov     bx,30
  385.         mcall 13, , , 0x0
  386.         ret
  387. ;---------------------------------------------------------------------
  388. include 'data.inc'
  389. include 'w_about.inc'
  390. ;---------------------------------------------------------------------
  391. IM_END:
  392.         rb 1024
  393. thread:
  394. ;---------------------------------------------------------------------
  395.         rb 1024
  396. stacktop:
  397. ;---------------------------------------------------------------------
  398. path:
  399.         rb 4096
  400. ;---------------------------------------------------------------------
  401. openfile_pach:
  402.         rb 4096
  403. ;---------------------------------------------------------------------
  404. file_name:
  405. library_path:
  406.         rb 4096
  407. ;---------------------------------------------------------------------
  408. plugin_pach:
  409.         rb 4096
  410. ;---------------------------------------------------------------------
  411. file_info:
  412.         rb 40
  413. ;---------------------------------------------------------------------
  414. procinfo:
  415.         rb 1024
  416. ;---------------------------------------------------------------------
  417. I_END:
  418.  
  419.