mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-12 07:39:28 +01:00
implemented adding multiple files in image list editor from Martin Smat
git-svn-id: trunk@7623 -
This commit is contained in:
parent
7635fa3ea2
commit
addc4cc25a
@ -405,6 +405,7 @@ end;
|
||||
|
||||
procedure TGUITestRunner.StartTest(ATest: TTest);
|
||||
begin
|
||||
if ATest=0 then ;
|
||||
end;
|
||||
|
||||
procedure TGUITestRunner.EndTest(ATest: TTest);
|
||||
|
||||
@ -4363,10 +4363,13 @@ begin
|
||||
// find the ancestor type in the source
|
||||
NewAncestorName:='';
|
||||
AncestorType:=TForm;
|
||||
CodeToolBoss.FindFormAncestor(AnUnitInfo.Source,NewClassName,
|
||||
NewAncestorName,true);
|
||||
if not CodeToolBoss.FindFormAncestor(AnUnitInfo.Source,NewClassName,
|
||||
NewAncestorName,true)
|
||||
then begin
|
||||
DebugLn('TMainIDE.DoLoadLFM Filename="',AnUnitInfo.Filename,'" NewClassName=',NewClassName,'. Unable to find ancestor class: ',CodeToolBoss.ErrorMessage);
|
||||
end;
|
||||
if NewAncestorName<>'' then begin
|
||||
if AnsiCompareText(NewAncestorName,'TDataModule')=0 then begin
|
||||
if CompareText(NewAncestorName,'TDataModule')=0 then begin
|
||||
// use our TDataModule
|
||||
// (some fpc versions have non designable TDataModule)
|
||||
AncestorType:=TDataModule;
|
||||
|
||||
@ -723,7 +723,12 @@ begin
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
fUnitName:=CodeToolBoss.GetSourceName(fSource,false);
|
||||
NewUnitName:=CodeToolBoss.GetSourceName(fSource,false);
|
||||
if (NewUnitName='') then begin
|
||||
NewUnitName:=ExtractFileNameOnly(Filename);
|
||||
if CompareText(NewUnitName,fUnitName)=0 then exit;
|
||||
fUnitName:=NewUnitName;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TUnitInfo.CreateUnitName: string;
|
||||
|
||||
@ -73,6 +73,7 @@ Type
|
||||
procedure OnClickMoveDown(Sender: TObject);
|
||||
procedure SetModified(const AValue: boolean);
|
||||
procedure MoveImageIndex(Direction : Directions);
|
||||
procedure AddImageToList(FileName: string);
|
||||
public
|
||||
mnuLVPopup : TPopupMenu;
|
||||
constructor Create(aOwner: TComponent); override;
|
||||
@ -122,53 +123,58 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TImageListEditorDlg.AddImageToList(FileName: string);
|
||||
var Ext: string;
|
||||
i: integer;
|
||||
Bmp: TBitmap;
|
||||
AListItem: TListItem;
|
||||
begin
|
||||
Ext:=ExtractFileExt(FileName);
|
||||
//Check if the file is supported
|
||||
for i:=Low(FormatsSupported) to High(FormatsSupported) do
|
||||
begin
|
||||
if AnsiCompareText(Ext,FormatsSupported[i]) = 0 then
|
||||
begin
|
||||
fImg.Picture.LoadFromFile(FileName);
|
||||
Break;
|
||||
end;
|
||||
end;
|
||||
//If the image is loaded, then add to list
|
||||
if Assigned(fImg.Picture.Graphic) then
|
||||
begin
|
||||
if not fImg.Picture.Graphic.Empty then
|
||||
begin
|
||||
Bmp:=TBitMap.Create;
|
||||
Bmp.LoadFromFile(FileName);
|
||||
Modified:=true;
|
||||
i:=fImgL.Add(Bmp,nil);
|
||||
AListItem:=fLV.Items.Add;
|
||||
AListItem.Caption:=IntToStr(i);
|
||||
AListItem.ImageIndex:=i;
|
||||
fLV.Selected:=AListItem;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
//Select new image file and add in list
|
||||
procedure TImageListEditorDlg.OnClickAdd(Sender: TObject);
|
||||
Var OpenDlg: TOpenDialog;
|
||||
Ext : String;
|
||||
FileName: String;
|
||||
AListItem: TListItem;
|
||||
i : Integer;
|
||||
Bmp : TBitMap;
|
||||
begin
|
||||
Opendlg := TOpenDialog.Create(Self);
|
||||
Try
|
||||
Opendlg.Options:=[ofextensiondifferent, ofpathmustexist, offilemustexist, ofenablesizing];
|
||||
Opendlg.Options:=[ofExtensionDifferent, ofPathMustExist, ofFileMustExist, ofEnableSizing, ofAllowMultiSelect];
|
||||
Opendlg.Filter:='All supported files (*.xpm;*.bmp)|*.xpm;*.bmp|'+
|
||||
'Pixmap (*.xpm)|*.xpm|Bitmap (*.bmp)|*.bmp';
|
||||
OpenDlg.InitialDir:=fDirName; //last rirectory
|
||||
OpenDlg.InitialDir:=fDirName; //last directory
|
||||
|
||||
If OpenDlg.Execute then
|
||||
begin
|
||||
fDirName:=ExtractFilePath(FileName); //save the directory
|
||||
FileName:=OpenDlg.FileName;
|
||||
Ext:=ExtractFileExt(FileName);
|
||||
|
||||
//Check if the file is supported
|
||||
For i:=Low(FormatsSupported) to High(FormatsSupported) do
|
||||
begin
|
||||
If AnsiCompareText(Ext,FormatsSupported[I]) = 0 then
|
||||
begin
|
||||
fImg.Picture.LoadFromFile(FileName);
|
||||
fDirName:=ExtractFilePath(FileName); //save the directory
|
||||
Break;
|
||||
end;
|
||||
end;
|
||||
|
||||
//If the image is loaded, then add to list
|
||||
If Assigned(fImg.Picture.Graphic) then
|
||||
begin
|
||||
If not fImg.Picture.Graphic.Empty then
|
||||
begin
|
||||
Bmp:=TBitMap.Create;
|
||||
Bmp.LoadFromFile(FileName);
|
||||
Modified:=true;
|
||||
i:=fImgL.Add(Bmp,nil);
|
||||
AListItem:=fLV.Items.Add;
|
||||
AListItem.Caption:=IntToStr(i);
|
||||
AListItem.ImageIndex:=i;
|
||||
fLV.Selected:=AListItem;
|
||||
end;
|
||||
end;
|
||||
for i := 0 to OpenDlg.Files.Count - 1 do
|
||||
AddImageToList(OpenDlg.Files[i]);
|
||||
end;
|
||||
finally
|
||||
OpenDlg.Free;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user