Rev 7724 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3887 | leency | 1 | ; Calendar for KolibriOS |
31 | halyavin | 2 | ; |
3895 | leency | 3 | ; v1.5 - time redesign by Heavyiron |
7724 | dunkaist | 4 | ; v1.2 - v1.55 - new design and functionality by Leency |
3887 | leency | 5 | ; v1.1 - add change time support by DedOK |
6 | ; v1.0 - written in pure assembler by Ivushkin Andrey aka Willow |
||
7 | ; also - diamond, spraid, fedesco |
||
31 | halyavin | 8 | ; |
3887 | leency | 9 | ; Created: November 1, 2004 |
31 | halyavin | 10 | |
11 | |||
3891 | leency | 12 | use32 |
31 | halyavin | 13 | |
3891 | leency | 14 | org 0x0 |
31 | halyavin | 15 | |
3891 | leency | 16 | db 'MENUET01' |
17 | dd 0x01 |
||
18 | dd START |
||
19 | dd I_END |
||
20 | dd 0x1000 |
||
21 | dd 0x1000 |
||
22 | dd 0x0 |
||
23 | dd 0x0 |
||
24 | include '..\..\..\macros.inc' |
||
31 | halyavin | 25 | include 'lang.inc' |
3887 | leency | 26 | include 'data.inc' |
31 | halyavin | 27 | |
28 | |||
485 | heavyiron | 29 | |
3889 | leency | 30 | macro ShowFocus field,reg |
31 | halyavin | 31 | { |
32 | local .nofocus, .exit |
||
33 | cmp [focus],field |
||
34 | jne .nofocus |
||
35 | if reg eq |
||
3890 | leency | 36 | mov ecx,COL_ACTIVE_TEXT |
31 | halyavin | 37 | else |
3890 | leency | 38 | mov reg,COL_ACTIVE_TEXT |
31 | halyavin | 39 | end if |
40 | jmp .exit |
||
41 | .nofocus: |
||
42 | if reg eq |
||
3889 | leency | 43 | mov ecx,COL_DROPDOWN_T |
31 | halyavin | 44 | else |
3889 | leency | 45 | mov reg,COL_DROPDOWN_T |
31 | halyavin | 46 | end if |
47 | .exit: |
||
48 | } |
||
49 | |||
3889 | leency | 50 | macro GetSkinHeight |
51 | { |
||
52 | mov eax,48 |
||
53 | mov ebx,4 |
||
54 | int 0x40 |
||
55 | } |
||
31 | halyavin | 56 | |
3891 | leency | 57 | macro DrawRect color1,color2,color3,color4 ; pizdec... but optimized well |
58 | { |
||
59 | ; top border-outer |
||
60 | push ebx |
||
61 | push ecx |
||
62 | mov eax,13 |
||
63 | mov bx,DATE_BUTTON_WIDTH |
||
64 | mov edx,color1 |
||
65 | mov cx,1 |
||
66 | mcall |
||
67 | ; left border-outer |
||
68 | mov bx,1 |
||
69 | mov cx,DATE_BUTTON_HEIGHT |
||
70 | mcall |
||
71 | ; top border-inner |
||
72 | mov edx,color2 |
||
73 | add ebx,1 shl 16 |
||
74 | add ecx,1 shl 16 |
||
75 | mov bx,DATE_BUTTON_WIDTH-1 |
||
76 | mov cx,1 |
||
77 | ; left border-inner |
||
78 | mcall |
||
79 | mov bx,1 |
||
80 | mov cx,DATE_BUTTON_HEIGHT-2 |
||
81 | mcall |
||
82 | ; inner |
||
83 | mov edx,color3 |
||
84 | add ebx,1 shl 16 |
||
85 | add ecx,1 shl 16 |
||
86 | mov bx,DATE_BUTTON_WIDTH-4 |
||
7717 | leency | 87 | mov cx,DATE_BUTTON_HEIGHT-3 |
3891 | leency | 88 | mcall |
89 | ; bottom border-inner |
||
90 | mov edx,color4 |
||
91 | add ebx,DATE_BUTTON_WIDTH shl 16 |
||
92 | sub ebx,4 shl 16 |
||
93 | mov bx,1 |
||
94 | mov cx,DATE_BUTTON_HEIGHT-3 |
||
95 | mcall |
||
6950 | leency | 96 | ; right border-outer |
3891 | leency | 97 | mov edx,color2 |
98 | add ebx,1 shl 16 |
||
99 | sub ecx,1 shl 16 |
||
100 | add cx,1 |
||
101 | mcall |
||
6950 | leency | 102 | ; right border-outer 2 |
103 | mov edx,color1 |
||
104 | add ebx,1 shl 16 |
||
105 | sub ecx,1 shl 16 |
||
106 | add cx,2 |
||
107 | add cx,1 |
||
108 | mcall |
||
3891 | leency | 109 | ; bottom border-outer |
110 | mov edx,color2 |
||
111 | pop ecx |
||
112 | pop ebx |
||
113 | add ecx,DATE_BUTTON_HEIGHT shl 16 |
||
114 | sub ecx,1 shl 16 |
||
115 | add ebx,1 shl 16 |
||
116 | mov cx,1 |
||
117 | mcall |
||
6950 | leency | 118 | ; bottom border-outer 2 |
119 | mov edx,color1 |
||
120 | add ecx,1 shl 16 |
||
121 | mcall |
||
122 | add ebx,1 shl 16 |
||
123 | sub ecx,1 shl 16 |
||
3891 | leency | 124 | ; left border-outer |
125 | mov edx,color4 |
||
126 | add ebx,1 shl 16 |
||
127 | sub ecx,1 shl 16 |
||
128 | sub bx,2 |
||
129 | mcall |
||
130 | } |
||
3887 | leency | 131 | |
3891 | leency | 132 | |
31 | halyavin | 133 | str2int: |
134 | xor eax,eax |
||
135 | lodsb |
||
136 | mov ebx,eax |
||
137 | shr ebx,4 |
||
138 | and eax,0xf |
||
139 | imul ebx,10 |
||
140 | add al,bl |
||
141 | ret |
||
142 | |||
7717 | leency | 143 | get_current_date: |
31 | halyavin | 144 | mcall 29 |
145 | mov [datestr],eax |
||
146 | mov esi,datestr |
||
147 | call str2int |
||
148 | add eax,1900 |
||
7717 | leency | 149 | mov [curYear],eax |
31 | halyavin | 150 | call str2int |
151 | dec eax |
||
7717 | leency | 152 | mov [curMonth],eax |
31 | halyavin | 153 | call str2int |
7717 | leency | 154 | mov [curDay],eax |
31 | halyavin | 155 | test byte[esi],0 |
156 | jnz .no2000 |
||
7717 | leency | 157 | add [curYear],100 |
31 | halyavin | 158 | .no2000: |
7717 | leency | 159 | ret |
160 | |||
161 | check_midnight: |
||
162 | mov ebx,[datestr] |
||
163 | mcall 29 |
||
164 | cmp eax,ebx |
||
165 | je end_check_midnight |
||
166 | call get_current_date |
||
167 | call draw_days |
||
168 | end_check_midnight: |
||
169 | ret |
||
170 | |||
171 | ;=============================================================== |
||
172 | |||
173 | START: |
||
174 | call get_current_date |
||
175 | m2m [Year], [curYear] |
||
176 | m2m [Month], [curMonth] |
||
177 | m2m [day_sel], [curDay] |
||
7724 | dunkaist | 178 | call calculate |
3891 | leency | 179 | red: |
4735 | leency | 180 | call define_window |
31 | halyavin | 181 | |
3891 | leency | 182 | still: |
31 | halyavin | 183 | |
3889 | leency | 184 | mcall 23,50 ; wait here for event |
31 | halyavin | 185 | .evt: |
186 | mov ebp,[focus] |
||
3891 | leency | 187 | cmp eax,1 |
188 | je red |
||
189 | cmp eax,2 |
||
190 | je key |
||
191 | cmp eax,3 |
||
192 | je button |
||
31 | halyavin | 193 | |
7717 | leency | 194 | call check_midnight |
452 | heavyiron | 195 | call draw_clock |
196 | |||
3891 | leency | 197 | jmp still |
31 | halyavin | 198 | |
3889 | leency | 199 | key: |
200 | mcall 2 ; get pressed key |
||
31 | halyavin | 201 | cmp ah,9 |
202 | jne no_tab |
||
203 | .tab: |
||
204 | cmp ebp,FOCUSABLE |
||
5880 | pathoswith | 205 | JAE foc_cycle |
31 | halyavin | 206 | inc [focus] |
207 | upd: |
||
208 | call calculate |
||
209 | jmp red |
||
210 | foc_cycle: |
||
211 | mov [focus],2 |
||
212 | jmp upd |
||
213 | no_tab: |
||
214 | push eax |
||
215 | shr eax,8 |
||
216 | mov ecx,12 |
||
217 | mov edi,Fkeys |
||
218 | repne scasb |
||
219 | pop eax |
||
220 | jnz .noFkey |
||
221 | sub edi,Fkeys+1 |
||
222 | mov [Month],edi |
||
223 | jmp upd |
||
224 | .noFkey: |
||
225 | cmp ebp,2 |
||
226 | jne .nomonth |
||
227 | cmp ah,177 |
||
135 | diamond | 228 | je noclose.drop |
31 | halyavin | 229 | jmp still |
230 | .nomonth: |
||
231 | cmp ebp,3 |
||
135 | diamond | 232 | je noy_up.year_evt |
3890 | leency | 233 | cmp ebp,4 |
31 | halyavin | 234 | jne still |
235 | mov ebx,[day_sel] |
||
135 | diamond | 236 | cmp ah,176 ; left arrow |
6002 | veliant | 237 | jg still |
31 | halyavin | 238 | cmp ah,179 |
6002 | veliant | 239 | jl still |
31 | halyavin | 240 | shr eax,8 |
241 | sub eax,176 |
||
242 | movsx ecx,byte[day_bounds+eax*2] |
||
243 | movzx eax,byte[day_bounds+eax*2+1] |
||
244 | add ecx,ebx |
||
245 | test eax,eax |
||
135 | diamond | 246 | jz .chk0 |
31 | halyavin | 247 | cmp ecx,eax |
135 | diamond | 248 | ja still |
31 | halyavin | 249 | .ok: |
250 | mov [day_sel],ecx |
||
251 | call draw_days |
||
3891 | leency | 252 | jmp still |
31 | halyavin | 253 | .chk0: |
254 | cmp ecx,eax |
||
255 | jle still |
||
256 | jmp .ok |
||
257 | |||
258 | day_bounds db -1,0,7,0,-7,0,1,0 ; left,down,up,right |
||
259 | |||
3889 | leency | 260 | button: |
3891 | leency | 261 | mcall 17 |
31 | halyavin | 262 | movzx ebx,ah |
263 | cmp ah,200 |
||
264 | jbe nodayselect |
||
265 | sub ah,200 |
||
266 | mov byte[day_sel],ah |
||
267 | cmp ebp,5 |
||
268 | jne .redraw |
||
269 | call draw_days |
||
270 | jmp still |
||
271 | .redraw: |
||
3890 | leency | 272 | mov [focus],4 |
31 | halyavin | 273 | jmp red |
274 | nodayselect: |
||
275 | cmp ah,100 |
||
135 | diamond | 276 | jb no_list |
31 | halyavin | 277 | sub ah,100 |
278 | mov byte[Month],ah |
||
279 | mov [focus],2 |
||
280 | jmp upd |
||
281 | no_list: |
||
3891 | leency | 282 | cmp ah,1 |
283 | jne noclose |
||
31 | halyavin | 284 | close: |
3891 | leency | 285 | mcall -1 ; clore programm |
31 | halyavin | 286 | |
287 | noclose: |
||
452 | heavyiron | 288 | |
289 | cmp ah,72 |
||
290 | je plus_he |
||
291 | |||
292 | cmp ah,73 |
||
293 | je plus_hd |
||
294 | |||
295 | cmp ah,74 |
||
296 | je minus_he |
||
297 | |||
298 | cmp ah,75 |
||
299 | je minus_hd |
||
300 | |||
301 | cmp ah,76 |
||
302 | je plus_me |
||
303 | |||
304 | cmp ah,77 |
||
305 | je plus_md |
||
306 | |||
307 | cmp ah,78 |
||
308 | je minus_me |
||
309 | |||
310 | cmp ah,79 |
||
311 | je minus_md |
||
312 | |||
313 | cmp ah,80 |
||
314 | je reset |
||
315 | |||
485 | heavyiron | 316 | cmp ah,81 |
317 | je set_date |
||
452 | heavyiron | 318 | |
135 | diamond | 319 | cmp ah,2 ; drop down list |
31 | halyavin | 320 | jne no_dropdn |
321 | .drop: |
||
322 | mov [focus],2 |
||
135 | diamond | 323 | cmp [dropped],al ; ==0 |
31 | halyavin | 324 | jne red |
325 | call draw_window |
||
326 | mov edx,1 shl 31+231 |
||
327 | mov ecx,31 |
||
328 | mov eax,8 |
||
329 | .bremove: |
||
452 | heavyiron | 330 | mcall |
31 | halyavin | 331 | dec edx |
332 | loop .bremove |
||
333 | call draw_dropdown |
||
334 | jmp still |
||
335 | no_dropdn: |
||
135 | diamond | 336 | cmp ah,3 ; year -1 |
31 | halyavin | 337 | jne noy_dn |
338 | year_dec: |
||
339 | dec [Year] |
||
3890 | leency | 340 | mov [focus],3 |
31 | halyavin | 341 | jmp upd |
342 | noy_dn: |
||
135 | diamond | 343 | cmp ah,4 ; year+1 |
31 | halyavin | 344 | jne noy_up |
345 | year_inc: |
||
346 | inc [Year] |
||
3890 | leency | 347 | mov [focus],3 |
31 | halyavin | 348 | jmp upd |
349 | noy_up: |
||
350 | cmp ah,5 |
||
351 | jne noy_click |
||
352 | mov [focus],3 |
||
353 | call draw_window |
||
354 | .still: |
||
355 | mcall 10 |
||
356 | cmp eax,2 |
||
357 | jne still.evt |
||
358 | mcall 2 |
||
359 | .year_evt: |
||
3890 | leency | 360 | cmp ah,176 |
361 | je year_dec |
||
362 | cmp ah,179 |
||
363 | je year_inc |
||
364 | |||
31 | halyavin | 365 | mov ebx,10 |
366 | cmp ah,9 |
||
135 | diamond | 367 | je key.tab |
368 | cmp ah,8 ; backspace |
||
31 | halyavin | 369 | jne .nobsp |
370 | mov eax,[Year] |
||
371 | xor edx,edx |
||
372 | div ebx |
||
373 | .ch_year: |
||
374 | mov [Year],eax |
||
375 | call draw_year |
||
376 | jmp .still |
||
377 | .nobsp: |
||
135 | diamond | 378 | cmp ah,13 ; enter |
379 | je upd |
||
31 | halyavin | 380 | cmp ah,182 |
135 | diamond | 381 | jne .noclear ; del |
31 | halyavin | 382 | xor eax,eax |
383 | jmp .ch_year |
||
384 | .noclear: |
||
385 | cmp ah,48 |
||
135 | diamond | 386 | jb .still |
31 | halyavin | 387 | cmp ah,57 |
135 | diamond | 388 | ja .still |
31 | halyavin | 389 | cmp [Year],1000 |
390 | jae .still |
||
391 | shr eax,8 |
||
392 | lea ecx,[eax-48] |
||
393 | mov eax,[Year] |
||
394 | imul eax,ebx |
||
395 | add eax,ecx |
||
396 | jmp .ch_year |
||
397 | noy_click: |
||
398 | cmp ah,10 |
||
3891 | leency | 399 | jne START |
31 | halyavin | 400 | xor [new_style],1 |
401 | jmp upd |
||
402 | |||
7902 | leency | 403 | update_clock: |
404 | mcall 22,0x00000000 |
||
405 | call draw_clock |
||
406 | jmp still |
||
31 | halyavin | 407 | |
452 | heavyiron | 408 | reset: |
3890 | leency | 409 | mcall 3 |
452 | heavyiron | 410 | mov ecx,eax |
411 | shl ecx,16 |
||
412 | shr ecx,16 |
||
7902 | leency | 413 | jmp update_clock |
452 | heavyiron | 414 | |
415 | plus_hd: |
||
3889 | leency | 416 | mcall 3 |
452 | heavyiron | 417 | mov ecx,eax |
418 | add ecx,1 |
||
7902 | leency | 419 | jmp update_clock |
452 | heavyiron | 420 | |
421 | plus_he: |
||
3889 | leency | 422 | mcall 3 |
452 | heavyiron | 423 | mov ecx,eax |
424 | add ecx,16 |
||
7902 | leency | 425 | jmp update_clock |
452 | heavyiron | 426 | |
427 | minus_hd: |
||
3889 | leency | 428 | mcall 3 |
452 | heavyiron | 429 | mov ecx,eax |
430 | sub ecx,1 |
||
7902 | leency | 431 | jmp update_clock |
452 | heavyiron | 432 | |
433 | minus_he: |
||
3890 | leency | 434 | mcall 3 |
452 | heavyiron | 435 | mov ecx,eax |
436 | sub ecx,16 |
||
7902 | leency | 437 | jmp update_clock |
452 | heavyiron | 438 | |
439 | plus_md: |
||
3890 | leency | 440 | mcall 3 |
452 | heavyiron | 441 | mov ecx,eax |
442 | add ecx,256 |
||
7902 | leency | 443 | jmp update_clock |
452 | heavyiron | 444 | |
445 | plus_me: |
||
3887 | leency | 446 | mcall 3 |
452 | heavyiron | 447 | mov ecx,eax |
448 | add ecx,4096 |
||
7902 | leency | 449 | jmp update_clock |
452 | heavyiron | 450 | |
451 | minus_md: |
||
3887 | leency | 452 | mcall 3 |
452 | heavyiron | 453 | mov ecx,eax |
454 | sub ecx,256 |
||
7902 | leency | 455 | jmp update_clock |
452 | heavyiron | 456 | |
457 | minus_me: |
||
3887 | leency | 458 | mcall 3 |
452 | heavyiron | 459 | mov ecx,eax |
460 | sub ecx,4096 |
||
7902 | leency | 461 | jmp update_clock |
452 | heavyiron | 462 | |
485 | heavyiron | 463 | set_date: |
464 | mov eax,0x00000000 |
||
465 | mov ebx,[day_sel] |
||
466 | call additem |
||
467 | shl eax,8 |
||
468 | mov ebx,[Month] |
||
469 | add ebx,1 |
||
470 | call additem |
||
471 | shl eax,8 |
||
472 | mov ebx,[Year] |
||
473 | call additem |
||
474 | mov ecx,eax |
||
3890 | leency | 475 | mcall 22,1 |
3895 | leency | 476 | jmp START |
485 | heavyiron | 477 | |
478 | additem: |
||
479 | add eax,1 |
||
480 | daa |
||
481 | sub ebx,1 |
||
482 | cmp ebx,0 |
||
483 | jne additem |
||
484 | ret |
||
485 | |||
486 | |||
31 | halyavin | 487 | ; ********************************************* |
5880 | pathoswith | 488 | ; ******* DRAW WINDOW ******* |
31 | halyavin | 489 | ; ********************************************* |
490 | |||
452 | heavyiron | 491 | draw_clock: |
492 | |||
3887 | leency | 493 | mcall 3 |
452 | heavyiron | 494 | mov ecx,eax |
5880 | pathoswith | 495 | mcall 47,0x00020100, ,195*65536+298,0x50CCCCCC,COL_TOOLBAR_BG |
452 | heavyiron | 496 | |
497 | shr ecx,8 |
||
3894 | heavyiron | 498 | add edx,22*65536 |
452 | heavyiron | 499 | mcall |
500 | |||
501 | shr ecx,8 |
||
3894 | heavyiron | 502 | add edx,22*65536 |
452 | heavyiron | 503 | mcall |
504 | ret |
||
505 | |||
4735 | leency | 506 | define_window: |
31 | halyavin | 507 | |
3889 | leency | 508 | mcall 12,1 |
5880 | pathoswith | 509 | mcall 48, 5 ; GetClientTop, fix for case when @patel in the top |
4880 | leency | 510 | shr ebx, 16 |
511 | mov ecx,ebx |
||
512 | shl ecx,16 |
||
513 | cmp ecx,0 |
||
514 | jne panel_top |
||
515 | ; panel bottom |
||
3895 | leency | 516 | mcall 48,5 ;get screen size |
517 | mov ecx, ebx |
||
518 | sub ecx, WIN_H |
||
519 | shl ecx, 16 |
||
4880 | leency | 520 | panel_top: |
5880 | pathoswith | 521 | add ecx, WIN_H ; [y start] *65536 + [y size] |
3895 | leency | 522 | mov ebx, eax |
523 | sub eax, WIN_W |
||
524 | shl ebx, 16 |
||
525 | add ebx, WIN_W |
||
526 | mcall 0,,,COL_WINDOW_BG, ,title ; define window |
||
4735 | leency | 527 | mcall 12,2 |
3889 | leency | 528 | GetSkinHeight |
529 | mov ecx, eax |
||
530 | shl ecx, 16 |
||
531 | add ecx, 43 |
||
532 | mcall 13,B_WBAR_X, ,COL_TOOLBAR_BG ; draw toolbar background |
||
4196 | Akyltist | 533 | mcall 13,B_WBAR_X,BT_WBAR_Y,COL_TOOLBAR_BG ; draw toolbar background |
4735 | leency | 534 | mcall 13,0*65536+B_WBAR_X,84*65536+199,0xE7E7E7 |
535 | |||
536 | draw_window: |
||
5880 | pathoswith | 537 | call draw_clock |
31 | halyavin | 538 | call draw_week |
5880 | pathoswith | 539 | mcall 8,193*65536+8,285*65536+10,72,COL_TOOLBAR_BG |
3895 | leency | 540 | mov ebx,202*65536+8 |
541 | inc edx ;73 |
||
452 | heavyiron | 542 | mcall |
3895 | leency | 543 | mov ebx,193*65536+8 |
5880 | pathoswith | 544 | mov ecx,315*65536+10 |
3895 | leency | 545 | inc edx ;74 |
452 | heavyiron | 546 | mcall |
3895 | leency | 547 | mov ebx,202*65536+8 |
548 | inc edx ;75 |
||
452 | heavyiron | 549 | mcall |
3895 | leency | 550 | mov ebx,215*65536+8 |
5880 | pathoswith | 551 | mov ecx,285*65536+10 |
3895 | leency | 552 | inc edx ;76 |
452 | heavyiron | 553 | mcall |
3895 | leency | 554 | mov ebx,224*65536+8 |
555 | inc edx ;77 |
||
452 | heavyiron | 556 | mcall |
3895 | leency | 557 | mov ebx,215*65536+8 |
5880 | pathoswith | 558 | mov ecx,315*65536+10 |
3895 | leency | 559 | inc edx ;78 |
452 | heavyiron | 560 | mcall |
3895 | leency | 561 | mov ebx,224*65536+8 |
562 | inc edx ;79 |
||
452 | heavyiron | 563 | mcall |
3895 | leency | 564 | mov ebx,25*65536+110 |
4196 | Akyltist | 565 | mov ecx,293*65536+22 |
566 | mov esi,COL_TOOLBAR_BG |
||
3894 | heavyiron | 567 | mov edx,81 |
485 | heavyiron | 568 | mcall |
569 | |||
5880 | pathoswith | 570 | mov esi,COL_MONTH_YEAR_B ; new style |
31 | halyavin | 571 | mov edx,10 |
135 | diamond | 572 | or edx,1 shl 29+1 shl 30 |
31 | halyavin | 573 | mov ebx,B_NS_X |
574 | mov ecx,B_NS_Y |
||
452 | heavyiron | 575 | mcall |
31 | halyavin | 576 | add edx,1-1 shl 29 |
577 | mov ebx,B_TODAY_X+8*(today_end-today_msg) |
||
578 | mov ecx,B_TODAY_Y |
||
452 | heavyiron | 579 | mcall |
31 | halyavin | 580 | mov ecx,B_Y |
581 | mov ebx,B_MONTH_X |
||
582 | mov edx,2 |
||
452 | heavyiron | 583 | mcall |
3889 | leency | 584 | mov ebx,B_SPIN_X ; < |
31 | halyavin | 585 | inc edx |
452 | heavyiron | 586 | mcall |
6950 | leency | 587 | add ebx,55 shl 16 ; > |
31 | halyavin | 588 | inc edx |
452 | heavyiron | 589 | mcall |
31 | halyavin | 590 | call draw_days |
591 | |||
3891 | leency | 592 | ; draw text in window |
4197 | Akyltist | 593 | mcall 4,157*65536+301,0x80CCCCCC,sys_text |
4196 | Akyltist | 594 | mcall ,211*65536+301,,separator |
595 | mcall ,233*65536+301 |
||
5880 | pathoswith | 596 | mcall ,185*65536+287, ,plus |
597 | mcall ,185*65536+317, ,minus |
||
4196 | Akyltist | 598 | mcall , 35*65536+300,0x00CCCCCC,set_date_t,15 ;set date text |
452 | heavyiron | 599 | |
3887 | leency | 600 | mov ecx,COL_GO_TODAY_T |
31 | halyavin | 601 | mov edx,today_msg |
602 | mov ebx,B_TODAY |
||
603 | mov esi,today_end-today_msg |
||
452 | heavyiron | 604 | mcall |
31 | halyavin | 605 | |
606 | mov ebx,B_SPIN |
||
607 | mov edx,spinner |
||
5880 | pathoswith | 608 | mov esi,8 |
609 | mov ecx,COL_DROPDOWN_T |
||
452 | heavyiron | 610 | mcall |
31 | halyavin | 611 | |
612 | mov edx,[Month] |
||
613 | movzx esi,byte[month_name] |
||
614 | imul edx,esi |
||
615 | add edx,month_name+1 |
||
616 | mov ebx,B_MONTH |
||
617 | ShowFocus 2 |
||
452 | heavyiron | 618 | mcall |
31 | halyavin | 619 | |
620 | call draw_year |
||
621 | mov [dropped],0 |
||
3889 | leency | 622 | ret |
31 | halyavin | 623 | |
624 | draw_year: |
||
625 | ShowFocus 3,esi |
||
626 | mcall 47,0x40001,Year,B_YEAR |
||
627 | ret |
||
628 | |||
629 | draw_dropdown: |
||
630 | mov [dropped],1 |
||
631 | push [Month] |
||
632 | pop [focus] |
||
633 | add [focus],100 |
||
634 | mov ecx,12 |
||
635 | mov edx,100 |
||
636 | push dword month_name+1 |
||
637 | push dword B_DROP |
||
638 | push dword B_Y+16 shl 16 |
||
639 | .ddd_loop: |
||
640 | mov edi,edx |
||
641 | push ecx |
||
3889 | leency | 642 | mov esi,COL_DROPDOWN_BG |
643 | mcall 8,B_MONTH_X,[esp+4] |
||
6950 | leency | 644 | mov eax,4 |
31 | halyavin | 645 | mov ebx,[esp+8] |
646 | xchg edx,[esp+12] |
||
647 | movzx esi,byte[month_name] |
||
648 | ShowFocus edi |
||
452 | heavyiron | 649 | mcall |
31 | halyavin | 650 | add edx,esi |
651 | xchg edx,[esp+12] |
||
652 | add dword[esp+8],16 |
||
653 | add dword[esp+4],16 shl 16 |
||
654 | inc edx |
||
655 | pop ecx |
||
656 | loop .ddd_loop |
||
657 | add esp,12 |
||
658 | ret |
||
659 | |||
660 | draw_week: |
||
661 | mov eax,13 |
||
662 | mov ebx,B_WBAR_X |
||
663 | mov ecx,B_WBAR_Y |
||
3887 | leency | 664 | mov edx,COL_WEEKDAY_BG |
452 | heavyiron | 665 | mcall |
31 | halyavin | 666 | movzx esi,byte[week_days] |
667 | movzx edi,byte[week_days+1] |
||
668 | mov ebx,B_WEEK |
||
669 | mov ecx,7 |
||
670 | mov edx,week_days+2 |
||
671 | mov eax,4 |
||
672 | .week: |
||
673 | push ecx |
||
674 | cmp ecx,edi |
||
135 | diamond | 675 | je .holiday |
31 | halyavin | 676 | mov ecx,0x10000000 |
677 | jmp .noholiday |
||
678 | .holiday: |
||
679 | mov ecx,0x10cc1010 |
||
680 | .noholiday: |
||
452 | heavyiron | 681 | mcall |
31 | halyavin | 682 | add edx,esi |
683 | add ebx,B_WX_SHIFT |
||
684 | pop ecx |
||
685 | loop .week |
||
686 | ret |
||
687 | |||
688 | draw_days: |
||
689 | call count_days |
||
690 | cmp ecx,[day_sel] |
||
691 | jae .ok |
||
692 | mov [day_sel],ecx |
||
693 | .ok: |
||
694 | mov [number],0 |
||
695 | mov eax,47 |
||
696 | mov edx,B_DAYS_Y |
||
3889 | leency | 697 | mov ebx,0x10001 |
31 | halyavin | 698 | mov edi,[firstday] |
5880 | pathoswith | 699 | push ecx |
31 | halyavin | 700 | .dayloop: |
701 | movzx edx,dx |
||
702 | mov esi,edi |
||
703 | shl esi,21 |
||
3889 | leency | 704 | lea edx,[edx+esi+34 shl 16] |
31 | halyavin | 705 | mov ecx,edi |
706 | add cl,[week_days+1] |
||
707 | cmp ecx,7 |
||
135 | diamond | 708 | je .holiday |
3891 | leency | 709 | mov esi,0x10313138 ; COL_DATE_TEXT |
31 | halyavin | 710 | jmp .noholiday |
711 | .holiday: |
||
712 | mov esi,0x10cc1010 |
||
713 | .noholiday: |
||
714 | mov ecx,number |
||
715 | inc dword[ecx] |
||
716 | pusha |
||
5880 | pathoswith | 717 | sub edx,8 shl 16 + 8 |
31 | halyavin | 718 | mov ebx,edx |
3891 | leency | 719 | mov bx,DATE_BUTTON_WIDTH-1 |
31 | halyavin | 720 | shrd ecx,edx,16 |
3891 | leency | 721 | mov cx,DATE_BUTTON_HEIGHT-1 |
31 | halyavin | 722 | mov edx,[number] |
723 | cmp edx,[day_sel] |
||
135 | diamond | 724 | je .draw_sel |
3887 | leency | 725 | mov esi,COL_DATE_BUTTONS |
31 | halyavin | 726 | jmp .draw_but |
5880 | pathoswith | 727 | .draw_sel: ;draw selected button |
3891 | leency | 728 | add edx,1 shl 30 |
729 | add edx,200+1 shl 29 |
||
730 | mcall 8 |
||
3890 | leency | 731 | cmp [focus],4 |
3891 | leency | 732 | jne .not_active |
733 | DrawRect COL_DATE_ACTIVE_1,COL_DATE_ACTIVE_2,COL_DATE_ACTIVE_3,COL_DATE_ACTIVE_4 |
||
3892 | leency | 734 | jmp .out |
3891 | leency | 735 | .not_active: |
736 | DrawRect COL_DATE_INACTIVE_1,COL_DATE_INACTIVE_2,COL_DATE_INACTIVE_3,COL_DATE_INACTIVE_4 |
||
3892 | leency | 737 | jmp .out |
5880 | pathoswith | 738 | .draw_but: ;draw non selected button |
31 | halyavin | 739 | add edx,200+1 shl 29 |
3889 | leency | 740 | mcall 8 |
6950 | leency | 741 | DrawRect COL_DATE_1,COL_DATE_2,COL_DATE_3,COL_DATE_4 |
3891 | leency | 742 | mov eax,[Year] |
743 | cmp [curYear],eax |
||
744 | jne .out |
||
745 | mov eax,[Month] |
||
746 | cmp [curMonth],eax |
||
747 | jne .out |
||
748 | mov eax,[number] |
||
749 | cmp [curDay],eax |
||
750 | jne .out |
||
3892 | leency | 751 | mov edx,0xff0000 |
6950 | leency | 752 | mov bx,DATE_BUTTON_WIDTH-1 |
753 | mov cx,3 |
||
754 | sub ebx,2 shl 16 |
||
755 | sub ecx,1 shl 16 |
||
3892 | leency | 756 | mcall 13 |
3891 | leency | 757 | .out: |
5880 | pathoswith | 758 | mov eax, [number] |
759 | xor edx, edx |
||
760 | mov ecx, 10 |
||
761 | div ecx |
||
762 | mov [remainder], edx |
||
763 | mov [quotient], eax |
||
3889 | leency | 764 | popa |
5880 | pathoswith | 765 | |
766 | ; first number |
||
767 | mov ecx,quotient |
||
3887 | leency | 768 | mcall |
5880 | pathoswith | 769 | add edx,1 shl 16 |
3889 | leency | 770 | mcall |
5880 | pathoswith | 771 | ; second number |
772 | mov ecx,remainder |
||
773 | add edx,8 shl 16 |
||
774 | mcall |
||
775 | add edx,1 shl 16 |
||
776 | mcall |
||
777 | sub edx,10 shl 16 |
||
778 | inc edi |
||
779 | cmp edi,7 |
||
780 | jne .nowrap |
||
781 | xor edi,edi |
||
782 | add dx,B_DAYS_SHIFT |
||
783 | .nowrap: |
||
784 | dec dword [esp] |
||
785 | jnz .dayloop |
||
786 | pop ecx |
||
787 | ret |
||
31 | halyavin | 788 | |
789 | count_days: ; ecx -days in month |
||
790 | call is_leap_year |
||
791 | mov ecx,[Month] |
||
792 | mov eax,1 |
||
793 | movzx ecx,byte[day_count+ecx] |
||
794 | add ecx,28 |
||
795 | cmp eax,[leap_year] |
||
796 | jne .noleap |
||
797 | cmp eax,[Month] |
||
798 | jne .noleap |
||
799 | inc ecx |
||
800 | .noleap: |
||
801 | mov [day_bounds+3],cl |
||
802 | mov [day_bounds+7],cl |
||
803 | ret |
||
804 | |||
805 | is_leap_year: |
||
806 | mov [leap_year],0 |
||
807 | mov eax,[Year] |
||
808 | mov bl,100 |
||
135 | diamond | 809 | div bl ; ah=Year mod 100, al=Year%100 |
31 | halyavin | 810 | test ah,ah |
135 | diamond | 811 | jz .century |
812 | shr ax,8 ; ax - last 2 digits |
||
31 | halyavin | 813 | .century: |
814 | test al,11b |
||
815 | jnz .noleap |
||
816 | inc [leap_year] |
||
817 | .noleap: |
||
818 | ret |
||
819 | |||
820 | calculate: |
||
821 | mov ebx,[Year] |
||
822 | mov eax,[Month] |
||
823 | sub eax,2 |
||
824 | jge .nojf |
||
825 | dec ebx |
||
826 | add eax,12 |
||
827 | .nojf: |
||
828 | add eax,4 |
||
829 | xor edx,edx |
||
830 | mov ecx,153 |
||
831 | imul cx |
||
832 | mov ecx,5 |
||
833 | div cx |
||
834 | inc eax |
||
835 | mov ecx,365 |
||
836 | imul ecx,ebx |
||
837 | add eax,ecx |
||
838 | mov ecx,ebx |
||
839 | shr ecx,2 |
||
840 | add eax,ecx |
||
841 | dec eax |
||
842 | add eax,2 |
||
843 | xchg eax,ebx |
||
844 | mov ecx,100 |
||
845 | xor edx,edx |
||
846 | div cx |
||
847 | sub ebx,eax |
||
848 | shr eax,2 |
||
849 | add ebx,eax |
||
850 | add ebx,5 |
||
851 | mov eax,ebx |
||
852 | xor edx,edx |
||
853 | movzx ebx,byte[week_days+1] |
||
854 | sub eax,ebx |
||
855 | inc eax |
||
856 | mov ebx,7 |
||
857 | div bx |
||
858 | mov [firstday],edx |
||
859 | ret |
||
860 | |||
3889 | leency | 861 | I_END: |