Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1037 mario79 1
;**************************************************************
2
; Dinamic Button Macro for Kolibri OS
1199 mario79 3
; Copyright (c) 2009, Marat Zakiyanov aka Mario79, aka Mario
1037 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  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
;
1199 mario79 17
; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
1037 mario79 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  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
macro dinamic_button_exit
29
{
30
popa
31
ret 4
32
}
33
;*****************************************************************************
34
macro use_dinamic_button
35
{
36
dinamic_button:
37
db_type				equ [edi]
38
db_size_x			equ [edi+4]
39
db_start_x			equ [edi+6]
40
db_size_y			equ [edi+8]
41
db_start_y			equ [edi+10]
42
db_mouse_pos		equ [edi+12]
43
db_mouse_keys		equ [edi+16]
44
db_mouse_keys_old	equ [edi+20]
45
db_active_raw		equ [edi+24]
46
db_passive_raw		equ [edi+28]
47
db_click_raw		equ [edi+32]
48
db_resolution_raw	equ [edi+36]
49
db_palette_raw		equ [edi+40]
50
db_offset_raw		equ [edi+44]
51
db_select			equ [edi+48]
52
db_click			equ [edi+52]
53
;*****************************************************************************
54
;*****************************************************************************
55
; draw event
56
;*****************************************************************************
57
;*****************************************************************************
58
.draw:
59
    pusha
60
	mov   edi,dword [esp+36]
61
    call  .draw_1
62
dinamic_button_exit
63
 
64
.draw_1:
65
	cmp    db_select,dword 1
66
	je     .active_1
67
	cmp    db_select,dword 2
68
	je     .click_2
69
	mov    ebx,db_passive_raw
1199 mario79 70
	jmp    .draw_2
1037 mario79 71
.active_1:
72
	mov    ebx,db_active_raw
1199 mario79 73
	jmp   .draw_2
1037 mario79 74
.click_2:
75
	mov    ebx,db_click_raw
76
@@:
77
.draw_2:
78
    mov   cx,db_size_x
79
	shl   ecx,16
80
	mov   cx,db_size_y
81
 
82
    mov   dx,db_start_x
83
	shl   edx,16
84
	mov   dx,db_start_y
85
 
86
	mov   esi,db_resolution_raw
87
 
88
	mov   ebp,db_offset_raw
89
 
90
	push  edi
91
	mov   edi,db_palette_raw
92
	mcall 65
93
	pop   edi
94
	ret
95
;*****************************************************************************
96
;*****************************************************************************
97
; mouse event
98
;*****************************************************************************
99
;*****************************************************************************
100
.mouse:
101
	pusha
102
	mov   edi,dword [esp+36]
103
     mcall 37,2
104
	 mov   ebx,db_mouse_keys
105
	 mov   db_mouse_keys_old,ebx
106
 
107
     mov   db_mouse_keys,eax
108
 
109
     mcall 37,1
110
     mov   db_mouse_pos,eax
111
 
112
     test  eax,0x80000000
113
     jnz   .exit_menu
114
     test  eax,0x8000
115
     jnz   .exit_menu
116
 
117
     mov   ebx,eax
118
     shr   ebx,16   ; x position
119
     shl   eax,16
120
     shr   eax,16   ; y position
121
 
122
     mov   cx,db_start_x
123
     cmp   bx,cx
124
     jb    .exit_menu
125
 
126
     add   cx,db_size_x
127
     cmp   bx,cx
128
     ja    .exit_menu
129
 
130
     mov   cx,db_start_y
131
     cmp   ax,cx
132
     jb    .exit_menu
133
 
134
     add   cx,db_size_y
135
     cmp   ax,cx
136
     ja    .exit_menu
137
 
138
	 test   db_mouse_keys,dword 1b
139
	 jnz   @f
140
	 cmp   db_select,dword 1
141
	 je    .exit_menu_1
142
	 mov   db_select,dword 1
143
	 call  .draw_1
144
	 jmp   .exit_menu_1
145
@@:
146
	 mov   eax,db_mouse_keys
147
     cmp   eax,db_mouse_keys_old
148
	 je    .exit_menu_1
149
 
150
	 mov   db_select,dword 2
151
	 call  .draw_1
152
	 mcall 5, 25
153
	 mov   db_select,dword 1
154
	 call  .draw_1
155
 
156
	 mov    db_click,dword 1
157
	 jmp   .exit_menu_2
158
 
159
.exit_menu:
160
	 cmp   db_select,dword 0
161
	 je    .exit_menu_1
162
	 mov   db_select,dword 0
163
 
164
	 call  .draw_1
165
 
166
.exit_menu_1:
167
;	mov    db_click,dword 0
168
.exit_menu_2:
169
dinamic_button_exit
170
}