Skip to content

Commit

Permalink
Work on issue #1162
Browse files Browse the repository at this point in the history
Move more simple types to VirtualTrees.Types and add aliases in VirtualTrees.pas in order to reduce breaking changes in V8.
  • Loading branch information
joachimmarder committed Feb 2, 2023
1 parent a2815b7 commit 0f9e309
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 72 deletions.
2 changes: 0 additions & 2 deletions Source/VirtualTrees.BaseTree.pas
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ TCacheEntry = record
end;

TCache = array of TCacheEntry;
TNodeArray = array of PVirtualNode;


// Used in the CF_VTREFERENCE clipboard format.
PVTReference = ^TVTReference;
Expand Down
44 changes: 0 additions & 44 deletions Source/VirtualTrees.Header.pas
Original file line number Diff line number Diff line change
Expand Up @@ -307,50 +307,6 @@ TVTFixedAreaConstraints = class(TPersistent)
property MinWidthPercent : TVTConstraintPercent index 3 read FMinWidthPercent write SetConstraints default 0;
end;

TVTHeaderStyle = (
hsThickButtons, //TButton look and feel
hsFlatButtons, //flatter look than hsThickButton, like an always raised flat TToolButton
hsPlates //flat TToolButton look and feel (raise on hover etc.)
);

TVTHeaderOption = (
hoAutoResize, //Adjust a column so that the header never exceeds the client width of the owner control.
hoColumnResize, //Resizing columns with the mouse is allowed.
hoDblClickResize, //Allows a column to resize itself to its largest entry.
hoDrag, //Dragging columns is allowed.
hoHotTrack, //Header captions are highlighted when mouse is over a particular column.
hoOwnerDraw, //Header items with the owner draw style can be drawn by the application via event.
hoRestrictDrag, //Header can only be dragged horizontally.
hoShowHint, //Show application defined header hint.
hoShowImages, //Show header images.
hoShowSortGlyphs, //Allow visible sort glyphs.
hoVisible, //Header is visible.
hoAutoSpring, //Distribute size changes of the header to all columns, which are sizable and have the coAutoSpring option enabled.
hoFullRepaintOnResize, //Fully invalidate the header (instead of subsequent columns only) when a column is resized.
hoDisableAnimatedResize, //Disable animated resize for all columns.
hoHeightResize, //Allow resizing header height via mouse.
hoHeightDblClickResize, //Allow the header to resize itself to its default height.
hoHeaderClickAutoSort, //Clicks on the header will make the clicked column the SortColumn or toggle sort direction if it already was the sort column
hoAutoColumnPopupMenu, //Show a context menu for activating and deactivating columns on right click
hoAutoResizeInclCaption //Includes the header caption for the auto resizing
);
TVTHeaderOptions = set of TVTHeaderOption;

THeaderState = (
hsAutoSizing, //auto size chain is in progess, do not trigger again on WM_SIZE
hsDragging, //header dragging is in progress (only if enabled)
hsDragPending, //left button is down, user might want to start dragging a column
hsLoading, //The header currently loads from stream, so updates are not necessary.
hsColumnWidthTracking, //column resizing is in progress
hsColumnWidthTrackPending, //left button is down, user might want to start resize a column
hsHeightTracking, //height resizing is in progress
hsHeightTrackPending, //left button is down, user might want to start changing height
hsResizing, //multi column resizing in progress
hsScaling, //the header is scaled after a change of FixedAreaConstraints or client size
hsNeedScaling //the header needs to be scaled
);
THeaderStates = set of THeaderState;

TVTHeader = class(TPersistent)
private
FOwner : TCustomControl;
Expand Down
4 changes: 2 additions & 2 deletions Source/VirtualTrees.StyleHooks.pas
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ implementation
System.Types,
VirtualTrees,
VirtualTrees.Header,
VirtualTrees.DrawTree,
VirtualTrees.BaseTree;
VirtualTrees.Types,
VirtualTrees.DrawTree;

function VTStyleServices(AControl: TControl = nil): TCustomStyleServices;
begin
Expand Down
77 changes: 61 additions & 16 deletions Source/VirtualTrees.Types.pas
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,50 @@ THitInfo = record
ShiftState: TShiftState;
end;

TVTHeaderStyle = (
hsThickButtons, //TButton look and feel
hsFlatButtons, //flatter look than hsThickButton, like an always raised flat TToolButton
hsPlates //flat TToolButton look and feel (raise on hover etc.)
);

TVTHeaderOption = (
hoAutoResize, //Adjust a column so that the header never exceeds the client width of the owner control.
hoColumnResize, //Resizing columns with the mouse is allowed.
hoDblClickResize, //Allows a column to resize itself to its largest entry.
hoDrag, //Dragging columns is allowed.
hoHotTrack, //Header captions are highlighted when mouse is over a particular column.
hoOwnerDraw, //Header items with the owner draw style can be drawn by the application via event.
hoRestrictDrag, //Header can only be dragged horizontally.
hoShowHint, //Show application defined header hint.
hoShowImages, //Show header images.
hoShowSortGlyphs, //Allow visible sort glyphs.
hoVisible, //Header is visible.
hoAutoSpring, //Distribute size changes of the header to all columns, which are sizable and have the coAutoSpring option enabled.
hoFullRepaintOnResize, //Fully invalidate the header (instead of subsequent columns only) when a column is resized.
hoDisableAnimatedResize, //Disable animated resize for all columns.
hoHeightResize, //Allow resizing header height via mouse.
hoHeightDblClickResize, //Allow the header to resize itself to its default height.
hoHeaderClickAutoSort, //Clicks on the header will make the clicked column the SortColumn or toggle sort direction if it already was the sort column
hoAutoColumnPopupMenu, //Show a context menu for activating and deactivating columns on right click
hoAutoResizeInclCaption //Includes the header caption for the auto resizing
);
TVTHeaderOptions = set of TVTHeaderOption;

THeaderState = (
hsAutoSizing, //auto size chain is in progess, do not trigger again on WM_SIZE
hsDragging, //header dragging is in progress (only if enabled)
hsDragPending, //left button is down, user might want to start dragging a column
hsLoading, //The header currently loads from stream, so updates are not necessary.
hsColumnWidthTracking, //column resizing is in progress
hsColumnWidthTrackPending, //left button is down, user might want to start resize a column
hsHeightTracking, //height resizing is in progress
hsHeightTrackPending, //left button is down, user might want to start changing height
hsResizing, //multi column resizing in progress
hsScaling, //the header is scaled after a change of FixedAreaConstraints or client size
hsNeedScaling //the header needs to be scaled
);
THeaderStates = set of THeaderState;

