Skip to content

Commit

Permalink
Moved TBaseVirtualTree.DoPaintText() up in class hierarchy as it is n…
Browse files Browse the repository at this point in the history
…ot platform specific. This fixes compiler warning in demp project MVCDemo.
  • Loading branch information
joachimmarder committed Jan 12, 2024
1 parent fa05c1e commit 23892be
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
13 changes: 12 additions & 1 deletion Source/VirtualTrees.BaseTree.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
18 changes: 0 additions & 18 deletions Source/VirtualTrees.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 23892be

Please sign in to comment.