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

📄 spdialogs.pas

📁 P2P即时通讯源码(DELPHI编写)
💻 PAS
📖 第 1 页 / 共 4 页
字号:

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 := 'Arial';
    Style := [];
    Height := 14;
  end;
  FShowSizeEdit := True;
  FShowHeightEdit := True;
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.Create(Application);
  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;
    //
    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;
    //
    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 := 190;
    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;
    ClientHeight := FH;
    //
    Result := (ShowModal = mrOk);
    if Result
    then
      begin
        Self.Font.Assign(FontExampleLabel.Font);
        Change;
      end;
  finally
    Free;
    FDlgFrm := nil;
  end;
end;


constructor TspSkinTextDialog.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 TspSkinTextDialog.Destroy;
begin
  FDefaultMemoFont.Free;
  FDefaultButtonFont.Free;
  FLines.Free;
  inherited;
end;

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

procedure TspSkinTextDialog.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 TspSkinTextDialog.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 TspSkinTextDialog.CopyButtonClick(Sender: TObject);
begin
  Memo.CopyToClipboard;
end;

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

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

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

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

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

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

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

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

procedure TspSkinTextDialog.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 TspSkinTextDialog.Execute: Boolean;
var
  Form: TForm;
  DSF: TspDynamicSkinForm;
  ButtonWidth, ButtonHeight: Integer;
  Panel: TspSkinPanel;
  HMemoScrollBar, VMemoScrollBar: TspSkinScrollBar;
  ToolPanel: TspSkinPanel;
begin
  Form := TForm.Create(Application);
  Form.BorderStyle := bsDialog;
  Form.Caption := FCaption;
  Form.Position := poScreenCenter;
  DSF := TspDynamicSkinForm.Create(Form);
  DSF.BorderIcons := [];
  DSF.SkinData := SkinData;
  DSF.MenusSkinData := CtrlSkinData;
  DSF.SizeAble := False;
  DSF.AlphaBlend := AlphaBlend;
  DSF.AlphaBlendAnimation := AlphaBlendAnimation;
  DSF.AlphaBlendValue := AlphaBlendValue;

  try

  with Form do
  begin
    ClientWidth := FClientWidth;
    ClientHeight := FClientHeight;
    ButtonWidth := 80;
    ButtonHeight := 25;

    with TspSkinButton.Create(Form) do
    begin
      Parent := Form;
      DefaultFont := DefaultButtonFont;
      UseSkinFont := Self.UseSkinFont;
      Caption := SP_MSG_BTN_OK;
      DefaultHeight := ButtonHeight;
      ModalResult := mrOk;
      Default := True;
      SkinDataName := FButtonSkinDataName;
      SkinData := CtrlSkinData;
      SetBounds(FClientWidth - ButtonWidth * 2 - 20, FClientHeight - Height - 10,
                ButtonWidth, Height);
    end;

    with TspSkinButton.Create(Form) do
    begin
      Parent := Form;
      DefaultFont := DefaultButtonFont;
      UseSkinFont := Self.UseSkinFont;
      Caption := SP_MSG_BTN_CANCEL;
      DefaultHeight := ButtonHeight;
      ModalResult := mrCancel;
      Cancel := True;
      SkinDataName := FButtonSkinDataName;
      SkinData := CtrlSkinData;
      SetBounds(FClientWidth - ButtonWidth - 10, FClientHeight - Height - 10,
                ButtonWidth, Height);
      ButtonHeight := Height;          
    end;

    Panel := TspSkinPanel.Create(Form);
    with Panel do
    begin
      Parent := Form;
      Align := alTop;
      SkinData := CtrlSkinData;
    end;

    if FShowToolBar
    then
      begin
        ToolPanel := TspSkinPanel.Create(Form);
        with ToolPanel do
        begin
          Parent := Form;
          Align := alTop;
          DefaultHeight := 25;
          SkinDataName := 'toolpanel';
          SkinData := CtrlSkinData;
        end;

        with TspSkinSpeedButton.Create(Form) do
        begin
          Parent := ToolPanel;
          DefaultWidth := 27;
          SkinDataName := 'toolbutton';
          Align := alLeft;
          OnClick := NewButtonClick;
          NumGlyphs := 1;
          Glyph.LoadFromResourceName(HInstance, 'SP_NEW');
          SkinData := CtrlSkinData;
        end;

        with TspSkinSpeedButton.Create(Form) do
        begin
          Parent := ToolPanel;
          DefaultWidth := 27;
          SkinDataName := 'toolbutton';
          Align := alLeft;
          OnClick := OpenButtonClick;
          NumGlyphs := 1;
          Glyph.LoadFromResourceName(HInstance, 'SP_OPEN');
          SkinData := CtrlSkinData;
        end;

        with TspSkinSpeedButton.Create(Form) do
        begin
          Parent := ToolPanel;
          DefaultWidth := 27;
          SkinDataName := 'toolbutton';
          Align := alLeft;
          OnClick := SaveButtonClick;
          NumGlyphs := 1;
          Glyph.LoadFromResourceName(HInstance, 'SP_SAVE');
          SkinData := CtrlSkinData;
        end;

        with TspSkinBevel.Create(Form) do
        begin
          Parent := ToolPanel;
          Width := 24;
          Align := alLeft;
          DividerMode := True;
          Shape := bsLeftLine;
          SkinData := CtrlSkinData;
        end;

        with TspSkinSpeedButton.Create(Form) do
        begin
          Parent := ToolPanel;
          DefaultWidth := 27;
          SkinDataName := 'toolbutton';
          Align := alLeft;
          OnClick := CopyButtonClick;
          NumGlyphs := 1;
          Glyph.LoadFromResourceName(HInstance, 'SP_COPY');
          SkinData := CtrlSkinData;
        end;

        with TspSkinSpeedButton.Create(Form) do
        begin
          Parent := ToolPanel;
          DefaultWidth := 27;
          SkinDataName := 'toolbutton';
          Align := alLeft;
          OnClick := CutButtonClick;
          NumGlyphs := 1;
          Glyph.LoadFromResourceName(HInstance, 'SP_CUT');
          SkinData := CtrlSkinData;
        end;

        with TspSkinSpeedButton.Create(Form) do
        begin
          Parent := ToolPanel;
          DefaultWidth := 27;
          SkinDataName := 'toolbutton';
          Align := alLeft;
          OnClick := PasteButtonClick;
          NumGlyphs := 1;
          Glyph.LoadFromResourceName(HInstance, 'SP_PASTE');
          SkinData := CtrlSkinData;
        end;

        with TspSkinSpeedButton.Create(Form) do
        begin
          Parent := ToolPanel;
          DefaultWidth := 27;
          SkinDataName := 'toolbutton';
          Align := alLeft;
          OnClick := DeleteButtonClick;
          NumGlyphs := 1;
          Glyph.LoadFromResourceName(HInstance, 'SP_DELETE');
          SkinData := CtrlSkinData;
        end;

      end;

    with Panel do
    begin
      if FShowToolBar
      then
        Height := FClientHeight -  ButtonHeight - 20 - ToolPanel.Height
      else
        Height := FClientHeight -  ButtonHeight - 20;
    end;

    VMemoScrollBar := TspSkinScrollBar.Create(Form);
    with VMemoScrollBar do
    begin
      Kind := sbVertical;
      Parent := Panel;
      Align := alRight;
      DefaultWidth := 19;
      Enabled := False;
      SkinDataName := 'vscrollbar';
      SkinData := CtrlSkinData;
    end;

⌨️ 快捷键说明

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