@@ -1,4 +1,4 @@
VERSION equ "0.5 "
; VERSION equ "v1.0 "
use32
org 0
@@ -14,22 +14,32 @@
;===============================
LIST_ITEM_SIZE equ 16
LIST_ITEM_COUNT equ 6
LIST_SIZE equ LIST_ITEM_SIZE * LIST_ITEM_COUNT
LIST_ITEM_COLOR1 equ dword [ scn.btn_face ]
LIST_ITEM_COLOR2 equ dword [ scn.win_face ]
LIST_ITEM_TEXT1 equ dword [ scn.btn_text ]
LIST_ITEM_TEXT2 equ dword [ scn.win_text ]
LIST_ITEM_Y equ LIST_ITEM_SIZE / 2 - 3
LIST_X = 5
LIST_Y = 43
LIST_ITEM_H = 26
LIST_ITEM_W = 320 - 25
LIST_ITEM_COUNT = 8
LIST_H = LIST_ITEM_H * LIST_ITEM_COUNT
LIST_TEXT_Y = LIST_ITEM_H / 2 - 8
KEYB_SIZE equ 140
KEYB_BTN_W = 37
KEYB_BTN_H = 37
GAP = 5
sz_cont db "Keyboard " , 0x1 0
sz_head db "Calc+ v" , VERSION , 0
KEYBOARD_X = LIST_ITEM_W + 2 0
KEYBOARD_Y = LIST_Y
KEYBOARD_W = 190
WIN_W = LIST_ITEM_W + 16 + KEYBOARD_W
WIN_H = LIST_H + 58
LIST_ITEM_TEXT1 equ dword [ sc.work_text ]
LIST_ITEM_TEXT2 equ dword [ sc.work_text ]
sz_head db "Calc+" , 0
btn_clr db " "
buttons db "|%^*/-+)(=7894561230"
edb1 edi t_box 0 , 8 , 12 , 0 , 0 , 0 , 0 , 0, 480 , \
edb1 edi t_box 0 , 8 , 12 , 0xffffff , 0x94AECE , 0xffc90E , 0xCACACA , 0x1000000 0, 480 , \
exp , group , ed_always_focus + ed_focus , 0 , 0
imports:
@@ -42,16 +52,14 @@
main:
mov [ ans.buffer ], dword "= 0"
mov [ ans.size ], 3 * 6 + 9
mov [ ans.size ], 3 * 8 + 9
mcall 40 , 100111b
; mcall 48, 3, scn, 192
mcall 40 , EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE
m2m [ edb1.color ], [ scn.gui_face ]
m2m [ edb1.shift_color ], [ scn.gui_select ]
m2m [ edb1.focus_border_color ], [ scn.gui_face ]
m2m [ edb1.text_color ], [ scn.gui_text ]
m2m [ edb1.color ], [ scn.gui_face ]
; m2m [ edb1.shift_color], [ scn.gui_select ]
; m2m [ edb1.focus_border_color], [scn.gui_face ]
; m2m [ edb1.text_color], [ scn.gui_text ]
mcall 68 , 11
stdcall dl l.Load , imports
@@ -76,17 +84,23 @@
ev_redraw:
mcall 12 , 1
mcall 48 , 3 , sc , si zeof.system_colors
; WINDOW
mov edx , [ scn .win_face ]
or edx , 0x34 shl 24
mcall 0 , < 100 , 236 + 100 - 50 - 25 > , < 100 , 66 + LIST_SIZE > , , , sz_head
mov edx , [ sc.work ]
or edx , 0x34 shl 24
; TOOLBAR
mov eb x , 1 20 shl 16 + 64
mcall 8 , , <- 17 , 12 > , 2 + 1 shl 30
add ebx , 4 shl 16 - ( 64 + 14 )
mcall 4 , , [ scn.win_title ], sz_cont , 10
mcall 48 , 4 ;get skin_h
mov ec x , 20 0 shl 16 + WIN_H
add ecx , eax ; add skin_h to WIN_H
mcall 14 ; get screen size
shr eax , 16
mov ebx , eax
sub ebx , WIN_W
shr ebx , 1
mcall 0 , < ebx , WIN_W > , , , , sz_head
; CONTENT
call draw_textbox
@@ -117,7 +131,12 @@
cmp ah , 1
je exit
cmp ah , 250
jne @ f
mcall 70 , f70_calc
jmp update
; DELETE
@ @ :
cmp ah , 4
jne .not_del
cmp [ edb1.pos ], 0
@@ -142,25 +161,6 @@
jmp .redraw
.not_del:
; SHOW/HIDE KEYBOARD
cmp ah , 2
jne .not_keyb
cmp [ keyb ], byte 0
je .open
mov [ keyb ], 0
mov [ sz_cont + 9 ], byte 0x10
mcall 67 , - 1 , - 1 , 286 - 25 , - 1
jmp update
.open:
mov [ keyb ], 1
mov [ sz_cont + 9 ], byte 0x11
mcall 67 , - 1 , - 1 , 286 - 25 + KEYB_SIZE , - 1
jmp update
.not_keyb:
; CALCULATE
cmp ah , 19
je calc
@@ -275,7 +275,7 @@
stdcall convert_to_str , eax , ans.buffer + 2
add eax , 2
mov edi , eax
imul eax , 6
imul eax , 8 ;char_w
add eax , 9
mov [ ans.size ], eax
@@ -301,7 +301,6 @@
stdcall str_cpy , ans.buffer , history + 480
mov esi , [ ans.size ]
mov dword [ history + 508 ], esi
not [ his_even ]
; Check length
mov esi , 37
@@ -330,7 +329,7 @@
mov [ ans.buffer + 4 ], dword "cted"
mov [ ans.buffer + 8 ], dword " ')'"
mov [ ans.buffer + 12 ], byte 0
mov [ ans.size ], 8 1
mov [ ans.size ], 105
cmp [ error_n ], 2
je .redraw
@@ -343,14 +342,14 @@
mov [ ans.buffer + 4 ], dword " by "
mov [ ans.buffer + 8 ], byte "0"
mov [ ans.buffer + 9 ], byte 0
mov [ ans.size ], 63
mov [ ans.size ], 81
jmp .redraw
.err_4:
mov [ ans.buffer + 0 ], dword "Inpu"
mov [ ans.buffer + 4 ], dword "t er"
mov [ ans.buffer + 8 ], dword "rror"
mov [ ans.buffer + 12 ], byte 0
mov [ ans.size ], 8 1
mov [ ans.size ], 105
jmp .redraw
.err_3:
mov [ ans.buffer + 10 ], byte "("
@@ -366,62 +365,43 @@
;----------------------
proc draw_button , x , y
mcall 8 , < [ x ], 30 > , < [ y ], 21 > , [ but_id ], [ but_c ]
mov ebx , [ x ]
mov esi , [ txt_size ]
imul esi , 3
mov edi , 16
sub edi , esi
add ebx , edi
shl ebx , 16
add ebx , [ y ]
add ebx , 7
mcall 4 , , [ but_tc ], [ txt_id ], [ txt_size ]
mov eax , [ txt_size ]
add [ txt_id ], eax
inc dword [ but_id ]
ret
endp
;----------------------
proc draw_textbox
mcall 13 , < 4 , 320 - 50 - 25 > , < 8 , 23 > , [ scn.gui_frame ]
; border
mcall 13 , < LIST_X , LIST_ITEM_W > , < 8 , 30 > , [ sc.work_graph ]
; background
mov edx , [ scn.gui_face ]
cmp [ error_n ], 0
je @ f
mov edx , 0xFFAAAA
@ @ :
mcall 13 , < 5 , 318 - 50 - 25 > , < 9 , 21 >
mcall , < 5 , 318 - 50 - 25 > , < 9 , 1 > , [ scn.3d_face ]
mcall , < 5 , 1 > , < 10 , 20 >
mcall , < 5 , 318 - 50 - 25 > , < 31 , 1 > , [ scn.3d _light ]
mcall 13 , < LIST_X + 1 , LIST_ITEM_W - 2 > , < 9 , 28 >
mcall , < LIST_X + 1 , LIST_ITEM_W - 2 > , < 9 , 1 > , [ scn.text_box_inner_shadow ]
mcall , < LIST_X + 1 , 1 > , < 10 , 27 >
mcall , < LIST_X , LIST_ITEM_W - 1 > , < 38 , 1 > , [ sc.work _light ]
mov ebx , 328 - 16 - 50 - 25
mov ebx , LIST_X + LIST_ITEM_W - 12
sub ebx , [ ans.size ]
shl ebx , 16
add ebx , 16
mov ecx , [ scn.gui_intext ]
or ecx , 1 shl 31
add ecx , 0x10000000
or ecx , 1 shl 31
mcall 4 , , , ans.buffer
mov ecx , [ scn.gui_text ]
mcall , < 310 - 50 - 25 , 16 > , , btn_clr , 1
mcall , < LIST_ITEM_W - 8 , 19 > , [ scn.gui_in text ], btn_clr , 1
add ebx , 1 shl 16
mcall
mcall 8 , < 305 - 50 - 25 , 17 > , < 9 , 20 > , 0x40000004
mcall 8 , < LIST_ITEM_W - 14 , 17 > , < 9 , 27 > , 4 + BT_HIDE
mcall 1 , 4 , 8 , [ scn.win_body ]
mcall , 323 - 50 - 25
mcall , , 30 , [ scn.3d_light ]
mcall , 4
; dots to fake border radius
; mcall 1, 4, 8, [sc.work]
; mcall , LIST_ITEM_W + 3
; mcall , , 37, [sc.work_light]
; mcall , 4
mov ebx , 318 - 16 - 50 - 25
mov ebx , LIST_ITEM_W - 18
sub ebx , [ ans.size ]
cmp ebx , 24
jg @ f
@@ -442,109 +422,133 @@
;----------------------
proc draw_button , x , y
mcall 8 , < [ x ], KEYB_BTN_W > , < [ y ], KEYB_BTN_H > , [ but_id ], [ but_c ]
mov ebx , [ x ]
add ebx , KEYB_BTN_W / 2 - 4
;mov esi, [txt_size] ;the text potentially could have valiable len
;imul esi, 4
;mov edi, 16
;add ebx, edi
shl ebx , 16
add ebx , [ y ]
add ebx , KEYB_BTN_H / 2 - 6
or [ but_tc ], 0x01000000 ;use bigger font
mcall 4 , , [ but_tc ], [ txt_id ], [ txt_size ]
mov eax , [ txt_size ]
add [ txt_id ], eax
inc dword [ but_id ]
ret
endp
;----------------------
if lang eq ru_RU
engineering_str db "Engineering calc"
engineering_len = 16
else
engineering_str db "<22> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ० <> <E0A5A6> "
engineering_len = 16
endf
proc draw_keyb
cmp [ keyb ], byte 0
je @ f
mcall 8 , < KEYBOARD_X , ( KEYB_BTN_W + GAP ) * 4 - GAP > , < 8 , 29 > , 250 , [ sc.work_light ]
mov ecx , [ sc.work_text ]
or ecx , 0x10000000
mcall 4 , < ( KEYB_BTN_W + GAP - engineering_len * 2 ) * 2 - GAP / 2 + KEYBOARD_X , KEYB_BTN_H / 2 - 10 + 8 > , , engineering_str , engineering_len
mov [ txt_size ], 1
mov [ but_id ], 0x0000000A
mov [ txt_id ], buttons
mov eax , [ scn .win_face ]
mov [ but_c ], eax
mov eax , [ scn.win_text ]
mov [ but_tc ] , eax
stdcall draw_button , 4 + 278 - 25 , 42 - 25 - 8
stdcall draw_button , 37 + 278 - 25 , 42 - 25 - 8
stdcall draw_button , 70 + 278 - 25 , 42 - 25 - 8
stdcall draw_button , 103 + 278 - 25 , 42 - 25 - 8
stdcall draw_button , 103 + 278 - 25 , 66 - 25 - 8
stdcall draw_button , 103 + 278 - 25 , 90 - 25 - 8
stdcall draw_button , 103 + 278 - 25 , 114 - 25 - 8
stdcall draw_button , 70 + 278 - 25 , 139 - 25 - 8
stdcall draw_button , 37 + 278 - 25 , 139 - 25 - 8
m2m [ but_c ] , [ sc.work ]
m2m [ but_t c ], [ sc.work_text ]
stdcall draw_button , KEYBOARD_X + ( KEYB_BTN_W + GAP ) * 0 , KEYBOARD_Y
stdcall draw_button , KEYBOARD_X + ( KEYB_BTN_W + GAP ) * 1 , KEYBOARD_Y
stdcall draw_button , KEYBOARD_X + ( KEYB_BTN_W + GAP ) * 2 , KEYBOARD_Y
stdcall draw_button , KEYBOARD_X + ( KEYB_BTN_W + GAP ) * 3 , KEYBOARD_Y
stdcall draw_button , KEYBOARD_X + ( KEYB_BTN_W + GAP ) * 3 , KEYBOARD_Y + ( KEYB_BTN_H + GAP ) * 1
stdcall draw_button , KEYBOARD_X + ( KEYB_BTN_W + GAP ) * 3 , KEYBOARD_Y + ( KEYB_BTN_H + GAP ) * 2
stdcall draw_button , KEYBOARD_X + ( KEYB_BTN_W + GAP ) * 3 , KEYBOARD_Y + ( KEYB_BTN_H + GAP ) * 3
stdcall draw_button , KEYBOARD_X + ( KEYB_BTN_W + GAP ) * 2 , KEYBOARD_Y + ( KEYB_BTN_H + GAP ) * 4
stdcall draw_button , KEYBOARD_X + ( KEYB_BTN_W + GAP ) * 1 , KEYBOARD_Y + ( KEYB_BTN_H + GAP ) * 4
mov eax , [ scn.btn_inface ]
mov [ but_c ], eax
mov eax , [ scn.btn_intext ]
mov [ but_tc ], eax
stdcall draw_button , 103 + 278 - 25 , 139 - 25 - 8
mov [ but_c ], 0xF0969D
mov [ but_t c ], 0x00FFFfff
stdcall draw_button , KEYBOARD_X + ( KEYB_BTN_W + GAP ) * 3 , KEYBOARD_Y + ( KEYB_BTN_H + GAP ) * 4
mov eax , [ scn.btn_face ]
mov [ but_c ], eax
mov eax , [ scn.btn_text ]
mov [ but_tc ], eax
stdcall draw_button , 4 + 278 - 25 , 66 - 25 - 8
stdcall draw_button , 37 + 278 - 25 , 66 - 25 - 8
stdcall draw_button , 70 + 278 - 25 , 66 - 25 - 8
stdcall draw_button , 4 + 278 - 25 , 90 - 25 - 8
stdcall draw_button , 37 + 278 - 25 , 90 - 25 - 8
stdcall draw_button , 70 + 278 - 25 , 90 - 25 - 8
stdcall draw_button , 4 + 278 - 25 , 114 - 25 - 8
stdcall draw_button , 37 + 278 - 25 , 114 - 25 - 8
stdcall draw_button , 70 + 278 - 25 , 114 - 25 - 8
stdcall draw_button , 4 + 278 - 25 , 139 - 25 - 8
m2m [ but_c ] , [ sc.work_button ]
m2m [ but_t c ], [ sc.work_button_text ]
stdcall draw_button , KEYBOARD_X + ( KEYB_BTN_W + GAP ) * 0 , KEYBOARD_Y + KEYB_BTN_H + GAP
stdcall draw_button , KEYBOARD_X + ( KEYB_BTN_W + GAP ) * 1 , KEYBOARD_Y + KEYB_BTN_H + GAP
stdcall draw_button , KEYBOARD_X + ( KEYB_BTN_W + GAP ) * 2 , KEYBOARD_Y + KEYB_BTN_H + GAP
stdcall draw_button , KEYBOARD_X + ( KEYB_BTN_W + GAP ) * 0 , KEYBOARD_Y + ( KEYB_BTN_H + GAP ) * 2
stdcall draw_button , KEYBOARD_X + ( KEYB_BTN_W + GAP ) * 1 , KEYBOARD_Y + ( KEYB_BTN_H + GAP ) * 2
stdcall draw_button , KEYBOARD_X + ( KEYB_BTN_W + GAP ) * 2 , KEYBOARD_Y + ( KEYB_BTN_H + GAP ) * 2
stdcall draw_button , KEYBOARD_X + ( KEYB_BTN_W + GAP ) * 0 , KEYBOARD_Y + ( KEYB_BTN_H + GAP ) * 3
stdcall draw_button , KEYBOARD_X + ( KEYB_BTN_W + GAP ) * 1 , KEYBOARD_Y + ( KEYB_BTN_H + GAP ) * 3
stdcall draw_button , KEYBOARD_X + ( KEYB_BTN_W + GAP ) * 2 , KEYBOARD_Y + ( KEYB_BTN_H + GAP ) * 3
stdcall draw_button , KEYBOARD_X + ( KEYB_BTN_W + GAP ) * 0 , KEYBOARD_Y + ( KEYB_BTN_H + GAP ) * 4
@ @ :
ret
endp
;----------------------
proc draw_list
; BACKGROUND
; === BACKGROUND ===
mov edi , LIST_ITEM_COUNT
mov eax , 13
mov ebx , 4 shl 16 + 320 - 50 - 25
mov ecx , 37 shl 16 + LIST_ITEM_SIZE
mov edx , LIST_ITEM_COLOR1
cmp [ his_even ], byte 0
je @ f
mov edx , LIST_ITEM_COLOR2
mov ebx , LIST_X shl 16 + LIST_ITEM_W
mov ecx , LIST_Y shl 16 + LIST_ITEM_H
mov edx , [ sc.work_light ]
@ @ :
mcall
add ecx , LIST_ITEM_SIZE shl 16
cmp ed x , LIST_ITEM_COLOR1
je .set_color_to_2
mov edx , LIST_ITEM_COLOR1
jmp .next
.set_color_to_2:
mov edx , LIST_ITEM_COLOR2
; draw separator {
push ec x edx
sub ecx , LIST_ITEM_H - 1
mov edx , [ sc.work_dark ]
mcall
; }
pop edx ecx
add ecx , LIST_ITEM_H shl 16
.next:
dec edi
cmp edi , 0
jne @ b
; BUTTONS
; === BUTTONS ===
mov edi , LIST_ITEM_COUNT
mov eax , 8
mov ebx , 4 shl 16 + 320 - 50 - 25
mov ecx , 37 shl 16 + LIST_ITEM_SIZE
mov edx , 0x40000060
mov ebx , LIST_X shl 16 + LIST_ITEM_W
mov ecx , 4 3 shl 16 + LIST_ITEM_H
mov edx , 60 + BT_HIDE
@ @ :
mcall
add ecx , LIST_ITEM_SIZE shl 16
add ecx , LIST_ITEM_H shl 16
inc edx
dec edi
cmp edi , 0
jne @ b
; TEXT
; === TEXT ===
mov edi , LIST_ITEM_COUNT
mov eax , 4
mov ebx , 8 shl 16 + 37 + LIST_I TEM _Y
mov ecx , LIST_ITEM_TEXT1
cmp [ his_even ], byte 0
je @ f
mov ecx , LIST_ITEM_TEXT2
mov ebx , ( LIST_X + LIST_X ) shl 16 + LIST_Y + LIST_TEXT _Y + 1
mov ecx , [ sc.work_text ]
@ @ :
or ecx , 1 shl 31
mov edx , history
@ @ :
add ecx , 0x10000000
mcall
push ebx
add ebx , ( 320 - 50 - 25 ) shl 16
add ebx , LIST_ITEM_W shl 16
mov esi , [ edx + 508 ]
shl esi , 16
sub ebx , esi
@@ -553,7 +557,7 @@
pop ebx
add edx , 32
add ebx , LIST_ITEM_SIZE
add ebx , LIST_ITEM_H
and ecx , 0xFFFFFF
cmp ecx , LIST_ITEM_TEXT2
@@ -631,38 +635,27 @@
but_tc rd 1
txt_id rd 1
txt_size rd 1
keyb rb 1
his_even rb 1
history rb 512 * LIST_ITEM_COUNT
rb 512
struc system_colors_internal {
.3d_face dd 0xCED0D0
.3d_dark dd 0xD7D7D7
.3d_light dd 0xFEFEFE
.win_title dd 0x2F2F2F
.win_body dd 0xE4DFE1
.btn_face dd 0xEFEBEF
.btn_text dd 0x373C42
.win_text dd 0x000000
.panel_frame dd 0x94AECE
.win_face dd 0xE1E1E1
.win_inface dd 0xE1E1E1
.win_frame dd 0x204962
.btn_inface dd 0xEFEBEF
.btn_intext dd 0xD0D9E8
.btn_fctext dd 0x2D3135
.gui_shadow dd 0xFFFFFF
.text_box_inner_shadow dd 0xCED0D0
.gui_face dd 0xFAF8FA
.gui_inface dd 0xF6F3F6
.gui_fcface dd 0xFAF8FA
.gui_frame dd 0x7698C0
.gui_text dd 0x373C42
.gui_text dd 0x10373C42
.gui_intext dd 0x5F5F5F
.gui_select dd 0xC7C9C9
}
scn system_colors_internal
sc system_colors
f70_calc:
dd 7
dd 0
dd 0
dd 0
dd 0
db '/sys/calc' , 0
memory: