@@ -26,15 +26,22 @@ THeidiVirtualStringTree = class(TLazVirtualStringTree)
2626 private
2727 FQtShowHorzGridLines: Boolean;
2828 FQtShowVertGridLines: Boolean;
29+ FQtWindowsHotTrack: Boolean;
30+ function BlendQtColor (BaseColor, AccentColor: TColor; AccentPercent: Byte): TColor;
2931 procedure DrawQtSolidLine (Canvas: TCanvas; Left, Top, Right, Bottom: Integer);
3032 protected
33+ procedure DoBeforeCellPaint (Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
34+ CellPaintMode: TVTCellPaintMode; CellRect: TRect; var ContentRect: TRect); override;
3135 procedure DoAfterCellPaint (Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
3236 const CellRect: TRect); override;
37+ procedure DoPaintText (Node: PVirtualNode; const Canvas: TCanvas; Column: TColumnIndex;
38+ TextType: TVSTTextType); override;
3339 procedure DrawDottedHLine (const PaintInfo: TVTPaintInfo; Left, Right, Top: Integer); override;
3440 procedure DrawDottedVLine (const PaintInfo: TVTPaintInfo; Top, Bottom, Left: Integer;
3541 UseSelectedBkColor: Boolean = False); override;
3642 public
3743 procedure ConfigureQtGridLines (ShowHorz, ShowVert: Boolean);
44+ procedure ConfigureQtHotTrack (Enabled: Boolean);
3845 { $ENDIF}
3946 end ;
4047
@@ -203,6 +210,22 @@ implementation
203210uses
204211 Math;
205212
213+ function THeidiVirtualStringTree.BlendQtColor (BaseColor, AccentColor: TColor;
214+ AccentPercent: Byte): TColor;
215+ var
216+ BaseRGB, AccentRGB: LongInt;
217+ BaseWeight: Integer;
218+ begin
219+ BaseRGB := ColorToRGB(BaseColor);
220+ AccentRGB := ColorToRGB(AccentColor);
221+ BaseWeight := 100 - AccentPercent;
222+ Result := RGBToColor(
223+ (((BaseRGB and $FF) * BaseWeight) + ((AccentRGB and $FF) * AccentPercent)) div 100 ,
224+ ((((BaseRGB shr 8 ) and $FF) * BaseWeight) + (((AccentRGB shr 8 ) and $FF) * AccentPercent)) div 100 ,
225+ ((((BaseRGB shr 16 ) and $FF) * BaseWeight) + (((AccentRGB shr 16 ) and $FF) * AccentPercent)) div 100 );
226+ end ;
227+
228+
206229procedure THeidiVirtualStringTree.DrawQtSolidLine (Canvas: TCanvas; Left, Top, Right, Bottom: Integer);
207230var
208231 OldBrushColor: TColor;
@@ -226,6 +249,43 @@ procedure THeidiVirtualStringTree.ConfigureQtGridLines(ShowHorz, ShowVert: Boole
226249 FQtShowVertGridLines := ShowVert;
227250end ;
228251
252+ procedure THeidiVirtualStringTree.ConfigureQtHotTrack (Enabled: Boolean);
253+ begin
254+ FQtWindowsHotTrack := Enabled;
255+ end ;
256+
257+ procedure THeidiVirtualStringTree.DoBeforeCellPaint (Canvas: TCanvas; Node: PVirtualNode;
258+ Column: TColumnIndex; CellPaintMode: TVTCellPaintMode; CellRect: TRect;
259+ var ContentRect: TRect);
260+ var
261+ OldBrushColor: TColor;
262+ OldBrushStyle: TBrushStyle;
263+ begin
264+ inherited DoBeforeCellPaint(Canvas, Node, Column, CellPaintMode, CellRect, ContentRect);
265+ if (CellPaintMode <> cpmPaint) or (not FQtWindowsHotTrack) or
266+ (Node <> HotNode) or (vsSelected in Node.States) then
267+ Exit;
268+
269+ OldBrushColor := Canvas.Brush.Color;
270+ OldBrushStyle := Canvas.Brush.Style;
271+ try
272+ Canvas.Brush.Style := bsSolid;
273+ Canvas.Brush.Color := BlendQtColor(OldBrushColor, clHighlight, 12 );
274+ Canvas.FillRect(CellRect);
275+ finally
276+ Canvas.Brush.Style := OldBrushStyle;
277+ Canvas.Brush.Color := OldBrushColor;
278+ end ;
279+ end ;
280+
281+ procedure THeidiVirtualStringTree.DoPaintText (Node: PVirtualNode; const Canvas: TCanvas;
282+ Column: TColumnIndex; TextType: TVSTTextType);
283+ begin
284+ inherited DoPaintText(Node, Canvas, Column, TextType);
285+ if FQtWindowsHotTrack and (Node = HotNode) then
286+ Canvas.Font.Style := Canvas.Font.Style - [fsUnderline];
287+ end ;
288+
229289procedure THeidiVirtualStringTree.DoAfterCellPaint (Canvas: TCanvas; Node: PVirtualNode;
230290 Column: TColumnIndex; const CellRect: TRect);
231291var
0 commit comments