Calendar 1.4

git-svn-id: svn://kolibrios.org@3891 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2013-09-05 22:19:50 +00:00
parent dcc2877e84
commit 6d61491177
2 changed files with 143 additions and 44 deletions

View File

@ -1,6 +1,6 @@
; Calendar for KolibriOS
;
; v1.35 - code update, redesign by Leency
; v1.2 - v1.4 - new desighn and functionality by Leency
; v1.1 - add change time support by DedOK
; v1.0 - written in pure assembler by Ivushkin Andrey aka Willow
; also - diamond, spraid, fedesco
@ -8,20 +8,20 @@
; Created: November 1, 2004
use32 ; ¢ª«îç¨âì 32-¡¨â­ë© ०¨¬  áᥬ¡«¥à 
use32
org 0x0 ;  ¤à¥á æ¨ï á ­ã«ï
org 0x0
db 'MENUET01' ; 8-¡ ©â­ë© ¨¤¥­â¨ä¨ª â®à MenuetOS
dd 0x01 ; ¢¥àá¨ï § £®«®¢ª  (¢á¥£¤  1)
dd start ;  ¤à¥á ¬¥âª¨, á ª®â®à®© ­ ç¨­ ¥âáï ¢ë¯®«­¥­¨¥ ¯à®£à ¬¬
dd I_END ; à §¬¥à ¯à®£à ¬¬ë
dd 0x1000 ; ª®«¨ç¥á⢮ ¯ ¬ïâ¨
dd 0x1000 ;  ¤à¥á ¢¥à設ë áâíª 
dd 0x0 ;  ¤à¥á ¡ãä¥à  ¤«ï áâப¨ ¯ à ¬¥â஢ (­¥ ¨á¯®«ì§ã¥âáï)
dd 0x0 ; § à¥§¥à¢¨à®¢ ­®
db 'MENUET01'
dd 0x01
dd START
dd I_END
dd 0x1000
dd 0x1000
dd 0x0
dd 0x0
include '..\..\..\macros.inc'
include 'lang.inc'
include '..\..\..\macros.inc' ; 㬥­ìè ¥â à §¬¥à ¯à®£à ¬¬ë
include 'data.inc'
@ -53,6 +53,68 @@ macro GetSkinHeight
int 0x40
}
macro DrawRect color1,color2,color3,color4 ; pizdec... but optimized well
{
; top border-outer
push ebx
push ecx
mov eax,13
mov bx,DATE_BUTTON_WIDTH
mov edx,color1
mov cx,1
mcall
; left border-outer
mov bx,1
mov cx,DATE_BUTTON_HEIGHT
mcall
; top border-inner
mov edx,color2
add ebx,1 shl 16
add ecx,1 shl 16
mov bx,DATE_BUTTON_WIDTH-1
mov cx,1
; left border-inner
mcall
mov bx,1
mov cx,DATE_BUTTON_HEIGHT-2
mcall
; inner
mov edx,color3
add ebx,1 shl 16
add ecx,1 shl 16
mov bx,DATE_BUTTON_WIDTH-4
mov cx,DATE_BUTTON_HEIGHT-4
mcall
; bottom border-inner
mov edx,color4
add ebx,DATE_BUTTON_WIDTH shl 16
sub ebx,4 shl 16
mov bx,1
mov cx,DATE_BUTTON_HEIGHT-3
mcall
; rgiht border-outer
mov edx,color2
add ebx,1 shl 16
sub ecx,1 shl 16
add cx,1
mcall
; bottom border-outer
mov edx,color2
pop ecx
pop ebx
add ecx,DATE_BUTTON_HEIGHT shl 16
sub ecx,1 shl 16
add ebx,1 shl 16
mov cx,1
mcall
; left border-outer
mov edx,color4
add ebx,1 shl 16
sub ecx,1 shl 16
sub bx,2
mcall
}
str2int:
xor eax,eax
@ -64,7 +126,7 @@ str2int:
add al,bl
ret
start:
START:
mcall 29
mov [datestr],eax
mov esi,datestr
@ -79,27 +141,33 @@ start:
test byte[esi],0
jnz .no2000
add [Year],100
mov eax,[Year]
mov [curYear], eax
mov eax,[Month]
mov [curMonth], eax
mov eax,[day_sel]
mov [curDay], eax
.no2000:
jmp upd ; §¤¥áì ­ ç¨­ ¥âáï ¢ë¯®«­¥­¨¥ ¯à®£à ¬¬ë
red: ; ¯¥à¥à¨á®¢ âì ®ª­®
jmp upd
red:
call draw_window
still: ; ƒ<E282AC>‰ –ˆŠ‹ <20><>Žƒ<C5BD>€ŒŒ
still:
mcall 23,50 ; wait here for event
.evt:
mov ebp,[focus]
cmp eax,1 ; ¯¥à¥à¨á®¢ âì ®ª­® ?
je red ; ¥á«¨ ¤  - ­  ¬¥âªã red
cmp eax,2 ; ­ ¦ â  ª« ¢¨è  ?
je key ; ¥á«¨ ¤  - ­  key
cmp eax,3 ; ­ ¦ â  ª­®¯ª  ?
je button ; ¥á«¨ ¤  - ­  button
cmp eax,1
je red
cmp eax,2
je key
cmp eax,3
je button
call draw_clock
jmp still ; ¥á«¨ ¤à㣮¥ ᮡë⨥ - ¢ ­ ç «® 横« 
jmp still
key:
mcall 2 ; get pressed key
@ -154,7 +222,7 @@ still: ;
.ok:
mov [day_sel],ecx
call draw_days
jmp still ; ¢¥à­ãâìáï ª ­ ç «ã 横« 
jmp still
.chk0:
cmp ecx,eax
jle still
@ -163,7 +231,7 @@ still: ;
day_bounds db -1,0,7,0,-7,0,1,0 ; left,down,up,right
button:
mcall 17 ; 17 - ¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨
mcall 17
movzx ebx,ah
cmp ah,200
jbe nodayselect
@ -184,11 +252,10 @@ day_bounds db -1,0,7,0,-7,0,1,0 ; left,down,up,right
mov [focus],2
jmp upd
no_list:
cmp ah,1 ; ¨¤¥­â¨ä¨ª â®à == 1 ?
jne noclose ; ¥á«¨ ­¥â - ¨¤¨ ¢¯¥àñ¤ ­  noclose
cmp ah,1
jne noclose
close:
or eax,-1 ; ¢ë室 ¨§ ¯à®£à ¬¬ë
mcall ; ¢ë§®¢ á¨á⥬ë
mcall -1 ; clore programm
noclose:
@ -302,7 +369,7 @@ day_bounds db -1,0,7,0,-7,0,1,0 ; left,down,up,right
jmp .ch_year
noy_click:
cmp ah,10
jne start
jne START
xor [new_style],1
jmp upd
@ -396,7 +463,7 @@ additem:
; *********************************************
; ******* Ž<EFBFBD><EFBFBD>…„…<EFBFBD>ˆˆ Ž<C5BD>ˆŽŠ€ ŽŠ<C5BD> *******
; ******* DRAW WINDOW *******
; *********************************************
draw_clock:
@ -491,14 +558,13 @@ draw_window:
mcall
call draw_days
; äã­ªæ¨ï 4 : ­ ¯¨á âì ¢ ®ª­¥ ⥪áâ
; draw text in window
mcall 4,162*65536+280,0x800000ff,sys_text
mcall ,180*65536+302,0x800000ff,minus
mcall ,180*65536+292,0x80ff0000,plus
mcall , 24*65536+292,0x00000000,set_date_t,15 ;set date text
mov ecx,0x10ddeeff ; èà¨äâ 1 ¨ 梥â ( 0xF0RRGGBB )
mov ecx,0x10ddeeff
mov edx,n_style
mov esi,ns_end-n_style
mov ebx,B_NS
@ -622,7 +688,7 @@ draw_days:
add cl,[week_days+1]
cmp ecx,7
je .holiday
mov esi,0x10000000 ; COL_DATE_TEXT
mov esi,0x10313138 ; COL_DATE_TEXT
jmp .noholiday
.holiday:
mov esi,0x10cc1010
@ -631,24 +697,44 @@ draw_days:
inc dword[ecx]
pusha
mov ebx,edx
mov bx,31 ; width
mov bx,DATE_BUTTON_WIDTH-1
sub ebx,8 shl 16
shrd ecx,edx,16
mov cx,29 ; height
mov cx,DATE_BUTTON_HEIGHT-1
sub ecx,12 shl 16
mov edx,[number]
cmp edx,[day_sel]
je .draw_sel
mov esi,COL_DATE_BUTTONS
jmp .draw_but
.draw_sel:
mov esi,COL_DATE_INACTIV
.draw_sel: ;draw selected button
add edx,1 shl 30
add edx,200+1 shl 29
mcall 8
cmp [focus],4
jne .draw_but
mov esi,COL_DATE_ACTIVE
.draw_but:
jne .not_active
DrawRect COL_DATE_ACTIVE_1,COL_DATE_ACTIVE_2,COL_DATE_ACTIVE_3,COL_DATE_ACTIVE_4
jmp .after_draw_but
.not_active:
DrawRect COL_DATE_INACTIVE_1,COL_DATE_INACTIVE_2,COL_DATE_INACTIVE_3,COL_DATE_INACTIVE_4
jmp .after_draw_but
.draw_but: ;draw non selected button
add edx,200+1 shl 29
mcall 8
.after_draw_but:
mov eax,[Year]
cmp [curYear],eax
jne .out
mov eax,[Month]
cmp [curMonth],eax
jne .out
mov eax,[number]
cmp [curDay],eax
jne .out
;DrawRect COL_DATE_INACTIVE_1,COL_DATE_INACTIVE_2,COL_DATE_INACTIVE_3,COL_DATE_INACTIVE_4
.out:
mov eax, [number]
xor edx, edx
mov ecx, 10

