Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
8346 IgorA 1
;**************************************************************
2
; Dinamic Button Macro for Kolibri OS
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  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  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
align 16
35
dinamic_button:
36
db_type				equ [edi]
37
db_size_x			equ [edi+4]
38
db_start_x			equ [edi+6]
39
db_size_y			equ [edi+8]
40
db_start_y			equ [edi+10]
41
db_mouse_pos		equ [edi+12]
42
db_mouse_keys		equ [edi+16]
43
db_mouse_keys_old	equ [edi+20]
44
db_active_raw		equ [edi+24]
45
db_passive_raw		equ [edi+28]
46
db_click_raw		equ [edi+32]
47
db_resolution_raw	equ [edi+36]
48
db_palette_raw		equ [edi+40]
49
db_offset_raw		equ [edi+44]
50
db_select			equ [edi+48]
51
db_click			equ [edi+52]
52
;*****************************************************************************
53
;*****************************************************************************
54
; draw event
55
;*****************************************************************************
56
;*****************************************************************************
57
.draw:
58
    pusha
59
	mov   edi,dword [esp+36]
60
    call  .draw_1
61
dinamic_button_exit
62
 
63
.draw_1:
64
	cmp    dword db_select,1
65
	je     .active_1
66
	cmp    dword db_select,2
67
	je     .click_2
68
	mov    ebx,db_passive_raw
69
	jmp    .draw_2
70
.active_1:
71
	mov    ebx,db_active_raw
72
	jmp   .draw_2
73
.click_2:
74
	mov    ebx,db_click_raw
75
@@:
76
.draw_2:
77
    mov   cx,db_size_x
78
	shl   ecx,16
79
	mov   cx,db_size_y
80
 
81
    mov   dx,db_start_x
82
	shl   edx,16
83
	mov   dx,db_start_y
84
 
85
	mov   esi,db_resolution_raw
86
 
87
	mov   ebp,db_offset_raw
88
 
89
	push  edi
90
	mov   edi,db_palette_raw
91
	mcall SF_PUT_IMAGE_EXT
92
	pop   edi
93
	ret
94
;*****************************************************************************
95
;*****************************************************************************
96
; mouse event
97
;*****************************************************************************
98
;*****************************************************************************
99
align 4
100
.mouse:
101
	pusha
102
	mov   edi,dword [esp+36]
103
     mcall SF_MOUSE_GET,SSF_BUTTON
104
	 mov   ebx,db_mouse_keys
105
	 mov   db_mouse_keys_old,ebx
106
 
107
     mov   db_mouse_keys,eax
108
 
109
     mcall SF_MOUSE_GET,SSF_WINDOW_POSITION
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   dword db_select,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 SF_SLEEP, 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   dword db_select,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