mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 06:39:26 +02:00
Examples, NoteBk: converted nested Notebook to TPageControl and restored features, which were removed in r28916 #76f0a18ff0
git-svn-id: trunk@29571 -
This commit is contained in:
parent
7d1c2d987a
commit
363abb927f
@ -1,38 +1,18 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<CONFIG>
|
<CONFIG>
|
||||||
<ProjectOptions>
|
<ProjectOptions>
|
||||||
<PathDelim Value="/"/>
|
<Version Value="9"/>
|
||||||
<Version Value="5"/>
|
|
||||||
<General>
|
<General>
|
||||||
<Flags>
|
<Flags>
|
||||||
<SaveOnlyProjectUnits Value="True"/>
|
<SaveOnlyProjectUnits Value="True"/>
|
||||||
|
<LRSInOutputDirectory Value="False"/>
|
||||||
</Flags>
|
</Flags>
|
||||||
<MainUnit Value="0"/>
|
<MainUnit Value="0"/>
|
||||||
<TargetFileExt Value=""/>
|
<ActiveWindowIndexAtStart Value="0"/>
|
||||||
<ActiveEditorIndexAtStart Value="1"/>
|
|
||||||
</General>
|
</General>
|
||||||
<Units Count="2">
|
<BuildModes Count="1">
|
||||||
<Unit0>
|
<Item1 Name="default" Default="True"/>
|
||||||
<CursorPos X="8" Y="29"/>
|
</BuildModes>
|
||||||
<EditorIndex Value="0"/>
|
|
||||||
<Filename Value="notebk.pp"/>
|
|
||||||
<IsPartOfProject Value="True"/>
|
|
||||||
<Loaded Value="True"/>
|
|
||||||
<TopLine Value="1"/>
|
|
||||||
<UnitName Value="NoteBk"/>
|
|
||||||
<UsageCount Value="20"/>
|
|
||||||
</Unit0>
|
|
||||||
<Unit1>
|
|
||||||
<CursorPos X="35" Y="36"/>
|
|
||||||
<EditorIndex Value="1"/>
|
|
||||||
<Filename Value="notebku.pp"/>
|
|
||||||
<IsPartOfProject Value="True"/>
|
|
||||||
<Loaded Value="True"/>
|
|
||||||
<TopLine Value="1"/>
|
|
||||||
<UnitName Value="notebku"/>
|
|
||||||
<UsageCount Value="20"/>
|
|
||||||
</Unit1>
|
|
||||||
</Units>
|
|
||||||
<PublishOptions>
|
<PublishOptions>
|
||||||
<Version Value="2"/>
|
<Version Value="2"/>
|
||||||
<IgnoreBinaries Value="False"/>
|
<IgnoreBinaries Value="False"/>
|
||||||
@ -50,15 +30,43 @@
|
|||||||
<PackageName Value="LCL"/>
|
<PackageName Value="LCL"/>
|
||||||
</Item1>
|
</Item1>
|
||||||
</RequiredPackages>
|
</RequiredPackages>
|
||||||
|
<Units Count="2">
|
||||||
|
<Unit0>
|
||||||
|
<Filename Value="notebk.pp"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
<UnitName Value="NoteBk"/>
|
||||||
|
<EditorIndex Value="0"/>
|
||||||
|
<WindowIndex Value="0"/>
|
||||||
|
<TopLine Value="1"/>
|
||||||
|
<CursorPos X="8" Y="29"/>
|
||||||
|
<UsageCount Value="21"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
|
<LoadedDesigner Value="True"/>
|
||||||
|
</Unit0>
|
||||||
|
<Unit1>
|
||||||
|
<Filename Value="notebku.pp"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
<UnitName Value="notebku"/>
|
||||||
|
<IsVisibleTab Value="True"/>
|
||||||
|
<EditorIndex Value="1"/>
|
||||||
|
<WindowIndex Value="0"/>
|
||||||
|
<TopLine Value="253"/>
|
||||||
|
<CursorPos X="38" Y="285"/>
|
||||||
|
<UsageCount Value="21"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
|
</Unit1>
|
||||||
|
</Units>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
<CompilerOptions>
|
<CompilerOptions>
|
||||||
<Version Value="5"/>
|
<Version Value="10"/>
|
||||||
<SearchPaths>
|
<SearchPaths>
|
||||||
<SrcPath Value="$(LazarusDir)/lcl/;$(LazarusDir)/lcl/interfaces/$(LCLWidgetType)/"/>
|
<SrcPath Value="$(LazarusDir)/lcl;$(LazarusDir)/lcl/interfaces/$(LCLWidgetType)"/>
|
||||||
</SearchPaths>
|
</SearchPaths>
|
||||||
<CodeGeneration>
|
<Parsing>
|
||||||
<Generate Value="Faster"/>
|
<SyntaxOptions>
|
||||||
</CodeGeneration>
|
<UseAnsiStrings Value="False"/>
|
||||||
|
</SyntaxOptions>
|
||||||
|
</Parsing>
|
||||||
<Linking>
|
<Linking>
|
||||||
<Options>
|
<Options>
|
||||||
<Win32>
|
<Win32>
|
||||||
|
@ -25,7 +25,7 @@ unit notebku;
|
|||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses Classes, SysUtils, Controls, Forms, ExtCtrls, Buttons, StdCtrls;
|
uses Classes, SysUtils, Controls, Forms, ExtCtrls, Buttons, StdCtrls, ComCtrls;
|
||||||
|
|
||||||
type
|
type
|
||||||
TForm1 = class(TForm)
|
TForm1 = class(TForm)
|
||||||
@ -33,7 +33,7 @@ type
|
|||||||
private
|
private
|
||||||
public
|
public
|
||||||
fNotebk: TNotebook;
|
fNotebk: TNotebook;
|
||||||
fNotebook: TNotebook;
|
fNotebook: TPageControl;
|
||||||
fButton1: TButton;
|
fButton1: TButton;
|
||||||
fButton2: TButton;
|
fButton2: TButton;
|
||||||
fButton3: TButton;
|
fButton3: TButton;
|
||||||
@ -49,7 +49,9 @@ type
|
|||||||
procedure Button1Click(Sender: TObject);
|
procedure Button1Click(Sender: TObject);
|
||||||
procedure Button2Click(Sender: TObject);
|
procedure Button2Click(Sender: TObject);
|
||||||
procedure Button3Click(Sender: TObject);
|
procedure Button3Click(Sender: TObject);
|
||||||
|
procedure Button4Click(Sender: TObject);
|
||||||
procedure Button5Click(Sender: TObject);
|
procedure Button5Click(Sender: TObject);
|
||||||
|
procedure Button6Click(Sender: TObject);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -64,9 +66,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TForm1.Create(AOwner: TComponent);
|
constructor TForm1.Create(AOwner: TComponent);
|
||||||
|
var
|
||||||
|
i: integer;
|
||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
Caption := 'Notebook Test';
|
Caption := 'Notebook/PageControl Test';
|
||||||
Width := 300;
|
Width := 300;
|
||||||
Height := 400;
|
Height := 400;
|
||||||
Left := 200;
|
Left := 200;
|
||||||
@ -82,31 +86,23 @@ begin
|
|||||||
Top :=0;
|
Top :=0;
|
||||||
Width := Self.Width;
|
Width := Self.Width;
|
||||||
Height := Self.Height;
|
Height := Self.Height;
|
||||||
if PageCount>0 then
|
for i:=1 to 5 do
|
||||||
Pages.Strings[0] := 'Page 1'
|
Pages.Add('Page '+IntToStr(i));
|
||||||
else
|
|
||||||
Pages.Add('Page 1');
|
|
||||||
Pages.Add('Page 2');
|
|
||||||
Pages.Add('Page 3');
|
|
||||||
Pages.Add('Page 4');
|
|
||||||
Pages.Add('Page 5');
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
fNotebk.Page[4].OnResize:=@fNotebkResize;
|
fNotebk.Page[4].OnResize:=@fNotebkResize;
|
||||||
|
|
||||||
// Create the Tabbed Notebook
|
// Create the nested PageControl
|
||||||
fNotebook := TNotebook.Create(Self);
|
fNotebook := TPageControl.Create(Self);
|
||||||
with fNotebook do
|
with fNotebook do
|
||||||
begin
|
begin
|
||||||
Parent := fNotebk.Page[4];
|
Parent := fNotebk.Page[4];
|
||||||
if PageCount>0 then
|
for i:=1 to 5 do
|
||||||
Pages.Strings[0] := 'Page 1'
|
with TTabSheet.Create(fNotebook) do
|
||||||
else
|
begin
|
||||||
Pages.Add('Page 1');
|
PageControl := fNotebook;
|
||||||
Pages.Add('Page 2');
|
Caption := 'Page '+IntToStr(i);
|
||||||
Pages.Add('Page 3');
|
end;
|
||||||
Pages.Add('Page 4');
|
|
||||||
Pages.Add('Page 5');
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Create Goto First Page Button on last page of Notebook
|
{ Create Goto First Page Button on last page of Notebook
|
||||||
@ -232,18 +228,18 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// Create Show/Hide Tabs Button on first page of TabbedNotebook
|
// Create Show/Hide Tabs Button on first page of TabbedNotebook
|
||||||
{ fButton4 := TButton.Create(fNotebook.Page[0]);
|
fButton4 := TButton.Create(fNotebook.Page[0]);
|
||||||
with fButton4 do
|
with fButton4 do
|
||||||
begin
|
begin
|
||||||
Parent := fNotebook.Page[0];
|
Parent := fNotebook.Page[0];
|
||||||
OnClick := @Button4Click;
|
OnClick := @Button4Click;
|
||||||
Width := 90;
|
Width := 90;
|
||||||
Height := 23;
|
Height := 23;
|
||||||
left := (250 {Parent.Widht} - Width) div 2;
|
left := (250 {Parent.Width} - Width) div 2;
|
||||||
top := 150;
|
top := 150;
|
||||||
Caption := 'Hide Tabs';
|
Caption := 'Hide Tabs';
|
||||||
Show;
|
Show;
|
||||||
end;}
|
end;
|
||||||
|
|
||||||
// Create Delete Page Button on third page of TabbedNotebook
|
// Create Delete Page Button on third page of TabbedNotebook
|
||||||
fButton5 := TButton.Create(fNotebook.Page[2]);
|
fButton5 := TButton.Create(fNotebook.Page[2]);
|
||||||
@ -253,12 +249,26 @@ begin
|
|||||||
OnClick := @Button5Click;
|
OnClick := @Button5Click;
|
||||||
Width := 120;
|
Width := 120;
|
||||||
Height := 23;
|
Height := 23;
|
||||||
left := (250 {Parent.Widht} - Width) div 2;
|
left := (250 {Parent.Width} - Width) div 2;
|
||||||
top := 100;
|
top := 100;
|
||||||
Caption := 'Delete Page';
|
Caption := 'Delete Page';
|
||||||
Show;
|
Show;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// Create Set Tabs Position Button on first page of TabbedNotebook
|
||||||
|
fButton6 := TButton.Create(fNotebook.Page[0]);
|
||||||
|
with fButton6 do
|
||||||
|
begin
|
||||||
|
Parent := fNotebook.Page[0];
|
||||||
|
OnClick := @Button6Click;
|
||||||
|
Width := 150;
|
||||||
|
Height := 23;
|
||||||
|
left := (250 {Parent.Widht} - Width) div 2;
|
||||||
|
top := 190;
|
||||||
|
Caption := 'Set Tab Position';
|
||||||
|
Show;
|
||||||
|
end;
|
||||||
|
|
||||||
// Goto the first page of the Notebook
|
// Goto the first page of the Notebook
|
||||||
fNotebk.PageIndex := 0;
|
fNotebk.PageIndex := 0;
|
||||||
end;
|
end;
|
||||||
@ -281,20 +291,45 @@ begin
|
|||||||
Close;
|
Close;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.Button4Click(Sender: TObject);
|
||||||
|
begin
|
||||||
|
//writeln('Show/Hide Tabs Button Clicked');
|
||||||
|
|
||||||
|
fNotebook.ShowTabs := not fNotebook.ShowTabs;
|
||||||
|
if (fNotebook.ShowTabs) then
|
||||||
|
fButton4.Caption := 'Hide Tabs'
|
||||||
|
else
|
||||||
|
fButton4.Caption := 'Show Tabs';
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TForm1.Button5Click(Sender: TObject);
|
procedure TForm1.Button5Click(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
//writeln('Delete Page Button Clicked');
|
//writeln('Delete Page Button Clicked');
|
||||||
|
|
||||||
if (fNotebook.Pages.Count > 1) then
|
if (fNotebook.PageCount > 1) then
|
||||||
begin
|
begin
|
||||||
// Make sure we don't delete the page with the delete button on it
|
// Make sure we don't delete the page with the delete button on it
|
||||||
if (fNotebook.PageIndex = fNotebook.Pages.Count - 1) then
|
if (fNotebook.PageIndex = fNotebook.PageCount - 1) then
|
||||||
fNotebook.Pages.Delete(fNotebook.Pages.Count - 2)
|
fNotebook.Pages[fNotebook.PageCount - 2].Free
|
||||||
else
|
else
|
||||||
fNotebook.Pages.Delete(fNotebook.Pages.Count - 1);
|
fNotebook.Pages[fNotebook.PageCount - 1].Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.Button6Click(Sender: TObject);
|
||||||
|
begin
|
||||||
|
//writeln('Set Tab Position Button Clicked');
|
||||||
|
|
||||||
|
if fNotebook.TabPosition = tpTop then
|
||||||
|
fNotebook.TabPosition := tpRight
|
||||||
|
else if fNotebook.TabPosition = tpRight then
|
||||||
|
fNotebook.TabPosition := tpBottom
|
||||||
|
else if fNotebook.TabPosition = tpBottom then
|
||||||
|
fNotebook.TabPosition := tpLeft
|
||||||
|
else if fNotebook.TabPosition = tpLeft then
|
||||||
|
fNotebook.TabPosition := tpTop;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user