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
|
program fontselect;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes,
fpgfx,
gui_form,
gui_dialogs,
gui_button,
gui_listbox,
gui_edit,
gui_label;
type
TMainForm = class(TfpgForm)
private
btnQuit: TfpgButton;
btnSelectFont: TfpgButton;
lbFontList: TfpgListBox;
edFontDesc: TfpgEdit;
lblFontList: TfpgLabel;
procedure btnQuitClick(Sender: TObject);
procedure btnSelectFontClick(Sender: TObject);
procedure CreateFontList;
public
constructor Create(AOwner: TComponent); override;
end;
{ TMainForm }
procedure TMainForm.btnQuitClick(Sender: TObject);
begin
Close;
end;
procedure TMainForm.btnSelectFontClick(Sender: TObject);
var
fontdesc: string;
begin
fontdesc := edFontDesc.Text;
if SelectFontDialog(fontdesc) then
edFontDesc.Text := fontdesc;
end;
procedure TMainForm.CreateFontList;
var
fl: TStringList;
i: integer;
begin
lbFontList.Items.Clear;
fl := fpgApplication.GetFontFaceList;
for i := 0 to fl.Count-1 do
lbFontList.Items.Add(fl.Strings[i]);
fl.Free;
end;
constructor TMainForm.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
WindowTitle := 'Font selection test';
SetPosition(100, 100, 500, 400);
btnSelectFont := CreateButton(self, 10, 10, 110, 'Select Font...', @btnSelectFontClick);
edFontDesc := CreateEdit(self, 10, 45, Width - 20, 24);
// edFontDesc.Text := fpgApplication.DefaultFont.FontDesc;
edFontDesc.Text := 'Bitstream Vera Sans-9';
lblFontList := CreateLabel(self, 10, 80, 'Font List:');
lbFontList := TfpgListBox.Create(self);
with lbFontList do
begin
SetPosition(10, 100, 232, 236);
Items.Clear;
end;
CreateFontList;
btnQuit := CreateButton(self, 415, 370, 80, 'Quit', @btnQuitClick);
btnQuit.ImageName := 'stdimg.Quit';
btnQuit.ShowImage := True;
btnQuit.Anchors := [anRight, anBottom];
btnSelectFont.TabOrder := 0;
end;
procedure MainProc;
var
frm: TMainForm;
begin
fpgApplication.Initialize;
frm := TMainForm.Create(nil);
frm.Show;
fpgApplication.Run;
frm.Free;
end;
begin
MainProc;
end.
|