📄 spdialogs.pas
字号:
FontSizeLabel := TspSkinStdLabel.Create(Self);
with FontSizeLabel do
begin
Left := 5;
Top := 95;
if ResStrData <> nil
then
Caption := ResStrData.GetResStr('FONTDLG_SIZE')
else
Caption := SP_FONTDLG_SIZE;
AutoSize := True;
Parent := Self;
end;
FontSizeEdit := TspSkinSpinEdit.Create(Self);
with FontSizeEdit do
begin
MinValue := -128;
MaxValue := 128;
Increment := 2;
Left := 5;
Top := 110;
Parent := Self;
Width := 90;
OnChange := FontSizeChange;
end;
FontHeightLabel := TspSkinStdLabel.Create(Self);
with FontHeightLabel do
begin
Left := 110;
Top := 95;
if ResStrData <> nil
then
Caption := ResStrData.GetResStr('FONTDLG_HEIGHT')
else
Caption := SP_FONTDLG_Height;
AutoSize := True;
Parent := Self;
end;
FontHeightEdit := TspSkinSpinEdit.Create(Self);
with FontHeightEdit do
begin
MinValue := -500;
MaxValue := 500;
Left := 110;
Top := 110;
Width := 95;
Parent := Self;
OnChange := FontHeightChange;
end;
ScriptLabel := TspSkinStdLabel.Create(Self);
with ScriptLabel do
begin
Left := 5;
Top := 140;
if ResStrData <> nil
then
Caption := ResStrData.GetResStr('FONTDLG_SCRIPT')
else
Caption := SP_FONTDLG_SCRIPT;
AutoSize := True;
Parent := Self;
end;
ScriptComboBox := TspSkinComboBox.Create(Self);
with ScriptComboBox do
begin
Left := 5;
Top := 155;
Width := 200;
DefaultHeight := 21;
Parent := Self;
TabOrder := 4;
TabStop := True;
for I := 0 to 18 do
Items.Add(ScriptNames[I]);
OnChange := FontScriptChange;
end;
FontExLabel := TspSkinStdLabel.Create(Self);
with FontExLabel do
begin
Left := 210;
Top := 50;
if ResStrData <> nil
then
Caption := ResStrData.GetResStr('FONTDLG_EXAMPLE')
else
Caption := SP_FONTDLG_EXAMPLE;
AutoSize := True;
Parent := Self;
end;
FontExamplePanel := TspSkinPanel.Create(Self);
with FontExamplePanel do
begin
Parent := Self;
BorderStyle := bvFrame;
Left := 210;
Top := 65;
Width := 185;
Height := 67;
end;
FontExampleLabel := TLabel.Create(Self);
with FontExampleLabel do
begin
Parent := FontExamplePanel;
Transparent := True;
Align := alClient;
Caption := 'AaBbYyZz';
end;
OkButton := TspSkinButton.Create(Self);
with OkButton do
begin
if ResStrData <> nil
then
Caption := ResStrData.GetResStr('MSG_BTN_OK')
else
Caption := SP_MSG_BTN_OK;
CanFocused := True;
Left := 230;
Top := 190;
Width := 75;
DefaultHeight := 25;
Parent := Self;
ModalResult := mrOk;
end;
CancelButton := TspSkinButton.Create(Self);
with CancelButton do
begin
if ResStrData <> nil
then
Caption := ResStrData.GetResStr('MSG_BTN_CANCEL')
else
Caption := SP_MSG_BTN_CANCEL;
CanFocused := True;
Left := 320;
Top := 190;
Width := 75;
DefaultHeight := 25;
Parent := Self;
ModalResult := mrCancel;
Cancel := True;
end;
FontStyleLabel := TspSkinStdLabel.Create(Self);
with FontStyleLabel do
begin
Left := 210;
Top := 5;
if ResStrData <> nil
then
Caption := ResStrData.GetResStr('FONTDLG_STYLE')
else
Caption := SP_FONTDLG_STYLE;
AutoSize := True;
Parent := Self;
end;
BoldButton := TspSkinSpeedButton.Create(Self);
with BoldButton do
begin
Parent := Self;
AllowAllUp := True;
DefaultWidth := 25;
DefaultHeight := 25;
SkinDataName := 'toolbutton';
GroupIndex := 1;
NumGlyphs := 1;
Left := 245;
Top := 20;
Glyph.LoadFromResourceName(HInstance, 'SP_BOLD');
OnClick := BoldButtonClick;
end;
ItalicButton := TspSkinSpeedButton.Create(Self);
with ItalicButton do
begin
Parent := Self;
AllowAllUp := True;
DefaultWidth := 25;
DefaultHeight := 25;
SkinDataName := 'toolbutton';
GroupIndex := 1;
NumGlyphs := 1;
Left := 275;
Top := 20;
Glyph.LoadFromResourceName(HInstance, 'SP_ITALIC');
OnClick := ItalicButtonClick;
end;
UnderLineButton := TspSkinSpeedButton.Create(Self);
with UnderLineButton do
begin
Parent := Self;
AllowAllUp := True;
DefaultWidth := 25;
DefaultHeight := 25;
SkinDataName := 'toolbutton';
GroupIndex := 1;
NumGlyphs := 1;
Left := 305;
Top := 20;
Glyph.LoadFromResourceName(HInstance, 'SP_UNDERLINE');
OnClick := UnderLineButtonClick;
end;
StrikeOutButton := TspSkinSpeedButton.Create(Self);
with StrikeOutButton do
begin
Parent := Self;
AllowAllUp := True;
DefaultWidth := 25;
DefaultHeight := 25;
SkinDataName := 'toolbutton';
GroupIndex := 1;
NumGlyphs := 1;
Left := 335;
Top := 20;
Glyph.LoadFromResourceName(HInstance, 'SP_STRIKEOUT');
OnClick := StrikeOutButtonClick;
end;
end;
procedure TspFontDlgForm.FontSizeChange(Sender: TObject);
begin
FontExampleLabel.Font.Size := Trunc(FontSizeEdit.Value);
FontHeightEdit.SimpleSetValue(FontExampleLabel.Font.Height);
end;
procedure TspFontDlgForm.FontHeightChange(Sender: TObject);
begin
FontExampleLabel.Font.Height := Trunc(FontHeightEdit.Value);
FontSizeEdit.SimpleSetValue(FontExampleLabel.Font.Size);
end;
procedure TspFontDlgForm.FontScriptChange(Sender: TObject);
begin
FontExampleLabel.Font.Charset := GetCharSetFormIndex(ScriptComboBox.ItemIndex);
end;
procedure TspFontDlgForm.FontNameChange(Sender: TObject);
begin
FontExampleLabel.Font.Name := FontNameBox.FontName;
end;
procedure TspFontDlgForm.FontColorChange(Sender: TObject);
begin
FontExampleLabel.Font.Color := FontColorBox.Selected;
end;
procedure TspFontDlgForm.BoldButtonClick(Sender: TObject);
begin
if BoldButton.Down
then
FontExampleLabel.Font.Style := FontExampleLabel.Font.Style + [fsBold]
else
FontExampleLabel.Font.Style := FontExampleLabel.Font.Style - [fsBold];
end;
procedure TspFontDlgForm.ItalicButtonClick(Sender: TObject);
begin
if ItalicButton.Down
then
FontExampleLabel.Font.Style := FontExampleLabel.Font.Style + [fsItalic]
else
FontExampleLabel.Font.Style := FontExampleLabel.Font.Style - [fsItalic];
end;
procedure TspFontDlgForm.StrikeOutButtonClick(Sender: TObject);
begin
if StrikeOutButton.Down
then
FontExampleLabel.Font.Style := FontExampleLabel.Font.Style + [fsStrikeOut]
else
FontExampleLabel.Font.Style := FontExampleLabel.Font.Style - [fsStrikeOut];
end;
procedure TspFontDlgForm.UnderLineButtonClick(Sender: TObject);
begin
if UnderLineButton.Down
then
FontExampleLabel.Font.Style := FontExampleLabel.Font.Style + [fsUnderLine]
else
FontExampleLabel.Font.Style := FontExampleLabel.Font.Style - [fsUnderLine];
end;
constructor TspSkinFontDialog.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FAlphaBlend := False;
FAlphaBlendAnimation := False;
FAlphaBlendValue := 200;
FTitle := 'Font';
FDefaultFont := TFont.Create;
FFont := TFont.Create;
with FDefaultFont do
begin
Name := '宋体';
Style := [];
Height := 14;
end;
FShowSizeEdit := True;
FShowHeightEdit := False;
end;
destructor TspSkinFontDialog.Destroy;
begin
FDefaultFont.Free;
FFont.Free;
inherited Destroy;
end;
procedure TspSkinFontDialog.SetDefaultFont;
begin
FDefaultFont.Assign(Value);
end;
procedure TspSkinFontDialog.SetFont;
begin
FFont.Assign(Value);
end;
procedure TspSkinFontDialog.Notification;
begin
inherited Notification(AComponent, Operation);
if (Operation = opRemove) and (AComponent = FSD) then FSD := nil;
if (Operation = opRemove) and (AComponent = FCtrlFSD) then FCtrlFSD := nil;
end;
function TspSkinFontDialog.GetTitle: string;
begin
Result := FTitle;
end;
procedure TspSkinFontDialog.SetTitle(const Value: string);
begin
FTitle := Value;
end;
procedure TspSkinFontDialog.Change;
begin
if Assigned(FOnChange) then FOnChange(Self);
end;
function TspSkinFontDialog.Execute: Boolean;
var
FW, FH: Integer;
begin
FDlgFrm := TspFontDlgForm.CreateEx(Application, CtrlSkinData);
with FDlgFrm do
try
Caption := Self.Title;
DSF.BorderIcons := [];
DSF.SkinData := FSD;
DSF.MenusSkinData := CtrlSkinData;
DSF.AlphaBlend := AlphaBlend;
DSF.AlphaBlendAnimation := AlphaBlendAnimation;
DSF.AlphaBlendValue := AlphaBlendValue;
DSF.Sizeable := False;
//
ScriptComboBox.SkinData := FCtrlFSD;
FontNameBox.SkinData := FCtrlFSD;
FontColorBox.SkinData := FCtrlFSD;
FontSizeEdit.SkinData := FCtrlFSD;
FontHeightEdit.SkinData := FCtrlFSD;
FontExamplePanel.SkinData := FCtrlFSD;
OkButton.SkinData := FCtrlFSD;
CancelButton.SkinData := FCtrlFSD;
BoldButton.SkinData := FCtrlFSD;
ItalicButton.SkinData := FCtrlFSD;
UnderLineButton.SkinData := FCtrlFSD;
StrikeOutButton.SkinData := FCtrlFSD;
//
FontHeightLabel.SkinData := FCtrlFSD;
FontSizeLabel.SkinData := FCtrlFSD;
FontStyleLabel.SkinData := FCtrlFSD;
FontNameLabel.SkinData := FCtrlFSD;
FontColorLabel.SkinData := FCtrlFSD;
FontExLabel.SkinData := FCtrlFSD;
//
ScriptComboBox.ItemIndex := GetIndexFromCharSet(Self.Font.CharSet);
//
FontExampleLabel.Font.Assign(Self.Font);
FontNameBox.FontName := FontExampleLabel.Font.Name;
FontColorBox.Selected := FontExampleLabel.Font.Color;
FontSizeEdit.SimpleSetValue(FontExampleLabel.Font.Size);
FontHeightEdit.SimpleSetValue(FontExampleLabel.Font.Height);
FontSizeEdit.Visible := FShowSizeEdit;
FontHeightEdit.Visible := FShowHeightEdit;
FontHeightLabel.Visible := FShowHeightEdit;
FontSizeLabel.Visible := FShowSizeEdit;
//
if fsBold in FontExampleLabel.Font.Style
then
BoldButton.Down := True;
if fsItalic in FontExampleLabel.Font.Style
then
ItalicButton.Down := True;
if fsStrikeOut in FontExampleLabel.Font.Style
then
StrikeOutButton.Down := True;
if fsUnderLine in FontExampleLabel.Font.Style
then
UnderLineButton.Down := True;
//
FW := 400;
FH := 230;
if (SkinData <> nil) and not SkinData.Empty
then
begin
if FW < DSF.GetMinWidth then FW := DSF.GetMinWidth;
if FH < DSF.GetMinHeight then FH := DSF.GetMinHeight;
end;
ClientWidth := FW;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -