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

📄 tableproperty.pas

📁 帮助编写程序
💻 PAS
字号:
{*******************************************************}
{                                                       }
{                动 态 网 页 编 辑 器                   }
{                                                       }
{       Copyright (C) 00,00 Justep Corporation          }
{                                                       }
{*******************************************************}
unit TableProperty;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, Spin, ExtCtrls;

type
  TTablePropertyForm = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    edtNumRows: TSpinEdit;
    edtNumCols: TSpinEdit;
    gbTableAttrib: TGroupBox;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    sbBGPicture: TSpeedButton;
    Label11: TLabel;
    Label12: TLabel;
    Label15: TLabel;
    edtWidth: TSpinEdit;
    cbWidthMode: TComboBox;
    edtBGPicture: TEdit;
    edtBorderWidth: TSpinEdit;
    cbAlign: TComboBox;
    edtCellSpacing: TSpinEdit;
    edtCellPadding: TSpinEdit;
    ccbTableBG: TColorBox;
    ccbTableBorder: TColorBox;
    cbUseBGPicture: TCheckBox;
    GroupBox1: TGroupBox;
    Label13: TLabel;
    Label14: TLabel;
    Label3: TLabel;
    cbCellAlign: TComboBox;
    cbCellEnter: TCheckBox;
    ccbCellBG: TColorBox;
    ccbCellBorder: TColorBox;
    btnOK: TButton;
    btnCancel: TButton;
    procedure FormCreate(Sender: TObject);
    procedure btnOKClick(Sender: TObject);
    procedure cbUseBGPictureClick(Sender: TObject);
    procedure sbBGPictureClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    TableAttrs: string;
    CellAttrs: string;
  end;

var
  TablePropertyForm: TTablePropertyForm;

implementation

uses WebBrowserEdit;

{$R *.DFM}

procedure TTablePropertyForm.FormCreate(Sender: TObject);
begin
  ccbTableBG.Items.Insert(0, '默认');
  ccbTableBorder.Items.Insert(0, '默认');
  ccbCellBG.Items.Insert(0, '默认');
  ccbCellBorder.Items.Insert(0, '默认');
  ccbTableBG.ItemIndex := 0;
  ccbTableBorder.ItemIndex := 0;
  ccbCellBG.ItemIndex := 0;
  ccbCellBorder.ItemIndex := 0;
end;

procedure TTablePropertyForm.btnOKClick(Sender: TObject);
var
  WidthMode: string;
  Align: string;
begin
  if cbWidthMode.ItemIndex = 1 then
    WidthMode := ''
  else
    WidthMode := '%';
  case cbAlign.ItemIndex of
    1:   Align := 'center';
    2:   Align := 'right';
    else Align := 'left';
  end;
  TableAttrs := 'width=' + IntToStr(edtWidth.Value) + WidthMode + ' ' +
                'align=' + Align + ' ';
  if ccbTableBG.ItemIndex > 0 then
    TableAttrs := TableAttrs +
                'bgcolor=' + ColorToHtml(ccbTableBG.Selected) + ' ';
  if ccbTableBorder.ItemIndex > 0 then
    TableAttrs := TableAttrs +
                'borderColor=' + ColorToHtml(ccbTableBorder.Selected) + ' ';
  TableAttrs := TableAttrs +
                'border=' + IntToStr(edtBorderWidth.Value) + ' ' +
                'cellspacing=' + IntToStr(edtCellSpacing.Value) + ' ' +
                'cellpadding=' + IntToStr(edtCellPadding.Value) + ' ';
  if cbUseBGPicture.Enabled then
    TableAttrs := TableAttrs +
                'background=file://' + edtBGPicture.Text;
  CellAttrs := 'align=' + cbCellAlign.Text + ' ';
  if ccbCellBG.ItemIndex > 0 then
    CellAttrs := CellAttrs +
               'bgcolor=' + ColorToHtml(ccbCellBG.Selected) + ' ';
  if ccbCellBorder.ItemIndex > 0 then
    CellAttrs := CellAttrs +
               'bordercolor=' + ColorToHtml(ccbCellBorder.Selected);
end;

procedure TTablePropertyForm.cbUseBGPictureClick(Sender: TObject);
begin
  edtBGPicture.Enabled := cbUseBGPicture.Checked;
  sbBGPicture.Enabled := edtBGPicture.Enabled;
  if edtBGPicture.Enabled then
    edtBGPicture.Color := clWindow
  else
    edtBGPicture.Color := clBtnFace;
end;

procedure TTablePropertyForm.sbBGPictureClick(Sender: TObject);
begin
  with TOpenDialog.Create(self) do
    begin
      try
        Filter := 'Image files (*.gif;*.jpg;*.jpeg;*.bmp)|*.gif;*.jpg;*.jpeg;*.bmp|' +
                  '所有文件(*.*)|*.*';
        if Execute then  edtBGPicture.Text := FileName;
      finally
        Free;
      end;
    end;
end;

end.

⌨️ 快捷键说明

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