IDEIntf: image list editor: implemented auto splitting added image from etrusco

git-svn-id: trunk@9997 -
This commit is contained in:
mattias 2006-09-27 19:30:22 +00:00
parent d3a7eb61d5
commit 008cfe9546
3 changed files with 57 additions and 15 deletions

View File

@ -117,7 +117,7 @@ begin
Result:=rsLanguageDutch
else if CompareText(ID,'ja')=0 then
Result:=rsLanguageJapanese
else if CompareText(ID,'zh-cn')=0 then
else if CompareText(ID,'zh_CN')=0 then
Result:=rsLanguageChinese
else if CompareText(ID,'id')=0 then
Result:=rsLanguageIndonesian

View File

@ -34,8 +34,8 @@ interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, LResources, ComCtrls,
StdCtrls, Buttons, ExtCtrls, Menus, PropEdits, ComponentEditors, LCLProc,
ColorBox, ExtDlgs, ObjInspStrConsts;
StdCtrls, Buttons, ExtCtrls, Menus, LCLProc, ColorBox, ExtDlgs,
IDEDialogs, PropEdits, ComponentEditors, ObjInspStrConsts;
type
TGlyphAdjustment = (gaNone, gaStretch, gaCrop, gaCenter);
@ -110,8 +110,10 @@ type
function GetVerbCount: Integer; override;
end;
implementation
function EditImageList(AImageList: TImageList): Boolean;
var
ImageListEditorDlg: TImageListEditorDlg;
@ -156,6 +158,15 @@ begin
end;
end;
function CreateGlyphSplit(Src: TBitmap; Width, Height: Integer; SrcSplitIndex: Integer): TBitmap;
begin
Result := TBitmap.Create;
Result.Width := Width;
Result.Height := Height;
Result.Canvas.CopyRect( Rect(0, 0, Width, Height),
Src.Canvas, Bounds(SrcSplitIndex * Width, 0, Width, Height) );
end;
{ TImageListEditorDlg }
procedure TImageListEditorDlg.FormCreate(Sender: TObject);
@ -469,6 +480,9 @@ var
Picture: TPicture;
P: PGlyphInfo;
Node: TTreeNode;
v_PartCount: Integer;
c_Part: Integer;
v_CompositeBmp: TBitmap;
begin
SaveDialog.InitialDir := ExtractFileDir(FileName);
Bmp := nil;
@ -487,18 +501,40 @@ begin
begin
if not Bmp.Empty then
begin
Glyph := CreateGlyph(Bmp, ImageList.Width, ImageList.Height, gaNone);
I := ImageList.AddDirect(Glyph, nil);
New(P);
P^.Bitmap := Bmp;
P^.Adjustment := gaNone;
P^.TransparentColor := clFuchsia;
Node := TreeView.Items.AddObject(nil, IntToStr(I), P);
Node.ImageIndex := I;
Node.SelectedIndex := I;
TreeView.Selected := Node;
if (Bmp.Height = ImageList.Height)
and (Bmp.Width mod ImageList.Width = 0)
and (IDEQuestionDialog(Caption +' - '+ btnAdd.Caption,
s_SuggestSplitImage, mtConfirmation,
[s_AddAsSingle, mrNo, s_SplitImage, mrYes]) = mrYes)
then begin
v_PartCount := Bmp.Width div ImageList.Width;
v_CompositeBmp := Bmp;
Bmp := nil;
end
else begin
v_PartCount := 1;
v_CompositeBmp := nil;
end;
for c_Part := 0 to v_PartCount -1 do
begin
if Assigned(v_CompositeBmp) then
Bmp := CreateGlyphSplit(v_CompositeBmp, ImageList.Width, ImageList.Height, c_Part);
Glyph := CreateGlyph(Bmp, ImageList.Width, ImageList.Height, gaNone);
I := ImageList.AddDirect(Glyph, nil);
New(P);
P^.Bitmap := Bmp;
P^.Adjustment := gaNone;
P^.TransparentColor := clFuchsia;
Node := TreeView.Items.AddObject(nil, IntToStr(I), P);
Node.ImageIndex := I;
Node.SelectedIndex := I;
TreeView.Selected := Node;
end;
v_CompositeBmp.Free;
end
else Bmp.Free;
end;

View File

@ -309,6 +309,12 @@ resourcestring
rscdAlignment = 'Alignment';
rscdLeft = 'Left';
// image list editor
s_SuggestSplitImage = 'Do you want to split the image?';
s_AddAsSingle = 'Add as single';
s_SplitImage = 'Split image';
implementation
end.