Вверх ↑
Разработчик
Ответов: 26158
Рейтинг: 2127
#1: 2013-08-10 10:33:53 ЛС | профиль | цитата
Galkov писал(а):
покажи весь AlignChildrenProc

Вот

//[procedure AlignChildrenProc]
{$ifdef ASM_VERSION}
procedure AlignChildrenProc(P: PObj);
const AlignModes = (1 shl byte(caBottom))+(1 shl byte(caTop))+
(((1 shl byte(caRight)) +(1 shl byte(caLeft)))shl 8)+
(((1 shl byte(caClient))+(1 shl byte(caNone)))shl 16);
asm
test eax,eax
jz @@Ret

// cmp [eax].TControl.fParent,0
// setz dl
// or dl,[eax].TControl.fisForm
// btr dword ptr[eax].TControl.fAligning,oaFromSelf
// ja @@20
// с этого места ------------------
btr dword ptr[eax].TControl.fAligning,oaFromSelf
jc @@20
cmp [eax].TControl.fParent,0
setz dl
or dl,[eax].TControl.fisForm
jnz @@20
// до этого ------------------------
or byte ptr[eax].TControl.fAligning,(1 shl oaWaitAlign)
mov eax,[eax].TControl.fParent
@@20:
call @@ToBeAlign
jnz @@DoAlign
@@Ret:
retn

@@ToBeAlign:
mov dl,[eax].TControl.fVisible
or dl,[eax].TControl.fCreateHidden
je @@10
and dl,[eax].TControl.fisForm
jne @@Ret
cmp dword ptr[eax].TControl.fParent,0
je @@11
push eax
mov eax,[eax].TControl.fParent
call @@ToBeAlign
pop eax
@@10:
xor dl,1
or [eax].TControl.fAligning,dl
@@11:
xor dl,1
retn

