summaryrefslogtreecommitdiff
path: root/examples/gui/tabtest/tabtest.lpr
blob: c52e011f6dccb64716694e4325282846f5f390af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
program tabtest;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes, fpgfx, gfx_widget, gfxbase, gui_form, gui_tab, gui_button,
  gui_label, gui_edit;

type
  TMainForm = class(TfpgForm)
  private
    btnQuit: TfpgButton;
    pcMain: TfpgPageControl;
    tsOne: TfpgTabSheet;
    tsTwo: TfpgTabSheet;
    tsThree: TfpgTabSheet;
    lbl1, lbl2, lbl3: TfpgLabel;
    btn1, btn2, btn3: TfpgButton;
    edit1: TfpgEdit;
    procedure   btnQuitClick(Sender: TObject);
    procedure   btn2Click(Sender: TObject);
    procedure   btn3Click(Sender: TObject);
  public
    constructor Create(AOwner: TComponent); override;
  end;

{ TMainForm }

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

procedure TMainForm.btn2Click(Sender: TObject);
begin
  pcMain.ActivePage := tsOne;
end;

procedure TMainForm.btn3Click(Sender: TObject);
begin
  pcMain.ActivePage := tsTwo;
end;

constructor TMainForm.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  WindowTitle := 'Tab control test';
  SetPosition(100, 100, 566, 350);
  
  btnQuit := CreateButton(self, 476, 320, 80, 'Quit', @btnQuitClick);
  btnQuit.ImageName := 'stdimg.Quit';
  btnQuit.ShowImage := True;
  btnQuit.Anchors := [anRight, anBottom];
  
  pcMain := TfpgPageControl.Create(self);
  pcMain.Top := 10;
  pcMain.Left := 10;
  pcMain.Width := Width - 20;
  pcMain.Height := 300;
  pcMain.Anchors := [anLeft, anTop, anRight, anBottom];

  // Tab One
  tsOne := TfpgTabSheet.Create(pcMain);
  tsOne.Text := 'Tab One';
  tsOne.Top := 50;
  
  lbl1 := CreateLabel(tsOne, 50, 50, 'TabSheet One');
  edit1 := CreateEdit(tsOne, 50, 100, 150, 25);

  // Tab Two
  tsTwo := TfpgTabSheet.Create(pcMain);
  tsTwo.Text := 'Tab Two';
  tsTwo.Top := 50;

  lbl2 := CreateLabel(tsTwo, 50, 50, 'TabSheet Two');
  btn1 := CreateButton(tsTwo, 50, 100, 80, 'Button1', nil);

  // Tab Three
  tsThree := TfpgTabSheet.Create(pcMain);
  tsThree.Text := 'Tab Three';
  tsThree.Top := 50;

  lbl3 := CreateLabel(tsThree, 50, 50, 'TabSheet Three');


  btn2 := CreateButton(self, 10, 320, 80, 'Page 1', @btn2Click);
  btn3 := CreateButton(self, 100, 320, 80, 'Page 2', @btn3Click);

end;

procedure MainProc;
var
  frm: TMainForm;
begin
  fpgApplication.Initialize;
  frm := TMainForm.Create(nil);
  frm.Show;
  fpgApplication.Run;
end;

begin
  MainProc;
end.