2004-09-02 10:36:24 +00:00
|
|
|
{
|
|
|
|
:: Contains the dialog presented for the Container's Graphics property
|
|
|
|
::
|
|
|
|
:: Last changed: $Date$
|
|
|
|
:: Revision: $Rev$
|
|
|
|
:: Author: $Author$
|
|
|
|
}
|
|
|
|
unit X2CLGraphicsEditor;
|
|
|
|
|
|
|
|
interface
|
|
|
|
uses
|
|
|
|
ActnList,
|
|
|
|
Classes,
|
|
|
|
ComCtrls,
|
|
|
|
Controls,
|
2007-01-04 19:47:47 +00:00
|
|
|
DesignIntf,
|
2004-09-02 10:36:24 +00:00
|
|
|
Dialogs,
|
|
|
|
ExtCtrls,
|
|
|
|
ExtDlgs,
|
|
|
|
Forms,
|
|
|
|
ImgList,
|
|
|
|
StdCtrls,
|
|
|
|
ToolWin,
|
|
|
|
|
|
|
|
X2CLGraphicList;
|
|
|
|
|
|
|
|
type
|
2007-01-31 09:41:11 +00:00
|
|
|
TGraphicsEditorForm = class(TForm)
|
2004-09-02 10:36:24 +00:00
|
|
|
actAdd: TAction;
|
|
|
|
actClear: TAction;
|
|
|
|
actDelete: TAction;
|
|
|
|
actDown: TAction;
|
|
|
|
actOpen: TAction;
|
|
|
|
actSave: TAction;
|
|
|
|
actUp: TAction;
|
|
|
|
alGraphics: TActionList;
|
|
|
|
dlgOpen: TOpenPictureDialog;
|
|
|
|
dlgSave: TSavePictureDialog;
|
|
|
|
ilsIcons: TImageList;
|
|
|
|
imgPreview: TImage;
|
|
|
|
lblName: TLabel;
|
|
|
|
lstGraphics: TListBox;
|
|
|
|
pnlGraphics: TPanel;
|
|
|
|
pnlImage: TPanel;
|
|
|
|
pnlProperties: TPanel;
|
|
|
|
sbImage: TScrollBox;
|
|
|
|
spltGraphics: TSplitter;
|
|
|
|
tbClear: TToolButton;
|
|
|
|
tbDelete: TToolButton;
|
|
|
|
tbDown: TToolButton;
|
|
|
|
tbGraphics: TToolBar;
|
|
|
|
tbImage: TToolBar;
|
|
|
|
tbNew: TToolButton;
|
|
|
|
tbOpen: TToolButton;
|
|
|
|
tbSave: TToolButton;
|
|
|
|
tbSep1: TToolButton;
|
|
|
|
tbUp: TToolButton;
|
|
|
|
txtName: TEdit;
|
|
|
|
|
|
|
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|
|
|
procedure lstGraphicsClick(Sender: TObject);
|
|
|
|
procedure txtNameChange(Sender: TObject);
|
|
|
|
procedure actAddExecute(Sender: TObject);
|
|
|
|
procedure actDeleteExecute(Sender: TObject);
|
|
|
|
procedure actUpExecute(Sender: TObject);
|
|
|
|
procedure actDownExecute(Sender: TObject);
|
|
|
|
procedure actOpenExecute(Sender: TObject);
|
|
|
|
procedure actSaveExecute(Sender: TObject);
|
|
|
|
procedure actClearExecute(Sender: TObject);
|
2008-06-06 14:22:00 +00:00
|
|
|
procedure lstGraphicsData(Control: TWinControl; Index: Integer;
|
|
|
|
var Data: String);
|
|
|
|
function lstGraphicsDataFind(Control: TWinControl;
|
|
|
|
FindString: String): Integer;
|
|
|
|
procedure lstGraphicsKeyPress(Sender: TObject; var Key: Char);
|
2004-09-02 10:36:24 +00:00
|
|
|
private
|
2007-01-31 09:41:11 +00:00
|
|
|
FComponent: TX2GraphicContainer;
|
|
|
|
FComponentDesigner: IDesigner;
|
|
|
|
FUpdating: Boolean;
|
2004-09-02 10:36:24 +00:00
|
|
|
|
2007-01-04 19:47:47 +00:00
|
|
|
procedure InternalExecute(const AComponent: TComponent; const ADesigner: IDesigner);
|
2007-04-02 14:45:31 +00:00
|
|
|
|
2008-06-06 14:22:00 +00:00
|
|
|
procedure LoadGraphic(AGraphic: TX2GraphicContainerItem; const AFileName: string);
|
2007-01-31 09:41:11 +00:00
|
|
|
|
|
|
|
procedure ItemChanged(AUpdatePreview: Boolean = True);
|
|
|
|
procedure UpdateUI();
|
2004-09-02 10:36:24 +00:00
|
|
|
procedure UpdatePreview();
|
|
|
|
|
2007-01-04 19:47:47 +00:00
|
|
|
function Active(out AIndex: Integer; out AGraphic: TX2GraphicContainerItem): Boolean;
|
|
|
|
protected
|
|
|
|
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
2004-09-02 10:36:24 +00:00
|
|
|
public
|
2007-01-04 19:47:47 +00:00
|
|
|
class procedure Execute(const AComponent: TComponent; const ADesigner: IDesigner);
|
2004-09-02 10:36:24 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
uses
|
|
|
|
Graphics,
|
2008-06-06 14:22:00 +00:00
|
|
|
SysUtils,
|
|
|
|
Windows;
|
2007-01-31 09:41:11 +00:00
|
|
|
|
|
|
|
|
2004-09-02 10:36:24 +00:00
|
|
|
var
|
2007-01-31 09:41:11 +00:00
|
|
|
EditorInstance: TGraphicsEditorForm;
|
2004-09-02 10:36:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
2007-01-31 09:41:11 +00:00
|
|
|
{ TGraphicsEditorForm }
|
|
|
|
class procedure TGraphicsEditorForm.Execute(const AComponent: TComponent; const ADesigner: IDesigner);
|
2004-09-02 10:36:24 +00:00
|
|
|
begin
|
2007-01-31 09:41:11 +00:00
|
|
|
if not Assigned(EditorInstance) then
|
|
|
|
EditorInstance := TGraphicsEditorForm.Create(Application);
|
2004-09-02 10:36:24 +00:00
|
|
|
|
2007-01-31 09:41:11 +00:00
|
|
|
EditorInstance.InternalExecute(AComponent, ADesigner);
|
2004-09-02 10:36:24 +00:00
|
|
|
end;
|
|
|
|
|
2007-01-31 09:41:11 +00:00
|
|
|
procedure TGraphicsEditorForm.InternalExecute(const AComponent: TComponent; const ADesigner: IDesigner);
|
2004-09-02 10:36:24 +00:00
|
|
|
begin
|
2007-01-04 19:47:47 +00:00
|
|
|
FComponent := TX2GraphicContainer(AComponent);
|
|
|
|
FComponent.FreeNotification(Self);
|
2007-01-31 09:41:11 +00:00
|
|
|
|
2007-01-04 19:47:47 +00:00
|
|
|
FComponentDesigner := ADesigner;
|
|
|
|
Caption := Format('%s Graphics', [FComponent.Name]);
|
2004-09-02 10:36:24 +00:00
|
|
|
|
2008-06-06 14:22:00 +00:00
|
|
|
lstGraphics.Count := FComponent.GraphicCount;
|
|
|
|
lstGraphics.ItemIndex := 0;
|
2004-09-02 10:36:24 +00:00
|
|
|
|
2007-01-31 09:41:11 +00:00
|
|
|
UpdateUI();
|
|
|
|
UpdatePreview();
|
2004-09-02 10:36:24 +00:00
|
|
|
Show();
|
|
|
|
end;
|
|
|
|
|
2007-01-31 09:41:11 +00:00
|
|
|
|
|
|
|
procedure TGraphicsEditorForm.FormClose(Sender: TObject; var Action: TCloseAction);
|
2004-09-02 10:36:24 +00:00
|
|
|
begin
|
|
|
|
Action := caFree;
|
2007-01-31 09:41:11 +00:00
|
|
|
|
|
|
|
if Self = EditorInstance then
|
|
|
|
EditorInstance := nil;
|
2007-01-04 19:47:47 +00:00
|
|
|
|
|
|
|
if Assigned(FComponent) then
|
|
|
|
FComponent.RemoveFreeNotification(Self);
|
2004-09-02 10:36:24 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2008-06-06 14:22:00 +00:00
|
|
|
procedure TGraphicsEditorForm.LoadGraphic(AGraphic: TX2GraphicContainerItem; const AFileName: string);
|
2007-04-02 14:45:31 +00:00
|
|
|
begin
|
|
|
|
AGraphic.Picture.LoadFromFile(AFileName);
|
|
|
|
if Length(AGraphic.PictureName) = 0 then
|
|
|
|
begin
|
2008-06-06 14:22:00 +00:00
|
|
|
AGraphic.PictureName := ChangeFileExt(ExtractFileName(AFileName), '');
|
|
|
|
lstGraphics.Invalidate;
|
2007-04-02 14:45:31 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2007-01-31 09:41:11 +00:00
|
|
|
procedure TGraphicsEditorForm.ItemChanged(AUpdatePreview: Boolean);
|
|
|
|
begin
|
|
|
|
if Assigned(FComponentDesigner) then
|
2008-06-06 14:22:00 +00:00
|
|
|
FComponentDesigner.Modified;
|
2007-01-31 09:41:11 +00:00
|
|
|
|
|
|
|
UpdateUI();
|
|
|
|
|
|
|
|
if AUpdatePreview then
|
2008-06-06 14:22:00 +00:00
|
|
|
UpdatePreview;
|
2007-01-31 09:41:11 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TGraphicsEditorForm.UpdateUI();
|
2004-09-02 10:36:24 +00:00
|
|
|
var
|
2007-01-31 09:41:11 +00:00
|
|
|
enabled: Boolean;
|
|
|
|
index: Integer;
|
|
|
|
graphic: TX2GraphicContainerItem;
|
2004-09-02 10:36:24 +00:00
|
|
|
|
|
|
|
begin
|
2007-01-31 09:41:11 +00:00
|
|
|
enabled := Active(index, graphic);
|
|
|
|
actDelete.Enabled := enabled;
|
|
|
|
actOpen.Enabled := enabled;
|
2004-09-02 10:36:24 +00:00
|
|
|
|
2007-01-31 09:41:11 +00:00
|
|
|
if enabled then
|
|
|
|
enabled := Assigned(graphic.Picture.Graphic)
|
2004-09-02 10:36:24 +00:00
|
|
|
else
|
2007-01-31 09:41:11 +00:00
|
|
|
enabled := False;
|
2004-09-02 10:36:24 +00:00
|
|
|
|
2007-01-31 09:41:11 +00:00
|
|
|
actSave.Enabled := enabled;
|
|
|
|
actClear.Enabled := enabled;
|
|
|
|
|
|
|
|
actUp.Enabled := enabled and (index > 0);
|
2008-06-06 14:22:00 +00:00
|
|
|
actDown.Enabled := enabled and (index < Pred(FComponent.GraphicCount));
|
2004-09-02 10:36:24 +00:00
|
|
|
end;
|
|
|
|
|
2007-01-31 09:41:11 +00:00
|
|
|
|
|
|
|
procedure TGraphicsEditorForm.UpdatePreview();
|
2004-09-02 10:36:24 +00:00
|
|
|
var
|
2007-01-31 09:41:11 +00:00
|
|
|
index: Integer;
|
|
|
|
graphic: TX2GraphicContainerItem;
|
2004-09-02 10:36:24 +00:00
|
|
|
|
|
|
|
begin
|
2007-01-31 09:41:11 +00:00
|
|
|
FUpdating := True;
|
|
|
|
try
|
|
|
|
if Active(index, graphic) then
|
|
|
|
begin
|
|
|
|
imgPreview.Picture.Assign(graphic.Picture);
|
2008-06-06 14:22:00 +00:00
|
|
|
txtName.Text := graphic.PictureName;
|
|
|
|
lstGraphics.Invalidate;
|
2007-04-02 14:45:31 +00:00
|
|
|
end else
|
|
|
|
begin
|
|
|
|
imgPreview.Picture.Assign(nil);
|
|
|
|
txtName.Text := '';
|
2007-01-31 09:41:11 +00:00
|
|
|
end;
|
|
|
|
finally
|
|
|
|
FUpdating := False;
|
|
|
|
end;
|
2004-09-02 10:36:24 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-01-31 09:41:11 +00:00
|
|
|
function TGraphicsEditorForm.Active(out AIndex: Integer; out AGraphic: TX2GraphicContainerItem): Boolean;
|
2004-09-02 10:36:24 +00:00
|
|
|
begin
|
|
|
|
Result := False;
|
|
|
|
AIndex := lstGraphics.ItemIndex;
|
|
|
|
if AIndex = -1 then
|
|
|
|
exit;
|
|
|
|
|
2008-06-06 14:22:00 +00:00
|
|
|
AGraphic := FComponent.Graphics[AIndex];
|
2004-09-02 10:36:24 +00:00
|
|
|
Result := Assigned(AGraphic);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2007-01-31 09:41:11 +00:00
|
|
|
procedure TGraphicsEditorForm.lstGraphicsClick(Sender: TObject);
|
2004-09-02 10:36:24 +00:00
|
|
|
begin
|
2007-01-31 09:41:11 +00:00
|
|
|
UpdateUI();
|
2004-09-02 10:36:24 +00:00
|
|
|
UpdatePreview();
|
|
|
|
end;
|
|
|
|
|
2007-01-31 09:41:11 +00:00
|
|
|
|
|
|
|
procedure TGraphicsEditorForm.txtNameChange(Sender: TObject);
|
2004-09-02 10:36:24 +00:00
|
|
|
var
|
2007-01-31 09:41:11 +00:00
|
|
|
index: Integer;
|
|
|
|
graphic: TX2GraphicContainerItem;
|
2004-09-02 10:36:24 +00:00
|
|
|
|
|
|
|
begin
|
2007-01-31 09:41:11 +00:00
|
|
|
if FUpdating then
|
|
|
|
Exit;
|
|
|
|
|
|
|
|
if Active(index, graphic) then
|
2004-09-02 10:36:24 +00:00
|
|
|
begin
|
2008-06-06 14:22:00 +00:00
|
|
|
graphic.PictureName := txtName.Text;
|
|
|
|
lstGraphics.Invalidate;
|
2007-01-31 09:41:11 +00:00
|
|
|
|
|
|
|
ItemChanged(False);
|
2004-09-02 10:36:24 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2007-01-31 09:41:11 +00:00
|
|
|
procedure TGraphicsEditorForm.actAddExecute(Sender: TObject);
|
2004-09-02 10:36:24 +00:00
|
|
|
var
|
2007-01-31 09:41:11 +00:00
|
|
|
graphic: TX2GraphicContainerItem;
|
2007-04-02 14:45:31 +00:00
|
|
|
fileIndex: Integer;
|
2004-09-02 10:36:24 +00:00
|
|
|
|
|
|
|
begin
|
2007-01-04 19:47:47 +00:00
|
|
|
if Assigned(FComponentDesigner) then
|
|
|
|
begin
|
2007-04-02 14:45:31 +00:00
|
|
|
dlgOpen.Filter := GraphicFilter(TGraphic);
|
|
|
|
dlgOpen.Options := dlgOpen.Options + [ofAllowMultiSelect];
|
2004-09-02 10:36:24 +00:00
|
|
|
|
2007-04-02 14:45:31 +00:00
|
|
|
if dlgOpen.Execute() then
|
2007-01-04 19:47:47 +00:00
|
|
|
begin
|
2007-04-02 14:45:31 +00:00
|
|
|
for fileIndex := 0 to Pred(dlgOpen.Files.Count) do
|
|
|
|
begin
|
|
|
|
graphic := TX2GraphicContainerItem(FComponentDesigner.CreateComponent(TX2GraphicContainerItem, nil, 0, 0, 0, 0));
|
|
|
|
|
|
|
|
if Assigned(graphic) then
|
|
|
|
begin
|
2008-06-06 14:22:00 +00:00
|
|
|
graphic.Container := FComponent;
|
|
|
|
lstGraphics.Count := FComponent.GraphicCount;
|
2007-04-02 14:45:31 +00:00
|
|
|
|
2008-06-06 14:22:00 +00:00
|
|
|
LoadGraphic(graphic, dlgOpen.Files[fileIndex]);
|
2007-04-02 14:45:31 +00:00
|
|
|
end else
|
|
|
|
raise Exception.Create('Failed to create TX2GraphicContainerItem!');
|
|
|
|
end;
|
2007-01-04 19:47:47 +00:00
|
|
|
|
2007-01-31 09:41:11 +00:00
|
|
|
ItemChanged();
|
2007-04-02 14:45:31 +00:00
|
|
|
end;
|
2007-01-04 19:47:47 +00:00
|
|
|
end else
|
|
|
|
raise Exception.Create('Designer not found!');
|
2004-09-02 10:36:24 +00:00
|
|
|
end;
|
|
|
|
|
2007-01-31 09:41:11 +00:00
|
|
|
|
|
|
|
procedure TGraphicsEditorForm.actDeleteExecute(Sender: TObject);
|
2004-09-02 10:36:24 +00:00
|
|
|
var
|
2007-01-31 09:41:11 +00:00
|
|
|
index: Integer;
|
|
|
|
graphic: TX2GraphicContainerItem;
|
2004-09-02 10:36:24 +00:00
|
|
|
|
|
|
|
begin
|
2007-01-31 09:41:11 +00:00
|
|
|
if Active(index, graphic) then
|
2004-09-02 10:36:24 +00:00
|
|
|
begin
|
2007-01-04 19:47:47 +00:00
|
|
|
{ First attempt to remove the component; this will raise an exception
|
|
|
|
if it's not allowed, for example due to it being introduced in
|
|
|
|
an ancestor. }
|
2007-01-31 09:41:11 +00:00
|
|
|
graphic.Free();
|
2008-06-06 14:22:00 +00:00
|
|
|
lstGraphics.Count := FComponent.GraphicCount;
|
2004-09-02 10:36:24 +00:00
|
|
|
|
2008-06-06 14:22:00 +00:00
|
|
|
if index > Pred(FComponent.GraphicCount) then
|
|
|
|
index := Pred(FComponent.GraphicCount);
|
2004-09-02 10:36:24 +00:00
|
|
|
|
2007-01-31 09:41:11 +00:00
|
|
|
lstGraphics.ItemIndex := index;
|
|
|
|
|
|
|
|
ItemChanged();
|
2004-09-02 10:36:24 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2007-01-31 09:41:11 +00:00
|
|
|
|
|
|
|
procedure TGraphicsEditorForm.actUpExecute(Sender: TObject);
|
2004-09-02 10:36:24 +00:00
|
|
|
var
|
2007-01-31 09:41:11 +00:00
|
|
|
index: Integer;
|
|
|
|
graphic: TX2GraphicContainerItem;
|
2004-09-02 10:36:24 +00:00
|
|
|
|
|
|
|
begin
|
2007-01-31 09:41:11 +00:00
|
|
|
if Active(index, graphic) then
|
|
|
|
if index > 0 then
|
2004-09-02 10:36:24 +00:00
|
|
|
begin
|
2007-01-31 09:41:11 +00:00
|
|
|
graphic.Index := Pred(index);
|
|
|
|
lstGraphics.ItemIndex := Pred(index);
|
2008-06-06 14:22:00 +00:00
|
|
|
lstGraphics.Invalidate;
|
2007-01-31 09:41:11 +00:00
|
|
|
|
|
|
|
ItemChanged(False);
|
2004-09-02 10:36:24 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2007-01-31 09:41:11 +00:00
|
|
|
|
|
|
|
procedure TGraphicsEditorForm.actDownExecute(Sender: TObject);
|
2004-09-02 10:36:24 +00:00
|
|
|
var
|
2007-01-31 09:41:11 +00:00
|
|
|
index: Integer;
|
|
|
|
graphic: TX2GraphicContainerItem;
|
2004-09-02 10:36:24 +00:00
|
|
|
|
|
|
|
begin
|
2007-01-31 09:41:11 +00:00
|
|
|
if Active(index, graphic) then
|
2008-06-06 14:22:00 +00:00
|
|
|
if index < Pred(FComponent.GraphicCount) then
|
2004-09-02 10:36:24 +00:00
|
|
|
begin
|
2007-01-31 09:41:11 +00:00
|
|
|
graphic.Index := Succ(index);
|
|
|
|
lstGraphics.ItemIndex := Succ(index);
|
2008-06-06 14:22:00 +00:00
|
|
|
lstGraphics.Invalidate;
|
2007-01-31 09:41:11 +00:00
|
|
|
|
|
|
|
ItemChanged(False);
|
2004-09-02 10:36:24 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2007-01-31 09:41:11 +00:00
|
|
|
procedure TGraphicsEditorForm.actOpenExecute(Sender: TObject);
|
2004-09-02 10:36:24 +00:00
|
|
|
var
|
2007-01-31 09:41:11 +00:00
|
|
|
index: Integer;
|
|
|
|
graphic: TX2GraphicContainerItem;
|
2004-09-02 10:36:24 +00:00
|
|
|
|
|
|
|
begin
|
2007-01-31 09:41:11 +00:00
|
|
|
if Active(index, graphic) then
|
2004-09-02 10:36:24 +00:00
|
|
|
begin
|
|
|
|
dlgOpen.Filter := GraphicFilter(TGraphic);
|
2007-04-02 14:45:31 +00:00
|
|
|
dlgOpen.Options := dlgOpen.Options - [ofAllowMultiSelect];
|
|
|
|
|
2004-09-02 10:36:24 +00:00
|
|
|
if dlgOpen.Execute() then
|
|
|
|
begin
|
2008-06-06 14:22:00 +00:00
|
|
|
LoadGraphic(graphic, dlgOpen.FileName);
|
2007-01-31 09:41:11 +00:00
|
|
|
ItemChanged();
|
2004-09-02 10:36:24 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2007-01-31 09:41:11 +00:00
|
|
|
procedure TGraphicsEditorForm.actSaveExecute(Sender: TObject);
|
2004-09-02 10:36:24 +00:00
|
|
|
var
|
2007-01-31 09:41:11 +00:00
|
|
|
index: Integer;
|
|
|
|
graphic: TX2GraphicContainerItem;
|
|
|
|
graphicClass: TGraphicClass;
|
2004-09-02 10:36:24 +00:00
|
|
|
|
|
|
|
begin
|
2007-01-31 09:41:11 +00:00
|
|
|
if Active(index, graphic) then
|
|
|
|
if Assigned(graphic.Picture.Graphic) then begin
|
|
|
|
graphicClass := TGraphicClass(graphic.Picture.Graphic.ClassType);
|
|
|
|
dlgSave.Filter := GraphicFilter(graphicClass);
|
|
|
|
dlgSave.FileName := ChangeFileExt(graphic.PictureName, '.' + GraphicExtension(graphicClass));
|
|
|
|
|
2004-09-02 10:36:24 +00:00
|
|
|
if dlgSave.Execute() then
|
2007-01-31 09:41:11 +00:00
|
|
|
graphic.Picture.SaveToFile(dlgSave.FileName);
|
2004-09-02 10:36:24 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2007-01-31 09:41:11 +00:00
|
|
|
procedure TGraphicsEditorForm.actClearExecute(Sender: TObject);
|
2004-09-02 10:36:24 +00:00
|
|
|
var
|
2007-01-31 09:41:11 +00:00
|
|
|
index: Integer;
|
|
|
|
graphic: TX2GraphicContainerItem;
|
2004-09-02 10:36:24 +00:00
|
|
|
|
|
|
|
begin
|
2007-01-31 09:41:11 +00:00
|
|
|
if Active(index, graphic) then
|
2004-09-02 10:36:24 +00:00
|
|
|
begin
|
2007-01-31 09:41:11 +00:00
|
|
|
graphic.Picture.Assign(nil);
|
|
|
|
ItemChanged();
|
2004-09-02 10:36:24 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2007-01-04 19:47:47 +00:00
|
|
|
|
2007-01-31 09:41:11 +00:00
|
|
|
procedure TGraphicsEditorForm.Notification(AComponent: TComponent; Operation: TOperation);
|
2007-01-04 19:47:47 +00:00
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
|
|
|
|
if (Operation = opRemove) and (AComponent = FComponent) then
|
|
|
|
begin
|
|
|
|
FComponent := nil;
|
|
|
|
Close();
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2008-06-06 14:22:00 +00:00
|
|
|
|
|
|
|
procedure TGraphicsEditorForm.lstGraphicsData(Control: TWinControl; Index: Integer; var Data: String);
|
|
|
|
begin
|
|
|
|
Data := Format('%d - %s', [Index, FComponent.Graphics[Index].PictureName]);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TGraphicsEditorForm.lstGraphicsDataFind(Control: TWinControl; FindString: String): Integer;
|
|
|
|
var
|
|
|
|
graphicIndex: Integer;
|
|
|
|
|
|
|
|
begin
|
|
|
|
Result := -1;
|
|
|
|
|
|
|
|
for graphicIndex := 0 to Pred(FComponent.GraphicCount) do
|
|
|
|
if SameText(Copy(FComponent.Graphics[graphicIndex].PictureName, 1, Length(FindString)), FindString) then
|
|
|
|
begin
|
|
|
|
Result := graphicIndex;
|
|
|
|
Break;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TGraphicsEditorForm.lstGraphicsKeyPress(Sender: TObject; var Key: Char);
|
|
|
|
begin
|
|
|
|
{ Because the listbox is virtual, Return causes the ItemIndex to reset to 0 }
|
|
|
|
if Ord(Key) = VK_RETURN then
|
|
|
|
Key := #0;
|
|
|
|
end;
|
|
|
|
|
2004-09-02 10:36:24 +00:00
|
|
|
end.
|