mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-12-27 00:39:41 +03:00
aa54290806
git-svn-id: svn://kolibrios.org@1411 a494cfbc-eb01-0410-851d-a64ba20cac60
422 lines
9.9 KiB
NASM
422 lines
9.9 KiB
NASM
;
|
||
; DESKTOP CONTEXT MENU
|
||
; written by Ivan Poddubny
|
||
;
|
||
; €¢â®à - ˆ¢ <20>®¤¤ã¡ë©
|
||
; e-mail: ivan-yar@bk.ru
|
||
;
|
||
; Compile with flat assembler
|
||
;
|
||
include 'lang.inc'
|
||
include '..\..\..\macros.inc'
|
||
|
||
meos_app_start
|
||
code
|
||
|
||
mov eax, 48 ; ¯®«ãç¨âì á¨áâ¥¬ë¥ æ¢¥â
|
||
mov ebx, 3
|
||
mov ecx, sc ; ¤à¥á áâàãªâãàë
|
||
mov edx, sizeof.system_colors ; ¨ ¥¥ à §¬¥à
|
||
mcall
|
||
|
||
mov eax,40 ; ãáâ ®¢¨¬ ¬ áªã ᮡë⨩
|
||
mov ebx,100000b ; á ¨â¥à¥áã¥â ⮫쪮 ¬ëèì
|
||
mcall
|
||
|
||
still: ; £« ¢ë© 横« ®á®¢®£® ¯à®æ¥áá
|
||
|
||
mov eax,10 ; ¦¤ñ¬ ᮡëâ¨ï
|
||
mcall
|
||
|
||
mov eax,37 ; ª ª¨¥ ¦ âë ª¯®¯ª¨?
|
||
mov ebx,2
|
||
mcall
|
||
|
||
cmp eax,ebx ; ¥á«¨ ¥ ¯à ¢ ï, ¢®§¢à â
|
||
jne still
|
||
|
||
;---¯®¥å «¨!---
|
||
|
||
; mov eax,37 ; íâ® ¤«ï ®â« ¤ª¨ - ¥á«¨ ¬ëèì ¢ â®çª¥ (0;0), § ªà®¥¬áï
|
||
; xor ebx,ebx
|
||
; mcall
|
||
; test eax,eax ; ªãàá®à ¢ â®çª¥ (0;0), â.¥. eax = 0
|
||
; je exit
|
||
|
||
|
||
mov eax,9 ; ¯®«ã稬 ç¨á«® ¯à®æ¥áᮢ ¢ á¨á⥬¥
|
||
mov ebx,procinfo
|
||
xor ecx,ecx
|
||
mcall
|
||
|
||
inc eax ; ⥯¥àì ¢ eax ᮤ¥à¦¨âáï ç¨á«® ¯à®æ¥áᮢ + 1
|
||
mov [processes],eax
|
||
mov ecx,1
|
||
|
||
new_process:
|
||
pushad
|
||
mov eax,9 ; ¯®«ã稬 ¨ä®à¬ æ¨î ® ¯à®æ¥áá¥; ®¬¥à - ¢ ecx
|
||
mov ebx,procinfo
|
||
mcall
|
||
mov eax,37 ; ª®®à¤¨ âë ªãàá®à
|
||
xor ebx,ebx
|
||
mcall
|
||
mov ebx,eax ; eax = cursor_x
|
||
shr eax,16 ; ebx = cursor_y
|
||
and ebx,0xffff
|
||
mov [curx1],eax ; curx1 = cursor_x
|
||
mov [cury1],ebx ; cury1 = cursor_y
|
||
; \begin{diamond}[18.09.2006]
|
||
; ignore minimized windows
|
||
test [procinfo.wnd_state], 2
|
||
jnz ne_goden
|
||
; \end{diamond}[18.09.2006]
|
||
mov eax,[procinfo.box.left] ; eax = wnd_x_start
|
||
mov ebx,[procinfo.box.top] ; ebx = wnd_y_start
|
||
|
||
mov ecx,[procinfo.box.width]
|
||
add ecx,eax ; ecx = wnd_x_end
|
||
mov edx,[procinfo.box.height]
|
||
add edx,ebx ; ecx = wnd_y_end
|
||
|
||
cmp eax,[curx1] ; wnd_x_start > cursor_x => ªãàá®à «¥¢¥¥ ®ª
|
||
jg ne_goden
|
||
cmp ecx,[curx1] ; wnd_x_end < cursor_x => ªãàá®à ¯à ¢¥¥ ®ª
|
||
jl ne_goden
|
||
cmp ebx,[cury1] ; wnd_y_start > cursor_y => ªãàá®à ¢ëè¥ ®ª
|
||
jg ne_goden
|
||
cmp edx,[cury1] ; wnd_y_end < cursor_y => ªãàá®à ¨¦¥ ®ª
|
||
jl ne_goden
|
||
|
||
goden: ; ª«¨ª ¡ë« ¢ãâਠª ª®£®-â® ®ª , ¯®í⮬㠨祣® ¥ ¤¥« ¥¬
|
||
popad
|
||
jmp still
|
||
|
||
ne_goden: ; ª«¨ª ¡ë« á à㦨 à áᬠâਢ ¥¬®£® ®ª , ¯®í⮬ã
|
||
popad
|
||
inc ecx
|
||
cmp ecx,[processes]
|
||
jl new_process ; «¨¡® ᬮਬ á«¥¤ãî饥 ®ª®, «¨¡® § ¯ã᪠¥¬ ¬¥î
|
||
|
||
|
||
@@: ; ¯®¤®¦¤ñ¬, ¯®ª ¯®«ì§®¢ â¥«ì ¥ ®â¯ãá⨫ ¯à ¢ãî ª®¯ªã ¬ëè¨
|
||
mov eax,37
|
||
mov ebx,2 ; äãªæ¨ï 37-2:
|
||
mcall ; ¦ âë «¨ ª®¯ª¨ ¬ëè¨?
|
||
test eax,ebx ; ¥á«¨ ®â¯ãá⨫, (eax != 2)
|
||
jz @f ; ¨¤ñ¬ ¢ ç «® £« ¢®£® 横«
|
||
|
||
mov eax,5 ; ¨ ç¥
|
||
;mov ebx,2 ; ¯®¤®¦¤ñ¬ 2 ¬á
|
||
mcall
|
||
|
||
jmp @b ; ¨ ¯à®¢¥à¨¬ ¬ëèì ®¯ïâì
|
||
@@:
|
||
|
||
; ¥á«¨ 㦥 ¡ë«® ®âªàëâ® ¬¥î, 㦮 ¯®¤®¦¤ âì, ¯®ª ®® § ªà®¥âáï:
|
||
@@:
|
||
cmp [menu_opened],0
|
||
je @f
|
||
mov eax,5
|
||
mov ebx,3 ; ¦¤ñ¬ 3 ¬á
|
||
mcall
|
||
jmp @b
|
||
@@:
|
||
|
||
mov eax,51 ; ⥯¥àì ¬®¦® ᬥ«® § ¯ã᪠âì ¯à®æ¥áá (¯®â®ª) ¬¥î
|
||
mov ebx,1 ; ᮧ¤ ñ¬ ¯®â®ª (thread)
|
||
mov ecx,start_wnd ; â®çª ¢å®¤ ¯®â®ª
|
||
mov edx,stack_wnd ; ¢¥àè¨ áâíª ¤«ï ¯®â®ª
|
||
mcall
|
||
|
||
jmp still
|
||
|
||
|
||
|
||
exit_menu: ; ¥á«¨ ¢ë室¨¬ ¨§ ¬¥î, ¤® § ¯¨á âì ¢ [menu_opened] 0
|
||
mov [menu_opened],0
|
||
exit: ; áî¤ ¬ë ¨¤ñ¬, ª®£¤ ¢ë室¨¬ ¨§ ®á®¢®£® ¯à®æ¥áá
|
||
or eax,-1 ; eax = -1
|
||
mcall
|
||
|
||
|
||
|
||
|
||
; §¤¥áì áâ àâã¥â ¯à®æ¥áá ¬¥î
|
||
start_wnd:
|
||
mov [menu_opened],1
|
||
mov eax,40 ; ãáâ ®¢¨¬ ¬ áªã ¦¥« ¥¬ëå ᮡë⨩ ¤«ï í⮣® ¯à®æ¥áá
|
||
mov ebx,100101b ; ¬¥î + ª®¯ª¨ + ¯¥à¥à¨á®¢ª
|
||
mcall
|
||
|
||
red:
|
||
call draw_window
|
||
|
||
still2: ; £« ¢ë© 横« ¯à®æ¥áá ¬¥î
|
||
|
||
mov eax,10 ; ¦¤ñ¬ ᮡëâ¨ï
|
||
mcall
|
||
|
||
cmp eax,1 ; ¯¥à¥à¨á®¢ª ?
|
||
je red
|
||
cmp eax,3 ; ª®¯ª ?
|
||
je button
|
||
cmp eax,6 ; ¬ëèì?
|
||
je mouse
|
||
|
||
jmp still2 ; ¢¥àñ¬áï ¢ ç «® £« ¢®£® 横«
|
||
|
||
|
||
; Ž<><C5BD>€<EFBFBD>Ž’—ˆŠ Œ›˜ˆ
|
||
mouse: ; ª®£¤ ¯®«ì§®¢ â¥«ì ¦¬ñâ ª®¯ªã ¬ëè¨, § ªà®¥¬áï
|
||
mov eax,37
|
||
mov ebx,2 ; ª ª¨¥ ª®¯ª¨ ¦ âë?
|
||
mcall
|
||
test eax,eax ; ¨ª ª¨¥? - ⮣¤ ¯à¥ªà á®! ¢¥àñ¬áï ¢ £« ¢ë© 横«
|
||
jz still2
|
||
|
||
mcall 37, 0
|
||
mov esi, eax
|
||
shr esi, 16
|
||
movzx edi, ax
|
||
mcall 9, procinfo2, -1
|
||
mov eax, [procinfo2.box.left]
|
||
cmp esi, eax
|
||
jl exit_menu
|
||
add eax, [procinfo2.box.width]
|
||
cmp esi, eax
|
||
jge exit_menu
|
||
mov eax, [procinfo2.box.top]
|
||
cmp edi, eax
|
||
jl exit_menu
|
||
add eax, [procinfo2.box.height]
|
||
cmp edi, eax
|
||
jge exit_menu
|
||
|
||
jmp still2
|
||
|
||
; <20>€†€’€ Š<>Ž<EFBFBD>Š€
|
||
button:
|
||
mov eax,17 ; ¯®«ãç¨âì ¨¤¥â¨ä¨ª â®à ¦ ⮩ ª®¯ª¨
|
||
mcall
|
||
|
||
sub ah,10 ; áà ¢¨¢ ¥¬ á 10
|
||
jl nofuncbtns ; ¥á«¨ ¬¥ìè¥ - § ªàë¢ ¥¬ ¬¥î
|
||
|
||
movzx ebx,ah ; ¯®«ã稫¨ ®¬¥à ¯à®£à ¬¬ë ¢ ᯨ᪥ ¢ ebx
|
||
mov esi, [startapps + ebx*4]
|
||
mov edi, start_info.path
|
||
cld
|
||
@@:
|
||
lodsb
|
||
stosb
|
||
test al, al
|
||
jnz @b
|
||
mcall 70, start_info
|
||
|
||
; mov eax,5 ; ¯®¤®¦¤ñ¬, ¯®ª ¯à®£à ¬¬ § ¯ãáâ¨âìáï
|
||
; mov ebx,1 ; â® ¥ñ ®ª® ¥ ¡ã¤¥â ®âà¨á®¢ ® (¡ £ ¢ ï¤à¥???)
|
||
; mcall ; à ᪮¬¬¥â¨àã©â¥ í⨠áâப¨, ¥á«¨ ã ¢ á ¯à®¡«¥¬ë
|
||
; á ®âà¨á®¢ª®©
|
||
|
||
nofuncbtns: ; § ªàë¢ ¥¬ ¬¥î
|
||
jmp exit_menu
|
||
|
||
|
||
|
||
_BTNS_ = 6 ; ª®«¨ç¥á⢮ ª®¯®ª ("¯ãªâ®¢ ¬¥î")
|
||
|
||
if lang eq ru
|
||
font = 0x00000000
|
||
string_length = 20 ; ¤«¨ áâப¨
|
||
wnd_x_size = 133 ; è¨à¨ ®ª
|
||
title_pos = 36 shl 16 + 7
|
||
else
|
||
font = 0x10000000
|
||
string_length = 12 ; ¤«¨ áâப¨
|
||
wnd_x_size = 105 ; è¨à¨ ®ª
|
||
title_pos = 23 shl 16 + 7
|
||
end if
|
||
|
||
;*******************************
|
||
;******** <20>ˆ‘“…Œ ŽŠ<C5BD>Ž ********
|
||
;*******************************
|
||
|
||
draw_window:
|
||
|
||
mov eax,12 ; ç¨ ¥¬ "à¨á®¢ âì"
|
||
mov ebx,1
|
||
mcall
|
||
|
||
mov eax,[curx1] ; ⥪ã騥 ª®®à¤¨ âë ªãàá®à
|
||
mov [curx],eax ; § ¯¨è¥¬ ¢ ª®®à¤¨ âë ®ª
|
||
mov eax,[cury1]
|
||
mov [cury],eax
|
||
|
||
; ⥯¥àì ¡ã¤¥¬ áç¨â âì ª®®à¤¨ âë ®ª , çâ®¡ë ®® § ªà © íªà ¥ ¢ë«¥§«®
|
||
mov eax,14 ; ¯®«ã稬 à §¬¥à íªà
|
||
mcall
|
||
mov ebx,eax
|
||
shr eax,16 ; ¢ eax - x_screen
|
||
and ebx,0xffff ; ¢ ebx - y_screen
|
||
add eax,-wnd_x_size ; eax = [x_screen - è¨à¨ ®ª ]
|
||
add ebx,-_BTNS_*15-21 ; ebx = [y_screen - ¢ëá®â ®ª ]
|
||
|
||
cmp eax,[curx]
|
||
jg .okx ; ¥á«¨ ®ª® ᫨誮¬ ¡«¨§ª® ª ¯à ¢®¬ã ªà î,
|
||
add [curx],-wnd_x_size ; ᤢ¨¥¬ ¥£® ¢«¥¢® 100
|
||
.okx:
|
||
|
||
cmp ebx, [cury]
|
||
jg .oky ; ¯® ¢¥à⨪ «¨ â®ç® â ª¦¥
|
||
add [cury], -_BTNS_*15-21
|
||
.oky:
|
||
|
||
xor eax, eax ; äãªæ¨ï 0 - ᮧ¤ âì ®ª®
|
||
mov ebx, [curx] ; ebx = [ª®®à¤¨ â ¯® x] shl 16 + [è¨à¨ ]
|
||
shl ebx, 16
|
||
add ebx, wnd_x_size
|
||
mov ecx, [cury] ; ecx = [ª®®à¤¨ â ¯® y] shl 16 + [¢ëá®â ]
|
||
shl ecx, 16
|
||
add ecx, _BTNS_*15+21
|
||
mov edx, [sc.work] ; 梥â à ¡®ç¥© ®¡« áâ¨
|
||
mov esi, [sc.grab] ; 梥⠧ £®«®¢ª
|
||
or esi, 0x81000000
|
||
mov edi, [sc.frame] ; 梥â à ¬ª¨
|
||
mcall
|
||
|
||
mov eax, 4 ; § £®«®¢®ª
|
||
mov ebx, title_pos ; [x] shl 16 + [y]
|
||
mov ecx, [sc.grab_text]; èà¨äâ ¨ 梥â (á¥àë©)
|
||
or ecx, 0x10000000
|
||
; add ecx, -0x333333
|
||
push ecx
|
||
push ecx
|
||
xor edx,edx
|
||
.dec_color:
|
||
sub byte [esp+edx], 0x33
|
||
jae @f
|
||
mov byte [esp+edx], 0
|
||
@@:
|
||
inc edx
|
||
jnp .dec_color
|
||
pop ecx
|
||
mov edx, title ; ¤à¥á § £®«®¢ª
|
||
mov esi, title.size ; ¤«¨ § £®«®¢ª ("M E N U")
|
||
mcall
|
||
pop ecx
|
||
add ebx, 1 shl 16 ; ᤢ¨¥¬ ¢¯à ¢® 1
|
||
mcall
|
||
|
||
mov ebx, 1*65536+wnd_x_size-2 ; ç¨ ¥¬ ¤¥« âì ª®¯ª¨
|
||
mov ecx, 20*65536+15
|
||
mov edx, 10 or 0x40000000 ; ¡¨â 30 ãáâ ®¢«¥ => ª®¯ª ¥ à¨áã¥âáï
|
||
|
||
mov edi,_BTNS_ ; ª®«¨ç¥á⢮ ª®¯®ª (áçñâ稪)
|
||
|
||
newbtn: ; ç «® 横«
|
||
mov eax,8 ; ᮧ¤ ñ¬ ª®¯ªã
|
||
mcall
|
||
|
||
; ¯¨è¥¬ ⥪áâ ª®¯ª¥
|
||
pushad ; á¯ á ¥¬ ॣ¨áâàë
|
||
shr ecx, 16
|
||
and ebx, 0xffff0000
|
||
add ebx, ecx ; ebx = [x] shl 16 + [y];
|
||
add ebx, 10*65536+4 ; ebx += ᬥ饨¥ ®â®á¨â¥«ì® ªà ï ª®¯ª¨;
|
||
mov ecx, [sc.work_text] ; èà¨äâ ¨ 梥â
|
||
or ecx, font
|
||
add edx, -10 ; edx = ®¬¥à ª®¯ª¨;
|
||
imul edx, string_length ; edx *= ¤«¨ áâப¨;
|
||
add edx, text ; edx += text; ⥯¥àì ¢ edx ¤à¥á áâப¨
|
||
mov esi, string_length ; ¢ esi - ¤«¨ áâப¨
|
||
mov eax, 4 ; äãªæ¨ï 4 - ¢ë¢®¤ ⥪áâ
|
||
mcall
|
||
popad
|
||
|
||
inc edx ; ®¬¥à ª®¯ª¨++;
|
||
add ecx,15*65536 ; 㢥«¨ç¨¬ ᬥ饨¥ ¯® y
|
||
dec edi ; 㬥ì訬 áçñâ稪
|
||
jnz newbtn ; ¥á«¨ ¥ ®«ì, ¯®¢â®à¨¬ ¢áñ ¥éñ à §
|
||
|
||
mov eax,12 ; § ª®ç¨«¨ "à¨á®¢ âì"
|
||
mov ebx,2
|
||
mcall
|
||
|
||
ret ; ¢®§¢à â
|
||
|
||
|
||
|
||
; „€<E2809E><E282AC>›… <20><>Žƒ<C5BD>€ŒŒ›
|
||
DATA
|
||
|
||
macro strtbl name, [string]
|
||
{
|
||
common
|
||
label name dword
|
||
forward
|
||
local str
|
||
dd str
|
||
forward
|
||
str db string
|
||
}
|
||
|
||
strtbl startapps ,\
|
||
<"/sys/PIC4",0> ,\
|
||
<"/sys/DESKTOP",0> ,\
|
||
<"/sys/ICONMNGR",0>,\
|
||
<"/sys/SETUP",0> ,\
|
||
<"/sys/VRR",0> ,\
|
||
<"/sys/CPU",0>
|
||
|
||
sz title, "KolibriOS"
|
||
|
||
lsz text,\
|
||
en, 'Background ',\
|
||
en, 'Desktop ',\
|
||
en, 'Icon manager',\
|
||
en, 'Device setup',\
|
||
en, 'VRR ',\
|
||
en, 'Processes ',\
|
||
\
|
||
ru, 'ƒ¥¥à â®à ®¡®¥¢ ',\
|
||
ru, '<27> áâனª ®ª® ',\
|
||
ru, '“¯à ¢«¥¨¥ ¨ª®ª ¬¨ ',\
|
||
ru, '<27> áâனª ãáâனá⢠',\
|
||
ru, '<27> áâனª ¬®¨â®à ',\
|
||
ru, '<27>à®æ¥ááë '
|
||
|
||
start_info:
|
||
.mode dd 7
|
||
dd 0
|
||
.params dd 0
|
||
dd 0
|
||
dd 0
|
||
db 0
|
||
dd start_info.path
|
||
|
||
; <20>…ˆ<E280A6>ˆ–ˆ€‹ˆ‡ˆ<E280A1>Ž‚€<E2809A><E282AC>›… „€<E2809E><E282AC>›…
|
||
UDATA
|
||
processes dd ? ; ª®«¨ç¥á⢮ ¯à®æ¥áᮢ ¢ á¨á⥬¥
|
||
curx1 dd ? ; ª®®à¤¨ âë ªãàá®à
|
||
cury1 dd ?
|
||
curx dd ? ; ª®®à¤¨ âë ®ª ¬¥î
|
||
cury dd ?
|
||
|
||
menu_opened db ? ; ®âªàëâ® ¬¥î ¨«¨ ¥â? (1-¤ , 0-¥â)
|
||
|
||
align 4
|
||
start_info.path rb 256
|
||
|
||
sc system_colors ; á¨áâ¥¬ë¥ æ¢¥â
|
||
procinfo process_information ; ¨ä®à¬ æ¨ï ® ¯à®æ¥áá¥
|
||
procinfo2 process_information
|
||
|
||
rb 1024 ; áâíª ¤«ï ®ª ¬¥î - å¢ â¨â ¨ 1 Š¡
|
||
align 32
|
||
stack_wnd:
|
||
|
||
|
||
MEOS_APP_END
|
||
; ŠŽ<C5A0>…– <20><>Žƒ<C5BD>€ŒŒ›
|