source: cprs/branches/tmg-cprs/dklang-package-3.01/Examples/Frames/ufrFontSettings.pas@ 1623

Last change on this file since 1623 was 468, checked in by Kevin Toppenberg, 16 years ago

CPRS v1.0.26.76

File size: 1.7 KB
Line 
1unit ufrFontSettings;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, TntForms,
7 Dialogs, DKLang, StdCtrls, ExtCtrls, TntStdCtrls, TntExtCtrls;
8
9type
10 TfrFontSettings = class(TTntFrame)
11 bSelectFont: TTntButton;
12 gbMain: TTntGroupBox;
13 lcMain: TDKLanguageController;
14 pSample: TTntPanel;
15 procedure bSelectFontClick(Sender: TObject);
16 private
17 // Prop handlers
18 function GetSelectedFont: TFont;
19 function GetTitle: WideString;
20 procedure SetSelectedFont(Value: TFont);
21 procedure SetTitle(const Value: WideString);
22 public
23 // Props
24 // -- Frame title, assigned at runtime (we cannot localize it at design time since all of the controllers share the
25 // same translation in this example)
26 property Title: WideString read GetTitle write SetTitle;
27 // -- A font selected in the editor
28 property SelectedFont: TFont read GetSelectedFont write SetSelectedFont;
29 end;
30
31implementation
32{$R *.dfm}
33
34 procedure TfrFontSettings.bSelectFontClick(Sender: TObject);
35 var fd: TFontDialog;
36 begin
37 fd := TFontDialog.Create(Self);
38 try
39 fd.Font.Assign(SelectedFont);
40 if fd.Execute then SelectedFont := fd.Font;
41 finally
42 fd.Free;
43 end;
44 end;
45
46 function TfrFontSettings.GetSelectedFont: TFont;
47 begin
48 Result := pSample.Font;
49 end;
50
51 function TfrFontSettings.GetTitle: WideString;
52 begin
53 Result := gbMain.Caption;
54 end;
55
56 procedure TfrFontSettings.SetSelectedFont(Value: TFont);
57 begin
58 pSample.Font.Assign(Value);
59 end;
60
61 procedure TfrFontSettings.SetTitle(const Value: WideString);
62 begin
63 gbMain.Caption := Value;
64 end;
65
66end.
67
Note: See TracBrowser for help on using the repository browser.