On Tue, 5 May 2009, Graeme Geldenhuys wrote:
> 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 ]=============== > > 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. When designing FPCanvas and so on, streaming was not taken into consideration at all. The point was to be able to represent all possible colors, independent of a GUI system or streaming system. > * Can the Reader/Writer support TFPColor No, because records cannot be published. To do this, you'd need something like a TGUIColor wrapper, which is a TPersistent: TGUIColor = Class(TPersistent) Private FColor : TFPColor Public Property Color : TFPColor Read FColor Write FColor; Published Property Red : Word Read FColor.Red Write FColor.Red // Same for blue,green,alpha end; Publish a property TGUIColor for streaming, but use it's color property when drawing. Another possibility would be TMyColor = Int64 publish this, and typecast in the getter/setter to/from TFPColor. Personally, I'd go for the first option. Michael. _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal