📄 bsdialogs.pas
字号:
begin
Left := 10;
Top := 150 + OffsetY - 2;
if ResStrData <> nil
then
Caption := ResStrData.GetResStr('FONTDLG_EXAMPLE')
else
Caption := BS_FONTDLG_EXAMPLE;
AutoSize := True;
Parent := Self;
end;
FontExamplePanel := TbsSkinPanel.Create(Self);
with FontExamplePanel do
begin
Parent := Self;
BorderStyle := bvFrame;
Left := 10;
Top := 165 + OffsetY;
Width := 240;
Height := 60;
end;
FontExampleLabel := TLabel.Create(Self);
with FontExampleLabel do
begin
Parent := FontExamplePanel;
Transparent := True;
Align := alClient;
Caption := 'AaBbYyZz';
end;
OkButton := TbsSkinButton.Create(Self);
with OkButton do
begin
if ResStrData <> nil
then
Caption := ResStrData.GetResStr('MSG_BTN_OK')
else
Caption := BS_MSG_BTN_OK;
CanFocused := True;
Left := 90;
Top := 235 + OffsetY;
Width := 75;
DefaultHeight := 25;
Parent := Self;
ModalResult := mrOk;
end;
CancelButton := TbsSkinButton.Create(Self);
with CancelButton do
begin
if ResStrData <> nil
then
Caption := ResStrData.GetResStr('MSG_BTN_CANCEL')
else
Caption := BS_MSG_BTN_CANCEL;
CanFocused := True;
Left := 175;
Top := 235 + OffsetY;
Width := 75;
DefaultHeight := 25;
Parent := Self;
ModalResult := mrCancel;
Cancel := True;
end;
FontStyleLabel := TbsSkinStdLabel.Create(Self);
with FontStyleLabel do
begin
Left := 10;
Top := 100 - 2;
if ResStrData <> nil
then
Caption := ResStrData.GetResStr('FONTDLG_STYLE')
else
Caption := BS_FONTDLG_STYLE;
AutoSize := True;
Parent := Self;
end;
BoldButton := TbsSkinSpeedButton.Create(Self);
with BoldButton do
begin
Parent := Self;
AllowAllUp := True;
DefaultWidth := 25;
DefaultHeight := 25;
SkinDataName := 'toolbutton';
GroupIndex := 1;
NumGlyphs := 1;
Left := 10;
Top := 115;
Glyph.LoadFromResourceName(HInstance, 'BS_BOLD');
OnClick := BoldButtonClick;
end;
ItalicButton := TbsSkinSpeedButton.Create(Self);
with ItalicButton do
begin
Parent := Self;
AllowAllUp := True;
DefaultWidth := 25;
DefaultHeight := 25;
SkinDataName := 'toolbutton';
GroupIndex := 1;
NumGlyphs := 1;
Left := 40;
Top := 115;
Glyph.LoadFromResourceName(HInstance, 'BS_ITALIC');
OnClick := ItalicButtonClick;
end;
UnderLineButton := TbsSkinSpeedButton.Create(Self);
with UnderLineButton do
begin
Parent := Self;
AllowAllUp := True;
DefaultWidth := 25;
DefaultHeight := 25;
SkinDataName := 'toolbutton';
GroupIndex := 1;
NumGlyphs := 1;
Left := 70;
Top := 115;
Glyph.LoadFromResourceName(HInstance, 'BS_UNDERLINE');
OnClick := UnderLineButtonClick;
end;
StrikeOutButton := TbsSkinSpeedButton.Create(Self);
with StrikeOutButton do
begin
Parent := Self;
AllowAllUp := True;
DefaultWidth := 25;
DefaultHeight := 25;
SkinDataName := 'toolbutton';
GroupIndex := 1;
NumGlyphs := 1;
Left := 100;
Top := 115;
Glyph.LoadFromResourceName(HInstance, 'BS_STRIKEOUT');
OnClick := StrikeOutButtonClick;
end;
end;
procedure TbsFontDlgForm.FontSizeChange(Sender: TObject);
begin
if FontSizeEdit.SizeValue <> 0
then
FontExampleLabel.Font.Size := Trunc(FontSizeEdit.SizeValue);
FontHeightEdit.SimpleSetValue(FontExampleLabel.Font.Height);
end;
procedure TbsFontDlgForm.FontHeightChange(Sender: TObject);
begin
FontExampleLabel.Font.Height := Trunc(FontHeightEdit.Value);
FontSizeEdit.Text := IntToStr(FontExampleLabel.Font.Size);
end;
procedure TbsFontDlgForm.FontNameChange(Sender: TObject);
begin
FontExampleLabel.Font.Name := FontNameBox.FontName;
FontSizeEdit.FontName := FontNameBox.FontName;
FontSizeEdit.Text := IntToStr(FontExampleLabel.Font.Size);
end;
procedure TbsFontDlgForm.FontScriptChange(Sender: TObject);
begin
FontExampleLabel.Font.Charset := GetCharSetFormIndex(ScriptComboBox.ItemIndex);
end;
procedure TbsFontDlgForm.FontColorChange(Sender: TObject);
begin
FontExampleLabel.Font.Color := FontColorBox.ColorValue;
end;
procedure TbsFontDlgForm.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 TbsFontDlgForm.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 TbsFontDlgForm.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 TbsFontDlgForm.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 TbsSkinFontDialog.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 := 'Arial';
Style := [];
Height := 14;
end;
FShowSizeEdit := True;
FShowHeightEdit := False;
FShowScript := False;
end;
destructor TbsSkinFontDialog.Destroy;
begin
FDefaultFont.Free;
FFont.Free;
inherited Destroy;
end;
procedure TbsSkinFontDialog.SetShowSizeEdit(Value: Boolean);
begin
FShowSizeEdit := Value;
if FShowSizeEdit then FShowHeightEdit := False;
end;
procedure TbsSkinFontDialog.SetShowHeightEdit(Value: Boolean);
begin
FShowheightEdit := Value;
if FShowHeightEdit then FShowSizeEdit := False;
end;
procedure TbsSkinFontDialog.SetDefaultFont;
begin
FDefaultFont.Assign(Value);
end;
procedure TbsSkinFontDialog.SetFont;
begin
FFont.Assign(Value);
end;
procedure TbsSkinFontDialog.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 TbsSkinFontDialog.GetTitle: string;
begin
Result := FTitle;
end;
procedure TbsSkinFontDialog.SetTitle(const Value: string);
begin
FTitle := Value;
end;
procedure TbsSkinFontDialog.Change;
begin
if Assigned(FOnChange) then FOnChange(Self);
end;
function TbsSkinFontDialog.Execute: Boolean;
var
FW, FH: Integer;
begin
FDlgFrm := TbsFontDlgForm.CreateEx(Application, CtrlSkinData, FShowScript);
with FDlgFrm do
try
Caption := Self.Title;
BSF.BorderIcons := [];
BSF.SkinData := FSD;
BSF.MenusSkinData := CtrlSkinData;
BSF.AlphaBlend := AlphaBlend;
BSF.AlphaBlendAnimation := AlphaBlendAnimation;
BSF.AlphaBlendValue := AlphaBlendValue;
//
ScriptComboBox.SkinData := FCtrlFSD;
FontNameBox.SkinData := FCtrlFSD;
FontColorBox.SkinData := FCtrlFSD;
FontColorBox.SkinImagesMenu.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;
ScriptLabel.SkinData := FCtrlFSD;
ScriptLabel.Visible := FShowScript;
//
ScriptComboBox.ItemIndex := GetIndexFromCharSet(Self.Font.CharSet);
ScriptComboBox.Visible := FShowScript;
//
FontExampleLabel.Font.Assign(Self.Font);
FontNameBox.FontName := FontExampleLabel.Font.Name;
FontColorBox.ColorValue := FontExampleLabel.Font.Color;
FontSizeEdit.Text := IntToStr(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 := 260;
FH := 270;
if FShowScript then FH := FH + 40;
if (SkinData <> nil) and not SkinData.Empty
then
begin
if FW < BSF.GetMinWidth then FW := BSF.GetMinWidth;
if FH < BSF.GetMinHeight then FH := BSF.GetMinHeight;
end;
ClientWidth := FW;
ClientHeight := FH;
//
Result := (ShowModal = mrOk);
if Result
then
begin
Self.Font.Assign(FontExampleLabel.Font);
Change;
end;
finally
Free;
FDlgFrm := nil;
end;
end;
constructor TbsSkinTextDialog.Create;
begin
inherited Create(AOwner);
FAlphaBlend := False;
FAlphaBlendAnimation := False;
FAlphaBlendValue := 200;
FToolButtonsTransparent := False;
Memo := nil;
FSkinOpenDialog := nil;
FSkinSaveDialog := nil;
FClientWidth := 350;
FClientHeight := 200;
FLines := TStringList.Create;
FCaption := 'Input text';
FButtonSkinDataName := 'button';
FMemoSkinDataName := 'memo';
FDefaultButtonFont := TFont.Create;
FDefaultMemoFont := TFont.Create;
FUseSkinFont := True;
ShowToolBar := True;
with FDefaultButtonFont do
begin
Name := 'Arial';
Style := [];
Height := 1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -