Subversion Repositories Kolibri OS

Rev

Rev 2087 | Rev 4817 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2087 Rev 2088
Line 1... Line 1...
1
use32
1
use32
2
    org 0x0
2
    org 0x0
3
    db  'MENUET01'
3
    db  'MENUET01'
4
    dd  0x01,start,i_end,e_end,e_end,0,0
4
    dd  0x01,start,i_end,e_end,e_end,0,0
Line -... Line 5...
-
 
5
 
-
 
6
include '../../../proc32.inc'
Line 5... Line 7...
5
 
7
include '../../../macros.inc'
6
 
8
 
-
 
9
BUTTON_SIDE			equ	16	; button are squares
-
 
10
BUTTON_SPACE			equ	19	; space between cols and rows
-
 
11
BUTTON_ID_SHIFT			equ	2	; button_id = character + BUTTON_ID_SHIFT
Line -... Line 12...
-
 
12
TABLE_BEGIN_X			equ	2
-
 
13
TABLE_BEGIN_Y			equ	2
Line 7... Line -...
7
BUTTON_SIDE		equ	16		; button are squares
-
 
8
BUTTON_SPACE		equ	19		; space between cols and rows
-
 
Line -... Line 14...
-
 
14
 
9
 
15
FOCUS_SQUARE_COLOR		equ	0x000080FF
10
 
16
PAGE_SWITCHER_BLINK_COLOR	equ	0x00808080
11
start:
-
 
12
	call	get_skin_height
-
 
13
 
17
 
14
still:
-
 
15
	mov	eax, 10
18
 
16
	int	0x40
19
start:
17
 
-
 
18
	dec	eax
20
still:
19
	jnz	@f
-
 
20
	call	redraw
-
 
21
    @@:	dec	eax
-
 
22
	jnz	@f
-
 
23
	call	key
-
 
24
    @@:	dec	eax
-
 
25
	jnz	@f
-
 
Line 26... Line 21...
26
	call	button
21
	mcall	10
27
    @@:	jmp	still
22
	dec	eax
28
 
23
	jz	redraw
Line -... Line 24...
-
 
24
	dec	eax
-
 
25
	jz	key
-
 
26
 
-
 
27
button:
-
 
28
	mcall	17
-
 
29
	shr	eax, 8
-
 
30
 
-
 
31
	cmp	eax, 1
29
 
32
	je	quit
-
 
33
	cmp	ax, 0xFFAA			; page switcher
-
 
34
	je	.switch_page			; any button with a character
-
 
35
  .change_focus:
-
 
36
	mov	bl, [symbol_focused]
-
 
37
	mov	[symbol_unfocused], bl
-
 
38
	sub	ax, BUTTON_ID_SHIFT		; get the corresponding character
-
 
39
	mov	[symbol_focused], al
-
 
40
	stdcall	draw_table, 0
-
 
41
	call	draw_codes
-
 
42
	jmp	still
-
 
43
  .switch_page:
30
get_skin_height:
44
	movzx	bx, [symbol_start]
-
 
45
	add	bx, BUTTON_ID_SHIFT
Line -... Line 46...
-
 
46
	mov	cx, 128				; half of page
-
 
47
	mov	edx, 0x80000000
-
 
48
	mov	dx, bx
-
 
49
    @@:	mcall	8
-
 
50
	inc	edx
-
 
51
	dec	cx
-
 
52
	jnz	@b
-
 
53
 
Line 31... Line 54...
31
 
54
    @@:	add	[symbol_start], 128		; change page
32
	mov	eax, 48
55
	add	[symbol_focused], 128
33
	mov	ebx, 4
56
	stdcall	draw_table, 1			; 1 means redraw the whole table
-
 
57
	call	draw_codes
34
	int	0x40
58
	stdcall	draw_page_switcher, 1		; 1 means dark color, for blinking
Line 35... Line -...
35
 
-
 
36
	mov	[skin_height], eax
59
	mcall	5, 10
37
	ret
60
	stdcall	draw_page_switcher, 0		; 0 means usual light color
38
 
61
	jmp	still
39
 
62
 
-
 
63
redraw:
40
redraw:
64
	mcall	9, proc_info, -1
