ghkweon / dwscript

Automatically exported from code.google.com/p/dwscript
0 stars 0 forks source link

Implementing TColor #306

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I'm using DWS 2.3 and I'm trying to implement "TColor" However, it's failing to 
compile the type declaration.

type
  TColor = -$7FFFFFFF-1..$7FFFFFFF;

This is how "TColor" is declared in Delphi XE2 in "System.UITypes".

Second of all, to accommodate for colors such as "clBlack", "clMaroon", etc, 
I've declared constants like so:

const clViolet = $EE82EE;
const clWheat = $F5DEB3;
const clWhite = $FFFFFF;
const clWhitesmoke = $F5F5F5;
const clYellow = $FFFF00;

I'm using it temporarily as an Integer ("type TColor = Integer;") However, the 
end result (passing as integer through to Delphi) is not anywhere close, for 
example, clRed shows blue and clBlue shows red.

Original issue reported on code.google.com by djjd47...@gmail.com on 3 Nov 2012 at 11:41

GoogleCodeExporter commented 8 years ago
Ranged integers are not supported, though

type
  TColor = -$7FFFFFFF-1..$7FFFFFFF;

is effectively a convoluted way of describing a signed 32bit integer.

> However, the end result (passing as integer through to Delphi)
> is not anywhere close, for example, clRed shows blue and clBlue shows red.

You have to use the same convention as in Delphi, were in hexadecimal, it's BGR 
and not RGB, f.i. if you look in Graphics.pas, you'll see

  clYellow = TColor($00FFFF);

Original comment by zar...@gmail.com on 5 Nov 2012 at 7:36

GoogleCodeExporter commented 8 years ago
In attempt to declare colors like that, it's still not working. I get the same 
results using "clYellow = TColor($00FFFF);" as I do using "clYellow = 
$00FFFF;". Using "TColor = Integer;" just doesn't seem right, and I know 
"TColor" isn't necessarily a useful type for typical DWS implementation, but in 
my case, I need it. How else could I define it to work?

Original comment by djjd47...@gmail.com on 5 Nov 2012 at 11:03

GoogleCodeExporter commented 8 years ago
I didn't notice the swapped R/B, after doing that it works.

Original comment by djjd47...@gmail.com on 5 Nov 2012 at 11:10