Subversion Repositories Kolibri OS

Rev

Rev 4816 | Rev 7957 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4817 yogev_ezra 1
use32
2
    org 0x0
3
    db  'MENUET01'
4
    dd  0x01,start,i_end,e_end,e_end,0,0
5
 
6
include '../../../proc32.inc'
7
include '../../../macros.inc'
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
12
TABLE_BEGIN_X			equ	2
13
TABLE_BEGIN_Y			equ	2
14
 
15
FOCUS_SQUARE_COLOR		equ	0x000080FF
16
PAGE_SWITCHER_BLINK_COLOR	equ	0x00808080
17
 
18
 
19
start:
20
still:
21
	mcall	10
22
	dec	eax
23
	jz	redraw
24
	dec	eax
25
	jz	key
26
 
27
button:
28
	mcall	17
29
	shr	eax, 8
30
 
31
	cmp	eax, 1
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:
44
	movzx	bx, [symbol_start]
45
	add	bx, BUTTON_ID_SHIFT
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
 
54
    @@:	add	[symbol_start], 128		; change page
55
	add	[symbol_focused], 128
56
	stdcall	draw_table, 1			; 1 means redraw the whole table
57
	call	draw_codes
58
	stdcall	draw_page_switcher, 1		; 1 means dark color, for blinking
59
	mcall	5, 10
60
	stdcall	draw_page_switcher, 0		; 0 means usual light color
61
	jmp	still
62
 
63
redraw:
64
	mcall	9, proc_info, -1
65
	mcall	48, 3, sys_colors, 40
66
 
67
	mcall	12, 1
68
 
69
	mcall	48, 4				; get skin height
70
	mov	ecx, 300*0x10000+184
71
	add	ecx, eax
72
	mov	edx, 0x34000000
73
	or	edx, [sys_colors.work]
74
	mov	esi, 0x80000000
75
	or	esi, [sys_colors.grab_text]
76
	mcall	0, <300,315>, , , , window_title
77
	test	[proc_info.wnd_state], 0x04
78
	jnz	@f
79
 
80
	stdcall	draw_table, 1
81
	call	draw_codes
82
	stdcall	draw_page_switcher, 0
83
 
84
    @@:
85
	mcall	12, 2
86
	jmp	still
87
 
88
key:
89
	mcall	2
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]
96
	mov	[symbol_unfocused], bl
97
	dec	bl
98
	and	bl, 0x0f
99
	and	[symbol_focused], 0xf0
100
	or	[symbol_focused], bl
101
	stdcall	draw_table, 0
102
	call	draw_codes
103
	jmp	still
104
 
105
    @@:	cmp	ah, 0xB1			; down
106
	jne	@f
107
	mov	bl, [symbol_focused]
108
	mov	[symbol_unfocused], bl
109
	add	bl, 16
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
121
	sub	bl, 16
122
	and	bl, 0x70
123
	and	[symbol_focused], 0x8f
124
	or	[symbol_focused], bl
125
	stdcall	draw_table, 0
126
	call	draw_codes
127
	jmp	still
128
 
129
    @@:	cmp	ah, 0xB3			; righ
130
	jne	@f
131
	mov	bl, [symbol_focused]
132
	mov	[symbol_unfocused], bl
133
	inc	bl
134
	and	bl, 0x0f
135
	and	[symbol_focused], 0xf0
136
	or	[symbol_focused], bl
137
	stdcall	draw_table, 0
138
	call	draw_codes
139
	jmp	still
140
	jne	@f
141
 
142
    @@:
143
	jmp	still
144
 
145
 
146
 
147
proc	draw_table _full_redraw
148
 
149
	mov	al, [symbol_start]
150
	mov	[symbol_current], al
151
 
152
  .next_button:
153
 
154
	xor	edi, edi			; character focus flag
155
	mov	al, [symbol_current]
156
	cmp	al, [symbol_focused]
157
	jne	@f
158
	inc	edi
159
    @@:	cmp	[_full_redraw], 1
160
	je	.draw
161
	cmp	al, [symbol_focused]
162
	je	.draw
163
	cmp	al, [symbol_unfocused]		; previously focused, should redraw to clear focus
164
	je	.draw
165
	jmp	.skip				; skip button if it isn't (un)focused
166
 
167
  .draw:
168
	call	draw_button
169
  .skip:
170
	mov	bl, [symbol_start]
171
	add	bl, 127				; end of current page
172
	cmp	[symbol_current], bl		; the last on page?
173
	jne	@f
174
	mov	[button_x], TABLE_BEGIN_X
175
	mov	[button_y], TABLE_BEGIN_Y
176
	ret
177
    @@:	inc	[symbol_current]
178
	add	[button_x], BUTTON_SPACE
179
	cmp	[button_x], 306			; the last in row?
180
	jne	.next_button
181
	add	[button_y], BUTTON_SPACE	; next row
182
	mov	[button_x], TABLE_BEGIN_X
183
	jmp	.next_button
184
	ret
185
endp
186
 
187
 
188
proc	draw_button
189
	mov	ebx, [button_x]
190
	shl	ebx, 16
191
	mov	bx, BUTTON_SIDE
192
	mov	ecx, [button_y]
193
	shl	ecx, 16
194
	mov	cx, BUTTON_SIDE
195
	mov	edx, 0x80000000
196
	mov	dl, [symbol_current]
197
	add	edx, BUTTON_ID_SHIFT
198
	mcall	8, , ,
199
	and	edx, 0x7FFFFFFF
200
	or	edx, 0x20000000
201
	mcall	, , , , [sys_colors.work_button]
202
 
203
	test	edi, edi			; is focused?
204
	jz	.symbol				; draw only character, not selection square
205
  .focus_frame:					; draw a blue square (selection), 8 segments
206
	mov	esi, [button_x]
207
	mov	edi, [button_y]
208
 
209
	mov	bx, si
210
	shl	ebx, 16
211
	mov	bx, si
212
	add	bx, BUTTON_SIDE
213
	mov	cx, di
214
	shl	ecx, 16
215
	mov	cx, di
216
	mcall	38, , , FOCUS_SQUARE_COLOR
217
	add	ecx, 0x00010001
218
	mcall
219
	add	ecx, (BUTTON_SIDE-2)*0x10000+(BUTTON_SIDE-2)
220
	mcall
221
	add	ecx, 0x00010001
222
	mcall
223
 
224
	mov	bx, si
225
	shl	ebx, 16
226
	mov	bx, si
227
	mov	cx, di
228
	shl	ecx, 16
229
	mov	cx, di
230
	add	ecx, 2*0x10000+(BUTTON_SIDE-2)
231
	mcall	38, , ,
232
	add	ebx, 0x00010001
233
	mcall
234
	add	ebx, (BUTTON_SIDE-2)*0x10000+(BUTTON_SIDE-2)
235
	mcall
236
	add	ebx, 0x00010001
237
	mcall
238
 
239
  .symbol:
240
	mov	ebx, [button_x]
241
	add	ebx, 6
242
	shl	ebx, 16
243
	add	ebx, [button_y]
244
	add	ebx, 5
245
	mcall	4, , [sys_colors.work_button_text], symbol_current, 1
246
 
247
	ret
248
endp
249
 
250
 
251
proc	draw_page_switcher _blinking
252
 
253
	mcall	8, , , 0x8000FFAA
254
 
255
	mov	esi, [sys_colors.work_button]
256
	cmp	[_blinking], 1			; blinking?
257
	jne	@f
258
	mov	esi, PAGE_SWITCHER_BLINK_COLOR
259
    @@:	mcall	, <2,60>, <157,19>, 0x2000FFAA
260
 
261
	mov	ecx, 0x80000000
262
	or	ecx, [sys_colors.work_button_text]
263
	mov	edx, string_000_127
264
	cmp	[symbol_start], 0		; first page?
265
	je	@f
266
	mov	edx, string_128_255		; ok, the second one
267
    @@:	mcall	4, <11,164>,
268
	ret
269
endp
270
 
271
 
272
proc	draw_codes
273
 
274
	mov	ecx, 0x80000000
275
	or	ecx, [sys_colors.work_text]
276
	mcall	4, <80,164>, , string_ASCII_CODE
277
	mcall	, <180,164>, , string_ASCII_HEX_CODE
278
	movzx	ecx, [symbol_focused]
279
	mov	esi, 0x40000000
280
	or	esi, [sys_colors.work_text]
281
	mcall	47, 0x00030000, , <152,164>, , [sys_colors.work]
282
	mcall	, 0x00020100, , <276,164>,
283
 
284
	ret
285
endp
286
 
287
 
288
quit:
289
	mcall	-1
290
 
291
 
292
szZ window_title		,'ASCIIVju v0.4'
293
szZ string_000_127		,'000-127'
294
szZ string_128_255		,'128-255'
295
szZ string_ASCII_CODE		,'ASCII Code:    '
296
szZ string_ASCII_HEX_CODE	,'ASCII Hex-Code:   '
297
 
298
button_x		dd 2
299
button_y		dd 2
300
 
301
symbol_current		db 0
302
symbol_start		db 0
303
 
304
symbol_unfocused	db 0
305
symbol_focused		db 0
306
i_end:
307
proc_info		process_information
308
sys_colors		system_colors
309
rb 0x400					;stack
310
e_end: