mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-22 01:59:12 +02:00
lcl: added support for custom colors to TColorBox (from Nikolay Ermolov)
git-svn-id: trunk@12401 -
This commit is contained in:
parent
2f59a48d23
commit
7bb6447b50
@ -225,8 +225,7 @@ function TColorBox.GetSelected: TColor;
|
|||||||
begin
|
begin
|
||||||
Result := 0;
|
Result := 0;
|
||||||
if ItemIndex >= 0 then
|
if ItemIndex >= 0 then
|
||||||
if not IdentToColor(Items[ItemIndex], LongInt(Result)) then
|
Result := StringToColor(Items[ItemIndex]);
|
||||||
Result := 0;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -240,8 +239,8 @@ end;
|
|||||||
|
|
||||||
function TColorBox.GetColor(Index : Integer): TColor;
|
function TColorBox.GetColor(Index : Integer): TColor;
|
||||||
begin
|
begin
|
||||||
if Not IdentToColor(Items[Index],Result) then
|
if not IdentToColor(Items[Index], Result) then
|
||||||
Result:=clNone;
|
Result := clNone;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -256,15 +255,17 @@ end;
|
|||||||
procedure TColorBox.SetSelected(Value: TColor);
|
procedure TColorBox.SetSelected(Value: TColor);
|
||||||
var
|
var
|
||||||
c: integer;
|
c: integer;
|
||||||
i: Longint;
|
selColor: TColor;
|
||||||
begin
|
begin
|
||||||
ItemIndex := -1;
|
ItemIndex := -1;
|
||||||
|
|
||||||
for c := 0 to Pred(Items.Count) do
|
for c := 0 to Pred(Items.Count) do
|
||||||
if IdentToColor(Items[c], i) then
|
begin
|
||||||
if i = Value then
|
selColor := StringToColor(Items[c]);
|
||||||
ItemIndex := c;
|
if selColor = Value then
|
||||||
|
ItemIndex := c;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TColorBox.SetPalette
|
Method: TColorBox.SetPalette
|
||||||
Params: Value
|
Params: Value
|
||||||
@ -309,7 +310,6 @@ end;
|
|||||||
procedure TColorBox.DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState);
|
procedure TColorBox.DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState);
|
||||||
var
|
var
|
||||||
r: TRect;
|
r: TRect;
|
||||||
ItemColor: TColor;
|
|
||||||
BrushColor: TColor;
|
BrushColor: TColor;
|
||||||
PenColor: TColor;
|
PenColor: TColor;
|
||||||
begin
|
begin
|
||||||
@ -326,8 +326,7 @@ begin
|
|||||||
BrushColor := Brush.Color;
|
BrushColor := Brush.Color;
|
||||||
PenColor := Pen.Color;
|
PenColor := Pen.Color;
|
||||||
|
|
||||||
if IdentToColor(Items[Index], LongInt(ItemColor)) then
|
Brush.Color := StringToColor(Items[Index]);
|
||||||
Brush.Color := ItemColor;
|
|
||||||
|
|
||||||
Pen.Color := clBlack;
|
Pen.Color := clBlack;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user