-
 
65
	mcall	48, 3, sys_colors, 40
41
	mov	eax, 12
66
 
-
 
67
	mcall	12, 1
42
	mov	ebx, 1
68
 
Line 43... Line 69...
43
	int	0x40
69
	mcall	48, 4				; get skin height
44
 
70
	mov	ecx, 300*0x10000+184
45
	mov	eax, 0
71
	add	ecx, eax
46
	mov	ebx, 300*0x10000+317
-
 
47
	mov	ecx, 300*0x10000+184
-
 
48
	add	ecx, [skin_height]
-
 
49
	mov	edx, 0x33F0F0F0			; skinned, resizeable
-
 
50
	mov	esi, 0x80808080			; title color
-
 
Line -... Line 72...
-
 
72
	mov	edx, 0x34000000
-
 
73
	or	edx, [sys_colors.work]
-
 
74
	mov	esi, 0x80000000
Line 51... Line 75...
51
	mov	edi, window_title
75
	or	esi, [sys_colors.grab_text]
52
	int	0x40
76
	mcall	0, <300,315>, , , , window_title
53
 
77
	test	[proc_info.wnd_state], 0x04
54
	call	draw_table
78
	jnz	@f
Line 55... Line -...
55
	call	draw_codes
-
 
56
	call	draw_page_switcher
-
 
57
 
-
 
58
	mov	eax, 12
79
 
59
	mov	ebx, 2
80
	stdcall	draw_table, 1
60
	int	0x40
-
 
61
	ret
-
 
62
 
-
 
63
 
-
 
64
key:
-
 
65
	mov	eax, 2
81
	call	draw_codes
66
	int	0x40
-
 
67
	ret
82
	stdcall	draw_page_switcher, 0
68
 
83
 
69
button:
-
 
70
	mov	eax, 17
84
    @@:
71
	int	0x40
85
	mcall	12, 2
72
	cmp	eax, 1
86
	jmp	still
73
	jnz	@f
87
 
74
	ret
-
 
75
    @@:	shr	eax, 8
88
key:
76
	cmp	eax, 1
-
 
77
	jz	quit
-
 
78
	cmp	ax, 0xFFAA
89
	mcall	2
Line 79... Line 90...
79
	jnz	.change_focus
90
	cmp	ah, 0x09			; TAB key
-
 
91
	je	button.switch_page
-
 
92
 
-
 
93
	cmp	ah, 0xB0			; left
-
 
94
	jne	@f
-
 
95
	mov	bl, [symbol_focused]
80
	xor	bx, bx
96
	mov	[symbol_unfocused], bl
-
 
97
	dec	bl
81
	mov	bl, [symbol_start]
98
	and	bl, 0x0f
82
	add	bx, 2
99
	and	[symbol_focused], 0xf0
83
	mov	cx, bx
-
 
84
	add	cx, 128
-
 
85
    @@:	mov	eax, 8
-
 
86
	mov	edx, 0x80000000
-
 
87
	add	dx, bx
100
	or	[symbol_focused], bl
88
	int	0x40
-
 
89
	cmp	bx, cx
-
 
90
	jz	@f
-
 
Line 91... Line 101...
91
	inc	bx
101
	stdcall	draw_table, 0
-
 
102
	call	draw_codes
92
	jmp	@b
103
	jmp	still
93
 
104
 
94
    @@:	add	[symbol_start], 128		; change page
105
    @@:	cmp	ah, 0xB1			; down
95
	add	[symbol_focused], 128
106
	jne	@f
96
	call	draw_table
107
	mov	bl, [symbol_focused]
97
	call	draw_codes
108
	mov	[symbol_unfocused], bl
98
	mov	[redraw_flag], 1		; for page_switcher this means visual blink (color changing)
109
	add	bl, 16
99
	call	draw_page_switcher
110
	and	bl, 0x70
-
 
111
	and	[symbol_focused], 0x8f
-
 
112
	or	[symbol_focused], bl
-
 
113
	stdcall	draw_table, 0
-
 
114
	call	draw_codes
-
 
115
	jmp	still
-
 
116
 
-
 
117
    @@:	cmp	ah, 0xB2			; up
