* Readd support for hidden nodes and new header click event removed in 4.8 branch

* Update demos

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2789 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
blikblum
2013-09-07 21:50:00 +00:00
parent d67d6d0a63
commit 6760f1a5bc
16 changed files with 526 additions and 337 deletions

View File

@@ -533,7 +533,8 @@ type
vsClearing, // A node's children are being deleted. Don't register structure change event. vsClearing, // A node's children are being deleted. Don't register structure change event.
vsMultiline, // Node text is wrapped at the cell boundaries instead of being shorted. vsMultiline, // Node text is wrapped at the cell boundaries instead of being shorted.
vsHeightMeasured, // Node height has been determined and does not need a recalculation. vsHeightMeasured, // Node height has been determined and does not need a recalculation.
vsToggling // Set when a node is expanded/collapsed to prevent recursive calls. vsToggling, // Set when a node is expanded/collapsed to prevent recursive calls.
vsHidden // Indicates that the node should not be painted (without effecting its children).
); );
TVirtualNodeStates = set of TVirtualNodeState; TVirtualNodeStates = set of TVirtualNodeState;
@@ -721,7 +722,9 @@ type
toStaticBackground, // Show simple static background instead of a tiled one. toStaticBackground, // Show simple static background instead of a tiled one.
toChildrenAbove, // Display child nodes above their parent. toChildrenAbove, // Display child nodes above their parent.
toFixedIndent, // Draw the tree with a fixed indent. toFixedIndent, // Draw the tree with a fixed indent.
toUseExplorerTheme // Use the explorer theme if run under Windows Vista (or above). toUseExplorerTheme, // Use the explorer theme if run under Windows Vista (or above).
toHideTreeLinesIfThemed, // Do not show tree lines if theming is used.
toShowHiddenNodes // Draw nodes even if they are hidden.
); );
TVTPaintOptions = set of TVTPaintOption; TVTPaintOptions = set of TVTPaintOption;
@@ -903,6 +906,16 @@ type
Data: record end; // this is a placeholder, each node gets extra data determined by NodeDataSize Data: record end; // this is a placeholder, each node gets extra data determined by NodeDataSize
end; end;
// Structure used when info about a certain position in the header is needed.
TVTHeaderHitInfo = record
X,
Y: Integer;
Button: TMouseButton;
Shift: TShiftState;
Column: TColumnIndex;
HitPosition: TVTHeaderHitPositions;
end;
// Structure used when info about a certain position in the tree is needed. // Structure used when info about a certain position in the tree is needed.
THitInfo = record THitInfo = record
HitNode: PVirtualNode; HitNode: PVirtualNode;
@@ -1963,8 +1976,7 @@ type
TVTSaveNodeEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Stream: TStream) of object; TVTSaveNodeEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Stream: TStream) of object;
// header/column events // header/column events
TVTHeaderClickEvent = procedure(Sender: TVTHeader; Column: TColumnIndex; Button: TMouseButton; Shift: TShiftState; X, TVTHeaderClickEvent = procedure(Sender: TVTHeader; HitInfo: TVTHeaderHitInfo) of object;
Y: Integer) of object;
TVTHeaderMouseEvent = procedure(Sender: TVTHeader; Button: TMouseButton; Shift: TShiftState; X, Y: Integer) of object; TVTHeaderMouseEvent = procedure(Sender: TVTHeader; Button: TMouseButton; Shift: TShiftState; X, Y: Integer) of object;
TVTHeaderMouseMoveEvent = procedure(Sender: TVTHeader; Shift: TShiftState; X, Y: Integer) of object; TVTHeaderMouseMoveEvent = procedure(Sender: TVTHeader; Shift: TShiftState; X, Y: Integer) of object;
TVTBeforeHeaderHeightTrackingEvent = procedure(Sender: TVTHeader; Shift: TShiftState) of object; TVTBeforeHeaderHeightTrackingEvent = procedure(Sender: TVTHeader; Shift: TShiftState) of object;
@@ -2283,9 +2295,7 @@ type
FOnAfterAutoFitColumns: TVTAfterAutoFitColumnsEvent; FOnAfterAutoFitColumns: TVTAfterAutoFitColumnsEvent;
FOnBeforeAutoFitColumns: TVTBeforeAutoFitColumnsEvent; FOnBeforeAutoFitColumns: TVTBeforeAutoFitColumnsEvent;
FOnBeforeAutoFitColumn: TVTBeforeAutoFitColumnEvent; FOnBeforeAutoFitColumn: TVTBeforeAutoFitColumnEvent;
FOnHeaderClick, // mouse events for the header, just like those for a control FOnHeaderClick: TVTHeaderClickEvent;
FOnHeaderImageClick,
FOnHeaderCheckBoxClick: TVTHeaderClickEvent;
FOnHeaderDblClick: TVTHeaderClickEvent; FOnHeaderDblClick: TVTHeaderClickEvent;
FOnAfterHeaderHeightTracking: TVTAfterHeaderHeightTrackingEvent; FOnAfterHeaderHeightTracking: TVTAfterHeaderHeightTrackingEvent;
FOnBeforeHeaderHeightTracking: TVTBeforeHeaderHeightTrackingEvent; FOnBeforeHeaderHeightTracking: TVTBeforeHeaderHeightTrackingEvent;
@@ -2391,6 +2401,7 @@ type
function GetExpanded(Node: PVirtualNode): Boolean; function GetExpanded(Node: PVirtualNode): Boolean;
function GetFullyVisible(Node: PVirtualNode): Boolean; function GetFullyVisible(Node: PVirtualNode): Boolean;
function GetHasChildren(Node: PVirtualNode): Boolean; function GetHasChildren(Node: PVirtualNode): Boolean;
function GetHidden(Node: PVirtualNode): Boolean;
function GetMultiline(Node: PVirtualNode): Boolean; function GetMultiline(Node: PVirtualNode): Boolean;
function GetNodeHeight(Node: PVirtualNode): Cardinal; function GetNodeHeight(Node: PVirtualNode): Cardinal;
function GetNodeParent(Node: PVirtualNode): PVirtualNode; function GetNodeParent(Node: PVirtualNode): PVirtualNode;
@@ -2445,6 +2456,7 @@ type
procedure SetFullyVisible(Node: PVirtualNode; Value: Boolean); procedure SetFullyVisible(Node: PVirtualNode; Value: Boolean);
procedure SetHasChildren(Node: PVirtualNode; Value: Boolean); procedure SetHasChildren(Node: PVirtualNode; Value: Boolean);
procedure SetHeader(const Value: TVTHeader); procedure SetHeader(const Value: TVTHeader);
procedure SetHidden(Node: PVirtualNode; Value: Boolean);
procedure SetImages(const Value: TCustomImageList); procedure SetImages(const Value: TCustomImageList);
procedure SetIndent(Value: Cardinal); procedure SetIndent(Value: Cardinal);
procedure SetLineMode(const Value: TVTLineMode); procedure SetLineMode(const Value: TVTLineMode);
@@ -2623,10 +2635,8 @@ type
function DoGetNodeWidth(Node: PVirtualNode; Column: TColumnIndex; Canvas: TCanvas = nil): Integer; virtual; function DoGetNodeWidth(Node: PVirtualNode; Column: TColumnIndex; Canvas: TCanvas = nil): Integer; virtual;
function DoGetPopupMenu(Node: PVirtualNode; Column: TColumnIndex; const Position: TPoint): TPopupMenu; virtual; function DoGetPopupMenu(Node: PVirtualNode; Column: TColumnIndex; const Position: TPoint): TPopupMenu; virtual;
procedure DoGetUserClipboardFormats(var Formats: TFormatEtcArray); virtual; procedure DoGetUserClipboardFormats(var Formats: TFormatEtcArray); virtual;
procedure DoHeaderClick(Column: TColumnIndex; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); virtual; procedure DoHeaderClick(HitInfo: TVTHeaderHitInfo); virtual;
procedure DoHeaderDblClick(Column: TColumnIndex; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); virtual; procedure DoHeaderDblClick(HitInfo: TVTHeaderHitInfo); virtual;
procedure DoHeaderImageClick(Column: TColumnIndex; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); virtual;
procedure DoHeaderCheckBoxClick(Column: TColumnIndex; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); virtual;
procedure DoHeaderDragged(Column: TColumnIndex; OldPosition: TColumnPosition); virtual; procedure DoHeaderDragged(Column: TColumnIndex; OldPosition: TColumnPosition); virtual;
procedure DoHeaderDraggedOut(Column: TColumnIndex; const DropPosition: TPoint); virtual; procedure DoHeaderDraggedOut(Column: TColumnIndex; const DropPosition: TPoint); virtual;
function DoHeaderDragging(Column: TColumnIndex): Boolean; virtual; function DoHeaderDragging(Column: TColumnIndex): Boolean; virtual;
@@ -2896,7 +2906,6 @@ type
property OnGetPopupMenu: TVTPopupEvent read FOnGetPopupMenu write FOnGetPopupMenu; property OnGetPopupMenu: TVTPopupEvent read FOnGetPopupMenu write FOnGetPopupMenu;
property OnGetUserClipboardFormats: TVTGetUserClipboardFormatsEvent read FOnGetUserClipboardFormats property OnGetUserClipboardFormats: TVTGetUserClipboardFormatsEvent read FOnGetUserClipboardFormats
write FOnGetUserClipboardFormats; write FOnGetUserClipboardFormats;
property OnHeaderCheckBoxClick: TVTHeaderClickEvent read FOnHeaderCheckBoxClick write FOnHeaderCheckBoxClick;
property OnHeaderClick: TVTHeaderClickEvent read FOnHeaderClick write FOnHeaderClick; property OnHeaderClick: TVTHeaderClickEvent read FOnHeaderClick write FOnHeaderClick;
property OnHeaderDblClick: TVTHeaderClickEvent read FOnHeaderDblClick write FOnHeaderDblClick; property OnHeaderDblClick: TVTHeaderClickEvent read FOnHeaderDblClick write FOnHeaderDblClick;
property OnHeaderDragged: TVTHeaderDraggedEvent read FOnHeaderDragged write FOnHeaderDragged; property OnHeaderDragged: TVTHeaderDraggedEvent read FOnHeaderDragged write FOnHeaderDragged;
@@ -2909,7 +2918,6 @@ type
write FOnHeaderHeightTracking; write FOnHeaderHeightTracking;
property OnHeaderHeightDblClickResize: TVTHeaderHeightDblClickResizeEvent read FOnHeaderHeightDblClickResize property OnHeaderHeightDblClickResize: TVTHeaderHeightDblClickResizeEvent read FOnHeaderHeightDblClickResize
write FOnHeaderHeightDblClickResize; write FOnHeaderHeightDblClickResize;
property OnHeaderImageClick: TVTHeaderClickEvent read FOnHeaderImageClick write FOnHeaderImageClick;
property OnHeaderMouseDown: TVTHeaderMouseEvent read FOnHeaderMouseDown write FOnHeaderMouseDown; property OnHeaderMouseDown: TVTHeaderMouseEvent read FOnHeaderMouseDown write FOnHeaderMouseDown;
property OnHeaderMouseMove: TVTHeaderMouseMoveEvent read FOnHeaderMouseMove write FOnHeaderMouseMove; property OnHeaderMouseMove: TVTHeaderMouseMoveEvent read FOnHeaderMouseMove write FOnHeaderMouseMove;
property OnHeaderMouseUp: TVTHeaderMouseEvent read FOnHeaderMouseUp write FOnHeaderMouseUp; property OnHeaderMouseUp: TVTHeaderMouseEvent read FOnHeaderMouseUp write FOnHeaderMouseUp;
@@ -2990,20 +2998,24 @@ type
function GetFirstLevel(NodeLevel: Cardinal): PVirtualNode; function GetFirstLevel(NodeLevel: Cardinal): PVirtualNode;
function GetFirstNoInit(ConsiderChildrenAbove: Boolean = False): PVirtualNode; function GetFirstNoInit(ConsiderChildrenAbove: Boolean = False): PVirtualNode;
function GetFirstSelected(ConsiderChildrenAbove: Boolean = False): PVirtualNode; function GetFirstSelected(ConsiderChildrenAbove: Boolean = False): PVirtualNode;
function GetFirstVisible(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = True): PVirtualNode; function GetFirstVisible(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = True;
function GetFirstVisibleChild(Node: PVirtualNode): PVirtualNode; IncludeHidden: Boolean = False): PVirtualNode;
function GetFirstVisibleChildNoInit(Node: PVirtualNode): PVirtualNode; function GetFirstVisibleChild(Node: PVirtualNode; IncludeHidden: Boolean = False): PVirtualNode;
function GetFirstVisibleNoInit(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = True): PVirtualNode; function GetFirstVisibleChildNoInit(Node: PVirtualNode; IncludeHidden: Boolean = False): PVirtualNode;
function GetFirstVisibleNoInit(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = True;
IncludeHidden: Boolean = False): PVirtualNode;
procedure GetHitTestInfoAt(X, Y: Integer; Relative: Boolean; var HitInfo: THitInfo); virtual; procedure GetHitTestInfoAt(X, Y: Integer; Relative: Boolean; var HitInfo: THitInfo); virtual;
function GetLast(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = False): PVirtualNode; function GetLast(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = False): PVirtualNode;
function GetLastInitialized(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = False): PVirtualNode; function GetLastInitialized(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = False): PVirtualNode;
function GetLastNoInit(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = False): PVirtualNode; function GetLastNoInit(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = False): PVirtualNode;
function GetLastChild(Node: PVirtualNode): PVirtualNode; function GetLastChild(Node: PVirtualNode): PVirtualNode;
function GetLastChildNoInit(Node: PVirtualNode): PVirtualNode; function GetLastChildNoInit(Node: PVirtualNode): PVirtualNode;
function GetLastVisible(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = True): PVirtualNode; function GetLastVisible(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = True;
function GetLastVisibleChild(Node: PVirtualNode): PVirtualNode; IncludeHidden: Boolean = False): PVirtualNode;
function GetLastVisibleChildNoInit(Node: PVirtualNode): PVirtualNode; function GetLastVisibleChild(Node: PVirtualNode; IncludeHidden: Boolean = False): PVirtualNode;
function GetLastVisibleNoInit(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = True): PVirtualNode; function GetLastVisibleChildNoInit(Node: PVirtualNode; IncludeHidden: Boolean = False): PVirtualNode;
function GetLastVisibleNoInit(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = True;
IncludeHidden: Boolean = False): PVirtualNode;
function GetMaxColumnWidth(Column: TColumnIndex; UseSmartColumnWidth: Boolean = False): Integer; function GetMaxColumnWidth(Column: TColumnIndex; UseSmartColumnWidth: Boolean = False): Integer;
function GetNext(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = False): PVirtualNode; function GetNext(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = False): PVirtualNode;
function GetNextChecked(Node: PVirtualNode; State: TCheckState = csCheckedNormal; function GetNextChecked(Node: PVirtualNode; State: TCheckState = csCheckedNormal;
@@ -3017,8 +3029,8 @@ type
function GetNextSibling(Node: PVirtualNode): PVirtualNode; function GetNextSibling(Node: PVirtualNode): PVirtualNode;
function GetNextVisible(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = True): PVirtualNode; function GetNextVisible(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = True): PVirtualNode;
function GetNextVisibleNoInit(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = True): PVirtualNode; function GetNextVisibleNoInit(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = True): PVirtualNode;
function GetNextVisibleSibling(Node: PVirtualNode): PVirtualNode; function GetNextVisibleSibling(Node: PVirtualNode; IncludeHidden: Boolean = False): PVirtualNode;
function GetNextVisibleSiblingNoInit(Node: PVirtualNode): PVirtualNode; function GetNextVisibleSiblingNoInit(Node: PVirtualNode; IncludeHidden: Boolean = False): PVirtualNode;
function GetNodeAt(X, Y: Integer): PVirtualNode; overload; function GetNodeAt(X, Y: Integer): PVirtualNode; overload;
function GetNodeAt(X, Y: Integer; Relative: Boolean; var NodeTop: Integer): PVirtualNode; overload; function GetNodeAt(X, Y: Integer; Relative: Boolean; var NodeTop: Integer): PVirtualNode; overload;
function GetNodeData(Node: PVirtualNode): Pointer; function GetNodeData(Node: PVirtualNode): Pointer;
@@ -3035,14 +3047,14 @@ type
function GetPreviousSibling(Node: PVirtualNode): PVirtualNode; function GetPreviousSibling(Node: PVirtualNode): PVirtualNode;
function GetPreviousVisible(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = True): PVirtualNode; function GetPreviousVisible(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = True): PVirtualNode;
function GetPreviousVisibleNoInit(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = True): PVirtualNode; function GetPreviousVisibleNoInit(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = True): PVirtualNode;
function GetPreviousVisibleSibling(Node: PVirtualNode): PVirtualNode; function GetPreviousVisibleSibling(Node: PVirtualNode; IncludeHidden: Boolean = False): PVirtualNode;
function GetPreviousVisibleSiblingNoInit(Node: PVirtualNode): PVirtualNode; function GetPreviousVisibleSiblingNoInit(Node: PVirtualNode; IncludeHidden: Boolean = False): PVirtualNode;
function GetSortedCutCopySet(Resolve: Boolean): TNodeArray; function GetSortedCutCopySet(Resolve: Boolean): TNodeArray;
function GetSortedSelection(Resolve: Boolean): TNodeArray; function GetSortedSelection(Resolve: Boolean): TNodeArray;
procedure GetTextInfo(Node: PVirtualNode; Column: TColumnIndex; const AFont: TFont; var R: TRect; procedure GetTextInfo(Node: PVirtualNode; Column: TColumnIndex; const AFont: TFont; var R: TRect;
out Text: String); virtual; out Text: String); virtual;
function GetTreeRect: TRect; function GetTreeRect: TRect;
function GetVisibleParent(Node: PVirtualNode): PVirtualNode; function GetVisibleParent(Node: PVirtualNode; IncludeHidden: Boolean = False): PVirtualNode;
function HasAsParent(Node, PotentialParent: PVirtualNode): Boolean; function HasAsParent(Node, PotentialParent: PVirtualNode): Boolean;
function InsertNode(Node: PVirtualNode; Mode: TVTNodeAttachMode; UserData: Pointer = nil): PVirtualNode; function InsertNode(Node: PVirtualNode; Mode: TVTNodeAttachMode; UserData: Pointer = nil): PVirtualNode;
procedure InvalidateChildren(Node: PVirtualNode; Recursive: Boolean); procedure InvalidateChildren(Node: PVirtualNode; Recursive: Boolean);
@@ -3051,6 +3063,8 @@ type
procedure InvalidateToBottom(Node: PVirtualNode); procedure InvalidateToBottom(Node: PVirtualNode);
procedure InvertSelection(VisibleOnly: Boolean); procedure InvertSelection(VisibleOnly: Boolean);
function IsEditing: Boolean; function IsEditing: Boolean;
function IsEffectivelyHidden(Node: PVirtualNode): Boolean;
function IsEffectivelyVisible(Node: PVirtualNode): Boolean;
function IsMouseSelecting: Boolean; function IsMouseSelecting: Boolean;
function IterateSubtree(Node: PVirtualNode; Callback: TVTGetNodeProc; Data: Pointer; Filter: TVirtualNodeStates = []; function IterateSubtree(Node: PVirtualNode; Callback: TVTGetNodeProc; Data: Pointer; Filter: TVirtualNodeStates = [];
DoInit: Boolean = False; ChildNodesOnly: Boolean = False): PVirtualNode; DoInit: Boolean = False; ChildNodesOnly: Boolean = False): PVirtualNode;
@@ -3116,6 +3130,7 @@ type
property HasChildren[Node: PVirtualNode]: Boolean read GetHasChildren write SetHasChildren; property HasChildren[Node: PVirtualNode]: Boolean read GetHasChildren write SetHasChildren;
property HotNode: PVirtualNode read FCurrentHotNode; property HotNode: PVirtualNode read FCurrentHotNode;
property IsDisabled[Node: PVirtualNode]: Boolean read GetDisabled write SetDisabled; property IsDisabled[Node: PVirtualNode]: Boolean read GetDisabled write SetDisabled;
property IsHidden[Node: PVirtualNode]: Boolean read GetHidden write SetHidden;
property IsVisible[Node: PVirtualNode]: Boolean read GetVisible write SetVisible; property IsVisible[Node: PVirtualNode]: Boolean read GetVisible write SetVisible;
property MultiLine[Node: PVirtualNode]: Boolean read GetMultiline write SetMultiline; property MultiLine[Node: PVirtualNode]: Boolean read GetMultiline write SetMultiline;
property NodeHeight[Node: PVirtualNode]: Cardinal read GetNodeHeight write SetNodeHeight; property NodeHeight[Node: PVirtualNode]: Cardinal read GetNodeHeight write SetNodeHeight;
@@ -3559,7 +3574,6 @@ type
property OnGetNodeDataSize; property OnGetNodeDataSize;
property OnGetPopupMenu; property OnGetPopupMenu;
property OnGetUserClipboardFormats; property OnGetUserClipboardFormats;
property OnHeaderCheckBoxClick;
property OnHeaderClick; property OnHeaderClick;
property OnHeaderDblClick; property OnHeaderDblClick;
property OnHeaderDragged; property OnHeaderDragged;
@@ -3569,7 +3583,6 @@ type
property OnHeaderDrawQueryElements; property OnHeaderDrawQueryElements;
property OnHeaderHeightDblClickResize; property OnHeaderHeightDblClickResize;
property OnHeaderHeightTracking; property OnHeaderHeightTracking;
property OnHeaderImageClick;
property OnHeaderMouseDown; property OnHeaderMouseDown;
property OnHeaderMouseMove; property OnHeaderMouseMove;
property OnHeaderMouseUp; property OnHeaderMouseUp;
@@ -3805,7 +3818,6 @@ type
property OnGetNodeWidth; property OnGetNodeWidth;
property OnGetPopupMenu; property OnGetPopupMenu;
property OnGetUserClipboardFormats; property OnGetUserClipboardFormats;
property OnHeaderCheckBoxClick;
property OnHeaderClick; property OnHeaderClick;
property OnHeaderDblClick; property OnHeaderDblClick;
property OnHeaderDragged; property OnHeaderDragged;
@@ -3815,7 +3827,6 @@ type
property OnHeaderDrawQueryElements; property OnHeaderDrawQueryElements;
property OnHeaderHeightTracking; property OnHeaderHeightTracking;
property OnHeaderHeightDblClickResize; property OnHeaderHeightDblClickResize;
property OnHeaderImageClick;
property OnHeaderMouseDown; property OnHeaderMouseDown;
property OnHeaderMouseMove; property OnHeaderMouseMove;
property OnHeaderMouseUp; property OnHeaderMouseUp;
@@ -5420,6 +5431,7 @@ procedure TCustomVirtualTreeOptions.SetPaintOptions(const Value: TVTPaintOptions
var var
ToBeSet, ToBeSet,
ToBeCleared: TVTPaintOptions; ToBeCleared: TVTPaintOptions;
Run: PVirtualNode;
begin begin
if FPaintOptions <> Value then if FPaintOptions <> Value then
@@ -5455,6 +5467,29 @@ begin
end end
else else
{$endif ThemeSupport} {$endif ThemeSupport}
if toShowHiddenNodes in ToBeSet + ToBeCleared then
begin
BeginUpdate;
InterruptValidation;
Run := GetFirst;
while Assigned(Run) do
begin
if vsHidden in Run.States then
if toShowHiddenNodes in ToBeSet then
begin
Inc(FVisibleCount);
AdjustTotalHeight(Run.Parent, Run.NodeHeight, True);
end
else
begin
AdjustTotalHeight(Run.Parent, -Run.NodeHeight, True);
Dec(FVisibleCount);
end;
Run := GetNext(Run);
end;
EndUpdate;
end
else
Invalidate; Invalidate;
end; end;
end; end;
@@ -7780,37 +7815,54 @@ procedure TVirtualTreeColumns.HandleClick(P: TPoint; Button: TMouseButton; Force
// double click). // double click).
var var
HitInfo: TVTHeaderHitInfo;
NewClickIndex: Integer; NewClickIndex: Integer;
Shift: TShiftState;
begin begin
// Convert vertical position to local coordinates. // Convert vertical position to local coordinates.
Inc(P.Y, FHeader.FHeight); Inc(P.Y, FHeader.FHeight);
NewClickIndex := ColumnFromPosition(P); NewClickIndex := ColumnFromPosition(P);
with HitInfo do
begin
X := P.X;
Y := P.Y;
Shift := FHeader.GetShiftState;
if DblClick then
Shift := Shift + [ssDouble];
end;
HitInfo.Button := Button;
if (NewClickIndex > NoColumn) and (coAllowClick in Items[NewClickIndex].FOptions) and if (NewClickIndex > NoColumn) and (coAllowClick in Items[NewClickIndex].FOptions) and
((NewClickIndex = FDownIndex) or Force) then ((NewClickIndex = FDownIndex) or Force) then
begin begin
FClickIndex := NewClickIndex; FClickIndex := NewClickIndex;
Shift := FHeader.GetShiftState; HitInfo.Column := NewClickIndex;
if DblClick then HitInfo.HitPosition := [hhiOnColumn];
Shift := Shift + [ssDouble];
if Items[NewClickIndex].FHasImage and PtInRect(Items[NewClickIndex].FImageRect, P) then if Items[NewClickIndex].FHasImage and PtInRect(Items[NewClickIndex].FImageRect, P) then
begin begin
Include(HitInfo.HitPosition, hhiOnIcon);
if Items[NewClickIndex].CheckBox then if Items[NewClickIndex].CheckBox then
begin begin
FHeader.Treeview.UpdateColumnCheckState(Items[NewClickIndex]); FHeader.Treeview.UpdateColumnCheckState(Items[NewClickIndex]);
FHeader.Treeview.DoHeaderCheckBoxClick(NewClickIndex, Button, Shift, P.X, P.Y); Include(HitInfo.HitPosition, hhiOnCheckbox);
end end;
else end;
FHeader.Treeview.DoHeaderImageClick(NewClickIndex, Button, Shift, P.X, P.Y)
end
else
FHeader.Treeview.DoHeaderClick(NewClickIndex, Button, Shift, P.X, P.Y);
FHeader.Invalidate(Items[NewClickIndex]);
end end
else else
begin
FClickIndex := NoColumn; FClickIndex := NoColumn;
HitInfo.Column := NoColumn;
HitInfo.HitPosition := [hhiNoWhere];
end;
if DblClick then
FHeader.Treeview.DoHeaderDblClick(HitInfo)
else
FHeader.Treeview.DoHeaderClick(HitInfo);
if not (hhiNoWhere in HitInfo.HitPosition) then
FHeader.Invalidate(Items[NewClickIndex]);
if (FClickIndex > NoColumn) and (FClickIndex <> NewClickIndex) then if (FClickIndex > NoColumn) and (FClickIndex <> NewClickIndex) then
FHeader.Invalidate(Items[FClickIndex]); FHeader.Invalidate(Items[FClickIndex]);
end; end;
@@ -12497,7 +12549,7 @@ begin
while Assigned(Child) do while Assigned(Child) do
begin begin
FixupTotalHeight(Child); FixupTotalHeight(Child);
if vsVisible in Child.States then if IsEffectivelyVisible(Child) then
Inc(Node.TotalHeight, Child.TotalHeight); Inc(Node.TotalHeight, Child.TotalHeight);
Child := Child.NextSibling; Child := Child.NextSibling;
end; end;
@@ -12650,6 +12702,14 @@ end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
function TBaseVirtualTree.GetHidden(Node: PVirtualNode): Boolean;
begin
Result := vsHidden in Node.States;
end;
//----------------------------------------------------------------------------------------------------------------------
function TBaseVirtualTree.GetMultiline(Node: PVirtualNode): Boolean; function TBaseVirtualTree.GetMultiline(Node: PVirtualNode): Boolean;
begin begin
@@ -12933,7 +12993,7 @@ begin
begin begin
repeat repeat
Node := Node.NextSibling; Node := Node.NextSibling;
Result := vsVisible in Node.States; Result := IsEffectivelyVisible(Node);
until Result or (Node.NextSibling = nil); until Result or (Node.NextSibling = nil);
end; end;
end; end;
@@ -12953,7 +13013,7 @@ begin
begin begin
repeat repeat
Node := Node.PrevSibling; Node := Node.PrevSibling;
Result := vsVisible in Node.States; Result := IsEffectivelyVisible(Node);
until Result or (Node.PrevSibling = nil); until Result or (Node.PrevSibling = nil);
end; end;
end; end;
@@ -13053,7 +13113,7 @@ var
begin begin
// Find first visible child. // Find first visible child.
Run := Parent.FirstChild; Run := Parent.FirstChild;
while Assigned(Run) and not (vsVisible in Run.States) do while Assigned(Run) and not IsEffectivelyVisible(Run) do
Run := Run.NextSibling; Run := Run.NextSibling;
Result := Assigned(Run) and (Run = Node); Result := Assigned(Run) and (Run = Node);
@@ -13071,7 +13131,7 @@ var
begin begin
// Find last visible child. // Find last visible child.
Run := Parent.LastChild; Run := Parent.LastChild;
while Assigned(Run) and not (vsVisible in Run.States) do while Assigned(Run) and not IsEffectivelyVisible(Run) do
Run := Run.PrevSibling; Run := Run.PrevSibling;
Result := Assigned(Run) and (Run = Node); Result := Assigned(Run) and (Run = Node);
@@ -13711,7 +13771,7 @@ begin
if vsExpanded in Node.States then if vsExpanded in Node.States then
begin begin
AdjustTotalHeight(Node, NewHeight, True); AdjustTotalHeight(Node, NewHeight, True);
if FullyVisible[Node] then if FullyVisible[Node] and not IsEffectivelyHidden(Node) then
Inc(Integer(FVisibleCount), Count); Inc(Integer(FVisibleCount), Count);
end; end;
@@ -13935,6 +13995,66 @@ begin
FHeader.Assign(Value); FHeader.Assign(Value);
end; end;
//----------------------------------------------------------------------------------------------------------------------
procedure TBaseVirtualTree.SetHidden(Node: PVirtualNode; Value: Boolean);
// Sets the hidden flag of the given node according to Value.
var
NeedUpdate: Boolean;
begin
Assert(Assigned(Node) and (Node <> FRoot), 'Invalid parameter.');
if Value <> (vsHidden in Node.States) then
begin
InterruptValidation;
NeedUpdate := False;
if Value then
begin
Include(Node.States, vsHidden);
if (vsExpanded in Node.Parent.States) and not (toShowHiddenNodes in FOptions.FPaintOptions) then
AdjustTotalHeight(Node.Parent, -Integer(NodeHeight[Node]), True);
if VisiblePath[Node] then
begin
Dec(FVisibleCount);
NeedUpdate := True;
end;
if FUpdateCount = 0 then
DetermineHiddenChildrenFlag(Node.Parent)
else
Include(FStates, tsUpdateHiddenChildrenNeeded);
end
else
begin
Exclude(Node.States, vsHidden);
if (vsExpanded in Node.Parent.States) and not (toShowHiddenNodes in FOptions.FPaintOptions) then
AdjustTotalHeight(Node.Parent, Integer(NodeHeight[Node]), True);
if VisiblePath[Node] then
begin
Inc(FVisibleCount);
NeedUpdate := True;
end;
if vsVisible in Node.States then
// Update the hidden children flag of the parent.
// Since this node is now visible we simply have to remove the flag.
Exclude(Node.Parent.States, vsAllChildrenHidden);
end;
InvalidateCache;
if NeedUpdate and (FUpdateCount = 0) then
begin
ValidateCache;
UpdateScrollBars(True);
Invalidate;
end;
end;
end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
procedure TBaseVirtualTree.SetImages(const Value: TCustomImageList); procedure TBaseVirtualTree.SetImages(const Value: TCustomImageList);
@@ -14087,7 +14207,7 @@ begin
UpdateEditBounds; UpdateEditBounds;
// Stay away from touching the node cache while it is being validated. // Stay away from touching the node cache while it is being validated.
if not (tsValidating in FStates) and FullyVisible[Node] then if not (tsValidating in FStates) and FullyVisible[Node] and not IsEffectivelyHidden(Node) then
begin begin
InvalidateCache; InvalidateCache;
if FUpdateCount = 0 then if FUpdateCount = 0 then
@@ -14220,7 +14340,7 @@ begin
if FSelectionCount = 0 then if FSelectionCount = 0 then
ResetRangeAnchor; ResetRangeAnchor;
end; end;
if FullyVisible[Node] then if FullyVisible[Node] and not IsEffectivelyHidden(Node) then
InvalidateNode(Node); InvalidateNode(Node);
end; end;
end; end;
@@ -14324,7 +14444,7 @@ begin
if Node.Align <> Value then if Node.Align <> Value then
begin begin
Node.Align := Value; Node.Align := Value;
if FullyVisible[Node] then if FullyVisible[Node] and not IsEffectivelyHidden(Node) then
InvalidateNode(Node); InvalidateNode(Node);
end; end;
end; end;
@@ -17364,7 +17484,8 @@ begin
Node := Node.FirstChild; Node := Node.FirstChild;
while Assigned(Node) do while Assigned(Node) do
begin begin
if vsVisible in Node.States then if (vsVisible in Node.States) and (not (vsHidden in Node.States) or
(toShowHiddenNodes in FOptions.FPaintOptions)) then
Inc(Result, CountVisibleChildren(Node) + 1); Inc(Result, CountVisibleChildren(Node) + 1);
Node := Node.NextSibling; Node := Node.NextSibling;
end; end;
@@ -17515,7 +17636,7 @@ begin
begin begin
// Iterate through all siblings and stop when one visible is found. // Iterate through all siblings and stop when one visible is found.
Run := Node.FirstChild; Run := Node.FirstChild;
while Assigned(Run) do while Assigned(Run) and not IsEffectivelyVisible(Run) do
Run := Run.NextSibling; Run := Run.NextSibling;
if Assigned(Run) then if Assigned(Run) then
Exclude(Node.States, vsAllChildrenHidden) Exclude(Node.States, vsAllChildrenHidden)
@@ -18769,42 +18890,20 @@ end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
procedure TBaseVirtualTree.DoHeaderClick(Column: TColumnIndex; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure TBaseVirtualTree.DoHeaderClick(HitInfo: TVTHeaderHitInfo);
begin begin
if Assigned(FOnHeaderClick) then if Assigned(FOnHeaderClick) then
FOnHeaderClick(FHeader, Column, Button, Shift, X, Y); FOnHeaderClick(FHeader, HitInfo);
end; end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
procedure TBaseVirtualTree.DoHeaderDblClick(Column: TColumnIndex; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure TBaseVirtualTree.DoHeaderDblClick(HitInfo: TVTHeaderHitInfo);
begin begin
if Assigned(FOnHeaderDblClick) then if Assigned(FOnHeaderDblClick) then
FOnHeaderDblClick(FHeader, Column, Button, Shift, X, Y); FOnHeaderDblClick(FHeader, HitInfo);
end;
//----------------------------------------------------------------------------------------------------------------------
procedure TBaseVirtualTree.DoHeaderImageClick(Column: TColumnIndex; Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
begin
if Assigned(FOnHeaderImageClick) then
FOnHeaderImageClick(FHeader, Column, Button, Shift, X, Y)
else if Assigned(FOnHeaderClick) then
FOnHeaderClick(FHeader, Column, Button, Shift, X, Y)
end;
//----------------------------------------------------------------------------------------------------------------------
procedure TBaseVirtualTree.DoHeaderCheckBoxClick(Column: TColumnIndex; Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
begin
if Assigned(FOnHeaderCheckBoxClick) then
FOnHeaderCheckBoxClick(FHeader, Column, Button, Shift, X, Y);
end; end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
@@ -20677,7 +20776,7 @@ begin
if not (vsInitialized in Run.States) then if not (vsInitialized in Run.States) then
Run := nil; Run := nil;
isVisibleOnly: isVisibleOnly:
if not FullyVisible[Run] then if not FullyVisible[Run] or IsEffectivelyHidden(Run) then
Run := nil; Run := nil;
end; end;
end; end;
@@ -21313,7 +21412,7 @@ begin
// Keep the current total height value of Node as it has already been applied // Keep the current total height value of Node as it has already been applied
// but might change in the load and fixup code. We have to adjust that afterwards. // but might change in the load and fixup code. We have to adjust that afterwards.
LastTotalHeight := Node.TotalHeight; LastTotalHeight := Node.TotalHeight;
WasFullyVisible := FullyVisible[Node]; WasFullyVisible := FullyVisible[Node] and not IsEffectivelyHidden(Node);
// Read in the new nodes. // Read in the new nodes.
ReadNode(Stream, Version, Node); ReadNode(Stream, Version, Node);
@@ -21327,7 +21426,7 @@ begin
// New nodes are always visible, so the visible node count has been increased already. // New nodes are always visible, so the visible node count has been increased already.
// If Node is now invisible we have to take back this increment and don't need to add any visible child node. // If Node is now invisible we have to take back this increment and don't need to add any visible child node.
if not FullyVisible[Node] then if not FullyVisible[Node] or IsEffectivelyHidden(Node) then
begin begin
if WasFullyVisible then if WasFullyVisible then
Dec(FVisibleCount); Dec(FVisibleCount);
@@ -21568,9 +21667,9 @@ begin
AdjustTotalCount(Destination.Parent, Node.TotalCount, True); AdjustTotalCount(Destination.Parent, Node.TotalCount, True);
// Add the new node's height only if its parent is expanded. // Add the new node's height only if its parent is expanded.
if Destination.Parent.States * [vsExpanded, vsVisible] = [vsExpanded, vsVisible] then if (vsExpanded in Destination.Parent.States) and IsEffectivelyVisible(Node) then
AdjustTotalHeight(Destination.Parent, Node.TotalHeight, True); AdjustTotalHeight(Destination.Parent, Node.TotalHeight, True);
if FullyVisible[Node] then if FullyVisible[Node] and not IsEffectivelyHidden(Node) then
Inc(FVisibleCount, CountVisibleChildren(Node) + 1); Inc(FVisibleCount, CountVisibleChildren(Node) + 1);
end; end;
amInsertAfter: amInsertAfter:
@@ -21598,9 +21697,9 @@ begin
AdjustTotalCount(Destination.Parent, Node.TotalCount, True); AdjustTotalCount(Destination.Parent, Node.TotalCount, True);
// Add the new node's height only if its parent is expanded. // Add the new node's height only if its parent is expanded.
if Destination.Parent.States * [vsExpanded, vsVisible] = [vsExpanded, vsVisible] then if (vsExpanded in Destination.Parent.States) and IsEffectivelyVisible(Node) then
AdjustTotalHeight(Destination.Parent, Node.TotalHeight, True); AdjustTotalHeight(Destination.Parent, Node.TotalHeight, True);
if FullyVisible[Node] then if FullyVisible[Node] and not IsEffectivelyHidden(Node) then
Inc(FVisibleCount, CountVisibleChildren(Node) + 1); Inc(FVisibleCount, CountVisibleChildren(Node) + 1);
end; end;
amAddChildFirst: amAddChildFirst:
@@ -21634,9 +21733,9 @@ begin
Include(Destination.States, vsHasChildren); Include(Destination.States, vsHasChildren);
AdjustTotalCount(Destination, Node.TotalCount, True); AdjustTotalCount(Destination, Node.TotalCount, True);
// Add the new node's height only if its parent is expanded. // Add the new node's height only if its parent is expanded.
if Destination.States * [vsExpanded, vsVisible] = [vsExpanded, vsVisible] then if (vsExpanded in Destination.Parent.States) and IsEffectivelyVisible(Node) then
AdjustTotalHeight(Destination, Node.TotalHeight, True); AdjustTotalHeight(Destination, Node.TotalHeight, True);
if FullyVisible[Node] then if FullyVisible[Node] and not IsEffectivelyHidden(Node) then
Inc(FVisibleCount, CountVisibleChildren(Node) + 1); Inc(FVisibleCount, CountVisibleChildren(Node) + 1);
end; end;
amAddChildLast: amAddChildLast:
@@ -21665,9 +21764,9 @@ begin
Include(Destination.States, vsHasChildren); Include(Destination.States, vsHasChildren);
AdjustTotalCount(Destination, Node.TotalCount, True); AdjustTotalCount(Destination, Node.TotalCount, True);
// Add the new node's height only if its parent is expanded. // Add the new node's height only if its parent is expanded.
if Destination.States * [vsExpanded, vsVisible] = [vsExpanded, vsVisible] then if (vsExpanded in Destination.Parent.States) and IsEffectivelyVisible(Node) then
AdjustTotalHeight(Destination, Node.TotalHeight, True); AdjustTotalHeight(Destination, Node.TotalHeight, True);
if FullyVisible[Node] then if FullyVisible[Node] and not IsEffectivelyHidden(Node) then
Inc(FVisibleCount, CountVisibleChildren(Node) + 1); Inc(FVisibleCount, CountVisibleChildren(Node) + 1);
end; end;
else else
@@ -21681,7 +21780,7 @@ begin
if (Mode <> amNoWhere) and (Node.Parent <> FRoot) then if (Mode <> amNoWhere) and (Node.Parent <> FRoot) then
begin begin
// If we have added a visible node then simply remove the all-children-hidden flag. // If we have added a visible node then simply remove the all-children-hidden flag.
if vsVisible in Node.States then if IsEffectivelyVisible(Node) then
Exclude(Node.Parent.States, vsAllChildrenHidden) Exclude(Node.Parent.States, vsAllChildrenHidden)
else else
// If we have added an invisible node and this is the only child node then // If we have added an invisible node and this is the only child node then
@@ -21742,7 +21841,7 @@ begin
Node.States := Node.States - [vsChecking]; Node.States := Node.States - [vsChecking];
Parent := Node.Parent; Parent := Node.Parent;
Dec(Parent.ChildCount); Dec(Parent.ChildCount);
AdjustHeight := Parent.States * [vsExpanded, vsVisible] = [vsExpanded, vsVisible]; AdjustHeight := (vsExpanded in Parent.States) and IsEffectivelyVisible(Node);
if Parent.ChildCount = 0 then if Parent.ChildCount = 0 then
begin begin
Parent.States := Parent.States - [vsAllChildrenHidden, vsHasChildren]; Parent.States := Parent.States - [vsAllChildrenHidden, vsHasChildren];
@@ -24625,7 +24724,7 @@ begin
Run := Node.LastChild; Run := Node.LastChild;
while Assigned(Run) do while Assigned(Run) do
begin begin
if ParentVisible and (vsVisible in Run.States) then if ParentVisible and IsEffectivelyVisible(Run) then
Dec(FVisibleCount); Dec(FVisibleCount);
Include(Run.States, vsDeleting); Include(Run.States, vsDeleting);
@@ -25156,7 +25255,7 @@ begin
// Check whether the node is visible (determine indentation level btw.). // Check whether the node is visible (determine indentation level btw.).
Temp := Node; Temp := Node;
if not (vsVisible in Temp.States) then if not IsEffectivelyVisible(Temp) then
Exit; Exit;
Indent := 0; Indent := 0;
while Temp <> FRoot do while Temp <> FRoot do
@@ -25486,7 +25585,8 @@ end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
function TBaseVirtualTree.GetFirstVisible(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = True): PVirtualNode; function TBaseVirtualTree.GetFirstVisible(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = True;
IncludeHidden: Boolean = False): PVirtualNode;
// Returns the first visible node in the tree while optionally considering toChildrenAbove. // Returns the first visible node in the tree while optionally considering toChildrenAbove.
// If necessary nodes are initialized on demand. // If necessary nodes are initialized on demand.
@@ -25576,11 +25676,14 @@ begin
end end
else else
Result := nil; Result := nil;
if Assigned(Result) and not IncludeHidden and IsEffectivelyHidden(Result) then
Result := GetNextVisible(Result);
end; end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
function TBaseVirtualTree.GetFirstVisibleChild(Node: PVirtualNode): PVirtualNode; function TBaseVirtualTree.GetFirstVisibleChild(Node: PVirtualNode; IncludeHidden: Boolean = False): PVirtualNode;
// Returns the first visible child node of Node. If necessary nodes are initialized on demand. // Returns the first visible child node of Node. If necessary nodes are initialized on demand.
@@ -25589,13 +25692,13 @@ begin
Node := FRoot; Node := FRoot;
Result := GetFirstChild(Node); Result := GetFirstChild(Node);
if Assigned(Result) and not (vsVisible in Result.States) then if Assigned(Result) and (not (vsVisible in Result.States) or (not IncludeHidden and IsEffectivelyHidden(Node))) then
Result := GetNextVisibleSibling(Result); Result := GetNextVisibleSibling(Result, IncludeHidden);
end; end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
function TBaseVirtualTree.GetFirstVisibleChildNoInit(Node: PVirtualNode): PVirtualNode; function TBaseVirtualTree.GetFirstVisibleChildNoInit(Node: PVirtualNode; IncludeHidden: Boolean = False): PVirtualNode;
// Returns the first visible child node of Node. // Returns the first visible child node of Node.
@@ -25603,14 +25706,14 @@ begin
if Node = nil then if Node = nil then
Node := FRoot; Node := FRoot;
Result := Node.FirstChild; Result := Node.FirstChild;
if Assigned(Result) and not (vsVisible in Result.States) then if Assigned(Result) and (not (vsVisible in Result.States) or (not IncludeHidden and IsEffectivelyHidden(Node))) then
Result := GetNextVisibleSiblingNoInit(ResulT); Result := GetNextVisibleSiblingNoInit(Result, IncludeHidden);
end; end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
function TBaseVirtualTree.GetFirstVisibleNoInit(Node: PVirtualNode = nil; function TBaseVirtualTree.GetFirstVisibleNoInit(Node: PVirtualNode = nil;
ConsiderChildrenAbove: Boolean = True): PVirtualNode; ConsiderChildrenAbove: Boolean = True; IncludeHidden: Boolean = False): PVirtualNode;
// Returns the first visible node in the tree or given subtree while optionally considering toChildrenAbove. // Returns the first visible node in the tree or given subtree while optionally considering toChildrenAbove.
// No initialization is performed. // No initialization is performed.
@@ -25682,6 +25785,9 @@ begin
end end
else else
Result := nil; Result := nil;
if Assigned(Result) and not IncludeHidden and IsEffectivelyHidden(Result) then
Result := GetNextVisibleNoInit(Result);
end; end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
@@ -25924,7 +26030,8 @@ end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
function TBaseVirtualTree.GetLastVisible(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = True): PVirtualNode; function TBaseVirtualTree.GetLastVisible(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = True;
IncludeHidden: Boolean = False): PVirtualNode;
// Returns the very last visible node in the tree while optionally considering toChildrenAbove. // Returns the very last visible node in the tree while optionally considering toChildrenAbove.
// The nodes are intialized all the way down including the result node. // The nodes are intialized all the way down including the result node.
@@ -25933,13 +26040,13 @@ var
Next: PVirtualNode; Next: PVirtualNode;
begin begin
Result := GetLastVisibleChild(Node); Result := GetLastVisibleChild(Node, IncludeHidden);
if not ConsiderChildrenAbove or not (toChildrenAbove in FOptions.FPaintOptions) then if not ConsiderChildrenAbove or not (toChildrenAbove in FOptions.FPaintOptions) then
while Assigned(Result) do while Assigned(Result) do
begin begin
// Test if there is a next last visible child. If not keep the node from the last run. // Test if there is a next last visible child. If not keep the node from the last run.
// Otherwise use the next last visible child. // Otherwise use the next last visible child.
Next := GetLastVisibleChild(Result); Next := GetLastVisibleChild(Result, IncludeHidden);
if Next = nil then if Next = nil then
Break; Break;
Result := Next; Result := Next;
@@ -25948,7 +26055,7 @@ end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
function TBaseVirtualTree.GetLastVisibleChild(Node: PVirtualNode): PVirtualNode; function TBaseVirtualTree.GetLastVisibleChild(Node: PVirtualNode; IncludeHidden: Boolean = False): PVirtualNode;
// Determines the last visible child of the given node and initializes it if necessary. // Determines the last visible child of the given node and initializes it if necessary.
@@ -25961,8 +26068,8 @@ begin
else else
Result := nil; Result := nil;
if Assigned(Result) and not (vsVisible in Result.States) then if Assigned(Result) and (not (vsVisible in Result.States) or (not IncludeHidden and IsEffectivelyHidden(Node))) then
Result := GetPreviousVisibleSibling(Result); Result := GetPreviousVisibleSibling(Result, IncludeHidden);
if Assigned(Result) and not (vsInitialized in Result.States) then if Assigned(Result) and not (vsInitialized in Result.States) then
InitNode(Result); InitNode(Result);
@@ -25970,7 +26077,7 @@ end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
function TBaseVirtualTree.GetLastVisibleChildNoInit(Node: PVirtualNode): PVirtualNode; function TBaseVirtualTree.GetLastVisibleChildNoInit(Node: PVirtualNode; IncludeHidden: Boolean = False): PVirtualNode;
// Determines the last visible child of the given node without initialization. // Determines the last visible child of the given node without initialization.
@@ -25983,14 +26090,14 @@ begin
else else
Result := nil; Result := nil;
if Assigned(Result) and not (vsVisible in Result.States) then if Assigned(Result) and (not (vsVisible in Result.States) or (not IncludeHidden and IsEffectivelyHidden(Node))) then
Result := GetPreviousVisibleSiblingNoInit(Result); Result := GetPreviousVisibleSiblingNoInit(Result, IncludeHidden);
end; end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
function TBaseVirtualTree.GetLastVisibleNoInit(Node: PVirtualNode = nil; function TBaseVirtualTree.GetLastVisibleNoInit(Node: PVirtualNode = nil;
ConsiderChildrenAbove: Boolean = True): PVirtualNode; ConsiderChildrenAbove: Boolean = True; IncludeHidden: Boolean = False): PVirtualNode;
// Returns the very last visible node in the tree while optionally considering toChildrenAbove. // Returns the very last visible node in the tree while optionally considering toChildrenAbove.
// No initialization is performed. // No initialization is performed.
@@ -25999,13 +26106,13 @@ var
Next: PVirtualNode; Next: PVirtualNode;
begin begin
Result := GetLastVisibleChildNoInit(Node); Result := GetLastVisibleChildNoInit(Node, IncludeHidden);
if not ConsiderChildrenAbove or not (toChildrenAbove in FOptions.FPaintOptions) then if not ConsiderChildrenAbove or not (toChildrenAbove in FOptions.FPaintOptions) then
while Assigned(Result) do while Assigned(Result) do
begin begin
// Test if there is a next last visible child. If not keep the node from the last run. // Test if there is a next last visible child. If not keep the node from the last run.
// Otherwise use the next last visible child. // Otherwise use the next last visible child.
Next := GetLastVisibleChildNoInit(Result); Next := GetLastVisibleChildNoInit(Result, IncludeHidden);
if Next = nil then if Next = nil then
Break; Break;
Result := Next; Result := Next;
@@ -26461,10 +26568,11 @@ begin
begin begin
Assert(Result <> FRoot, 'Node must not be the hidden root node.'); Assert(Result <> FRoot, 'Node must not be the hidden root node.');
repeat
// If the given node is not visible then look for a parent node which is visible, otherwise we will // If the given node is not visible then look for a parent node which is visible, otherwise we will
// likely go unnecessarily through a whole bunch of invisible nodes. // likely go unnecessarily through a whole bunch of invisible nodes.
if not FullyVisible[Result] then if not FullyVisible[Result] then
Result := GetVisibleParent(Result); Result := GetVisibleParent(Result, True);
if ConsiderChildrenAbove and (toChildrenAbove in FOptions.FPaintOptions) then if ConsiderChildrenAbove and (toChildrenAbove in FOptions.FPaintOptions) then
begin begin
@@ -26557,6 +26665,7 @@ begin
until False; until False;
end; end;
end; end;
until not Assigned(Result) or IsEffectivelyVisible(Result);
end; end;
end; end;
@@ -26576,6 +26685,7 @@ begin
begin begin
Assert(Result <> FRoot, 'Node must not be the hidden root node.'); Assert(Result <> FRoot, 'Node must not be the hidden root node.');
repeat
if ConsiderChildrenAbove and (toChildrenAbove in FOptions.FPaintOptions) then if ConsiderChildrenAbove and (toChildrenAbove in FOptions.FPaintOptions) then
begin begin
repeat repeat
@@ -26617,7 +26727,7 @@ begin
// If the given node is not visible then look for a parent node which is visible, otherwise we will // If the given node is not visible then look for a parent node which is visible, otherwise we will
// likely go unnecessarily through a whole bunch of invisible nodes. // likely go unnecessarily through a whole bunch of invisible nodes.
if not FullyVisible[Result] then if not FullyVisible[Result] then
Result := GetVisibleParent(Result); Result := GetVisibleParent(Result, True);
// Child nodes are the first choice if possible. // Child nodes are the first choice if possible.
if (vsExpanded in Result.States) and Assigned(Result.FirstChild) then if (vsExpanded in Result.States) and Assigned(Result.FirstChild) then
@@ -26654,12 +26764,13 @@ begin
until False; until False;
end; end;
end; end;
until not Assigned(Result) or IsEffectivelyVisible(Result);
end; end;
end; end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
function TBaseVirtualTree.GetNextVisibleSibling(Node: PVirtualNode): PVirtualNode; function TBaseVirtualTree.GetNextVisibleSibling(Node: PVirtualNode; IncludeHidden: Boolean = False): PVirtualNode;
// Returns the next visible sibling after Node. Initialization is done implicitly. // Returns the next visible sibling after Node. Initialization is done implicitly.
@@ -26669,12 +26780,12 @@ begin
Result := Node; Result := Node;
repeat repeat
Result := GetNextSibling(Result); Result := GetNextSibling(Result);
until not Assigned(Result) or (vsVisible in Result.States); until not Assigned(Result) or ((vsVisible in Result.States) and (IncludeHidden or not IsEffectivelyHidden(Result)));
end; end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
function TBaseVirtualTree.GetNextVisibleSiblingNoInit(Node: PVirtualNode): PVirtualNode; function TBaseVirtualTree.GetNextVisibleSiblingNoInit(Node: PVirtualNode; IncludeHidden: Boolean = False): PVirtualNode;
// Returns the next visible sibling after Node. // Returns the next visible sibling after Node.
@@ -26684,7 +26795,7 @@ begin
Result := Node; Result := Node;
repeat repeat
Result := Result.NextSibling; Result := Result.NextSibling;
until not Assigned(Result) or (vsVisible in Result.States); until not Assigned(Result) or ((vsVisible in Result.States) and (IncludeHidden or not IsEffectivelyHidden(Result)));
end; end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
@@ -27084,7 +27195,7 @@ begin
// child or the parent node (if there is no visible child) as result. // child or the parent node (if there is no visible child) as result.
if not FullyVisible[Result] then if not FullyVisible[Result] then
begin begin
Result := GetVisibleParent(Result); Result := GetVisibleParent(Result, True);
if Result = FRoot then if Result = FRoot then
Result := nil; Result := nil;
Marker := GetLastVisible(Result, True); Marker := GetLastVisible(Result, True);
@@ -27122,7 +27233,7 @@ begin
repeat repeat
Result := Result.Parent; Result := Result.Parent;
if Result <> FRoot then if Result <> FRoot then
Marker := GetPreviousVisibleSibling(Result) Marker := GetPreviousVisibleSibling(Result, True)
else else
Result := nil; Result := nil;
until Assigned(Marker) or (Result = nil); until Assigned(Marker) or (Result = nil);
@@ -27146,7 +27257,7 @@ begin
if vsVisible in Result.States then if vsVisible in Result.States then
begin begin
// If there are visible child nodes then use the last one. // If there are visible child nodes then use the last one.
Marker := GetLastVisible(Result, True); Marker := GetLastVisible(Result, True, True);
if Assigned(Marker) then if Assigned(Marker) then
Result := Marker; Result := Marker;
Break; Break;
@@ -27166,7 +27277,7 @@ begin
if Assigned(Result) and not (vsInitialized in Result.States) then if Assigned(Result) and not (vsInitialized in Result.States) then
InitNode(Result); InitNode(Result);
end; end;
until not Assigned(Result) or (vsVisible in Result.States); until not Assigned(Result) or IsEffectivelyVisible(Result);
end; end;
end; end;
@@ -27192,7 +27303,7 @@ begin
// child or the parent node (if there is no visible child) as result. // child or the parent node (if there is no visible child) as result.
if not FullyVisible[Result] then if not FullyVisible[Result] then
begin begin
Result := GetVisibleParent(Result); Result := GetVisibleParent(Result, True);
if Result = FRoot then if Result = FRoot then
Result := nil; Result := nil;
Marker := GetLastVisibleNoInit(Result, True); Marker := GetLastVisibleNoInit(Result, True);
@@ -27229,7 +27340,7 @@ begin
repeat repeat
Result := Result.Parent; Result := Result.Parent;
if Result <> FRoot then if Result <> FRoot then
Marker := GetPreviousVisibleSiblingNoInit(Result) Marker := GetPreviousVisibleSiblingNoInit(Result, True)
else else
Result := nil; Result := nil;
until Assigned(Marker) or (Result = nil); until Assigned(Marker) or (Result = nil);
@@ -27249,7 +27360,7 @@ begin
if vsVisible in Result.States then if vsVisible in Result.States then
begin begin
// If there are visible child nodes then use the last one. // If there are visible child nodes then use the last one.
Marker := GetLastVisibleNoInit(Result, True); Marker := GetLastVisibleNoInit(Result, True, True);
if Assigned(Marker) then if Assigned(Marker) then
Result := Marker; Result := Marker;
Break; Break;
@@ -27266,13 +27377,13 @@ begin
until False; until False;
end; end;
end; end;
until not Assigned(Result) or (vsVisible in Result.States); until not Assigned(Result) or IsEffectivelyVisible(Result);
end; end;
end; end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
function TBaseVirtualTree.GetPreviousVisibleSibling(Node: PVirtualNode): PVirtualNode; function TBaseVirtualTree.GetPreviousVisibleSibling(Node: PVirtualNode; IncludeHidden: Boolean = False): PVirtualNode;
// Returns the previous visible sibling before Node. Initialization is done implicitly. // Returns the previous visible sibling before Node. Initialization is done implicitly.
@@ -27282,12 +27393,13 @@ begin
Result := Node; Result := Node;
repeat repeat
Result := GetPreviousSibling(Result); Result := GetPreviousSibling(Result);
until not Assigned(Result) or (vsVisible in Result.States); until not Assigned(Result) or ((vsVisible in Result.States) and (IncludeHidden or not IsEffectivelyHidden(Result)));
end; end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
function TBaseVirtualTree.GetPreviousVisibleSiblingNoInit(Node: PVirtualNode): PVirtualNode; function TBaseVirtualTree.GetPreviousVisibleSiblingNoInit(Node: PVirtualNode;
IncludeHidden: Boolean = False): PVirtualNode;
// Returns the previous visible sibling before Node. // Returns the previous visible sibling before Node.
@@ -27297,7 +27409,7 @@ begin
Result := Node; Result := Node;
repeat repeat
Result := Result.PrevSibling; Result := Result.PrevSibling;
until not Assigned(Result) or (vsVisible in Result.States); until not Assigned(Result) or ((vsVisible in Result.States) and (IncludeHidden or not IsEffectivelyHidden(Result)));
end; end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
@@ -27480,7 +27592,7 @@ end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
function TBaseVirtualTree.GetVisibleParent(Node: PVirtualNode): PVirtualNode; function TBaseVirtualTree.GetVisibleParent(Node: PVirtualNode; IncludeHidden: Boolean = False): PVirtualNode;
// Returns the first (nearest) parent node of Node which is visible. // Returns the first (nearest) parent node of Node which is visible.
// This method is one of the seldom cases where the hidden root node could be returned. // This method is one of the seldom cases where the hidden root node could be returned.
@@ -27490,7 +27602,7 @@ begin
Assert(Node <> FRoot, 'Node must not be the hidden root node.'); Assert(Node <> FRoot, 'Node must not be the hidden root node.');
Result := Node.Parent; Result := Node.Parent;
while (Result <> FRoot) and not FullyVisible[Result] do while (Result <> FRoot) and (not FullyVisible[Result] or (not IncludeHidden and IsEffectivelyHidden(Result))) do
Result := Result.Parent; Result := Result.Parent;
end; end;
@@ -27677,7 +27789,7 @@ begin
if (Node = nil) or (Node = FRoot) then if (Node = nil) or (Node = FRoot) then
Invalidate Invalidate
else else
if (vsInitialized in Node.States) and (vsVisible in Node.States) then if (vsInitialized in Node.States) and IsEffectivelyVisible(Node) then
begin begin
R := GetDisplayRect(Node, -1, False); R := GetDisplayRect(Node, -1, False);
if R.Top < ClientHeight then if R.Top < ClientHeight then
@@ -27757,6 +27869,27 @@ end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
function TBaseVirtualTree.IsEffectivelyHidden(Node: PVirtualNode): Boolean;
// Checks if a node will effectively be hidden as this depends on the nodes state and the paint options.
begin
if Assigned(Node) then
Result := (vsHidden in Node.States) and not (toShowHiddenNodes in FOptions.FPaintOptions)
else
Result := False;
end;
//----------------------------------------------------------------------------------------------------------------------
function TBaseVirtualTree.IsEffectivelyVisible(Node: PVirtualNode): Boolean;
begin
Result := (vsVisible in Node.States) and not IsEffectivelyHidden(Node);
end;
//----------------------------------------------------------------------------------------------------------------------
function TBaseVirtualTree.IsMouseSelecting: Boolean; function TBaseVirtualTree.IsMouseSelecting: Boolean;
begin begin
@@ -29867,7 +30000,7 @@ begin
// Iterate through the child nodes without initializing them. We have to determine the entire height. // Iterate through the child nodes without initializing them. We have to determine the entire height.
Child := Node.FirstChild; Child := Node.FirstChild;
repeat repeat
if vsVisible in Child.States then if IsEffectivelyVisible(Child) then
Inc(HeightDelta, Child.TotalHeight); Inc(HeightDelta, Child.TotalHeight);
Child := Child.NextSibling; Child := Child.NextSibling;
until Child = nil; until Child = nil;

View File

@@ -12,7 +12,7 @@ object AlignForm: TAlignForm
Font.Name = 'Arial' Font.Name = 'Arial'
OnCreate = FormCreate OnCreate = FormCreate
OnDestroy = FormDestroy OnDestroy = FormDestroy
LCLVersion = '0.9.29' LCLVersion = '1.0.8.0'
object Label8: TLabel object Label8: TLabel
Left = 8 Left = 8
Height = 111 Height = 111
@@ -26,9 +26,9 @@ object AlignForm: TAlignForm
end end
object Label1: TLabel object Label1: TLabel
Left = 8 Left = 8
Height = 113 Height = 17
Top = 110 Top = 110
Width = 203 Width = 1213
Caption = 'Note that hints are aligned properly and draw selection takes the alignment into account too. Sort arrows are shown but the tree is not sorted. All I want to demonstrate is how well the layout in the header works.' Caption = 'Note that hints are aligned properly and draw selection takes the alignment into account too. Sort arrows are shown but the tree is not sorted. All I want to demonstrate is how well the layout in the header works.'
ParentColor = False ParentColor = False
ShowAccelChar = False ShowAccelChar = False
@@ -99,6 +99,7 @@ object AlignForm: TAlignForm
Header.Columns = < Header.Columns = <
item item
Alignment = taCenter Alignment = taCenter
Color = clWindow
Hint = 'Text is initially centered and has a left-to-right directionality.' Hint = 'Text is initially centered and has a left-to-right directionality.'
ImageIndex = 20 ImageIndex = 20
Options = [coAllowClick, coDraggable, coEnabled, coResizable, coShowDropMark, coVisible, coAutoSpring] Options = [coAllowClick, coDraggable, coEnabled, coResizable, coShowDropMark, coVisible, coAutoSpring]
@@ -108,6 +109,7 @@ object AlignForm: TAlignForm
Width = 199 Width = 199
end end
item item
Color = clWindow
Hint = 'Text is initially left aligned and has a left-to-right directionality.' Hint = 'Text is initially left aligned and has a left-to-right directionality.'
ImageIndex = 35 ImageIndex = 35
Options = [coAllowClick, coDraggable, coEnabled, coResizable, coShowDropMark, coVisible, coAutoSpring, coWrapCaption] Options = [coAllowClick, coDraggable, coEnabled, coResizable, coShowDropMark, coVisible, coAutoSpring, coWrapCaption]
@@ -118,6 +120,7 @@ object AlignForm: TAlignForm
end end
item item
BiDiMode = bdRightToLeft BiDiMode = bdRightToLeft
Color = clWindow
Hint = 'Text is initially left aligned and has a right-to-left directionality.' Hint = 'Text is initially left aligned and has a right-to-left directionality.'
ImageIndex = 32 ImageIndex = 32
Options = [coAllowClick, coDraggable, coEnabled, coResizable, coShowDropMark, coVisible, coAutoSpring] Options = [coAllowClick, coDraggable, coEnabled, coResizable, coShowDropMark, coVisible, coAutoSpring]
@@ -148,6 +151,7 @@ object AlignForm: TAlignForm
TreeOptions.MiscOptions = [toEditable, toFullRepaintOnResize, toInitOnSave, toToggleOnDblClick, toWheelPanning] TreeOptions.MiscOptions = [toEditable, toFullRepaintOnResize, toInitOnSave, toToggleOnDblClick, toWheelPanning]
TreeOptions.PaintOptions = [toHideFocusRect, toShowButtons, toShowDropmark, toShowRoot, toShowTreeLines, toThemeAware] TreeOptions.PaintOptions = [toHideFocusRect, toShowButtons, toShowDropmark, toShowRoot, toShowTreeLines, toThemeAware]
TreeOptions.SelectionOptions = [toExtendedFocus, toMultiSelect] TreeOptions.SelectionOptions = [toExtendedFocus, toMultiSelect]
OnCompareNodes = AlignTreeCompareNodes
OnFocusChanged = AlignTreeFocusChanged OnFocusChanged = AlignTreeFocusChanged
OnGetText = AlignTreeGetText OnGetText = AlignTreeGetText
OnPaintText = AlignTreePaintText OnPaintText = AlignTreePaintText

View File

@@ -14,6 +14,9 @@ uses
StdCtrls, ComCtrls, VirtualTrees, ExtCtrls, Menus, LResources; StdCtrls, ComCtrls, VirtualTrees, ExtCtrls, Menus, LResources;
type type
{ TAlignForm }
TAlignForm = class(TForm) TAlignForm = class(TForm)
AlignTree: TVirtualStringTree; AlignTree: TVirtualStringTree;
Label8: TLabel; Label8: TLabel;
@@ -38,10 +41,13 @@ type
EnabledOptionBox: TCheckBox; EnabledOptionBox: TCheckBox;
Label5: TLabel; Label5: TLabel;
LayoutCombo: TComboBox; LayoutCombo: TComboBox;
procedure AlignTreeCompareNodes(Sender: TBaseVirtualTree; Node1,
Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer);
procedure AlignTreeGetImageIndex(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex; procedure AlignTreeGetImageIndex(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
var Ghosted: Boolean; var Index: Integer); var Ghosted: Boolean; var Index: Integer);
procedure AlignTreeGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; procedure AlignTreeGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
var CellText: String); var CellText: String);
procedure AlignTreeHeaderClick(Sender: TVTHeader; HitInfo: TVTHeaderHitInfo);
procedure AlignTreePaintText(Sender: TBaseVirtualTree; const Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; procedure AlignTreePaintText(Sender: TBaseVirtualTree; const Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
TextType: TVSTTextType); TextType: TVSTTextType);
procedure AlignTreeGetNodeDataSize(Sender: TBaseVirtualTree; var NodeDataSize: Integer); procedure AlignTreeGetNodeDataSize(Sender: TBaseVirtualTree; var NodeDataSize: Integer);
@@ -53,7 +59,7 @@ type
procedure IconPopupPopup(Sender: TObject); procedure IconPopupPopup(Sender: TObject);
procedure AlignComboChange(Sender: TObject); procedure AlignComboChange(Sender: TObject);
procedure BidiGroupClick(Sender: TObject); procedure BidiGroupClick(Sender: TObject);
procedure AlignTreeHeaderClick(Sender: TVTHeader; Column: TColumnIndex; Button: TMouseButton; Shift: TShiftState; X, procedure AlignTreeHeaderClickx(Sender: TVTHeader; Column: TColumnIndex; Button: TMouseButton; Shift: TShiftState; X,
Y: Integer); Y: Integer);
procedure OptionBoxClick(Sender: TObject); procedure OptionBoxClick(Sender: TObject);
procedure LayoutComboChange(Sender: TObject); procedure LayoutComboChange(Sender: TObject);
@@ -179,6 +185,31 @@ begin
end; end;
end; end;
procedure TAlignForm.AlignTreeHeaderClick(Sender: TVTHeader;
HitInfo: TVTHeaderHitInfo);
begin
with HitInfo do
if Button = mbLeft then
begin
with Sender do
begin
if SortColumn <> Column then
begin
SortColumn := Column;
SortDirection := sdAscending;
end
else
case SortDirection of
sdAscending:
SortDirection := sdDescending;
sdDescending:
SortColumn := NoColumn;
end;
AlignTree.SortTree(SortColumn, SortDirection, False);
end;
end;
end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
procedure TAlignForm.AlignTreeGetImageIndex(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind; procedure TAlignForm.AlignTreeGetImageIndex(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind;
@@ -195,6 +226,23 @@ begin
end; end;
end; end;
procedure TAlignForm.AlignTreeCompareNodes(Sender: TBaseVirtualTree; Node1,
Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer);
var
Data1, Data2: PAlignData;
begin
Data1 := Sender.GetNodeData(Node1);
Data2 := Sender.GetNodeData(Node2);
case Column of
0: // left alignd column
Result := CompareText(Data1.MainColumnText, Data2.MainColumnText);
1: // centered column
Result := CompareText(Data1.GreekText, Data2.GreekText);
2: // right aligned column
Result := CompareText(Data1.RTLText, Data2.RTLText);
end;
end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
procedure TAlignForm.AlignTreeInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode; procedure TAlignForm.AlignTreeInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode;
@@ -476,31 +524,14 @@ end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
procedure TAlignForm.AlignTreeHeaderClick(Sender: TVTHeader; Column: TColumnIndex; Button: TMouseButton; Shift: TShiftState; procedure TAlignForm.AlignTreeHeaderClickx(Sender: TVTHeader; Column: TColumnIndex; Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); X, Y: Integer);
// This method sets sort column and direction on a header click. // This method sets sort column and direction on a header click.
// Note: this is only to show the header layout. There gets nothing really sorted. // Note: this is only to show the header layout. There gets nothing really sorted.
begin begin
if Button = mbLeft then
begin
with Sender do
begin
if SortColumn <> Column then
begin
SortColumn := Column;
SortDirection := sdAscending;
end
else
case SortDirection of
sdAscending:
SortDirection := sdDescending;
sdDescending:
SortColumn := NoColumn;
end;
end;
end;
end; end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------

View File

@@ -10,7 +10,7 @@ object DrawTreeForm: TDrawTreeForm
Font.Height = -13 Font.Height = -13
Font.Name = 'Trebuchet MS' Font.Name = 'Trebuchet MS'
OnCreate = FormCreate OnCreate = FormCreate
LCLVersion = '0.9.29' LCLVersion = '1.0.8.0'
object Label7: TLabel object Label7: TLabel
Left = 0 Left = 0
Height = 61 Height = 61

View File

@@ -24,6 +24,9 @@ uses
VirtualTrees, StdCtrls, shlobjext, LResources, FileUtil; VirtualTrees, StdCtrls, shlobjext, LResources, FileUtil;
type type
{ TDrawTreeForm }
TDrawTreeForm = class(TForm) TDrawTreeForm = class(TForm)
VDT1: TVirtualDrawTree; VDT1: TVirtualDrawTree;
Label7: TLabel; Label7: TLabel;
@@ -42,8 +45,7 @@ type
var Ghosted: Boolean; var Index: Integer); var Ghosted: Boolean; var Index: Integer);
procedure VDT1GetNodeWidth(Sender: TBaseVirtualTree; Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; procedure VDT1GetNodeWidth(Sender: TBaseVirtualTree; Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
var NodeWidth: Integer); var NodeWidth: Integer);
procedure VDT1HeaderClick(Sender: TVTHeader; Column: TColumnIndex; Button: TMouseButton; Shift: TShiftState; X, procedure VDT1HeaderClick(Sender: TVTHeader; HitInfo: TVTHeaderHitInfo);
Y: Integer);
procedure VDT1InitChildren(Sender: TBaseVirtualTree; Node: PVirtualNode; var ChildCount: Cardinal); procedure VDT1InitChildren(Sender: TBaseVirtualTree; Node: PVirtualNode; var ChildCount: Cardinal);
procedure VDT1InitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode; procedure VDT1InitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode;
var InitialStates: TVirtualNodeInitStates); var InitialStates: TVirtualNodeInitStates);
@@ -514,6 +516,34 @@ begin
end; end;
end; end;
procedure TDrawTreeForm.VDT1HeaderClick(Sender: TVTHeader;
HitInfo: TVTHeaderHitInfo);
begin
with HitInfo do
if Button = mbLeft then
begin
with Sender do
begin
if Column <> MainColumn then
SortColumn := NoColumn
else
begin
if SortColumn = NoColumn then
begin
SortColumn := Column;
SortDirection := sdAscending;
end
else
if SortDirection = sdAscending then
SortDirection := sdDescending
else
SortDirection := sdAscending;
Treeview.SortTree(SortColumn, SortDirection, False);
end;
end;
end;
end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
procedure TDrawTreeForm.VDT1InitChildren(Sender: TBaseVirtualTree; Node: PVirtualNode; var ChildCount: Cardinal); procedure TDrawTreeForm.VDT1InitChildren(Sender: TBaseVirtualTree; Node: PVirtualNode; var ChildCount: Cardinal);
@@ -674,37 +704,6 @@ end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
procedure TDrawTreeForm.VDT1HeaderClick(Sender: TVTHeader; Column: TColumnIndex; Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
// Click handler to switch the column on which will be sorted. Since we cannot sort image data sorting is actually
// limited to the main column.
begin
if Button = mbLeft then
begin
with Sender do
begin
if Column <> MainColumn then
SortColumn := NoColumn
else
begin
if SortColumn = NoColumn then
begin
SortColumn := Column;
SortDirection := sdAscending;
end
else
if SortDirection = sdAscending then
SortDirection := sdDescending
else
SortDirection := sdAscending;
Treeview.SortTree(SortColumn, SortDirection, False);
end;
end;
end;
end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
procedure TDrawTreeForm.TrackBar1Change(Sender: TObject); procedure TDrawTreeForm.TrackBar1Change(Sender: TObject);

View File

@@ -11,22 +11,22 @@ object WindowsXPForm: TWindowsXPForm
Font.Height = -13 Font.Height = -13
Font.Name = 'Microsoft Sans Serif' Font.Name = 'Microsoft Sans Serif'
OnCreate = FormCreate OnCreate = FormCreate
LCLVersion = '0.9.29' LCLVersion = '1.0.8.0'
object Label1: TLabel object Label1: TLabel
Left = 564 Left = -449
Height = 81 Height = 17
Top = 40 Top = 40
Width = 273 Width = 1286
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
Caption = 'This demo shows a tree with properties which make it look as in the new Windows XP style. Under Windows XP native theme APIs are used to paint the tree. On other system legacy code is used which simulates the look.' Caption = 'This demo shows a tree with properties which make it look as in the new Windows XP style. Under Windows XP native theme APIs are used to paint the tree. On other system legacy code is used which simulates the look.'
ParentColor = False ParentColor = False
WordWrap = True WordWrap = True
end end
object Label2: TLabel object Label2: TLabel
Left = 565 Left = -291
Height = 81 Height = 17
Top = 168 Top = 168
Width = 272 Width = 1128
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
Caption = 'Note that the scrollbars are not drawn in the new style on non-XP systems. It would be far off the goal of the tree to reimplement a full blown scrollbar handling, which would be required otherwise.' Caption = 'Note that the scrollbars are not drawn in the new style on non-XP systems. It would be far off the goal of the tree to reimplement a full blown scrollbar handling, which would be required otherwise.'
ParentColor = False ParentColor = False
@@ -34,10 +34,10 @@ object WindowsXPForm: TWindowsXPForm
end end
object Label4: TLabel object Label4: TLabel
Cursor = crHandPoint Cursor = crHandPoint
Left = 565 Left = -617
Height = 97 Height = 17
Top = 290 Top = 290
Width = 272 Width = 1454
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
Caption = 'If you want to have an explorer treeview with real content then I recommend that you give Jim Kuenemann''s shell tools a try. His shell treeview (based on Virtual Treeview) is the most advanced you will find worldwide. Click here to open Yahoo Group.' Caption = 'If you want to have an explorer treeview with real content then I recommend that you give Jim Kuenemann''s shell tools a try. His shell treeview (based on Virtual Treeview) is the most advanced you will find worldwide. Click here to open Yahoo Group.'
Font.CharSet = ANSI_CHARSET Font.CharSet = ANSI_CHARSET
@@ -169,12 +169,12 @@ object WindowsXPForm: TWindowsXPForm
object ToolButton15: TToolButton object ToolButton15: TToolButton
Left = 241 Left = 241
Top = 2 Top = 2
Width = 8 Width = 10
Caption = 'ToolButton15' Caption = 'ToolButton15'
Style = tbsSeparator Style = tbsSeparator
end end
object ToolButton16: TToolButton object ToolButton16: TToolButton
Left = 249 Left = 251
Top = 2 Top = 2
Caption = 'Click here to print the treeview.' Caption = 'Click here to print the treeview.'
ImageIndex = 24 ImageIndex = 24

View File

@@ -37,12 +37,13 @@ type
procedure XPTreeGetImageIndex(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind; procedure XPTreeGetImageIndex(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind;
Column: TColumnIndex; var Ghosted: Boolean; var Index: Integer); Column: TColumnIndex; var Ghosted: Boolean; var Index: Integer);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure XPTreeHeaderClick(Sender: TVTHeader; HitInfo: TVTHeaderHitInfo);
procedure XPTreeInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode; procedure XPTreeInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode;
var InitialStates: TVirtualNodeInitStates); var InitialStates: TVirtualNodeInitStates);
procedure XPTreeInitChildren(Sender: TBaseVirtualTree; Node: PVirtualNode; var ChildCount: Cardinal); procedure XPTreeInitChildren(Sender: TBaseVirtualTree; Node: PVirtualNode; var ChildCount: Cardinal);
procedure XPTreeGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; procedure XPTreeGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex;
TextType: TVSTTextType; var CellText: String); TextType: TVSTTextType; var CellText: String);
procedure XPTreeHeaderClick(Sender: TVTHeader; Column: TColumnIndex; Button: TMouseButton; Shift: TShiftState; procedure XPTreeHeaderClickx(Sender: TVTHeader; Column: TColumnIndex; Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); X, Y: Integer);
procedure XPTreeCompareNodes(Sender: TBaseVirtualTree; Node1, Node2: PVirtualNode; Column: TColumnIndex; procedure XPTreeCompareNodes(Sender: TBaseVirtualTree; Node1, Node2: PVirtualNode; Column: TColumnIndex;
var Result: Integer); var Result: Integer);
@@ -129,6 +130,40 @@ begin
{$endif} {$endif}
end; end;
procedure TWindowsXPForm.XPTreeHeaderClick(Sender: TVTHeader;
HitInfo: TVTHeaderHitInfo);
begin
with HitInfo do
if Button = mbLeft then
begin
with Sender, Treeview do
begin
if SortColumn > NoColumn then
Columns[SortColumn].Options := Columns[SortColumn].Options + [coParentColor];
// Do not sort the last column, it contains nothing to sort.
if Column = 2 then
SortColumn := NoColumn
else
begin
if (SortColumn = NoColumn) or (SortColumn <> Column) then
begin
SortColumn := Column;
SortDirection := sdAscending;
end
else
if SortDirection = sdAscending then
SortDirection := sdDescending
else
SortDirection := sdAscending;
Columns[SortColumn].Color := $F7F7F7;
SortTree(SortColumn, SortDirection, False);
end;
end;
end;
end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
procedure TWindowsXPForm.XPTreeInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode; procedure TWindowsXPForm.XPTreeInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode;
@@ -186,38 +221,11 @@ end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
procedure TWindowsXPForm.XPTreeHeaderClick(Sender: TVTHeader; Column: TColumnIndex; Button: TMouseButton; procedure TWindowsXPForm.XPTreeHeaderClickx(Sender: TVTHeader;
Shift: TShiftState; X, Y: Integer); Column: TColumnIndex; Button: TMouseButton; Shift: TShiftState; X, Y: Integer
);
begin begin
if Button = mbLeft then
begin
with Sender, Treeview do
begin
if SortColumn > NoColumn then
Columns[SortColumn].Options := Columns[SortColumn].Options + [coParentColor];
// Do not sort the last column, it contains nothing to sort.
if Column = 2 then
SortColumn := NoColumn
else
begin
if (SortColumn = NoColumn) or (SortColumn <> Column) then
begin
SortColumn := Column;
SortDirection := sdAscending;
end
else
if SortDirection = sdAscending then
SortDirection := sdDescending
else
SortDirection := sdAscending;
Columns[SortColumn].Color := $F7F7F7;
SortTree(SortColumn, SortDirection, False);
end;
end;
end;
end; end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------

View File

@@ -12,30 +12,30 @@ object Form1: TForm1
OnClose = FormClose OnClose = FormClose
OnCreate = FormCreate OnCreate = FormCreate
Position = poScreenCenter Position = poScreenCenter
LCLVersion = '0.9.29' LCLVersion = '1.0.8.0'
object Label1: TLabel object Label1: TLabel
Left = 224 Left = 246
Height = 14 Height = 14
Top = 348 Top = 348
Width = 174 Width = 152
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
Caption = 'Array data of the clicked node:' Caption = 'Array data of the clicked node:'
ParentColor = False ParentColor = False
end end
object Label2: TLabel object Label2: TLabel
Left = 224 Left = 258
Height = 14 Height = 14
Top = 382 Top = 382
Width = 256 Width = 222
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
Caption = 'Find and show the node by specific array index' Caption = 'Find and show the node by specific array index'
ParentColor = False ParentColor = False
end end
object Label3: TLabel object Label3: TLabel
Left = 224 Left = 261
Height = 14 Height = 14
Top = 398 Top = 398
Width = 274 Width = 237
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
Caption = 'Type index to get related tree node on the screen:' Caption = 'Type index to get related tree node on the screen:'
ParentColor = False ParentColor = False
@@ -66,8 +66,8 @@ object Form1: TForm1
AnchorSideLeft.Control = Label1 AnchorSideLeft.Control = Label1
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
Left = 402 Left = 402
Height = 23 Height = 21
Top = 344 Top = 346
Width = 170 Width = 170
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
BorderSpacing.Left = 4 BorderSpacing.Left = 4
@@ -89,8 +89,8 @@ object Form1: TForm1
AnchorSideLeft.Control = Label3 AnchorSideLeft.Control = Label3
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
Left = 502 Left = 502
Height = 23 Height = 21
Top = 394 Top = 396
Width = 97 Width = 97
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
BorderSpacing.Left = 4 BorderSpacing.Left = 4

View File

@@ -115,8 +115,7 @@ type
procedure Button1Click(Sender: TObject); procedure Button1Click(Sender: TObject);
procedure MyTreeCompareNodes(Sender: TBaseVirtualTree; Node1, procedure MyTreeCompareNodes(Sender: TBaseVirtualTree; Node1,
Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer); Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer);
procedure MyTreeHeaderClick(Sender: TVTHeader; Column: TColumnIndex; procedure MyTreeHeaderClick(Sender: TVTHeader; HitInfo: TVTHeaderHitInfo);
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure btnDeleteClick(Sender: TObject); procedure btnDeleteClick(Sender: TObject);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure MyTreePaintText(Sender: TBaseVirtualTree; procedure MyTreePaintText(Sender: TBaseVirtualTree;
@@ -240,8 +239,7 @@ begin
end end
end; end;
procedure TForm1.MyTreeHeaderClick(Sender: TVTHeader; Column: TColumnIndex; procedure TForm1.MyTreeHeaderClick(Sender: TVTHeader; HitInfo: TVTHeaderHitInfo);
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var var
Direction : TSortDirection; Direction : TSortDirection;
begin begin
@@ -251,7 +249,8 @@ begin
// MyTree.Header.SortDirection and MyTree.Header.SortColumn // MyTree.Header.SortDirection and MyTree.Header.SortColumn
// to get automatically Descending/Ascending sorting // to get automatically Descending/Ascending sorting
// by only clicking on header // by only clicking on header
with HitInfo do
begin
if ssShift in Shift if ssShift in Shift
then then
Direction := sdDescending Direction := sdDescending
@@ -269,9 +268,11 @@ begin
// Sorting process // Sorting process
MyTree.SortTree(Column, Direction); MyTree.SortTree(Column, Direction);
end end;
end;
end; end;
procedure TForm1.btnDeleteClick(Sender: TObject); procedure TForm1.btnDeleteClick(Sender: TObject);
var var
Timer: cardinal; Timer: cardinal;

View File

@@ -10,7 +10,7 @@ object Form1: TForm1
Font.Height = -11 Font.Height = -11
Font.Name = 'MS Sans Serif' Font.Name = 'MS Sans Serif'
OnCreate = FormCreate OnCreate = FormCreate
LCLVersion = '0.9.29' LCLVersion = '1.0.8.0'
object VST1: TVirtualStringTree object VST1: TVirtualStringTree
Cursor = 63 Cursor = 63
Left = 0 Left = 0

View File

@@ -41,6 +41,7 @@ type
procedure VST1BeforeCellPaint(Sender: TBaseVirtualTree; procedure VST1BeforeCellPaint(Sender: TBaseVirtualTree;
TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
CellPaintMode: TVTCellPaintMode; CellRect: TRect; var ContentRect: TRect); CellPaintMode: TVTCellPaintMode; CellRect: TRect; var ContentRect: TRect);
procedure VST1HeaderClick(Sender: TVTHeader; HitInfo: TVTHeaderHitInfo);
procedure VST1InitNode(Sender: TBaseVirtualTree; ParentNode, procedure VST1InitNode(Sender: TBaseVirtualTree; ParentNode,
Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates); Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates);
procedure VST1GetText(Sender: TBaseVirtualTree; Node: PVirtualNode; procedure VST1GetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
@@ -51,8 +52,6 @@ type
var Ghosted: Boolean; var ImageIndex: Integer); var Ghosted: Boolean; var ImageIndex: Integer);
procedure VST1Checking(Sender: TBaseVirtualTree; Node: PVirtualNode; procedure VST1Checking(Sender: TBaseVirtualTree; Node: PVirtualNode;
var NewState: TCheckState; var Allowed: Boolean); var NewState: TCheckState; var Allowed: Boolean);
procedure VST1HeaderClick(Sender: TVTHeader; Column: TColumnIndex;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure VST1CompareNodes(Sender: TBaseVirtualTree; Node1, procedure VST1CompareNodes(Sender: TBaseVirtualTree; Node1,
Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer); Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer);
private private
@@ -151,6 +150,26 @@ begin
end; end;
end; end;
procedure TForm1.VST1HeaderClick(Sender: TVTHeader; HitInfo: TVTHeaderHitInfo);
begin
// Determinate sorting direction
if HitInfo.Button=mbLeft then
with Sender do
begin
if SortColumn <> HitInfo.Column then
SortColumn := HitInfo.Column
else begin
if SortDirection = sdAscending then
SortDirection := sdDescending
else
SortDirection := sdAscending
end;
// Initiate sorting
VST1.SortTree(HitInfo.Column, Sender.SortDirection, False);
end;
end;
procedure TForm1.VST1InitNode(Sender: TBaseVirtualTree; ParentNode, procedure TForm1.VST1InitNode(Sender: TBaseVirtualTree; ParentNode,
Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates); Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates);
var var
@@ -261,28 +280,6 @@ begin
Allowed:=true Allowed:=true
end; end;
procedure TForm1.VST1HeaderClick(Sender: TVTHeader; Column: TColumnIndex;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
// Determinate sorting direction
if Button=mbLeft then
with Sender do
begin
if SortColumn <> Column then
SortColumn := Column
else begin
if SortDirection = sdAscending then
SortDirection := sdDescending
else
SortDirection := sdAscending
end;
// Initiate sorting
VST1.SortTree(Column, Sender.SortDirection, False);
end;
end;
procedure TForm1.VST1CompareNodes(Sender: TBaseVirtualTree; Node1, procedure TForm1.VST1CompareNodes(Sender: TBaseVirtualTree; Node1,
Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer); Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer);
var var

View File

@@ -1,20 +1,21 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<CONFIG> <CONFIG>
<ProjectOptions> <ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/> <PathDelim Value="\"/>
<Version Value="7"/>
<General> <General>
<Flags> <Flags>
<AlwaysBuild Value="False"/>
<LRSInOutputDirectory Value="False"/> <LRSInOutputDirectory Value="False"/>
</Flags> </Flags>
<SessionStorage Value="InProjectDir"/> <SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/> <MainUnit Value="0"/>
<TargetFileExt Value=".exe"/>
</General> </General>
<VersionInfo> <VersionInfo>
<ProjectVersion Value=""/> <StringTable ProductVersion=""/>
</VersionInfo> </VersionInfo>
<BuildModes Count="1">
<Item1 Name="default" Default="True"/>
</BuildModes>
<PublishOptions> <PublishOptions>
<Version Value="2"/> <Version Value="2"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/> <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
@@ -51,8 +52,13 @@
</Units> </Units>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>
<Version Value="8"/> <Version Value="11"/>
<PathDelim Value="\"/> <PathDelim Value="\"/>
<Parsing>
<SyntaxOptions>
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
<Linking> <Linking>
<Options> <Options>
<Win32> <Win32>

View File

@@ -13,7 +13,7 @@ object frmVTDBExample: TfrmVTDBExample
OnClose = FormClose OnClose = FormClose
OnCreate = FormCreate OnCreate = FormCreate
Position = poDefaultPosOnly Position = poDefaultPosOnly
LCLVersion = '0.9.27' LCLVersion = '1.0.8.0'
object Label1: TLabel object Label1: TLabel
Left = 12 Left = 12
Height = 14 Height = 14
@@ -23,7 +23,9 @@ object frmVTDBExample: TfrmVTDBExample
ParentColor = False ParentColor = False
end end
object Panel1: TPanel object Panel1: TPanel
Left = 0
Height = 482 Height = 482
Top = 0
Width = 553 Width = 553
Align = alClient Align = alClient
BevelOuter = bvNone BevelOuter = bvNone
@@ -45,8 +47,10 @@ object frmVTDBExample: TfrmVTDBExample
DefaultText = 'Node' DefaultText = 'Node'
Font.Height = -11 Font.Height = -11
Font.Name = 'Tahoma' Font.Name = 'Tahoma'
Header.AutoSizeIndex = 0
Header.Columns = < Header.Columns = <
item item
Color = clWindow
ImageIndex = 3 ImageIndex = 3
Layout = blGlyphRight Layout = blGlyphRight
Options = [coAllowClick, coDraggable, coEnabled, coParentBidiMode, coResizable, coShowDropMark, coVisible, coAllowFocus] Options = [coAllowClick, coDraggable, coEnabled, coParentBidiMode, coResizable, coShowDropMark, coVisible, coAllowFocus]
@@ -61,9 +65,11 @@ object frmVTDBExample: TfrmVTDBExample
end end
item item
Alignment = taCenter Alignment = taCenter
Position = 0
Text = 'Status' Text = 'Status'
Width = 42 Width = 42
end> end>
Header.DefaultHeight = 17
Header.Font.Height = -11 Header.Font.Height = -11
Header.Font.Name = 'MS Sans Serif' Header.Font.Name = 'MS Sans Serif'
Header.Images = imgMaster Header.Images = imgMaster
@@ -201,7 +207,7 @@ object frmVTDBExample: TfrmVTDBExample
end end
object chkShowIDs: TCheckBox object chkShowIDs: TCheckBox
Left = 244 Left = 244
Height = 17 Height = 19
Top = 35 Top = 35
Width = 60 Width = 60
Caption = 'Show ID' Caption = 'Show ID'
@@ -220,7 +226,7 @@ object frmVTDBExample: TfrmVTDBExample
end end
object chkAllVisible: TCheckBox object chkAllVisible: TCheckBox
Left = 429 Left = 429
Height = 17 Height = 19
Top = 35 Top = 35
Width = 63 Width = 63
Caption = 'All Visible' Caption = 'All Visible'
@@ -229,7 +235,7 @@ object frmVTDBExample: TfrmVTDBExample
end end
object chkDynHt: TCheckBox object chkDynHt: TCheckBox
Left = 324 Left = 324
Height = 17 Height = 19
Top = 35 Top = 35
Width = 94 Width = 94
Caption = 'Dynamic Height' Caption = 'Dynamic Height'

View File

@@ -57,6 +57,7 @@ interface
procedure VTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; procedure VTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
var Text: String); var Text: String);
procedure VTFreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode); procedure VTFreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode);
procedure VTHeaderClick(Sender: TVTHeader; HitInfo: TVTHeaderHitInfo);
procedure VTInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode; procedure VTInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode;
var InitialStates: TVirtualNodeInitStates); var InitialStates: TVirtualNodeInitStates);
procedure FormActivate(Sender: TObject); procedure FormActivate(Sender: TObject);
@@ -67,8 +68,6 @@ interface
procedure VTPaintText(Sender: TBaseVirtualTree; procedure VTPaintText(Sender: TBaseVirtualTree;
const TargetCanvas: TCanvas; Node: PVirtualNode; const TargetCanvas: TCanvas; Node: PVirtualNode;
Column: TColumnIndex; TextType: TVSTTextType); Column: TColumnIndex; TextType: TVSTTextType);
procedure VTHeaderClick(Sender: TVTHeader; Column: TColumnIndex;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure VTCompareNodes(Sender: TBaseVirtualTree; Node1, procedure VTCompareNodes(Sender: TBaseVirtualTree; Node1,
Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer); Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer);
procedure VTGetNodeDataSize(Sender: TBaseVirtualTree; var NodeDataSize: Integer); procedure VTGetNodeDataSize(Sender: TBaseVirtualTree; var NodeDataSize: Integer);
@@ -214,6 +213,22 @@ implementation
Finalize( Data^ ); Finalize( Data^ );
end; end;
procedure TfrmVTDBExample.VTHeaderClick(Sender: TVTHeader;
HitInfo: TVTHeaderHitInfo);
begin
with HitInfo do
begin
if (VT.Header.SortColumn <> Column) then
VT.Header.SortColumn := Column
else if (VT.Header.SortDirection = sdAscending) then
VT.Header.SortDirection := sdDescending
else
VT.Header.SortDirection := sdAscending;
VT.SortTree( Column, VT.Header.SortDirection );
end;
end;
procedure TfrmVTDBExample.VTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; procedure TfrmVTDBExample.VTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
Column: TColumnIndex; TextType: TVSTTextType; var Text: String); Column: TColumnIndex; TextType: TVSTTextType; var Text: String);
var var
@@ -342,19 +357,6 @@ implementation
VT.Refresh; VT.Refresh;
end; end;
procedure TfrmVTDBExample.VTHeaderClick(Sender: TVTHeader; Column: TColumnIndex;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if (VT.Header.SortColumn <> Column) then
VT.Header.SortColumn := Column
else if (VT.Header.SortDirection = sdAscending) then
VT.Header.SortDirection := sdDescending
else
VT.Header.SortDirection := sdAscending;
VT.SortTree( Column, VT.Header.SortDirection );
end;
procedure TfrmVTDBExample.VTCompareNodes(Sender: TBaseVirtualTree; Node1, procedure TfrmVTDBExample.VTCompareNodes(Sender: TBaseVirtualTree; Node1,
Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer); Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer);
var var

View File

@@ -14,7 +14,7 @@ object frmVTNoData: TfrmVTNoData
OnCreate = FormCreate OnCreate = FormCreate
OnDestroy = FormDestroy OnDestroy = FormDestroy
Position = poDefaultPosOnly Position = poDefaultPosOnly
LCLVersion = '0.9.29' LCLVersion = '1.0.8.0'
object Panel1: TPanel object Panel1: TPanel
Left = 0 Left = 0
Height = 346 Height = 346
@@ -67,7 +67,7 @@ object frmVTNoData: TfrmVTNoData
Left = 9 Left = 9
Height = 14 Height = 14
Top = 9 Top = 9
Width = 82 Width = 76
Alignment = taCenter Alignment = taCenter
Caption = 'VT.TreeOptions' Caption = 'VT.TreeOptions'
Font.Color = clRed Font.Color = clRed
@@ -78,27 +78,27 @@ object frmVTNoData: TfrmVTNoData
end end
object chkCheckBoxes: TCheckBox object chkCheckBoxes: TCheckBox
Left = 180 Left = 180
Height = 22 Height = 19
Top = 7 Top = 7
Width = 93 Width = 81
Caption = 'Check Boxes' Caption = 'Check Boxes'
OnClick = chkCheckBoxesClick OnClick = chkCheckBoxesClick
TabOrder = 0 TabOrder = 0
end end
object chkFullExpand: TCheckBox object chkFullExpand: TCheckBox
Left = 100 Left = 100
Height = 22 Height = 19
Top = 7 Top = 7
Width = 86 Width = 75
Caption = 'Full Expand' Caption = 'Full Expand'
OnClick = chkFullExpandClick OnClick = chkFullExpandClick
TabOrder = 1 TabOrder = 1
end end
object chkShowLevel: TCheckBox object chkShowLevel: TCheckBox
Left = 271 Left = 271
Height = 22 Height = 19
Top = 7 Top = 7
Width = 86 Width = 74
Caption = 'Show Level' Caption = 'Show Level'
OnClick = chkShowLevelClick OnClick = chkShowLevelClick
TabOrder = 2 TabOrder = 2

View File

@@ -194,7 +194,9 @@ implementation
'StaticBackground', 'StaticBackground',
'ChildrenAbove', 'ChildrenAbove',
'FixedIndent', 'FixedIndent',
'UseExplorerTheme' 'UseExplorerTheme',
'HideTreeLinesIfThemed',
'ShowHiddenNodes'
); );
aSelOpts : array[0..Ord(High(TVTSelectionOption))] of string[25] = aSelOpts : array[0..Ord(High(TVTSelectionOption))] of string[25] =