⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spdialogs.pas

📁 一款支持Delphi和C++ Builder的VCL控件
💻 PAS
📖 第 1 页 / 共 5 页
字号:
var
  I: Integer;
  ResStrData: TspResourceStrData;
  OffsetY: Integer;
begin
  inherited CreateNew(AOwner);

  if AShowScript then OffsetY := 45 else OffsetY := 0;

  if (ACtrlSkinData <> nil) and (ACtrlSkinData.ResourceStrData <> nil)
  then
    ResStrData := ACtrlSkinData.ResourceStrData
  else
    ResStrData := nil;
  KeyPreview := True;
  BorderStyle := bsDialog;
  Position := poScreenCenter;
  DSF := TspDynamicSkinForm.Create(Self);
  DSF.SizeAble := False;
  
  FontColorLabel := TspSkinStdLabel.Create(Self);
  with FontColorLabel do
  begin
    Left := 10;
    Top := 50 - 2;
    if ResStrData <> nil
    then
      Caption := ResStrData.GetResStr('FONTDLG_COLOR')
    else
      Caption := SP_FONTDLG_COLOR;
    AutoSize := True;
    Parent := Self;
  end;

  FontColorBox := TspSkinTextColorButton.Create(Self);
  with FontColorBox do
  begin
    Left := 10;
    Top := 65;
    Width := 70;
    DefaultHeight := 21;
    Parent := Self;
    ShowAutoColor := False;
    InitColors;
    SkinDataName := 'resizetoolbutton';
    OnChangeColor := FontColorChange;
  end;

  FontNameLabel := TspSkinStdLabel.Create(Self);
  with FontNameLabel do
  begin
    Left := 10;
    Top := 5 - 2;
    if ResStrData <> nil
    then
      Caption := ResStrData.GetResStr('FONTDLG_NAME')
    else
      Caption := SP_FONTDLG_NAME;
    AutoSize := True;
    Parent := Self;
  end;

  FontNameBox := TspSkinFontComboBox.Create(Self);
  with FontNameBox do
  begin
    Left := 10;
    Top := 20;
    Width := 240;
    DefaultHeight := 21;
    Parent := Self;
    PopulateList;
    TabOrder := 0;
    TabStop := True;
    OnChange := FontNameChange;
  end;

  FontSizeLabel := TspSkinStdLabel.Create(Self);
  with FontSizeLabel do
  begin
    Left := 100;
    Top := 50 - 2;
    if ResStrData <> nil
    then
      Caption := ResStrData.GetResStr('FONTDLG_SIZE')
    else
      Caption := SP_FONTDLG_SIZE;
    AutoSize := True;
    Parent := Self;
  end;

  FontSizeEdit := TspSkinFontSizeComboBox.Create(Self);
  with  FontSizeEdit do
  begin
    Left := 100;
    Top := 65;
    Parent := Self;
    Width := 60;
    Style := spcbEditStyle;
    OnChange := FontSizeChange;
  end;

  FontHeightLabel := TspSkinStdLabel.Create(Self);
  with FontHeightLabel do
  begin
    Left := 100;
    Top := 50 - 2;
    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 := 100;
    Top := 65;
    Width := 60;
    Parent := Self;
    OnChange := FontHeightChange;
  end;

  ScriptLabel := TspSkinStdLabel.Create(Self);
  with ScriptLabel do
  begin
    Left := 10;
    Top := 150 - 2;
    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 := 10;
    Top := 165;
    Width := 240;
    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 := 10;
    Top := 150 + OffsetY - 2;
    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 := 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 := 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 := 90;
    Top := 235 + OffsetY;
    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 := 175;
    Top := 235 + OffsetY;
    Width := 75;
    DefaultHeight := 25;
    Parent := Self;
    ModalResult := mrCancel;
    Cancel := True;
  end;

  FontStyleLabel := TspSkinStdLabel.Create(Self);
  with FontStyleLabel do
  begin
    Left := 10;
    Top := 100 - 2;
    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 := 10;
    Top := 115;
    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 := 40;
    Top := 115;
    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 := 70;
    Top := 115;
    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 := 100;
    Top := 115;
    Glyph.LoadFromResourceName(HInstance, 'SP_STRIKEOUT');
    OnClick := StrikeOutButtonClick;
  end;

end;

procedure TspFontDlgForm.FontSizeChange(Sender: TObject);
begin
  if FontSizeEdit.SizeValue <> 0
  then
    FontExampleLabel.Font.Size := Trunc(FontSizeEdit.SizeValue);
  FontHeightEdit.SimpleSetValue(FontExampleLabel.Font.Height);
end;

procedure TspFontDlgForm.FontHeightChange(Sender: TObject);
begin
  FontExampleLabel.Font.Height := Trunc(FontHeightEdit.Value);
  FontSizeEdit.Text := IntToStr(FontExampleLabel.Font.Size);
end;

procedure TspFontDlgForm.FontNameChange(Sender: TObject);
begin
  FontExampleLabel.Font.Name := FontNameBox.FontName;
  FontSizeEdit.FontName := FontNameBox.FontName;
  FontSizeEdit.Text := IntToStr(FontExampleLabel.Font.Size);
end;

procedure TspFontDlgForm.FontScriptChange(Sender: TObject);
begin
  FontExampleLabel.Font.Charset := GetCharSetFormIndex(ScriptComboBox.ItemIndex);
end;


procedure TspFontDlgForm.FontColorChange(Sender: TObject);
begin
  FontExampleLabel.Font.Color := FontColorBox.ColorValue;
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 := 'Arial';
    Style := [];
    Height := 14;
  end;
  FShowSizeEdit := True;
  FShowHeightEdit := False;
  FShowScript := False;
end;

destructor TspSkinFontDialog.Destroy;
begin
  FDefaultFont.Free;
  FFont.Free;
  inherited Destroy;
end;

procedure TspSkinFontDialog.SetShowSizeEdit(Value: Boolean);
begin
  FShowSizeEdit := Value;
  if FShowSizeEdit then FShowHeightEdit := False;
end;

procedure TspSkinFontDialog.SetShowHeightEdit(Value: Boolean);
begin
  FShowheightEdit := Value;
  if FShowHeightEdit then FShowSizeEdit := False;
end;

procedure TspSkinFontDialog.SetDefaultFont;
begin

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -