Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 482 - Color mapping font of for treenodes
Summary: Color mapping font of for treenodes
Status: RESOLVED FIXED
Alias: None
Product: VCL TeeChart
Classification: Unclassified
Component: TTree (show other bugs)
Version: 131119
Hardware: PC Windows
: High major
Target Milestone: ---
Assignee: Steema Issue Manager
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-27 04:40 EST by h.hasenack
Modified: 2013-12-04 09:47 EST (History)
2 users (show)

See Also:
Chart Series: ---
Delphi / C++ Builder RAD IDE Version: RAD XE5


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description h.hasenack 2013-11-27 04:40:49 EST
As for my previous reported patch on TeeTree panel, there is another issue for drawing the text of TTreeNodeshape. The system color values (like clWindowText) are not mapped into rgb values, and as these system values are negative, they are drawn as transparent values, thus become invisible.

Here's the fix I come up with:

Procedure TTreeNodeShape.SetCanvasFont(const ACanvas:TCanvas3D);
begin
  if not Assigned(Tree) then
     ACanvas.AssignFont(InternalFont)
  else

  with Tree do
  if Self.FSelected and
     (Selected.TextColor<>clNone) and
     (not Designing) then
  begin
    ACanvas.AssignFont(InternalFont);
    ACanvas.Font.Color:=Selected.TextColor;
  end
  else
  begin
    // HotTrack ...
    if IMouseInside and (not Designing) and
       HotTrack.Active then
    begin
      if HotTrack.UseFont then
         ACanvas.AssignFont(HotTrack.Font)
      else
      if HotTrack.HotLink then
      begin
        ACanvas.AssignFont(InternalFont);
        with ACanvas.Font do Style:=Style+[{$IFDEF FMX}TFontStyle.{$ENDIF}fsUnderline];
      end;
    end
    else
       ACanvas.AssignFont(InternalFont);
  end;
{$ifdef HH_PATCH_TEETREE}
  aCanvas.Font.Color:=ColorToRGB(aCanvas.Font.Color);
{$endif}

end;
Comment 1 david berneda 2013-12-04 09:47:31 EST
Fixed with the code below.
But, there is a (minor) problem with "system" colors like "clWindowText" etc.

When using GDI+ canvas (the default canvas now), colors are expressed using the 4 bytes of a Cardinal (RGBA format) instead of just 3 bytes (RGB).

That means, GDI+ does not interpret and does not know if a color is a "system" color by looking at the 4 byte. This is only a VCL mechanism intended only for "old" GDI. The 4 byte (A) is used to determine the transparency from 0 to 255.

In GDI+, a "clWindowText" color ($FF000008) is a perfect valid color, (a totally transparent RGB with Red=8), and so, when calling ColorToRGB it will be converted (in VCL only).  FireMonkey follows GDI+ specs (4 bytes RGBA and no special system colors).

{$IFNDEF FMX}
{$IFNDEF LCL}
{$IFNDEF CLX}
var tmpColor : TColor;
{$ENDIF}
{$ENDIF}
{$ENDIF}

.....

    {$IFNDEF FMX}
    {$IFNDEF LCL}
    {$IFNDEF CLX}
    tmpColor:=ACanvas.Font.Color;

    if (Cardinal(tmpColor)>={$IFDEF D7}clSystemColor{$ELSE}$80000000{$ENDIF}) and
       (Cardinal({$IFDEF D6}clMenuBar{$ELSE}clInfoBk{$ENDIF})>=Cardinal(tmpColor)) then
       ACanvas.Font.Color:=ColorToRGB(tmpColor);

    {$ENDIF}
    {$ENDIF}
    {$ENDIF}