You've already forked lazarus-ccr
mbColorLib: Fix drawing of ColorTree nodes.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5465 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -49,7 +49,6 @@ type
|
|||||||
procedure SetInfoLabel(Value: string);
|
procedure SetInfoLabel(Value: string);
|
||||||
|
|
||||||
protected
|
protected
|
||||||
function CanChange(Node: TTreeNode): Boolean; override;
|
|
||||||
procedure CMHintShow(var Message: TCMHintShow); message CM_HINTSHOW;
|
procedure CMHintShow(var Message: TCMHintShow); message CM_HINTSHOW;
|
||||||
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
@@ -163,7 +162,7 @@ type
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
PalUtils;
|
PalUtils, mbUtils;
|
||||||
|
|
||||||
//taken from GraphUtil, only for Delphi 5
|
//taken from GraphUtil, only for Delphi 5
|
||||||
{$IFNDEF DELPHI_6_UP}
|
{$IFNDEF DELPHI_6_UP}
|
||||||
@@ -249,11 +248,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TmbColorTree.CanChange(Node: TTreeNode): Boolean;
|
|
||||||
begin
|
|
||||||
Result := Assigned(Node) and Node.HasChildren;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TmbColorTree.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
procedure TmbColorTree.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||||
var
|
var
|
||||||
r: TRect;
|
r: TRect;
|
||||||
@@ -327,8 +321,10 @@ begin
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
b.Canvas.Brush.Color := clBtnFace;
|
b.Canvas.Brush.Color := clFuchsia;
|
||||||
b.Canvas.Pen.Color := clWindowText;
|
b.Canvas.Pen.Color := clWindowText;
|
||||||
|
b.Transparent := true;
|
||||||
|
b.TransparentColor := clFuchsia;
|
||||||
end;
|
end;
|
||||||
b.Canvas.FillRect(B.Canvas.ClipRect);
|
b.Canvas.FillRect(B.Canvas.ClipRect);
|
||||||
case dir of
|
case dir of
|
||||||
@@ -455,20 +451,24 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TmbColorTree.DrawInfoItem(R: TRect; Index: integer);
|
procedure TmbColorTree.DrawInfoItem(R: TRect; Index: integer);
|
||||||
|
const
|
||||||
|
FLAGS = DT_LEFT or DT_END_ELLIPSIS or DT_NOCLIP;
|
||||||
|
DELTA = 2;
|
||||||
var
|
var
|
||||||
b: TBitmap;
|
b: TBitmap;
|
||||||
BR, TR: TRect;
|
BR, TR: TRect;
|
||||||
i, fx: integer;
|
i, fx: integer;
|
||||||
s: string;
|
s: string;
|
||||||
|
h: Integer;
|
||||||
begin
|
begin
|
||||||
b := TBitmap.Create;
|
b := TBitmap.Create;
|
||||||
try
|
try
|
||||||
b.Width := R.Right - R.Left;
|
b.Width := R.Right - R.Left;
|
||||||
b.Height := R.Bottom - R.Top;
|
b.Height := R.Bottom - R.Top;
|
||||||
BR := b.Canvas.ClipRect;
|
BR := b.Canvas.ClipRect;
|
||||||
b.Canvas.Font.Assign(Font);
|
|
||||||
with b.Canvas do
|
with b.Canvas do
|
||||||
begin
|
begin
|
||||||
|
Canvas.Font.Assign(Self.Font);
|
||||||
Brush.Color := Blend(clBtnFace, clWindow, 30);
|
Brush.Color := Blend(clBtnFace, clWindow, 30);
|
||||||
FillRect(BR);
|
FillRect(BR);
|
||||||
BR := Rect(BR.Left + 42, BR.Top, BR.Right, BR.Bottom);
|
BR := Rect(BR.Left + 42, BR.Top, BR.Right, BR.Bottom);
|
||||||
@@ -479,34 +479,28 @@ begin
|
|||||||
Font.Size := 7;
|
Font.Size := 7;
|
||||||
|
|
||||||
s := FInfoLabel;
|
s := FInfoLabel;
|
||||||
TR := Rect(BR.Left, BR.Top + 2, BR.Right, BR.Top + 12);
|
h := TextHeight(s);
|
||||||
|
TR := Rect(BR.Left, BR.Top{ + 2}, BR.Right, BR.Top + {2 + }h + DELTA);
|
||||||
if Assigned(FDraw1) then FDraw1(Self, Index, Canvas.Font, s);
|
if Assigned(FDraw1) then FDraw1(Self, Index, Canvas.Font, s);
|
||||||
DrawText(b.Canvas.Handle, PChar(s), Length(s), TR, DT_LEFT or DT_END_ELLIPSIS or DT_NOCLIP);
|
DrawText(b.Canvas.Handle, PChar(s), Length(s), TR, FLAGS);
|
||||||
|
|
||||||
fX := BR.Left;
|
DrawHorDottedLine(b.Canvas, BR.Left, BR.Right, TR.Bottom + DELTA, clGray);
|
||||||
for i := 0 to (BR.Right - 2 - BR.Left) div 2 do
|
|
||||||
begin
|
|
||||||
Pixels[fX, BR.Top + 4 + TextHeight(s)] := clGray;
|
|
||||||
fX := fX + 2;
|
|
||||||
end;
|
|
||||||
|
|
||||||
s := FormatHint(FInfo1, Self.Colors[Index].value);
|
s := FormatHint(FInfo1, Self.Colors[Index].value);
|
||||||
TR := Rect(BR.Left, BR.Top + (BR.Bottom - BR.Top) div 3 + 2, BR.Right, BR.Top + 12);
|
TR.Top := TR.Bottom + 2 * DELTA;
|
||||||
|
TR.Bottom := TR.Top + h + DELTA;
|
||||||
if Assigned(FDraw2) then FDraw2(Self, Index, Canvas.Font, s);
|
if Assigned(FDraw2) then FDraw2(Self, Index, Canvas.Font, s);
|
||||||
DrawText(b.Canvas.Handle, PChar(s), Length(s), TR, DT_LEFT or DT_END_ELLIPSIS or DT_NOCLIP);
|
DrawText(b.Canvas.Handle, PChar(s), Length(s), TR, FLAGS);
|
||||||
|
|
||||||
fX := BR.Left;
|
DrawHorDottedLine(b.Canvas, BR.LEft, BR.Right, TR.Bottom + DELTA, clGray);
|
||||||
for i := 0 to (BR.Right - 2 - BR.Left) div 2 do
|
|
||||||
begin
|
|
||||||
Pixels[fX, BR.Top + (BR.Bottom - BR.Top) div 3 + 4 + TextHeight(s)] := clGray;
|
|
||||||
fX := fX + 2;
|
|
||||||
end;
|
|
||||||
|
|
||||||
s := FormatHint(FInfo2, Self.Colors[Index].value);
|
s := FormatHint(FInfo2, Self.Colors[Index].value);
|
||||||
TR := Rect(BR.Left, BR.Top + 2*((BR.Bottom - BR.Top) div 3) + 2, BR.Right, BR.Top + 12);
|
TR.Top := TR.Bottom + 2 * DELTA;
|
||||||
|
TR.Bottom := TR.Top + h + DELTA;
|
||||||
if Assigned(FDraw3) then FDraw3(Self, Index, Canvas.Font, s);
|
if Assigned(FDraw3) then FDraw3(Self, Index, Canvas.Font, s);
|
||||||
DrawText(b.Canvas.Handle, PChar(s), Length(s), TR, DT_LEFT or DT_END_ELLIPSIS or DT_NOCLIP);
|
DrawText(b.Canvas.Handle, PChar(s), Length(s), TR, FLAGS);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Canvas.Draw(R.Left, R.Top, b);
|
Canvas.Draw(R.Left, R.Top, b);
|
||||||
finally
|
finally
|
||||||
b.Free;
|
b.Free;
|
||||||
|
@@ -5,9 +5,10 @@ unit mbUtils;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils;
|
Classes, SysUtils, Graphics;
|
||||||
|
|
||||||
procedure Clamp(var AValue:Integer; AMin, AMax: Integer);
|
procedure Clamp(var AValue:Integer; AMin, AMax: Integer);
|
||||||
|
procedure DrawHorDottedLine(ACanvas: TCanvas; X1, X2, Y: Integer; AColor: TColor);
|
||||||
function PointInCircle(p: TPoint; Size: integer): boolean;
|
function PointInCircle(p: TPoint; Size: integer): boolean;
|
||||||
function PtInCircle(p, ctr: TPoint; Radius: Integer): Boolean;
|
function PtInCircle(p, ctr: TPoint; Radius: Integer): Boolean;
|
||||||
|
|
||||||
@@ -19,6 +20,14 @@ begin
|
|||||||
if AValue > AMax then AValue := AMax;
|
if AValue > AMax then AValue := AMax;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure DrawHorDottedLine(ACanvas: TCanvas; X1, X2, Y: Integer; AColor: TColor);
|
||||||
|
begin
|
||||||
|
while X1 <= X2 do begin
|
||||||
|
ACanvas.Pixels[X1, Y] := AColor;
|
||||||
|
inc(X1, 2);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function PointInCircle(p: TPoint; Size: integer): boolean;
|
function PointInCircle(p: TPoint; Size: integer): boolean;
|
||||||
var
|
var
|
||||||
r: integer;
|
r: integer;
|
||||||
|
Reference in New Issue
Block a user