summaryrefslogtreecommitdiff
path: root/examples/gui/alignment/aligntest.dpr
blob: 7099b761376b5925c4e67d7a915cda30f0e49a05 (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 aligntest;

{$mode objfpc}{$H+}

uses
  Classes, SysUtils,
  fpgfx, gfxbase, gfx_widget, gui_form, gui_label;

type
  TMainForm = class(TfpgForm)
  private
    lblTop: array[1..3] of TfpgLabel;
    lblBottom: array[1..3] of TfpgLabel;
    lblLeft: array[1..3] of TfpgLabel;
    lblRight: array[1..3] of TfpgLabel;
    lblClient: TfpgLabel;
    lblNone: TfpgLabel;
    AlignRect: TfpgRect;
  public
    procedure AfterCreate; override;
  end;
  

{ TMainForm }

procedure TMainForm.AfterCreate;
var
  x: integer;
  y: integer;
  n: integer;
  ColorArray: array[1..3] of TfpgColor;
begin
  x := 10;
  y := 10;
  ColorArray[1] := clDodgerBlue;
  ColorArray[2] := clDeepSkyBlue;
  ColorArray[3] := clSkyBlue;
  
  for n := low(lblTop) to high(lblTop) do
  begin
    lblTop[n] := CreateLabel(self, x, y, 'alTop '+IntToStr(n));
    lblTop[n].BackgroundColor := ColorArray[n];
    lblTop[n].Align := alTop;
    lblTop[n].Width := 100;
    inc(y,20);
  end;

  y := 280;
  for n:=low(lblBottom) to high(lblBottom) do
  begin
    lblBottom[n] := CreateLabel(self, x, y, 'alBottom '+IntToStr(n));
    lblBottom[n].BackgroundColor := ColorArray[n];
    lblBottom[n].Align := alBottom;
    dec(y,20);
  end;

  y := 100;
  x := 10;
  for n:=low(lblLeft) to high(lblLeft) do
  begin
    lblLeft[n] := CreateLabel(self, x, y, 'L'+IntToStr(n));
    lblLeft[n].BackgroundColor := ColorArray[n];
    lblLeft[n].Align := alLeft;
    inc(x,30);
  end;

  x := 200;
  for n:=low(lblRight) to high(lblRight) do
  begin
    lblRight[n] := CreateLabel(self, x, y, 'R'+IntToStr(n));
    lblRight[n].BackgroundColor := ColorArray[n];
    lblRight[n].Align := alRight;
    dec(x,30);
  end;

  lblClient := CreateLabel(self, 150, 150, 'alClient');
  lblClient.BackgroundColor := clWhite;
  lblClient.Align := alClient;

  lblNone := CreateLabel(self, 15, 120, 'Resize the form to see Align in action');
  lblNone.Color := clWhite;
  lblNone.BackgroundColor := clBlack;
end;


procedure MainProc;
var
  frm : TMainForm;
begin
  fpgApplication.Initialize;

  frm := TMainForm.Create(nil);
  frm.WindowPosition := wpScreenCenter;
  frm.Width       := 300;
  frm.Height      := 300;
  frm.MinWidth    := 250;
  frm.MinHeight   := 150;
  frm.WindowTitle := 'fpGUI Align Example';
  frm.Show;

  fpgApplication.Run;
end;

begin
  MainProc;
end.