summaryrefslogtreecommitdiff
path: root/examples/gui/customstyles/frm_test.pas
blob: 6eb30b35e9dcf88330e1b4e65ea63dac3c63badb (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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
unit frm_test;

{$mode objfpc}{$H+}

interface

uses
  SysUtils, Classes, fpg_base, fpg_main, fpg_widget,
  fpg_form, fpg_edit, fpg_label, fpg_button, fpg_menu,
  fpg_memo;

type

  TTestForm = class(TfpgForm)
  private
    {@VFD_HEAD_BEGIN: TestForm}
    btnName1: TfpgButton;
    lblName1: TfpgLabel;
    lblName2: TfpgLabel;
    btnName2: TfpgButton;
    lblName3: TfpgLabel;
    btnName3: TfpgButton;
    lblName4: TfpgLabel;
    btnName4: TfpgButton;
    edtName1: TfpgEdit;
    btnClose: TfpgButton;
    MainMenu: TfpgMenuBar;
    pmFile: TfpgPopupMenu;
    pmEdit: TfpgPopupMenu;
    pmHelp: TfpgPopupMenu;
    pmSubMenu1: TfpgPopupMenu;
    memStyles: TfpgMemo;
    Label1: TfpgLabel;
    {@VFD_HEAD_END: TestForm}
    procedure CloseClicked(Sender: TObject);
  public
    procedure AfterCreate; override;
  end;

{@VFD_NEWFORM_DECL}

implementation

uses
  fpg_stylemanager;

{@VFD_NEWFORM_IMPL}

procedure TTestForm.CloseClicked(Sender: TObject);
begin
  Close;
end;

procedure TTestForm.AfterCreate;
var
  miSubMenu: TfpgMenuItem;
begin
  {@VFD_BODY_BEGIN: TestForm}
  Name := 'TestForm';
  SetPosition(335, 206, 484, 250);
  WindowTitle := 'Testing Custom Styles';
  Hint := '';
  WindowPosition := wpScreenCenter;

  btnName1 := TfpgButton.Create(self);
  with btnName1 do
  begin
    Name := 'btnName1';
    SetPosition(24, 56, 80, 24);
    Text := 'Button1';
    FontDesc := '#Label1';
    Hint := '';
    ImageName := '';
    TabOrder := 1;
  end;

  lblName1 := TfpgLabel.Create(self);
  with lblName1 do
  begin
    Name := 'lblName1';
    SetPosition(20, 32, 116, 16);
    FontDesc := '#Label2';
    Hint := '';
    Text := 'Standard Button';
  end;

  lblName2 := TfpgLabel.Create(self);
  with lblName2 do
  begin
    Name := 'lblName2';
    SetPosition(164, 32, 124, 16);
    FontDesc := '#Label2';
    Hint := '';
    Text := 'Embedded Button';
  end;

  btnName2 := TfpgButton.Create(self);
  with btnName2 do
  begin
    Name := 'btnName2';
    SetPosition(176, 56, 80, 24);
    Text := 'Button2';
    Embedded := True;
    FontDesc := '#Label1';
    Hint := '';
    ImageName := '';
    TabOrder := 2;
  end;

  lblName3 := TfpgLabel.Create(self);
  with lblName3 do
  begin
    Name := 'lblName3';
    SetPosition(20, 100, 100, 16);
    FontDesc := '#Label2';
    Hint := '';
    Text := 'Default Button';
  end;

  btnName3 := TfpgButton.Create(self);
  with btnName3 do
  begin
    Name := 'btnName3';
    SetPosition(24, 124, 80, 24);
    Text := 'Button3';
    FontDesc := '#Label1';
    Hint := '';
    ImageName := '';
    TabOrder := 3;
    Default := True;
  end;

  lblName4 := TfpgLabel.Create(self);
  with lblName4 do
  begin
    Name := 'lblName4';
    SetPosition(164, 100, 116, 16);
    FontDesc := '#Label2';
    Hint := '';
    Text := 'Flat Button';
  end;

  btnName4 := TfpgButton.Create(self);
  with btnName4 do
  begin
    Name := 'btnName4';
    SetPosition(176, 124, 80, 24);
    Text := 'Button4';
    Flat := True;
    FontDesc := '#Label1';
    Hint := '';
    ImageName := '';
    TabOrder := 4;
  end;

  edtName1 := TfpgEdit.Create(self);
  with edtName1 do
  begin
    Name := 'edtName1';
    SetPosition(24, 168, 164, 27);
    ExtraHint := '';
    FontDesc := '#Edit1';
    Hint := '';
    TabOrder := 5;
    Text := '';
  end;

  btnClose := TfpgButton.Create(self);
  with btnClose do
  begin
    Name := 'btnClose';
    SetPosition(396, 216, 80, 24);
    Anchors := [anRight,anBottom];
    Text := 'Close';
    FontDesc := '#Label1';
    Hint := '';
    ImageName := 'stdimg.close';
    TabOrder := 6;
    OnClick := @CloseClicked;
  end;

  MainMenu := TfpgMenuBar.Create(self);
  with MainMenu do
  begin
    Name := 'MainMenu';
    SetPosition(8, 4, 120, 24);
    Align := alTop;
  end;

  pmFile := TfpgPopupMenu.Create(self);
  with pmFile do
  begin
    Name := 'pmFile';
    SetPosition(204, 148, 120, 24);
    AddMenuItem('&Open', 'Ctrl+O', nil);
    AddMenuItem('&Save', 'Ctrl+S', nil);
    AddMenuItem('S&ave As', 'Ctrl+A', nil);
    AddMenuItem('-', '', nil);
    AddMenuItem('Save && Reload', '', nil);
    AddMenuItem('-', '', nil);
    AddMenuItem('&Quit', 'Ctrl+Q', nil);
  end;

  pmEdit := TfpgPopupMenu.Create(self);
  with pmEdit do
  begin
    Name := 'pmEdit';
    SetPosition(204, 172, 120, 24);
    AddMenuItem('Cut', '', nil);
    AddMenuItem('Copy', '', nil);
    AddMenuItem('Paste', '', nil);
    AddMenuItem('-', '', nil);
    AddMenuItem('Some selected item', '', nil).Checked := True;
    miSubMenu := AddMenuItem('My sub-menu', '', nil);
  end;

  pmHelp := TfpgPopupMenu.Create(self);
  with pmHelp do
  begin
    Name := 'pmHelp';
    SetPosition(204, 196, 120, 24);
    AddMenuItem('About...', '', nil);
  end;

  pmSubMenu1 := TfpgPopupMenu.Create(self);
  with pmSubMenu1 do
  begin
    Name := 'pmSubMenu1';
    SetPosition(204, 220, 120, 24);
    AddMenuItem('Item 1', '', nil);
    AddMenuItem('Item 2', '', nil);
    AddMenuItem('Item 3', '', nil).Enabled := False;
  end;

  memStyles := TfpgMemo.Create(self);
  with memStyles do
  begin
    Name := 'memStyles';
    SetPosition(304, 48, 168, 146);
    FontDesc := '#Edit1';
    Hint := '';
    TabOrder := 16;
  end;

  Label1 := TfpgLabel.Create(self);
  with Label1 do
  begin
    Name := 'Label1';
    SetPosition(304, 32, 172, 16);
    FontDesc := '#Label2';
    Hint := '';
    Text := 'Registered Styles:';
  end;

  {@VFD_BODY_END: TestForm}

  // hook up menus to mainmenu bar
  MainMenu.AddMenuItem('File', nil).SubMenu := pmFile;
  MainMenu.AddMenuItem('Edit', nil).SubMenu := pmEdit;
  MainMenu.AddMenuItem('Help', nil).SubMenu := pmHelp;

  miSubMenu.SubMenu := pmSubMenu1;

  fpgStyleManager.AssignStyleTypes(memStyles.Lines);
end;



end.