-
 
118
	jne	@f
-
 
119
	mov	bl, [symbol_focused]
-
 
120
	mov	[symbol_unfocused], bl
100
	mov	eax, 5
121
	sub	bl, 16
-
 
122
	and	bl, 0x70
-
 
123
	and	[symbol_focused], 0x8f
101
	mov	ebx, 10
124
	or	[symbol_focused], bl
-
 
125
	stdcall	draw_table, 0
-
 
126
	call	draw_codes
-
 
127
	jmp	still
-
 
128
 
Line 102... Line 129...
102
	int	0x40
129
    @@:	cmp	ah, 0xB3			; righ
Line 103... Line 130...
103
	mov	[redraw_flag], 0
130
	jne	@f
104
	call	draw_page_switcher
131
	mov	bl, [symbol_focused]
Line 105... Line 132...
105
	ret
132
	mov	[symbol_unfocused], bl
106
 
-
 
107
  .change_focus:
-
 
108
	mov	bl, [symbol_focused]
-
 
109
	mov	[symbol_unfocused], bl
-
 
Line -... Line 133...
-
 
133
	inc	bl
110
	shl	eax, 8
134
	and	bl, 0x0f
111
	sub	ah, 2
-
 
112
	mov	[symbol_focused], ah
-
 
113
	mov	[redraw_flag], 1		; for table this means redraw only focused and unfocused buttons
-
 
114
	call	draw_table
-
 
115
	call	draw_codes
135
	and	[symbol_focused], 0xf0
116
	mov	[redraw_flag], 0
-
 
117
	ret
136
	or	[symbol_focused], bl
118
 
137
	stdcall	draw_table, 0
119
 
138
	call	draw_codes
120
draw_table:
139
	jmp	still
121
 
140
	jne	@f
122
	mov	al, [symbol_start]
-
 
123
	mov	[symbol_current], al
141
 
124
 
142
    @@:
125
  .next_button:
-
 
126
	push	[button_x]
143
	jmp	still
127
	pop	[button_cur_x]
144
 
Line 128... Line 145...
128
	push	[button_y]
145
 
129
	pop	[button_cur_y]
146
 
130
 
147
proc	draw_table _full_redraw
131
	mov	al, [symbol_current]
148
 
132
	mov	[button_cur_id], al
149
	mov	al, [symbol_start]
133
 
150
	mov	[symbol_current], al
134
	mov	[is_active], 0
151
 
135
 
152
  .next_button:
136
	mov	al, [symbol_focused]
153
 
137
	cmp	[symbol_current], al
154
	xor	edi, edi			; character focus flag
138
	jnz	@f
155
	mov	al, [symbol_current]
139
	mov	byte[is_active], 1
156
	cmp	al, [symbol_focused]
140
    @@:	cmp	[redraw_flag], 1
157
	jne	@f
141
	jnz	.draw				; if redraw_flag is zero, we should redraw the whole table
-
 
142
	mov	al, [symbol_focused]
158
	inc	edi
143
	cmp	[symbol_current], al
159
    @@:	cmp	[_full_redraw], 1
144
	jz	.draw
160
	je	.draw
145
	mov	al, [symbol_unfocused]
161
	cmp	al, [symbol_focused]
146
	cmp	[symbol_current], al
-
 
147
	jz	.draw
-
 
148
	jmp	.skip				; skip button if it isn't (un)focused
162
	je	.draw
-
 
163
	cmp	al, [symbol_unfocused]		; previously focused, should redraw to clear focus
Line 149... Line 164...
149
 
164
	je	.draw
150
  .draw:
-
 
151
	call	draw_button
165
	jmp	.skip				; skip button if it isn't (un)focused
152
  .skip:
166
 
153
	mov	al, [symbol_start]
167
  .draw:
154
	add	al, 127				; end of current page
168
	call	draw_button
155
	cmp	[symbol_current], al		; the last on page?
169
  .skip:
156
	jb	@f
170
	mov	bl, [symbol_start]
157
	mov	[button_x], 2
171
	add	bl, 127				; end of current page
158
	mov	[button_y], 2
172
	cmp	[symbol_current], bl		; the last on page?
159
	ret
173
	jne	@f
160
    @@:	inc	[symbol_current]
174
	mov	[button_x], TABLE_BEGIN_X
161
	add	[button_x], BUTTON_SPACE
175
	mov	[button_y], TABLE_BEGIN_Y
162
	cmp	[button_x], 306			; the last in row?
-
 
163
	jae	@f
176
	ret
164
	jmp	.next_button
-
 
165
    @@:	add	[button_y], BUTTON_SPACE	; next row
-
 
166
	mov	[button_x], 2
-
 
167
	jmp	.next_button
-
 
168
 
-
 
169
 
-
 
170
	ret
-
 
171
 
-
 
172
 
-
 
173
draw_button:
-
 
174
	mov	eax, 8
-
 
175
	mov	ebx, [button_cur_x]
-
 
176
	shl	ebx, 16
-
 
177
	add	ebx, BUTTON_SIDE
-
 
178
	mov	ecx, [button_cur_y]
177
    @@:	inc	[symbol_current]
179
	shl	ecx, 16
-
 
180
	add	ecx, BUTTON_SIDE
-
 
181
	mov	edx, 0x80000000
-
 
182
	add	dl, [button_cur_id]
-
 
183
	add	edx, 2
-
 
184
	mov	eax, 8
-
 
185
	int	0x40
-
 
186
 
-
 
187
	or	edx, 0x20000000
-
 
188
	add	edx, 0x80000000
-
 
189
	mov	esi, 0x00F0F0F0			; button color
-
 
190
	int	0x40
-
 
191
 
-
 
192
	cmp	byte[is_active], 1
-
 
193
	jz	@f
-
 
194
  .symbol:
-
 
195
	mov	eax, 4
-
 
196
	mov	ebx, [button_cur_x]
-
 
197
	add	ebx, 6
-
 
198
	shl	ebx, 16
-
 
199
	add	ebx, [button_cur_y]
-
 
200
	add	ebx, 5
-
 
201
	xor	ecx, ecx
-
 
Line 202... Line 178...
202
	mov	edx, symbol_current
178
	add	[button_x], BUTTON_SPACE
203
	mov	esi, 1
-
 
204
	int	0x40	
-
 
205
	ret
179
	cmp	[button_x], 306			; the last in row?
206
    @@:						; draw a blue square (selection), 8 lines
-
 
207
	mov	eax, 38
180
	jne	.next_button
208
	mov	ebx, [button_cur_x]
181
	add	[button_y], BUTTON_SPACE	; next row
209
	shl	ebx, 16
-
 
210
	add	ebx, [button_cur_x]
-
 
211
	add	ebx, BUTTON_SIDE-1
182
	mov	[button_x], TABLE_BEGIN_X
212
	mov	ecx, [button_cur_y]
-
 
213
	shl	ecx, 16
-
 
Line 214... Line -...
214
	add	ecx, [button_cur_y]
-
 
215
	mov	edx, 0x000080FF			; square color
183
	jmp	.next_button
216
	int	0x40
184
	ret
217
 
-
 
218
	mov	ebx, [button_cur_x]
185
endp
219
	shl	ebx, 16
186
 
220
	add	ebx, [button_cur_x]
187
 
221
	mov	ecx, [button_cur_y]
188
proc	draw_button
-
 
189
	mov	ebx, [button_x]
-
 
190
	shl	ebx, 16
222
	shl	ecx, 16
191
	mov	bx, BUTTON_SIDE
-
 
192
	mov	ecx, [button_y]
-
 
193
	shl	ecx, 16
223
	add	ecx, [button_cur_y]
194
	mov	cx, BUTTON_SIDE
224
	add	ecx, BUTTON_SIDE-1
195
	mov	edx, 0x80000000
225
	int	0x40
196
	mov	dl, [symbol_current]
Line 226... Line 197...
226
 
197
	add	edx, BUTTON_ID_SHIFT
227
	mov	ebx, [button_cur_x]
-
 
228
	inc	ebx
198
	mcall	8, , ,
229
	shl	ebx, 16
-
 
230
	add	ebx, [button_cur_x]
-
 
231
	inc	ebx
199
	and	edx, 0x7FFFFFFF
232
	add	ebx, BUTTON_SIDE-1
200
	or	edx, 0x20000000
233
	mov	ecx, [button_cur_y]
201
	mcall	, , , , [sys_colors.work_button]
-
 
202
 
-
 
203
	test	edi, edi			; is focused?
-
 
204
	jz	.symbol				; draw only character, not selection square
234
	inc	ecx
205
  .focus_frame:					; draw a blue square (selection), 8 segments
-
 
206
	mov	esi, [button_x]
-
 
207
	mov	edi, [button_y]
-
 
208
 
235
	shl	ecx, 16
209
	mov	bx, si
236
	add	ecx, [button_cur_y]
210
	shl	ebx, 16
Line 237... Line -...
237
	inc	ecx
-
 
238
	int	0x40
211
	mov	bx, si
239
 
-
 
240
	mov	ebx, [button_cur_x]
-
 
241
	inc	ebx
-
 
242
	shl	ebx, 16
-
 
243
	add	ebx, [button_cur_x]
-
 
244
	inc	ebx
-
 
245
	mov	ecx, [button_cur_y]
-
 
246
	inc	ecx
-
 
247
	shl	ecx, 16
-
 
248
	add	ecx, [button_cur_y]
-
 
249
	inc	ecx
212
	add	bx, BUTTON_SIDE
250
	add	ecx, BUTTON_SIDE-2
-
 
251
	int	0x40
213
	mov	cx, di
252
 
-
 
253
	mov	ebx, [button_cur_x]
-
 
254
	add	ebx, BUTTON_SIDE-1
-
 
255
	shl	ebx, 16
-
 
256
	add	ebx, [button_cur_x]
-
 
257
	add	ebx, BUTTON_SIDE-1
-
 
258
	mov	ecx, [button_cur_y]
-
 
259
	inc	ecx
-
 
260
	shl	ecx, 16
-
 
261
	add	ecx, [button_cur_y]
214
	shl	ecx, 16
262
	add	ecx, BUTTON_SIDE-1
215
	mov	cx, di
263
	int	0x40
-
 
264
 
-
 
265
	mov	ebx, [button_cur_x]
-
 
266
	inc	ebx
216
	mcall	38, , , FOCUS_SQUARE_COLOR
267
	shl	ebx, 16
217
	add	ecx, 0x00010001
268
	add	ebx, [button_cur_x]
-
 
269
	add	ebx, BUTTON_SIDE-2
-
 
Line -... Line 218...
-
 
218
	mcall
270
	mov	ecx, [button_cur_y]
219
	add	ecx, (BUTTON_SIDE-2)*0x10000+(BUTTON_SIDE-2)
Line 271... Line 220...
271
	add	ecx, BUTTON_SIDE-1
220
	mcall
Line 272... Line -...
272
	shl	ecx, 16
-
 
273
	add	ecx, [button_cur_y]
221
	add	ecx, 0x00010001
274
	add	ecx, BUTTON_SIDE-1
-
 
Line 275... Line 222...
275
	int	0x40
222
	mcall
276
 
223
 
277
	mov	ebx, [button_cur_x]
224
	mov	bx, si
278
	add	ebx, BUTTON_SIDE
225
	shl	ebx, 16
279
	shl	ebx, 16
-
 
280
	add	ebx, [button_cur_x]
-
 
281
	add	ebx, BUTTON_SIDE
-
 
282
	mov	ecx, [button_cur_y]
226
	mov	bx, si
283
	shl	ecx, 16
-
 
Line 284... Line -...
284
	add	ecx, [button_cur_y]
-
 
285
	add	ecx, BUTTON_SIDE-1
-
 
286
	int	0x40
-
 
287
 
-
 
288
	mov	ebx, [button_cur_x]
227
	mov	cx, di
-
 
228
	shl	ecx, 16
289
	shl	ebx, 16
229
	mov	cx, di
-
 
230
	add	ecx, 2*0x10000+(BUTTON_SIDE-2)
290
	add	ebx, [button_cur_x]
231
	mcall	38, , ,
-
 
232
	add	ebx, 0x00010001
-
 
233
	mcall
291
	add	ebx, BUTTON_SIDE
234
	add	ebx, (BUTTON_SIDE-2)*0x10000+(BUTTON_SIDE-2)
-
 
235
	mcall
Line 292... Line -...
292
	mov	ecx, [button_cur_y]
-
 
293
	add	ecx, BUTTON_SIDE
-
 
294
	shl	ecx, 16
-
 
295
	add	ecx, [button_cur_y]
-
 
296
	add	ecx, BUTTON_SIDE
-
 
297
	int	0x40
-
 
298
 
-
 
299
	jmp	.symbol
-
 
300
 
-
 
Line 301... Line 236...
301
 
236
	add	ebx, 0x00010001
302
draw_page_switcher:
-
 
303
 
-
 
304
	mov	eax, 8
-
 
305
	mov	edx, 0x8000FFAA
-
 
Line 306... Line -...
306
	int	0x40
-
 
307
 
-
 
308
	mov	esi, 0x00F0F0F0
237
	mcall
309
	cmp	[redraw_flag], 1
238
 
310
	jnz	@f
-
 
311
	mov	esi, 0x00808080
-
 
312
    @@:	mov	eax, 8
239
  .symbol:
313
	mov	ebx, 2*0x10000+60
-
 
314
	mov	ecx, 157*0x10000+19
240
	mov	ebx, [button_x]
315
	mov	edx, 0x2000FFAA
-
 
316
	int	0x40
-
 
317
 
-
 
318
	cmp	[symbol_start], 0
-
 
319
	jnz	@f
-
 
320
	mov	eax, 4
241
	add	ebx, 6
321
	mov	ebx, 11*0x10000+164
242
	shl	ebx, 16
322
	mov	ecx, 0x80000000
243
	add	ebx, [button_y]
323
	mov	edx, string_000_127
-
 
324
	int	0x40
-
 
325
	ret
244
	add	ebx, 5
326
 
245
	mcall	4, , [sys_colors.work_button_text], symbol_current, 1
327
    @@:	mov	eax, 4
-
 
Line 328... Line 246...
328
	mov	ebx, 11*0x10000+164
246
 
-
 
247
	ret
Line 329... Line 248...
329
	mov	ecx, 0x80000000
248
endp
330
	mov	edx, string_128_255
249
 
331
	int	0x40
-
 
Line 332... Line -...
332
	ret
-
 
Line -... Line 250...
-
 
250
 
333
 
251
proc	draw_page_switcher _blinking
334
 
252
 
335
draw_codes:
253
	mcall	8, , , 0x8000FFAA
336
 
254
 
337
	mov	eax, 13
-
 
338
	mov	ebx, 80*0x10000+220
-
 
Line 339... Line 255...
339
	mov	ecx, 164*0x10000+9
255
	mov	esi, [sys_colors.work_button]
340
	mov	edx, 0x00F0F0F0
256
	cmp	[_blinking], 1			; blinking?
Line 341... Line 257...
341
	int	0x40
257
	jne	@f
342
 
258
	mov	esi, PAGE_SWITCHER_BLINK_COLOR
343
	mov	eax, 4
-
 
344
	mov	ebx, 80*0x10000+164
-
 
345
	mov	ecx, 0x80000000
-
 
346
	mov	edx, string_ASCII_CODE
-
 
347
	int	0x40
-
 
348
 
-
 
349
	mov	ebx, 180*0x10000+164
-
 
Line 350... Line 259...
350
	mov	ecx, 0x80000000
259
    @@:	mcall	, <2,60>, <157,19>, 0x2000FFAA
351
	mov	edx, string_ASCII_HEX_CODE
260
 
352
	int	0x40
-
 
353
 
-
 
354
	mov	eax, 47
-
 
355
	mov	ebx, 0x00030000			; 3 digits, dec
261
	mov	ecx, 0x80000000
356
	xor	ecx, ecx
-
 
-
 
262
	or	ecx, [sys_colors.work_button_text]
-
 
263
	mov	edx, string_000_127
357
	add	cl, [symbol_focused]
264
	cmp	[symbol_start], 0		; first page?
358
	mov	edx, 152*0x10000+164
265
	je	@f