clean code 'optionbox' and 'treelist'

git-svn-id: svn://kolibrios.org@6972 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2017-09-12 13:56:36 +00:00
parent 57299a7248
commit ec2d075e74
5 changed files with 452 additions and 496 deletions

View File

@ -1,9 +1,7 @@
include 'optionbox.mac' ;macro implements optionbox
include 'scrollbar.mac' ;macro implements scrollbar include 'scrollbar.mac' ;macro implements scrollbar
include 'd_button.mac' ;macro implements dinamic_button include 'd_button.mac' ;macro implements dinamic_button
include 'menubar.mac' ;macro implements menubar include 'menubar.mac' ;macro implements menubar
include 'filebrowser.mac' ;macro implements filebrowser include 'filebrowser.mac' ;macro implements filebrowser
include 'tree_list.mac' ;macro implements tree_list, image_list, list_box
include 'pathshow.mac' ;macro implements pathshow include 'pathshow.mac' ;macro implements pathshow
include 't_edit.mac' ;macro implements text_editor include 't_edit.mac' ;macro implements text_editor
include 'frame.mac' ;macro implements frame include 'frame.mac' ;macro implements frame

View File

@ -39,13 +39,7 @@ include 'checkbox.asm' ;checkbox
;-------------------------------------------------- ;--------------------------------------------------
;radiobutton Group ;radiobutton Group
;-------------------------------------------------- include 'optionbox.asm' ;macro implements optionbox
align 16
use_optionbox_driver ;macro that control the operating modes
align 16
use_optionbox_draw ;macro reveals the function of the display.
align 16
use_optionbox_mouse ;macro reveals processing function of the mouse.
;-------------------------------------------------- ;--------------------------------------------------
;scrollbar Group ;scrollbar Group
@ -77,9 +71,7 @@ use_file_browser
;-------------------------------------------------- ;--------------------------------------------------
;tree list ;tree list
;-------------------------------------------------- include 'tree_list.asm' ;macro implements tree_list, image_list, list_box
align 16
use_tree_list
;-------------------------------------------------- ;--------------------------------------------------
;PathShow Group ;PathShow Group

View File