View File

@ -1,4 +1,10 @@
; program data: colors, text, vars
DATE_BUTTON_WIDTH equ 32
DATE_BUTTON_HEIGHT equ 30
curMonth dd ?
curYear dd ?
curDay dd ?
; colors
COL_WINDOW_BG equ 0x14E7E7E7
@ -6,8 +12,6 @@ COL_TOOLBAR_BG equ 0x555555
COL_ACTIVE_TEXT equ 0x10e7c750
COL_WEEKDAY_BG equ 0xCCCDDD
COL_DATE_BUTTONS equ 0xF3F3F3
COL_DATE_INACTIV equ 0x31A4D0
COL_DATE_ACTIVE equ COL_ACTIVE_TEXT
COL_TIME_BUTTONS equ 0x5555dd
COL_GO_TODAY_T equ 0xd048c8
COL_MONTH_YEAR_B equ 0x0555555 ; 0 for time?
@ -15,6 +19,15 @@ COL_DROPDOWN_BG equ 0x666666
COL_DROPDOWN_T equ 0x10CCCccc
COL_NEW_STYLE_T equ 0xef3333
COL_DATE_INACTIVE_1 equ 0x1585B8
COL_DATE_INACTIVE_2 equ 0x4EA4CA
COL_DATE_INACTIVE_3 equ 0x5FB2D6
COL_DATE_INACTIVE_4 equ 0x81C1DE
COL_DATE_ACTIVE_1 equ 0xBB8C00
COL_DATE_ACTIVE_2 equ 0xEAB10F
COL_DATE_ACTIVE_3 equ 0xF7C22D
COL_DATE_ACTIVE_4 equ 0xF7CB4B
remainder dd 1
quotient dd 1