summaryrefslogtreecommitdiff
path: root/examples/gui/embedded_form/fra_test.pas
blob: f88c08e5c4928a2c3b162bc3f342f2d861f251d2 (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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
unit fra_test;

{$mode objfpc}{$H+}

interface

uses
  SysUtils, Classes, fpg_base, fpg_main, fpg_checkbox, fpg_button,
  fpg_menu, fpg_memo, fpg_panel;

type

  { Note the tags for the UI Designer. This allows use to visually design
    our frame. }
  TMyFrame = class(TfpgFrame)
  private
    {@VFD_HEAD_BEGIN: MyFrame}
    fraCheckBox1: TfpgCheckBox;
    fraMenu1: TfpgMenuBar;
    Button1: TfpgButton;
    Memo1: TfpgMemo;
    {@VFD_HEAD_END: MyFrame}
    framnuFile: TfpgPopupMenu;
    framnuHelp: TfpgPopupMenu;
    procedure miHelpAboutClicked(Sender: TObject);
  public
    destructor Destroy; override;
    procedure AfterCreate; override;
  end;

{@VFD_NEWFORM_DECL}

implementation

uses
  fpg_dialogs;

{@VFD_NEWFORM_IMPL}

procedure TMyFrame.miHelpAboutClicked(Sender: TObject);
begin
  TfpgMessageDialog.AboutFPGui('');
end;

destructor TMyFrame.Destroy;
begin
  framnuFile.Free;
  framnuHelp.Free;
  inherited Destroy;
end;

procedure TMyFrame.AfterCreate;
var
  miFile: TfpgMenuItem;
  miHelp: TfpgMenuItem;
begin
  {%region 'Auto-generated GUI code' -fold}
  {@VFD_BODY_BEGIN: MyFrame}
  Name := 'MyFrame';
  SetPosition(380, 237, 200, 203);
  WindowTitle := 'MyFrame';
  Hint := '';

  fraCheckBox1 := TfpgCheckBox.Create(self);
  with fraCheckBox1 do
  begin
    Name := 'fraCheckBox1';
    SetPosition(8, 40, 120, 20);
    FontDesc := '#Label1';
    Hint := '';
    TabOrder := 0;
    Text := 'CheckBox';
  end;

  fraMenu1 := TfpgMenuBar.Create(self);
  with fraMenu1 do
  begin
    Name := 'fraMenu1';
    SetPosition(0, 0, 200, 24);
    Anchors := [anLeft,anRight,anTop];
    miFile := AddMenuItem('File', nil);
    AddMenuItem('Edit', nil).Enabled := False;
    miHelp := AddMenuItem('Help', nil);
  end;

  Button1 := TfpgButton.Create(self);
  with Button1 do
  begin
    Name := 'Button1';
    SetPosition(104, 164, 80, 24);
    Anchors := [anRight,anBottom];
    Text := 'Button';
    FontDesc := '#Label1';
    Hint := '';
    ImageName := '';
    TabOrder := 2;
  end;

  Memo1 := TfpgMemo.Create(self);
  with Memo1 do
  begin
    Name := 'Memo1';
    SetPosition(12, 60, 172, 88);
    Anchors := [anLeft,anRight,anTop,anBottom];
    Hint := '';
    Lines.Add('');
    FontDesc := '#Edit1';
    TabOrder := 3;
  end;

  {@VFD_BODY_END: MyFrame}
  {%endregion}

  { There still seems to be a minor issue with Popup Menus used in a frame. So
    for now the work around is to manually maintain the life of the Popup
    Menus - so Owner is set to nil. }
  framnuFile := TfpgPopupMenu.Create(nil);
  with framnuFile do
  begin
    Name := 'framnuFile';
    SetPosition(44, 64, 120, 20);
    AddMenuItem('Open...', '', nil);
    AddMenuItem('-', '', nil);
    AddMenuItem('Save', '', nil);
  end;
  miFile.SubMenu := framnuFile;

  framnuHelp := TfpgPopupMenu.Create(nil);
  with framnuHelp do
  begin
    Name := 'framnuHelp';
    SetPosition(44, 64, 120, 20);
    AddMenuItem('About fpGUI...', '', @miHelpAboutClicked);
  end;
  miHelp.SubMenu := framnuHelp;
end;


end.