added TreeView demo from Tom Lisjac

git-svn-id: trunk@4297 -
This commit is contained in:
mattias 2003-06-23 10:05:39 +00:00
parent 1fb4ee52a5
commit 62d535b829
9 changed files with 265 additions and 0 deletions

7
.gitattributes vendored
View File

@ -229,6 +229,13 @@ examples/testallform.pp svneol=native#text/pascal
examples/testtools.inc svneol=native#text/pascal
examples/toolbar.pp svneol=native#text/pascal
examples/trackbar.pp svneol=native#text/pascal
examples/treeview/TV_Add_Remove.dpr svneol=native#text/pascal
examples/treeview/TV_Add_Remove.res svneol=native#unset
examples/treeview/TV_Add_Remove_U1.dfm svneol=native#unset
examples/treeview/tv_add_remove.lpi svneol=native#text/plain
examples/treeview/tv_add_remove_u1.lfm svneol=native#text/plain
examples/treeview/tv_add_remove_u1.lrs svneol=native#text/pascal
examples/treeview/tv_add_remove_u1.pas svneol=native#text/pascal
ide/aboutfrm.lfm svneol=native#text/plain
ide/aboutfrm.lrs svneol=native#text/pascal
ide/aboutfrm.pas svneol=native#text/pascal

8
examples/treeview/README Normal file
View File

@ -0,0 +1,8 @@
This demo was written by Andre .v.d. Merwe and marked public domain.
Quickly converted to Lazarus and FPC by Tom Lisjac <vlx@users.sourceforge.net>
The original source and an *excellent* tutorial on the TTreeview
component can be found here:
http://users.iafrica.com/d/da/dart/Delphi/TTreeView/TreeView.html

View File

@ -0,0 +1,15 @@
program TV_Add_Remove;
uses
Interfaces,
Forms,
TV_Add_Remove_U1;
//in 'TV_Add_Remove_U1.pas' {Form1};
//{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,68 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<Version Value="2"/>
<General>
<ProjectType Value="Application"/>
<Flags>
<SaveClosedFiles Value="False"/>
<SaveOnlyProjectUnits Value="True"/>
</Flags>
<MainUnit Value="0"/>
<ActiveEditorIndexAtStart Value="1"/>
<IconPath Value="./"/>
<TargetFileExt Value=""/>
<Title Value="TV_Add_Remove"/>
</General>
<Units Count="2">
<Unit0>
<CursorPos X="1" Y="7"/>
<EditorIndex Value="0"/>
<Filename Value="TV_Add_Remove.dpr"/>
<IsPartOfProject Value="True"/>
<Loaded Value="True"/>
<TopLine Value="1"/>
<UsageCount Value="20"/>
</Unit0>
<Unit1>
<CursorPos X="19" Y="52"/>
<EditorIndex Value="1"/>
<Filename Value="tv_add_remove_u1.pas"/>
<ComponentName Value="Form1"/>
<IsPartOfProject Value="True"/>
<Loaded Value="True"/>
<ResourceFilename Value="tv_add_remove_u1.lrs"/>
<TopLine Value="38"/>
<UnitName Value="TV_Add_Remove_U1"/>
<UsageCount Value="20"/>
</Unit1>
</Units>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
<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="1">
<Item1>
<PackageName Value="LCL"/>
<MinVersion Major="1" Valid="True"/>
</Item1>
</RequiredPackages>
</ProjectOptions>
<CompilerOptions>
<SearchPaths>
<LCLWidgetType Value="gtk"/>
<SrcPath Value="$(LazarusDir)/lcl;$(LazarusDir)/lcl/interfaces/$(LCLWidgetType)"/>
</SearchPaths>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
</CONFIG>

View File

@ -0,0 +1,47 @@
object Form1: TForm1
CAPTION = 'TreeView Example 1'
CLIENTHEIGHT = 427
CLIENTWIDTH = 455
FONT.HEIGHT = -11
FONT.NAME = 'MS Sans Serif'
TEXTHEIGHT = 13
HORZSCROLLBAR.PAGE = 456
VERTSCROLLBAR.PAGE = 428
LEFT = 570
HEIGHT = 427
TOP = 249
WIDTH = 455
object tv_eg1: TTREEVIEW
ALIGN = alleft
BACKGROUNDCOLOR = 16777215
BORDERWIDTH = 2
DEFAULTITEMHEIGHT = 17
DRAGCURSOR = 0
HIDESELECTION = False
INDENT = 19
PARENTCTL3D = False
SELECTIONCOLOR = -2147483635
TABORDER = 0
OPTIONS = [tvoautoitemheight, tvokeepcollapsednodes, tvoshowbuttons, tvoshowlines, tvoshowroot, tvotooltips]
HEIGHT = 427
WIDTH = 196
end
object but_Add: TBUTTON
CAPTION = 'Add'
TABORDER = 1
ONCLICK = but_AddClick
LEFT = 208
HEIGHT = 25
TOP = 8
WIDTH = 75
end
object but_Remove: TBUTTON
CAPTION = 'Remove'
TABORDER = 2
ONCLICK = but_RemoveClick
LEFT = 208
HEIGHT = 25
TOP = 40
WIDTH = 75
end
end

