summaryrefslogtreecommitdiff
path: root/examples/gui/bevel/beveltest.lpr
blob: e339825e7e82650beb0289bdb80fc5e145d08d74 (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
program beveltest;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes,
  typinfo,
  fpgfx,
  gui_form,
  gui_button,
  gui_bevel,
  gui_label;
  
type
  TMainForm = class(TfpgForm)
  private
    bevel: TfpgBevel;
    btnQuit: TfpgButton;
    btnStyles: TfpgButton;
    btnShapes: TfpgButton;
    lblTitle: TfpgLabel;
    lblStyle: TfpgLabel;
    lblShape: TfpgLabel;
    lblNext: TfpgLabel;
    procedure   btnQuitClick(Sender: TObject);
    procedure   btnStylesClick(Sender: TObject);
    procedure   btnShapesClick(Sender: TObject);
  public
    constructor Create(AOwner: TComponent); override;
  end;

{ TMainForm }

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

procedure TMainForm.btnStylesClick(Sender: TObject);
begin
  if Bevel.Style = bsRaised then
  begin
    Bevel.Style     := bsLowered;
    lblStyle.Text   := 'Bevel is bsLowered';
    btnStyles.Text  := 'bsRaised';
  end
  else
  begin
    Bevel.Style     := bsRaised;
    lblStyle.Text   := 'Bevel is bsRaised';
    btnStyles.Text  := 'bsLowered';
  end;
end;

procedure TMainForm.btnShapesClick(Sender: TObject);
var
  next: TBevelShape;
begin
  if Bevel.Shape = High(TBevelShape) then
    Bevel.Shape := Low(TBevelShape)
  else
    Bevel.Shape := TBevelShape(Ord(Bevel.Shape) + 1);
  lblShape.Text := 'Shape is ' + GetEnumName(TypeInfo(TBevelShape), Ord(Bevel.Shape));
  
  if Bevel.Shape = High(TBevelShape) then
    next := Low(TBevelShape)
  else
    next := TBevelShape(Ord(Bevel.Shape) + 1);
  btnShapes.Text := GetEnumName(TypeInfo(TBevelShape), Ord(next));
end;

constructor TMainForm.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  WindowTitle := 'Bevel test';
  SetPosition(100, 100, 300, 250);
  
  lblTitle  := CreateLabel(self, 6, 6, 'Click buttons to change properties');
  bevel     := CreateBevel(self, 20, 30, 150, 150, bsBox, bsRaised);

  btnQuit   := CreateButton(self, 210, 220, 80, 'Quit', @btnQuitClick);
  btnQuit.ImageName := 'stdimg.quit';
  btnQuit.ShowImage := True;
  
  lblNext   := CreateLabel(self, 200, 80, 'Next value is...');
  btnShapes := CreateButton(self, 200, 100, 90, 'bsFrame', @btnShapesClick);
  btnStyles := CreateButton(self, 200, 130, 90, 'bsLowered', @btnStylesClick);

  lblShape  := CreateLabel(self, 6, 190, 'Shape is bsBox');
  lblStyle  := CreateLabel(self, 6, 210, 'Style is bsRaised');
end;


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

begin
  MainProc;
end.