From f2e1d9f50bf65e08fba0c52034db79c784c603f0 Mon Sep 17 00:00:00 2001 From: zeljko Date: Sat, 4 Sep 2010 17:14:49 +0000 Subject: [PATCH] Gtk2: fixed TGtk2WSWinControl.SetChildZPosition(). fixes #17298 git-svn-id: trunk@27269 - --- lcl/interfaces/gtk2/gtk2wscontrols.pp | 30 ++++++++++++++------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/lcl/interfaces/gtk2/gtk2wscontrols.pp b/lcl/interfaces/gtk2/gtk2wscontrols.pp index 1722ebf602..f2213ae71c 100644 --- a/lcl/interfaces/gtk2/gtk2wscontrols.pp +++ b/lcl/interfaces/gtk2/gtk2wscontrols.pp @@ -617,25 +617,27 @@ begin if not WSCheckHandleAllocated(AWincontrol, 'SetChildZPosition') then Exit; - if ANewPos < AChildren.Count div 2 then + if not WSCheckHandleAllocated(AChild, 'SetChildZPosition (child)') then + Exit; + + if (ANewPos <= 0) or (ANewPos >= AChildren.Count - 1) then begin - // move down (and others below us) - for n := ANewPos downto 0 do - begin - child := TWinControlHack(AChildren[n]); - if child.HandleAllocated then - TGtkPrivateWidgetClass( - child.WidgetSetClass.WSPrivate).SetZPosition(child, wszpBack); - end; + // simple + Child := TWinControlHack(AChild); + if ANewPos <= 0 then // bottom + TGtkPrivateWidgetClass( + Child.WidgetSetClass.WSPrivate).SetZPosition(Child, wszpBack) + else + TGtkPrivateWidgetClass( + Child.WidgetSetClass.WSPrivate).SetZPosition(Child, wszpFront); end else begin - // move up (and others above us) - for n := ANewPos to AChildren.Count - 1 do + for n := 1 to AChildren.Count - 1 do begin - child := TWinControlHack(AChildren[n]); - if child.HandleAllocated then + Child := TWinControlHack(AChildren[n]); + if Child.HandleAllocated then TGtkPrivateWidgetClass( - child.WidgetSetClass.WSPrivate).SetZPosition(child, wszpFront); + Child.WidgetSetClass.WSPrivate).SetZPosition(Child, wszpBack); end; end; end;