h2d2b: use 'editbox'

git-svn-id: svn://kolibrios.org@2139 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2011-08-30 21:00:03 +00:00
parent 2cc416a4d8
commit 2d55c22d0a

View File

@ -1,3 +1,6 @@
;; h2d2b v0.4 use editbox by IgorA ;;
;; 30.08.2011 ;;
;; h2d2b v0.3 system colors by Leency ;;
;; 21.08.2011 ;;
@ -7,57 +10,51 @@
use32
org 0x0
db 'MENUET01'
dd 0x01,start,i_end,e_end,e_end,0,0
dd 0x01,start,i_end,e_end,e_end,0,sys_path
include '../../../proc32.inc'
include '../../../macros.inc' ; ìàêðîñû îáëåã÷àþò æèçíü àññåìáëåðùèêîâ!
include '../../../macros.inc' ; ¬ ªà®áë ®¡«¥£ç îâ ¦¨§­ì  áᥬ¡«¥à騪®¢!
include '../../../develop/libraries/box_lib/load_lib.mac'
include '../../../develop/libraries/box_lib/trunk/box_lib.mac'
include 'lang.inc'
@use_library
start:
red:
load_libraries l_libs_start,l_libs_end
;¯à®¢¥àª  ­  ᪮«ìª® 㤠筮 § £ã§¨« áì ­ è  ¡¨¡«¨®â¥ª 
mov ebp,lib_0
cmp dword [ebp+ll_struc_size-4],0
jz @f
mcall -1 ;exit not correct
@@:
mcall 40,0x27
mcall 48, 3, sys_colors, 40
edit_boxes_set_sys_color edit1,editboxes_end,sys_colors
red:
call draw_window
still:
mcall 10 ; ôóíêöèÿ 10 - æäàòü ñîáûòèÿ
mcall 10 ; äã­ªæ¨ï 10 - ¦¤ âì ᮡëâ¨ï
cmp eax,1 ; ïåðåðèñîâàòü îêíî ?
je red ; åñëè äà - íà ìåòêó red
cmp eax,2 ; íàæàòà êëàâèøà ?
je key ; åñëè äà - íà key
cmp eax,3 ; íàæàòà êíîïêà ?
je button ; åñëè äà - íà button
cmp eax,1 ; ¯¥à¥à¨á®¢ âì ®ª­® ?
je red ; ¥á«¨ ¤  - ­  ¬¥âªã red
cmp eax,2 ; ­ ¦ â  ª« ¢¨è  ?
je key ; ¥á«¨ ¤  - ­  key
cmp eax,3 ; ­ ¦ â  ª­®¯ª  ?
je button ; ¥á«¨ ¤  - ­  button
cmp eax,6
je mouse
jmp still ; åñëè äðóãîå ñîáûòèå - â íà÷àëî öèêëà
jmp still ; ¥á«¨ ¤à㣮¥ ᮡë⨥ - ¢ ­ ç «® 横« 
;---------------------------------------------------------------------
key: ; íàæàòà êëàâèøà íà êëàâèàòóðå
mov eax, 2
mcall
mov edi, [index]
cmp edi, string1
jz no_back
cmp ah, 8
jnz no_back
dec edi
mov byte [edi], ' '
mov [index], edi
call Draw_String
jmp still
no_back:
cmp ah, 13
jz read_str
cmp edi, string1_end
jae still
mov al, ah
stosb
mov [index], edi
call Draw_String
jmp still ; âåðíóòüñÿ ê íà÷àëó öèêëà
key: ; ­ ¦ â  ª« ¢¨è  ­  ª« ¢¨ âãà¥
mcall 2
stdcall [edit_box_key], dword edit1
jmp still ; ¢¥à­ãâìáï ª ­ ç «ã 横« 
read_str:
dec edi
@ -93,7 +90,7 @@ next_digit:
@@:
cmp dl, bl
jb @f
; Çäåñü îáðàáîòàòü îøèáêó
; ‡¤¥áì ®¡à ¡®â âì ®è¨¡ªã
jmp .done
@@:
@ -108,37 +105,44 @@ next_digit:
jmp next_digit
.done:
mov [num], eax ; ñîõðàíÿåì ââåäåííîå ÷èñëî
xor eax, eax
mov al, ' '
mov edi, string1
mov [index], edi
mov ecx, string1_end-string1
rep stosb ; ñòèðàåì ââåäåííóþ ñòðîêó
mov [num], eax ; á®å࠭塞 ¢¢¥¤¥­­®¥ ç¨á«®
jmp red
;---------------------------------------------------------------------
button:
mcall 17 ; 17 - ïîëó÷èòü èäåíòèôèêàòîð íàæàòîé êíîïêè
cmp ah, 1 ; åñëè ÍÅ íàæàòà êíîïêà ñ íîìåðîì 1,
button:
mcall 17 ; 17 - ¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨
cmp ah, 1 ; ¥á«¨ <20>… ­ ¦ â  ª­®¯ª  á ­®¬¥à®¬ 1,
jne @f
mcall -1
@@:
@@:
cmp ah, 2
jne @f
shl [num], 1
jmp red
@@:
@@:
cmp ah, 3
jne @f
shr [num], 1
jmp red
@@:
@@:
cmp ah, 4
jne still
jne @f
sar [num], 1
jmp red
@@:
cmp ah, 5
jne @f
mov edi,string1
add edi,[edit1.size] ;ãáâ ­ ¢«¨¢ ¥¬ ¢ edi ª®­¥æ áâப¨
jmp read_str
;jmp red
@@:
jmp still
mouse:
stdcall [edit_box_mouse], edit1
jmp still
;------------------------------------------------
draw_window:
@ -153,10 +157,11 @@ next_digit:
mcall 0, 200*65536+300, 200*65536+175, ,,title
mcall 8, 15 *65536+ 38, 90*65536+ 15, 2, [sys_colors.work_button] ; êíîïêà shl
mcall , ,110*65536+ 15, , ; êíîïêà sal
mcall , (300-53)*65536+ 38, 90*65536+ 15, 3, ; êíîïêà shr
mcall , ,110*65536+ 15, 4, ; êíîïêà sar
mcall 8, 15 *65536+ 38, 90*65536+ 15, 2, [sys_colors.work_button] ; ª­®¯ª  shl
mcall , ,110*65536+ 15, , ; ª­®¯ª  sal
mcall , (300-53)*65536+ 38, 90*65536+ 15, 3, ; ª­®¯ª  shr
mcall , ,110*65536+ 15, 4, ; ª­®¯ª  sar
mcall , ,145*65536+ 15, 5, ; ª­®¯ª  Ok
mov ecx, 0x80000000
or ecx, [sys_colors.work_text]
@ -172,12 +177,13 @@ next_digit:
mcall , (300-42)*65536+94, , shrstr,
mcall , 26*65536+114, , salstr,
mcall , (300-42)*65536+114, , sarstr,
mcall , (300-42)*65536+149, , Okstr,
mov ecx, [num]
mcall 47, 8*65536+256,,240*65536+72,[sys_colors.work_text] ; 16-íàÿ
mcall , 10*65536, ,228*65536+44, ; 10-íàÿ
mcall , 8*65536+512,,240*65536+30, ; 2-íàÿ
mcall 47, 8*65536+256,,240*65536+72,[sys_colors.work_text] ; 16-­ ï
mcall , 10*65536, ,228*65536+44, ; 10-­ ï
mcall , 8*65536+512,,240*65536+30, ; 2-­ ï
ror ecx, 8
mcall , ,,(240-56)*65536+30,
ror ecx, 8
@ -190,21 +196,14 @@ next_digit:
mov [minus], '-'
neg ecx
@@:
mcall , 10*65536,,228*65536+58, ; 10-íàÿ ñî çíàêîì
mcall , 10*65536,,228*65536+58, ; 10-­ ï á® §­ ª®¬
mcall 4, 222*65536+58, 0, minus, 1
mcall 38, 15*65536+300-15, 137*65536+137, [sys_colors.work_graph]
call Draw_String
mcall 12, 2 ; ôóíêöèÿ 12: ñîîáùèòü ÎÑ îá îòðèñîâêå îêíà
stdcall [edit_box_draw], edit1
mcall 12, 2 ; äã­ªæ¨ï 12: á®®¡é¨âì Ž‘ ®¡ ®âà¨á®¢ª¥ ®ª­ 
ret
;-------------------------------------------------
Draw_String:
;-------------------------------------------------
mcall 4, 60*65536+150, 0x40A40473, \
string1,string1_end-string1,0x00AABBCC
ret
;-------------------------------------------------
GetBase:
@ -244,24 +243,63 @@ ret
string1:
db 34 dup(' ')
string1_end:
index dd string1
num dd 0
title db 'hex2dec2bin 0.3',0
title db 'hex2dec2bin 0.4',0
minus db '-',0
numstr db 'Number:',0
hexstr db 'hex:',0
binstr db 'bin:',0
decstr db 'dec:',0
sdecstr db 'signed dec:',0
sdecstr db 'signed dec:',0
shlstr db 'shl',0
salstr db 'sal',0
shrstr db 'shr',0
sarstr db 'sar',0
if lang eq ru
numstr db '—¨á«®:',0
Okstr db '‚¢®¤',0
head_f_i:
head_f_l db '‘¨á⥬­ ï ®è¨¡ª ',0
else
numstr db 'Number:',0
Okstr db 'Ok',0
head_f_i:
head_f_l db 'System error',0
end if
mouse_dd dd 0
edit1 edit_box 182, 59, 146, 0xffffff, 0xff, 0x80ff, 0, 0x8000, (string1_end-string1), string1, mouse_dd, 0
editboxes_end:
system_dir_0 db '/sys/lib/'
lib_name_0 db 'box_lib.obj',0
err_msg_found_lib_0 db '<27>¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'box_lib.obj',39,0
err_msg_import_0 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'box_lib',39,0
l_libs_start:
lib_0 l_libs lib_name_0, sys_path, library_path, system_dir_0,\
err_msg_found_lib_0,head_f_l,import_box_lib,err_msg_import_0,head_f_i
l_libs_end:
align 4
import_box_lib:
;dd sz_init1
edit_box_draw dd sz_edit_box_draw
edit_box_key dd sz_edit_box_key
edit_box_mouse dd sz_edit_box_mouse
;edit_box_set_text dd sz_edit_box_set_text
dd 0,0
;sz_init1 db 'lib_init',0
sz_edit_box_draw db 'edit_box',0
sz_edit_box_key db 'edit_box_key',0
sz_edit_box_mouse db 'edit_box_mouse',0
;sz_edit_box_set_text db 'edit_box_set_text',0
i_end:
sys_colors system_colors
rb 0x400 ;stack
e_end: ; ìåòêà êîíöà ïðîãðàììû
sys_path rb 4096
library_path rb 4096
e_end: ; ¬¥âª  ª®­æ  ¯à®£à ¬¬ë