@@DoAlign:
push ebp
push ebx
push esi
push edi
push AlignModes //00210A14h
sub esp,030h
mov ebx,eax
and byte ptr[ebx].TControl.fAligning,not(1 shl oaWaitAlign)
or byte ptr[ebx].TControl.fAligning,(1 shl oaAligning)
lea edx,[esp+20h] //@CR
call TControl.ClientRect
@@Main:
mov eax,[ebx].TControl.fChildren
mov edi,[eax].TList.fCount
mov ebp,[eax].TList.fItems
jmp @@entry
@@loop:
mov esi,[ebp]
mov al,[esi].TControl.fVisible
or al,[esi].TControl.fCreateHidden
jz @@continue
movzx eax,[esi].TControl.fAlign
bt [esp+30h],eax //Allowed
jnc @@continue
cmp byte ptr[esi].TControl.fNotUseAlign,0
jne @@align
mov edx,esp //@R
mov eax,esi //C
call TControl.GetBoundsRect
mov eax,[esp+0Ch] //R.Bottom
mov [esp+1Ch],eax //H
mov eax,[esp+08h] //R.Right
mov [esp+18h],eax //W
mov eax,[esp+04h] //R.Top
mov [esp+14h],eax //R1.Top
sub [esp+1Ch],eax //H
mov eax,[esp] //R.Left
mov [esp+10h],eax //R1.Left
sub [esp+18h],eax //W
mov edx,[ebx].TControl.fMargin
movzx ecx,byte ptr[esi].TControl.fAlign
loop @@caTop
mov eax,[esp+20h] //CR.Left
sub eax,[esp] //R.Left
add eax,edx //+Margin
mov ecx,[esp+18h] //W
add ecx,edx //+Margin
add [esp+20h],ecx //CR.Left
jmp @@00
@@caTop:
loop @@caRight
mov eax,[esp+24h] //CR.Top
sub eax,[esp+04h] //R.Top
add eax,edx //+Margin
mov ecx,[esp+1Ch] //H
add ecx,edx //+Margin
add [esp+24h],ecx //CR.Top
jmp @@01
@@caRight:
loop @@caBottom
mov eax,[esp+28h] //CR.Right
sub eax,[esp+08h] //R.Right
sub eax,edx //-Margin
mov ecx,[esp+18h] //W
add ecx,edx //+Margin
sub [esp+28h],ecx //CR.Right
@@00:
add [esp],eax //R.Left
add [esp+08h],eax //R.Right
mov eax,[esp+2Ch] //CR.Bottom
sub eax,edx //+Margin
mov [esp+0Ch],eax //R.Bottom
add edx,[esp+24h] //Margin+CR.Top
mov [esp+04h],edx //R.Top
jmp @@caNone
@@caBottom:
loop @@caClient
mov eax,[esp+2Ch] //CR.Bottom
sub eax,[esp+0Ch] //R.Bottom
sub eax,edx //-Margin
mov ecx,[esp+1Ch] //H
add ecx,edx //+Margin
sub [esp+2Ch],ecx //CR.Bottom
@@01:
add [esp+04h],eax //R.Top
add [esp+0Ch],eax //R.Bottom
mov eax,[esp+28h] //CR.Right
sub eax,edx //-Margin
mov [esp+08h],eax //R.Right
add edx,[esp+20h] //Margin+CR.Left
mov [esp],edx //R.Left
jmp @@caNone
@@caClient:
loop @@caNone
mov eax,[esp+2Ch] //CR.Bottom
sub eax,edx //-Margin
mov [esp+0Ch],eax //R.Bottom
mov eax,[esp+28h] //CR.Right
sub eax,edx //-Margin
mov [esp+08h],eax //R.Right
mov eax,[esp+24h] //CR.Top
add eax,edx //+Margin
mov [esp+04h],eax //R.Top
add edx,[esp+20h] //Margin+CR.Left
mov [esp],edx //R.Left
@@caNone:
mov eax,[esp] //R.Left
cmp eax,[esp+08h] //R.Right
jle @@02
mov [esp+08h],eax //R.Right
@@02:
mov eax,[esp+04h] //R.Top
cmp eax,[esp+0Ch] //R.Bottom
jle @@03
mov [esp+0Ch],eax //R.Bottom
@@03:
mov edx,[esp] //R.Left
sub edx,[esp+10h] //R1.Left
mov eax,[esp+04h] //R.Top
sub eax,[esp+14h] //R1.Top
or edx,eax //ChgPos
mov ecx,[esp+08h] //R.Right
sub ecx,[esp] //R.Left
sub ecx,[esp+18h] //W
mov eax,[esp+0Ch] //R.Bottom
sub eax,[esp+04h] //R.Top
sub eax,[esp+1Ch] //H
or eax,ecx
jz @@04
and byte ptr[esi].TControl.fAligning,not(1 shl oaWaitAlign)
or byte ptr[esi].TControl.fAligning,(1 shl oaFromSelf)
@@04:
or eax,edx
jz @@align
mov edx,esp //@R
mov eax,esi //C
call TControl.SetBoundsRect
@@align:
test byte ptr[esi].TControl.fAligning,(1 shl oaWaitAlign)
jz @@continue
mov eax,esi //C
call @@DoAlign
@@continue:
test byte ptr[ebx].TControl.fAligning,(1 shl oaAligning)
jz @@exit
add ebp,4
@@entry:
dec edi
jge @@loop
shr dword ptr[esp+30h],8 //Allowed
jnz @@Main
and byte ptr[ebx].TControl.fAligning,not(1 shl oaAligning)
@@exit:
add esp,34h
pop edi
pop esi
pop ebx
pop ebp
end;
{$else PAS_VERSION}
procedure AlignChildrenProc_(P:PControl);
type TAligns = set of TControlAlign;
var CR: TRect;
procedure DoAlign(Allowed:TAligns);
var I, W, H: Integer;
C: PControl;
R, R1: TRect;
ChgPos, ChgSiz: Boolean;
begin
for I := 0 to P.fChildren.fCount-1 do begin
if not (oaAligning in P.fAligning) then exit;
C := P.fChildren.fItems[ I ];
with C{-}^{+} do begin
if (not(fVisible or fCreateHidden))
or(not(fAlign in Allowed)) then continue;
if not fNotUseAlign then begin
R := BoundsRect;
R1 := R;
W := R.Right - R.Left;
H := R.Bottom - R.Top;
case FAlign of
caTop:
begin
OffsetRect( R, 0, -R.Top + CR.Top + P.Margin );
Inc( CR.Top, H + P.Margin );
R.Left := CR.Left + P.Margin;
R.Right := CR.Right - P.Margin;
end;
caBottom:
begin
OffsetRect( R, 0, -R.Bottom + CR.Bottom - P.Margin );
Dec( CR.Bottom, H + P.Margin );
R.Left := CR.Left + P.Margin;
R.Right := CR.Right - P.Margin;
end;
caLeft:
begin
OffsetRect( R, -R.Left + CR.Left + P.Margin, 0 );
Inc( CR.Left, W + P.Margin );
R.Top := CR.Top + P.Margin;
R.Bottom := CR.Bottom - P.Margin;
end;
caRight:
begin
OffsetRect( R, -R.Right + CR.Right - P.Margin, 0 );
Dec( CR.Right, W + P.Margin );
R.Top := CR.Top + P.Margin;
R.Bottom := CR.Bottom - P.Margin;
end;
caClient:
begin
R := CR;
InflateRect( R, -P.Margin, -P.Margin );
end;
end;
if R.Right < R.Left then R.Right := R.Left;
if R.Bottom < R.Top then R.Bottom := R.Top;
ChgPos := (R.Left <> R1.Left) or (R.Top <> R1.Top);
ChgSiz := (R.Right - R.Left <> W) or (R.Bottom - R.Top <> H);
if ChgSiz then begin
exclude(fAligning,oaWaitAlign);
include(fAligning,oaFromSelf);
end;
if ChgPos or ChgSiz then BoundsRect := R;
end;
if oaWaitAlign in fAligning then AlignChildrenProc_(C);
end;
end;
end;
begin
exclude(P.fAligning,oaWaitAlign);
include(P.fAligning,oaAligning);
CR := P.ClientRect;
DoAlign( [ caTop, caBottom ] );
DoAlign( [ caLeft, caRight ] );
DoAlign( [ caClient,caNone ] );
exclude(P.fAligning,oaAligning);
end;

procedure AlignChildrenProc(P: PObj);
function ToBeAlign( S: PControl ):boolean;
begin with S{-}^{+} do begin
Result := (fVisible or fCreateHidden)
and(isForm or(fParent=nil)or ToBeAlign(fParent));
if not Result then include(fAligning,oaWaitAlign);
end; end;
begin
if P = nil then Exit;
if oaFromSelf in PControl(P).fAligning then
exclude(PControl(P).fAligning,oaFromSelf)
else if(not PControl(P).isForm)and(PControl(P).fParent<>nil) then begin
include(PControl(P).fAligning,oaWaitAlign);
P := PControl(P).fParent;
end;
if not ToBeAlign(PControl(P)) then exit;
AlignChildrenProc_(PControl(P));
end;
{$endif}

карма: 22

0