2004-09-01 11:19:37 +00:00
|
|
|
{
|
|
|
|
:: Contains the design-time editor for the GraphicList
|
|
|
|
::
|
|
|
|
:: Last changed: $Date$
|
|
|
|
:: Revision: $Rev$
|
|
|
|
:: Author: $Author$
|
|
|
|
}
|
|
|
|
unit X2CLGLEditors;
|
|
|
|
|
|
|
|
interface
|
|
|
|
uses
|
|
|
|
DesignEditors,
|
|
|
|
DesignIntf;
|
|
|
|
|
|
|
|
type
|
|
|
|
TX2GraphicContainerEditor = class(TComponentEditor)
|
2007-01-04 19:47:47 +00:00
|
|
|
protected
|
|
|
|
procedure Convert();
|
2004-09-01 11:19:37 +00:00
|
|
|
public
|
|
|
|
procedure Edit(); override;
|
2004-09-02 10:36:24 +00:00
|
|
|
procedure ExecuteVerb(Index: Integer); override;
|
|
|
|
function GetVerb(Index: Integer): String; override;
|
|
|
|
function GetVerbCount(): Integer; override;
|
2004-09-01 11:19:37 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
TX2GraphicListEditor = class(TComponentEditor)
|
|
|
|
public
|
|
|
|
procedure Edit(); override;
|
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
uses
|
2004-09-02 10:36:24 +00:00
|
|
|
Classes,
|
2004-09-01 11:19:37 +00:00
|
|
|
SysUtils,
|
|
|
|
TypInfo,
|
2004-09-02 10:36:24 +00:00
|
|
|
|
|
|
|
X2CLGraphicList,
|
|
|
|
X2CLGraphicsEditor;
|
|
|
|
|
2007-01-04 19:47:47 +00:00
|
|
|
type
|
|
|
|
TProtectedX2GraphicContainer = class(TX2GraphicContainer);
|
|
|
|
|
2004-09-02 10:36:24 +00:00
|
|
|
|
2007-01-31 09:41:11 +00:00
|
|
|
{ TX2GraphicContainerEditor }
|
2007-01-04 19:47:47 +00:00
|
|
|
procedure TX2GraphicContainerEditor.Edit();
|
2004-09-02 10:36:24 +00:00
|
|
|
begin
|
2007-01-31 09:41:11 +00:00
|
|
|
TGraphicsEditorForm.Execute(Component, Self.Designer);
|
2004-09-02 10:36:24 +00:00
|
|
|
end;
|
|
|
|
|
2007-01-04 19:47:47 +00:00
|
|
|
procedure TX2GraphicContainerEditor.ExecuteVerb(Index: Integer);
|
2004-09-02 10:36:24 +00:00
|
|
|
begin
|
2007-01-04 19:47:47 +00:00
|
|
|
case Index of
|
|
|
|
0: Edit();
|
|
|
|
1: Convert();
|
|
|
|
end;
|
2004-09-02 10:36:24 +00:00
|
|
|
end;
|
|
|
|
|
2007-01-04 19:47:47 +00:00
|
|
|
function TX2GraphicContainerEditor.GetVerb(Index: Integer): String;
|
2004-09-02 10:36:24 +00:00
|
|
|
begin
|
2007-01-04 19:47:47 +00:00
|
|
|
case Index of
|
|
|
|
0: Result := 'Graphics Editor...';
|
|
|
|
1: Result := 'Convert items';
|
|
|
|
end;
|
2004-09-02 10:36:24 +00:00
|
|
|
end;
|
2004-09-01 11:19:37 +00:00
|
|
|
|
2007-01-04 19:47:47 +00:00
|
|
|
function TX2GraphicContainerEditor.GetVerbCount(): Integer;
|
2004-09-01 11:19:37 +00:00
|
|
|
begin
|
2007-01-04 19:47:47 +00:00
|
|
|
Result := 1;
|
|
|
|
|
|
|
|
if TProtectedX2GraphicContainer(Component).ConversionRequired then
|
|
|
|
Inc(Result);
|
2004-09-01 11:19:37 +00:00
|
|
|
end;
|
|
|
|
|
2007-01-04 19:47:47 +00:00
|
|
|
|
|
|
|
procedure TX2GraphicContainerEditor.Convert();
|
2004-09-01 11:19:37 +00:00
|
|
|
var
|
2007-01-04 19:47:47 +00:00
|
|
|
container: TX2GraphicContainer;
|
|
|
|
tempContainer: TX2GraphicContainer;
|
|
|
|
graphicIndex: Integer;
|
|
|
|
graphicItem: TX2GraphicContainerItem;
|
2004-09-01 11:19:37 +00:00
|
|
|
|
|
|
|
begin
|
2007-01-04 19:47:47 +00:00
|
|
|
if not Assigned(Designer) then
|
|
|
|
exit;
|
|
|
|
|
|
|
|
container := TX2GraphicContainer(Component);
|
|
|
|
tempContainer := TX2GraphicContainer.Create(nil);
|
2004-09-01 11:19:37 +00:00
|
|
|
try
|
2007-01-04 19:47:47 +00:00
|
|
|
tempContainer.Assign(container);
|
2004-09-01 11:19:37 +00:00
|
|
|
|
2007-01-04 19:47:47 +00:00
|
|
|
container.Clear();
|
2004-09-02 10:36:24 +00:00
|
|
|
|
2007-01-04 19:47:47 +00:00
|
|
|
for graphicIndex := 0 to Pred(tempContainer.GraphicCount) do
|
|
|
|
begin
|
|
|
|
graphicItem := TX2GraphicContainerItem(Designer.CreateComponent(TX2GraphicContainerItem, nil, 0, 0, 0, 0));
|
|
|
|
if Assigned(graphicItem) then
|
|
|
|
begin
|
|
|
|
graphicItem.Assign(tempContainer.Graphics[graphicIndex]);
|
|
|
|
graphicItem.Container := container;
|
|
|
|
end;
|
|
|
|
end;
|
2004-09-02 10:36:24 +00:00
|
|
|
|
2007-01-04 19:47:47 +00:00
|
|
|
TProtectedX2GraphicContainer(container).ConversionRequired := False;
|
|
|
|
finally
|
|
|
|
FreeAndNil(tempContainer);
|
|
|
|
end;
|
2004-09-02 10:36:24 +00:00
|
|
|
end;
|
|
|
|
|
2004-09-01 11:19:37 +00:00
|
|
|
|
2007-01-31 09:41:11 +00:00
|
|
|
{ TX2GraphicContainerEditor }
|
2004-09-01 11:19:37 +00:00
|
|
|
procedure TX2GraphicListEditor.Edit;
|
|
|
|
var
|
|
|
|
ifEditor: IComponentEditor;
|
|
|
|
|
|
|
|
begin
|
|
|
|
// Instead of showing the default ImageList dialog, check if a Container
|
|
|
|
// is available and execute it's default action...
|
|
|
|
if Component is TX2GraphicList then
|
|
|
|
with TX2GraphicList(Component) do
|
|
|
|
if Assigned(Container) then
|
|
|
|
begin
|
|
|
|
ifEditor := GetComponentEditor(Container, Designer);
|
|
|
|
if Assigned(ifEditor) then
|
|
|
|
ifEditor.Edit();
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|
2007-01-04 19:47:47 +00:00
|
|
|
|