mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2026-01-06 07:22:34 +01:00
Imagelist: fix moving first item down, incl refactor Issue #033903 Patch by FTurtle
git-svn-id: trunk@58587 -
This commit is contained in:
parent
117bbb1157
commit
7e3ca12084
@ -205,7 +205,7 @@ object ImageListEditorDlg: TImageListEditorDlg
|
||||
BorderSpacing.Top = 4
|
||||
BorderSpacing.Right = 6
|
||||
Caption = 'Move Up'
|
||||
OnClick = BtnMoveUpClick
|
||||
OnClick = BtnMoveUpDownClick
|
||||
TabOrder = 4
|
||||
end
|
||||
object BtnMoveDown: TButton
|
||||
@ -224,7 +224,7 @@ object ImageListEditorDlg: TImageListEditorDlg
|
||||
BorderSpacing.Top = 4
|
||||
BorderSpacing.Right = 6
|
||||
Caption = 'Move Down'
|
||||
OnClick = BtnMoveUpClick
|
||||
OnClick = BtnMoveUpDownClick
|
||||
TabOrder = 5
|
||||
end
|
||||
object BtnSave: TButton
|
||||
|
||||
@ -79,7 +79,7 @@ type
|
||||
procedure BtnClearClick(Sender: TObject);
|
||||
procedure BtnDeleteClick(Sender: TObject);
|
||||
procedure BtnReplaceClick(Sender: TObject);
|
||||
procedure BtnMoveUpClick(Sender: TObject);
|
||||
procedure BtnMoveUpDownClick(Sender: TObject);
|
||||
procedure btnSaveAllClick(Sender: TObject);
|
||||
procedure BtnSaveClick(Sender: TObject);
|
||||
procedure ColorBoxTransparentClick(Sender: TObject);
|
||||
@ -476,26 +476,27 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TImageListEditorDlg.BtnMoveUpClick(Sender: TObject);
|
||||
procedure TImageListEditorDlg.BtnMoveUpDownClick(Sender: TObject);
|
||||
var
|
||||
S, D: Integer;
|
||||
OldIndex, NewIndex: Integer;
|
||||
P: TObject;
|
||||
begin
|
||||
if ImageListBox.ItemIndex > 0 then
|
||||
if ImageListBox.ItemIndex < 0 then
|
||||
Exit;
|
||||
|
||||
OldIndex := ImageListBox.ItemIndex;
|
||||
NewIndex := OldIndex + (Sender as TControl).Tag;
|
||||
|
||||
if (NewIndex >= 0) and (NewIndex < ImageListBox.Items.Count) then
|
||||
begin
|
||||
S := ImageListBox.ItemIndex;
|
||||
D := (Sender as TControl).Tag;
|
||||
if (S + D >= 0) and (S + D < ImageListBox.Items.Count) then
|
||||
begin
|
||||
ImageList.Move(S, S + D);
|
||||
|
||||
P := ImageListBox.Items.Objects[S + D];
|
||||
ImageListBox.Items.Objects[S + D] := ImageListBox.Items.Objects[S];
|
||||
ImageListBox.Items.Objects[S] := P;
|
||||
|
||||
ImageListBox.ItemIndex := S + D;
|
||||
ImageListBox.SetFocus;
|
||||
end;
|
||||
ImageList.Move(OldIndex, NewIndex);
|
||||
|
||||
P := ImageListBox.Items.Objects[NewIndex];
|
||||
ImageListBox.Items.Objects[NewIndex] := ImageListBox.Items.Objects[OldIndex];
|
||||
ImageListBox.Items.Objects[OldIndex] := P;
|
||||
|
||||
ImageListBox.ItemIndex := NewIndex;
|
||||
ImageListBox.SetFocus;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user