[fpc-pascal] TFPColor vs TColor

Graeme Geldenhuys graemeg.lists at gmail.com
Tue May 5 09:14:52 CEST 2009


Hi,

I'm looking at starting the conversion of fpGUI Toolkit's own Canvas
and Image classes, to using the TFPCustomCanvas and related image
classes.

Looking at TFPColor as defined below....  I looked at using something
similar to this in fpGUI, but soon realized that published properties
of record type is not supported. So I ended up using similar to
Lazarus and Delphi - TColor of type integer.

==============[ fpimage.pp ]===============
  TFPColor = record
    red,green,blue,alpha : word;
  end;
========================================

I really like the idea of having separated R,G,B,A colors. Plus you
always know the order of the separated R, G, B and A. The individual
colors could also store values higher that 0..254 for other color
space implementations (I think).  But what's the point of having
TFPColor when properties of that type can't be published.

You will never be able to have something like the following...

  TPanel = class(...)
     ...
  published
     property Color: TFPColor read FColor write FColor;
  end;

Even Lazarus had to override all the FPColor properties in Canvas and
Image classes to use TColor instead. So what's the point? Am I missing
something.

If the Reader/Writer classes used for streaming Lazarus Form files
(*.lfm) could handle TFPColor the output could look as follows:

  object Panel1: TPanel
    Left = 213
    Height = 50
    Top = 37
    Width = 170
    Caption = 'Panel1'
    Color = (240,0,115,0)
  end

Color being of type TFPColor and the values in brackets are always in
R, G, B, A order (no matter the platform).  I have seem many theme
config files under Linux using a similar format for storing color
values.  Is this possible with the Reader/Write?  But first we have to
address the problem of the TFPColor not being able to be published.


So in summary:

* What's the point of TFPColor when we cannot publish it.
* Can the Reader/Writer support TFPColor


Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/



More information about the fpc-pascal mailing list