View File

@ -0,0 +1,18 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TForm1','FORMDATA',[
'TPF0'#6'TForm1'#5'Form1'#7'CAPTION'#6#18'TreeView Example 1'#12'CLIENTHEIGHT'
+#3#171#1#11'CLIENTWIDTH'#3#199#1#11'FONT.HEIGHT'#2#245#9'FONT.NAME'#6#13'MS '
+'Sans Serif'#10'TEXTHEIGHT'#2#13#18'HORZSCROLLBAR.PAGE'#3#200#1#18'VERTSCROL'
+'LBAR.PAGE'#3#172#1#4'LEFT'#3':'#2#6'HEIGHT'#3#171#1#3'TOP'#3#249#0#5'WIDTH'
+#3#199#1#0#9'TTREEVIEW'#6'tv_eg1'#5'ALIGN'#7#6'alleft'#15'BACKGROUNDCOLOR'#4
+#255#255#255#0#11'BORDERWIDTH'#2#2#17'DEFAULTITEMHEIGHT'#2#17#10'DRAGCURSOR'
+#2#0#13'HIDESELECTION'#8#6'INDENT'#2#19#11'PARENTCTL3D'#8#14'SELECTIONCOLOR'
+#4#13#0#0#128#8'TABORDER'#2#0#7'OPTIONS'#11#17'tvoautoitemheight'#21'tvokeep'
+'collapsednodes'#14'tvoshowbuttons'#12'tvoshowlines'#11'tvoshowroot'#11'tvot'
+'ooltips'#0#6'HEIGHT'#3#171#1#5'WIDTH'#3#196#0#0#0#7'TBUTTON'#7'but_Add'#7'C'
+'APTION'#6#3'Add'#8'TABORDER'#2#1#7'ONCLICK'#7#12'but_AddClick'#4'LEFT'#3#208
+#0#6'HEIGHT'#2#25#3'TOP'#2#8#5'WIDTH'#2'K'#0#0#7'TBUTTON'#10'but_Remove'#7'C'
+'APTION'#6#6'Remove'#8'TABORDER'#2#2#7'ONCLICK'#7#15'but_RemoveClick'#4'LEFT'
+#3#208#0#6'HEIGHT'#2#25#3'TOP'#2'('#5'WIDTH'#2'K'#0#0#0
]);

View File

@ -0,0 +1,102 @@
unit TV_Add_Remove_U1;
{
This demo was written by Andre .v.d. Merwe and marked public domain.
Quickly converted to Lazarus and FPC by Tom Lisjac <vlx@users.sourceforge.net>
The original source and an *excellent* tutorial on the TTreeview
component can be found here:
http://users.iafrica.com/d/da/dart/Delphi/TTreeView/TreeView.html
}
interface
uses
Messages, SysUtils, LResources, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls, Buttons;
type
TForm1 = class(TForm)
tv_eg1: TTreeView;
but_Add: TButton;
but_Remove: TButton;
procedure but_AddClick(Sender: TObject);
procedure but_RemoveClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
//{$R *.DFM}
procedure TForm1.but_AddClick(Sender: TObject);
var
sText : ansistring;
begin
{If nothing is selected}
if( tv_eg1.Selected = nil ) then
begin
{Does a root node already exist?}
if( tv_eg1.Items.Count = 0 ) then
begin
{Add the root node}
with tv_eg1.Items.AddFirst( nil, 'Root' ) do
begin
Selected := true;
end;
end
else begin
{There is a root, so user must first select a node}
//MessageBeep( -1 );
ShowMessage( 'Select a parent node' );
Exit;
end;
end
else begin
{Get a name for the new node}
InputQuery( 'New Node', 'Caption ?', sText );
{Add the node as a child of the selected node}
with tv_eg1.Items.AddChild( tv_eg1.Selected, sText ) do
begin
MakeVisible;
end;
end;
end;
procedure TForm1.but_RemoveClick(Sender: TObject);
begin
{Make sure somthing is selected, before trying to
delete it}
if( tv_eg1.Selected = nil ) then
begin
//MessageBeep( -1 );
ShowMessage( 'Nothing selected' );
Exit;
end;
{Dont allow user to delete the root node}
if( tv_eg1.Selected.Level = 0 ) then
begin
//MessageBeep( -1 );
ShowMessage( 'Cant delete the root node' );
Exit;
end;
{Delete the node}
tv_eg1.Selected.Delete;
end;
Initialization
{$I tv_add_remove_u1.lrs}
end.