From 23892be635f28274aaf5bc4a5d2b12e7b22540e0 Mon Sep 17 00:00:00 2001 From: Joachim Marder Date: Fri, 12 Jan 2024 08:53:31 +0100 Subject: [PATCH] Moved TBaseVirtualTree.DoPaintText() up in class hierarchy as it is not platform specific. This fixes compiler warning in demp project MVCDemo. --- Source/VirtualTrees.BaseTree.pas | 13 ++++++++++++- Source/VirtualTrees.pas | 18 ------------------ 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/Source/VirtualTrees.BaseTree.pas b/Source/VirtualTrees.BaseTree.pas index d47c6cca..23c691ee 100644 --- a/Source/VirtualTrees.BaseTree.pas +++ b/Source/VirtualTrees.BaseTree.pas @@ -319,6 +319,8 @@ TClipboardFormats = class(TStringList) TVTGetLineStyleEvent = procedure(Sender: TBaseVirtualTree; var Bits: Pointer) of object; TVTMeasureItemEvent = procedure(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode; var NodeHeight: TDimension) of object; + TVTPaintText = procedure(Sender: TBaseVirtualTree; const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; + TextType: TVSTTextType) of object; TVTPrepareButtonImagesEvent = procedure(Sender: TBaseVirtualTree; const APlusBM : TBitmap; const APlusHotBM :TBitmap; const APlusSelectedHotBM :TBitmap; const AMinusBM : TBitmap; const AMinusHotBM : TBitmap; @@ -681,6 +683,8 @@ TBaseVirtualTree = class abstract(TVTBaseAncestor) // determined by the application. FOnGetUserClipboardFormats: TVTGetUserClipboardFormatsEvent; // gives application/descendants the opportunity to // add own clipboard formats on the fly + FOnPaintText: TVTPaintText; // triggered before either normal or fixed text is painted to allow + // even finer customization (kind of sub cell painting) // drag'n drop events FOnCreateDragManager: TVTCreateDragManagerEvent; // called to allow for app./descendant defined drag managers FOnCreateDataObject: TVTCreateDataObjectEvent; // called to allow for app./descendant defined data objects @@ -1039,7 +1043,7 @@ TBaseVirtualTree = class abstract(TVTBaseAncestor) function DoPaintBackground(Canvas: TCanvas; R: TRect): Boolean; virtual; procedure DoPaintDropMark(Canvas: TCanvas; Node: PVirtualNode; R: TRect); virtual; procedure DoPaintNode(var PaintInfo: TVTPaintInfo); virtual; - procedure DoPaintText(Node: PVirtualNode; const Canvas: TCanvas; Column: TColumnIndex; TextType: TVSTTextType); virtual; abstract; + procedure DoPaintText(Node: PVirtualNode; const Canvas: TCanvas; Column: TColumnIndex; TextType: TVSTTextType); virtual; procedure DoPopupMenu(Node: PVirtualNode; Column: TColumnIndex; Position: TPoint); virtual; procedure DoRemoveFromSelection(Node: PVirtualNode); virtual; procedure DoReset(Node: PVirtualNode); virtual; @@ -1363,6 +1367,7 @@ TBaseVirtualTree = class abstract(TVTBaseAncestor) property OnNodeMoved: TVTNodeMovedEvent read FOnNodeMoved write FOnNodeMoved; property OnNodeMoving: TVTNodeMovingEvent read FOnNodeMoving write FOnNodeMoving; property OnPaintBackground: TVTBackgroundPaintEvent read FOnPaintBackground write FOnPaintBackground; + property OnPaintText: TVTPaintText read FOnPaintText write FOnPaintText; property OnPrepareButtonBitmaps : TVTPrepareButtonImagesEvent read FOnPrepareButtonImages write SetOnPrepareButtonImages; property OnRemoveFromSelection: TVTRemoveFromSelectionEvent read FOnRemoveFromSelection write FOnRemoveFromSelection; property OnResetNode: TVTChangeEvent read FOnResetNode write FOnResetNode; @@ -10658,6 +10663,12 @@ procedure TBaseVirtualTree.DoPaintNode(var PaintInfo: TVTPaintInfo); begin end; +procedure TBaseVirtualTree.DoPaintText(Node: PVirtualNode; const Canvas: TCanvas; Column: TColumnIndex; TextType: TVSTTextType); +begin + if Assigned(FOnPaintText) then + FOnPaintText(Self, Canvas, Node, Column, TextType); +end; + //---------------------------------------------------------------------------------------------------------------------- procedure TBaseVirtualTree.DoPopupMenu(Node: PVirtualNode; Column: TColumnIndex; Position: TPoint); diff --git a/Source/VirtualTrees.pas b/Source/VirtualTrees.pas index 0c231bb3..4cc7e1cd 100644 --- a/Source/VirtualTrees.pas +++ b/Source/VirtualTrees.pas @@ -201,8 +201,6 @@ TCustomVirtualStringTree = class; tstChecked // Only checked nodes are rendered ); - TVTPaintText = procedure(Sender: TBaseVirtualTree; const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; - TextType: TVSTTextType) of object; TVSTGetTextEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var CellText: string) of object; TVSTGetHintEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; @@ -250,8 +248,6 @@ TCustomVirtualStringTree = class(TVTAncestor) FTextHeight: Integer; // true size of the font FEllipsisWidth: Integer; // width of '...' for the current font - FOnPaintText: TVTPaintText; // triggered before either normal or fixed text is painted to allow - // even finer customization (kind of sub cell painting) FOnGetText: TVSTGetTextEvent; // used to retrieve the string to be displayed for a specific node fOnGetCellText: TVSTGetCellTextEvent; // used to retrieve the normal and static text of a tree node FOnGetHint: TVSTGetHintEvent; // used to retrieve the hint to be displayed for a specific node @@ -298,8 +294,6 @@ TCustomVirtualStringTree = class(TVTAncestor) function DoIncrementalSearch(Node: PVirtualNode; const Text: string): Integer; override; procedure DoNewText(Node: PVirtualNode; Column: TColumnIndex; const Text: string); virtual; procedure DoPaintNode(var PaintInfo: TVTPaintInfo); override; - procedure DoPaintText(Node: PVirtualNode; const Canvas: TCanvas; Column: TColumnIndex; - TextType: TVSTTextType); override; function DoShortenString(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; const S: string; Width: TDimension; EllipsisWidth: TDimension = 0): string; virtual; procedure DoTextDrawing(var PaintInfo: TVTPaintInfo; const Text: string; CellRect: TRect; DrawFormat: Cardinal); virtual; @@ -324,7 +318,6 @@ TCustomVirtualStringTree = class(TVTAncestor) property OnGetText: TVSTGetTextEvent read FOnGetText write FOnGetText; property OnGetCellText: TVSTGetCellTextEvent read fOnGetCellText write fOnGetCellText; property OnNewText: TVSTNewTextEvent read FOnNewText write FOnNewText; - property OnPaintText: TVTPaintText read FOnPaintText write FOnPaintText; property OnShortenString: TVSTShortenStringEvent read FOnShortenString write FOnShortenString; property OnMeasureTextWidth: TVTMeasureTextEvent read FOnMeasureTextWidth write FOnMeasureTextWidth; property OnMeasureTextHeight: TVTMeasureTextEvent read FOnMeasureTextHeight write FOnMeasureTextHeight; @@ -1414,17 +1407,6 @@ procedure TCustomVirtualStringTree.DoPaintNode(var PaintInfo: TVTPaintInfo); //---------------------------------------------------------------------------------------------------------------------- - -procedure TCustomVirtualStringTree.DoPaintText(Node: PVirtualNode; const Canvas: TCanvas; Column: TColumnIndex; - TextType: TVSTTextType); - -begin - if Assigned(FOnPaintText) then - FOnPaintText(Self, Canvas, Node, Column, TextType); -end; - -//---------------------------------------------------------------------------------------------------------------------- - function TCustomVirtualStringTree.DoShortenString(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; const S: string; Width: TDimension; EllipsisWidth: TDimension = 0): string;