You've already forked lazarus-ccr
Import from old repository
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@56 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
103
components/virtualtreeview/demos/mininal/Main.lfm
Normal file
103
components/virtualtreeview/demos/mininal/Main.lfm
Normal file
@@ -0,0 +1,103 @@
|
||||
object MainForm: TMainForm
|
||||
Left = 353
|
||||
Height = 481
|
||||
Top = 172
|
||||
Width = 425
|
||||
HorzScrollBar.Page = 424
|
||||
VertScrollBar.Page = 480
|
||||
ActiveControl = VST
|
||||
Caption = 'Simple Virtual Treeview demo'
|
||||
Font.Height = -11
|
||||
Font.Name = 'MS Sans Serif'
|
||||
OnCreate = FormCreate
|
||||
object Label1: TLabel
|
||||
Left = 12
|
||||
Height = 14
|
||||
Top = 12
|
||||
Width = 117
|
||||
Caption = 'Last operation duration:'
|
||||
Color = clNone
|
||||
ParentColor = False
|
||||
end
|
||||
object VST: TVirtualStringTree
|
||||
Left = 8
|
||||
Height = 318
|
||||
Top = 36
|
||||
Width = 397
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
Colors.BorderColor = clWindowText
|
||||
Colors.HotColor = clBlack
|
||||
Header.AutoSizeIndex = -1
|
||||
Header.Font.Height = -11
|
||||
Header.Font.Name = 'MS Sans Serif'
|
||||
Header.MainColumn = -1
|
||||
Header.Options = [hoColumnResize, hoDrag]
|
||||
HintAnimation = hatNone
|
||||
IncrementalSearch = isAll
|
||||
RootNodeCount = 100
|
||||
TabOrder = 0
|
||||
TreeOptions.AnimationOptions = [toAnimatedToggle]
|
||||
TreeOptions.AutoOptions = [toAutoDropExpand, toAutoTristateTracking]
|
||||
TreeOptions.MiscOptions = [toEditable, toInitOnSave, toToggleOnDblClick, toWheelPanning]
|
||||
TreeOptions.PaintOptions = [toShowButtons, toShowRoot, toShowTreeLines, toThemeAware, toUseBlendedImages]
|
||||
TreeOptions.SelectionOptions = [toMultiSelect, toCenterScrollIntoView]
|
||||
OnFreeNode = VSTFreeNode
|
||||
OnGetText = VSTGetText
|
||||
OnInitNode = VSTInitNode
|
||||
Columns = <>
|
||||
end
|
||||
object ClearButton: TButton
|
||||
Left = 97
|
||||
Height = 25
|
||||
Top = 421
|
||||
Width = 129
|
||||
Anchors = [akLeft, akBottom]
|
||||
BorderSpacing.InnerBorder = 4
|
||||
Caption = 'Clear tree'
|
||||
OnClick = ClearButtonClick
|
||||
TabOrder = 1
|
||||
end
|
||||
object AddOneButton: TButton
|
||||
Left = 96
|
||||
Height = 25
|
||||
Top = 361
|
||||
Width = 130
|
||||
Anchors = [akLeft, akBottom]
|
||||
BorderSpacing.InnerBorder = 4
|
||||
Caption = 'Add node(s) to root'
|
||||
OnClick = AddButtonClick
|
||||
TabOrder = 2
|
||||
end
|
||||
object Edit1: TEdit
|
||||
Left = 8
|
||||
Height = 21
|
||||
Top = 377
|
||||
Width = 81
|
||||
Anchors = [akLeft, akBottom]
|
||||
TabOrder = 3
|
||||
Text = '1'
|
||||
end
|
||||
object Button1: TButton
|
||||
Tag = 1
|
||||
Left = 96
|
||||
Height = 25
|
||||
Top = 389
|
||||
Width = 130
|
||||
Anchors = [akLeft, akBottom]
|
||||
BorderSpacing.InnerBorder = 4
|
||||
Caption = 'Add node(s) as children'
|
||||
OnClick = AddButtonClick
|
||||
TabOrder = 4
|
||||
end
|
||||
object CloseButton: TButton
|
||||
Left = 330
|
||||
Height = 25
|
||||
Top = 421
|
||||
Width = 75
|
||||
Anchors = [akRight, akBottom]
|
||||
BorderSpacing.InnerBorder = 4
|
||||
Caption = 'Close'
|
||||
OnClick = CloseButtonClick
|
||||
TabOrder = 5
|
||||
end
|
||||
end
|
||||
40
components/virtualtreeview/demos/mininal/Main.lrs
Normal file
40
components/virtualtreeview/demos/mininal/Main.lrs
Normal file
@@ -0,0 +1,40 @@
|
||||
{ This is an automatically generated lazarus resource file }
|
||||
|
||||
LazarusResources.Add('TMainForm','FORMDATA',[
|
||||
'TPF0'#9'TMainForm'#8'MainForm'#4'Left'#3'a'#1#6'Height'#3#225#1#3'Top'#3#172
|
||||
+#0#5'Width'#3#169#1#18'HorzScrollBar.Page'#3#168#1#18'VertScrollBar.Page'#3
|
||||
+#224#1#13'ActiveControl'#7#3'VST'#7'Caption'#6#28'Simple Virtual Treeview de'
|
||||
+'mo'#11'Font.Height'#2#245#9'Font.Name'#6#13'MS Sans Serif'#8'OnCreate'#7#10
|
||||
+'FormCreate'#0#6'TLabel'#6'Label1'#4'Left'#2#12#6'Height'#2#14#3'Top'#2#12#5
|
||||
+'Width'#2'u'#7'Caption'#6#24'Last operation duration:'#5'Color'#7#6'clNone'
|
||||
+#11'ParentColor'#8#0#0#18'TVirtualStringTree'#3'VST'#4'Left'#2#8#6'Height'#3
|
||||
+'>'#1#3'Top'#2'$'#5'Width'#3#141#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRigh'
|
||||
+'t'#8'akBottom'#0#18'Colors.BorderColor'#7#12'clWindowText'#15'Colors.HotCol'
|
||||
+'or'#7#7'clBlack'#20'Header.AutoSizeIndex'#2#255#18'Header.Font.Height'#2#245
|
||||
+#16'Header.Font.Name'#6#13'MS Sans Serif'#17'Header.MainColumn'#2#255#14'Hea'
|
||||
+'der.Options'#11#14'hoColumnResize'#6'hoDrag'#0#13'HintAnimation'#7#7'hatNon'
|
||||
+'e'#17'IncrementalSearch'#7#5'isAll'#13'RootNodeCount'#2'd'#8'TabOrder'#2#0
|
||||
+#28'TreeOptions.AnimationOptions'#11#16'toAnimatedToggle'#0#23'TreeOptions.A'
|
||||
+'utoOptions'#11#16'toAutoDropExpand'#22'toAutoTristateTracking'#0#23'TreeOpt'
|
||||
+'ions.MiscOptions'#11#10'toEditable'#12'toInitOnSave'#18'toToggleOnDblClick'
|
||||
+#14'toWheelPanning'#0#24'TreeOptions.PaintOptions'#11#13'toShowButtons'#10't'
|
||||
+'oShowRoot'#15'toShowTreeLines'#12'toThemeAware'#18'toUseBlendedImages'#0#28
|
||||
+'TreeOptions.SelectionOptions'#11#13'toMultiSelect'#22'toCenterScrollIntoVie'
|
||||
+'w'#0#10'OnFreeNode'#7#11'VSTFreeNode'#9'OnGetText'#7#10'VSTGetText'#10'OnIn'
|
||||
+'itNode'#7#11'VSTInitNode'#7'Columns'#14#0#0#0#7'TButton'#11'ClearButton'#4
|
||||
+'Left'#2'a'#6'Height'#2#25#3'Top'#3#165#1#5'Width'#3#129#0#7'Anchors'#11#6'a'
|
||||
+'kLeft'#8'akBottom'#0#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#10'Clea'
|
||||
+'r tree'#7'OnClick'#7#16'ClearButtonClick'#8'TabOrder'#2#1#0#0#7'TButton'#12
|
||||
+'AddOneButton'#4'Left'#2'`'#6'Height'#2#25#3'Top'#3'i'#1#5'Width'#3#130#0#7
|
||||
+'Anchors'#11#6'akLeft'#8'akBottom'#0#25'BorderSpacing.InnerBorder'#2#4#7'Cap'
|
||||
+'tion'#6#19'Add node(s) to root'#7'OnClick'#7#14'AddButtonClick'#8'TabOrder'
|
||||
+#2#2#0#0#5'TEdit'#5'Edit1'#4'Left'#2#8#6'Height'#2#21#3'Top'#3'y'#1#5'Width'
|
||||
+#2'Q'#7'Anchors'#11#6'akLeft'#8'akBottom'#0#8'TabOrder'#2#3#4'Text'#6#1'1'#0
|
||||
+#0#7'TButton'#7'Button1'#3'Tag'#2#1#4'Left'#2'`'#6'Height'#2#25#3'Top'#3#133
|
||||
+#1#5'Width'#3#130#0#7'Anchors'#11#6'akLeft'#8'akBottom'#0#25'BorderSpacing.I'
|
||||
+'nnerBorder'#2#4#7'Caption'#6#23'Add node(s) as children'#7'OnClick'#7#14'Ad'
|
||||
+'dButtonClick'#8'TabOrder'#2#4#0#0#7'TButton'#11'CloseButton'#4'Left'#3'J'#1
|
||||
+#6'Height'#2#25#3'Top'#3#165#1#5'Width'#2'K'#7'Anchors'#11#7'akRight'#8'akBo'
|
||||
+'ttom'#0#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#5'Close'#7'OnClick'#7
|
||||
+#16'CloseButtonClick'#8'TabOrder'#2#5#0#0#0
|
||||
]);
|
||||
190
components/virtualtreeview/demos/mininal/Main.pas
Normal file
190
components/virtualtreeview/demos/mininal/Main.pas
Normal file
@@ -0,0 +1,190 @@
|
||||
unit Main;
|
||||
|
||||
{$MODE Delphi}
|
||||
{$define DEBUG}
|
||||
|
||||
// Demonstration project for TVirtualStringTree to generally show how to get started.
|
||||
// Written by Mike Lischke.
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
{$ifdef DEBUG}
|
||||
vtlogger, ipcchannel,
|
||||
{$endif}
|
||||
LCLIntf, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
||||
VirtualTrees, StdCtrls, ExtCtrls, LResources, Buttons;
|
||||
|
||||
type
|
||||
TMainForm = class(TForm)
|
||||
VST: TVirtualStringTree;
|
||||
ClearButton: TButton;
|
||||
AddOneButton: TButton;
|
||||
Edit1: TEdit;
|
||||
Button1: TButton;
|
||||
Label1: TLabel;
|
||||
CloseButton: TButton;
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure ClearButtonClick(Sender: TObject);
|
||||
procedure AddButtonClick(Sender: TObject);
|
||||
procedure VSTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
|
||||
var Text: WideString);
|
||||
procedure VSTFreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode);
|
||||
procedure VSTInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode;
|
||||
var InitialStates: TVirtualNodeInitStates);
|
||||
procedure CloseButtonClick(Sender: TObject);
|
||||
end;
|
||||
|
||||
var
|
||||
MainForm: TMainForm;
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
type
|
||||
// This is a very simple record we use to store data in the nodes.
|
||||
// Since the application is responsible to manage all data including the node's caption
|
||||
// this record can be considered as minimal requirement in all VT applications.
|
||||
// Extend it to whatever your application needs.
|
||||
PMyRec = ^TMyRec;
|
||||
TMyRec = record
|
||||
Caption: WideString;
|
||||
end;
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
procedure TMainForm.FormCreate(Sender: TObject);
|
||||
|
||||
begin
|
||||
{$ifdef DEBUG}
|
||||
Logger.ActiveClasses:=[lcScroll];
|
||||
Logger.Channels.Add(TIPCChannel.Create);
|
||||
Logger.Clear;
|
||||
Logger.MaxStackCount:=10;
|
||||
{$endif}
|
||||
// Let the tree know how much data space we need.
|
||||
VST.NodeDataSize := SizeOf(TMyRec);
|
||||
// Set an initial number of nodes.
|
||||
VST.RootNodeCount := 20;
|
||||
end;
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
procedure TMainForm.ClearButtonClick(Sender: TObject);
|
||||
|
||||
var
|
||||
Start: Cardinal;
|
||||
|
||||
begin
|
||||
Screen.Cursor := crHourGlass;
|
||||
try
|
||||
Start := GetTickCount;
|
||||
VST.Clear;
|
||||
Label1.Caption := Format('Last operation duration: %d ms', [GetTickCount - Start]);
|
||||
finally
|
||||
Screen.Cursor := crDefault;
|
||||
end;
|
||||
end;
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
procedure TMainForm.AddButtonClick(Sender: TObject);
|
||||
|
||||
var
|
||||
Count: Cardinal;
|
||||
Start: Cardinal;
|
||||
|
||||
begin
|
||||
// Add some nodes to the treeview.
|
||||
Screen.Cursor := crHourGlass;
|
||||
with VST do
|
||||
try
|
||||
Start := GetTickCount;
|
||||
case (Sender as TButton).Tag of
|
||||
0: // add to root
|
||||
begin
|
||||
Count := StrToInt(Edit1.Text);
|
||||
RootNodeCount := RootNodeCount + Count;
|
||||
end;
|
||||
1: // add as child
|
||||
if Assigned(FocusedNode) then
|
||||
begin
|
||||
Count := StrToInt(Edit1.Text);
|
||||
ChildCount[FocusedNode] := ChildCount[FocusedNode] + Count;
|
||||
Expanded[FocusedNode] := True;
|
||||
InvalidateToBottom(FocusedNode);
|
||||
end;
|
||||
end;
|
||||
Label1.Caption := Format('Last operation duration: %d ms', [GetTickCount - Start]);
|
||||
finally
|
||||
Screen.Cursor := crDefault;
|
||||
end;
|
||||
end;
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
procedure TMainForm.VSTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
|
||||
var Text: WideString);
|
||||
|
||||
var
|
||||
Data: PMyRec;
|
||||
|
||||
begin
|
||||
// A handler for the OnGetText event is always needed as it provides the tree with the string data to display.
|
||||
// Note that we are always using WideString.
|
||||
Data := Sender.GetNodeData(Node);
|
||||
if Assigned(Data) then
|
||||
Text := Data.Caption;
|
||||
end;
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
procedure TMainForm.VSTFreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode);
|
||||
|
||||
var
|
||||
Data: PMyRec;
|
||||
|
||||
begin
|
||||
Data := Sender.GetNodeData(Node);
|
||||
// Explicitely free the string, the VCL cannot know that there is one but needs to free
|
||||
// it nonetheless. For more fields in such a record which must be freed use Finalize(Data^) instead touching
|
||||
// every member individually.
|
||||
if Assigned(Data) then
|
||||
Data.Caption := '';
|
||||
end;
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
procedure TMainForm.VSTInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode;
|
||||
var InitialStates: TVirtualNodeInitStates);
|
||||
|
||||
var
|
||||
Data: PMyRec;
|
||||
|
||||
begin
|
||||
with Sender do
|
||||
begin
|
||||
Data := GetNodeData(Node);
|
||||
// Construct a node caption. This event is triggered once for each node but
|
||||
// appears asynchronously, which means when the node is displayed not when it is added.
|
||||
Data.Caption := Format('Level %d, Index %d', [GetNodeLevel(Node), Node.Index]);
|
||||
end;
|
||||
end;
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
procedure TMainForm.CloseButtonClick(Sender: TObject);
|
||||
|
||||
begin
|
||||
Close;
|
||||
end;
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
initialization
|
||||
{$i Main.lrs}
|
||||
|
||||
end.
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <assemblyIdentity processorArchitecture="*" version="5.1.0.0" type="win32" name="Microsoft.Windows.Shell.shell32"/> <description>Windows Shell</description> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" publicKeyToken="6595b64144ccf1df" language="*" processorArchitecture="*" /> </dependentAssembly> </dependency> </assembly>
|
||||
83
components/virtualtreeview/demos/mininal/minimal_lcl.lpi
Normal file
83
components/virtualtreeview/demos/mininal/minimal_lcl.lpi
Normal file
@@ -0,0 +1,83 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<PathDelim Value="\"/>
|
||||
<Version Value="5"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<AlwaysBuild Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<IconPath Value="./"/>
|
||||
<TargetFileExt Value=".exe"/>
|
||||
</General>
|
||||
<VersionInfo>
|
||||
<ProjectVersion Value=""/>
|
||||
</VersionInfo>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="3">
|
||||
<Item1>
|
||||
<PackageName Value="virtualtreeview_package"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="miscutils_package"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item3>
|
||||
</RequiredPackages>
|
||||
<Units Count="3">
|
||||
<Unit0>
|
||||
<Filename Value="minimal_lcl.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="minimal_lcl"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="fmain.pas"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ResourceFilename Value="fmain.lrs"/>
|
||||
<UnitName Value="fmain"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="Main.pas"/>
|
||||
<ComponentName Value="MainForm"/>
|
||||
<HasResources Value="True"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ResourceFilename Value="Main.lrs"/>
|
||||
<UnitName Value="Main"/>
|
||||
</Unit2>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="5"/>
|
||||
<PathDelim Value="\"/>
|
||||
<SearchPaths>
|
||||
<OtherUnitFiles Value="E:\subversion\luipack\trunk\virtualtreeview\"/>
|
||||
</SearchPaths>
|
||||
<CodeGeneration>
|
||||
<Generate Value="Faster"/>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
</CONFIG>
|
||||
18
components/virtualtreeview/demos/mininal/minimal_lcl.lpr
Normal file
18
components/virtualtreeview/demos/mininal/minimal_lcl.lpr
Normal file
@@ -0,0 +1,18 @@
|
||||
program minimal_lcl;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms
|
||||
{ add your units here }, Main, miscutils_package, virtualtreeview_package;
|
||||
|
||||
begin
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TMainForm, MainForm);
|
||||
Application.Run;
|
||||
end.
|
||||
|
||||
Reference in New Issue
Block a user