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

📄 bsdialogs.pas

📁 一个用Delpi写的视频聊天的SDK
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    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 := 275;
    Top := 20;
    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 := 305;
    Top := 20;
    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 := 335;
    Top := 20;
    Glyph.LoadFromResourceName(HInstance, 'BS_STRIKEOUT');
    OnClick := StrikeOutButtonClick;
  end;

end;

procedure TbsFontDlgForm.FontSizeChange(Sender: TObject);
begin
  FontExampleLabel.Font.Size := Trunc(FontSizeEdit.Value);
  FontHeightEdit.SimpleSetValue(FontExampleLabel.Font.Height);
end;

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

procedure TbsFontDlgForm.FontNameChange(Sender: TObject);
begin
  FontExampleLabel.Font.Name := FontNameBox.FontName;
end;

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


procedure TbsFontDlgForm.FontColorChange(Sender: TObject);
begin
  FontExampleLabel.Font.Color := FontColorBox.Selected;
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;
end;

destructor TbsSkinFontDialog.Destroy;
begin
  FDefaultFont.Free;
  FFont.Free;
  inherited Destroy;
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);
  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;
    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 < 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;

  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 := 14;
  end;

  with FDefaultMemoFont do
  begin
    Name := 'Arial';
    Style := [];
    Height := 14;
  end;
end;

destructor TbsSkinTextDialog.Destroy;
begin
  FDefaultMemoFont.Free;
  FDefaultButtonFont.Free;
  FLines.Free;
  inherited;
end;

procedure TbsSkinTextDialog.NewButtonClick(Sender: TObject);
begin
  Memo.Clear;
end;

procedure TbsSkinTextDialog.OpenButtonClick(Sender: TObject);
var
  OD: TOpenDialog;
begin
  if FSkinOpenDialog <> nil
  then
    begin
      if FSkinOpenDialog.Execute
      then Memo.Lines.LoadFromFile(FSkinOpenDialog.FileName);
    end
  else
    begin
      OD := TOpenDialog.Create(Self);
      OD.Filter := '*.txt|*.txt|*.*|*.*';
      if OD.Execute then Memo.Lines.LoadFromFile(OD.FileName);
      OD.Free;
    end;
end;

procedure TbsSkinTextDialog.SaveButtonClick(Sender: TObject);
var
  SD: TSaveDialog;
begin
  if FSkinSaveDialog <> nil
  then
    begin
      if FSkinSaveDialog.Execute
      then Memo.Lines.LoadFromFile(FSkinSaveDialog.FileName);
    end
  else
    begin
      SD := TSaveDialog.Create(Self);
      SD.Filter := '*.txt|*.txt|*.*|*.*';
      if SD.Execute then Memo.Lines.SaveToFile(SD.FileName);
      SD.Free;
    end;  
end;
procedure TbsSkinTextDialog.CopyButtonClick(Sender: TObject);
begin
  Memo.CopyToClipboard;
end;

procedure TbsSkinTextDialog.CutButtonClick(Sender: TObject);
begin
  Memo.CutToClipboard;
end;

procedure TbsSkinTextDialog.PasteButtonClick(Sender: TObject);
begin
  Memo.PasteFromClipboard;
end;

procedure TbsSkinTextDialog.DeleteButtonClick(Sender: TObject);
begin
  Memo.ClearSelection;
end;

procedure TbsSkinTextDialog.SetLines(Value: TStrings);
begin
  FLines.Assign(Value);
end;

procedure TbsSkinTextDialog.SetClientWidth(Value: Integer);
begin
  if Value > 0 then FClientWidth := Value;
end;

procedure TbsSkinTextDialog.SetClientHeight(Value: Integer);
begin
  if Value > 0 then FClientHeight := Value;
end;

procedure TbsSkinTextDialog.SetDefaultMemoFont;
begin
  FDefaultMemoFont.Assign(Value);
end;

procedure TbsSkinTextDialog.SetDefaultButtonFont;
begin
  FDefaultButtonFont.Assign(Value);
end;

procedure TbsSkinTextDialog.Notification;
begin
  inherited Notification(AComponent, Operation);
  if (Operation = opRemove) and (AComponent = FSD) then FSD := nil;
  if (Operation = opRemove) and (AComponent = FCtrlFSD) then FCtrlFSD := nil;
  if (Operation = opRemove) and (AComponent = FSkinOpenDialog) then FSkinOpenDialog := nil;
  if (Operation = opRemove) and (AComponent = FSkinSaveDialog) then FSkinSaveDialog := nil;
end;

function TbsSkinTextDialog.Execute: Boolean;
var
  Form: TForm;
  BSF: TbsBusinessSkinForm;
  ButtonWidth, ButtonHeight: Integer;
  Panel: TbsSkinPanel;
  HMemoScrollBar, VMemoScrollBar: TbsSkinScrollBar;
  ToolPanel: TbsSkinPanel;
begin
  Form := TForm.Create(Application);
  Form.BorderStyle := bsDialog;
  Form.Caption := FCaption;
  Form.Position 

⌨️ 快捷键说明

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