Rev 814 | Rev 9014 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
183 | diamond | 1 | ; int __stdcall GenericBox(DLGTEMPLATE* dlg, void* DlgProc); |
2 | ; int __stdcall DlgProc(DLGTEMPLATE* dlg, int msg, int param1, int param2); |
||
180 | heavyiron | 3 | |
4 | virtual at 0 |
||
5 | dlgtemplate: |
||
314 | diamond | 6 | ; Флаги: |
7 | ; бит 0: использовать стандартные цвета диалога |
||
8 | ; бит 1: использовать стандартные цвета предупреждения/ошибки |
||
9 | ; (если любой из этих битов установлен, поля main_color,border_color,header_color |
||
10 | ; игнорируются) |
||
814 | diamond | 11 | ; бит 2: не рисовать тень |
180 | heavyiron | 12 | .flags dd ? |
13 | .x dd ? |
||
14 | .y dd ? |
||
15 | .width dd ? |
||
16 | .height dd ? |
||
17 | .border_size_x dd ? |
||
18 | .border_size_y dd ? |
||
19 | .title dd ? |
||
20 | .main_color db ? |
||
21 | .border_color db ? |
||
22 | .header_color db ? |
||
23 | db ? ; align |
||
814 | diamond | 24 | .dataptr dd ? ; used internally, ignored on input |
183 | diamond | 25 | .size = $ |
180 | heavyiron | 26 | end virtual |
27 | |||
183 | diamond | 28 | GenericBox: |
814 | diamond | 29 | push [cursor_x] |
30 | push [cursor_y] |
||
31 | push dword [esp+8+8] |
||
32 | push dword [esp+8+8] |
||
33 | call ShowGenericBox |
||
34 | test eax, eax |
||
35 | jz @f |
||
36 | pop [cursor_y] |
||
37 | pop [cursor_x] |
||
38 | ret |
||
39 | @@: |
||
180 | heavyiron | 40 | pushad |
814 | diamond | 41 | ; message loop |
42 | .event: |
||
997 | diamond | 43 | ; call get_event |
814 | diamond | 44 | push 10 |
45 | pop eax |
||
46 | int 40h |
||
47 | dec eax |
||
48 | jz .redraw |
||
49 | dec eax |
||
50 | jz .key |
||
51 | jmp exit |
||
52 | .redraw: |
||
53 | call draw_window |
||
54 | jmp .event |
||
55 | .key: |
||
56 | mov al, 2 |
||
57 | int 40h |
||
58 | shr eax, 8 |
||
59 | cmp al, 0xE0 |
||
60 | jnz @f |
||
61 | mov [bWasE0], 1 |
||
62 | jmp .event |
||
63 | @@: |
||
64 | xchg ah, [bWasE0] |
||
65 | cmp al, 0x1D |
||
66 | jz .ctrl_down |
||
67 | cmp al, 0x9D |
||
68 | jz .ctrl_up |
||
69 | cmp al, 0x2A |
||
70 | jz .lshift_down |
||
71 | cmp al, 0xAA |
||
72 | jz .lshift_up |
||
73 | cmp al, 0x36 |
||
74 | jz .rshift_down |
||
75 | cmp al, 0xB6 |
||
76 | jz .rshift_up |
||
77 | cmp al, 0x38 |
||
78 | jz .alt_down |
||
79 | cmp al, 0xB8 |
||
80 | jz .alt_up |
||
81 | mov ebx, [esp+24h+8] |
||
82 | mov ecx, [esp+28h+8] |
||
83 | push 0 |
||
84 | push eax |
||
85 | push 2 |
||
86 | push ebx |
||
87 | call ecx |
||
88 | test eax, eax |
||
89 | jz .event |
||
90 | mov [esp+28], eax |
||
91 | jmp .exit |
||
92 | .ctrl_down: |
||
93 | test ah, ah |
||
94 | jnz .rctrl_down |
||
95 | or [ctrlstate], 4 |
||
96 | jmp .event |
||
97 | .rctrl_down: |
||
98 | or [ctrlstate], 8 |
||
99 | jmp .event |
||
100 | .ctrl_up: |
||
101 | test ah, ah |
||
102 | jnz .rctrl_up |
||
103 | and [ctrlstate], not 4 |
||
104 | jmp .event |
||
105 | .rctrl_up: |
||
106 | and [ctrlstate], not 8 |
||
107 | jmp .event |
||
108 | .lshift_down: |
||
109 | test ah, ah |
||
110 | jnz @f |
||
111 | or [ctrlstate], 1 |
||
112 | @@: jmp .event |
||
113 | .lshift_up: |
||
114 | test ah, ah |
||
115 | jnz @b |
||
116 | and [ctrlstate], not 1 |
||
117 | jmp @b |
||
118 | .rshift_down: |
||
119 | or [ctrlstate], 2 |
||
120 | jmp .event |
||
121 | .rshift_up: |
||
122 | and [ctrlstate], not 2 |
||
123 | jmp .event |
||
124 | .alt_down: |
||
125 | test ah, ah |
||
126 | jnz .ralt_down |
||
127 | or [ctrlstate], 0x10 |
||
128 | jmp .event |
||
129 | .ralt_down: |
||
130 | or [ctrlstate], 0x20 |
||
131 | jmp .event |
||
132 | .alt_up: |
||
133 | test ah, ah |
||
134 | jnz .ralt_up |
||
135 | and [ctrlstate], not 0x10 |
||
136 | jmp .event |
||
137 | .ralt_up: |
||
138 | and [ctrlstate], not 0x20 |
||
139 | jmp .event |
||
140 | .exit: |
||
141 | popad |
||
142 | push eax |
||
143 | push 0 |
||
144 | push dword [esp+12+8] |
||
145 | call HideGenericBox |
||
146 | pop eax |
||
147 | pop [cursor_y] |
||
148 | pop [cursor_x] |
||
149 | pushad |
||
150 | call draw_image |
||
151 | popad |
||
152 | ret 8 |
||
153 | |||
154 | ; int __stdcall ShowGenericBox(DLGTEMPLATE* dlg, void* DlgProc); |
||
155 | ShowGenericBox: |
||
156 | pushad |
||
183 | diamond | 157 | mov ebx, [esp+20h+4] |
158 | ; center window if required |
||
474 | diamond | 159 | push [ebx+dlgtemplate.x] |
160 | push [ebx+dlgtemplate.y] |
||
183 | diamond | 161 | cmp [ebx+dlgtemplate.x], -1 |
162 | jnz @f |
||
163 | mov eax, [cur_width] |
||
164 | sub eax, [ebx+dlgtemplate.width] |
||
165 | shr eax, 1 |
||
166 | mov [ebx+dlgtemplate.x], eax |
||
167 | @@: |
||
168 | cmp [ebx+dlgtemplate.y], -1 |
||
169 | jnz @f |
||
170 | mov eax, [cur_height] |
||
171 | sub eax, [ebx+dlgtemplate.height] |
||
172 | shr eax, 1 |
||
173 | mov [ebx+dlgtemplate.y], eax |
||
174 | @@: |
||
180 | heavyiron | 175 | ; some checks |
176 | mov eax, [ebx+dlgtemplate.x] |
||
177 | cmp eax, 1 |
||
178 | jl .sizeerr |
||
179 | add eax, [ebx+dlgtemplate.width] |
||
180 | cmp eax, [cur_width] |
||
181 | jge .sizeerr |
||
182 | mov eax, [ebx+dlgtemplate.y] |
||
183 | cmp eax, 1 |
||
184 | jl .sizeerr |
||
185 | add eax, [ebx+dlgtemplate.height] |
||
186 | cmp eax, [cur_height] |
||
187 | jge .sizeerr |
||
188 | cmp [ebx+dlgtemplate.border_size_x], 1 |
||
189 | jl .sizeerr |
||
190 | cmp [ebx+dlgtemplate.border_size_y], 1 |
||
191 | jge .sizeok |
||
192 | .sizeerr: |
||
474 | diamond | 193 | pop [ebx+dlgtemplate.y] |
194 | pop [ebx+dlgtemplate.x] |
||
180 | heavyiron | 195 | popad |
196 | or eax, -1 |
||
197 | ret 8 |
||
198 | .sizeok: |
||
314 | diamond | 199 | ; set color if required |
200 | test byte [ebx+dlgtemplate.flags], 1 |
||
201 | jz @f |
||
202 | mov edi, dialog_colors |
||
203 | jmp .setcolor |
||
204 | @@: |
||
205 | test byte [ebx+dlgtemplate.flags], 2 |
||
206 | jz @f |
||
207 | mov edi, warning_colors |
||
208 | .setcolor: |
||
474 | diamond | 209 | mov al, [edi + dialog_main_color-dialog_colors] |
314 | diamond | 210 | mov [ebx+dlgtemplate.main_color], al |
474 | diamond | 211 | mov al, [edi + dialog_border_color-dialog_colors] |
314 | diamond | 212 | mov [ebx+dlgtemplate.border_color], al |
474 | diamond | 213 | mov al, [edi + dialog_header_color-dialog_colors] |
314 | diamond | 214 | mov [ebx+dlgtemplate.header_color], al |
215 | @@: |
||
180 | heavyiron | 216 | ; allocate memory for data under dialog |
314 | diamond | 217 | ; for 'No memory' dialog use static data area |
814 | diamond | 218 | mov eax, nomem_dlgsavearea |
314 | diamond | 219 | cmp ebx, nomem_dlgdata |
220 | jz .allocated |
||
180 | heavyiron | 221 | mov eax, [ebx+dlgtemplate.width] |
222 | add eax, [ebx+dlgtemplate.border_size_x] |
||
223 | add eax, [ebx+dlgtemplate.border_size_x] |
||
224 | inc eax |
||
225 | inc eax |
||
226 | mov edx, [ebx+dlgtemplate.height] |
||
227 | add edx, [ebx+dlgtemplate.border_size_y] |
||
228 | add edx, [ebx+dlgtemplate.border_size_y] |
||
229 | inc edx |
||
230 | mul edx |
||
814 | diamond | 231 | lea ecx, [eax*2+8] |
474 | diamond | 232 | call xpgalloc |
180 | heavyiron | 233 | test eax, eax |
234 | jnz @f |
||
474 | diamond | 235 | pop [ebx+dlgtemplate.y] |
236 | pop [ebx+dlgtemplate.x] |
||
180 | heavyiron | 237 | popad |
238 | or eax, -1 |
||
239 | ret 8 |
||
240 | @@: |
||
314 | diamond | 241 | .allocated: |
814 | diamond | 242 | mov [ebx+dlgtemplate.dataptr], eax |
243 | pop dword [eax+4] |
||
244 | pop dword [eax] |
||
245 | lea ebp, [eax+8] |
||
180 | heavyiron | 246 | ; save data |
247 | mov eax, [ebx+dlgtemplate.y] |
||
248 | add eax, [ebx+dlgtemplate.height] |
||
249 | add eax, [ebx+dlgtemplate.border_size_y] |
||
250 | inc eax |
||
251 | push eax |
||
252 | mov eax, [ebx+dlgtemplate.x] |
||
253 | add eax, [ebx+dlgtemplate.width] |
||
254 | add eax, [ebx+dlgtemplate.border_size_x] |
||
255 | inc eax |
||
256 | inc eax |
||
257 | push eax |
||
258 | mov eax, [ebx+dlgtemplate.y] |
||
259 | sub eax, [ebx+dlgtemplate.border_size_y] |
||
260 | push eax |
||
261 | mov eax, [ebx+dlgtemplate.x] |
||
262 | sub eax, [ebx+dlgtemplate.border_size_x] |
||
263 | push eax |
||
264 | call save_console_data |
||
265 | ; draw shadow |
||
814 | diamond | 266 | test byte [ebx+dlgtemplate.flags], 4 |
267 | jnz .noshadow |
||
997 | diamond | 268 | call draw_dialog_shadow |
269 | .noshadow: |
||
270 | popad |
||
271 | push dword [esp+8] |
||
272 | push dword [esp+8] |
||
273 | call DrawGenericBox |
||
274 | xor eax, eax |
||
275 | ret 8 |
||
276 | |||
277 | draw_dialog_shadow: |
||
180 | heavyiron | 278 | mov eax, [ebx+dlgtemplate.x] |
279 | sub eax, [ebx+dlgtemplate.border_size_x] |
||
280 | ja @f |
||
281 | xor eax, eax |
||
282 | @@: |
||
283 | inc eax |
||
284 | inc eax |
||
285 | mov edx, [ebx+dlgtemplate.y] |
||
286 | sub edx, [ebx+dlgtemplate.border_size_y] |
||
287 | ja @f |
||
288 | xor edx, edx |
||
289 | @@: |
||
290 | inc edx |
||
291 | call get_console_ptr |
||
292 | mov ecx, [ebx+dlgtemplate.y] |
||
293 | add ecx, [ebx+dlgtemplate.height] |
||
294 | add ecx, [ebx+dlgtemplate.border_size_y] |
||
295 | inc ecx |
||
296 | cmp ecx, [cur_height] |
||
297 | jb @f |
||
298 | mov ecx, [cur_height] |
||
299 | @@: |
||
300 | sub ecx, edx |
||
301 | mov edx, ecx |
||
302 | mov ecx, [ebx+dlgtemplate.x] |
||
303 | add ecx, [ebx+dlgtemplate.width] |
||
304 | add ecx, [ebx+dlgtemplate.border_size_x] |
||
305 | inc ecx |
||
306 | inc ecx |
||
307 | cmp ecx, [cur_width] |
||
308 | jb @f |
||
309 | mov ecx, [cur_width] |
||
310 | @@: |
||
311 | sub ecx, eax |
||
312 | mov eax, ecx |
||
313 | .shadow_loop: |
||
314 | mov ecx, eax |
||
315 | push edi |
||
316 | .sl1: |
||
317 | inc edi |
||
318 | test byte [edi], 0x0F |
||
319 | jnz @f |
||
320 | or byte [edi], 8 |
||
321 | @@: |
||
322 | and byte [edi], 0x0F |
||
323 | inc edi |
||
324 | loop .sl1 |
||
325 | pop edi |
||
326 | add edi, [cur_width] |
||
327 | add edi, [cur_width] |
||
328 | dec edx |
||
329 | jnz .shadow_loop |
||
997 | diamond | 330 | ret |
814 | diamond | 331 | |
332 | ; void __stdcall DrawGenericBox(DLGDATA* dlg, void* DlgProc) |
||
333 | DrawGenericBox: |
||
334 | pushad |
||
335 | mov ebx, [esp+24h] |
||
180 | heavyiron | 336 | ; draw area background |
814 | diamond | 337 | mov eax, [ebx+dlgtemplate.x] |
338 | sub eax, [ebx+dlgtemplate.border_size_x] |
||
339 | ja @f |
||
340 | xor eax, eax |
||
341 | @@: |
||
342 | mov edx, [ebx+dlgtemplate.y] |
||
343 | sub edx, [ebx+dlgtemplate.border_size_y] |
||
344 | ja @f |
||
345 | xor edx, edx |
||
346 | @@: |
||
180 | heavyiron | 347 | call get_console_ptr |
348 | mov ecx, [ebx+dlgtemplate.x] |
||
349 | add ecx, [ebx+dlgtemplate.width] |
||
350 | add ecx, [ebx+dlgtemplate.border_size_x] |
||
351 | cmp ecx, [cur_width] |
||
352 | jb @f |
||
353 | mov ecx, [cur_width] |
||
354 | @@: |
||
355 | sub ecx, eax |
||
356 | mov esi, ecx |
||
357 | mov ecx, [ebx+dlgtemplate.y] |
||
358 | add ecx, [ebx+dlgtemplate.height] |
||
359 | add ecx, [ebx+dlgtemplate.border_size_y] |
||
360 | cmp ecx, [cur_height] |
||
361 | jb @f |
||
362 | mov ecx, [cur_height] |
||
363 | @@: |
||
364 | sub ecx, edx |
||
365 | mov edx, ecx |
||
366 | mov al, ' ' |
||
367 | mov ah, [ebx+dlgtemplate.border_color] |
||
368 | .1: |
||
369 | mov ecx, esi |
||
370 | push edi |
||
371 | rep stosw |
||
372 | pop edi |
||
373 | add edi, [cur_width] |
||
374 | add edi, [cur_width] |
||
375 | dec edx |
||
376 | jnz .1 |
||
377 | ; draw border |
||
378 | mov eax, [ebx+dlgtemplate.x] |
||
379 | dec eax |
||
380 | mov edx, [ebx+dlgtemplate.y] |
||
381 | dec edx |
||
382 | call get_console_ptr |
||
383 | mov edx, [ebx+dlgtemplate.height] |
||
384 | inc edx |
||
385 | inc edx |
||
386 | mov ah, [ebx+dlgtemplate.border_color] |
||
387 | push ebx |
||
388 | mov ebx, [ebx+dlgtemplate.width] |
||
389 | inc ebx |
||
390 | inc ebx |
||
391 | call draw_border |
||
392 | pop ebx |
||
393 | ; draw header |
||
394 | mov esi, [ebx+dlgtemplate.title] |
||
395 | test esi, esi |
||
396 | jz .noheader |
||
397 | cmp byte [esi], 0 |
||
398 | jz .noheader |
||
399 | push esi |
||
400 | @@: lodsb |
||
401 | test al, al |
||
402 | jnz @b |
||
403 | mov eax, esi |
||
404 | pop esi |
||
405 | sub eax, esi |
||
283 | diamond | 406 | inc eax ; eax = длина заголовка + 2 |
180 | heavyiron | 407 | mov ecx, [ebx+dlgtemplate.width] |
408 | cmp eax, ecx |
||
409 | jbe .fullhea |
||
410 | sub ecx, 5 |
||
411 | jb .noheader |
||
412 | xor edx, edx |
||
413 | jmp .drawhea |
||
414 | .fullhea: |
||
415 | mov edx, ecx |
||
416 | sub edx, eax |
||
417 | shr edx, 1 |
||
418 | .drawhea: |
||
419 | mov eax, [ebx+dlgtemplate.x] |
||
420 | add eax, edx |
||
421 | mov edx, [ebx+dlgtemplate.y] |
||
422 | dec edx |
||
423 | call get_console_ptr |
||
424 | mov ah, [ebx+dlgtemplate.header_color] |
||
425 | mov al, ' ' |
||
426 | stosw |
||
283 | diamond | 427 | .2: |
180 | heavyiron | 428 | dec ecx |
283 | diamond | 429 | jz .3 |
180 | heavyiron | 430 | lodsb |
431 | test al, al |
||
432 | jz .4 |
||
433 | stosw |
||
434 | jmp .2 |
||
435 | .3: |
||
436 | mov al, '.' |
||
437 | stosw |
||
438 | stosw |
||
439 | stosw |
||
440 | .4: |
||
441 | mov al, ' ' |
||
442 | stosw |
||
443 | .noheader: |
||
444 | ; draw window background |
||
445 | mov eax, [ebx+dlgtemplate.x] |
||
446 | mov edx, [ebx+dlgtemplate.y] |
||
447 | call get_console_ptr |
||
448 | mov ah, [ebx+dlgtemplate.main_color] |
||
449 | mov al, ' ' |
||
450 | mov edx, [ebx+dlgtemplate.height] |
||
451 | @@: |
||
452 | mov ecx, [ebx+dlgtemplate.width] |
||
453 | push edi |
||
454 | rep stosw |
||
455 | pop edi |
||
456 | add edi, [cur_width] |
||
457 | add edi, [cur_width] |
||
458 | dec edx |
||
459 | jnz @b |
||
460 | ; send redraw message |
||
814 | diamond | 461 | mov eax, [esp+28h] |
180 | heavyiron | 462 | push 0 |
463 | push 0 |
||
464 | push 1 |
||
183 | diamond | 465 | push ebx |
180 | heavyiron | 466 | call eax |
467 | call draw_image |
||
814 | diamond | 468 | popad |
469 | ret 8 |
||
470 | |||
471 | ; void __stdcall HideGenericBox(DLGTEMPLATE* dlg, int bRedrawWindow); |
||
472 | HideGenericBox: |
||
473 | ; void __stdcall HideDialogBox(DLGDATA* dlg, int bRedrawWindow); |
||
474 | HideDialogBox: |
||
475 | pushad |
||
476 | mov ebx, [esp+24h] |
||
477 | mov ebp, [ebx+dlgtemplate.dataptr] |
||
478 | add ebp, 8 |
||
180 | heavyiron | 479 | ; restore data |
480 | mov eax, [ebx+dlgtemplate.y] |
||
481 | add eax, [ebx+dlgtemplate.height] |
||
482 | add eax, [ebx+dlgtemplate.border_size_y] |
||
483 | inc eax |
||
484 | push eax |
||
485 | mov eax, [ebx+dlgtemplate.x] |
||
486 | add eax, [ebx+dlgtemplate.width] |
||
487 | add eax, [ebx+dlgtemplate.border_size_x] |
||
488 | inc eax |
||
489 | inc eax |
||
490 | push eax |
||
491 | mov eax, [ebx+dlgtemplate.y] |
||
492 | sub eax, [ebx+dlgtemplate.border_size_y] |
||
493 | push eax |
||
494 | mov eax, [ebx+dlgtemplate.x] |
||
495 | sub eax, [ebx+dlgtemplate.border_size_x] |
||
496 | push eax |
||
497 | call restore_console_data |
||
498 | call draw_keybar |
||
814 | diamond | 499 | lea ecx, [ebp-8] |
500 | push dword [ecx] |
||
501 | push dword [ecx+4] |
||
502 | pop [ebx+dlgtemplate.y] |
||
503 | pop [ebx+dlgtemplate.x] |
||
314 | diamond | 504 | cmp ebx, nomem_dlgdata |
505 | jz @f |
||
474 | diamond | 506 | call pgfree |
314 | diamond | 507 | @@: |
283 | diamond | 508 | or [cursor_x], -1 |
509 | or [cursor_y], -1 |
||
814 | diamond | 510 | cmp dword [esp+28h], 0 |
511 | jz @f |
||
180 | heavyiron | 512 | call draw_image |
814 | diamond | 513 | @@: |
180 | heavyiron | 514 | popad |
515 | ret 8 |
||
516 | |||
517 | save_console_data: |
||
518 | cmp dword [esp+4], 0 |
||
519 | jge @f |
||
520 | and dword [esp+4], 0 |
||
521 | @@: |
||
522 | cmp dword [esp+8], 0 |
||
523 | jge @f |
||
524 | and dword [esp+8], 0 |
||
525 | @@: |
||
526 | mov eax, [esp+12] |
||
527 | cmp eax, [cur_width] |
||
528 | jbe @f |
||
529 | mov eax, [cur_width] |
||
530 | @@: |
||
531 | sub eax, [esp+4] |
||
532 | ja @f |
||
533 | ret 16 |
||
534 | @@: |
||
535 | mov [esp+12], eax |
||
536 | mov eax, [esp+16] |
||
537 | cmp eax, [cur_height] |
||
538 | jbe @f |
||
539 | mov eax, [cur_height] |
||
540 | @@: |
||
541 | sub eax, [esp+8] |
||
542 | ja @f |
||
543 | ret 16 |
||
544 | @@: |
||
545 | mov [esp+16], eax |
||
546 | mov eax, [esp+4] |
||
547 | mov edx, [esp+8] |
||
548 | call get_console_ptr |
||
549 | mov esi, edi |
||
550 | mov edi, ebp |
||
551 | .l: |
||
552 | mov ecx, [esp+12] |
||
553 | push esi |
||
554 | shr ecx, 1 |
||
555 | rep movsd |
||
556 | adc ecx, ecx |
||
557 | rep movsw |
||
558 | pop esi |
||
559 | add esi, [cur_width] |
||
560 | add esi, [cur_width] |
||
561 | dec dword [esp+16] |
||
562 | jnz .l |
||
563 | ret 16 |
||
564 | |||
565 | restore_console_data: |
||
566 | cmp dword [esp+4], 0 |
||
567 | jge @f |
||
568 | and dword [esp+4], 0 |
||
569 | @@: |
||
570 | cmp dword [esp+8], 0 |
||
571 | jge @f |
||
572 | and dword [esp+8], 0 |
||
573 | @@: |
||
574 | mov eax, [esp+12] |
||
575 | cmp eax, [cur_width] |
||
576 | jbe @f |
||
577 | mov eax, [cur_width] |
||
578 | @@: |
||
579 | sub eax, [esp+4] |
||
580 | ja @f |
||
581 | ret 16 |
||
582 | @@: |
||
583 | mov [esp+12], eax |
||
584 | mov eax, [esp+16] |
||
585 | cmp eax, [cur_height] |
||
586 | jbe @f |
||
587 | mov eax, [cur_height] |
||
588 | @@: |
||
589 | sub eax, [esp+8] |
||
590 | ja @f |
||
591 | ret 16 |
||
592 | @@: |
||
593 | mov [esp+16], eax |
||
594 | mov eax, [esp+4] |
||
595 | mov edx, [esp+8] |
||
596 | call get_console_ptr |
||
597 | mov esi, ebp |
||
598 | .l: |
||
599 | mov ecx, [esp+12] |
||
600 | push edi |
||
601 | shr ecx, 1 |
||
602 | rep movsd |
||
603 | adc ecx, ecx |
||
604 | rep movsw |
||
605 | pop edi |
||
606 | add edi, [cur_width] |
||
607 | add edi, [cur_width] |
||
608 | dec dword [esp+16] |
||
609 | jnz .l |
||
610 | ret 16 |
||
611 | |||
612 | ; int __stdcall menu(void* variants, const char* title, unsigned flags); |
||
613 | ; variants указывает на текущий элемент в двусвязном линейном списке |
||
614 | menu: |
||
615 | pop eax |
||
616 | push [cur_height] |
||
617 | push [cur_width] |
||
618 | push 0 |
||
619 | push 0 |
||
620 | push eax |
||
621 | |||
622 | ; int __stdcall menu_centered_in(unsigned left, unsigned top, unsigned width, unsigned height, |
||
623 | ; void* variants, const char* title, unsigned flags); |
||
624 | menu_centered_in: |
||
625 | pushad |
||
814 | diamond | 626 | mov ecx, 60 |
627 | ; 40 bytes for dlgtemplate + additional: |
||
628 | ; +40: dd cur_variant |
||
629 | ; +44: dd num_variants |
||
630 | ; +48: dd begin_variant |
||
631 | ; +52: dd end_variant |
||
632 | ; +56: dd cur_variant_idx |
||
474 | diamond | 633 | call xpgalloc |
180 | heavyiron | 634 | test eax, eax |
635 | jnz @f |
||
636 | .ret_bad: |
||
637 | popad |
||
638 | or eax, -1 |
||
639 | ret 28 |
||
640 | @@: |
||
641 | mov ebx, eax |
||
642 | mov eax, 1 |
||
643 | test byte [esp+20h+28], 1 |
||
644 | jz @f |
||
645 | mov al, 3 |
||
646 | @@: |
||
647 | mov [ebx+dlgtemplate.border_size_x], eax |
||
648 | inc eax |
||
649 | shr eax, 1 |
||
650 | mov [ebx+dlgtemplate.border_size_y], eax |
||
651 | ; Находим ширину и высоту окна |
||
652 | xor eax, eax |
||
653 | xor ecx, ecx |
||
654 | mov esi, [esp+20h+20] |
||
814 | diamond | 655 | mov [ebx+40], esi |
997 | diamond | 656 | mov dword [ebx+56], eax |
180 | heavyiron | 657 | @@: |
997 | diamond | 658 | cmp dword [esi+4], eax |
180 | heavyiron | 659 | jz .find_width |
660 | mov esi, [esi+4] |
||
814 | diamond | 661 | inc dword [ebx+56] |
180 | heavyiron | 662 | jmp @b |
663 | .find_width: |
||
814 | diamond | 664 | mov [ebx+48], esi |
180 | heavyiron | 665 | add esi, 8 |
666 | push esi |
||
667 | xor edx, edx |
||
668 | .fw1: |
||
669 | cmp byte [esi], '&' |
||
670 | jnz @f |
||
671 | mov dl, 1 |
||
672 | @@: |
||
673 | inc esi |
||
674 | cmp byte [esi-1], 0 |
||
675 | jnz .fw1 |
||
676 | sub esi, [esp] |
||
677 | sub esi, edx |
||
678 | dec esi |
||
679 | cmp eax, esi |
||
680 | ja @f |
||
681 | mov eax, esi |
||
682 | @@: |
||
683 | inc ecx |
||
684 | pop esi |
||
685 | mov esi, [esi-8] |
||
686 | test esi, esi |
||
687 | jnz .find_width |
||
688 | add eax, 3 |
||
689 | add eax, [ebx+dlgtemplate.border_size_x] |
||
690 | add eax, [ebx+dlgtemplate.border_size_x] |
||
691 | cmp eax, [cur_width] |
||
692 | jb @f |
||
693 | mov eax, [cur_width] |
||
694 | @@: |
||
695 | sub eax, [ebx+dlgtemplate.border_size_x] |
||
696 | sub eax, [ebx+dlgtemplate.border_size_x] |
||
697 | mov [ebx+dlgtemplate.width], eax |
||
698 | mov [ebx+dlgtemplate.height], ecx |
||
814 | diamond | 699 | mov [ebx+44], ecx |
180 | heavyiron | 700 | sub eax, [esp+20h+12] |
701 | neg eax |
||
702 | sar eax, 1 |
||
703 | add eax, [esp+20h+4] |
||
704 | cmp eax, [ebx+dlgtemplate.border_size_x] |
||
705 | jge @f |
||
706 | mov eax, [ebx+dlgtemplate.border_size_x] |
||
707 | @@: |
||
708 | push eax |
||
709 | add eax, [ebx+dlgtemplate.width] |
||
710 | add eax, [ebx+dlgtemplate.border_size_x] |
||
711 | cmp eax, [cur_width] |
||
712 | jbe @f |
||
713 | pop eax |
||
714 | mov eax, [cur_width] |
||
715 | sub eax, [ebx+dlgtemplate.width] |
||
716 | sub eax, [ebx+dlgtemplate.border_size_x] |
||
717 | push eax |
||
718 | @@: |
||
719 | pop [ebx+dlgtemplate.x] |
||
720 | sub ecx, [esp+20h+16] |
||
721 | neg ecx |
||
722 | sar ecx, 1 |
||
723 | add ecx, [esp+20h+8] |
||
724 | cmp ecx, [ebx+dlgtemplate.border_size_y] |
||
725 | jge @f |
||
726 | mov ecx, [ebx+dlgtemplate.border_size_y] |
||
727 | @@: |
||
728 | push ecx |
||
729 | add ecx, [ebx+dlgtemplate.height] |
||
730 | add ecx, [ebx+dlgtemplate.border_size_y] |
||
731 | cmp ecx, [cur_height] |
||
732 | jbe @f |
||
733 | pop ecx |
||
734 | mov ecx, [cur_height] |
||
735 | sub ecx, [ebx+dlgtemplate.height] |
||
736 | sub ecx, [ebx+dlgtemplate.border_size_y] |
||
737 | push ecx |
||
738 | @@: |
||
739 | pop [ebx+dlgtemplate.y] |
||
740 | mov eax, [cur_height] |
||
741 | sub eax, 6 |
||
742 | cmp [ebx+dlgtemplate.height], eax |
||
743 | jbe .small_height |
||
744 | mov [ebx+dlgtemplate.height], eax |
||
745 | mov [ebx+dlgtemplate.y], 3 |
||
746 | .small_height: |
||
747 | mov ecx, [ebx+dlgtemplate.height] |
||
814 | diamond | 748 | mov eax, [ebx+40] |
749 | mov [ebx+48], eax |
||
180 | heavyiron | 750 | dec ecx |
751 | jz .skip |
||
752 | push ecx |
||
753 | @@: |
||
754 | cmp dword [eax+4], 0 |
||
755 | jz @f |
||
756 | mov eax, [eax+4] |
||
757 | loop @b |
||
758 | @@: |
||
814 | diamond | 759 | mov [ebx+48], eax |
180 | heavyiron | 760 | pop ecx |
761 | .loop: |
||
762 | mov eax, [eax] |
||
763 | loop .loop |
||
764 | .skip: |
||
814 | diamond | 765 | mov [ebx+52], eax |
180 | heavyiron | 766 | mov eax, [esp+20h+24] |
767 | mov [ebx+dlgtemplate.title], eax |
||
768 | mov al, [menu_normal_color] |
||
769 | mov [ebx+dlgtemplate.main_color], al |
||
770 | mov al, [menu_border_color] |
||
771 | mov [ebx+dlgtemplate.border_color], al |
||
772 | mov al, [menu_header_color] |
||
773 | mov [ebx+dlgtemplate.header_color], al |
||
774 | push MenuDlgProc |
||
775 | push ebx |
||
183 | diamond | 776 | call GenericBox |
180 | heavyiron | 777 | mov [esp+28], eax |
474 | diamond | 778 | mov ecx, ebx |
779 | call pgfree |
||
180 | heavyiron | 780 | popad |
781 | ret 28 |
||
782 | |||
783 | MenuDlgProc: |
||
183 | diamond | 784 | mov eax, [esp+8] |
180 | heavyiron | 785 | cmp al, 1 |
786 | jz .draw |
||
787 | cmp al, 2 |
||
788 | jz .key |
||
183 | diamond | 789 | ret 16 |
180 | heavyiron | 790 | .draw: |
791 | call .dodraw |
||
183 | diamond | 792 | ret 16 |
474 | diamond | 793 | .prev: |
814 | diamond | 794 | mov eax, [ebx+40] |
474 | diamond | 795 | cmp dword [eax+4], 0 |
796 | jz .end |
||
797 | call .line_prev |
||
798 | .posret: |
||
814 | diamond | 799 | mov [ebx+40], eax |
474 | diamond | 800 | .redraw: |
801 | call .dodraw |
||
802 | call draw_image |
||
803 | xor eax, eax |
||
804 | ret 16 |
||
805 | .next: |
||
814 | diamond | 806 | mov eax, [ebx+40] |
474 | diamond | 807 | cmp dword [eax], 0 |
808 | jz .home |
||
809 | call .line_next |
||
810 | jmp .posret |
||
811 | .pgdn: |
||
814 | diamond | 812 | mov eax, [ebx+40] |
474 | diamond | 813 | mov ecx, [ebx+dlgtemplate.height] |
814 | .pgdnl: |
||
815 | cmp dword [eax], 0 |
||
816 | jz .posret |
||
817 | call .line_next |
||
818 | loop .pgdnl |
||
819 | jmp .posret |
||
180 | heavyiron | 820 | .key: |
183 | diamond | 821 | mov al, [esp+12] |
180 | heavyiron | 822 | cmp al, 0x48 |
823 | jz .prev |
||
824 | cmp al, 0x4B |
||
825 | jz .prev |
||
826 | cmp al, 0x4D |
||
827 | jz .next |
||
828 | cmp al, 0x50 |
||
829 | jz .next |
||
830 | cmp al, 0x1C |
||
831 | jz .enter |
||
832 | cmp al, 1 |
||
833 | jz .esc |
||
834 | cmp al, 0x47 |
||
835 | jz .home |
||
836 | cmp al, 0x4F |
||
837 | jz .end |
||
838 | cmp al, 0x51 |
||
839 | jz .pgdn |
||
840 | cmp al, 0x49 |
||
841 | jz .pgup |
||
589 | diamond | 842 | cmp al, 0x52 |
843 | jz .ins |
||
844 | cmp al, 0x53 |
||
845 | jz .del |
||
814 | diamond | 846 | mov edx, [ebx+40] |
180 | heavyiron | 847 | @@: |
848 | cmp dword [edx+4], 0 |
||
849 | jz @f |
||
850 | mov edx, [edx+4] |
||
851 | jmp @b |
||
852 | @@: |
||
853 | .l: |
||
854 | lea esi, [edx+7] |
||
855 | @@: |
||
856 | inc esi |
||
857 | cmp byte [esi], 0 |
||
858 | jz .n |
||
859 | cmp byte [esi], '&' |
||
860 | jnz @b |
||
861 | movzx ecx, byte [esi+1] |
||
862 | cmp [ascii2scan+ecx], al |
||
863 | jnz .n |
||
864 | mov eax, edx |
||
183 | diamond | 865 | ret 16 |
180 | heavyiron | 866 | .n: |
867 | mov edx, [edx] |
||
868 | test edx, edx |
||
869 | jnz .l |
||
870 | .ret: |
||
871 | xor eax, eax |
||
183 | diamond | 872 | ret 16 |
180 | heavyiron | 873 | .pgup: |
814 | diamond | 874 | mov eax, [ebx+40] |
180 | heavyiron | 875 | mov ecx, [ebx+dlgtemplate.height] |
876 | .pgupl: |
||
877 | cmp dword [eax+4], 0 |
||
878 | jz .posret |
||
879 | call .line_prev |
||
880 | loop .pgupl |
||
881 | jmp .posret |
||
882 | .home: |
||
814 | diamond | 883 | mov eax, [ebx+40] |
180 | heavyiron | 884 | @@: |
885 | cmp dword [eax+4], 0 |
||
886 | jz @f |
||
887 | mov eax, [eax+4] |
||
888 | jmp @b |
||
889 | @@: |
||
814 | diamond | 890 | mov [ebx+48], eax |
180 | heavyiron | 891 | push eax |
892 | mov ecx, [ebx+dlgtemplate.height] |
||
893 | dec ecx |
||
894 | jz .h1 |
||
895 | .h2: |
||
896 | mov eax, [eax] |
||
897 | loop .h2 |
||
898 | .h1: |
||
814 | diamond | 899 | mov [ebx+52], eax |
180 | heavyiron | 900 | pop eax |
814 | diamond | 901 | and dword [ebx+56], 0 |
180 | heavyiron | 902 | jmp .posret |
903 | .end: |
||
814 | diamond | 904 | mov eax, [ebx+40] |
180 | heavyiron | 905 | @@: |
906 | cmp dword [eax], 0 |
||
907 | jz @f |
||
908 | mov eax, [eax] |
||
909 | jmp @b |
||
910 | @@: |
||
814 | diamond | 911 | mov [ebx+52], eax |
180 | heavyiron | 912 | push eax |
913 | mov ecx, [ebx+dlgtemplate.height] |
||
914 | dec ecx |
||
915 | jz .e1 |
||
916 | .e2: |
||
917 | mov eax, [eax+4] |
||
918 | loop .e2 |
||
919 | .e1: |
||
814 | diamond | 920 | mov [ebx+48], eax |
921 | mov eax, [ebx+44] |
||
180 | heavyiron | 922 | dec eax |
814 | diamond | 923 | mov [ebx+56], eax |
180 | heavyiron | 924 | pop eax |
925 | jmp .posret |
||
926 | .esc: |
||
927 | or eax, -1 |
||
183 | diamond | 928 | ret 16 |
180 | heavyiron | 929 | .enter: |
814 | diamond | 930 | mov eax, [ebx+40] |
183 | diamond | 931 | ret 16 |
589 | diamond | 932 | .ins: |
933 | push 5 |
||
934 | pop edx |
||
935 | jmp @f |
||
936 | .del: |
||
937 | push 4 |
||
938 | pop edx |
||
939 | @@: |
||
814 | diamond | 940 | mov eax, [ebx+40] |
589 | diamond | 941 | cmp byte [eax+8], '/' |
942 | jnz @f |
||
943 | cmp word [eax+9], 'cd' |
||
944 | jnz @f |
||
945 | movzx ecx, byte [eax+11] |
||
946 | sub ecx, '0' |
||
947 | push 24 |
||
948 | pop eax |
||
949 | mov ebx, edx |
||
950 | int 40h |
||
951 | @@: |
||
952 | xor eax, eax |
||
953 | ret 16 |
||
180 | heavyiron | 954 | |
955 | .line_prev: |
||
814 | diamond | 956 | cmp eax, [ebx+48] |
180 | heavyiron | 957 | jnz @f |
958 | mov edx, [ebx+48] |
||
959 | mov edx, [edx+4] |
||
960 | mov [ebx+48], edx |
||
814 | diamond | 961 | mov edx, [ebx+52] |
962 | mov edx, [edx+4] |
||
963 | mov [ebx+52], edx |
||
180 | heavyiron | 964 | @@: |
965 | mov eax, [eax+4] |
||
814 | diamond | 966 | dec dword [ebx+56] |
180 | heavyiron | 967 | ret |
968 | .line_next: |
||
814 | diamond | 969 | cmp eax, [ebx+52] |
180 | heavyiron | 970 | jnz @f |
971 | mov edx, [ebx+48] |
||
972 | mov edx, [edx] |
||
973 | mov [ebx+48], edx |
||
814 | diamond | 974 | mov edx, [ebx+52] |
975 | mov edx, [edx] |
||
976 | mov [ebx+52], edx |
||
180 | heavyiron | 977 | @@: |
978 | mov eax, [eax] |
||
814 | diamond | 979 | inc dword [ebx+56] |
180 | heavyiron | 980 | ret |
981 | |||
982 | .dodraw: |
||
983 | mov eax, [ebx+dlgtemplate.x] |
||
984 | mov edx, [ebx+dlgtemplate.y] |
||
985 | call get_console_ptr |
||
814 | diamond | 986 | mov esi, [ebx+48] |
180 | heavyiron | 987 | .0: |
988 | xor edx, edx |
||
989 | mov ah, [menu_selected_color] |
||
814 | diamond | 990 | cmp esi, [ebx+40] |
180 | heavyiron | 991 | jz @f |
992 | mov ah, [menu_normal_color] |
||
993 | @@: |
||
994 | push edi |
||
995 | mov ecx, [ebx+dlgtemplate.width] |
||
996 | mov al, ' ' |
||
997 | stosw |
||
998 | dec ecx |
||
999 | stosw |
||
1000 | dec ecx |
||
1001 | dec ecx |
||
1002 | push esi |
||
1003 | add esi, 8 |
||
1004 | @@: |
||
1005 | lodsb |
||
1006 | test al, al |
||
1007 | jz @f |
||
1008 | cmp al, '&' |
||
1009 | jnz .noamp |
||
1010 | test dl, dl |
||
1011 | jnz .noamp |
||
1012 | mov dl, 1 |
||
1013 | lodsb |
||
1014 | push eax |
||
1015 | mov ah, [menu_selected_highlight_color] |
||
1016 | push ecx |
||
1017 | mov ecx, [esp+8] |
||
814 | diamond | 1018 | cmp ecx, [ebx+40] |
180 | heavyiron | 1019 | pop ecx |
1020 | jz .amp1 |
||
1021 | mov ah, [menu_highlight_color] |
||
1022 | .amp1: |
||
1023 | stosw |
||
1024 | pop eax |
||
1025 | jmp .amp2 |
||
1026 | .noamp: |
||
1027 | stosw |
||
1028 | .amp2: |
||
1029 | loop @b |
||
1030 | mov al, ' ' |
||
1031 | cmp byte [esi], 0 |
||
1032 | jnz .1 |
||
1033 | lodsb |
||
1034 | jmp .1 |
||
1035 | @@: |
||
1036 | mov al, ' ' |
||
1037 | .1: |
||
1038 | stosw |
||
1039 | mov al, ' ' |
||
1040 | rep stosw |
||
1041 | pop esi edi |
||
1042 | add edi, [cur_width] |
||
1043 | add edi, [cur_width] |
||
814 | diamond | 1044 | cmp esi, [ebx+52] |
180 | heavyiron | 1045 | jz @f |
1046 | mov esi, [esi] |
||
1047 | test esi, esi |
||
1048 | jnz .0 |
||
1049 | @@: |
||
1050 | ; Линейка прокрутки |
||
1051 | mov ecx, [ebx+dlgtemplate.height] |
||
814 | diamond | 1052 | cmp ecx, [ebx+44] |
180 | heavyiron | 1053 | jz .noscrollbar |
1054 | sub ecx, 2 |
||
1055 | jbe .noscrollbar |
||
814 | diamond | 1056 | mov eax, [ebx+56] |
180 | heavyiron | 1057 | mul ecx |
814 | diamond | 1058 | div dword [ebx+44] |
180 | heavyiron | 1059 | push eax |
1060 | mov eax, [ebx+dlgtemplate.x] |
||
1061 | add eax, [ebx+dlgtemplate.width] |
||
1062 | mov edx, [ebx+dlgtemplate.y] |
||
1063 | call get_console_ptr |
||
1064 | pop edx |
||
1065 | inc edx |
||
1066 | mov al, 0x1E |
||
1067 | mov ah, [menu_scrollbar_color] |
||
1068 | mov [edi], ax |
||
1069 | add edi, [cur_width] |
||
1070 | add edi, [cur_width] |
||
1071 | .2: |
||
1072 | mov al, 0xB2 |
||
1073 | dec edx |
||
1074 | jz @f |
||
1075 | mov al, 0xB0 |
||
1076 | @@: |
||
1077 | mov [edi], ax |
||
1078 | add edi, [cur_width] |
||
1079 | add edi, [cur_width] |
||
1080 | loop .2 |
||
1081 | mov al, 0x1F |
||
1082 | stosw |
||
1083 | .noscrollbar: |
||
1084 | ret |
||
183 | diamond | 1085 | |
814 | diamond | 1086 | get_ascii_char: |
1087 | ; query keyboard layout |
||
1088 | pushad |
||
1089 | mov al, [ctrlstate] |
||
1090 | and al, 3 |
||
1091 | xor ecx, ecx |
||
1092 | cmp al, 1 |
||
1093 | sbb ecx, -2 |
||
1094 | push 26 |
||
1095 | pop eax |
||
1096 | push 2 |
||
1097 | pop ebx |
||
1098 | mov edx, layout |
||
1099 | int 0x40 |
||
1100 | popad |
||
1101 | ; translate scancode to ASCII |
||
1102 | movzx eax, byte [layout+eax] |
||
1103 | ret |
||
1104 | |||
183 | diamond | 1105 | virtual at 0 |
1106 | dlgitemtemplate: |
||
1107 | ; Элементы: |
||
1108 | ; 1 = статический текст |
||
283 | diamond | 1109 | ; 2 = кнопка |
1110 | ; 3 = поле редактирования |
||
997 | diamond | 1111 | ; 4 = горизонтальный разделитель |
1112 | ; 5 = флажок |
||
1113 | ; 6 = список |
||
183 | diamond | 1114 | .type dd ? |
1115 | .x1 dd ? |
||
1116 | .y1 dd ? |
||
1117 | .x2 dd ? |
||
1118 | .y2 dd ? |
||
283 | diamond | 1119 | ; Данные: |
1120 | ; для текста: const char* data - ASCIIZ-строка |
||
997 | diamond | 1121 | ; для кнопки и флажка: const char* data - заголовок |
283 | diamond | 1122 | ; для редактора: struct {unsigned maxlength; unsigned pos; unsigned start; |
1123 | ; char data[maxlength+1];}* data; |
||
997 | diamond | 1124 | ; для списка: struct {listitem* curitemptr; unsigned numitems; |
1125 | ; listitem *head; unsigned curitem;}* data; |
||
1126 | ; head = указатель на первый отображаемый элемент, |
||
1127 | ; curitemptr = указатель на выделенный элемент, curitem = его индекс в списке (от 0) |
||
1128 | ; (где struct listitem {listitem* next; listitem* prev; char text[];};) |
||
183 | diamond | 1129 | .data dd ? |
1130 | .flags dd ? |
||
1131 | ; Флаги: |
||
1132 | ; 0 = выравнивание влево |
||
1133 | ; 1 = выравнивание по центру |
||
1134 | ; 2 = выравнивание вправо |
||
1135 | ; 4 = элемент имеет фокус ввода |
||
283 | diamond | 1136 | ; 8 = элемент может иметь фокус ввода |
1137 | ; 10h: для кнопки = кнопка по умолчанию (Enter на не-кнопке) |
||
1138 | ; для поля ввода = данные были модифицированы |
||
997 | diamond | 1139 | ; для флажка = флажок установлен |
589 | diamond | 1140 | ; 20h: для поля ввода = не отображать вводимые данные (показывать '*') |
183 | diamond | 1141 | .size = $ |
1142 | end virtual |
||
1143 | ; struct DLGDATA |
||
1144 | ; { |
||
1145 | ; DLGTEMPLATE dialog; /* window description */ |
||
1146 | ; void* DlgProc; /* dialog procedure */ |
||
1147 | ; /* int __stdcall DlgProc(DLGDATA* dlg, int msg, int param1, int param2); */ |
||
1148 | ; void* user_data; /* arbitrary user data */ |
||
1149 | ; unsigned num_items; /* number of items in the following array */ |
||
1150 | ; DLGITEMTEMPLATE items[]; /* array of dialog items */ |
||
1151 | ; } |
||
1152 | ; int __stdcall DialogBox(DLGDATA* dlg); |
||
1153 | DialogBox: |
||
1154 | push ManagerDlgProc |
||
1155 | push dword [esp+8] |
||
1156 | call GenericBox |
||
314 | diamond | 1157 | ret 4 |
183 | diamond | 1158 | |
814 | diamond | 1159 | ; int __stdcall ShowDialogBox(DLGDATA* dlg); |
1160 | ShowDialogBox: |
||
1161 | push ManagerDlgProc |
||
1162 | push dword [esp+8] |
||
1163 | call ShowGenericBox |
||
1164 | ret 4 |
||
1165 | |||
1166 | ; void __stdcall DrawDialogBox(DLGDATA* dlg); |
||
1167 | DrawDialogBox: |
||
1168 | push ManagerDlgProc |
||
1169 | push dword [esp+8] |
||
1170 | call DrawGenericBox |
||
1171 | ret 4 |
||
1172 | |||
183 | diamond | 1173 | ManagerDlgProc: |
314 | diamond | 1174 | mov ebp, ebx |
183 | diamond | 1175 | mov eax, [esp+8] |
1176 | dec eax |
||
1177 | jz .draw |
||
1178 | dec eax |
||
1179 | jz .key |
||
1180 | xor eax, eax |
||
1181 | ret 16 |
||
1182 | .draw: |
||
1183 | call .dodraw |
||
1184 | ret 16 |
||
1185 | .key: |
||
1186 | ; find item with focus |
||
1187 | add ebx, dlgtemplate.size+12 |
||
1188 | mov ecx, [ebx-4] |
||
1189 | jecxz .nobtns |
||
1190 | @@: |
||
1191 | test [ebx+dlgitemtemplate.flags], 4 |
||
1192 | jnz @f |
||
1193 | add ebx, dlgitemtemplate.size |
||
1194 | loop @b |
||
1195 | @@: |
||
1196 | .nobtns: |
||
1197 | mov al, [esp+12] |
||
1198 | cmp al, 1 |
||
1199 | jz .esc |
||
1200 | cmp al, 0x1C |
||
1201 | jz .enter |
||
1202 | cmp al, 0xF |
||
1203 | jz .tab |
||
1204 | cmp al, 0x48 |
||
1205 | jz .up |
||
283 | diamond | 1206 | cmp al, 0x50 |
1207 | jz .down |
||
997 | diamond | 1208 | jecxz .nobtns2 |
283 | diamond | 1209 | cmp [ebx+dlgitemtemplate.type], 3 |
1210 | jz .key_edit |
||
997 | diamond | 1211 | cmp [ebx+dlgitemtemplate.type], 5 |
1212 | jnz @f |
||
1213 | cmp al, 0x39 |
||
1214 | jnz @f |
||
1215 | xor [ebx+dlgitemtemplate.flags], 10h |
||
1216 | jmp .ret_draw |
||
283 | diamond | 1217 | @@: |
997 | diamond | 1218 | .nobtns2: |
183 | diamond | 1219 | cmp al, 0x4B |
1220 | jz .left |
||
1221 | cmp al, 0x4D |
||
1222 | jz .right |
||
1223 | .ret0: |
||
1224 | xor eax, eax |
||
1225 | ret 16 |
||
1226 | .esc: |
||
1227 | or eax, -1 |
||
1228 | ret 16 |
||
1229 | .enter: |
||
283 | diamond | 1230 | cmp [ebx+dlgitemtemplate.type], 2 |
1231 | jnz @f |
||
1232 | .enter_found: |
||
183 | diamond | 1233 | mov eax, ebx |
1234 | ret 16 |
||
283 | diamond | 1235 | @@: |
314 | diamond | 1236 | lea ebx, [ebp+dlgtemplate.size+12] |
474 | diamond | 1237 | mov ecx, [ebx-4] |
283 | diamond | 1238 | .enter_find: |
1239 | cmp [ebx+dlgitemtemplate.type], 2 |
||
1240 | jnz @f |
||
1241 | test [ebx+dlgitemtemplate.flags], 0x10 |
||
1242 | jnz .enter_found |
||
1243 | @@: |
||
1244 | add ebx, dlgitemtemplate.size |
||
474 | diamond | 1245 | loop .enter_find |
1246 | jmp .enter_found |
||
183 | diamond | 1247 | .tab: |
1248 | test [ctrlstate], 3 |
||
1249 | jnz .shift_tab |
||
1250 | .right: |
||
1251 | .down: |
||
1252 | jecxz .ret0 |
||
1253 | and byte [ebx+dlgitemtemplate.flags], not 4 |
||
1254 | dec ecx |
||
1255 | jz .find_first_btn |
||
1256 | @@: |
||
1257 | add ebx, dlgitemtemplate.size |
||
283 | diamond | 1258 | test [ebx+dlgitemtemplate.flags], 8 |
1259 | jnz .btn_found |
||
183 | diamond | 1260 | loop @b |
1261 | .find_first_btn: |
||
314 | diamond | 1262 | lea ebx, [ebp+dlgtemplate.size+12] |
183 | diamond | 1263 | @@: |
283 | diamond | 1264 | test [ebx+dlgitemtemplate.flags], 8 |
1265 | jnz .btn_found |
||
183 | diamond | 1266 | add ebx, dlgitemtemplate.size |
1267 | jmp @b |
||
1268 | .btn_found: |
||
1269 | or byte [ebx+dlgitemtemplate.flags], 4 |
||
283 | diamond | 1270 | .ret_draw: |
314 | diamond | 1271 | mov ebx, ebp |
183 | diamond | 1272 | call .dodraw |
1273 | call draw_image |
||
1274 | xor eax, eax |
||
1275 | ret 16 |
||
1276 | .shift_tab: |
||
1277 | .left: |
||
1278 | .up: |
||
1279 | jecxz .ret0 |
||
1280 | and byte [ebx+dlgitemtemplate.flags], not 4 |
||
314 | diamond | 1281 | sub ecx, [ebp+dlgtemplate.size+8] |
183 | diamond | 1282 | neg ecx |
1283 | jz .find_last_btn |
||
1284 | @@: |
||
1285 | sub ebx, dlgitemtemplate.size |
||
283 | diamond | 1286 | test [ebx+dlgitemtemplate.flags], 8 |
1287 | loopz @b |
||
1288 | jnz .btn_found |
||
183 | diamond | 1289 | .find_last_btn: |
314 | diamond | 1290 | mov ebx, [ebp+dlgtemplate.size+8] |
183 | diamond | 1291 | imul ebx, dlgitemtemplate.size |
314 | diamond | 1292 | lea ebx, [ebx+ebp+dlgtemplate.size+12] |
183 | diamond | 1293 | @@: |
1294 | sub ebx, dlgitemtemplate.size |
||
283 | diamond | 1295 | test [ebx+dlgitemtemplate.flags], 8 |
1296 | jz @b |
||
1297 | jmp .btn_found |
||
1298 | .key_edit: |
||
1299 | ; обработка клавиш в поле ввода |
||
1300 | test al, 0x80 |
||
1301 | jnz .ret0 |
||
1302 | or [ebx+dlgitemtemplate.flags], 0x10 |
||
1303 | mov edx, [ebx+dlgitemtemplate.data] |
||
1304 | cmp al, 0x4B |
||
1305 | jz .editor_left |
||
1306 | cmp al, 0x4D |
||
1307 | jz .editor_right |
||
1308 | cmp al, 0x47 |
||
1309 | jz .editor_home |
||
1310 | cmp al, 0x4F |
||
1311 | jz .editor_end |
||
1312 | cmp al, 0x0E |
||
1313 | jz .editor_backspace |
||
1314 | cmp al, 0x53 |
||
474 | diamond | 1315 | jnz .editor_char |
1316 | .editor_del: |
||
1317 | mov ecx, [edx+4] |
||
1318 | lea edi, [ecx+edx+12] |
||
1319 | lea esi, [edi+1] |
||
1320 | cmp byte [edi], 0 |
||
1321 | jz .ret_test |
||
1322 | jmp .copy_and_ret_test |
||
283 | diamond | 1323 | .editor_left: |
1324 | mov ecx, [edx+4] |
||
1325 | jecxz @f |
||
1326 | dec dword [edx+4] |
||
1327 | @@: jmp .ret_test |
||
1328 | .editor_right: |
||
1329 | mov ecx, [edx+4] |
||
1330 | cmp byte [edx+ecx+12], 0 |
||
1331 | jz @b |
||
1332 | inc dword [edx+4] |
||
1333 | jmp @b |
||
1334 | .editor_home: |
||
1335 | and dword [edx+4], 0 |
||
1336 | jmp @b |
||
1337 | .editor_end: |
||
1338 | lea edi, [edx+12] |
||
1339 | xor eax, eax |
||
1340 | or ecx, -1 |
||
1341 | repnz scasb |
||
1342 | not ecx |
||
1343 | dec ecx |
||
1344 | mov [edx+4], ecx |
||
1345 | .ret_test: |
||
1346 | mov eax, [edx+4] |
||
1347 | cmp [edx+8], eax |
||
1348 | jl .ret_test.l1 |
||
1349 | mov [edx+8], eax |
||
1350 | jmp .ret_test.l2 |
||
1351 | .ret_test.l1: |
||
1352 | add eax, [ebx+dlgitemtemplate.x1] |
||
1353 | sub eax, [ebx+dlgitemtemplate.x2] |
||
1354 | cmp [edx+8], eax |
||
1355 | jge .ret_test.l2 |
||
1356 | mov [edx+8], eax |
||
1357 | .ret_test.l2: |
||
1358 | jmp .ret_draw |
||
1359 | .editor_backspace: |
||
1360 | mov ecx, [edx+4] |
||
1361 | jecxz .ret_test |
||
1362 | dec dword [edx+4] |
||
1363 | lea esi, [edx+ecx+12] |
||
1364 | lea edi, [esi-1] |
||
1365 | .copy_and_ret_test: |
||
1366 | @@: |
||
1367 | lodsb |
||
1368 | stosb |
||
1369 | test al, al |
||
183 | diamond | 1370 | jnz @b |
283 | diamond | 1371 | jmp .ret_test |
474 | diamond | 1372 | .editor_char: |
1373 | test [ctrlstate], 0x3C |
||
1374 | jnz .ret_draw |
||
1375 | movzx eax, al |
||
814 | diamond | 1376 | call get_ascii_char |
474 | diamond | 1377 | push eax |
1378 | ; insert entered symbol |
||
1379 | xor eax, eax |
||
1380 | lea edi, [edx+12] |
||
1381 | or ecx, -1 |
||
1382 | repnz scasb |
||
1383 | not ecx |
||
1384 | pop eax |
||
1385 | cmp ecx, [edx] |
||
1386 | ja .ret_test ; buffer capacity exceeded |
||
1387 | lea edi, [edx+ecx+12-1] |
||
1388 | mov esi, [edx+4] |
||
1389 | lea esi, [edx+esi+12] |
||
1390 | @@: |
||
1391 | mov cl, [edi] |
||
1392 | mov [edi+1], cl |
||
1393 | dec edi |
||
1394 | cmp edi, esi |
||
1395 | jae @b |
||
1396 | mov [esi], al |
||
1397 | inc dword [edx+4] |
||
1398 | @@: jmp .ret_test |
||
183 | diamond | 1399 | |
1400 | .dodraw: |
||
283 | diamond | 1401 | or [cursor_x], -1 |
1402 | or [cursor_y], -1 |
||
183 | diamond | 1403 | add ebx, dlgtemplate.size+8 |
1404 | mov ecx, [ebx] |
||
1405 | add ebx, 4 |
||
1406 | jecxz .done_draw |
||
1407 | .draw_loop: |
||
1408 | push ecx |
||
1409 | mov eax, [ebx+dlgitemtemplate.type] |
||
997 | diamond | 1410 | cmp eax, draw_functions_num |
1411 | jae .draw_loop_continue |
||
1412 | call [draw_functions + eax*4] |
||
183 | diamond | 1413 | .draw_loop_continue: |
1414 | pop ecx |
||
1415 | add ebx, dlgitemtemplate.size |
||
1416 | loop .draw_loop |
||
1417 | .done_draw: |
||
1418 | ret |
||
1419 | |||
997 | diamond | 1420 | iglobal |
1421 | align 4 |
||
1422 | label draw_functions dword |
||
1423 | dd ManagerDlgProc.done_draw |
||
1424 | dd draw_static_text |
||
1425 | dd draw_button |
||
1426 | dd draw_editbox |
||
1427 | dd draw_h_separator |
||
1428 | dd draw_checkbox |
||
1429 | dd draw_listbox |
||
1430 | draw_functions_num = ($ - draw_functions) / 4 |
||
1431 | endg |
||
1432 | |||
183 | diamond | 1433 | draw_static_text: |
1434 | ; рисуем статический текст |
||
1435 | mov ah, [dialog_main_color] |
||
314 | diamond | 1436 | test byte [ebp+dlgtemplate.flags], 2 |
1437 | jz draw_text |
||
1438 | mov ah, [warning_main_color] |
||
183 | diamond | 1439 | draw_text: |
1440 | ; определяем длину строки |
||
1441 | mov esi, [ebx+dlgitemtemplate.data] |
||
283 | diamond | 1442 | draw_text_esi: |
183 | diamond | 1443 | test esi, esi |
997 | diamond | 1444 | jz .ret2 |
1445 | push eax |
||
589 | diamond | 1446 | push -1 |
1447 | pop ecx |
||
183 | diamond | 1448 | @@: |
1449 | inc ecx |
||
1450 | cmp byte [ecx+esi], 0 |
||
1451 | jnz @b |
||
1452 | ; в ecx длина строки |
||
1453 | xor eax, eax |
||
1454 | mov edx, [ebx+dlgitemtemplate.x2] |
||
1455 | sub edx, [ebx+dlgitemtemplate.x1] |
||
1456 | inc edx |
||
1457 | cmp ecx, edx |
||
1458 | jae .text_draw |
||
1459 | mov al, byte [ebx+dlgitemtemplate.flags] |
||
1460 | and al, 3 |
||
1461 | jz .text_align_left |
||
1462 | cmp al, 1 |
||
1463 | jz .text_align_center |
||
1464 | ; текст выровнен вправо |
||
1465 | mov eax, edx |
||
1466 | sub eax, ecx |
||
1467 | jmp .text_draw |
||
1468 | .text_align_center: |
||
1469 | mov eax, edx |
||
1470 | sub eax, ecx |
||
1471 | shr eax, 1 |
||
1472 | jmp .text_draw |
||
1473 | .text_align_left: |
||
1474 | xor eax, eax |
||
1475 | .text_draw: |
||
1476 | push ecx |
||
1477 | push eax |
||
1478 | push edx |
||
997 | diamond | 1479 | call dlgitem_get_console_ptr |
183 | diamond | 1480 | pop edx |
1481 | pop ecx |
||
1482 | mov ah, [esp+5] |
||
1483 | mov al, ' ' |
||
1484 | rep stosw |
||
1485 | pop ecx |
||
1486 | cmp ecx, edx |
||
1487 | jbe .text_copy |
||
283 | diamond | 1488 | cmp [ebx+dlgitemtemplate.type], 3 |
1489 | jnz @f |
||
1490 | mov ecx, edx |
||
1491 | jmp .text_copy |
||
1492 | @@: |
||
183 | diamond | 1493 | cmp edx, 3 |
1494 | jb .ret |
||
1495 | mov al, '.' |
||
1496 | stosw |
||
1497 | stosw |
||
1498 | stosw |
||
1499 | add esi, ecx |
||
1500 | mov ecx, edx |
||
1501 | sub ecx, 3 |
||
1502 | sub esi, ecx |
||
1503 | .text_copy: |
||
1504 | jecxz .ret |
||
589 | diamond | 1505 | ; check for password editboxes |
1506 | cmp [ebx+dlgitemtemplate.type], 3 |
||
1507 | jnz @f |
||
1508 | test [ebx+dlgitemtemplate.flags], 20h |
||
1509 | jz @f |
||
1510 | mov al, '*' |
||
1511 | rep stosw |
||
1512 | jmp .ret |
||
183 | diamond | 1513 | @@: |
1514 | lodsb |
||
1515 | stosw |
||
1516 | loop @b |
||
1517 | .ret: |
||
314 | diamond | 1518 | mov eax, [ebp+dlgtemplate.x] |
1519 | mov edx, [ebp+dlgtemplate.y] |
||
183 | diamond | 1520 | add eax, [ebx+dlgitemtemplate.x2] |
1521 | inc eax |
||
1522 | add edx, [ebx+dlgitemtemplate.y1] |
||
1523 | mov ecx, edi |
||
1524 | call get_console_ptr |
||
1525 | xchg ecx, edi |
||
1526 | sub ecx, edi |
||
1527 | shr ecx, 1 |
||
1528 | pop eax |
||
1529 | mov al, ' ' |
||
1530 | rep stosw |
||
997 | diamond | 1531 | .ret2: |
183 | diamond | 1532 | ret |
1533 | |||
1534 | draw_button: |
||
314 | diamond | 1535 | mov ecx, dialog_colors |
1536 | test byte [ebp+dlgtemplate.flags], 2 |
||
1537 | jz @f |
||
1538 | mov ecx, warning_colors |
||
1539 | @@: |
||
1540 | mov ah, [dialog_normal_btn_color-dialog_colors+ecx] |
||
183 | diamond | 1541 | test [ebx+dlgitemtemplate.flags], 4 |
1542 | jz @f |
||
314 | diamond | 1543 | mov ah, [dialog_selected_btn_color-dialog_colors+ecx] |
183 | diamond | 1544 | @@: |
1545 | jmp draw_text |
||
283 | diamond | 1546 | |
1547 | draw_editbox: |
||
1548 | mov edx, [ebx+dlgitemtemplate.data] |
||
1549 | test [ebx+dlgitemtemplate.flags], 4 |
||
1550 | jz @f |
||
1551 | mov eax, [ebx+dlgitemtemplate.x1] |
||
1552 | add eax, [edx+4] |
||
1553 | sub eax, [edx+8] |
||
314 | diamond | 1554 | add eax, [ebp+dlgtemplate.x] |
283 | diamond | 1555 | mov [cursor_x], eax |
1556 | mov eax, [ebx+dlgitemtemplate.y1] |
||
314 | diamond | 1557 | add eax, [ebp+dlgtemplate.y] |
283 | diamond | 1558 | mov [cursor_y], eax |
1559 | @@: |
||
314 | diamond | 1560 | mov ecx, dialog_colors |
1561 | test byte [ebp+dlgtemplate.flags], 2 |
||
1562 | jz @f |
||
1563 | mov ecx, warning_colors |
||
1564 | @@: |
||
1565 | mov ah, [dialog_edit_color-dialog_colors+ecx] |
||
283 | diamond | 1566 | test [ebx+dlgitemtemplate.flags], 10h |
1567 | jnz @f |
||
314 | diamond | 1568 | mov ah, [dialog_unmodified_edit_color-dialog_colors+ecx] |
283 | diamond | 1569 | @@: |
1570 | mov esi, [ebx+dlgitemtemplate.data] |
||
1571 | add esi, [edx+8] |
||
1572 | add esi, 12 |
||
1573 | jmp draw_text_esi |
||
314 | diamond | 1574 | |
997 | diamond | 1575 | dlgitem_get_console_ptr: |
1576 | mov eax, [ebx+dlgitemtemplate.x1] |
||
1577 | mov edx, [ebx+dlgitemtemplate.y1] |
||
1578 | mov ecx, eax |
||
1579 | add eax, [ebp+dlgtemplate.x] |
||
1580 | add edx, [ebp+dlgtemplate.y] |
||
1581 | jmp get_console_ptr |
||
1582 | |||
1583 | draw_h_separator: |
||
1584 | ; рисуем горизонтальный разделитель |
||
1585 | call dlgitem_get_console_ptr |
||
1586 | .scan: |
||
1587 | mov al, 0xC7 |
||
1588 | test ecx, ecx |
||
1589 | js @f |
||
1590 | mov al, 0xB6 |
||
1591 | cmp ecx, [ebp+dlgtemplate.width] |
||
1592 | jz @f |
||
1593 | mov al, 0xC4 |
||
1594 | @@: |
||
1595 | stosb |
||
1596 | jz .done |
||
1597 | inc ecx |
||
1598 | inc edi |
||
1599 | cmp ecx, [ebx+dlgitemtemplate.x2] |
||
1600 | jb .scan |
||
1601 | .done: |
||
1602 | ret |
||
1603 | |||
1604 | draw_checkbox: |
||
1605 | ; рисуем флажок |
||
1606 | call dlgitem_get_console_ptr |
||
1607 | test byte [ebx+dlgitemtemplate.flags], 4 |
||
1608 | jz @f |
||
1609 | inc eax |
||
1610 | mov [cursor_x], eax |
||
1611 | mov [cursor_y], edx |
||
1612 | @@: |
||
1613 | mov ah, [dialog_main_color] |
||
1614 | test byte [ebp+dlgtemplate.flags], 2 |
||
1615 | jz @f |
||
1616 | mov ah, [warning_main_color] |
||
1617 | @@: |
||
1618 | mov al, '[' |
||
1619 | stosw |
||
1620 | mov al, 'x' |
||
1621 | test byte [ebx+dlgitemtemplate.flags], 10h |
||
1622 | jnz @f |
||
1623 | mov al, ' ' |
||
1624 | @@: |
||
1625 | stosw |
||
1626 | mov al, ']' |
||
1627 | stosw |
||
1628 | mov al, ' ' |
||
1629 | stosw |
||
1630 | mov ecx, [ebx+dlgitemtemplate.x2] |
||
1631 | sub ecx, [ebx+dlgitemtemplate.x1] |
||
1632 | jb .ret |
||
1633 | sub ecx, 3 |
||
1634 | jbe .ret |
||
1635 | mov esi, [ebx+dlgitemtemplate.data] |
||
1636 | @@: |
||
1637 | lodsb |
||
1638 | test al, al |
||
1639 | jz .ret |
||
1640 | stosw |
||
1641 | loop @b |
||
1642 | .ret: |
||
1643 | ret |
||
1644 | |||
1645 | draw_listbox: |
||
1646 | ; рисуем список |
||
1647 | call dlgitem_get_console_ptr |
||
1648 | mov edx, [ebx+dlgitemtemplate.data] |
||
1649 | mov esi, [edx+8] |
||
1650 | mov eax, [ebx+dlgitemtemplate.y2] |
||
1651 | sub eax, [ebx+dlgitemtemplate.y1] |
||
1652 | push eax |
||
1653 | push eax |
||
1654 | .0: |
||
1655 | test esi, esi |
||
1656 | jz .listdone |
||
1657 | push esi edi |
||
1658 | push edx |
||
1659 | or edx, -1 |
||
1660 | mov ecx, [ebx+dlgitemtemplate.x2] |
||
1661 | sub ecx, [ebx+dlgitemtemplate.x1] |
||
1662 | inc ecx |
||
1663 | xor eax, eax |
||
1664 | @@: |
||
1665 | inc edx |
||
1666 | cmp byte [esi+8+edx], al |
||
1667 | jnz @b |
||
1668 | @@: |
||
1669 | cmp ecx, edx |
||
1670 | jae .text_draw |
||
1671 | mov al, byte [ebx+dlgitemtemplate.flags] |
||
1672 | and al, 3 |
||
1673 | jz .text_align_left |
||
1674 | cmp al, 1 |
||
1675 | jz .text_align_center |
||
1676 | ; текст выровнен вправо |
||
1677 | mov eax, edx |
||
1678 | sub eax, ecx |
||
1679 | jmp .text_draw |
||
1680 | .text_align_center: |
||
1681 | mov eax, edx |
||
1682 | sub eax, ecx |
||
1683 | shr eax, 1 |
||
1684 | jmp .text_draw |
||
1685 | .text_align_left: |
||
1686 | ; xor eax, eax |
||
1687 | .text_draw: |
||
1688 | pop edx |
||
1689 | cmp esi, [edx] |
||
1690 | lea esi, [esi+8+eax] |
||
1691 | mov ah, [dialog_selected_list_color] |
||
1692 | jz @f |
||
1693 | mov ah, [dialog_list_color] |
||
1694 | @@: |
||
1695 | jecxz .next |
||
1696 | @@: |
||
1697 | lodsb |
||
1698 | test al, al |
||
1699 | jz @f |
||
1700 | stosw |
||
1701 | loop @b |
||
1702 | @@: |
||
1703 | mov al, ' ' |
||
1704 | rep stosw |
||
1705 | .next: |
||
1706 | pop edi esi |
||
1707 | add edi, [cur_width] |
||
1708 | add edi, [cur_width] |
||
1709 | mov esi, [esi] |
||
1710 | dec dword [esp] |
||
1711 | jns .0 |
||
1712 | .listdone: |
||
1713 | pop eax |
||
1714 | ; Линейка прокрутки |
||
1715 | pop ecx |
||
1716 | inc ecx |
||
1717 | mov esi, [edx+4] |
||
1718 | cmp ecx, esi |
||
1719 | jae .noscrollbar |
||
1720 | sub ecx, 2 |
||
1721 | jbe .noscrollbar |
||
1722 | mov eax, [edx+12] |
||
1723 | mul ecx |
||
1724 | div esi |
||
1725 | push eax |
||
1726 | mov eax, [ebx+dlgitemtemplate.x2] |
||
1727 | add eax, [ebp+dlgtemplate.x] |
||
1728 | mov edx, [ebx+dlgitemtemplate.y1] |
||
1729 | add edx, [ebp+dlgtemplate.y] |
||
1730 | call get_console_ptr |
||
1731 | pop edx |
||
1732 | inc edx |
||
1733 | mov al, 0x1E |
||
1734 | mov ah, [dialog_scroll_list_color] |
||
1735 | mov [edi], ax |
||
1736 | add edi, [cur_width] |
||
1737 | add edi, [cur_width] |
||
1738 | .2: |
||
1739 | mov al, 0xB1 |
||
1740 | dec edx |
||
1741 | jz @f |
||
1742 | mov al, 0xB0 |
||
1743 | @@: |
||
1744 | mov [edi], ax |
||
1745 | add edi, [cur_width] |
||
1746 | add edi, [cur_width] |
||
1747 | loop .2 |
||
1748 | mov al, 0x1F |
||
1749 | stosw |
||
1750 | .noscrollbar: |
||
1751 | ret |
||
1752 | |||
1753 | listbox_key: |
||
1754 | mov edx, [ebx+dlgitemtemplate.data] |
||
1755 | cmp al, 0x48 |
||
1756 | jz .prev |
||
1757 | cmp al, 0x50 |
||
1758 | jz .next |
||
1759 | cmp al, 0x47 |
||
1760 | jz .home |
||
1761 | cmp al, 0x4F |
||
1762 | jz .end |
||
1763 | cmp al, 0x51 |
||
1764 | jz .pgdn |
||
1765 | cmp al, 0x49 |
||
1766 | jz .pgup |
||
1767 | ret |
||
1768 | .next: |
||
1769 | call .calc_last_line |
||
1770 | mov eax, [edx] |
||
1771 | cmp dword [eax], 0 |
||
1772 | jz @f |
||
1773 | call .line_next |
||
1774 | @@: |
||
1775 | mov [edx], eax |
||
1776 | ret |
||
1777 | .pgdn: |
||
1778 | call .calc_last_line |
||
1779 | mov eax, [edx] |
||
1780 | mov ecx, [ebx+dlgitemtemplate.y2] |
||
1781 | sub ecx, [ebx+dlgitemtemplate.y1] |
||
1782 | .pgdnl: |
||
1783 | cmp dword [eax], 0 |
||
1784 | jz @f |
||
1785 | call .line_next |
||
1786 | loop .pgdnl |
||
1787 | @@: |
||
1788 | mov [edx], eax |
||
1789 | ret |
||
1790 | .prev: |
||
1791 | mov eax, [edx] |
||
1792 | cmp dword [eax+4], 0 |
||
1793 | jz @f |
||
1794 | call .line_prev |
||
1795 | @@: |
||
1796 | mov [edx], eax |
||
1797 | ret |
||
1798 | .pgup: |
||
1799 | mov eax, [edx] |
||
1800 | mov ecx, [ebx+dlgitemtemplate.y2] |
||
1801 | sub ecx, [ebx+dlgitemtemplate.y1] |
||
1802 | ; inc ecx |
||
1803 | .pgupl: |
||
1804 | cmp dword [eax+4], 0 |
||
1805 | jz @f |
||
1806 | call .line_prev |
||
1807 | loop .pgupl |
||
1808 | @@: |
||
1809 | mov [edx], eax |
||
1810 | ret |
||
1811 | .home: |
||
1812 | mov eax, [edx] |
||
1813 | @@: |
||
1814 | cmp dword [eax+4], 0 |
||
1815 | jz @f |
||
1816 | mov eax, [eax+4] |
||
1817 | jmp @b |
||
1818 | @@: |
||
1819 | mov [edx], eax |
||
1820 | mov [edx+8], eax |
||
1821 | and dword [edx+12], 0 |
||
1822 | ret |
||
1823 | .end: |
||
1824 | mov eax, [edx] |
||
1825 | @@: |
||
1826 | cmp dword [eax], 0 |
||
1827 | jz @f |
||
1828 | mov eax, [eax] |
||
1829 | jmp @b |
||
1830 | @@: |
||
1831 | mov [edx], eax |
||
1832 | mov ecx, [ebx+dlgitemtemplate.y2] |
||
1833 | sub ecx, [ebx+dlgitemtemplate.y1] |
||
1834 | jz .e1 |
||
1835 | .e2: |
||
1836 | mov eax, [eax+4] |
||
1837 | loop .e2 |
||
1838 | .e1: |
||
1839 | mov [edx+8], eax |
||
1840 | mov eax, [edx+4] |
||
1841 | dec eax |
||
1842 | mov [edx+12], eax |
||
1843 | ret |
||
1844 | |||
1845 | .line_prev: |
||
1846 | cmp eax, [edx+8] |
||
1847 | mov eax, [eax+4] |
||
1848 | jnz @f |
||
1849 | mov [edx+8], eax |
||
1850 | @@: |
||
1851 | dec dword [edx+12] |
||
1852 | ret |
||
1853 | .calc_last_line: |
||
1854 | mov esi, [edx+8] |
||
1855 | mov ecx, [ebx+dlgitemtemplate.y2] |
||
1856 | sub ecx, [ebx+dlgitemtemplate.y1] |
||
1857 | jz .clldone |
||
1858 | @@: |
||
1859 | mov esi, [esi] |
||
1860 | test esi, esi |
||
1861 | jz @f |
||
1862 | loop @b |
||
1863 | .clldone: |
||
1864 | ret |
||
1865 | .line_next: |
||
1866 | cmp eax, esi |
||
1867 | mov eax, [eax] |
||
1868 | jnz @f |
||
1869 | push eax |
||
1870 | mov eax, [edx+8] |
||
1871 | mov eax, [eax] |
||
1872 | mov [edx+8], eax |
||
1873 | pop eax |
||
1874 | mov esi, eax |
||
1875 | @@: |
||
1876 | inc dword [edx+12] |
||
1877 | ret |
||
1878 | |||
314 | diamond | 1879 | ; void __stdcall SayNoMem(void); |
1880 | SayNoMem: |
||
1881 | or dword [nomem_dlgdata+4], -1 |
||
1882 | or dword [nomem_dlgdata+8], -1 |
||
1883 | push nomem_dlgdata |
||
1884 | call DialogBox |
||
1885 | ret |
||
1886 | |||
997 | diamond | 1887 | ; int __stdcall ConfirmCancel(void); |
1888 | ; return value: 0 = the user is sure, nonzero = the user wants to continue |
||
1889 | ConfirmCancel: |
||
1890 | push YesOrNoBtn |
||
1891 | push 2 |
||
1892 | push ConfirmCancelMsg |
||
1893 | push 1 |
||
1894 | push aCancelled |
||
1895 | call SayErrTitle |
||
1896 | test eax, eax |
||
1897 | ret |
||
1898 | |||
589 | diamond | 1899 | ; int __stdcall SayErr(int num_strings, const char* strings[], |
1900 | ; int num_buttons, const char* buttons[]); |
||
474 | diamond | 1901 | SayErr: |
589 | diamond | 1902 | pop eax |
1903 | push aError |
||
1904 | push eax |
||
814 | diamond | 1905 | ; int __stdcall SayErrTitle(const char* title, |
1906 | ; int num_strings, const char* strings[], |
||
1907 | ; int num_buttons, const char* buttons[]); |
||
1908 | SayErrTitle: |
||
474 | diamond | 1909 | push 2 |
1910 | jmp @f |
||
1911 | |||
589 | diamond | 1912 | ; int __stdcall Message(const char* title, |
474 | diamond | 1913 | ; int num_strings, const char* strings[], |
1914 | ; int num_buttons, const char* buttons[]); |
||
1915 | Message: |
||
1916 | push 1 |
||
1917 | @@: |
||
589 | diamond | 1918 | pop eax |
314 | diamond | 1919 | ; [esp+4] = title |
589 | diamond | 1920 | ; [esp+8] = num_strings |
1921 | ; [esp+12] = strings |
||
1922 | ; [esp+16] = num_buttons |
||
1923 | ; [esp+20] = buttons |
||
474 | diamond | 1924 | pushad |
589 | diamond | 1925 | mov ecx, [esp+32+8] |
1926 | add ecx, [esp+32+16] |
||
474 | diamond | 1927 | imul ecx, dlgitemtemplate.size |
1928 | add ecx, dlgtemplate.size+12 |
||
1929 | call xpgalloc |
||
314 | diamond | 1930 | test eax, eax |
1931 | jnz @f |
||
474 | diamond | 1932 | popad |
314 | diamond | 1933 | or eax, -1 |
1934 | ret 28 |
||
1935 | @@: |
||
1936 | mov ebx, eax |
||
1937 | mov edi, eax |
||
474 | diamond | 1938 | mov eax, [esp+28] |
314 | diamond | 1939 | stosd ; dlgtemplate.flags |
589 | diamond | 1940 | or eax, -1 |
314 | diamond | 1941 | stosd ; dlgtemplate.x |
1942 | stosd ; dlgtemplate.y |
||
1943 | ; calculate width |
||
589 | diamond | 1944 | mov ecx, [esp+32+8] |
1945 | mov esi, [esp+32+12] |
||
314 | diamond | 1946 | xor edx, edx |
1947 | .calcwidth: |
||
1948 | lodsd |
||
1949 | @@: |
||
1950 | inc eax |
||
1951 | cmp byte [eax-1], 0 |
||
1952 | jnz @b |
||
1953 | sub eax, [esi-4] |
||
1954 | inc eax |
||
1955 | cmp edx, eax |
||
1956 | ja @f |
||
1957 | mov edx, eax |
||
1958 | @@: |
||
1959 | loop .calcwidth |
||
589 | diamond | 1960 | mov ecx, [esp+32+16] |
1961 | mov esi, [esp+32+20] |
||
314 | diamond | 1962 | xor ebp, ebp |
1963 | .calcwidth2: |
||
1964 | lodsd |
||
1965 | @@: |
||
1966 | inc eax |
||
1967 | cmp byte [eax-1], 0 |
||
1968 | jnz @b |
||
1969 | sub eax, [esi-4] |
||
1970 | inc eax |
||
1971 | add ebp, eax |
||
1972 | loop .calcwidth2 |
||
1973 | inc ebp |
||
1974 | inc ebp |
||
1975 | cmp edx, ebp |
||
1976 | ja @f |
||
1977 | mov edx, ebp |
||
1978 | @@: |
||
1979 | mov eax, [cur_width] |
||
1980 | sub eax, 8 |
||
1981 | cmp edx, eax |
||
1982 | jb @f |
||
1983 | mov edx, eax |
||
1984 | @@: |
||
1985 | mov eax, edx |
||
1986 | stosd ; dlgtemplate.width |
||
589 | diamond | 1987 | mov eax, [esp+32+8] |
314 | diamond | 1988 | inc eax |
1989 | stosd ; dlgtemplate.height |
||
1990 | mov eax, 3 |
||
1991 | stosd ; dlgtemplate.border_size_x |
||
1992 | mov al, 2 |
||
1993 | stosd ; dlgtemplate.border_size_y |
||
1994 | mov eax, [esp+32+4] |
||
1995 | stosd ; dlgtemplate.title |
||
1996 | xor eax, eax |
||
1997 | stosd ; (ignored) |
||
814 | diamond | 1998 | stosd ; (ignored) |
314 | diamond | 1999 | stosd ; DlgProc |
2000 | stosd ; userdata |
||
589 | diamond | 2001 | mov eax, [esp+32+8] |
2002 | add eax, [esp+32+16] |
||
314 | diamond | 2003 | stosd ; num_items |
2004 | ; fill strings |
||
2005 | xor ecx, ecx |
||
589 | diamond | 2006 | mov esi, [esp+32+12] |
314 | diamond | 2007 | @@: |
2008 | mov eax, 1 |
||
2009 | stosd ; dlgitemtemplate.type |
||
2010 | dec eax |
||
2011 | stosd ; dlgitemtemplate.x1 |
||
2012 | mov eax, ecx |
||
2013 | stosd ; dlgitemtemplate.y1 |
||
2014 | lea eax, [edx-1] |
||
2015 | stosd ; dlgitemtemplate.x2 |
||
2016 | mov eax, ecx |
||
2017 | stosd ; dlgitemtemplate.y2 |
||
2018 | movsd ; dlgitemtemplate.data |
||
2019 | mov eax, 1 |
||
2020 | stosd ; dlgitemtemplate.flags |
||
2021 | inc ecx |
||
589 | diamond | 2022 | cmp ecx, [esp+32+8] |
314 | diamond | 2023 | jb @b |
2024 | ; fill buttons |
||
589 | diamond | 2025 | mov ecx, [esp+32+16] |
2026 | mov esi, [esp+32+20] |
||
314 | diamond | 2027 | sub edx, ebp |
2028 | jc .big |
||
2029 | shr edx, 1 |
||
2030 | inc edx |
||
2031 | jmp .fillbtns |
||
2032 | .big: |
||
2033 | xor edx, edx |
||
2034 | .fillbtns: |
||
2035 | mov eax, 2 |
||
2036 | stosd ; dlgitemtemplate.type |
||
2037 | mov eax, edx |
||
2038 | stosd ; dlgitemtemplate.x1 |
||
2039 | mov eax, [ebx+dlgtemplate.height] |
||
2040 | dec eax |
||
2041 | stosd ; dlgitemtemplate.y1 |
||
2042 | push eax |
||
2043 | lodsd |
||
2044 | sub eax, edx |
||
2045 | @@: |
||
2046 | inc edx |
||
2047 | cmp byte [eax+edx-1], 0 |
||
2048 | jnz @b |
||
2049 | mov eax, edx |
||
2050 | inc edx |
||
2051 | stosd ; dlgitemtemplate.x2 |
||
2052 | pop eax |
||
2053 | stosd ; dlgitemtemplate.y2 |
||
2054 | mov eax, [esi-4] |
||
2055 | stosd ; dlgitemtemplate.data |
||
2056 | mov eax, 9 |
||
589 | diamond | 2057 | cmp ecx, [esp+32+16] |
314 | diamond | 2058 | jnz @f |
2059 | or al, 4 |
||
2060 | @@: |
||
2061 | stosd ; dlgitemtemplate.flags |
||
2062 | loop .fillbtns |
||
2063 | push ebx |
||
2064 | call DialogBox |
||
2065 | cmp eax, -1 |
||
2066 | jz @f |
||
2067 | sub eax, ebx |
||
2068 | sub eax, dlgtemplate.size+12 |
||
2069 | xor edx, edx |
||
2070 | mov ecx, dlgitemtemplate.size |
||
2071 | div ecx |
||
589 | diamond | 2072 | sub eax, [esp+32+8] |
314 | diamond | 2073 | @@: |
2074 | mov [esp+28], eax |
||
474 | diamond | 2075 | mov ecx, ebx |
2076 | call pgfree |
||
314 | diamond | 2077 | popad |
589 | diamond | 2078 | ret 20 |