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