From addc4cc25aa596572c90c7a0785e89c76299dbc5 Mon Sep 17 00:00:00 2001 From: mattias Date: Sun, 4 Sep 2005 08:46:52 +0000 Subject: [PATCH] implemented adding multiple files in image list editor from Martin Smat git-svn-id: trunk@7623 - --- components/fpcunit/guitestrunner.pas | 1 + ide/main.pp | 9 ++-- ide/project.pp | 7 ++- ideintf/imagelisteditor.pp | 72 +++++++++++++++------------- 4 files changed, 52 insertions(+), 37 deletions(-) diff --git a/components/fpcunit/guitestrunner.pas b/components/fpcunit/guitestrunner.pas index e7e01e0395..3887fc0fe5 100644 --- a/components/fpcunit/guitestrunner.pas +++ b/components/fpcunit/guitestrunner.pas @@ -405,6 +405,7 @@ end; procedure TGUITestRunner.StartTest(ATest: TTest); begin + if ATest=0 then ; end; procedure TGUITestRunner.EndTest(ATest: TTest); diff --git a/ide/main.pp b/ide/main.pp index 827edadabd..f21fe64384 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -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; diff --git a/ide/project.pp b/ide/project.pp index 23a0c6f730..862ccf3585 100644 --- a/ide/project.pp +++ b/ide/project.pp @@ -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; diff --git a/ideintf/imagelisteditor.pp b/ideintf/imagelisteditor.pp index bd5956d623..9db7004473 100644 --- a/ideintf/imagelisteditor.pp +++ b/ideintf/imagelisteditor.pp @@ -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;