mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-16 18:50:30 +01:00
TurboPower_iPro: Implement css function rgb().
git-svn-id: trunk@59259 -
This commit is contained in:
parent
38389bb56f
commit
10690a117f
@ -398,6 +398,7 @@ end;
|
|||||||
function ColorFromString(S: String): TColor;
|
function ColorFromString(S: String): TColor;
|
||||||
var
|
var
|
||||||
R, G, B, Err : Integer;
|
R, G, B, Err : Integer;
|
||||||
|
L: TStringList;
|
||||||
begin
|
begin
|
||||||
Result := -1;
|
Result := -1;
|
||||||
if S = '' then
|
if S = '' then
|
||||||
@ -421,6 +422,24 @@ begin
|
|||||||
else
|
else
|
||||||
if BinSearchNamedColor(S, result) then exit
|
if BinSearchNamedColor(S, result) then exit
|
||||||
else
|
else
|
||||||
|
if pos('RGB', S) = 1 then begin
|
||||||
|
S := Copy(S, 4, MaxInt);
|
||||||
|
while (S <> '') and (IsWhiteSpace(S[1]) or (S[1] = '(')) do
|
||||||
|
Delete(S, 1, 1);
|
||||||
|
while (S <> '') and (IsWhiteSpace(S[Length(S)]) or (S[Length(S)] = ')')) do
|
||||||
|
SetLength(S, Length(S)-1);
|
||||||
|
L := TStringList.Create;
|
||||||
|
try
|
||||||
|
L.CommaText := S;
|
||||||
|
if L.Count > 0 then R := StrToIntDef(L[0], 255);
|
||||||
|
if L.Count > 1 then G := StrToIntDef(L[1], 255);
|
||||||
|
if L.Count > 2 then B := StrToIntDef(L[2], 255);
|
||||||
|
Exit(RGB(R, G, B));
|
||||||
|
finally
|
||||||
|
L.Free;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
if length(S) = 6 then
|
if length(S) = 6 then
|
||||||
try
|
try
|
||||||
val('$'+Copy(S,1,2), R, Err);
|
val('$'+Copy(S,1,2), R, Err);
|
||||||
@ -582,12 +601,14 @@ var
|
|||||||
Start: Integer;
|
Start: Integer;
|
||||||
Quote: char;
|
Quote: char;
|
||||||
WantChar: Boolean;
|
WantChar: Boolean;
|
||||||
|
WantPar: Boolean;
|
||||||
Len: Integer;
|
Len: Integer;
|
||||||
begin
|
begin
|
||||||
Result := TStringList.Create;
|
Result := TStringList.Create;
|
||||||
Start := Pos(':', ACommand)+1;
|
Start := Pos(':', ACommand)+1;
|
||||||
|
|
||||||
WantArg := True;
|
WantArg := True;
|
||||||
|
WantPar := false;
|
||||||
Quote := #0;
|
Quote := #0;
|
||||||
for i := Start to Length(ACommand) do
|
for i := Start to Length(ACommand) do
|
||||||
begin
|
begin
|
||||||
@ -616,7 +637,9 @@ begin
|
|||||||
else // we have an arg we are reading ...
|
else // we have an arg we are reading ...
|
||||||
begin
|
begin
|
||||||
WantChar:=not (ACommand[i] in [';',' ',#9]);
|
WantChar:=not (ACommand[i] in [';',' ',#9]);
|
||||||
if (i<Length(ACommand)) and WantChar
|
if ACommand[i] = '(' then WantPar := True;
|
||||||
|
if ACommand[i] = ')' then WantPar := False;
|
||||||
|
if (i<Length(ACommand)) and (WantChar or WantPar)
|
||||||
then
|
then
|
||||||
continue;
|
continue;
|
||||||
WantArg := True;
|
WantArg := True;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user