PDA

View Full Version : reuse vcl source for timage like component?



noeska
22-05-2007, 08:40 PM
On rewriting gl3ds i got the suggestion to make it work like timage.

Looking at the vcl sources i got with delphi2005 i see i uses a global var Fileformats.
For keeping track of different fileformat it uses this:
TFileFormatsList = class(TList)
which is a list of:
TFileFormat = record
GraphicClass: TGraphicClass;
.....

Changing TGraphicClass to TModelClass it get a working system for my use, but am i allowed to copy from the vcl sources? Or should i write my own on TList based class for this? Or are there better ways of keeping track of extension and class info for an x number of fileformats? Or is there a generic TList to be used for this?

Questions, questions ....

But the main one is, am i allowed to copy the TFileFormatsList from the vcl and adopt it for my purposes?

Next: Is there a generic TList that takes an record, and allows easy and fast access to the fields in the record (under an mpl license)?

Setharian
22-05-2007, 09:38 PM
I believe you cannot directly copy VCL source code and publish it...for personal use it is allowed....but not sure here, maybe the licensing conditions have changed...

noeska
22-05-2007, 09:49 PM
I did not publish anything yet. I have my doubt about using it for personal use also. Hence my second question on alternatives!. Write my own derived TList that is...

M109uk
22-05-2007, 09:56 PM
I use a similar idea with my world, texture and gui classes.. i have a base class, the object classes and then the object list.. e.g.



CBaseTexture = Class Of TBaseTexture;
TBaseTexture = Class
end;

TTexture = Class(TBaseTexture)
end;

TShader = Class(TBaseTexture)
end;

TTextures = Class(TList)
//list of textures
end;

TTextureClass = Class
name: string;
class: CBaseTexture;
end;

TTextureClasses = Class(TList)
private
function GetItem(Index: Integer): TTextureClass;
public
function add(const name: string; const class: CBaseTexture): Integer;
function Find(const Name: String): Integer;
property Items[Index: Integer]: TTextureClass read GetItem; default;
end;


I found this very helpful, and made life simple when i added new gui classes, etc... although there is probably a better way of doing it :?