@ -0,0 +1,173 @@
; í«¥¬¥­â Optionbox ¤«ï ¡¨¡«¨®â¥ª¨ box_lib.obj
; ­  ª®¤ ¯à¨¬¥­¥­  GPL2 «¨æ¥­§¨ï
; ä ©« ᮧ¤ ­ 13.02.2009 <Lrz>
; ¯®á«¥¤­ïï ¬®¤¨ä¨ª æ¨ï 12.09.2017 IgorA
align 16
option_box_draw:
pusha
mov eax,dword[esp+36]
@@:
mov edi,dword[eax]
test edi,edi
je option_check
call option_box_draw_box
add eax,4
jmp @b
option_check:
mov eax,dword[esp+36]
@@:
mov edi,dword[eax]
test edi,edi
je @f
mov ebx,dword[edi]
mov ebx,dword[ebx]
cmp edi,ebx
jne .clear_op
pusha
call option_box_draw_op
popa
add eax,4
jmp @b
.clear_op:
pusha
call option_box_clear_op
popa
add eax,4
jmp @b
@@:
popa
ret 4
align 16
option_box_mouse:
pusha
mcall SF_MOUSE_GET,SSF_BUTTON
test eax,eax
jnz @f
popa
ret 4
@@:
mov eax,dword[esp+36]
@@:
mov edi,dword[eax]
test edi,edi
je option_check
call option_box_mouse_op
add eax,4
jmp @b
align 16
option_box_draw_box:
pusha ;á®åà ­¨¬ ¢á¥ ॣ¨áâàë
movzx ebx,word op_left
shl ebx,16
add ebx,dword op_size
movzx ecx,word op_top
shl ecx,16
add ecx,dword op_size
mcall SF_DRAW_RECT,,,op_border_color ;à¨á㥬 à ¬ªã
add ebx,1 shl 16 - 2
add ecx,1 shl 16 - 2
mcall ,,,op_color ;§ ªà è¨¢ ¥¬ ¢­ãâ७­®á⨠祪¡®ªá 
; mov eax,dword option_group
; mov eax,[eax]
; cmp eax,edi
; jne @f
; call option_box_draw_op ;­ à¨á®¢ âì ¢ª«î祭­ë© 祪 ¡®ªá
;----------------------------
;à áç¥â ªã¤  ¡ã¤¥â ¯à®¨§¢¥¤¥­ ¢ë¢®¤ ⥪áâ 
;----------------------------
@@:
movzx ebx,word op_left ;§ £à㧨âì §­ ç¥­¨¥ å ¤«ï 祪 ¡®ªá 
add ebx,dword op_size
add ebx,dword op_text_margin ;¤®¡ ¢¨âì à §¬¥à áâ®à®­ë ¨ à ááâ®ï­¨¥ ­  ª®â®à®¬ ­ ç­¥âáï ¢ë¢®¤ ⥪áâ 
shl ebx,16 ;ᤢ¨­¥¬ ­  16 à §à冷¢ ¢ «¥¢® (㬭®¦¨¬ ­  65536)
mov bx,word op_top ;§ £à㧨¬ §­ ç¥­¨¥ ¯® y
mov eax,op_size
shr eax,1
add eax,4
add ebx,eax
sub ebx,7 ;¤®¡ ¢¨¬ §­ ç¥­¨¥ ¤«¨­ë áâ®à®­ë -9+2
mov esi,dword op_text_length
mcall SF_DRAW_TEXT,,op_text_color,op_text_ptr ;‚뢮¤ ­ ¤¯¨á¨ ­  ª ­¢ã
popa ;¢®ááâ ­®¢¨âì §­ ç¥­¨ï ॣ¨áâ஢ ¨§ á⥪ 
ret ;¢ë©¤¥¬ ¨§ ¯à®æ¥¤ãàë
option_box_clear_op: ;®ç¨á⪠ 祪 ¡®ªá 
mov edx,dword op_color ;梥⠢­ãâਠ祪 ¡®ªá 
jmp @f ;¡¥§ãá«®¢­ë© ¯à릮ª ­  ­¨¦­îî ¬¥âªã @@
option_box_draw_op: ;­ à¨á®¢ âì ¢ª«î祭­ë© 祪 ¡®ªá
mov edx,dword op_border_color ;§ £à㧨âì 梥â
@@:
movzx ebx,word op_left ;§ £à㧨âì ª®®à¤¨­ âã ¯® å
mov eax,dword op_size
mov bp,ax
shr eax,2
push ax
push ax
add ebx,eax
shl ebx,16 ;ᤢ¨­¥¬ ­  16 à §à冷¢ ¢ «¥¢® (㬭®¦¨¬ ­  65536)
pop ax
lea eax,[eax*2]
sub bp,ax ;á®åà ­¨¬ ॣ¨áâà bx ¢ ॣ¨áâॠ㪠§ â¥«ï ¡ §ë
mov bx,bp
movzx ecx,word op_top ;§ £à㧨âì ª®®à¤¨­ âã ¯® ã
pop ax
add cx,ax
shl ecx,16 ;ᤢ¨­¥¬ ­  16 à §à冷¢ ¢ «¥¢® (㬭®¦¨¬ ­  65536)
mov cx,bp ;§ £à㧨¬ §­ ç¥­¨ï ॣ¨áâà  ãª § â¥«ï ¡ §ë ¢ cx
mcall SF_DRAW_RECT ;¢ë¢®¤ ¯®«®áë â.¥. ¯® áã⨠¯àאַ㣮«ì­¨ª , ª®â®àë© ®â®¡à ¦ ¥â ¢ª«î祭­ë© ª®¬¯®­¥­â 祪 ¡®ªá
ret ;¢ë©â¨ ¨§ ¯à®æ¥¤ãàë
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Ž¡à ¡®â稪 mouse
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
align 16
option_box_mouse_op: ;®¡à ¡®âª  ¬ëè¨
pusha
mov esi,dword op_text_length ;§ £à㧨âì ª®«-¢® ᨬ¢®«®¢ ¢ ⥪á⮢®© áâப¥
imul esi,6 ;¨«¨ ¬®¦­® ¨ â ª 㬭®¦¨âì ­  6
add esi,dword op_text_margin ;¤®¡ ¢¨âì 3 - à ááâ®ï­¨¥ ®â 祪 ¡®ªá  ¤® ­ ¤¯¨á¨
mcall SF_MOUSE_GET,SSF_WINDOW_POSITION ;¯®«ãç¨âì ª®®à¤¨­ âë ªãàá®à  ®â­®á¨â¥«ì­® ®ª­ 
movzx ebx,word op_top ;§ £à㧨âì ¢ bx §­ ç¥­¨¥ ª®®à¤¨­ âë ã
cmp ax,bx ;áà ¢­¨âì á á ª®®à¤¨­ â®© ªãàá®à 
jl option_box_mouse_end ;SF <> OF ¥á«¨ ¬¥­ìè¥
add ebx,dword op_size ;¤®¡ ¢¨âì à §¬¥à
cmp ax,bx ;áà ¢­¨âì
jg option_box_mouse_end ;ZF = 0 ¨ SF = OF ¥á«¨ ¡®«ìè¥
shr eax,16 ;à §¤¥«¨¬ ­  65536 ¨«¨ ¯à®á⮠ᤢ¨­¥¬ ¡¨âë ­  16 §­ ç¥­¨©
movzx ebx,word op_left ;¯à®¨§¢¥¤¥¬  ­ «®£¨ç­®¥ áà ¢­¥­¨¥
cmp ax,bx ;áà ¢­¨âì ॣ¨áâàë
jl option_box_mouse_end ;¥á«¨ ¬¥­ìè¥
add ebx,dword op_size ;¤®¡ ¢¨âì ¤«¨­ã áâ®à®­ë ¯àאַ㣮«ì­¨ª 
add ebx,esi ;“ç¥áâì ¢ §­ ç¥­¨¨ ¯® å ¥é¥ ¨ ¤«¨­ã ­ ¤¯¨á¨ ª 祪¡®ªáã
cmp ax,bx ;áâà ¢­¨âì ॣ¨áâàë
jg option_box_mouse_end ;¥á«¨ ¡®«ìè¥
mov eax,dword option_group
mov [eax],edi
option_box_mouse_end:
popa ;¢®ááâ ­®¢¨âì ॣ¨áâàë ¨§ á⥪ 
ret ;¢ë©â¨

View File

@ -1,189 +0,0 @@
;ä ©« ᮧ¤ ­ 13.02.2009 <Lrz> <20>  ª®¤ ¯à¨¬¥­¥­  GPL2 «¨æ¥­§¨ï
;Œ ªà®á ¤«ï á¨á⥬­®© ¡¨¡«¨®â¥ª¨ box_lib.obj
;Optionbox
macro use_optionbox_driver ;¬ ªà®áë ª®â®àë¥ ã¯à ¢«ïîâ à ¡®â®© ¡®ªá  )
{
option_box_draw:
pusha
mov eax,dword [esp+36]
@@: mov edi,dword [eax]
test edi,edi
je option_check
call option_box_draw_box
add eax,4
jmp @b
option_check:
mov eax,dword [esp+36]
@@: mov edi,dword [eax]
test edi,edi
je @f
mov ebx,dword [edi]
mov ebx,dword [ebx]
cmp edi,ebx
jne .clear_op
pusha
call option_box_draw_op
popa
add eax,4
jmp @b
.clear_op:
pusha
call option_box_clear_op
popa
add eax,4
jmp @b
@@: popa
ret 4
; exit ¢®®¡é¥ :)
option_box_mouse:
pusha
mcall 37,2
test eax,eax
jnz @f
popa
ret 4
@@:
mov eax,dword [esp+36]
@@: mov edi,dword [eax]
test edi,edi
je option_check
call option_box_mouse_op
add eax,4
jmp @b
}
macro use_optionbox_draw
{
option_box_draw_box:
pusha ;á®åà ­¨¬ ¢á¥ ॣ¨áâàë
movzx ebx,word op_left
shl ebx,16
add ebx,dword op_size
movzx ecx,word op_top
shl ecx,16
add ecx,dword op_size
mov edx,dword op_border_color
mov eax,13
mcall ;à¨á㥬 à ¬ªã
mov edx,dword op_color
add ebx,1 shl 16 - 2
add ecx,1 shl 16 - 2
mcall ;§ ªà è¨¢ ¥¬ ¢­ãâ७­®á⨠祪¡®ªá 
; mov eax,dword option_group
; mov dword eax,[eax]
; cmp eax,edi
; jne @f
; call option_box_draw_op ;­ à¨á®¢ âì ¢ª«î祭­ë© 祪 ¡®ªá
;----------------------------
;à áç¥â ªã¤  ¡ã¤¥â ¯à®¨§¢¥¤¥­ ¢ë¢®¤ ⥪áâ 
;----------------------------
@@: movzx ebx,word op_left ;§ £à㧨âì §­ ç¥­¨¥ å ¤«ï 祪 ¡®ªá 
add ebx,dword op_size
add ebx,dword op_text_margin;¤®¡ ¢¨âì à §¬¥à áâ®à®­ë ¨ à ááâ®ï­¨¥ ­  ª®â®à®¬ ­ ç­¥âáï ¢ë¢®¤ ⥪áâ 
shl ebx,16 ;ᤢ¨­¥¬ ­  16 à §à冷¢ ¢ «¥¢® (㬭®¦¨¬ ­  65536)
mov bx,word op_top ;§ £à㧨¬ §­ ç¥­¨¥ ¯® y
mov eax,op_size
shr eax,1
add eax,4
add ebx,eax
mov ecx,dword op_text_color ;§ £à㧨¬ 梥⠭ ¤¯¨á¨ + flags
sub ebx,7 ;¤®¡ ¢¨¬ §­ ç¥­¨¥ ¤«¨­ë áâ®à®­ë -9+2
mov edx,dword op_text_ptr ;㪠¦¥¬  ¤à¥á ®â ªã¤  ­ã¦­® ¢ë¢®¤¨âì áâபã
mov esi,dword op_text_length
;¢­¥á¥¬ ¢ eax §­ ç¥­¨¥ ¢ë¢®¤  ­ ¤¯¨á¨ ­  ª ­¢ã
mov eax,4
mcall ;‚뢮¤
popa ;¢®ááâ ­®¢¨âì §­ ç¥­¨ï ॣ¨áâ஢ ¨§ á⥪ 
ret ;¢ë©¤¥¬ ¨§ ¯à®æ¥¤ãàë
option_box_clear_op: ;®ç¨á⪠ 祪 ¡®ªá 
mov edx,dword op_color ;梥⠢­ãâਠ祪 ¡®ªá 
jmp @f ;¡¥§ãá«®¢­ë© ¯à릮ª ­  ­¨¦­îî ¬¥âªã @@
option_box_draw_op: ;­ à¨á®¢ âì ¢ª«î祭­ë© 祪 ¡®ªá
mov edx,dword op_border_color ;§ £à㧨âì 梥â
@@:
movzx ebx,word op_left ;§ £à㧨âì ª®®à¤¨­ âã ¯® å
mov eax,dword op_size
mov bp,ax
shr eax,2
push ax
push ax
add ebx,eax
shl ebx,16 ;ᤢ¨­¥¬ ­  16 à §à冷¢ ¢ «¥¢® (㬭®¦¨¬ ­  65536)
pop ax
lea eax,[eax*2]
sub bp,ax ;á®åà ­¨¬ ॣ¨áâà bx ¢ ॣ¨áâॠ㪠§ â¥«ï ¡ §ë
mov bx,bp
movzx ecx,word op_top ;§ £à㧨âì ª®®à¤¨­ âã ¯® ã
pop ax
add cx,ax
shl ecx,16 ;ᤢ¨­¥¬ ­  16 à §à冷¢ ¢ «¥¢® (㬭®¦¨¬ ­  65536)
mov cx,bp ;§ £à㧨¬ §­ ç¥­¨ï ॣ¨áâà  ãª § â¥«ï ¡ §ë ¢ cx
mov eax,13 ;¢ eax - §­ ç¥­¨ï ä㭪樨 ¤«ï ¢ë¢®¤  ¯®«®áë â.¥. ¯® áã⨠¯àאַ㣮«ì­¨ª , ª®â®àë© ®â®¡à ¦ ¥â ¢ª«î祭­ë© ª®¬¯®­¥­â 祪 ¡®ªá
mcall ;¢ë¢®¤
ret ;¢ë©â¨ ¨§ ¯à®æ¥¤ãàë
}
macro use_optionbox_mouse
{
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Ž¡à ¡®â稪 mouse
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
option_box_mouse_op: ;®¡à ¡®âª  ¬ëè¨
pusha
mov esi,dword op_text_length ;§ £à㧨âì ª®«-¢® ᨬ¢®«®¢ ¢ ⥪á⮢®© áâப¥
;“¬­®¦¥­¨¥ ­  6 <20>ëáâ஥ 㬭®¦¥­¨¥ ¬®¦­® ¢®á¯®«ì§®¢ âìáï «î¡ë¬ ¬§ ¬¥â®¤®¢, ­® ­  áâ àëå <20>à®æ¥áá®à å (386,486,P1)¡ëáâ॥ ¡ã¤¥â á ¨­áâàãªæ¨¥© Lea
; lea esi,[eax*2+eax]
; shl eax,1
imul esi,6 ; ¨«¨ ¬®¦­® ¨ â ª 㬭®¦¨âì ­  6
xor ebx,ebx
add esi,dword op_text_margin ;¤®¡ ¢¨âì 3 - à ááâ®ï­¨¥ ®â 祪 ¡®ªá  ¤® ­ ¤¯¨á¨
mov eax,37 ;¯®«ã稬 ª®®à¤¨­ âë ¬ë誨
inc ebx ;¤®¡ ¢¨âì 1
mcall ;¯®«ãç¨âì ª®®à¤¨­ âë ªãàá®à  ®â­®á¨â¥«ì­® ®ª­ 
movzx ebx,word op_top ;§ £à㧨âì ¢ bx §­ ç¥­¨¥ ª®®à¤¨­ âë ã
cmp ax,bx ;áà ¢­¨âì á á ª®®à¤¨­ â®© ªãàá®à 
jl option_box_mouse_end ;SF <> OF ¥á«¨ ¬¥­ìè¥
add ebx,dword op_size ;¤®¡ ¢¨âì à §¬¥à
cmp ax,bx ;áà ¢­¨âì
jg option_box_mouse_end ;ZF = 0 ¨ SF = OF ¥á«¨ ¡®«ìè¥
shr eax,16 ;à §¤¥«¨¬ ­  65536 ¨«¨ ¯à®á⮠ᤢ¨­¥¬ ¡¨âë ­  16 §­ ç¥­¨©
movzx ebx,word op_left ;¯à®¨§¢¥¤¥¬  ­ «®£¨ç­®¥ áà ¢­¥­¨¥
cmp ax,bx ;áà ¢­¨âì ॣ¨áâàë
jl option_box_mouse_end ;¥á«¨ ¬¥­ìè¥
add ebx,dword op_size ;¤®¡ ¢¨âì ¤«¨­ã áâ®à®­ë ¯àאַ㣮«ì­¨ª 
add ebx,esi ;“ç¥áâì ¢ §­ ç¥­¨¨ ¯® å ¥é¥ ¨ ¤«¨­ã ­ ¤¯¨á¨ ª 祪¡®ªáã
cmp ax,bx ;áâà ¢­¨âì ॣ¨áâàë
jg option_box_mouse_end ;¥á«¨ ¡®«ìè¥
mov eax,dword option_group
mov [eax],edi
option_box_mouse_end:
popa ;¢®ááâ ­®¢¨âì ॣ¨áâàë ¨§ á⥪ 
ret ;¢ë©â¨
}