Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Port to Firemonkey #839

Closed
wants to merge 74 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
df38930
Initial Port to Firemonkey
livius2 Nov 4, 2018
1eb7a99
Rework on TDimension and TCanvas
livius2 Nov 7, 2018
545c10f
added safer prevDC: HDC; when using dummyCanvas
livius2 Nov 7, 2018
eabd4c6
move some specific function sto VirtualTrees.FMX
livius2 Nov 7, 2018
619cace
fix introduced warnings
livius2 Nov 7, 2018
cc9c95e
missed uses "FMX.Types"
livius2 Nov 7, 2018
a5113f5
code cleanup cast to integer not needed after TDimension introduced
livius2 Nov 7, 2018
300e77e
VCL Fixing HandleAllocated of dummyCanvas (Canvas does not allow draw…
livius2 Nov 8, 2018
4b0e161
TreeLines, HorzGridLines, VertGridLines, FullVertGridLines + fixes
livius2 Nov 8, 2018
ad36e69
Merge pull request #1 from Virtual-TreeView/master
livius2 Nov 8, 2018
5bb5d78
Cliping, Text alignment
livius2 Nov 8, 2018
ca25342
Merge branch 'master' of https://github.com/livius2/Virtual-TreeView
livius2 Nov 8, 2018
8f72978
Update README.md
livius2 Nov 9, 2018
7a480eb
Update README.md
livius2 Nov 9, 2018
85df814
Update README.md
livius2 Nov 9, 2018
86fcfc0
Update README.md
livius2 Nov 9, 2018
15756c8
Update README.md
livius2 Nov 9, 2018
9bc27eb
Update README.md
livius2 Nov 9, 2018
9de9ad0
Update README.md
livius2 Nov 9, 2018
3056fd2
Update README.md
livius2 Nov 9, 2018
70708e7
Merge branch 'master' of https://github.com/livius2/Virtual-TreeView
livius2 Nov 9, 2018
cfef0eb
soft fix for + bitmap
livius2 Nov 9, 2018
93be8bc
Added header drawing
livius2 Nov 9, 2018
0787e1a
Fix Vertical lines across cells
livius2 Nov 9, 2018
d47d2fa
Full DrawEdge implementation
livius2 Nov 10, 2018
efd6fca
Added expanding and collapsing by mouse click
livius2 Nov 11, 2018
b3e252b
Added header column resizing by mouse
livius2 Nov 12, 2018
88c2bfd
Accept focus, draw focus rect
livius2 Nov 12, 2018
ddbad39
Update README.md
livius2 Nov 13, 2018
e30cf51
Checkbox support
livius2 Nov 14, 2018
f79264a
Added package for FMX for Delphi Tokyo
livius2 Nov 14, 2018
05ee7d4
Take action when VT is resized
livius2 Nov 14, 2018
78ff502
System checkboxes and Android port
livius2 Nov 14, 2018
6c78b76
code cleanup
livius2 Nov 14, 2018
a06e055
added Hot and Selected plus/minus buttons
livius2 Nov 14, 2018
0c4110b
GreedLines now have dedicated brush
livius2 Nov 15, 2018
6fadd51
Better procedure which create images for system platform check and ra…
livius2 Nov 15, 2018
4ec248d
Fix header resize column when VT is on the Right of parent control
livius2 Nov 15, 2018
8244ca3
Manual Merge
livius2 Nov 15, 2018
2d0cfe4
Update VirtualTrees.WorkerThread.pas
livius2 Nov 15, 2018
d73ff17
Merge branch 'pr/2'
livius2 Nov 15, 2018
956d65f
Fixes after merge with master
livius2 Nov 15, 2018
9224b62
softer glow effect on checked hot
livius2 Nov 15, 2018
b226571
First attempt to ScrollBars support - many issues
livius2 Nov 17, 2018
373d5f1
Fix painting header when vertical scrollbar position>0
livius2 Nov 17, 2018
66a4a75
Fixing horiz and vert scroll
livius2 Nov 18, 2018
4812f4e
Fix horizontal scroll content painting
livius2 Nov 18, 2018
91426b7
Fix focus rect and area between scrollbars
livius2 Nov 19, 2018
5372d56
Update README.md
livius2 Nov 19, 2018
0e0facf
Merge branch 'pr/3'
livius2 Nov 19, 2018
e544584
Remove many unnescessary ifdefs by providing canvas helper
livius2 Nov 20, 2018
6a4e5cd
Fix warnings nad some hints
livius2 Nov 20, 2018
dc8da09
corner case fixes
livius2 Nov 20, 2018
013ff40
added MultiSelect with smDottedRectangle and with smBlendedRectangle
livius2 Nov 21, 2018
e214a1d
Merge branch 'master' of https://github.com/livius2/Virtual-TreeView
livius2 Nov 21, 2018
5241c2a
Fix cursor changes when back from header splitter
livius2 Nov 21, 2018
2f1ebbc
added mouse wheel scrolling
livius2 Nov 21, 2018
09a0602
remove debug code
livius2 Nov 21, 2018
eaf960f
Added draw static background
livius2 Nov 21, 2018
055fc7f
Merge branch 'pr/4'
livius2 Nov 30, 2018
180eea5
fix after merge with master
livius2 Nov 30, 2018
6627010
Merge branch 'pr/5'
livius2 Dec 3, 2018
bf009fa
Merge branch 'merge_master_step_1'
livius2 Dec 21, 2018
58a984f
Fix after merge with master
joachimmarder Dec 14, 2018
240be0c
Merge branch 'pr/8'
livius2 Mar 29, 2019
92c574b
Merge branch 'pr/8'
livius2 Mar 29, 2019
caf9bc0
Merge branch 'pr/9'
livius2 Apr 4, 2019
892db4d
Fix FMX after merge with master
livius2 Apr 8, 2019
a8a0e0c
Added screenshot from Android
livius2 Apr 10, 2019
7d67c32
Update README.md
livius2 Apr 10, 2019
0af13ea
Merge branch 'pr/10'
livius2 Apr 10, 2019
7649a6e
Migrate demo - "Minimal" to FMX
livius2 Apr 12, 2019
8edb0aa
Update README.md
livius2 Apr 24, 2019
11e4155
Update README.md
livius2 Apr 24, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions Demos/FMX/Minimal/Main.fmx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
object MainForm: TMainForm
Left = 0
Top = 0
Caption = 'Simple Virtual Treeview demo'
ClientHeight = 443
ClientWidth = 409
FormFactor.Width = 320
FormFactor.Height = 480
FormFactor.Devices = [Desktop]
OnCreate = FormCreate
DesignerMasterStyle = 0
object AddOneButton: TButton
Anchors = [akLeft, akBottom]
Position.X = 128.000000000000000000
Position.Y = 352.000000000000000000
Size.Width = 130.000000000000000000
Size.Height = 25.000000000000000000
Size.PlatformDefault = False
TabOrder = 2
Text = 'Add node(s) to root'
OnClick = AddOneButtonClick
Left = 96
Top = 350
end
object Button1: TButton
Tag = 1
Anchors = [akLeft, akBottom]
Position.X = 128.000000000000000000
Position.Y = 384.000000000000000000
Size.Width = 130.000000000000000000
Size.Height = 25.000000000000000000
Size.PlatformDefault = False
TabOrder = 5
Text = 'Add node(s) as children'
OnClick = AddOneButtonClick
Left = 96
Top = 378
end
object ClearButton: TButton
Anchors = [akLeft, akBottom]
Position.X = 128.000000000000000000
Position.Y = 416.000000000000000000
Size.Width = 129.000000000000000000
Size.Height = 25.000000000000000000
Size.PlatformDefault = False
TabOrder = 0
Text = 'Clear tree'
OnClick = ClearButtonClick
Left = 97
Top = 410
end
object CloseButton: TButton
Anchors = [akRight, akBottom]
Position.X = 328.000000000000000000
Position.Y = 416.000000000000000000
Size.Width = 75.000000000000000000
Size.Height = 25.000000000000000000
Size.PlatformDefault = False
TabOrder = 4
Text = 'Close'
OnClick = CloseButtonClick
Left = 330
Top = 410
end
object Edit1: TEdit
Touch.InteractiveGestures = [LongTap, DoubleTap]
Anchors = [akLeft, akBottom]
TabOrder = 1
Text = '3'
Position.X = 24.000000000000000000
Position.Y = 352.000000000000000000
Size.Width = 81.000000000000000000
Size.Height = 21.000000000000000000
Size.PlatformDefault = False
Left = 8
Top = 366
end
object Label1: TLabel
Position.X = 8.000000000000000000
Position.Y = 320.000000000000000000
Size.Width = 116.000000000000000000
Size.Height = 13.000000000000000000
Size.PlatformDefault = False
Text = 'Last operation duration:'
TabOrder = 6
Left = 10
Top = 280
end
end
185 changes: 185 additions & 0 deletions Demos/FMX/Minimal/Main.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
unit Main;

interface

uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, VirtualTrees, VirtualTrees.FMX, FMX.StdCtrls, FMX.Edit,
FMX.Controls.Presentation;

type
TMainForm = class(TForm)
AddOneButton: TButton;
Button1: TButton;
ClearButton: TButton;
CloseButton: TButton;
Edit1: TEdit;
Label1: TLabel;
procedure FormCreate(Sender: TObject);
procedure ClearButtonClick(Sender: TObject);
procedure AddOneButtonClick(Sender: TObject);
procedure CloseButtonClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
VST: TVirtualStringTree;


procedure VSTFreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode);
procedure VSTInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode;
var InitialStates: TVirtualNodeInitStates);
procedure VSTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
Column: TColumnIndex; TextType: TVSTTextType; var CellText: string);
end;

var
MainForm: TMainForm;

implementation

{$R *.fmx}

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.AddOneButtonClick(Sender: TObject);
var
Count: Cardinal;
Start: Cardinal;
No : Integer;
begin
// Add some nodes to the treeview.
//Screen.Cursor := crHourGlass;

try
Start := TThread.GetTickCount;
No:= (Sender as TButton).Tag;
case No of
0: // add to root
begin
Count := StrToInt(Edit1.Text);
VST.RootNodeCount := VST.RootNodeCount + Count;
end;
1: // add as child
if Assigned(VST.FocusedNode) then
begin
Count := StrToInt(Edit1.Text);
VST.ChildCount[VST.FocusedNode] := VST.ChildCount[VST.FocusedNode] + Count;
VST.Expanded[VST.FocusedNode] := True;
VST.InvalidateToBottom(VST.FocusedNode);
end;
end;
Label1.Text := Format('Last operation duration: %d ms', [TThread.GetTickCount - Start]);
finally
//Screen.Cursor := crDefault;
end;
end;

procedure TMainForm.ClearButtonClick(Sender: TObject);
var
Start: Cardinal;

begin
//Screen.Cursor := crHourGlass;
try
Start := TThread.GetTickCount;
VST.Clear;
Label1.Text := Format('Last operation duration: %d ms', [TThread.GetTickCount - Start]);
finally
//Screen.Cursor := crDefault;
end;
end;

procedure TMainForm.CloseButtonClick(Sender: TObject);
begin
Close;
end;

procedure TMainForm.FormCreate(Sender: TObject);
Var col: TVirtualTreeColumn;
begin
VST:= TVirtualStringTree.Create(Self);
VST.Parent:= Self;
VST.Fill.Color:= TAlphaColorRec.White;
//VST.AlignWithMargins:= true;
VST.Height:= 262;
VST.Align:= TAlignLayout.Top;
VST.Colors.BorderColor:= clWindowText;
VST.Colors.HotColor := clBlack;
//VST.DragMode := TDragMode.dmAutomatic;
VST.DragType := dtVCL;
VST.Header.AutoSizeIndex := -1;
//VST.Header.Font.Charset := DEFAULT_CHARSET;
//VST.Header.Font.Color := clWindowText;
VST.Header.Font.Size := 10;
VST.Header.Font.Family := 'Tahoma';
VST.Header.Font.Style := [];
VST.Header.Options := [hoColumnResize, hoDrag, hoShowSortGlyphs, hoVisible];
//VST.HintAnimation := hatNone;
VST.IncrementalSearch := isAll;
//VST.ParentBiDiMode := False;
VST.TabOrder := 0;
VST.TreeOptions.AnimationOptions := [toAnimatedToggle];
VST.TreeOptions.MiscOptions := [toEditable, toInitOnSave, toToggleOnDblClick, toWheelPanning];
VST.TreeOptions.PaintOptions := [toShowButtons, toShowRoot, toShowTreeLines, toThemeAware, toUseBlendedImages];
VST.TreeOptions.SelectionOptions := [toMultiSelect];
VST.OnFreeNode := VSTFreeNode;
VST.OnGetText := VSTGetText;
VST.OnInitNode := VSTInitNode;
col:= VST.Header.Columns.Add;
col.Position := 0;
col.Width := 300;
col.Text := 'Name';


// 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.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.
Finalize(Data^);
end;

procedure TMainForm.VSTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex;
TextType: TVSTTextType; var CellText: string);
var
Data: PMyRec;

begin
// A handler for the OnGetText event is always needed as it provides the tree with the string data to display.
Data := Sender.GetNodeData(Node);
if Assigned(Data) then
CellText := Data.Caption;
end;

procedure TMainForm.VSTInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode;
var InitialStates: TVirtualNodeInitStates);
var
Data: PMyRec;

begin
Data := Sender.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', [Sender.GetNodeLevel(Node), Node.Index]);
end;

end.
15 changes: 15 additions & 0 deletions Demos/FMX/Minimal/Minimal.dpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
program Minimal;

uses
System.StartUpCopy,
FMX.Forms,
Main in 'Main.pas' {MainForm},
VirtualTrees in '..\..\..\..\Source\VirtualTrees.pas';

{$R *.res}

begin
Application.Initialize;
Application.CreateForm(TMainForm, MainForm);
Application.Run;
end.
Loading