summaryrefslogtreecommitdiff
path: root/examples/gui/widgettest/widgettest.pas
blob: 8dea18a222fd8405a2416df8ed4b7488f4079a56 (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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
program WidgetTest;

uses
  SysUtils
  ,Classes
  ,fpGFX
  ,fpGUI
  ;

type

  // forward declarations
  TCheckboxForm       = class;
  TRadioButtonForm    = class;
  TGroupBoxForm       = class;
  TEditForm           = class;
  TScrollBarForm      = class;
  TScrollBoxForm      = class;
  TListBoxForm        = class;
  TComboBoxForm       = class;
  TGridForm           = class;
  TMenuForm           = class;
  TPanelForm          = class;
  TProgressBarForm    = class;

  { TMainForm }

  TMainForm = class(TFForm)
  private
    _frmCheckBox: TCheckboxForm;
    _frmRadioButton: TRadioButtonForm;
    _frmGroupBox: TGroupBoxForm;
    _frmEdit: TEditForm;
    _frmScrollBar: TScrollBarForm;
    _frmScrollBox: TScrollBoxForm;
    _frmListBox: TListBoxForm;
    _frmComboBox: TComboBoxForm;
    _frmGrid: TGridForm;
    _frmMenu: TMenuForm;
    _frmPanel: TPanelForm;
    _frmProgressBar: TProgressBarForm;
  public
    constructor Create(AOwner: TComponent); override;
    destructor  Destroy; override;
  published
    Box: TFBoxLayout;
    Title: TFLabel;
    CheckboxBtn: TFButton;
    RadioButtonBtn: TFButton;
    GroupBoxBtn: TFButton;
    EditBtn: TFButton;
    ScrollBarBtn: TFButton;
    ScrollBoxBtn: TFButton;
    ListBoxBtn: TFButton;
    ComboBoxBtn: TFButton;
    GridBtn: TFButton;
    MenuBtn: TFButton;
    PanelBtn: TFButton;
    ProgressBarBtn: TFButton;
    Separator: TSeparator;
    ExitBtn: TFButton;
    procedure CheckBoxBtnClick(Sender: TObject);
    procedure RadioButtonBtnClick(Sender: TObject);
    procedure GroupBoxBtnClick(Sender: TObject);
    procedure EditBtnClick(Sender: TObject);
    procedure ScrollBarBtnClick(Sender: TObject);
    procedure ScrollBoxBtnClick(Sender: TObject);
    procedure ListBoxBtnClick(Sender: TObject);
    procedure ComboBoxBtnClick(Sender: TObject);
    procedure GridBtnClick(Sender: TObject);
    procedure ExitBtnClick(Sender: TObject);
    procedure MenuBtnClick(Sender: TObject);
    procedure PanelBtnClick(Sender: TObject);
    procedure ProgressBarBtnClick(Sender: TObject);
  end;


  TTestForm = class(TFForm)
  end;


  TCheckboxForm = class(TTestForm)
    Box: TFBoxLayout;
    GrayCheckBox, CheckBox1, CheckBox2: TFCheckbox;
    procedure GrayCheckBoxClick(Sender: TObject);
  public
    constructor Create(AOwner: TComponent); override;
  end;


  TRadioButtonForm = class(TTestForm)
    Box, HorzBox, ButtonBox1, ButtonBox2: TFBoxLayout;
    GrayCheckBox: TFCheckbox;
    Radio1a, Radio1b, Radio2a, Radio2b: TFRadioButton;
    procedure GrayCheckBoxClick(Sender: TObject);
  public
    constructor Create(AOwner: TComponent); override;
  end;


  TGroupBoxForm = class(TTestForm)
    HorzBox, VertBox1, VertBox2: TFBoxLayout;
    GroupBox1, GroupBox2: TFGroupBox;
    GrayCheckBox: TFCheckbox;
    Button: TFButton;
    Radio1, Radio2, Radio3, Radio4, Radio5: TFRadioButton;
    procedure GrayCheckBoxClick(Sender: TObject);
    procedure ButtonClick(Sender: TObject);
    procedure RadioButtonClick(Sender: TObject);
  public
    constructor Create(AOwner: TComponent); override;
  end;


  { TEditForm }

  TEditForm = class(TTestForm)
    Grid: TFGridLayout;
    VertBox, HorzBox1, HorzBox2: TFBoxLayout;
    Label1, Label2, PasswordDisplay: TFLabel;
    Edit1, Edit2: TFEdit;
    GrayCheckBox1, GrayCheckBox2: TFCheckbox;
    Separator: TSeparator;
    cbBorderStyle: TFButton;
    procedure GrayCheckBox1Click(Sender: TObject);
    procedure GrayCheckBox2Click(Sender: TObject);
    procedure cbBorderStyleClick(Sender: TObject);
    procedure Edit2Change(Sender: TObject);
  public
    constructor Create(AOwner: TComponent); override;
  end;


  TScrollBarForm = class(TTestForm)
    VertLayout: TFBoxLayout;
    GrayCheckBox: TFCheckbox;
    HorzBox: TFBoxLayout;
    HorzGrid, VertGrid: TFGridLayout;
    VertBar: TSeparator;
    VerTFLabel, Label1, Label2, Label3, Label4, Label5: TFLabel;
    PosLabel1, PosLabel2, PosLabel3, PosLabel4, PosLabel5: TFLabel;
    VerTFScrollBar, ScrollBar1, ScrollBar2, ScrollBar3,
      ScrollBar4, ScrollBar5: TFScrollBar;
    procedure GrayCheckBoxClick(Sender: TObject);
    procedure ScrollBar1Change(Sender: TObject);
    procedure ScrollBar2Change(Sender: TObject);
    procedure ScrollBar3Change(Sender: TObject);
    procedure ScrollBar4Change(Sender: TObject);
    procedure ScrollBar5Change(Sender: TObject);
  public
    constructor Create(AOwner: TComponent); override;
  end;


  TScrollBoxForm = class(TTestForm)
    VertLayout: TFBoxLayout;
    Label1: TFLabel;
    ScrollBox: TFScrollBox;
  public
    constructor Create(AOwner: TComponent); override;
  end;


  TListBoxForm = class(TTestForm)
    ListBox: TFListBox;
  public
    constructor Create(AOwner: TComponent); override;
  end;


  TComboBoxForm = class(TTestForm)
  published
    VertLayout: TFBoxLayout;
    GrayCheckBox: TFCheckbox;
    BetaLabel: TFLabel;
    ComboBox1: TFComboBox;
    ComboBox2: TFComboBox;
    procedure GrayCheckBoxClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  public
    constructor Create(AOwner: TComponent); override;
  end;


  TGridForm = class(TTestForm)
    StringGrid: TFStringGrid;
    procedure FormCreate(Sender: TObject);
  public
    constructor Create(AOwner: TComponent); override;
  end;
  

  { TMenuForm }

  TMenuForm = class(TTestForm)
  private
    procedure   CloseMenuClicked(Sender: TObject);
    procedure   AboutMenuClicked(Sender: TObject);
  public
    constructor Create(AOwner: TComponent); override;
  published
    BoxLayout: TFBoxLayout;
    MainMenu: TFMenuBar;
    Title: TFLabel;
    p1, p2, p3, p4, p5, p6: TFPanel;
    MenuBox: TFBoxLayout;
  end;
  
  
  TPanelForm = class(TTestForm)
  private
    procedure   RadioButtonClick(Sender: TObject);
  public
    constructor Create(AOwner: TComponent); override;
    destructor  Destroy; override;
  published
    MainLayout: TFBoxLayout;
    StyleGroup: TFGroupBox;
    rbPlain, rbLowered, rbRaised: TFRadioButton;
    VBox1: TFBoxLayout;
    Panel: TFPanel;
    Separator: TSeparator;
  end;
  

  TProgressBarForm = class(TTestForm)
  private
    procedure   cbShowPercentClick(Sender: TObject);
    procedure   RadioButtonClick(Sender: TObject);
    procedure   GeneratePercentage(Sender: TObject);
  public
    constructor Create(AOwner: TComponent); override;
    destructor  Destroy; override;
  published
    MainLayout: TFGridLayout;
    VBox: TFBoxLayout;
    PB: TFProgressBar;
    cbShowPercent: TFCheckbox;
    gbColor: TFGroupBox;
    rbBlue: TFRadioButton;
    rbRed: TFRadioButton;
    rbGreen: TFRadioButton;
    Separator: TSeparator;
    btnRandom: TFButton;
  end;

{ TListBoxForm }

constructor TListBoxForm.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  LoadForm(self);
end;

{ TScrollBoxForm }

constructor TScrollBoxForm.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  LoadForm(self);
end;


{ TMenuForm }

procedure TMenuForm.CloseMenuClicked(Sender: TObject);
begin
  writeln('...Close menu clicked');
  Close;
end;

procedure TMenuForm.AboutMenuClicked(Sender: TObject);
begin
  writeln('   About menu clicked from <' + Sender.ClassName + '>');
  if Sender is TFMenuItem then
    writeln('   from: ' + TFMenuItem(Sender).Text);
end;

constructor TMenuForm.Create(AOwner: TComponent);
var
  lMenuItem: TFMenuItem;
begin
  inherited Create(AOwner);
  Name := 'MenuForm';
  Text := 'Menu Test';
  
  BoxLayout := TFBoxLayout.Create(self);
  BoxLayout.Orientation := Vertical;
  
  MainMenu := TFMenuBar.Create(self);
  BoxLayout.InsertChild(MainMenu);

  MainMenu.AddMenu('Close', 'C', @CloseMenuClicked);
//  MainMenu.AddMenu('File');
  MainMenu.AddMenu('Edit');
  MainMenu.AddMenu('Options');
  MainMenu.AddMenu('Windows');
  lMenuItem := MainMenu.AddMenu('Help');
  lMenuItem.SubMenu.AddMenu('Online Help');
  lMenuItem.SubMenu.AddMenu('Tutorials');
  lMenuItem.SubMenu.AddMenu('About', '', @AboutMenuClicked);

  Title := TFLabel.Create(self);
  Title.CanExpandWidth := True;
  Title.Alignment := taCenter;
  Title.Text := 'This is work in progress...';
  Title.FontColor := clBlue;
  BoxLayout.InsertChild(Title);

  Child := BoxLayout;
end;


{ TPanelForm }

procedure TPanelForm.RadioButtonClick(Sender: TObject);
begin
  case TFRadioButton(Sender).Tag of
    1: Panel.BevelStyle := bsPlain;
    2: Panel.BevelStyle := bsLowered;
    3: Panel.BevelStyle := bsRaised;
  end;
end;

constructor TPanelForm.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  Name := 'PanelForm';
  Text := 'Panel Test';
  BorderWidth := 8;

  MainLayout := TFBoxLayout.Create(self);
  MainLayout.Orientation := Vertical;
  
  StyleGroup := TFGroupBox.Create('Bevel Style:', self);
  StyleGroup.CanExpandWidth := True;
  MainLayout.InsertChild(StyleGroup);
  
  VBox1 := TFBoxLayout.Create(self);
  VBox1.Orientation := Vertical;
  StyleGroup.InsertChild(VBox1);
  
  rbPlain := TFRadioButton.Create('Plain', self);
  rbPlain.Tag := 1;
  rbPlain.OnClick := @RadioButtonClick;
  rbLowered := TFRadioButton.Create('Lowered', self);
  rbLowered.Tag := 2;
  rbLowered.OnClick := @RadioButtonClick;
  rbRaised := TFRadioButton.Create('Raised', self);
  rbRaised.Tag := 3;
  rbRaised.OnClick := @RadioButtonClick;
  rbRaised.Checked := True;
  VBox1.InsertChild(rbPlain);
  VBox1.InsertChild(rbLowered);
  VBox1.InsertChild(rbRaised);
  
  Separator := TSeparator.Create(self);
  MainLayout.InsertChild(Separator);

  Panel := TFPanel.Create('My Panel', self);
  MainLayout.InsertChild(Panel);
  
  Child := MainLayout;
end;

destructor TPanelForm.Destroy;
begin
  inherited Destroy;
end;


{ TProgressBarForm }

procedure TProgressBarForm.cbShowPercentClick(Sender: TObject);
begin
  PB.ShowPercentage := cbShowPercent.Checked;
end;

procedure TProgressBarForm.RadioButtonClick(Sender: TObject);
begin
  case TFRadioButton(Sender).Tag of
    1: PB.FillColor := clRed;
    2: PB.FillColor := clGreen;
    3: PB.FillColor := clBlue;
  end;
end;

procedure TProgressBarForm.GeneratePercentage(Sender: TObject);
begin
  PB.Position := Random(100);
end;

constructor TProgressBarForm.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  Text := 'Progress Bar Demo';
  BorderWidth := 8;

  MainLayout := TFGridLayout.Create(self);
  MainLayout.RowCount := 4;
  MainLayout.ColCount := 2;
  
  VBox := TFBoxLayout.Create(self);
  VBox.Orientation := Vertical;
  
  gbColor   := TFGroupBox.Create('Fill Color', self);
  rbRed           := TFRadioButton.Create('Red', self);
  rbRed.Tag       := 1;
  rbRed.OnClick   := @RadioButtonClick;
  rbRed.Checked   := True;

  rbGreen         := TFRadioButton.Create('Green', self);
  rbGreen.Tag     := 2;
  rbGreen.OnClick := @RadioButtonClick;

  rbBlue          := TFRadioButton.Create('Blue', self);
  rbBlue.Tag      := 3;
  rbBlue.OnClick  := @RadioButtonClick;

  VBox.InsertChild(rbRed);
  VBox.InsertChild(rbGreen);
  VBox.InsertChild(rbBlue);
  gbColor.InsertChild(VBox);
  MainLayout.AddWidget(gbColor, 0, 0, 1, 2);

  cbShowPercent := TFCheckbox.Create('Show Percentage', self);
  cbShowPercent.Checked := True;
  cbShowPercent.OnClick := @cbShowPercentClick;
  cbShowPercent.CanExpandWidth := True;
  MainLayout.AddWidget(cbShowPercent, 1, 0, 1, 1);
  
  btnRandom := TFButton.Create('Randomize', self);
  btnRandom.OnClick := @GeneratePercentage;
  MainLayout.AddWidget(btnRandom, 1, 1, 1, 1);

  Separator := TSeparator.Create(self);
  MainLayout.AddWidget(Separator, 0, 2, 2, 1);
  
  PB := TFProgressBar.Create('', self);
  PB.Position := 75;
  MainLayout.AddWidget(PB, 0, 3, 2, 1);
  
  Child := MainLayout;
end;

destructor TProgressBarForm.Destroy;
begin
  inherited Destroy;
end;


// -------------------------------------------------------------------
//   TMainForm
// -------------------------------------------------------------------

constructor TMainForm.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  LoadForm(self);
end;

destructor TMainForm.Destroy;
begin
  _frmCheckBox.Free;
  _frmRadioButton.Free;
  _frmGroupBox.Free;
  _frmEdit.Free;
  _frmScrollBar.Free;
  _frmScrollBox.Free;
  _frmListBox.Free;
  _frmComboBox.Free;
  _frmGrid.Free;
  _frmMenu.Free;
  _frmPanel.Free;
  _frmProgressBar.Free;
  inherited Destroy;
end;


procedure TMainForm.CheckBoxBtnClick(Sender: TObject);
begin
  if not Assigned(_frmCheckBox) then
    _frmCheckBox := TCheckboxForm.Create(self);
  _frmCheckBox.Show;
end;


procedure TMainForm.RadioButtonBtnClick(Sender: TObject);
begin
  if not Assigned(_frmRadioButton) then
    _frmRadioButton := TRadioButtonForm.Create(self);
  _frmRadioButton.Show;
end;


procedure TMainForm.GroupBoxBtnClick(Sender: TObject);
begin
  if not Assigned(_frmGroupBox) then
    _frmGroupBox := TGroupBoxForm.Create(self);
  _frmGroupBox.Show;
end;


procedure TMainForm.EditBtnClick(Sender: TObject);
begin
  if not Assigned(_frmEdit) then
    _frmEdit := TEditForm.Create(self);
  _frmEdit.Show;
end;


procedure TMainForm.ScrollBarBtnClick(Sender: TObject);
begin
  if not Assigned(_frmScrollBar) then
    _frmScrollBar := TScrollBarForm.Create(self);
  _frmScrollBar.Show;
end;


procedure TMainForm.ScrollBoxBtnClick(Sender: TObject);
begin
  if not Assigned(_frmScrollBox) then
    _frmScrollBox := TScrollBoxForm.Create(self);
  _frmScrollBox.Show;
end;


procedure TMainForm.ListBoxBtnClick(Sender: TObject);
begin
  if not Assigned(_frmListBox) then
    _frmListBox := TListBoxForm.Create(self);
  _frmListBox.Show;
end;


procedure TMainForm.ComboBoxBtnClick(Sender: TObject);
begin
  if not Assigned(_frmComboBox) then
    _frmComboBox := TComboBoxForm.Create(self);
  _frmComboBox.Show;
end;


procedure TMainForm.GridBtnClick(Sender: TObject);
begin
  if not Assigned(_frmGrid) then
    _frmGrid := TGridForm.Create(self);
  _frmGrid.Show;
end;


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


procedure TMainForm.MenuBtnClick(Sender: TObject);
begin
  if not Assigned(_frmMenu) then
    _frmMenu := TMenuForm.Create(self);
  _frmMenu.Show;
  _frmMenu.SetPosition(Point(Left + Width + 5, FindForm.Top));
end;

procedure TMainForm.PanelBtnClick(Sender: TObject);
begin
  if not Assigned(_frmPanel) then
    _frmPanel := TPanelForm.Create(self);
  _frmPanel.Show;
  _frmPanel.SetPosition(Point(Left + Width + 5, FindForm.Top));
end;

procedure TMainForm.ProgressBarBtnClick(Sender: TObject);
begin
  if not Assigned(_frmProgressBar) then
    _frmProgressBar := TProgressBarForm.Create(self);
  _frmProgressBar.Show;
  _frmProgressBar.SetPosition(Point(Left + Width + 5, FindForm.Top));
end;


// -------------------------------------------------------------------
//   TCheckboxForm
// -------------------------------------------------------------------

procedure TCheckboxForm.GrayCheckBoxClick(Sender: TObject);
begin
  CheckBox1.Enabled := not GrayCheckBox.Checked;
  CheckBox2.Enabled := not GrayCheckBox.Checked;
end;

constructor TCheckboxForm.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  LoadForm(self);
end;


// -------------------------------------------------------------------
//   TRadioButtonForm
// -------------------------------------------------------------------

procedure TRadioButtonForm.GrayCheckBoxClick(Sender: TObject);
begin
  HorzBox.Enabled := not GrayCheckBox.Checked;
end;

constructor TRadioButtonForm.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  LoadForm(self);
end;


// -------------------------------------------------------------------
//   TGroupBoxForm
// -------------------------------------------------------------------

procedure TGroupBoxForm.GrayCheckBoxClick(Sender: TObject);
begin
  GroupBox2.Enabled := not GrayCheckBox.Checked;
end;


procedure TGroupBoxForm.ButtonClick(Sender: TObject);
begin
  Radio1.Checked := True;
  Button.Enabled := False;
end;


procedure TGroupBoxForm.RadioButtonClick(Sender: TObject);
begin
  Button.Enabled := not Radio1.Checked;
end;

constructor TGroupBoxForm.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  LoadForm(self);
end;


// -------------------------------------------------------------------
//   TEditForm
// -------------------------------------------------------------------

procedure TEditForm.GrayCheckBox1Click(Sender: TObject);
begin
  Edit1.Enabled := not GrayCheckBox1.Checked;
end;


procedure TEditForm.GrayCheckBox2Click(Sender: TObject);
begin
  Edit2.Enabled := not GrayCheckBox2.Checked;
end;

procedure TEditForm.cbBorderStyleClick(Sender: TObject);
begin
  if Edit1.BorderStyle = bsNone then
  begin
    Edit1.BorderStyle := bsSingle;
    Edit2.BorderStyle := bsSingle;
  end
  else
  begin
    Edit1.BorderStyle := bsNone;
    Edit2.BorderStyle := bsNone;
  end;
end;


procedure TEditForm.Edit2Change(Sender: TObject);
begin
//  PasswordDisplay.Text := '(= ' + Edit2.Text + ')';
end;

constructor TEditForm.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  LoadForm(self);
end;


// -------------------------------------------------------------------
//   TScrollBarForm
// -------------------------------------------------------------------

procedure TScrollBarForm.GrayCheckBoxClick(Sender: TObject);
begin
  HorzBox.Enabled := not GrayCheckBox.Checked;
end;


procedure TScrollBarForm.ScrollBar1Change(Sender: TObject);
begin
  PosLabel1.Text := IntToStr(ScrollBar1.Position);
end;


procedure TScrollBarForm.ScrollBar2Change(Sender: TObject);
begin
  PosLabel2.Text := IntToStr(ScrollBar2.Position);
end;


procedure TScrollBarForm.ScrollBar3Change(Sender: TObject);
begin
  PosLabel3.Text := IntToStr(ScrollBar3.Position);
end;


procedure TScrollBarForm.ScrollBar4Change(Sender: TObject);
begin
  PosLabel4.Text := IntToStr(ScrollBar4.Position);
end;


procedure TScrollBarForm.ScrollBar5Change(Sender: TObject);
begin
  PosLabel5.Text := IntToStr(ScrollBar5.Position);
end;

constructor TScrollBarForm.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  LoadForm(self);
end;


// -------------------------------------------------------------------
//   TComboBoxForm
// -------------------------------------------------------------------

procedure TComboBoxForm.GrayCheckBoxClick(Sender: TObject);
begin
  ComboBox1.Enabled := not GrayCheckBox.Checked;
  ComboBox2.Enabled := not GrayCheckBox.Checked;
end;


procedure TComboBoxForm.FormCreate(Sender: TObject);
var
  i: integer;
begin
  for i := 1 to 20 do
  begin
    ComboBox1.Items.Add(Format('Item 1.%d...', [i]));
    ComboBox2.Items.Add(Format('Item 2.%d...', [i]));
  end;
  ComboBox2.Items.Add('A long item that should cause a horizontal scrollbar to appear.');
  BetaLabel.FontColor := clBlue;
end;

constructor TComboBoxForm.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  LoadForm(self);
end;


// -------------------------------------------------------------------
//   TGridForm
// -------------------------------------------------------------------

procedure TGridForm.FormCreate(Sender: TObject);
var
  x, y: Integer;
begin
  for y := 0 to StringGrid.RowCount - 1 do
    for x := 0 to StringGrid.ColCount - 1 do
      StringGrid.Cells[x, y] := Format('%d, %d', [x, y]);
end;

constructor TGridForm.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  LoadForm(self);
end;


var
  MainForm: TMainForm;
begin
  WriteLn('Version: ' + {$I %date%} + ' ' + {$I %time%});
  GFApplication.Initialize;
  
  MainForm := TMainForm.Create(GFApplication);
  try
    MainForm.Show;
    GFApplication.Run;
  finally
    MainForm.Free;
  end;
end.