2004-08-31 14:40:07 +00:00
|
|
|
{
|
|
|
|
:: X2CLGraphicList contains a container component for TGraphic
|
|
|
|
:: descendants and a replacement for TImageList.
|
|
|
|
::
|
2004-09-01 11:19:37 +00:00
|
|
|
:: Many thanks to Erik Stok. Before I could even work out the idea, he not
|
|
|
|
:: only had a similar idea, but created TPngImageList and worked out many of
|
|
|
|
:: the problems I thought we would face. His original (Dutch) article can
|
|
|
|
:: be found at:
|
2004-08-31 14:40:07 +00:00
|
|
|
:: http://www.erikstok.net/delphi/artikelen/xpicons.html
|
|
|
|
::
|
|
|
|
:: Last changed: $Date$
|
|
|
|
:: Revision: $Rev$
|
|
|
|
:: Author: $Author$
|
|
|
|
}
|
|
|
|
unit X2CLGraphicList;
|
|
|
|
|
|
|
|
interface
|
|
|
|
uses
|
|
|
|
Windows,
|
|
|
|
|
|
|
|
Classes,
|
|
|
|
Controls,
|
|
|
|
Graphics;
|
|
|
|
|
2004-09-25 16:19:08 +00:00
|
|
|
{$IFDEF VER150}
|
|
|
|
{$WARN UNSAFE_CODE OFF}
|
|
|
|
{$WARN UNSAFE_CAST OFF}
|
|
|
|
{$ENDIF}
|
|
|
|
|
|
|
|
|
2004-08-31 14:40:07 +00:00
|
|
|
type
|
|
|
|
// Forward declarations
|
|
|
|
TX2GraphicList = class;
|
|
|
|
TX2GraphicContainer = class;
|
|
|
|
|
|
|
|
{
|
|
|
|
:$ Holds a single graphic.
|
|
|
|
}
|
|
|
|
TX2GraphicCollectionItem = class(TCollectionItem, IChangeNotifier)
|
|
|
|
private
|
2004-09-01 17:41:06 +00:00
|
|
|
FName: String;
|
2004-08-31 14:40:07 +00:00
|
|
|
FPicture: TPicture;
|
|
|
|
|
|
|
|
procedure SetPicture(const Value: TPicture);
|
2004-09-01 17:41:06 +00:00
|
|
|
procedure SetName(const Value: String);
|
2004-08-31 14:40:07 +00:00
|
|
|
protected
|
|
|
|
function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall;
|
|
|
|
function _AddRef(): Integer; stdcall;
|
|
|
|
function _Release(): Integer; stdcall;
|
|
|
|
|
2004-09-01 17:41:06 +00:00
|
|
|
function GetDisplayName(): String; override;
|
|
|
|
|
2004-08-31 14:40:07 +00:00
|
|
|
procedure NotifierChanged();
|
|
|
|
procedure IChangeNotifier.Changed = NotifierChanged;
|
|
|
|
public
|
|
|
|
constructor Create(Collection: TCollection); override;
|
|
|
|
destructor Destroy(); override;
|
2004-09-01 11:19:37 +00:00
|
|
|
|
|
|
|
procedure AssignTo(Dest: TPersistent); override;
|
2004-08-31 14:40:07 +00:00
|
|
|
published
|
2004-09-01 17:41:06 +00:00
|
|
|
property Name: String read FName write SetName;
|
2004-08-31 14:40:07 +00:00
|
|
|
property Picture: TPicture read FPicture write SetPicture;
|
|
|
|
end;
|
|
|
|
|
|
|
|
{
|
|
|
|
:$ Holds a collection of graphics.
|
|
|
|
}
|
|
|
|
TX2GraphicCollection = class(TCollection)
|
|
|
|
private
|
|
|
|
FContainer: TX2GraphicContainer;
|
|
|
|
|
|
|
|
function GetItem(Index: Integer): TX2GraphicCollectionItem;
|
|
|
|
procedure SetItem(Index: Integer; Value: TX2GraphicCollectionItem);
|
|
|
|
protected
|
|
|
|
procedure Notify(Item: TCollectionItem; Action: TCollectionNotification); override;
|
|
|
|
procedure Update(Item: TCollectionItem); override;
|
|
|
|
public
|
|
|
|
constructor Create(const AContainer: TX2GraphicContainer);
|
|
|
|
|
|
|
|
function Add(): TX2GraphicCollectionItem;
|
2005-03-26 17:06:08 +00:00
|
|
|
function IndexByName(const AName: String): Integer;
|
|
|
|
function GraphicByName(const AName: String): TX2GraphicCollectionItem;
|
|
|
|
function PictureByName(const AName: String): TPicture;
|
2004-08-31 14:40:07 +00:00
|
|
|
|
|
|
|
property Items[Index: Integer]: TX2GraphicCollectionItem read GetItem
|
|
|
|
write SetItem; default;
|
|
|
|
end;
|
|
|
|
|
|
|
|
{
|
|
|
|
:$ Container object for graphics.
|
|
|
|
|
|
|
|
:: TX2GraphicContainer holds all the original graphic data. Link a container
|
|
|
|
:: to a TX2GraphicList to provide the graphics for various components.
|
|
|
|
}
|
|
|
|
TX2GraphicContainer = class(TComponent)
|
|
|
|
private
|
|
|
|
FGraphics: TX2GraphicCollection;
|
|
|
|
FLists: TList;
|
|
|
|
|
|
|
|
procedure SetGraphics(const Value: TX2GraphicCollection);
|
|
|
|
protected
|
|
|
|
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
|
|
|
procedure Notify(Item: TCollectionItem; Action: TCollectionNotification); virtual;
|
|
|
|
procedure Update(Item: TCollectionItem); virtual;
|
|
|
|
|
|
|
|
procedure RegisterList(const AList: TX2GraphicList);
|
|
|
|
procedure UnregisterList(const AList: TX2GraphicList);
|
|
|
|
public
|
|
|
|
constructor Create(AOwner: TComponent); override;
|
|
|
|
destructor Destroy(); override;
|
2004-09-01 11:19:37 +00:00
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
function IndexByName(const AName: String): Integer;
|
|
|
|
function GraphicByName(const AName: String): TX2GraphicCollectionItem;
|
|
|
|
function PictureByName(const AName: String): TPicture;
|
|
|
|
|
2004-09-01 11:19:37 +00:00
|
|
|
procedure AssignTo(Dest: TPersistent); override;
|
2004-08-31 14:40:07 +00:00
|
|
|
published
|
|
|
|
property Graphics: TX2GraphicCollection read FGraphics write SetGraphics;
|
|
|
|
end;
|
|
|
|
|
|
|
|
{
|
|
|
|
:$ Defines the various modes for drawing a larger image.
|
|
|
|
}
|
|
|
|
TX2GLStretchMode = (smCrop, smStretch);
|
|
|
|
|
|
|
|
{
|
|
|
|
:$ ImageList replacement for graphics.
|
2005-12-13 15:05:09 +00:00
|
|
|
|
|
|
|
:: If you are only using components which use ImageList.Draw directly
|
|
|
|
:: instead of the ImageList_Draw API (for ex. TMainMenu), set the Convert
|
|
|
|
:: property to False to save some processing.
|
2004-08-31 14:40:07 +00:00
|
|
|
}
|
|
|
|
TX2GraphicList = class(TImageList)
|
|
|
|
private
|
|
|
|
FBackground: TColor;
|
|
|
|
FContainer: TX2GraphicContainer;
|
2005-12-13 15:05:09 +00:00
|
|
|
FConvert: Boolean;
|
2004-08-31 15:02:35 +00:00
|
|
|
FEnabled: Boolean;
|
2004-08-31 14:40:07 +00:00
|
|
|
FStretchMode: TX2GLStretchMode;
|
2004-08-31 15:02:35 +00:00
|
|
|
FUpdateCount: Integer;
|
2004-08-31 14:40:07 +00:00
|
|
|
|
|
|
|
procedure SetBackground(const Value: TColor);
|
|
|
|
procedure SetContainer(const Value: TX2GraphicContainer);
|
2005-12-13 15:05:09 +00:00
|
|
|
procedure SetConvert(const Value: Boolean);
|
2004-08-31 15:02:35 +00:00
|
|
|
procedure SetEnabled(const Value: Boolean);
|
2005-12-13 15:05:09 +00:00
|
|
|
procedure SetStretchMode(const Value: TX2GLStretchMode);
|
2004-08-31 14:40:07 +00:00
|
|
|
protected
|
|
|
|
procedure DefineProperties(Filer: TFiler); override;
|
|
|
|
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
|
|
|
|
2004-08-31 15:02:35 +00:00
|
|
|
function DrawGraphic(const AIndex: Integer;
|
|
|
|
const ACanvas: TCanvas;
|
|
|
|
const AX, AY: Integer;
|
|
|
|
const AEnabled: Boolean = True): Boolean;
|
|
|
|
|
|
|
|
procedure DoDraw(Index: Integer; Canvas: TCanvas; X, Y: Integer;
|
|
|
|
Style: Cardinal; Enabled: Boolean = True); override;
|
|
|
|
|
2004-08-31 14:40:07 +00:00
|
|
|
procedure CreateImage(const AIndex: Integer; var AImage, AMask: TBitmap); virtual;
|
|
|
|
procedure AddImage(const AIndex: Integer); virtual;
|
|
|
|
procedure UpdateImage(const AIndex: Integer); virtual;
|
|
|
|
procedure DeleteImage(const AIndex: Integer); virtual;
|
|
|
|
|
|
|
|
procedure RebuildImages(); virtual;
|
2004-08-31 15:02:35 +00:00
|
|
|
|
|
|
|
procedure BeginUpdate();
|
|
|
|
procedure EndUpdate();
|
2004-08-31 14:40:07 +00:00
|
|
|
public
|
|
|
|
constructor Create(AOwner: TComponent); override;
|
|
|
|
destructor Destroy(); override;
|
|
|
|
|
2004-09-01 11:19:37 +00:00
|
|
|
procedure AssignTo(Dest: TPersistent); override;
|
|
|
|
|
2004-08-31 14:40:07 +00:00
|
|
|
procedure Loaded(); override;
|
2004-08-31 15:02:35 +00:00
|
|
|
procedure Change(); override;
|
2004-08-31 14:40:07 +00:00
|
|
|
published
|
|
|
|
property Background: TColor read FBackground write SetBackground default clBtnFace;
|
|
|
|
property Container: TX2GraphicContainer read FContainer write SetContainer;
|
2005-12-13 15:05:09 +00:00
|
|
|
property Convert: Boolean read FConvert write SetConvert default True;
|
2004-09-01 07:58:26 +00:00
|
|
|
property Enabled: Boolean read FEnabled write SetEnabled default True;
|
2004-08-31 14:40:07 +00:00
|
|
|
property StretchMode: TX2GLStretchMode read FStretchMode write SetStretchMode default smCrop;
|
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
uses
|
|
|
|
ImgList,
|
|
|
|
SysUtils;
|
|
|
|
|
|
|
|
type
|
|
|
|
PClass = ^TClass;
|
|
|
|
|
|
|
|
PRGBTripleArray = ^TRGBTripleArray;
|
|
|
|
TRGBTripleArray = array[Word] of TRGBTriple;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{=============== TX2GraphicCollectionItem
|
|
|
|
Initialization
|
|
|
|
========================================}
|
2005-03-26 17:06:08 +00:00
|
|
|
constructor TX2GraphicCollectionItem.Create(Collection: TCollection);
|
2004-08-31 14:40:07 +00:00
|
|
|
begin
|
|
|
|
FPicture := TPicture.Create();
|
|
|
|
FPicture.PictureAdapter := Self;
|
2004-08-31 18:46:34 +00:00
|
|
|
|
|
|
|
inherited;
|
2004-08-31 14:40:07 +00:00
|
|
|
end;
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
destructor TX2GraphicCollectionItem.Destroy();
|
2004-08-31 14:40:07 +00:00
|
|
|
begin
|
|
|
|
FreeAndNil(FPicture);
|
|
|
|
|
|
|
|
inherited;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicCollectionItem.AssignTo(Dest: TPersistent);
|
2004-09-01 11:19:37 +00:00
|
|
|
begin
|
|
|
|
if Dest is TX2GraphicCollectionItem then
|
|
|
|
with TX2GraphicCollectionItem(Dest) do
|
|
|
|
Picture := Self.Picture
|
|
|
|
else
|
|
|
|
inherited;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
function TX2GraphicCollectionItem.QueryInterface(const IID: TGUID;
|
|
|
|
out Obj): HResult;
|
2004-08-31 14:40:07 +00:00
|
|
|
begin
|
|
|
|
if GetInterface(IID, Obj) then
|
|
|
|
Result := 0
|
|
|
|
else
|
|
|
|
Result := E_NOINTERFACE;
|
|
|
|
end;
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
function TX2GraphicCollectionItem._AddRef(): Integer;
|
2004-08-31 14:40:07 +00:00
|
|
|
begin
|
|
|
|
Result := -1;
|
|
|
|
end;
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
function TX2GraphicCollectionItem._Release(): Integer;
|
2004-08-31 14:40:07 +00:00
|
|
|
begin
|
|
|
|
Result := -1;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
function TX2GraphicCollectionItem.GetDisplayName(): String;
|
2004-09-01 17:41:06 +00:00
|
|
|
begin
|
|
|
|
if Length(FName) > 0 then
|
|
|
|
Result := FName
|
|
|
|
else
|
|
|
|
Result := inherited GetDisplayName();
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicCollectionItem.NotifierChanged();
|
2004-08-31 14:40:07 +00:00
|
|
|
begin
|
|
|
|
Changed(False);
|
|
|
|
end;
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicCollectionItem.SetName(const Value: String);
|
2004-09-01 17:41:06 +00:00
|
|
|
begin
|
|
|
|
FName := Value;
|
|
|
|
Changed(False);
|
|
|
|
end;
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicCollectionItem.SetPicture(const Value: TPicture);
|
2004-08-31 14:40:07 +00:00
|
|
|
begin
|
|
|
|
FPicture.Assign(Value);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
{=================== TX2GraphicCollection
|
|
|
|
Item Management
|
|
|
|
========================================}
|
2005-03-26 17:06:08 +00:00
|
|
|
constructor TX2GraphicCollection.Create(const AContainer: TX2GraphicContainer);
|
2004-08-31 14:40:07 +00:00
|
|
|
begin
|
|
|
|
inherited Create(TX2GraphicCollectionItem);
|
|
|
|
|
|
|
|
FContainer := AContainer;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
function TX2GraphicCollection.Add(): TX2GraphicCollectionItem;
|
2004-08-31 14:40:07 +00:00
|
|
|
begin
|
|
|
|
Result := TX2GraphicCollectionItem(inherited Add());
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
function TX2GraphicCollection.IndexByName(const AName: String): Integer;
|
|
|
|
var
|
|
|
|
iIndex: Integer;
|
|
|
|
|
|
|
|
begin
|
|
|
|
Result := -1;
|
|
|
|
for iIndex := Pred(Count) downto 0 do
|
|
|
|
if SameText(Items[iIndex].Name, AName) then
|
|
|
|
begin
|
|
|
|
Result := iIndex;
|
|
|
|
break;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TX2GraphicCollection.GraphicByName(const AName: String): TX2GraphicCollectionItem;
|
|
|
|
var
|
|
|
|
iIndex: Integer;
|
|
|
|
|
|
|
|
begin
|
|
|
|
Result := nil;
|
|
|
|
iIndex := IndexByName(AName);
|
|
|
|
if iIndex > -1 then
|
|
|
|
Result := Items[iIndex];
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TX2GraphicCollection.PictureByName(const AName: String): TPicture;
|
|
|
|
var
|
|
|
|
pGraphic: TX2GraphicCollectionItem;
|
|
|
|
|
|
|
|
begin
|
|
|
|
Result := nil;
|
|
|
|
pGraphic := GraphicByName(AName);
|
|
|
|
if Assigned(pGraphic) then
|
|
|
|
Result := pGraphic.Picture;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TX2GraphicCollection.Notify(Item: TCollectionItem;
|
|
|
|
Action: TCollectionNotification);
|
2004-08-31 14:40:07 +00:00
|
|
|
begin
|
|
|
|
inherited;
|
2005-03-26 17:06:08 +00:00
|
|
|
|
2004-08-31 14:40:07 +00:00
|
|
|
if Assigned(FContainer) then
|
|
|
|
FContainer.Notify(Item, Action);
|
|
|
|
end;
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicCollection.Update(Item: TCollectionItem);
|
2004-08-31 14:40:07 +00:00
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
|
|
|
|
if Assigned(FContainer) then
|
|
|
|
FContainer.Update(Item);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
function TX2GraphicCollection.GetItem(Index: Integer): TX2GraphicCollectionItem;
|
2004-08-31 14:40:07 +00:00
|
|
|
begin
|
|
|
|
Result := TX2GraphicCollectionItem(inherited GetItem(Index));
|
|
|
|
end;
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicCollection.SetItem(Index: Integer; Value: TX2GraphicCollectionItem);
|
2004-08-31 14:40:07 +00:00
|
|
|
begin
|
|
|
|
inherited SetItem(Index, Value);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
{==================== TX2GraphicContainer
|
|
|
|
Initialization
|
|
|
|
========================================}
|
2005-03-26 17:06:08 +00:00
|
|
|
constructor TX2GraphicContainer.Create(AOwner: TComponent);
|
2004-08-31 14:40:07 +00:00
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
|
|
|
|
FGraphics := TX2GraphicCollection.Create(Self);
|
|
|
|
FLists := TList.Create();
|
|
|
|
end;
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
destructor TX2GraphicContainer.Destroy();
|
2004-08-31 14:40:07 +00:00
|
|
|
begin
|
|
|
|
FreeAndNil(FGraphics);
|
|
|
|
FreeAndNil(FLists);
|
|
|
|
|
|
|
|
inherited;
|
|
|
|
end;
|
|
|
|
|
2004-09-01 11:19:37 +00:00
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
function TX2GraphicContainer.IndexByName(const AName: String): Integer;
|
|
|
|
begin
|
|
|
|
Result := FGraphics.IndexByName(AName);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TX2GraphicContainer.GraphicByName(const AName: String): TX2GraphicCollectionItem;
|
|
|
|
begin
|
|
|
|
Result := FGraphics.GraphicByName(AName);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TX2GraphicContainer.PictureByName(const AName: String): TPicture;
|
|
|
|
begin
|
|
|
|
Result := FGraphics.PictureByName(AName);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TX2GraphicContainer.AssignTo(Dest: TPersistent);
|
2004-09-01 11:19:37 +00:00
|
|
|
begin
|
|
|
|
if Dest is TX2GraphicContainer then
|
|
|
|
with TX2GraphicContainer(Dest) do
|
|
|
|
Graphics := Self.Graphics
|
|
|
|
else
|
|
|
|
inherited;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicContainer.Notification(AComponent: TComponent; Operation: TOperation);
|
2004-08-31 14:40:07 +00:00
|
|
|
begin
|
|
|
|
if not Assigned(FLists) then
|
|
|
|
exit;
|
|
|
|
|
|
|
|
if Operation = opRemove then
|
|
|
|
FLists.Remove(AComponent)
|
|
|
|
else
|
|
|
|
// In design-time, if a TX2GraphicList is added and it doesn't yet have
|
|
|
|
// a container, assign ourselves to it for lazy programmers (such as me :))
|
|
|
|
if (Operation = opInsert) and (csDesigning in ComponentState) and
|
|
|
|
(AComponent is TX2GraphicList) and
|
|
|
|
(not Assigned(TX2GraphicList(AComponent).Container)) then
|
|
|
|
TX2GraphicList(AComponent).Container := Self;
|
|
|
|
|
|
|
|
inherited;
|
|
|
|
end;
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicContainer.Notify(Item: TCollectionItem;
|
|
|
|
Action: TCollectionNotification);
|
2004-08-31 14:40:07 +00:00
|
|
|
var
|
|
|
|
iList: Integer;
|
|
|
|
|
|
|
|
begin
|
|
|
|
case Action of
|
|
|
|
cnAdded:
|
|
|
|
for iList := FLists.Count - 1 downto 0 do
|
|
|
|
TX2GraphicList(FLists[iList]).AddImage(Item.Index);
|
|
|
|
cnDeleting:
|
|
|
|
for iList := FLists.Count - 1 downto 0 do
|
|
|
|
TX2GraphicList(FLists[iList]).DeleteImage(Item.Index);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicContainer.Update(Item: TCollectionItem);
|
2004-08-31 14:40:07 +00:00
|
|
|
var
|
|
|
|
iList: Integer;
|
|
|
|
|
|
|
|
begin
|
|
|
|
if Assigned(Item) then
|
|
|
|
for iList := FLists.Count - 1 downto 0 do
|
|
|
|
TX2GraphicList(FLists[iList]).UpdateImage(Item.Index)
|
|
|
|
else
|
|
|
|
for iList := FLists.Count - 1 downto 0 do
|
|
|
|
TX2GraphicList(FLists[iList]).RebuildImages();
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicContainer.RegisterList(const AList: TX2GraphicList);
|
2004-08-31 14:40:07 +00:00
|
|
|
begin
|
|
|
|
if FLists.IndexOf(AList) = -1 then
|
|
|
|
FLists.Add(AList);
|
|
|
|
end;
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicContainer.UnregisterList(const AList: TX2GraphicList);
|
2004-08-31 14:40:07 +00:00
|
|
|
begin
|
|
|
|
FLists.Remove(AList);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicContainer.SetGraphics(const Value: TX2GraphicCollection);
|
2004-08-31 14:40:07 +00:00
|
|
|
begin
|
|
|
|
FGraphics.Assign(Value);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{========================= TX2GraphicList
|
|
|
|
Initialization
|
|
|
|
========================================}
|
2005-03-26 17:06:08 +00:00
|
|
|
constructor TX2GraphicList.Create(AOwner: TComponent);
|
2004-08-31 14:40:07 +00:00
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
|
|
|
|
FBackground := clBtnFace;
|
2004-08-31 18:46:34 +00:00
|
|
|
BkColor := clNone;
|
2005-12-13 15:05:09 +00:00
|
|
|
FConvert := True;
|
2004-09-01 07:58:26 +00:00
|
|
|
FEnabled := True;
|
2004-08-31 14:40:07 +00:00
|
|
|
FStretchMode := smCrop;
|
|
|
|
end;
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicList.Loaded();
|
2004-08-31 14:40:07 +00:00
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
|
|
|
|
RebuildImages();
|
|
|
|
end;
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicList.Change();
|
2004-08-31 15:02:35 +00:00
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
|
|
|
|
if FUpdateCount = 0 then
|
|
|
|
RebuildImages();
|
|
|
|
end;
|
|
|
|
|
2004-08-31 14:40:07 +00:00
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
destructor TX2GraphicList.Destroy();
|
2004-08-31 14:40:07 +00:00
|
|
|
begin
|
|
|
|
SetContainer(nil);
|
|
|
|
|
|
|
|
inherited;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicList.AssignTo(Dest: TPersistent);
|
2004-09-01 11:19:37 +00:00
|
|
|
begin
|
|
|
|
if Dest is TX2GraphicList then
|
|
|
|
with TX2GraphicList(Dest) do
|
|
|
|
begin
|
|
|
|
Background := Self.Background;
|
|
|
|
Container := Self.Container;
|
|
|
|
Enabled := Self.Enabled;
|
|
|
|
StretchMode := Self.StretchMode;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
inherited;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2004-08-31 14:40:07 +00:00
|
|
|
|
|
|
|
{========================= TX2GraphicList
|
|
|
|
Graphics
|
|
|
|
========================================}
|
2005-03-26 17:06:08 +00:00
|
|
|
function TX2GraphicList.DrawGraphic(const AIndex: Integer;
|
|
|
|
const ACanvas: TCanvas;
|
|
|
|
const AX, AY: Integer;
|
|
|
|
const AEnabled: Boolean = True): Boolean;
|
2004-09-01 17:41:06 +00:00
|
|
|
procedure InternalDrawGraphic(const ADest: TCanvas;
|
|
|
|
const ADestX, ADestY: Integer);
|
2004-08-31 14:40:07 +00:00
|
|
|
var
|
2004-08-31 18:46:34 +00:00
|
|
|
bmpTemp: TBitmap;
|
|
|
|
iHeight: Integer;
|
|
|
|
iWidth: Integer;
|
2004-08-31 14:40:07 +00:00
|
|
|
rDest: TRect;
|
2004-08-31 18:46:34 +00:00
|
|
|
rSource: TRect;
|
2004-08-31 14:40:07 +00:00
|
|
|
|
|
|
|
begin
|
|
|
|
with FContainer.Graphics[AIndex].Picture do
|
2004-08-31 18:46:34 +00:00
|
|
|
if (Width <= Self.Width) and (Height <= Self.Height) then
|
2004-09-01 17:41:06 +00:00
|
|
|
ADest.Draw(ADestX, ADestY, Graphic)
|
2004-08-31 14:40:07 +00:00
|
|
|
else
|
|
|
|
begin
|
2004-08-31 18:46:34 +00:00
|
|
|
iWidth := Width;
|
|
|
|
iHeight := Height;
|
|
|
|
|
|
|
|
if iWidth > Self.Width then
|
|
|
|
iWidth := Self.Width;
|
|
|
|
|
|
|
|
if iHeight > Self.Height then
|
|
|
|
iHeight := Self.Height;
|
|
|
|
|
2004-09-01 17:41:06 +00:00
|
|
|
rDest := Rect(ADestX, ADestY,
|
|
|
|
ADestX + iWidth, ADestY + iHeight);
|
2004-08-31 18:46:34 +00:00
|
|
|
rSource := Rect(0, 0, iWidth, iHeight);
|
|
|
|
|
|
|
|
case FStretchMode of
|
|
|
|
smCrop:
|
|
|
|
begin
|
|
|
|
bmpTemp := TBitmap.Create();
|
|
|
|
try
|
|
|
|
with bmpTemp do
|
|
|
|
begin
|
|
|
|
Width := iWidth;
|
|
|
|
Height := iHeight;
|
|
|
|
PixelFormat := pf24bit;
|
|
|
|
|
|
|
|
// Copy existing content
|
|
|
|
Canvas.CopyRect(rSource, ADest, rDest);
|
|
|
|
|
|
|
|
// Overlay graphic
|
|
|
|
Canvas.Draw(0, 0, Graphic);
|
|
|
|
|
|
|
|
// Copy back
|
|
|
|
ADest.CopyRect(rDest, Canvas, rDest);
|
|
|
|
end;
|
|
|
|
finally
|
|
|
|
FreeAndNil(bmpTemp);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
smStretch:
|
|
|
|
// Note: some TGraphic's don't support StretchDraw and will
|
|
|
|
// always crop. Nothing we can do about that...
|
|
|
|
ADest.StretchDraw(rDest, Graphic);
|
|
|
|
end;
|
2004-08-31 14:40:07 +00:00
|
|
|
end;
|
2004-08-31 15:02:35 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
|
|
|
bmpBackground: TBitmap;
|
|
|
|
bmpBlend: TBitmap;
|
2004-09-01 07:58:26 +00:00
|
|
|
iX: Integer;
|
|
|
|
iY: Integer;
|
|
|
|
pBackground: PRGBTripleArray;
|
|
|
|
pBlend: PRGBTripleArray;
|
2004-08-31 14:40:07 +00:00
|
|
|
|
2004-08-31 15:02:35 +00:00
|
|
|
begin
|
|
|
|
Result := False;
|
2004-10-07 19:34:57 +00:00
|
|
|
if not Assigned(FContainer) then
|
2004-10-07 18:21:44 +00:00
|
|
|
exit;
|
|
|
|
|
2004-10-07 19:34:57 +00:00
|
|
|
if (AIndex < 0) or (AIndex >= FContainer.Graphics.Count) then
|
|
|
|
exit;
|
|
|
|
|
|
|
|
if (not Assigned(FContainer.Graphics[AIndex].Picture.Graphic)) or
|
2004-08-31 18:46:34 +00:00
|
|
|
(FContainer.Graphics[AIndex].Picture.Graphic.Empty) then
|
2004-08-31 15:02:35 +00:00
|
|
|
exit;
|
|
|
|
|
|
|
|
if AEnabled then
|
|
|
|
// Enabled, simply draw the graphic
|
2004-09-01 17:41:06 +00:00
|
|
|
InternalDrawGraphic(ACanvas, AX, AY)
|
2004-08-31 15:02:35 +00:00
|
|
|
else
|
|
|
|
begin
|
|
|
|
// Disabled, need to draw the image using 50% transparency. There's only
|
|
|
|
// one problem; not all TGraphic's support that, and neither is there a
|
|
|
|
// generic way of determining a pixel's transparency. So instead, we
|
|
|
|
// blend the background with a copy of the background with the graphic
|
|
|
|
// painted on it...
|
|
|
|
bmpBackground := TBitmap.Create();
|
|
|
|
bmpBlend := TBitmap.Create();
|
|
|
|
try
|
|
|
|
// Get background from canvas
|
|
|
|
with bmpBackground do
|
|
|
|
begin
|
|
|
|
Width := Self.Width;
|
|
|
|
Height := Self.Height;
|
|
|
|
PixelFormat := pf24bit;
|
|
|
|
Canvas.CopyRect(Rect(0, 0, Width, Height), ACanvas,
|
|
|
|
Rect(AX, AY, AX + Width, AY + Height));
|
|
|
|
end;
|
|
|
|
|
|
|
|
bmpBlend.Assign(bmpBackground);
|
2004-09-01 17:41:06 +00:00
|
|
|
InternalDrawGraphic(bmpBlend.Canvas, 0, 0);
|
2004-08-31 15:02:35 +00:00
|
|
|
|
2004-09-01 07:58:26 +00:00
|
|
|
// Blend graphic with background at 50%
|
|
|
|
for iY := 0 to bmpBackground.Height - 1 do
|
|
|
|
begin
|
|
|
|
pBackground := bmpBackground.ScanLine[iY];
|
|
|
|
pBlend := bmpBlend.ScanLine[iY];
|
2004-09-01 17:41:06 +00:00
|
|
|
|
2004-09-01 07:58:26 +00:00
|
|
|
for iX := 0 to bmpBackground.Width - 1 do
|
|
|
|
with pBlend^[iX] do
|
|
|
|
begin
|
|
|
|
rgbtBlue := ((pBackground^[iX].rgbtBlue shl 7) +
|
|
|
|
(rgbtBlue shl 7)) shr 8;
|
|
|
|
rgbtGreen := ((pBackground^[iX].rgbtGreen shl 7) +
|
|
|
|
(rgbtGreen shl 7)) shr 8;
|
|
|
|
rgbtRed := ((pBackground^[iX].rgbtRed shl 7) +
|
|
|
|
(rgbtRed shl 7)) shr 8;
|
|
|
|
end;
|
|
|
|
end;
|
2004-08-31 15:02:35 +00:00
|
|
|
|
2004-08-31 18:46:34 +00:00
|
|
|
// Copy blended graphic back
|
|
|
|
ACanvas.Draw(AX, AY, bmpBlend);
|
2004-08-31 15:02:35 +00:00
|
|
|
finally
|
|
|
|
FreeAndNil(bmpBlend);
|
|
|
|
FreeAndNil(bmpBackground);
|
|
|
|
end;
|
2004-08-31 14:40:07 +00:00
|
|
|
end;
|
|
|
|
|
2004-08-31 15:02:35 +00:00
|
|
|
Result := True;
|
|
|
|
end;
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicList.DoDraw(Index: Integer; Canvas: TCanvas; X, Y: Integer;
|
|
|
|
Style: Cardinal; Enabled: Boolean = True);
|
2004-08-31 15:02:35 +00:00
|
|
|
begin
|
|
|
|
DrawGraphic(Index, Canvas, X, Y, Enabled);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicList.CreateImage(const AIndex: Integer;
|
|
|
|
var AImage, AMask: TBitmap);
|
2004-08-31 14:40:07 +00:00
|
|
|
function RGBTriple(const AColor: TColor): TRGBTriple;
|
|
|
|
var
|
|
|
|
cColor: Cardinal;
|
|
|
|
|
|
|
|
begin
|
|
|
|
cColor := ColorToRGB(AColor);
|
|
|
|
|
|
|
|
with Result do
|
|
|
|
begin
|
|
|
|
rgbtBlue := GetBValue(cColor);
|
|
|
|
rgbtGreen := GetGValue(cColor);
|
|
|
|
rgbtRed := GetRValue(cColor);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function SameColor(const AColor1, AColor2: TRGBTriple): Boolean;
|
|
|
|
begin
|
|
|
|
Result := CompareMem(@AColor1, @AColor2, SizeOf(TRGBTriple));
|
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
|
|
|
bmpCompare: TBitmap;
|
|
|
|
bOk: Boolean;
|
|
|
|
cImage: TRGBTriple;
|
|
|
|
cMask: TRGBTriple;
|
|
|
|
iBit: Integer;
|
|
|
|
iPosition: Integer;
|
|
|
|
iX: Integer;
|
|
|
|
iY: Integer;
|
|
|
|
pCompare: PRGBTripleArray;
|
|
|
|
pImage: PRGBTripleArray;
|
|
|
|
pMask: PByteArray;
|
|
|
|
|
|
|
|
begin
|
|
|
|
// Technique used here: draw the image twice, once on the background color,
|
|
|
|
// once on black. Loop through the two images, check if a pixel is the
|
|
|
|
// background color on one image and black on the other; if so then it's
|
|
|
|
// fully transparent. This doesn't eliminate all problems with alpha images,
|
|
|
|
// but it's the best option (at least for pre-XP systems).
|
|
|
|
//
|
|
|
|
// Note that components using ImageList.Draw will have full alpha support,
|
|
|
|
// this routine only ensures compatibility with ImageList_Draw components.
|
|
|
|
// TMenu is among the first, TToolbar and similar are amongst the latter.
|
|
|
|
with AImage do
|
|
|
|
begin
|
|
|
|
Width := Self.Width;
|
|
|
|
Height := Self.Height;
|
|
|
|
PixelFormat := pf24bit;
|
|
|
|
|
|
|
|
with Canvas do
|
|
|
|
begin
|
|
|
|
Brush.Color := FBackground;
|
|
|
|
FillRect(Rect(0, 0, Width, Height));
|
2004-08-31 15:02:35 +00:00
|
|
|
bOk := DrawGraphic(AIndex, Canvas, 0, 0, FEnabled);
|
2004-08-31 14:40:07 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
with AMask do
|
|
|
|
begin
|
|
|
|
Width := Self.Width;
|
|
|
|
Height := Self.Height;
|
|
|
|
PixelFormat := pf1bit;
|
|
|
|
|
|
|
|
with Canvas do
|
|
|
|
begin
|
|
|
|
Brush.Color := clBlack;
|
|
|
|
FillRect(Rect(0, 0, Width, Height));
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
// No point in looping through the
|
|
|
|
// images if they're blank anyways...
|
|
|
|
if not bOk then
|
|
|
|
exit;
|
|
|
|
|
|
|
|
bmpCompare := TBitmap.Create();
|
|
|
|
try
|
|
|
|
with bmpCompare do
|
|
|
|
begin
|
|
|
|
Width := Self.Width;
|
|
|
|
Height := Self.Height;
|
|
|
|
PixelFormat := pf24bit;
|
|
|
|
|
|
|
|
with Canvas do
|
|
|
|
begin
|
|
|
|
Brush.Color := clBlack;
|
|
|
|
FillRect(Rect(0, 0, Width, Height));
|
2004-08-31 15:02:35 +00:00
|
|
|
DrawGraphic(AIndex, Canvas, 0, 0, FEnabled);
|
2004-08-31 14:40:07 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
cImage := RGBTriple(FBackground);
|
|
|
|
cMask := RGBTriple(clBlack);
|
|
|
|
|
|
|
|
for iY := 0 to AImage.Height - 1 do
|
|
|
|
begin
|
|
|
|
pImage := AImage.ScanLine[iY];
|
|
|
|
pCompare := bmpCompare.ScanLine[iY];
|
|
|
|
pMask := AMask.ScanLine[iY];
|
|
|
|
iPosition := 0;
|
|
|
|
iBit := 128;
|
|
|
|
|
|
|
|
for iX := 0 to AImage.Width - 1 do
|
|
|
|
begin
|
|
|
|
if iBit = 128 then
|
|
|
|
pMask^[iPosition] := 0;
|
|
|
|
|
|
|
|
if SameColor(pImage^[iX], cImage) and
|
|
|
|
SameColor(pCompare^[iX], cMask) then
|
|
|
|
begin
|
|
|
|
// Transparent pixel
|
|
|
|
FillChar(pImage^[iX], SizeOf(TRGBTriple), $00);
|
|
|
|
pMask^[iPosition] := pMask^[iPosition] or iBit;
|
|
|
|
end;
|
|
|
|
|
|
|
|
iBit := iBit shr 1;
|
|
|
|
if iBit < 1 then
|
|
|
|
begin
|
|
|
|
iBit := 128;
|
|
|
|
Inc(iPosition);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
finally
|
|
|
|
FreeAndNil(bmpCompare);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicList.AddImage(const AIndex: Integer);
|
2004-08-31 14:40:07 +00:00
|
|
|
var
|
|
|
|
bmpImage: TBitmap;
|
|
|
|
bmpMask: TBitmap;
|
|
|
|
|
|
|
|
begin
|
|
|
|
if csLoading in ComponentState then
|
|
|
|
exit;
|
|
|
|
|
2004-08-31 15:02:35 +00:00
|
|
|
BeginUpdate();
|
2004-08-31 14:40:07 +00:00
|
|
|
try
|
2004-08-31 15:02:35 +00:00
|
|
|
bmpImage := TBitmap.Create();
|
|
|
|
bmpMask := TBitmap.Create();
|
|
|
|
try
|
|
|
|
CreateImage(AIndex, bmpImage, bmpMask);
|
|
|
|
Assert(AIndex <= Self.Count, 'AAAH! Images out of sync! *panics*');
|
|
|
|
|
|
|
|
if AIndex = Self.Count then
|
|
|
|
Add(bmpImage, bmpMask)
|
|
|
|
else
|
|
|
|
Insert(AIndex, bmpImage, bmpMask);
|
|
|
|
finally
|
|
|
|
FreeAndNil(bmpMask);
|
|
|
|
FreeAndNil(bmpImage);
|
|
|
|
end;
|
2004-08-31 14:40:07 +00:00
|
|
|
finally
|
2004-08-31 15:02:35 +00:00
|
|
|
EndUpdate();
|
2004-08-31 14:40:07 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicList.UpdateImage(const AIndex: Integer);
|
2004-08-31 14:40:07 +00:00
|
|
|
var
|
|
|
|
bmpImage: TBitmap;
|
|
|
|
bmpMask: TBitmap;
|
|
|
|
|
|
|
|
begin
|
|
|
|
if csLoading in ComponentState then
|
|
|
|
exit;
|
|
|
|
|
2004-08-31 15:02:35 +00:00
|
|
|
BeginUpdate();
|
2004-08-31 14:40:07 +00:00
|
|
|
try
|
2004-08-31 15:02:35 +00:00
|
|
|
bmpImage := TBitmap.Create();
|
|
|
|
bmpMask := TBitmap.Create();
|
|
|
|
try
|
|
|
|
CreateImage(AIndex, bmpImage, bmpMask);
|
|
|
|
Replace(AIndex, bmpImage, bmpMask);
|
|
|
|
finally
|
|
|
|
FreeAndNil(bmpMask);
|
|
|
|
FreeAndNil(bmpImage);
|
|
|
|
end;
|
2004-08-31 14:40:07 +00:00
|
|
|
finally
|
2004-08-31 15:02:35 +00:00
|
|
|
EndUpdate();
|
2004-08-31 14:40:07 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicList.DeleteImage(const AIndex: Integer);
|
2004-08-31 14:40:07 +00:00
|
|
|
begin
|
2004-08-31 15:02:35 +00:00
|
|
|
BeginUpdate();
|
|
|
|
try
|
|
|
|
Delete(AIndex);
|
|
|
|
finally
|
|
|
|
EndUpdate();
|
|
|
|
end;
|
2004-08-31 14:40:07 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicList.RebuildImages();
|
2004-08-31 14:40:07 +00:00
|
|
|
var
|
2005-12-13 15:05:09 +00:00
|
|
|
bmpTemp: TBitmap;
|
2004-08-31 14:40:07 +00:00
|
|
|
iIndex: Integer;
|
|
|
|
|
|
|
|
begin
|
|
|
|
if (csLoading in ComponentState) or
|
|
|
|
(Width = 0) or (Height = 0) then
|
|
|
|
exit;
|
|
|
|
|
2004-08-31 15:02:35 +00:00
|
|
|
BeginUpdate();
|
|
|
|
try
|
|
|
|
Clear();
|
2004-08-31 14:40:07 +00:00
|
|
|
|
2004-08-31 15:02:35 +00:00
|
|
|
if not Assigned(FContainer) then
|
|
|
|
exit;
|
2004-08-31 14:40:07 +00:00
|
|
|
|
2005-12-13 15:05:09 +00:00
|
|
|
if FConvert then
|
|
|
|
begin
|
|
|
|
for iIndex := 0 to FContainer.Graphics.Count - 1 do
|
|
|
|
AddImage(iIndex);
|
|
|
|
end else
|
|
|
|
begin
|
|
|
|
bmpTemp := TBitmap.Create();
|
|
|
|
try
|
|
|
|
bmpTemp.Width := Self.Width;
|
|
|
|
bmpTemp.Height := Self.Height;
|
|
|
|
bmpTemp.Canvas.Brush.Color := clWhite;
|
|
|
|
bmpTemp.Canvas.FillRect(Rect(0, 0, bmpTemp.Width, bmpTemp.Height));
|
|
|
|
Add(bmpTemp, bmpTemp);
|
|
|
|
finally
|
|
|
|
FreeAndNil(bmpTemp);
|
|
|
|
end;
|
|
|
|
end;
|
2004-08-31 15:02:35 +00:00
|
|
|
finally
|
|
|
|
EndUpdate();
|
|
|
|
end;
|
2004-08-31 14:40:07 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
{========================= TX2GraphicList
|
|
|
|
Properties
|
|
|
|
========================================}
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicList.DefineProperties(Filer: TFiler);
|
2004-08-31 14:40:07 +00:00
|
|
|
var
|
|
|
|
pType: TClass;
|
|
|
|
|
|
|
|
begin
|
|
|
|
// TCustomImageList defines the Bitmap property, we don't want that
|
|
|
|
// (since the ImageList will be generated from a GraphicContainer).
|
|
|
|
// Erik's solution was to override Read/WriteData, but in Delphi 6 those
|
|
|
|
// aren't virtual yet. Instead we skip TCustomImageList's DefineProperties.
|
|
|
|
//
|
|
|
|
// The trick here is to modify the ClassType so the VMT of descendants
|
|
|
|
// (include ourself!) is ignored and only TComponent.DefineProperties
|
|
|
|
// is called...
|
|
|
|
pType := Self.ClassType;
|
|
|
|
PClass(Self)^ := TComponent;
|
|
|
|
try
|
|
|
|
DefineProperties(Filer);
|
|
|
|
finally
|
|
|
|
PClass(Self)^ := pType;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicList.Notification(AComponent: TComponent;
|
|
|
|
Operation: TOperation);
|
2004-08-31 14:40:07 +00:00
|
|
|
begin
|
|
|
|
if (Operation = opRemove) and (AComponent = FContainer) then
|
|
|
|
FContainer := nil;
|
2005-03-26 17:06:08 +00:00
|
|
|
|
2004-08-31 14:40:07 +00:00
|
|
|
inherited;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicList.SetBackground(const Value: TColor);
|
2004-08-31 14:40:07 +00:00
|
|
|
begin
|
|
|
|
FBackground := Value;
|
|
|
|
RebuildImages();
|
|
|
|
end;
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicList.SetContainer(const Value: TX2GraphicContainer);
|
2004-08-31 14:40:07 +00:00
|
|
|
begin
|
|
|
|
if Assigned(FContainer) then
|
2004-08-31 18:46:34 +00:00
|
|
|
begin
|
2004-08-31 14:40:07 +00:00
|
|
|
FContainer.UnregisterList(Self);
|
2004-08-31 18:46:34 +00:00
|
|
|
FContainer.RemoveFreeNotification(Self);
|
|
|
|
end;
|
2004-08-31 14:40:07 +00:00
|
|
|
|
|
|
|
FContainer := Value;
|
|
|
|
|
|
|
|
if Assigned(FContainer) then
|
2004-08-31 18:46:34 +00:00
|
|
|
begin
|
|
|
|
FContainer.FreeNotification(Self);
|
2004-08-31 14:40:07 +00:00
|
|
|
FContainer.RegisterList(Self);
|
2004-08-31 18:46:34 +00:00
|
|
|
end;
|
2004-08-31 14:40:07 +00:00
|
|
|
|
|
|
|
RebuildImages();
|
|
|
|
end;
|
|
|
|
|
2005-12-13 15:05:09 +00:00
|
|
|
procedure TX2GraphicList.SetConvert(const Value: Boolean);
|
|
|
|
begin
|
|
|
|
if Value <> FConvert then
|
|
|
|
begin
|
|
|
|
FConvert := Value;
|
|
|
|
RebuildImages();
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicList.SetEnabled(const Value: Boolean);
|
2004-08-31 15:02:35 +00:00
|
|
|
begin
|
|
|
|
FEnabled := Value;
|
|
|
|
RebuildImages();
|
|
|
|
end;
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicList.SetStretchMode(const Value: TX2GLStretchMode);
|
2004-08-31 14:40:07 +00:00
|
|
|
begin
|
|
|
|
FStretchMode := Value;
|
|
|
|
RebuildImages();
|
|
|
|
end;
|
|
|
|
|
2004-08-31 15:02:35 +00:00
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicList.BeginUpdate();
|
2004-08-31 15:02:35 +00:00
|
|
|
begin
|
|
|
|
Inc(FUpdateCount);
|
|
|
|
end;
|
|
|
|
|
2005-03-26 17:06:08 +00:00
|
|
|
procedure TX2GraphicList.EndUpdate();
|
2004-08-31 15:02:35 +00:00
|
|
|
begin
|
|
|
|
Assert(FUpdateCount > 0, 'EndUpdate without matching BeginUpdate!');
|
|
|
|
Dec(FUpdateCount);
|
|
|
|
end;
|
|
|
|
|
2004-08-31 14:40:07 +00:00
|
|
|
end.
|
2005-12-13 15:05:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
|