mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 14:38:01 +02:00
Examples: Replace lfm-less NotebookTest demo by version with lfm form.
This commit is contained in:
parent
dc62098696
commit
718ebb5676
@ -1,54 +1,60 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<Version Value="12"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<SaveOnlyProjectUnits Value="True"/>
|
||||
<LRSInOutputDirectory Value="False"/>
|
||||
<CompatibilityMode Value="True"/>
|
||||
</Flags>
|
||||
<MainUnit Value="0"/>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<Title Value="notebooktest"/>
|
||||
<Scaled Value="True"/>
|
||||
<ResourceType Value="res"/>
|
||||
<ActiveWindowIndexAtStart Value="0"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<XPManifest>
|
||||
<DpiAware Value="True"/>
|
||||
</XPManifest>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="default" Default="True"/>
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<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"/>
|
||||
<UseFileFilters Value="True"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
<FormatVersion Value="2"/>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="1">
|
||||
<Item1>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units Count="1">
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="notebooktest.pp"/>
|
||||
<Filename Value="notebooktest.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="NotebookTest"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="0"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="1"/>
|
||||
<CursorPos X="1" Y="1"/>
|
||||
<UsageCount Value="20"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="notebooktestfrm.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="NoteBookTestFrm"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="10"/>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="notebooktest"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
<Options>
|
||||
@ -57,11 +63,18 @@
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CompilerMessages>
|
||||
<UseMsgFile Value="True"/>
|
||||
</CompilerMessages>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
||||
|
60
examples/notebooktest.lpr
Normal file
60
examples/notebooktest.lpr
Normal file
@ -0,0 +1,60 @@
|
||||
{ $Id$ }
|
||||
{
|
||||
/***************************************************************************
|
||||
NoteBookTest.pp
|
||||
-------------------
|
||||
|
||||
|
||||
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* This source is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This code is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* General Public License for more details. *
|
||||
* *
|
||||
* A copy of the GNU General Public License is available on the World *
|
||||
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
|
||||
* obtain it by writing to the Free Software Foundation, *
|
||||
* Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA. *
|
||||
* *
|
||||
***************************************************************************
|
||||
}
|
||||
{
|
||||
@abstract(An example application for TNotebook)
|
||||
@author(NoteBookTest.pp - Marc Weustink <weus@quicknet.nl>)
|
||||
}
|
||||
|
||||
program notebooktest;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}
|
||||
cthreads,
|
||||
{$ENDIF}
|
||||
{$IFDEF HASAMIGA}
|
||||
athreads,
|
||||
{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms, NoteBookTestFrm
|
||||
{ you can add units after this };
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
RequireDerivedFormResource:=True;
|
||||
Application.Scaled:=True;
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end.
|
||||
|
@ -1,169 +0,0 @@
|
||||
{ $Id$ }
|
||||
{
|
||||
/***************************************************************************
|
||||
NoteBookTest.pp
|
||||
-------------------
|
||||
|
||||
|
||||
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* This source is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This code is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* General Public License for more details. *
|
||||
* *
|
||||
* A copy of the GNU General Public License is available on the World *
|
||||
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
|
||||
* obtain it by writing to the Free Software Foundation, *
|
||||
* Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA. *
|
||||
* *
|
||||
***************************************************************************
|
||||
}
|
||||
{
|
||||
@abstract(An example application for TNotebook)
|
||||
@author(NoteBookTest.pp - Marc Weustink <weus@quicknet.nl>)
|
||||
}
|
||||
program NotebookTest;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
Interfaces, Classes, Controls, Forms, Buttons, SysUtils, StdCtrls,
|
||||
Graphics, ExtCtrls, LclProc;
|
||||
|
||||
type
|
||||
|
||||
TForm1 = class(TForm)
|
||||
Notebook1 : TNotebook;
|
||||
Button1: TButton;
|
||||
Button2: TButton;
|
||||
Button3: TButton;
|
||||
Label1: TLabel;
|
||||
procedure Button1CLick(Sender : TObject);
|
||||
procedure Button2CLick(Sender : TObject);
|
||||
procedure Button3CLick(Sender : TObject);
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
end;
|
||||
|
||||
|
||||
constructor TForm1.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited CreateNew(AOwner, 1);
|
||||
Caption := 'Notebook testing';
|
||||
Left := 0;
|
||||
Top := 0;
|
||||
Width := 700;
|
||||
Height := 300;
|
||||
Position:= poMainFormCenter;
|
||||
|
||||
Button1 := TButton.Create(Self);
|
||||
with Button1 do begin
|
||||
Top:= 0;
|
||||
Left:= 0;
|
||||
AutoSize := true;
|
||||
Parent:= Self;
|
||||
Caption := 'Create page';
|
||||
OnClick := @Button1Click;
|
||||
end;
|
||||
|
||||
Button2 := TButton.Create(Self);
|
||||
with Button2 do begin
|
||||
AnchorSide[akLeft].Side := asrRight;
|
||||
AnchorSide[akLeft].Control := Button1;
|
||||
AnchorSide[akTop].Side := asrCenter;
|
||||
AnchorSide[akTop].Control := Button1;
|
||||
AutoSize := true;
|
||||
Parent:= Self;
|
||||
Caption := 'Back';
|
||||
OnClick := @Button2Click;
|
||||
end;
|
||||
|
||||
Button3 := TButton.Create(Self);
|
||||
with Button3 do begin
|
||||
AnchorSide[akLeft].Side := asrRight;
|
||||
AnchorSide[akLeft].Control := Button2;
|
||||
AnchorSide[akTop].Side := asrCenter;
|
||||
AnchorSide[akTop].Control := Button2;
|
||||
AutoSize := true;
|
||||
Parent:= Self;
|
||||
Caption := 'Forward';
|
||||
OnClick := @Button3Click;
|
||||
end;
|
||||
|
||||
Label1 := TLabel.Create(Self);
|
||||
with Label1 do begin
|
||||
AnchorSide[akLeft].Side := asrRight;
|
||||
BorderSpacing.Left := 6;
|
||||
AnchorSide[akLeft].Control := Button3;
|
||||
AnchorSide[akTop].Side := asrCenter;
|
||||
AnchorSide[akTop].Control := Button3;
|
||||
Parent:= Self;
|
||||
Caption := '0 pages total';
|
||||
end;
|
||||
|
||||
NoteBook1 := TNoteBook.Create(Self);
|
||||
with NoteBook1 do
|
||||
begin
|
||||
AnchorSide[akTop].Side := asrBottom;
|
||||
AnchorSide[akTop].Control := Button1;
|
||||
Align := alBottom;
|
||||
Anchors := Anchors + [akTop];
|
||||
Parent:= Self;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.Button1Click(Sender : TObject);
|
||||
var
|
||||
NewPageIndex: integer;
|
||||
NewPage: TPage;
|
||||
PageLabel: TLabel;
|
||||
begin
|
||||
NewPageIndex := Notebook1.Pages.Add(Format('[Page %d]', [Notebook1.Pages.Count]));
|
||||
NewPage := Notebook1.Page[NewPageIndex];
|
||||
PageLabel := TLabel.Create(Self);
|
||||
with PageLabel do
|
||||
begin
|
||||
Left := 20;
|
||||
Top := 10 + NewPageIndex * 20;
|
||||
Width := 500;
|
||||
Height := 20;
|
||||
Caption := Format('This is page [%d]',[NewPageIndex]);
|
||||
Parent := NewPage;
|
||||
end;
|
||||
Label1.Caption := IntToStr(Notebook1.PageCount)+ ' pages total';
|
||||
end;
|
||||
|
||||
procedure TForm1.Button2Click(Sender : TObject);
|
||||
begin
|
||||
if Notebook1.PageIndex>0 then
|
||||
Notebook1.PageIndex:=Notebook1.PageIndex-1;
|
||||
end;
|
||||
|
||||
procedure TForm1.Button3Click(Sender : TObject);
|
||||
begin
|
||||
if Notebook1.PageIndex<Notebook1.PageCount-1 then
|
||||
Notebook1.PageIndex:=Notebook1.PageIndex+1;
|
||||
end;
|
||||
|
||||
var
|
||||
F1: TForm1;
|
||||
|
||||
begin
|
||||
DebugLN('------ INIT ------- ');
|
||||
Application.Initialize;
|
||||
DebugLN('------ CREATE ------- ');
|
||||
Application.CreateForm(TForm1, F1);
|
||||
DebugLN('------ RUN ------- ');
|
||||
Application.Run;
|
||||
DebugLN('------ DONE ------- ');
|
||||
end.
|
72
examples/notebooktestfrm.lfm
Normal file
72
examples/notebooktestfrm.lfm
Normal file
@ -0,0 +1,72 @@
|
||||
object Form1: TForm1
|
||||
Left = 270
|
||||
Height = 300
|
||||
Top = 131
|
||||
Width = 700
|
||||
Caption = 'Notebook testing'
|
||||
ClientHeight = 300
|
||||
ClientWidth = 700
|
||||
Position = poMainFormCenter
|
||||
LCLVersion = '2.3.0.0'
|
||||
object Button1: TButton
|
||||
Left = 0
|
||||
Height = 25
|
||||
Top = 0
|
||||
Width = 89
|
||||
AutoSize = True
|
||||
Caption = 'Create Page'
|
||||
OnClick = Button1Click
|
||||
TabOrder = 0
|
||||
end
|
||||
object Button2: TButton
|
||||
AnchorSideLeft.Control = Button1
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = Button1
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 89
|
||||
Height = 25
|
||||
Top = 0
|
||||
Width = 51
|
||||
AutoSize = True
|
||||
Caption = 'Back'
|
||||
OnClick = Button2Click
|
||||
TabOrder = 1
|
||||
end
|
||||
object Button3: TButton
|
||||
AnchorSideLeft.Control = Button2
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = Button2
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 140
|
||||
Height = 25
|
||||
Top = 0
|
||||
Width = 69
|
||||
AutoSize = True
|
||||
Caption = 'Forward'
|
||||
OnClick = Button3Click
|
||||
TabOrder = 2
|
||||
end
|
||||
object Label1: TLabel
|
||||
AnchorSideLeft.Control = Button3
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = Button3
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 215
|
||||
Height = 15
|
||||
Top = 5
|
||||
Width = 67
|
||||
BorderSpacing.Left = 6
|
||||
Caption = '0 pages total'
|
||||
end
|
||||
object Notebook1: TNotebook
|
||||
AnchorSideTop.Control = Button1
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 0
|
||||
Height = 275
|
||||
Top = 25
|
||||
Width = 700
|
||||
Align = alBottom
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
TabOrder = 3
|
||||
end
|
||||
end
|
73
examples/notebooktestfrm.pas
Normal file
73
examples/notebooktestfrm.pas
Normal file
@ -0,0 +1,73 @@
|
||||
unit NoteBookTestFrm;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls;
|
||||
|
||||
type
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
Button1: TButton;
|
||||
Button2: TButton;
|
||||
Button3: TButton;
|
||||
Label1: TLabel;
|
||||
Notebook1: TNotebook;
|
||||
procedure Button1Click(Sender: TObject);
|
||||
procedure Button2Click(Sender: TObject);
|
||||
procedure Button3Click(Sender: TObject);
|
||||
private
|
||||
|
||||
public
|
||||
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
procedure TForm1.Button1Click(Sender: TObject);
|
||||
var
|
||||
NewPageIndex: integer;
|
||||
NewPage: TPage;
|
||||
PageLabel: TLabel;
|
||||
begin
|
||||
NewPageIndex := Notebook1.Pages.Add(Format('[Page %d]', [Notebook1.Pages.Count]));
|
||||
NewPage := Notebook1.Page[NewPageIndex];
|
||||
NewPage.Color := RgbToColor(Random(128)+127, Random(128)+127, Random(128)+127);
|
||||
PageLabel := TLabel.Create(Self);
|
||||
with PageLabel do
|
||||
begin
|
||||
Left := 20;
|
||||
Top := 10 + NewPageIndex * 20;
|
||||
Width := 500;
|
||||
Height := 20;
|
||||
Caption := Format('This is page [%d]',[NewPageIndex]);
|
||||
Parent := NewPage;
|
||||
end;
|
||||
Label1.Caption := IntToStr(Notebook1.PageCount)+ ' pages total';
|
||||
end;
|
||||
|
||||
procedure TForm1.Button2Click(Sender: TObject);
|
||||
begin
|
||||
if Notebook1.PageIndex > 0 then
|
||||
Notebook1.PageIndex := Notebook1.PageIndex - 1;
|
||||
end;
|
||||
|
||||
procedure TForm1.Button3Click(Sender: TObject);
|
||||
begin
|
||||
if Notebook1.PageIndex < Notebook1.PageCount-1 then
|
||||
Notebook1.PageIndex := Notebook1.PageIndex + 1;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user