File: speedtest.pp

package info (click to toggle)
lazarus 0.9.28.2-12
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 93,096 kB
  • ctags: 89,312
  • sloc: pascal: 820,189; xml: 202,194; makefile: 110,323; sh: 2,460; perl: 395; sql: 174; ansic: 133
file content (176 lines) | stat: -rw-r--r-- 4,547 bytes parent folder | download | duplicates (2)
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
{
 ***************************************************************************
 *                                                                         *
 *   This source is free software; you can redistribute it and/or modify   *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This code is distributed in the hope that it will be useful, but      *
 *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
 *   General Public License for more details.                              *
 *                                                                         *
 *   A copy of the GNU General Public License is available on the World    *
 *   Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also      *
 *   obtain it by writing to the Free Software Foundation,                 *
 *   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.        *
 *                                                                         *
 ***************************************************************************
}
program SpeedTest;

{$mode objfpc}{$H+}

uses 
  Interfaces, Forms, SysUtils, Buttons, Classes, StdCtrls, LCLType,
  LCLIntf, Graphics;

type
  TForm1 = class(TForm)
    cmdOK: TButton;
    SpeedButton1 : TSpeedButton;
    SpeedButton2 : TSpeedButton;
    SpeedButton3 : TSpeedButton;
    SpeedButton4 : TSpeedButton;
  private
    FPicture: TPixmap;
    procedure ButtonClick(Sender: TObject);
  protected
    procedure Paint; override;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  end;
  

constructor TForm1.Create(AOwner: TComponent); 
var
  S: TFileStream;
begin
  inherited Create(AOwner);
  Width := 300;
  Height := 150;

  cmdOK := TButton.Create(Self);
  with cmdOK do
  begin
    top := 0;
    left := 0;
    Height := 20;
    parent := Self;
    visible := true;
    onClick := @ButtonClick;
  end;

  SpeedButton1 := TSpeedButton.Create(Self);
  with Speedbutton1 do
  begin
    Parent := self;
    Enabled := True;
    Top := 25;
    Visible := True;
   end;

  SpeedButton2 := TSpeedButton.Create(Self);
  with Speedbutton2 do
  begin
    Parent := self;
    Enabled := True;
    Top := 25;
    Left := 25;
    Visible := True;
  end;

  SpeedButton3 := TSpeedButton.Create(Self);
  with Speedbutton3 do
  begin
    Parent := self;
    Enabled := True;
    Top := 50;
    Visible := True;
    Flat := True;
   end;

  SpeedButton4 := TSpeedButton.Create(Self);
  with Speedbutton4 do
  begin
    Parent := self;
    Enabled := True;
    Top := 50;
    Left := 25;
    Flat := True;
    Visible := True;
  end;

  S := TFileStream.Create('../images/penguin.xpm', fmOpenRead);
  try
    FPicture := TPixmap.Create;
    FPicture.TransparentColor := clBtnFace;
    FPicture.LoadFromStream(S);
  finally
    S.Free;
  end;
end;

destructor TForm1.Destroy;
begin
  FPicture.Free;
  inherited Destroy;
end;

procedure TForm1.Paint;
var
  r: TRect;
begin
  inherited Paint;
  Canvas.Copyrect(Bounds(100,0,139,160), FPicture.Canvas, Rect(0,0,138,159));
  
  with SpeedButton4 do
  begin
    Self.Canvas.MoveTo(Left + Width + 2, Top);
    Self.Canvas.LineTo(Left + Width + 12, Top);

    Self.Canvas.MoveTo(Left + Width + 2, Top + Height);
    Self.Canvas.LineTo(Left + Width + 12, Top + Height);

    Self.Canvas.MoveTo(Left, Top + Height + 2);
    Self.Canvas.LineTo(Left, Top + Height + 12);
    
    Self.Canvas.MoveTo(Left + Width, Top + Height + 2);
    Self.Canvas.LineTo(Left + Width, Top + Height + 12);

    R := Bounds(Left + Width + 13, Top, Width, Height);
  end;

  DrawEdge(Canvas.Handle, R, BDR_RAISEDOUTER, BF_RECT);

  with R do
  begin
    Canvas.MoveTo(Left, Bottom + 2);
    Canvas.LineTo(Left, Bottom + 12);

    Canvas.MoveTo(Right, Bottom + 2);
    Canvas.LineTo(Right, Bottom + 12);
  end;
end;

procedure TForm1.ButtonClick(Sender: TObject);
begin
end;


var
  Form1: TForm1;
  
  
begin
   WriteLN('------ INIT ------- ');
   Application.Initialize; { calls InitProcedure which starts up GTK }
   WriteLN('------ CREATE ------- ');
   Application.CreateForm(TForm1, Form1);
   WriteLN('------ RUN ------- ');
   Application.Run;
   WriteLN('------ DONE ------- ');
end.