// content elements of the control from left to right, used when calculatin left margins.
TVTElement = (
ofsMargin, // right of the margin
Expand Down Expand Up @@ -1015,24 +1059,25 @@ TVTImageInfo = record
TVTInternalPaintOptions = set of TVTInternalPaintOption;

TVTPaintInfo = record
Canvas: TCanvas; // the canvas to paint on
PaintOptions: TVTInternalPaintOptions; // a copy of the paint options passed to PaintTree
Node: PVirtualNode; // the node to paint
Column: TColumnIndex; // the node's column index to paint
Position: TColumnPosition; // the column position of the node
CellRect: TRect; // the node cell
ContentRect: TRect; // the area of the cell used for the node's content
NodeWidth: TDimension; // the actual node width
Alignment: TAlignment; // how to align within the node rectangle
CaptionAlignment: TAlignment; // how to align text within the caption rectangle
BidiMode: TBidiMode; // directionality to be used for painting
BrushOrigin: TPoint; // the alignment for the brush used to draw dotted lines
ImageInfo: array[TVTImageInfoIndex] of TVTImageInfo; // info about each possible node image
Offsets: TVTOffsets; // The offsets of the various elements of a tree node
VAlign: TDimension;
procedure AdjustImageCoordinates();
Canvas: TCanvas; // the canvas to paint on
PaintOptions: TVTInternalPaintOptions; // a copy of the paint options passed to PaintTree
Node: PVirtualNode; // the node to paint
Column: TColumnIndex; // the node's column index to paint
Position: TColumnPosition; // the column position of the node
CellRect: TRect; // the node cell
ContentRect: TRect; // the area of the cell used for the node's content
NodeWidth: TDimension; // the actual node width
Alignment: TAlignment; // how to align within the node rectangle
CaptionAlignment: TAlignment; // how to align text within the caption rectangle
BidiMode: TBidiMode; // directionality to be used for painting
BrushOrigin: TPoint; // the alignment for the brush used to draw dotted lines
ImageInfo: array[TVTImageInfoIndex] of TVTImageInfo; // info about each possible node image
Offsets: TVTOffsets; // The offsets of the various elements of a tree node
VAlign: TDimension;
procedure AdjustImageCoordinates();
end;

TNodeArray = array of PVirtualNode;

implementation

Expand Down
47 changes: 39 additions & 8 deletions Source/VirtualTrees.pas
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,52 @@ interface
// Some aliases for backward compatiblity
PVirtualNode = VirtualTrees.Types.PVirtualNode;
TVirtualNode = VirtualTrees.Types.TVirtualNode;
TVTHeaderColumnLayout = VirtualTrees.Types.TVTHeaderColumnLayout;
TSmartAutoFitType = VirtualTrees.Types.TSmartAutoFitType;
TVirtualTreeStates = VirtualTrees.Types.TVirtualTreeStates;
TCheckState = VirtualTrees.Types.TCheckState;
TCheckType = VirtualTrees.Types.TCheckType;
TSortDirection = VirtualTrees.Types.TSortDirection;
TColumnIndex = VirtualTrees.Types.TColumnIndex;
TVTColumnOption = VirtualTrees.Types.TVTColumnOption;
TVTHeaderHitInfo = VirtualTrees.Types.TVTHeaderHitInfo;
TVTHeaderHitPosition = VirtualTrees.Types.TVTHeaderHitPosition;
TVTHeaderHitPositions = VirtualTrees.Types.TVTHeaderHitPositions;
THeaderState = VirtualTrees.Types.THeaderState;
THeaderStates = VirtualTrees.Types.THeaderStates;
TDropMode = VirtualTrees.Types.TDropMode;
TFormatArray = VirtualTrees.Types.TFormatArray;
TVTHeaderOption = VirtualTrees.Types.TVTHeaderOption;
TVTHeaderOptions = VirtualTrees.Types.TVTHeaderOptions;
TVTHeaderStyle = VirtualTrees.Types.TVTHeaderStyle;
TVTExportType = VirtualTrees.Types.TVTExportType;
TVTImageKind = VirtualTrees.Types.TVTImageKind;
TVTExportMode = VirtualTrees.Types.TVTExportMode;
TVTOperationKind = VirtualTrees.Types.TVTOperationKind;
TVTUpdateState = VirtualTrees.Types.TVTUpdateState;
TVTCellPaintMode = VirtualTrees.Types.TVTCellPaintMode;
TVirtualNodeState = VirtualTrees.Types.TVirtualNodeState;
TVirtualNodeInitState = VirtualTrees.Types.TVirtualNodeInitState;
TVirtualNodeInitStates = VirtualTrees.Types.TVirtualNodeInitStates;
TVTTooltipLineBreakStyle = VirtualTrees.Types.TVTTooltipLineBreakStyle;
TVTNodeAttachMode = VirtualTrees.Types.TVTNodeAttachMode;
TNodeArray = VirtualTrees.Types.TNodeArray;
THitInfo = VirtualTrees.Types.THitInfo;
THitPosition = VirtualTrees.Types.THitPosition;
TVTPaintOption = VirtualTrees.Types.TVTPaintOption;
TVTSelectionOption = VirtualTrees.Types.TVTSelectionOption;
TBaseVirtualTree = VirtualTrees.BaseTree.TBaseVirtualTree;
IVTEditLink = VirtualTrees.BaseTree.IVTEditLink;
TVTHeaderNotifyEvent = VirtualTrees.BaseTree.TVTHeaderNotifyEvent;
TVirtualTreeColumn = VirtualTrees.Header.TVirtualTreeColumn;
TVirtualTreeColumns = VirtualTrees.Header.TVirtualTreeColumns;
TVTHeader = VirtualTrees.Header.TVTHeader;
TVTHeaderClass = VirtualTrees.Header.TVTHeaderClass;
TVTHeaderOption = VirtualTrees.Header.TVTHeaderOption;
TVTHeaderOptions = VirtualTrees.Header.TVTHeaderOptions;
THeaderPaintInfo = VirtualTrees.Header.THeaderPaintInfo;
TVTHeaderColumnLayout = VirtualTrees.Types.TVTHeaderColumnLayout;
TVTConstraintPercent = VirtualTrees.Header.TVTConstraintPercent;
TSmartAutoFitType = VirtualTrees.Types.TSmartAutoFitType;
TVirtualTreeStates = VirtualTrees.Types.TVirtualTreeStates;
TVTFixedAreaConstraints = VirtualTrees.Header.TVTFixedAreaConstraints;
TVTHeaderStyle = VirtualTrees.Header.TVTHeaderStyle;
THeaderState = VirtualTrees.Header.THeaderState;
THeaderStates = VirtualTrees.Header.THeaderStates;
TColumnsArray = VirtualTrees.Header.TColumnsArray;
TCanvas = Vcl.Graphics.TCanvas;
const
//Aliases
NoColumn = VirtualTrees.Types.NoColumn;
Expand Down

0 comments on commit 0f9e309

Please sign in to comment.