lcl: improve reordering of toolbuttons if they were added on toolbar create and their bounds are equal

git-svn-id: trunk@15434 -
This commit is contained in:
paul 2008-06-16 07:06:37 +00:00
parent d5d9f4c4d6
commit e1ffc23daa
2 changed files with 31 additions and 14 deletions

View File

@ -36,14 +36,28 @@ begin
Row1 := (Control1.Top + HalfBtnHeight) div BtnHeight;
Row2 := (Control2.Top + HalfBtnHeight) div BtnHeight;
if Row1<Row2 then
Result:=-1
else if Row1>Row2 then
Result:=1
else if Control1.Left<Control2.Left then
Result:=-1
else if Control1.Left>Control2.Left then
Result:=1;
if Row1 < Row2 then
Result := -1
else
if Row1 > Row2 then
Result :=1
else
if Control1.Left < Control2.Left then
Result := -1
else
if Control1.Left > Control2.Left then
Result := 1
else
begin
Row1 := ToolBar.GetControlIndex(Control1);
Row2 := ToolBar.GetControlIndex(Control2);
// buttons order is reversed, iow last addeted button will be first
if Row1 < Row2 then
Result := 1
else
if Row1 > Row2 then
Result := -1
end;
end;
{------------------------------------------------------------------------------
@ -537,9 +551,10 @@ begin
AlignedControls.Add(CurControl)
end;
// sort OrderedControls
if FRealizedButtonHeight=0 then FRealizedButtonHeight:=FButtonHeight;
if FRealizedButtonHeight = 0 then
FRealizedButtonHeight := FButtonHeight;
OrderedControls.Sort(TListSortCompare(@CompareToolBarControl));
// position OrderedControls
CurClientRect:=ClientRect;
ARect:=CurClientRect;

View File

@ -809,7 +809,8 @@ begin
if FToolBar<>nil then
FToolBar.RemoveButton(Self);
FToolBar:=nil;
if AParent is TToolBar then begin
if AParent is TToolBar then
begin
if Style in [tbsButton,tbsDropDown,tbsCheck] then
NewWidth:=TToolBar(AParent).ButtonWidth
else
@ -822,10 +823,11 @@ begin
inherited SetParent(AParent);
// add to new button list
if Parent is TToolBar then begin
if Parent is TToolBar then
begin
FToolBar:=TToolBar(Parent);
i:=Index;
if i<0 then
i := Index;
if i < 0 then
FToolBar.AddButton(Self);
UpdateVisibleToolbar;
end;