Calendar 1.3: redesign, code update

git-svn-id: svn://kolibrios.org@3889 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2013-09-03 21:16:37 +00:00
parent 8f95eab474
commit 8cea9d046a
2 changed files with 117 additions and 113 deletions

View File

@ -1,51 +1,12 @@
; Calendar for KolibriOS ; Calendar for KolibriOS
; ;
; v1.2 - code update by Leency, small design fixes ; v1.3 - code update, redesign by Leency
; v1.1 - add change time support by DedOK ; v1.1 - add change time support by DedOK
; v1.0 - written in pure assembler by Ivushkin Andrey aka Willow ; v1.0 - written in pure assembler by Ivushkin Andrey aka Willow
; also - diamond, spraid, fedesco ; also - diamond, spraid, fedesco
; ;
; Created: November 1, 2004 ; Created: November 1, 2004
WIN_CW equ 266
WIN_X equ (5000 shl 16+WIN_CW+9)
WIN_Y equ (100 shl 16+335)
LINE1 equ 27 shl 16+16
B_MONTH_X equ 5 shl 16+158+11
B_Y equ LINE1
B_MONTH equ 63 shl 16+32
B_WBAR_X equ 5 shl 16+WIN_CW
B_WBAR_Y equ 64 shl 16+20
B_WEEK equ 30 shl 16+70
B_WX_SHIFT equ 32 shl 16
B_DBAR_X equ B_WBAR_X
B_DBAR_Y equ 85 shl 16+190
B_DROP equ B_MONTH+16
B_DAYS_Y equ 100
B_DAYS_SHIFT equ 30
B_YEAR_X equ 173 shl 16+58
B_YEAR equ 188 shl 16+32
B_TODAY_X equ 25 shl 16
B_TODAY_Y equ 48 shl 16+10
B_TODAY equ 30 shl 16+50
B_SPIN_WIDTH equ 13
B_SPIN_X equ 234 shl 16+B_SPIN_WIDTH
B_SPIN equ 238 shl 16+32
B_NS_X equ 185 shl 16+75
B_NS_Y equ 48 shl 16+10
B_NS equ 190 shl 16+50
FOCUSABLE equ 5
use32 ; ¢ª«îç¨âì 32-¡¨â­ë© ०¨¬  áᥬ¡«¥à  use32 ; ¢ª«îç¨âì 32-¡¨â­ë© ०¨¬  áᥬ¡«¥à 
@ -65,7 +26,7 @@ include 'data.inc'
macro ShowFocus field,reg macro ShowFocus field,reg
{ {
local .nofocus, .exit local .nofocus, .exit
cmp [focus],field cmp [focus],field
@ -78,13 +39,19 @@ macro ShowFocus field,reg
jmp .exit jmp .exit
.nofocus: .nofocus:
if reg eq if reg eq
mov ecx,0x10000000 mov ecx,COL_DROPDOWN_T
else else
mov reg,0x10000000 mov reg,COL_DROPDOWN_T
end if end if
.exit: .exit:
} }
macro GetSkinHeight
{
mov eax,48
mov ebx,4
int 0x40
}
str2int: str2int:
@ -120,9 +87,7 @@ red: ;
still: ; ƒ<E282AC>‰ –ˆŠ‹ <20><>Žƒ<C5BD>€ŒŒ still: ; ƒ<E282AC>‰ –ˆŠ‹ <20><>Žƒ<C5BD>€ŒŒ
mov eax,23 ; wait here for event mcall 23,50 ; wait here for event
mov ebx,50
mcall
.evt: .evt:
mov ebp,[focus] mov ebp,[focus]
cmp eax,1 ; ¯¥à¥à¨á®¢ âì ®ª­® ? cmp eax,1 ; ¯¥à¥à¨á®¢ âì ®ª­® ?
@ -136,9 +101,8 @@ still: ;
jmp still ; ¥á«¨ ¤à㣮¥ ᮡë⨥ - ¢ ­ ç «® 横«  jmp still ; ¥á«¨ ¤à㣮¥ ᮡë⨥ - ¢ ­ ç «® 横« 
key: ; ­ ¦ â  ª« ¢¨è  ­  ª« ¢¨ âãॠkey:
mov eax,2 ; äã­ªæ¨ï 2 - áç¨â âì ª®¤ ᨬ¢®«  mcall 2 ; get pressed key
mcall ; ¢ë§®¢ á¨á⥬ë
cmp ah,9 cmp ah,9
jne no_tab jne no_tab
.tab: .tab:
@ -205,9 +169,8 @@ still: ;
day_bounds db -1,0,7,0,-7,0,1,0 ; left,down,up,right day_bounds db -1,0,7,0,-7,0,1,0 ; left,down,up,right
button: ; ­ ¦ â  ª­®¯ª  ¢ ®ª­¥ ¯à®£à ¬¬ë button:
mov eax,17 ; 17 - ¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨ mcall 17 ; 17 - ¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨
mcall ; ¢ë§®¢ á¨á⥬ë
movzx ebx,ah movzx ebx,ah
cmp ah,200 cmp ah,200
jbe nodayselect jbe nodayselect
@ -360,33 +323,22 @@ reset:
jmp still jmp still
plus_hd: plus_hd:
mcall 3
mov eax,3
mcall
mov ecx,eax mov ecx,eax
add ecx,1 add ecx,1
mov eax,22 mov eax,22
mov ebx,0x00000000 mcall 22,0x00000000
mcall
jmp still jmp still
plus_he: plus_he:
mcall 3
mov eax,3
mcall
mov ecx,eax mov ecx,eax
add ecx,16 add ecx,16
mov eax,22 mcall 22,0x00000000
mov ebx,0x00000000
mcall
jmp still jmp still
minus_hd: minus_hd:
mcall 3
mov eax,3
mcall
mov ecx,eax mov ecx,eax
sub ecx,1 sub ecx,1
mov eax,22 mov eax,22
@ -494,13 +446,13 @@ draw_clock:
draw_window: draw_window:
mcall 12,1 ; äã­ªæ¨ï 12: á®®¡é¨âì Ž‘ ®¡ ®âà¨á®¢ª¥ ®ª­  mcall 12,1
xor eax,eax ; äã­ªæ¨ï 0 : ®¯à¥¤¥«¨âì ¨ ®âà¨á®¢ âì ®ª­® mcall 0,WIN_X,WIN_Y-15,COL_WINDOW_BG, ,title ; define window
mov ebx,WIN_X GetSkinHeight
mov ecx,WIN_Y-15 mov ecx, eax
mov edx,COL_WINDOW_BG ; 梥â à ¡®ç¥© ®¡« á⨠RRGGBB,8->color gl shl ecx, 16
mov edi,title ; § £®«®¢®ª add ecx, 43
mcall mcall 13,B_WBAR_X, ,COL_TOOLBAR_BG ; draw toolbar background
call draw_week call draw_week
mcall 8,205*65536+7,290*65536+10,72,COL_TIME_BUTTONS mcall 8,205*65536+7,290*65536+10,72,COL_TIME_BUTTONS
@ -518,36 +470,36 @@ draw_window:
inc edx inc edx
mcall mcall
mov ebx,224*65536+7 mov ebx,225*65536+7
mov ecx,290*65536+10 mov ecx,290*65536+10
inc edx inc edx
mcall mcall
mov ebx,231*65536+7 mov ebx,232*65536+7
inc edx inc edx
mcall mcall
mov ebx,224*65536+7 mov ebx,225*65536+7
mov ecx,300*65536+10 mov ecx,300*65536+10
inc edx inc edx
mcall mcall
mov ebx,231*65536+7 mov ebx,232*65536+7
inc edx inc edx
mcall mcall
mov ebx,243*65536+14 mov ebx,244*65536+14
mov ecx,290*65536+20 mov ecx,290*65536+20
inc edx inc edx
mcall mcall
mov ebx,14*65536+110 mov ebx,14*65536+110
mov ecx,285*65536+22 mov ecx,285*65536+22
mov esi,0x00d5d5d5 mov esi,COL_DATE_BUTTONS
inc edx inc edx
mcall mcall
mov esi,COL_MONTH_YEAR_B mov esi,COL_MONTH_YEAR_B ; new style
mov edx,10 mov edx,10
or edx,1 shl 29+1 shl 30 or edx,1 shl 29+1 shl 30
mov ebx,B_NS_X mov ebx,B_NS_X
@ -561,10 +513,10 @@ draw_window:
mov ebx,B_MONTH_X mov ebx,B_MONTH_X
mov edx,2 mov edx,2
mcall mcall
mov ebx,B_SPIN_X mov ebx,B_SPIN_X ; <
inc edx inc edx
mcall mcall
add ebx,B_SPIN_WIDTH shl 16 add ebx,61 shl 16 ; >
inc edx inc edx
mcall mcall
call draw_days call draw_days
@ -597,7 +549,7 @@ draw_window:
mov ebx,B_SPIN mov ebx,B_SPIN
mov edx,spinner mov edx,spinner
mov esi,3 mov esi,12
ShowFocus 4 ShowFocus 4
mcall mcall
@ -612,7 +564,7 @@ draw_window:
call draw_year call draw_year
mov [dropped],0 mov [dropped],0
mcall 12,2 mcall 12,2
ret ; ¢ë室¨¬ ¨§ ¯à®æ¥¤ãàë ret
draw_year: draw_year:
mcall 8,B_YEAR_X,B_Y,5,COL_MONTH_YEAR_B mcall 8,B_YEAR_X,B_Y,5,COL_MONTH_YEAR_B
@ -633,11 +585,8 @@ draw_dropdown:
.ddd_loop: .ddd_loop:
mov edi,edx mov edi,edx
push ecx push ecx
mov ebx,B_MONTH_X mov esi,COL_DROPDOWN_BG
mov ecx,[esp+4] mcall 8,B_MONTH_X,[esp+4]
mov esi,0x6f9fef
mov eax,8
mcall
shr eax,1 shr eax,1
mov ebx,[esp+8] mov ebx,[esp+8]
xchg edx,[esp+12] xchg edx,[esp+12]
@ -683,11 +632,6 @@ draw_week:
ret ret
draw_days: draw_days:
mov eax,13
mov ebx,B_DBAR_X
mov ecx,B_DBAR_Y
mov edx,COL_DATES_BG
mcall
call count_days call count_days
cmp ecx,[day_sel] cmp ecx,[day_sel]
jae .ok jae .ok
@ -696,19 +640,19 @@ draw_days:
mov [number],0 mov [number],0
mov eax,47 mov eax,47
mov edx,B_DAYS_Y mov edx,B_DAYS_Y
mov ebx,0x20001 mov ebx,0x10001
mov edi,[firstday] mov edi,[firstday]
.dayloop: .dayloop:
push ecx push ecx
movzx edx,dx movzx edx,dx
mov esi,edi mov esi,edi
shl esi,21 shl esi,21
lea edx,[edx+esi+29 shl 16] lea edx,[edx+esi+34 shl 16]
mov ecx,edi mov ecx,edi
add cl,[week_days+1] add cl,[week_days+1]
cmp ecx,7 cmp ecx,7
je .holiday je .holiday
mov esi,0x10000000 mov esi,0x10000000 ; COL_DATE_TEXT
jmp .noholiday jmp .noholiday
.holiday: .holiday:
mov esi,0x10cc1010 mov esi,0x10cc1010
@ -734,13 +678,31 @@ draw_days:
mov esi,COL_DATE_CHANGED mov esi,COL_DATE_CHANGED
.draw_but: .draw_but:
add edx,200+1 shl 29 add edx,200+1 shl 29
mov eax,8 mcall 8
mcall mov eax, [number]
popa xor edx, edx
mcall mov ecx, 10
div ecx
mov [remainder], edx
mov [quotient], eax
popa
;first number
mov ecx,quotient
mcall
add edx,1 shl 16 add edx,1 shl 16
mcall mcall
sub edx,1 shl 16 sub edx,1 shl 16
;second number
mov ecx,remainder
add edx,9 shl 16
mcall
add edx,1 shl 16
mcall
sub edx,10 shl 16
pop ecx pop ecx
inc edi inc edi
cmp edi,7 cmp edi,7
@ -830,7 +792,8 @@ calculate:
mov [firstday],edx mov [firstday],edx
ret ret
I_END: ; ª®­¥æ ¯à®£à ¬¬ë I_END:
firstday dd ? firstday dd ?
Year dd ? Year dd ?
Month dd ? Month dd ?

View File

@ -1,17 +1,59 @@
; program data: colors, text, vars (todo) ; program data: colors, text, vars (todo)
; colors ; colors
COL_WINDOW_BG equ 0x14aabbcc COL_WINDOW_BG equ 0x14E7E7E7
COL_TOOLBAR_BG equ 0x555555
COL_WEEKDAY_BG equ 0xCCCDDD COL_WEEKDAY_BG equ 0xCCCDDD
COL_DATES_BG equ 0xE7E7E7 COL_DATE_BUTTONS equ 0xF3F3F3
COL_DATE_BUTTONS equ 0xE7E7E7
COL_DATE_CURRENT equ 0x31A4D0 COL_DATE_CURRENT equ 0x31A4D0
COL_DATE_CHANGED equ 0xef7840 COL_DATE_CHANGED equ 0xef7840
COL_TIME_BUTTONS equ 0x5555dd COL_TIME_BUTTONS equ 0x5555dd
COL_GO_TODAY_T equ 0xd048c8 COL_GO_TODAY_T equ 0xd048c8
COL_MONTH_YEAR_B equ 0x05080d0 COL_MONTH_YEAR_B equ 0x0555555 ; 0 for time?
COL_DROPDOWN_BG equ 0x666666
COL_DROPDOWN_T equ 0x10CCCccc
COL_NEW_STYLE_T equ 0xac0000 COL_NEW_STYLE_T equ 0xef3333
remainder dd 1
quotient dd 1
; definitions
WIN_CW equ 266
WIN_X equ (5000 shl 16+WIN_CW+9)
WIN_Y equ (100 shl 16+335)
LINE1 equ 27 shl 16+16
B_MONTH_X equ 15 shl 16+158
B_Y equ LINE1
B_MONTH equ 63 shl 16+32
B_WBAR_X equ 5 shl 16+WIN_CW
B_WBAR_Y equ 64 shl 16+20
B_WEEK equ 34 shl 16+70
B_WX_SHIFT equ 32 shl 16
B_DROP equ B_MONTH+16
B_DAYS_Y equ 106
B_DAYS_SHIFT equ 30
B_YEAR_X equ 198 shl 16+46
B_YEAR equ 206 shl 16+32
B_SPIN_WIDTH equ 13
B_SPIN_X equ 184 shl 16+B_SPIN_WIDTH
B_SPIN equ 188 shl 16+32
spinner db '< >'
B_TODAY_X equ 25 shl 16
B_TODAY_Y equ 48 shl 16+10
B_TODAY equ 30 shl 16+50
B_NS_X equ 185 shl 16+75
B_NS_Y equ 48 shl 16+10
B_NS equ 190 shl 16+50
FOCUSABLE equ 5
; multilanguage interface - configuratable in lang.inc ; multilanguage interface - configuratable in lang.inc
day_count db 3,0,3,2,3,2,3,3,2,3,2,3 day_count db 3,0,3,2,3,2,3,3,2,3,2,3
@ -117,7 +159,6 @@ else
db 'November ' db 'November '
db 'December ' db 'December '
end if end if
spinner db '< >'
week_days: week_days:
if lang eq ru if lang eq ru
db 2 db 2
@ -191,7 +232,7 @@ else
db 'Sat' db 'Sat'
end if end if
title: ; áâப  § £®«®¢ª  title:
if lang eq ru if lang eq ru
db 'Š «¥­¤ àì',0 db 'Š «¥­¤ àì',0
else if lang eq ge else if lang eq ge
@ -254,7 +295,7 @@ set_date_t:
if lang eq ru if lang eq ru
db '“áâ ­®¢¨âì ¤ âã',0 db '“áâ ­®¢¨âì ¤ âã',0
else if lang eq it else if lang eq it
db 'Impostazioni',0 db ' Impostazioni ',0
else else
db '“áâ ­®¢¨âì ¤ âã',0 db ' Set date ',0
end if end if