Subversion Repositories Kolibri OS

Rev

Rev 1041 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. ;
  2. ; Example for Box_lib: scrollbar, menubar, dinamic_button
  3. ; Copyright (c) 2009, Mario79
  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 Mario79 ''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. ;---------------------------------------------------------------------
  46. ;---    Start of program        ----------------------------------------------
  47. ;---------------------------------------------------------------------
  48. START:
  49.         mcall 68, 11
  50.         mcall 66, 1, 1
  51.         mcall 40, 0x27
  52. ;---------------------------------------------------------------------  
  53. ; Procinfo area for function 9 in MenuBar
  54.         mcall   68,12,1024
  55.         mov     [menu_data_1.procinfo],eax
  56.         mov     [menu_data_2.procinfo],eax
  57. ;---------------------------------------------------------------------  
  58. ; loading Box_Lib library
  59. load_libraries l_libs_start,end_l_libs
  60. ;sys_load_library  boxlib_name, path, file_name, system_dir, \
  61. ;er_message_found_lib, ihead_f_l, myimport, er_message_import, ihead_f_i
  62. ;        test    eax,eax
  63. ;        jnz  button.exit
  64.  
  65. ;----------------------------------old
  66. ;        mov     ebx,boxlib_name
  67. ;        mov     esi,path
  68. ;        mov     edi,file_name
  69. ;        call    copy_path
  70. ;
  71. ;        mcall 68,19,file_name ; load of alternative
  72. ;        test    eax,eax
  73. ;        jnz @f
  74. ;        
  75. ;        mcall 68,19,system_dir ; load of sys directory
  76. ;        test    eax,eax
  77. ;        jz      button.exit
  78. ;@@:
  79. ;        call    import_boxlib
  80. ;---------------------------------------------------------------------
  81. ; Load and convert BMP file for DinamicButton
  82. ; This procedures use cnv_bmp.obj and this module used only for
  83. ; demonstration of use DinamicButton
  84.  
  85. ;        mov     ebx,plugin_BMP_name
  86. ;        mov     esi,path
  87. ;        mov     edi,file_name
  88.         copy_path   plugin_BMP_name,path,file_name
  89. ;
  90.         mcall 68,19,file_name
  91.         test    eax,eax
  92.         jz  button.exit
  93.        
  94.         mov     eax,[eax+4]
  95.         mov     [plugin],eax
  96.  
  97.  
  98. ;ïðîâåðêà íà ñêîëüêî óäà÷íî çàãóçèëàñü íàøà ëèáà
  99.         mov     ebp,library01
  100.         cmp     dword [ebp+ll_struc_size-4],0
  101.         jnz     button.exit
  102. ;
  103. ;        mov     ebp,library02
  104. ;        cmp     dword [ebp+ll_struc_size-4],0x2
  105. ;        jnz     button.exit
  106. ;        mov     eax,dword [ebp+36]
  107. ;        mov     eax,[eax+4]
  108. ;        mov     [plugin],eax
  109.        
  110.  
  111.  
  112. ;        mov     ebx,icons_file_name
  113. ;        mov     esi,path
  114. ;        mov     edi,file_name
  115.         copy_path    icons_file_name,path,file_name
  116.        
  117.         mcall 70, fileinfo
  118.  
  119.         mov     [fileinfo+0],dword 0
  120.  
  121.         mov     ecx,[file_info+32]
  122.         mov     [fileinfo+12],ecx
  123.         mov [img_size],ecx
  124.        
  125.  
  126.         mcall 68, 12
  127.  
  128.  
  129.         mov     [fileinfo+16],eax
  130.         mov     [image_file],eax
  131.  
  132.  
  133.         mcall 70, fileinfo
  134.        
  135.         xor     eax,eax
  136.         mov     [return_code],eax
  137.         mov     eax,image_file
  138.         call    [plugin]
  139.        
  140.         mov     ecx,[image_file]
  141.         mcall 68, 13,
  142.        
  143.         cmp     [return_code],dword 0
  144.         jne     button.exit
  145.        
  146.         mov     ebx,[raw_pointer]
  147.         mov     eax,[ebx+4]
  148.         ; set of button size
  149.         mov     [dinamic_button_data_1.size_x],ax
  150.         mov     [dinamic_button_data_1.size_y],ax
  151.         mov     [dinamic_button_data_2.size_x],ax
  152.         mov     [dinamic_button_data_2.size_y],ax
  153.         mov     eax,[ebx+12]
  154.         ; set of RAW resolution to pixel
  155.         mov     [dinamic_button_data_1.resolution_raw],eax
  156.         mov     [dinamic_button_data_2.resolution_raw],eax
  157.         mov     eax,[ebx+20]
  158.         add     eax,ebx
  159.         ; set RAW palette, use else resolution 8bit or less
  160.         mov     [dinamic_button_data_1.palette_raw],eax
  161.         mov     [dinamic_button_data_2.palette_raw],eax
  162.         mov     eax,[ebx+28]
  163.         add     eax,ebx
  164.         ; set RAW area for passive button
  165.         mov     [dinamic_button_data_1.passive_raw],eax
  166.         mov     [dinamic_button_data_2.passive_raw],eax
  167.         mov     ecx,[ebx+4]
  168.         imul ecx,[ebx+4]
  169.         imul ecx,[ebx+12]
  170.         shr     ecx,3
  171.         add     eax,ecx
  172.         ; set  RAW area for active button
  173.         mov     [dinamic_button_data_1.active_raw],eax
  174.         mov     [dinamic_button_data_2.active_raw],eax
  175.         add     eax,ecx
  176.         ; RAW area for click button
  177.         mov     [dinamic_button_data_1.click_raw],eax
  178.         mov     [dinamic_button_data_2.click_raw],eax
  179. ;---------------------------------------------------------------------  
  180. red:
  181.         call draw_window
  182. still:
  183.         mcall 10
  184.  
  185.         cmp     eax,1
  186.         je      red
  187.         cmp     eax,2
  188.         je      key
  189.         cmp     eax,3
  190.         je      button
  191.         cmp     eax,6
  192.         je      mouse
  193.         jmp     still
  194.  
  195.  
  196. ;---------------------------------------------------------------------
  197.         key:
  198.         mcall 2
  199.         jmp     still
  200. ;---------------------------------------------------------------------
  201.         button:
  202.         mcall 17
  203.         cmp     ah, 1
  204.         jne     still
  205.         .exit:
  206.         mcall -1
  207. ;---------------------------------------------------------------------
  208. mouse:
  209. ;-----------------------------------------------
  210.         cmp     [scroll_bar_data_horizontal.delta2],0
  211.         jne     .horizontal
  212. .vertical:
  213.     mov   eax,[scroll_bar_data_vertical.max_area]
  214.     cmp   eax,[scroll_bar_data_vertical.cur_area]
  215.     jbe   .horizontal
  216. ; mouse event for Vertical ScrollBar
  217.         push dword scroll_bar_data_vertical
  218.         call [scrollbar_ver_mouse]
  219.         mov  eax,scroll_bar_data_vertical.redraw
  220.         xor  ebx,ebx
  221.         cmp     [eax],ebx
  222.         je      @f
  223.         mov     [eax],ebx
  224.         jmp     .draw_cube
  225. @@:
  226.         cmp     [scroll_bar_data_vertical.delta2],0
  227.         jne     still
  228. .horizontal:
  229.     mov   eax,[scroll_bar_data_horizontal.max_area]
  230.     cmp   eax,[scroll_bar_data_horizontal.cur_area]
  231.     jbe   .other
  232. ; mouse event for Horizontal ScrollBar
  233.         push dword scroll_bar_data_horizontal
  234.         call [scrollbar_hor_mouse]
  235.         mov  eax,scroll_bar_data_horizontal.redraw
  236.         xor  ebx,ebx
  237.         cmp     [eax],ebx      
  238.         je      .other
  239.         mov     [eax],ebx
  240. .draw_cube:
  241.         call draw_cube
  242.         jmp     still
  243. .other:
  244.         cmp  [scroll_bar_data_vertical.delta2],0
  245.         jne   still
  246.         cmp  [scroll_bar_data_horizontal.delta2],0
  247.         jne   still
  248. ;-----------------------------------------------
  249. .menu_bar_1:
  250.         call   .set_mouse_flag
  251. @@:
  252. ; mouse event for Menu 1
  253.         push    dword menu_data_1
  254.         call    [menu_bar_mouse]
  255.     cmp   [menu_data_1.click],dword 1
  256.         jne   .menu_bar_2
  257.         cmp   [menu_data_1.cursor_out],dword 0
  258.         jne    analyse_out_menu_1
  259.         jmp    .menu_bar_1
  260. ;--------------------------------------------
  261. .menu_bar_2:
  262. ; mouse event for Menu 2
  263.         push    dword menu_data_2
  264.         call    [menu_bar_mouse]
  265.     cmp   [menu_data_2.click],dword 1
  266.         jne   .mouse_dinamic_button
  267.         cmp   [menu_data_2.cursor_out],dword 0
  268.         jne    analyse_out_menu_2
  269.     jmp    .menu_bar_1
  270. ;--------------------------------------------
  271. .mouse_dinamic_button:
  272. ; mouse event for Dinamic Button 1
  273.         push    dword dinamic_button_data_1
  274.         call    [dinamic_button_mouse]
  275.         mov   eax,dinamic_button_data_1.click
  276.     cmp   [eax],dword 1
  277.         jne   @f
  278.     mov   [eax],dword 0
  279.         jmp   about
  280. @@:
  281. ; mouse event for Dinamic Button 2
  282.         push    dword dinamic_button_data_2
  283.         call    [dinamic_button_mouse]
  284.         mov   eax,dinamic_button_data_2.click
  285.     cmp   [eax],dword 1
  286.         jne   still  ;@f
  287.     mov   [eax],dword 0
  288.         jmp   button.exit
  289. ;---------------------------------------------------------------------
  290. .set_mouse_flag:        
  291.         xor   eax,eax
  292.         inc   eax
  293.         mov   [menu_data_1.get_mouse_flag],eax
  294.         mov   [menu_data_2.get_mouse_flag],eax
  295.         ret
  296. ;---------------------------------------------------------------------
  297. analyse_out_menu_1:
  298. ; analyse result of Menu 1
  299.         cmp [menu_data_1.cursor_out],dword 3
  300.         je      button.exit    
  301.         jmp     still
  302.        
  303. analyse_out_menu_2:
  304. ; analyse result of Menu 2
  305.         cmp [menu_data_2.cursor_out],dword 2
  306.         je      about
  307.         jmp     still
  308. ;---------------------------------------------------------------------
  309.         about:
  310.         mcall 51,1,thread3,thread
  311.         jmp     still
  312. ;---------------------------------------------------------------------
  313. draw_window:
  314.         mcall 12, 1
  315.         mcall 0, <0,400>, <0,400>, 0x03AABBCC, 0x805080D0, 0x005080D0
  316.         mcall 71, 1, header_1
  317. ;---------------------------------------------
  318. ; draw for Menu 1
  319.         push    dword menu_data_1
  320.         call    [menu_bar_draw]
  321. ; draw for Menu 2
  322.         push    dword menu_data_2
  323.         call    [menu_bar_draw]
  324. ;---------------------------------------------
  325. ; draw for Dinamic Button 1
  326.         push    dword dinamic_button_data_1
  327.         call    [dinamic_button_draw]
  328. ; draw for Dinamic Button 2
  329.         push    dword dinamic_button_data_2
  330.         call    [dinamic_button_draw]
  331. ;---------------------------------------------
  332. ; set all_redraw flag for draw all ScrollBar
  333. ; In some cases it is necessity to draw only the area
  334. ; of moving of a "runner", for acceleration of output -
  335. ; in this case the flag needs to be reset to 0 (zero).
  336.         xor     eax,eax
  337.         inc     eax
  338.         mov     [scroll_bar_data_vertical.all_redraw],eax
  339.         mov     [scroll_bar_data_horizontal.all_redraw],eax
  340.        
  341. ; draw for Vertical ScrollBar
  342.         push     dword scroll_bar_data_vertical
  343.         call     [scrollbar_ver_draw]
  344. ; draw for Horizontal ScrollBar
  345.         push     dword scroll_bar_data_horizontal
  346.         call     [scrollbar_hor_draw]
  347. ; reset all_redraw flag
  348.         xor     eax,eax
  349.         mov     [scroll_bar_data_vertical.all_redraw],eax
  350.         mov     [scroll_bar_data_horizontal.all_redraw],eax
  351. ;---------------------------------------------
  352.         call draw_cube
  353.         mcall 12, 2
  354.         ret
  355. ;---------------------------------------------------------------------
  356. draw_cube:
  357.         mcall 13,<30,301>,<50,301>,0xafafaf
  358.         mov     ecx,[scroll_bar_data_vertical.position]
  359.         add     ecx,50
  360.         shl     ecx,16
  361.         mov     cx,30
  362.         mov     ebx,[scroll_bar_data_horizontal.position]
  363.         add     ebx,30
  364.         shl     ebx,16
  365.         mov     bx,30
  366.         mcall 13, , , 0x0
  367.         ret
  368.  
  369. include 'data.inc'
  370. include 'w_about.inc'
  371. IM_END:
  372.         rb 1024
  373. thread:
  374.         rb 1024
  375. stacktop:
  376. path:
  377.         rb      4096
  378. file_name:
  379.         rb 4096
  380. file_info:
  381.         rb 40
  382. I_END:
  383.  
  384.