You've already forked lazarus-ccr
* 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:
File diff suppressed because it is too large
Load Diff
@ -12,7 +12,7 @@ object AlignForm: TAlignForm
|
||||
Font.Name = 'Arial'
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
LCLVersion = '0.9.29'
|
||||
LCLVersion = '1.0.8.0'
|
||||
object Label8: TLabel
|
||||
Left = 8
|
||||
Height = 111
|
||||
@ -26,9 +26,9 @@ object AlignForm: TAlignForm
|
||||
end
|
||||
object Label1: TLabel
|
||||
Left = 8
|
||||
Height = 113
|
||||
Height = 17
|
||||
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.'
|
||||
ParentColor = False
|
||||
ShowAccelChar = False
|
||||
@ -99,6 +99,7 @@ object AlignForm: TAlignForm
|
||||
Header.Columns = <
|
||||
item
|
||||
Alignment = taCenter
|
||||
Color = clWindow
|
||||
Hint = 'Text is initially centered and has a left-to-right directionality.'
|
||||
ImageIndex = 20
|
||||
Options = [coAllowClick, coDraggable, coEnabled, coResizable, coShowDropMark, coVisible, coAutoSpring]
|
||||
@ -108,6 +109,7 @@ object AlignForm: TAlignForm
|
||||
Width = 199
|
||||
end
|
||||
item
|
||||
Color = clWindow
|
||||
Hint = 'Text is initially left aligned and has a left-to-right directionality.'
|
||||
ImageIndex = 35
|
||||
Options = [coAllowClick, coDraggable, coEnabled, coResizable, coShowDropMark, coVisible, coAutoSpring, coWrapCaption]
|
||||
@ -118,6 +120,7 @@ object AlignForm: TAlignForm
|
||||
end
|
||||
item
|
||||
BiDiMode = bdRightToLeft
|
||||
Color = clWindow
|
||||
Hint = 'Text is initially left aligned and has a right-to-left directionality.'
|
||||
ImageIndex = 32
|
||||
Options = [coAllowClick, coDraggable, coEnabled, coResizable, coShowDropMark, coVisible, coAutoSpring]
|
||||
@ -148,6 +151,7 @@ object AlignForm: TAlignForm
|
||||
TreeOptions.MiscOptions = [toEditable, toFullRepaintOnResize, toInitOnSave, toToggleOnDblClick, toWheelPanning]
|
||||
TreeOptions.PaintOptions = [toHideFocusRect, toShowButtons, toShowDropmark, toShowRoot, toShowTreeLines, toThemeAware]
|
||||
TreeOptions.SelectionOptions = [toExtendedFocus, toMultiSelect]
|
||||
OnCompareNodes = AlignTreeCompareNodes
|
||||
OnFocusChanged = AlignTreeFocusChanged
|
||||
OnGetText = AlignTreeGetText
|
||||
OnPaintText = AlignTreePaintText
|
||||
|
@ -14,6 +14,9 @@ uses
|
||||
StdCtrls, ComCtrls, VirtualTrees, ExtCtrls, Menus, LResources;
|
||||
|
||||
type
|
||||
|
||||
{ TAlignForm }
|
||||
|
||||
TAlignForm = class(TForm)
|
||||
AlignTree: TVirtualStringTree;
|
||||
Label8: TLabel;
|
||||
@ -38,10 +41,13 @@ type
|
||||
EnabledOptionBox: TCheckBox;
|
||||
Label5: TLabel;
|
||||
LayoutCombo: TComboBox;
|
||||
procedure AlignTreeCompareNodes(Sender: TBaseVirtualTree; Node1,
|
||||
Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer);
|
||||
procedure AlignTreeGetImageIndex(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
|
||||
var Ghosted: Boolean; var Index: Integer);
|
||||
procedure AlignTreeGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
|
||||
var CellText: String);
|
||||
procedure AlignTreeHeaderClick(Sender: TVTHeader; HitInfo: TVTHeaderHitInfo);
|
||||
procedure AlignTreePaintText(Sender: TBaseVirtualTree; const Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
|
||||
TextType: TVSTTextType);
|
||||
procedure AlignTreeGetNodeDataSize(Sender: TBaseVirtualTree; var NodeDataSize: Integer);
|
||||
@ -53,7 +59,7 @@ type
|
||||
procedure IconPopupPopup(Sender: TObject);
|
||||
procedure AlignComboChange(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);
|
||||
procedure OptionBoxClick(Sender: TObject);
|
||||
procedure LayoutComboChange(Sender: TObject);
|
||||
@ -179,6 +185,31 @@ begin
|
||||
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;
|
||||
@ -195,6 +226,23 @@ begin
|
||||
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;
|
||||
@ -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);
|
||||
|
||||
// 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.
|
||||
|
||||
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;
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -10,7 +10,7 @@ object DrawTreeForm: TDrawTreeForm
|
||||
Font.Height = -13
|
||||
Font.Name = 'Trebuchet MS'
|
||||
OnCreate = FormCreate
|
||||
LCLVersion = '0.9.29'
|
||||
LCLVersion = '1.0.8.0'
|
||||
object Label7: TLabel
|
||||
Left = 0
|
||||
Height = 61
|
||||
|
@ -24,6 +24,9 @@ uses
|
||||
VirtualTrees, StdCtrls, shlobjext, LResources, FileUtil;
|
||||
|
||||
type
|
||||
|
||||
{ TDrawTreeForm }
|
||||
|
||||
TDrawTreeForm = class(TForm)
|
||||
VDT1: TVirtualDrawTree;
|
||||
Label7: TLabel;
|
||||
@ -42,8 +45,7 @@ type
|
||||
var Ghosted: Boolean; var Index: Integer);
|
||||
procedure VDT1GetNodeWidth(Sender: TBaseVirtualTree; Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
|
||||
var NodeWidth: Integer);
|
||||
procedure VDT1HeaderClick(Sender: TVTHeader; Column: TColumnIndex; Button: TMouseButton; Shift: TShiftState; X,
|
||||
Y: Integer);
|
||||
procedure VDT1HeaderClick(Sender: TVTHeader; HitInfo: TVTHeaderHitInfo);
|
||||
procedure VDT1InitChildren(Sender: TBaseVirtualTree; Node: PVirtualNode; var ChildCount: Cardinal);
|
||||
procedure VDT1InitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode;
|
||||
var InitialStates: TVirtualNodeInitStates);
|
||||
@ -514,6 +516,34 @@ begin
|
||||
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);
|
||||
@ -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);
|
||||
|
@ -11,22 +11,22 @@ object WindowsXPForm: TWindowsXPForm
|
||||
Font.Height = -13
|
||||
Font.Name = 'Microsoft Sans Serif'
|
||||
OnCreate = FormCreate
|
||||
LCLVersion = '0.9.29'
|
||||
LCLVersion = '1.0.8.0'
|
||||
object Label1: TLabel
|
||||
Left = 564
|
||||
Height = 81
|
||||
Left = -449
|
||||
Height = 17
|
||||
Top = 40
|
||||
Width = 273
|
||||
Width = 1286
|
||||
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.'
|
||||
ParentColor = False
|
||||
WordWrap = True
|
||||
end
|
||||
object Label2: TLabel
|
||||
Left = 565
|
||||
Height = 81
|
||||
Left = -291
|
||||
Height = 17
|
||||
Top = 168
|
||||
Width = 272
|
||||
Width = 1128
|
||||
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.'
|
||||
ParentColor = False
|
||||
@ -34,10 +34,10 @@ object WindowsXPForm: TWindowsXPForm
|
||||
end
|
||||
object Label4: TLabel
|
||||
Cursor = crHandPoint
|
||||
Left = 565
|
||||
Height = 97
|
||||
Left = -617
|
||||
Height = 17
|
||||
Top = 290
|
||||
Width = 272
|
||||
Width = 1454
|
||||
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.'
|
||||
Font.CharSet = ANSI_CHARSET
|
||||
@ -169,12 +169,12 @@ object WindowsXPForm: TWindowsXPForm
|
||||
object ToolButton15: TToolButton
|
||||
Left = 241
|
||||
Top = 2
|
||||
Width = 8
|
||||
Width = 10
|
||||
Caption = 'ToolButton15'
|
||||
Style = tbsSeparator
|
||||
end
|
||||
object ToolButton16: TToolButton
|
||||
Left = 249
|
||||
Left = 251
|
||||
Top = 2
|
||||
Caption = 'Click here to print the treeview.'
|
||||
ImageIndex = 24
|
||||
|
@ -37,12 +37,13 @@ type
|
||||
procedure XPTreeGetImageIndex(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind;
|
||||
Column: TColumnIndex; var Ghosted: Boolean; var Index: Integer);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure XPTreeHeaderClick(Sender: TVTHeader; HitInfo: TVTHeaderHitInfo);
|
||||
procedure XPTreeInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode;
|
||||
var InitialStates: TVirtualNodeInitStates);
|
||||
procedure XPTreeInitChildren(Sender: TBaseVirtualTree; Node: PVirtualNode; var ChildCount: Cardinal);
|
||||
procedure XPTreeGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex;
|
||||
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);
|
||||
procedure XPTreeCompareNodes(Sender: TBaseVirtualTree; Node1, Node2: PVirtualNode; Column: TColumnIndex;
|
||||
var Result: Integer);
|
||||
@ -129,6 +130,40 @@ begin
|
||||
{$endif}
|
||||
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;
|
||||
@ -186,38 +221,11 @@ end;
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
procedure TWindowsXPForm.XPTreeHeaderClick(Sender: TVTHeader; Column: TColumnIndex; Button: TMouseButton;
|
||||
Shift: TShiftState; X, Y: Integer);
|
||||
procedure TWindowsXPForm.XPTreeHeaderClickx(Sender: TVTHeader;
|
||||
Column: TColumnIndex; Button: TMouseButton; Shift: TShiftState; X, Y: Integer
|
||||
);
|
||||
|
||||
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;
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -12,30 +12,30 @@ object Form1: TForm1
|
||||
OnClose = FormClose
|
||||
OnCreate = FormCreate
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '0.9.29'
|
||||
LCLVersion = '1.0.8.0'
|
||||
object Label1: TLabel
|
||||
Left = 224
|
||||
Left = 246
|
||||
Height = 14
|
||||
Top = 348
|
||||
Width = 174
|
||||
Width = 152
|
||||
Anchors = [akRight, akBottom]
|
||||
Caption = 'Array data of the clicked node:'
|
||||
ParentColor = False
|
||||
end
|
||||
object Label2: TLabel
|
||||
Left = 224
|
||||
Left = 258
|
||||
Height = 14
|
||||
Top = 382
|
||||
Width = 256
|
||||
Width = 222
|
||||
Anchors = [akRight, akBottom]
|
||||
Caption = 'Find and show the node by specific array index'
|
||||
ParentColor = False
|
||||
end
|
||||
object Label3: TLabel
|
||||
Left = 224
|
||||
Left = 261
|
||||
Height = 14
|
||||
Top = 398
|
||||
Width = 274
|
||||
Width = 237
|
||||
Anchors = [akRight, akBottom]
|
||||
Caption = 'Type index to get related tree node on the screen:'
|
||||
ParentColor = False
|
||||
@ -66,8 +66,8 @@ object Form1: TForm1
|
||||
AnchorSideLeft.Control = Label1
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
Left = 402
|
||||
Height = 23
|
||||
Top = 344
|
||||
Height = 21
|
||||
Top = 346
|
||||
Width = 170
|
||||
Anchors = [akLeft, akBottom]
|
||||
BorderSpacing.Left = 4
|
||||
@ -89,8 +89,8 @@ object Form1: TForm1
|
||||
AnchorSideLeft.Control = Label3
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
Left = 502
|
||||
Height = 23
|
||||
Top = 394
|
||||
Height = 21
|
||||
Top = 396
|
||||
Width = 97
|
||||
Anchors = [akLeft, akBottom]
|
||||
BorderSpacing.Left = 4
|
||||
|
@ -115,8 +115,7 @@ type
|
||||
procedure Button1Click(Sender: TObject);
|
||||
procedure MyTreeCompareNodes(Sender: TBaseVirtualTree; Node1,
|
||||
Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer);
|
||||
procedure MyTreeHeaderClick(Sender: TVTHeader; Column: TColumnIndex;
|
||||
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||
procedure MyTreeHeaderClick(Sender: TVTHeader; HitInfo: TVTHeaderHitInfo);
|
||||
procedure btnDeleteClick(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure MyTreePaintText(Sender: TBaseVirtualTree;
|
||||
@ -240,8 +239,7 @@ begin
|
||||
end
|
||||
end;
|
||||
|
||||
procedure TForm1.MyTreeHeaderClick(Sender: TVTHeader; Column: TColumnIndex;
|
||||
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||
procedure TForm1.MyTreeHeaderClick(Sender: TVTHeader; HitInfo: TVTHeaderHitInfo);
|
||||
var
|
||||
Direction : TSortDirection;
|
||||
begin
|
||||
@ -251,27 +249,30 @@ begin
|
||||
// MyTree.Header.SortDirection and MyTree.Header.SortColumn
|
||||
// to get automatically Descending/Ascending sorting
|
||||
// by only clicking on header
|
||||
|
||||
if ssShift in Shift
|
||||
then
|
||||
Direction := sdDescending
|
||||
else
|
||||
Direction := sdAscending;
|
||||
|
||||
// Sort all columns except the second
|
||||
if Column<>1 then
|
||||
with HitInfo do
|
||||
begin
|
||||
// Set direction image on the sorted column
|
||||
MyTree.Header.SortColumn := Column;
|
||||
if ssShift in Shift
|
||||
then
|
||||
Direction := sdDescending
|
||||
else
|
||||
Direction := sdAscending;
|
||||
|
||||
// Set the right direction image
|
||||
MyTree.Header.SortDirection := Direction;
|
||||
// Sort all columns except the second
|
||||
if Column<>1 then
|
||||
begin
|
||||
// Set direction image on the sorted column
|
||||
MyTree.Header.SortColumn := Column;
|
||||
|
||||
// Sorting process
|
||||
MyTree.SortTree(Column, Direction);
|
||||
end
|
||||
// Set the right direction image
|
||||
MyTree.Header.SortDirection := Direction;
|
||||
|
||||
// Sorting process
|
||||
MyTree.SortTree(Column, Direction);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TForm1.btnDeleteClick(Sender: TObject);
|
||||
var
|
||||
Timer: cardinal;
|
||||
|
@ -10,7 +10,7 @@ object Form1: TForm1
|
||||
Font.Height = -11
|
||||
Font.Name = 'MS Sans Serif'
|
||||
OnCreate = FormCreate
|
||||
LCLVersion = '0.9.29'
|
||||
LCLVersion = '1.0.8.0'
|
||||
object VST1: TVirtualStringTree
|
||||
Cursor = 63
|
||||
Left = 0
|
||||
|
@ -41,6 +41,7 @@ type
|
||||
procedure VST1BeforeCellPaint(Sender: TBaseVirtualTree;
|
||||
TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
|
||||
CellPaintMode: TVTCellPaintMode; CellRect: TRect; var ContentRect: TRect);
|
||||
procedure VST1HeaderClick(Sender: TVTHeader; HitInfo: TVTHeaderHitInfo);
|
||||
procedure VST1InitNode(Sender: TBaseVirtualTree; ParentNode,
|
||||
Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates);
|
||||
procedure VST1GetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
|
||||
@ -51,8 +52,6 @@ type
|
||||
var Ghosted: Boolean; var ImageIndex: Integer);
|
||||
procedure VST1Checking(Sender: TBaseVirtualTree; Node: PVirtualNode;
|
||||
var NewState: TCheckState; var Allowed: Boolean);
|
||||
procedure VST1HeaderClick(Sender: TVTHeader; Column: TColumnIndex;
|
||||
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||
procedure VST1CompareNodes(Sender: TBaseVirtualTree; Node1,
|
||||
Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer);
|
||||
private
|
||||
@ -151,6 +150,26 @@ begin
|
||||
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,
|
||||
Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates);
|
||||
var
|
||||
@ -261,28 +280,6 @@ begin
|
||||
Allowed:=true
|
||||
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,
|
||||
Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer);
|
||||
var
|
||||
|
@ -1,20 +1,21 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Version Value="7"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<AlwaysBuild Value="False"/>
|
||||
<LRSInOutputDirectory Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<TargetFileExt Value=".exe"/>
|
||||
</General>
|
||||
<VersionInfo>
|
||||
<ProjectVersion Value=""/>
|
||||
<StringTable ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
@ -51,8 +52,13 @@
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="8"/>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<UseAnsiStrings Value="False"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<Linking>
|
||||
<Options>
|
||||
<Win32>
|
||||
|
@ -13,7 +13,7 @@ object frmVTDBExample: TfrmVTDBExample
|
||||
OnClose = FormClose
|
||||
OnCreate = FormCreate
|
||||
Position = poDefaultPosOnly
|
||||
LCLVersion = '0.9.27'
|
||||
LCLVersion = '1.0.8.0'
|
||||
object Label1: TLabel
|
||||
Left = 12
|
||||
Height = 14
|
||||
@ -23,7 +23,9 @@ object frmVTDBExample: TfrmVTDBExample
|
||||
ParentColor = False
|
||||
end
|
||||
object Panel1: TPanel
|
||||
Left = 0
|
||||
Height = 482
|
||||
Top = 0
|
||||
Width = 553
|
||||
Align = alClient
|
||||
BevelOuter = bvNone
|
||||
@ -45,8 +47,10 @@ object frmVTDBExample: TfrmVTDBExample
|
||||
DefaultText = 'Node'
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Header.AutoSizeIndex = 0
|
||||
Header.Columns = <
|
||||
item
|
||||
Color = clWindow
|
||||
ImageIndex = 3
|
||||
Layout = blGlyphRight
|
||||
Options = [coAllowClick, coDraggable, coEnabled, coParentBidiMode, coResizable, coShowDropMark, coVisible, coAllowFocus]
|
||||
@ -61,9 +65,11 @@ object frmVTDBExample: TfrmVTDBExample
|
||||
end
|
||||
item
|
||||
Alignment = taCenter
|
||||
Position = 0
|
||||
Text = 'Status'
|
||||
Width = 42
|
||||
end>
|
||||
Header.DefaultHeight = 17
|
||||
Header.Font.Height = -11
|
||||
Header.Font.Name = 'MS Sans Serif'
|
||||
Header.Images = imgMaster
|
||||
@ -201,7 +207,7 @@ object frmVTDBExample: TfrmVTDBExample
|
||||
end
|
||||
object chkShowIDs: TCheckBox
|
||||
Left = 244
|
||||
Height = 17
|
||||
Height = 19
|
||||
Top = 35
|
||||
Width = 60
|
||||
Caption = 'Show ID'
|
||||
@ -220,7 +226,7 @@ object frmVTDBExample: TfrmVTDBExample
|
||||
end
|
||||
object chkAllVisible: TCheckBox
|
||||
Left = 429
|
||||
Height = 17
|
||||
Height = 19
|
||||
Top = 35
|
||||
Width = 63
|
||||
Caption = 'All Visible'
|
||||
@ -229,7 +235,7 @@ object frmVTDBExample: TfrmVTDBExample
|
||||
end
|
||||
object chkDynHt: TCheckBox
|
||||
Left = 324
|
||||
Height = 17
|
||||
Height = 19
|
||||
Top = 35
|
||||
Width = 94
|
||||
Caption = 'Dynamic Height'
|
||||
|
@ -57,6 +57,7 @@ interface
|
||||
procedure VTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
|
||||
var Text: String);
|
||||
procedure VTFreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode);
|
||||
procedure VTHeaderClick(Sender: TVTHeader; HitInfo: TVTHeaderHitInfo);
|
||||
procedure VTInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode;
|
||||
var InitialStates: TVirtualNodeInitStates);
|
||||
procedure FormActivate(Sender: TObject);
|
||||
@ -67,8 +68,6 @@ interface
|
||||
procedure VTPaintText(Sender: TBaseVirtualTree;
|
||||
const TargetCanvas: TCanvas; Node: PVirtualNode;
|
||||
Column: TColumnIndex; TextType: TVSTTextType);
|
||||
procedure VTHeaderClick(Sender: TVTHeader; Column: TColumnIndex;
|
||||
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||
procedure VTCompareNodes(Sender: TBaseVirtualTree; Node1,
|
||||
Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer);
|
||||
procedure VTGetNodeDataSize(Sender: TBaseVirtualTree; var NodeDataSize: Integer);
|
||||
@ -213,6 +212,22 @@ implementation
|
||||
Data.bnd.Free;
|
||||
Finalize( Data^ );
|
||||
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;
|
||||
Column: TColumnIndex; TextType: TVSTTextType; var Text: String);
|
||||
@ -342,19 +357,6 @@ implementation
|
||||
VT.Refresh;
|
||||
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,
|
||||
Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer);
|
||||
var
|
||||
|
@ -14,7 +14,7 @@ object frmVTNoData: TfrmVTNoData
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
Position = poDefaultPosOnly
|
||||
LCLVersion = '0.9.29'
|
||||
LCLVersion = '1.0.8.0'
|
||||
object Panel1: TPanel
|
||||
Left = 0
|
||||
Height = 346
|
||||
@ -67,7 +67,7 @@ object frmVTNoData: TfrmVTNoData
|
||||
Left = 9
|
||||
Height = 14
|
||||
Top = 9
|
||||
Width = 82
|
||||
Width = 76
|
||||
Alignment = taCenter
|
||||
Caption = 'VT.TreeOptions'
|
||||
Font.Color = clRed
|
||||
@ -78,27 +78,27 @@ object frmVTNoData: TfrmVTNoData
|
||||
end
|
||||
object chkCheckBoxes: TCheckBox
|
||||
Left = 180
|
||||
Height = 22
|
||||
Height = 19
|
||||
Top = 7
|
||||
Width = 93
|
||||
Width = 81
|
||||
Caption = 'Check Boxes'
|
||||
OnClick = chkCheckBoxesClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object chkFullExpand: TCheckBox
|
||||
Left = 100
|
||||
Height = 22
|
||||
Height = 19
|
||||
Top = 7
|
||||
Width = 86
|
||||
Width = 75
|
||||
Caption = 'Full Expand'
|
||||
OnClick = chkFullExpandClick
|
||||
TabOrder = 1
|
||||
end
|
||||
object chkShowLevel: TCheckBox
|
||||
Left = 271
|
||||
Height = 22
|
||||
Height = 19
|
||||
Top = 7
|
||||
Width = 86
|
||||
Width = 74
|
||||
Caption = 'Show Level'
|
||||
OnClick = chkShowLevelClick
|
||||
TabOrder = 2
|
||||
|
@ -194,7 +194,9 @@ implementation
|
||||
'StaticBackground',
|
||||
'ChildrenAbove',
|
||||
'FixedIndent',
|
||||
'UseExplorerTheme'
|
||||
'UseExplorerTheme',
|
||||
'HideTreeLinesIfThemed',
|
||||
'ShowHiddenNodes'
|
||||
);
|
||||
|
||||
aSelOpts : array[0..Ord(High(TVTSelectionOption))] of string[25] =
|
||||
|
Reference in New Issue
Block a user