~ubuntu-branches/ubuntu/vivid/lazarus/vivid

« back to all changes in this revision

Viewing changes to examples/lazfreetype/mainform.pas

  • Committer: Package Import Robot
  • Author(s): Paul Gevers, Abou Al Montacir, Paul Gevers
  • Date: 2014-02-22 10:25:57 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20140222102557-ors9d31r84nz31jq
Tags: 1.2~rc2+dfsg-1
[ Abou Al Montacir ]
* New upstream pre-release.
  + Moved ideintf to components directory.
  + Added new package cairocanvas.
* Remove usage of depreciated parameters form of find. (Closes: Bug#724776)
* Bumped standard version to 3.9.5.
* Clean the way handling make files generation and removal.

[ Paul Gevers ]
* Remove nearly obsolete bzip compression for binary packages
  (See https://lists.debian.org/debian-devel/2014/01/msg00542.html)
* Update d/copyright for newly added dir in examples and components
* Update Vcs-* fields with new packaging location
* Update d/watch file to properly (Debian way) change upstreams versions
* Prevent 46MB of package size by sym linking duplicate files
* Patches
  - refresh to remove fuzz
  - add more Lintian found spelling errors
  - new patch to add shbang to two scripts in lazarus-src
* Drop lcl-# from Provides list of lcl-units-#
* Make lazarus-ide-qt4-# an arch all until it really contains stuff
* Make all metapackages arch all as the usecase for arch any doesn't
  seem to warrant the addition archive hit
* Fix permissions of non-scripts in lazarus-src-#

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
uses
8
8
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
9
 
  ComCtrls, ExtCtrls, Spin, fpimage,
 
9
  ComCtrls, ExtCtrls, Spin, fpimage, LCLType,
10
10
 
11
11
  IntfGraphics, GraphType,      //Intf basic routines
12
12
 
19
19
  { TForm1 }
20
20
 
21
21
  TForm1 = class(TForm)
 
22
    CheckBox_Rect: TCheckBox;
22
23
    Label1: TLabel;
23
24
    LFontSize: TLabel;
24
25
    Panel_Option: TPanel;
25
26
    SpinEdit_Zoom: TSpinEdit;
26
27
    TrackBar_Size: TTrackBar;
 
28
    procedure CheckBox_RectChange(Sender: TObject);
27
29
    procedure FormCreate(Sender: TObject);
28
30
    procedure FormDestroy(Sender: TObject);
29
31
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
32
34
    procedure TrackBar_SizeChange(Sender: TObject);
33
35
  private
34
36
    procedure UpdateSizeLabel;
35
 
    { private declarations }
36
37
  public
37
 
    { public declarations }
38
38
    lazimg: TLazIntfImage;
39
39
    drawer: TIntfFreeTypeDrawer;
40
40
    ftFont1,ftFont2,ftFont3: TFreeTypeFont;
41
41
    mx,my: integer; //mouse position
 
42
    procedure EraseBackground(DC: HDC); override;
42
43
  end;
43
44
 
44
45
var
48
49
 
49
50
{ TForm1 }
50
51
 
 
52
procedure TForm1.EraseBackground(DC: HDC);
 
53
begin
 
54
  // empty
 
55
end;
 
56
 
51
57
procedure TForm1.FormCreate(Sender: TObject);
52
58
begin
53
59
  mx := clientwidth div 2;
83
89
  UpdateSizeLabel;
84
90
end;
85
91
 
 
92
procedure TForm1.CheckBox_RectChange(Sender: TObject);
 
93
begin
 
94
  invalidate;
 
95
end;
 
96
 
86
97
procedure TForm1.FormDestroy(Sender: TObject);
87
98
begin
88
99
  ftFont1.Free;
109
120
end;
110
121
 
111
122
procedure TForm1.FormPaint(Sender: TObject);
112
 
const testtext = 'Enjoy'+LineEnding+'and play!';
 
123
const testtext = 'The'#13#10'quick brown fox jumps over the lazy dog';
113
124
var bmp: TBitmap;
114
125
    tx,ty: integer;
115
126
    p: array of TCharPosition;
138
149
  ftFont1.ClearType := true;
139
150
  ftFont1.Quality := grqHighQuality;
140
151
  ftFont1.SmallLinePadding := false;
141
 
  drawer.DrawText(ftFont1.Information[ftiFullName], ftFont1, x, y, colBlack, [ftaRight, ftaBottom]);
 
152
  if CheckBox_Rect.Checked then
 
153
    drawer.DrawTextRect(testtext, ftFont1, 0,0, tx/3,ty, colBlack, [ftaLeft, ftaBottom])
 
154
  else
 
155
    drawer.DrawText(ftFont1.Information[ftiFullName], ftFont1, x, y, colBlack, [ftaRight, ftaBottom]);
142
156
 
143
157
  ftFont2.Hinted := false;
144
158
  ftFont2.ClearType := false;
145
159
  ftFont2.Quality := grqHighQuality;
146
 
  drawer.DrawText(ftFont2.Information[ftiFullName], ftFont2, x, y, colRed, 192, [ftaCenter, ftaBaseline]);
 
160
  if CheckBox_Rect.Checked then
 
161
    drawer.DrawTextRect(testtext, ftFont2, tx/3,0, 2*tx/3,ty, colRed, [ftaCenter, ftaVerticalCenter])
 
162
  else
 
163
    drawer.DrawText(ftFont2.Information[ftiFullName], ftFont2, x, y, colRed, 192, [ftaCenter, ftaBaseline]);
147
164
 
148
165
  ftFont3.Hinted := false;
149
166
  ftFont3.ClearType := false;
150
167
  ftFont3.Quality := grqMonochrome;
151
 
  drawer.DrawText(ftFont3.Information[ftiFullName]+' '+ftFont3.VersionNumber, ftFont3, x, y, colBlack, 128, [ftaLeft, ftaTop]);
 
168
  if CheckBox_Rect.Checked then
 
169
    drawer.DrawTextRect(testtext, ftFont3, 2*tx/3,0, tx,ty, colBlue, [ftaRight, ftaTop])
 
170
  else
 
171
    drawer.DrawText(ftFont3.Information[ftiFullName]+' '+ftFont3.VersionNumber, ftFont3, x, y, colBlack, 128, [ftaLeft, ftaTop]);
152
172
 
153
 
  p := ftFont1.CharsPosition(ftFont1.Information[ftiFullName],[ftaRight, ftaBottom]);
154
 
  for i := 0 to high(p) do
 
173
  if not CheckBox_Rect.Checked then
155
174
  begin
156
 
    drawer.DrawVertLine(round(x+p[i].x),round(y+p[i].yTop),round(y+p[i].yBottom), TColorToFPColor(clBlue));
157
 
    drawer.DrawHorizLine(round(x+p[i].x),round(y+p[i].yBase),round(x+p[i].x+p[i].width), TColorToFPColor(clBlue));
 
175
    p := ftFont1.CharsPosition(ftFont1.Information[ftiFullName],[ftaRight, ftaBottom]);
 
176
    for i := 0 to high(p) do
 
177
    begin
 
178
      drawer.DrawVertLine(round(x+p[i].x),round(y+p[i].yTop),round(y+p[i].yBottom), TColorToFPColor(clBlue));
 
179
      drawer.DrawHorizLine(round(x+p[i].x),round(y+p[i].yBase),round(x+p[i].x+p[i].width), TColorToFPColor(clBlue));
 
180
    end;
158
181
  end;
159
182
 
160
183
  EndTime := Now;