mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-05 11:38:04 +02:00
Examples/FontEnum: Fix font styles. Anchored layout.
This commit is contained in:
parent
cefa008446
commit
f0223d2d37
@ -11,8 +11,12 @@
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<Title Value="project1"/>
|
||||
<Scaled Value="True"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<XPManifest>
|
||||
<DpiAware Value="True"/>
|
||||
</XPManifest>
|
||||
</General>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="default" Default="True"/>
|
||||
@ -49,10 +53,6 @@
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<DebugInfoType Value="dsDwarf3"/>
|
||||
<UseExternalDbgSyms Value="True"/>
|
||||
</Debugging>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
|
@ -10,6 +10,8 @@ uses
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
Application.Scaled:=True;
|
||||
Application.Title:='project1';
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TfrmMain, frmMain);
|
||||
Application.Run;
|
||||
|
@ -1,121 +1,174 @@
|
||||
object frmMain: TfrmMain
|
||||
Left = 33
|
||||
Height = 440
|
||||
Top = 116
|
||||
Width = 714
|
||||
Left = 216
|
||||
Height = 403
|
||||
Top = 153
|
||||
Width = 709
|
||||
HorzScrollBar.Page = 713
|
||||
VertScrollBar.Page = 439
|
||||
ActiveControl = lbFamily
|
||||
Caption = 'frmMain'
|
||||
ClientHeight = 440
|
||||
ClientWidth = 714
|
||||
Caption = 'Font Enumeration'
|
||||
ClientHeight = 403
|
||||
ClientWidth = 709
|
||||
OnCloseQuery = FormCloseQuery
|
||||
OnCreate = FormCreate
|
||||
OnShow = FormShow
|
||||
ShowHint = True
|
||||
LCLVersion = '2.3.0.0'
|
||||
object Label3: TLabel
|
||||
Left = 548
|
||||
Height = 15
|
||||
Top = 257
|
||||
Width = 27
|
||||
Caption = 'Filtro'
|
||||
end
|
||||
object Label4: TLabel
|
||||
Left = 216
|
||||
object lflFontFaceList: TLabel
|
||||
AnchorSideLeft.Control = lbFamily
|
||||
AnchorSideTop.Control = lblFilter
|
||||
Left = 222
|
||||
Height = 15
|
||||
Top = 16
|
||||
Width = 67
|
||||
Caption = 'Face font list'
|
||||
end
|
||||
object Label5: TLabel
|
||||
Left = 424
|
||||
object lblStyles: TLabel
|
||||
AnchorSideLeft.Control = lbStyles
|
||||
AnchorSideTop.Control = lblFilter
|
||||
Left = 416
|
||||
Height = 15
|
||||
Top = 11
|
||||
Top = 16
|
||||
Width = 30
|
||||
Caption = 'Styles'
|
||||
end
|
||||
object Sizes: TLabel
|
||||
Left = 648
|
||||
object lblSizes: TLabel
|
||||
AnchorSideLeft.Control = lbSizes
|
||||
AnchorSideTop.Control = lblFilter
|
||||
Left = 624
|
||||
Height = 15
|
||||
Top = 11
|
||||
Top = 16
|
||||
Width = 25
|
||||
Caption = 'Sizes'
|
||||
end
|
||||
object lblCharset: TLabel
|
||||
Left = 424
|
||||
AnchorSideLeft.Control = lbStyles
|
||||
AnchorSideTop.Control = lbSizes
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 416
|
||||
Height = 15
|
||||
Top = 176
|
||||
Width = 53
|
||||
Caption = 'lblCharset'
|
||||
Top = 145
|
||||
Width = 41
|
||||
Caption = 'CharSet'
|
||||
end
|
||||
object Label6: TLabel
|
||||
Left = 11
|
||||
object lblFilter: TLabel
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = Owner
|
||||
Left = 16
|
||||
Height = 15
|
||||
Top = 16
|
||||
Width = 26
|
||||
BorderSpacing.Left = 16
|
||||
BorderSpacing.Top = 16
|
||||
Caption = 'Filter'
|
||||
end
|
||||
object lbFamily: TListBox
|
||||
Left = 216
|
||||
Height = 272
|
||||
Top = 32
|
||||
Width = 200
|
||||
AnchorSideLeft.Control = cbCharset
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = cbCharset
|
||||
AnchorSideRight.Control = lbStyles
|
||||
Left = 222
|
||||
Height = 239
|
||||
Top = 33
|
||||
Width = 186
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Left = 12
|
||||
BorderSpacing.Right = 8
|
||||
ItemHeight = 0
|
||||
OnClick = lbFamilyClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object cbCharset: TComboBox
|
||||
Left = 8
|
||||
AnchorSideLeft.Control = lblFilter
|
||||
AnchorSideTop.Control = lblFilter
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 16
|
||||
Height = 23
|
||||
Top = 37
|
||||
Top = 33
|
||||
Width = 194
|
||||
BorderSpacing.Top = 2
|
||||
DropDownCount = 24
|
||||
ItemHeight = 15
|
||||
TabOrder = 1
|
||||
Text = 'ANSI_CHARSET'
|
||||
end
|
||||
object Button2: TButton
|
||||
Left = 8
|
||||
Height = 25
|
||||
Top = 96
|
||||
Width = 75
|
||||
object btnApplyFilter: TButton
|
||||
AnchorSideLeft.Control = lblFilter
|
||||
AnchorSideTop.Control = cbPitch
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 16
|
||||
Height = 33
|
||||
Top = 99
|
||||
Width = 92
|
||||
AutoSize = True
|
||||
BorderSpacing.Top = 16
|
||||
BorderSpacing.InnerBorder = 4
|
||||
Caption = 'apply filter'
|
||||
OnClick = Button2Click
|
||||
Caption = 'Apply filter'
|
||||
OnClick = btnApplyFilterClick
|
||||
TabOrder = 2
|
||||
end
|
||||
object lbStyles: TListBox
|
||||
Left = 424
|
||||
Height = 128
|
||||
Top = 32
|
||||
Width = 208
|
||||
AnchorSideTop.Control = cbCharset
|
||||
AnchorSideRight.Control = lbSizes
|
||||
AnchorSideBottom.Control = lblCharset
|
||||
Left = 416
|
||||
Height = 104
|
||||
Top = 33
|
||||
Width = 200
|
||||
Anchors = [akTop, akRight, akBottom]
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
ItemHeight = 0
|
||||
OnClick = lbStylesClick
|
||||
TabOrder = 3
|
||||
end
|
||||
object lbSizes: TListBox
|
||||
Left = 640
|
||||
Height = 272
|
||||
Top = 32
|
||||
Width = 56
|
||||
AnchorSideLeft.Control = chkUnderLine
|
||||
AnchorSideTop.Control = cbCharset
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = lbFamily
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 624
|
||||
Height = 239
|
||||
Top = 33
|
||||
Width = 69
|
||||
Anchors = [akTop, akRight, akBottom]
|
||||
BorderSpacing.Right = 16
|
||||
ItemHeight = 0
|
||||
OnClick = lbSizesClick
|
||||
TabOrder = 4
|
||||
end
|
||||
object lbCharset: TListBox
|
||||
Left = 424
|
||||
Height = 112
|
||||
Top = 192
|
||||
Width = 208
|
||||
AnchorSideLeft.Control = lbStyles
|
||||
AnchorSideTop.Control = lblCharset
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = lbSizes
|
||||
AnchorSideBottom.Control = lbFamily
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 416
|
||||
Height = 110
|
||||
Top = 162
|
||||
Width = 200
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Top = 2
|
||||
BorderSpacing.Right = 8
|
||||
ItemHeight = 0
|
||||
OnClick = lbCharsetClick
|
||||
TabOrder = 5
|
||||
end
|
||||
object cbPitch: TComboBox
|
||||
Left = 8
|
||||
AnchorSideLeft.Control = lblFilter
|
||||
AnchorSideTop.Control = cbCharset
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = cbCharset
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 16
|
||||
Height = 23
|
||||
Top = 61
|
||||
Top = 60
|
||||
Width = 194
|
||||
BorderSpacing.Top = 4
|
||||
DropDownCount = 24
|
||||
ItemHeight = 15
|
||||
ItemIndex = 0
|
||||
Items.Strings = (
|
||||
@ -127,64 +180,96 @@ object frmMain: TfrmMain
|
||||
TabOrder = 6
|
||||
Text = 'DEFAULT_PITCH'
|
||||
end
|
||||
object BtnFontDlg: TButton
|
||||
Left = 56
|
||||
Height = 40
|
||||
Top = 368
|
||||
Width = 152
|
||||
object btnFontDlg: TButton
|
||||
AnchorSideLeft.Control = btnResetText
|
||||
AnchorSideTop.Control = btnResetText
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = btnResetText
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 81
|
||||
Height = 33
|
||||
Top = 321
|
||||
Width = 129
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.InnerBorder = 4
|
||||
Caption = 'Font Dlg'
|
||||
OnClick = BtnFontDlgClick
|
||||
OnClick = btnFontDlgClick
|
||||
TabOrder = 7
|
||||
end
|
||||
object chkStrike: TCheckBox
|
||||
Left = 591
|
||||
AnchorSideLeft.Control = chkUnderLine
|
||||
AnchorSideTop.Control = grid
|
||||
Left = 624
|
||||
Height = 19
|
||||
Top = 312
|
||||
Width = 67
|
||||
Top = 280
|
||||
Width = 65
|
||||
Caption = 'Strikeout'
|
||||
OnChange = chkStrikeChange
|
||||
TabOrder = 8
|
||||
end
|
||||
object chkUnderLine: TCheckBox
|
||||
Left = 592
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = chkStrike
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = lbSizes
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 624
|
||||
Height = 19
|
||||
Top = 336
|
||||
Width = 74
|
||||
Caption = 'UnderLine'
|
||||
Top = 303
|
||||
Width = 69
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.Top = 4
|
||||
Caption = 'Underline'
|
||||
OnChange = chkUnderLineChange
|
||||
TabOrder = 9
|
||||
end
|
||||
object Button1: TButton
|
||||
Left = 56
|
||||
Height = 41
|
||||
Top = 312
|
||||
Width = 153
|
||||
object btnResetText: TButton
|
||||
AnchorSideTop.Control = grid
|
||||
AnchorSideRight.Control = cbPitch
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 81
|
||||
Height = 33
|
||||
Top = 280
|
||||
Width = 129
|
||||
Anchors = [akTop, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.InnerBorder = 4
|
||||
Caption = 'Reset Sample Text'
|
||||
OnClick = Button1Click
|
||||
OnClick = btnResetTextClick
|
||||
TabOrder = 10
|
||||
end
|
||||
object grid: TStringGrid
|
||||
Left = 216
|
||||
Height = 120
|
||||
Top = 312
|
||||
Width = 368
|
||||
AnchorSideLeft.Control = lbFamily
|
||||
AnchorSideTop.Control = lbFamily
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = chkUnderLine
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 222
|
||||
Height = 107
|
||||
Top = 280
|
||||
Width = 394
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
AutoFillColumns = True
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 16
|
||||
ColCount = 1
|
||||
DefaultRowHeight = 17
|
||||
FixedCols = 0
|
||||
FixedRows = 0
|
||||
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goThumbTracking, goSmoothScroll]
|
||||
Options = [goFixedVertLine, goFixedHorzLine, goHorzLine, goRangeSelect, goEditing, goThumbTracking, goSmoothScroll]
|
||||
TabOrder = 11
|
||||
ColWidths = (
|
||||
368
|
||||
390
|
||||
)
|
||||
end
|
||||
object FontDialog1: TFontDialog
|
||||
MinFontSize = 0
|
||||
MaxFontSize = 0
|
||||
Left = 312
|
||||
Top = 384
|
||||
Left = 248
|
||||
Top = 320
|
||||
end
|
||||
end
|
||||
|
@ -13,28 +13,27 @@ type
|
||||
{ TfrmMain }
|
||||
|
||||
TfrmMain = class(TForm)
|
||||
Button1: TButton;
|
||||
Button2: TButton;
|
||||
BtnFontDlg: TButton;
|
||||
btnResetText: TButton;
|
||||
btnApplyFilter: TButton;
|
||||
btnFontDlg: TButton;
|
||||
cbCharset: TComboBox;
|
||||
cbPitch: TComboBox;
|
||||
chkStrike: TCheckBox;
|
||||
chkUnderLine: TCheckBox;
|
||||
FontDialog1: TFontDialog;
|
||||
Label3: TLabel;
|
||||
Label4: TLabel;
|
||||
Label5: TLabel;
|
||||
lflFontFaceList: TLabel;
|
||||
lblStyles: TLabel;
|
||||
lblCharset: TLabel;
|
||||
Label6: TLabel;
|
||||
Sizes: TLabel;
|
||||
lblFilter: TLabel;
|
||||
lblSizes: TLabel;
|
||||
lbFamily: TListBox;
|
||||
lbStyles: TListBox;
|
||||
lbSizes: TListBox;
|
||||
lbCharset: TListBox;
|
||||
grid: TStringGrid;
|
||||
procedure BtnFontDlgClick(Sender: TObject);
|
||||
procedure Button1Click(Sender: TObject);
|
||||
procedure Button2Click(Sender: TObject);
|
||||
procedure btnFontDlgClick(Sender: TObject);
|
||||
procedure btnResetTextClick(Sender: TObject);
|
||||
procedure btnApplyFilterClick(Sender: TObject);
|
||||
procedure chkStrikeChange(Sender: TObject);
|
||||
procedure chkUnderLineChange(Sender: TObject);
|
||||
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
||||
@ -115,15 +114,28 @@ begin
|
||||
LCharsets.AddObject(s, TObject(ptrint(eLogFont.elfLogFont.lfCharSet)));
|
||||
exit;
|
||||
end;
|
||||
|
||||
// collect styles
|
||||
s :=eLogFont.elfStyle;
|
||||
if LStyles.IndexOf(s)<0 then begin
|
||||
// encode bold, italic
|
||||
n := eLogFont.elfLogFont.lfItalic;
|
||||
if eLogFont.elfLogFont.lfWeight > FW_MEDIUM then
|
||||
// encode bold (bit 0), italic (bit 1) -- see SelectFont
|
||||
n := 0;
|
||||
{$IFDEF LCLWin32}
|
||||
if (eLogFont.elfLogFont.lfItalic <> 0) then
|
||||
n := n or 1;
|
||||
if (eLogFont.elfLogFont.lfWeight > FW_MEDIUM) then
|
||||
n := n or 2;
|
||||
{$ENDIF}
|
||||
{$IF DEFINED(LCLGtk2) or DEFINED(LCLGtk3) or DEFINED(LCLQt) or DEFINED(LCLQt5)}
|
||||
s := Lowercase(s);
|
||||
if (pos('italic', s) <> 0) or (pos('oblique', s) <> 0) then
|
||||
n := n or 1;
|
||||
if (pos('bold', s) <> 0) then
|
||||
n := n or 2;
|
||||
{$ENDIF}
|
||||
LStyles.AddObject(eLogFont.elfStyle, TObject(ptrint(n)));
|
||||
end;
|
||||
|
||||
// collect sizes
|
||||
if FontType=TRUETYPE_FONTTYPE then
|
||||
NeedTTF := True
|
||||
@ -141,18 +153,18 @@ begin
|
||||
result := 1;
|
||||
end;
|
||||
|
||||
procedure TfrmMain.BtnFontDlgClick(Sender: TObject);
|
||||
procedure TfrmMain.btnFontDlgClick(Sender: TObject);
|
||||
begin
|
||||
if FontDialog1.Execute then
|
||||
UpdateFont(FontDialog1.Font);
|
||||
end;
|
||||
|
||||
procedure TfrmMain.Button1Click(Sender: TObject);
|
||||
procedure TfrmMain.btnResetTextClick(Sender: TObject);
|
||||
begin
|
||||
ResetSampleText;
|
||||
end;
|
||||
|
||||
procedure TfrmMain.Button2Click(Sender: TObject);
|
||||
procedure TfrmMain.btnApplyFilterClick(Sender: TObject);
|
||||
begin
|
||||
LoadFontList;
|
||||
end;
|
||||
@ -298,7 +310,7 @@ begin
|
||||
else
|
||||
result := DEFAULT_PITCH;
|
||||
end;
|
||||
Button2.Caption := IntToStr(result);
|
||||
btnApplyFilter.Caption := IntToStr(result);
|
||||
end;
|
||||
|
||||
procedure TfrmMain.EnableEvents(Ok: boolean; Lb: TListbox = nil);
|
||||
@ -353,12 +365,8 @@ begin
|
||||
F.Style := [];
|
||||
if i and 1 <> 0 then F.Style := F.Style + [fsItalic];
|
||||
if i and 2 <> 0 then F.Style := F.Style + [fsBold];
|
||||
if chkUnderLine.Checked
|
||||
then F.Style := F.Style + [fsUnderline]
|
||||
else F.Style := F.Style - [fsUnderline];
|
||||
if chkStrike.Checked
|
||||
then F.Style := F.Style + [fsStrikeOut]
|
||||
else F.Style := F.Style - [fsStrikeOut];
|
||||
if chkUnderLine.Checked then F.Style := F.Style + [fsUnderline];
|
||||
if chkStrike.Checked then F.Style := F.Style + [fsStrikeOut];
|
||||
UpdateFont(F);
|
||||
SaveSelection;
|
||||
finally
|
||||
@ -474,7 +482,7 @@ begin
|
||||
end;
|
||||
LoadFamilyFonts(-1);
|
||||
|
||||
Label4.Caption := format('Fontfaces, found %d, %d ms',[lbFamily.Items.Count, FTime]);
|
||||
lflFontFaceList.Caption := format('Fontfaces, found %d, %d ms',[lbFamily.Items.Count, FTime]);
|
||||
finally
|
||||
EnableEvents(True, lbFamily);
|
||||
ReleaseDC(0, DC);
|
||||
|
Loading…
Reference in New Issue
Block a user