📄 unit1.pas
字号:
Editor.TableCellAttrs.WidthInPercent := FormTable.CheckBoxCellWidthPercent.Checked;
Editor.TableCellAttrs.Height := StrToIntDef(FormTable.EditCellHeight.Text, 0);
Editor.TableCellAttrs.HeightInPercent := FormTable.CheckBoxCellHeightPercent.Checked;
Editor.InsertTable(StrToIntDef(FormTable.EditRows.Text, 0),
StrToIntDef(FormTable.EditCols.Text, 0),
FormTable.EditCaption.Text)
end
end;
procedure TForm1.MenuItemTablePropertiesClick(Sender: TObject);
var
TableNumRows, TableNumCols, I, J: Integer;
TableCaption: WideString;
begin
Editor.GetTableInfo(TableNumRows, TableNumCols, TableCaption, Editor.TableAttrs);
FormTable.EditCols.Text := IntToStr(TableNumCols);
FormTable.EditRows.Text := IntToStr(TableNumRows);
FormTable.EditCaption.Text := TableCaption;
FormTable.EditTableWidth.Text := IntToStr(Editor.TableAttrs.Width);
FormTable.CheckBoxTableWidthPercent.Checked := Editor.TableAttrs.WidthInPercent;
FormTable.EditCellSpacing.Text := IntToStr(Editor.TableAttrs.CellSpacing);
FormTable.EditCellPadding.Text := IntToStr(Editor.TableAttrs.CellPadding);
FormTable.RadioGroupAlignment.ItemIndex := Ord(Editor.TableAttrs.Align);
FormTable.EditBorderWidth.Text := IntToStr(Editor.TableAttrs.BorderSize);
FormTable.PanelBorderColor.Color := Editor.TableAttrs.BorderColor;
FormTable.PanelBgColor.Color := Editor.TableAttrs.BgColor;
FormTable.EditBackground.Text := Editor.TableAttrs.Background;
if Editor.IsTableCellSelected then
begin
for I := 0 to FormTable.GroupBoxCells.ControlCount - 1 do
if not (FormTable.GroupBoxCells.Controls[I] is TGroupBox) then
FormTable.GroupBoxCells.Controls[I].Enabled := True
else
for J := 0 to (FormTable.GroupBoxCells.Controls[I] as TGroupBox).ControlCount - 1 do
(FormTable.GroupBoxCells.Controls[I] as TGroupBox).Controls[J].Enabled := True;
Editor.GetTableCellAttrs(Editor.TableCellAttrs);
FormTable.RadioGroupCellAlignment.ItemIndex := Ord(Editor.TableCellAttrs.Align);
FormTable.RadioGroupCellVAlignment.ItemIndex := Ord(Editor.TableCellAttrs.VAlign);
FormTable.PanelCellBorderColor.Color := Editor.TableCellAttrs.BorderColor;
FormTable.PanelCellBgColor.Color := Editor.TableCellAttrs.BgColor;
FormTable.EditCellBackground.Text := Editor.TableCellAttrs.Background;
FormTable.EditCellWidth.Text := IntToStr(Editor.TableCellAttrs.Width);
FormTable.CheckBoxCellWidthPercent.Checked := Editor.TableCellAttrs.WidthInPercent;
FormTable.EditCellHeight.Text := IntToStr(Editor.TableCellAttrs.Height);
FormTable.CheckBoxCellHeightPercent.Checked := Editor.TableCellAttrs.HeightInPercent;
FormTable.CheckBoxNoWrap.Checked := Editor.TableCellAttrs.NoWrap
end
else
for I := 0 to FormTable.GroupBoxCells.ControlCount - 1 do
if not (FormTable.GroupBoxCells.Controls[I] is TGroupBox) then
FormTable.GroupBoxCells.Controls[I].Enabled := False
else
for J := 0 to (FormTable.GroupBoxCells.Controls[I] as TGroupBox).ControlCount - 1 do
(FormTable.GroupBoxCells.Controls[I] as TGroupBox).Controls[J].Enabled := False;
FormTable.ButtonOK.Caption := 'Modify';
FormTable.ButtonCancel.Caption := 'Close';
if FormTable.ShowModal = mrOK then
begin
Editor.AlterTable(StrToIntDef(FormTable.EditRows.Text, 0),
StrToIntDef(FormTable.EditCols.Text, 0),
FormTable.EditCaption.Text);
Editor.TableAttrs.Width := StrToIntDef(FormTable.EditTableWidth.Text, 0);
Editor.TableAttrs.WidthInPercent := FormTable.CheckBoxTableWidthPercent.Checked;
Editor.TableAttrs.Align := THTMLAlign(FormTable.RadioGroupAlignment.ItemIndex);
Editor.TableAttrs.BorderSize := StrToIntDef(FormTable.EditBorderWidth.Text, 0);
Editor.TableAttrs.BorderColor := FormTable.PanelBorderColor.Color;
Editor.TableAttrs.BgColor := FormTable.PanelBgColor.Color;
Editor.TableAttrs.Background := FormTable.EditBackground.Text;
Editor.TableAttrs.CellSpacing := StrToIntDef(FormTable.EditCellSpacing.Text, 0);
Editor.TableAttrs.CellPadding := StrToIntDef(Formtable.EditCellPadding.Text, 0);
Editor.SetTableAttrs(Editor.TableAttrs);
if Editor.IsTableCellSelected then
begin
Editor.TableCellAttrs.Align := THTMLAlign(FormTable.RadioGroupCellAlignment.ItemIndex);
Editor.TableCellAttrs.VAlign := THTMLVAlign(FormTable.RadioGroupCellVAlignment.ItemIndex);
Editor.TableCellAttrs.BorderColor := FormTable.PanelCellBorderColor.Color;
Editor.TableCellAttrs.BgColor := FormTable.PanelCellBgColor.Color;
Editor.TableCellAttrs.Background := FormTable.EditCellBackground.Text;
Editor.TableCellAttrs.Width := StrToIntDef(FormTable.EditCellWidth.Text, 0);
Editor.TableCellAttrs.WidthInPercent := FormTable.CheckBoxCellWidthPercent.Checked;
Editor.TableCellAttrs.Height := StrToIntDef(FormTable.EditCellHeight.Text, 0);
Editor.TableCellAttrs.HeightInPercent := FormTable.CheckBoxCellHeightPercent.Checked;
Editor.TableCellAttrs.NoWrap := FormTable.CheckBoxNoWrap.Checked;
Editor.SetTableCellAttrs(Editor.TableCellAttrs)
end
end
end;
procedure TForm1.MenuItemInsertTextBoxClick(Sender: TObject);
begin
Editor.InsertTextBox('TextBox' + IntToStr(FID));
Inc(FID)
end;
procedure TForm1.MenuItemInsertTextAreaClick(Sender: TObject);
begin
Editor.InsertTextArea('TextArea' + IntToStr(FID));
Inc(FID)
end;
procedure TForm1.MenuItemInsertCheckBoxClick(Sender: TObject);
begin
Editor.InsertCheckBox('CheckBox' + IntToStr(FID));
Inc(FID)
end;
procedure TForm1.MenuItemInsertRadioButtonClick(Sender: TObject);
begin
Editor.InsertRadioButton('RadioButton' + IntToStr(FID));
Inc(FID)
end;
procedure TForm1.MenuItemInsertDropdownBoxClick(Sender: TObject);
begin
Editor.InsertDropdownBox('DropdownBox' + IntToStr(FID));
Inc(FID)
end;
procedure TForm1.MenuItemInsertListBoxClick(Sender: TObject);
begin
Editor.InsertListBox('ListBox' + IntToStr(FID));
Inc(FID)
end;
procedure TForm1.MenuItemInsertButtonClick(Sender: TObject);
begin
Editor.InsertButton('Button' + IntToStr(FID));
Inc(FID)
end;
procedure TForm1.MenuItemInsertIframeClick(Sender: TObject);
begin
Editor.InsertIframe('Iframe' + IntToStr(FID));
Inc(FID)
end;
procedure TForm1.MenuItemInsertMarqueeClick(Sender: TObject);
begin
Editor.InsertMarquee('Marquee' + IntToStr(FID));
Inc(FID)
end;
procedure TForm1.MenuItemInsertLineBreakClick(Sender: TObject);
begin
Editor.InsertLineBreak('', ClearNone)
end;
procedure TForm1.MenuItemInsertNoBreakSpaceClick(Sender: TObject);
begin
Editor.InsertNoBreakSpace
end;
procedure TForm1.MenuItemInsertHorizontalLineClick(Sender: TObject);
begin
Editor.InsertHorizontalLine('')
end;
procedure TForm1.ToolButtonInsertHorizontalLineClick(Sender: TObject);
begin
MenuItemInsertHorizontalLineClick(nil)
end;
procedure TForm1.MenuItemViewTextSizeLargestClick(Sender: TObject);
begin
Editor.TextSize := TextSizeLargest
end;
procedure TForm1.MenuItemViewTextSizeLargerClick(Sender: TObject);
begin
Editor.TextSize := TextSizeLarger
end;
procedure TForm1.MenuItemViewTextSizeMediumClick(Sender: TObject);
begin
Editor.TextSize := TextSizeMedium
end;
procedure TForm1.MenuItemViewTextSizeSmallerClick(Sender: TObject);
begin
Editor.TextSize := TextSizeSmaller
end;
procedure TForm1.MenuItemViewTextSizeSmallestClick(Sender: TObject);
begin
Editor.TextSize := TextSizeSmallest
end;
procedure TForm1.EditorMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Shift = [ssRight] then
Editor.ShowEditMenu(X, Y)
end;
procedure TForm1.EditorDisplayChanged(Sender: TObject);
var
TextSize: TTextSize;
Justify: TJustify;
SL: TStringList;
I: Integer;
FileName, FileCaption, Style: AnsiString;
TableRows, TableCols: Integer;
TableCaption: WideString;
begin
FileName := Editor.FileName;
if FileName = '' then
FileCaption := sUntitled
else
FileCaption := ExtractFileName(FileName);
Caption := FileCaption + ' - ' + Application.Title;
MenuItemFileNew.Enabled := Editor.CanNewDocument;
MenuItemFileOpen.Enabled := Editor.CanLoadFromFile;
MenuItemFileSave.Enabled := Editor.CanSave;
MenuItemFileSaveAs.Enabled := MenuItemFileSave.Enabled;
MenuItemFilePrint.Enabled := Editor.CanPrint;
MenuItemFilePrintPreview.Enabled := Editor.CanDisplayPrintPreviewDialog;
MenuItemFilePageSetup.Enabled := Editor.CanDisplayPageSetupDialog;
ToolButtonNew.Enabled := MenuItemFileNew.Enabled;
ToolButtonOpen.Enabled := MenuItemFileOpen.Enabled;
ToolButtonSave.Enabled := MenuItemFileSave.Enabled;
ToolButtonPrint.Enabled := MenuItemFilePrint.Enabled;
ToolButtonPreview.Enabled := MenuItemFilePrintPreview.Enabled;
MenuItemEditUndo.Enabled := Editor.CanUndo;
MenuItemEditUndo.Caption := Editor.UndoHint;
MenuItemEditRedo.Enabled := Editor.CanRedo;
MenuItemEditRedo.Caption := Editor.RedoHint;
MenuItemEditCut.Enabled := Editor.CanCut;
MenuItemEditCopy.Enabled := Editor.CanCopy;
MenuItemEditPaste.Enabled := Editor.CanPaste;
MenuItemEditClear.Enabled := Editor.CanClearSelection;
MenuItemEditSelectAll.Enabled := Editor.CanSelectAll;
MenuItemEditFind.Enabled := Editor.CanDisplayFindDialog;
ToolButtonCut.Enabled := MenuItemEditCut.Enabled;
ToolButtonCopy.Enabled := MenuItemEditCopy.Enabled;
ToolButtonPaste.Enabled := MenuItemEditPaste.Enabled;
ToolButtonUndo.Enabled := MenuItemEditUndo.Enabled;
ToolButtonUndo.Hint := MenuItemEditUndo.Caption;
if ToolButtonUndo.Enabled then
ToolButtonUndo.Hint := ToolButtonUndo.Hint + ' (Ctrl+Z)';
ToolButtonRedo.Enabled := MenuItemEditRedo.Enabled;
ToolButtonRedo.Hint := MenuItemEditRedo.Caption;
if ToolButtonRedo.Enabled then
ToolButtonRedo.Hint := ToolButtonRedo.Hint + ' (Ctrl+Y)';
MenuItemViewTextSizeLargest.Enabled := Editor.CanSetTextSize;
MenuItemViewTextSizeLarger.Enabled := MenuItemViewTextSizeLargest.Enabled;
MenuItemViewTextSizeMedium.Enabled := MenuItemViewTextSizeLargest.Enabled;
MenuItemViewTextSizeSmaller.Enabled := MenuItemViewTextSizeLargest.Enabled;
MenuItemViewTextSizeSmallest.Enabled := MenuItemViewTextSizeLargest.Enabled;
MenuItemViewDetails.Enabled := True;
MenuItemViewSource.Enabled := Editor.CanGetSource;
TextSize := Editor.TextSize;
MenuItemViewTextSizeLargest.Checked := TextSize = TextSizeLargest;
MenuItemViewTextSizeLarger.Checked := TextSize = TextSizeLarger;
MenuItemViewTextSizeMedium.Checked := TextSize = TextSizeMedium;
MenuItemViewTextSizeSmaller.Checked := TextSize = TextSizeSmaller;
MenuItemViewTextSizeSmallest.Checked := TextSize = TextSizeSmallest;
MenuItemViewDetails.Checked := Editor.ShowDetails;
if not (csLButtonDown in Editor.ControlState) then
begin
ComboBoxFontName.ItemIndex := ComboBoxFontName.Items.IndexOf(Editor.FontName);
ComboBoxFontHTMLSize.ItemIndex := Editor.FontHTMLSize - 1
end;
ComboBoxFontName.Enabled := Editor.CanSetFontName;
ComboBoxFontHTMLSize.Enabled := Editor.CanSetFontHTMLSize;
ToolButtonBold.Down := Editor.Bold;
ToolButtonBold.Enabled := Editor.CanToggleBold(True);
ToolButtonItalic.Down := Editor.Italic;
ToolButtonitalic.Enabled := Editor.CanToggleItalic(True);
ToolButtonUnderline.Down := Editor.Underline;
ToolButtonUnderline.Enabled := Editor.CanToggleUnderline(True);
MenuItemNumbers.Checked := Editor.Numbering;
MenuItemNumbers.Enabled := Editor.CanToggleNumbering;
MenuItemBullets.Checked := Editor.Bullets;
MenuItemBullets.Enabled := Editor.CanToggleBullets;
MenuItemBulletsNone.Checked := not (MenuItemNumbers.Checked or MenuItemBullets.Checked);
ToolButtonNumbering.Down := MenuItemNumbers.Checked;
ToolButtonNumbering.Enabled := MenuItemNumbers.Enabled;
ToolButtonBullets.Down := MenuItemBullets.Checked;
ToolButtonBullets.Enabled := MenuItemBullets.Enabled;
MenuItemFormatIncreaseIndent.Enabled := Editor.CanIncreaseIndentation;
MenuItemFormatDecreaseIndent.Enabled := Editor.CanDecreaseIndentation;
ToolButtonDecInd.Enabled := MenuItemFormatIncreaseIndent.Enabled;
ToolButtonIncInd.Enabled := MenuItemFormatDecreaseIndent.Enabled;
Justify := Editor.Justify;
MenuItemJustifyNone.Checked := Justify = JustifyNone;
MenuItemJustifyNone.Enabled := Editor.CanJustifyNone;
MenuItemJustifyLeft.Checked := Justify = JustifyLeft;
MenuItemJustifyLeft.Enabled := Editor.CanJustifyLeft;
MenuItemJustifyCenter.Checked := Justify = JustifyCenter;
MenuItemJustifyCenter.Enabled := Editor.CanJustifyCenter;
MenuItemJustifyRight.Checked := Justify = JustifyRight;
MenuItemJustifyRight.Enabled := Editor.CanJustifyRight;
MenuItemJustifyFull.Checked := Justify = JustifyFull;
MenuItemJustifyFull.Enabled := Editor.CanJustifyFull;
ToolButtonJustifyLeft.Down := MenuItemJustifyLeft.Checked;
ToolButtonJustifyLeft.Enabled := MenuItemJustifyLeft.Enabled;
ToolButtonJustifyCenter.Down := MenuItemJustifyCenter.Checked;
ToolButtonJustifyCenter.Enabled := MenuItemJustifyCenter.Enabled;
ToolButtonJustifyRight.Down := MenuItemJustifyRight.Checked;
ToolButtonJustifyRight.Enabled := MenuItemJustifyRight.Enabled;
ToolButtonJustifyFull.Down := MenuItemJustifyFull.Checked;
ToolButtonJustifyFull.Enabled := MenuItemJustifyFull.Enabled;
MenuItemInsertHorizontalLine.Enabled := Editor.CanInsertHorizontalLine;
ToolButtonInsertHorizontalLine.Enabled := MenuItemInsertHorizontalLine.Enabled;
MenuItemInsertHyperlink.Enabled := Editor.CanDisplayHyperlinkDialog;
ToolButtonInsertHyperlink.Enabled := MenuItemInsertHyperlink.Enabled;
MenuItemInsertPicture.Enabled := Editor.CanInsertImage;
ToolButtonInsertPicture.Enabled := MenuItemInsertPicture.Enabled;
ToolButtonBackColor.Enabled := Editor.CanSetBackColor;
ToolButtonForeColor.Enabled := Editor.CanSetForeColor;
MenuItemInsertHTML.Enabled := Editor.CanInsertHTML;
MenuItemInsertComment.Enabled := Editor.CanInsertComment;
MenuItemInsertTextBox.Enabled := Editor.CanInsertTextBox;
MenuItemInsertTextArea.Enabled := Editor.CanInsertTextArea;
MenuItemInsertCheckBox.Enabled := Editor.CanInsertCheckBox;
MenuItemInsertRadioButton.Enabled := Editor.CanInsertRadioButton;
MenuItemInsertDropdownBox.Enabled := Editor.CanInsertDropdownBox;
MenuItemInsertListBox.Enabled := Editor.CanInsertListBox;
MenuItemInsertButton.Enabled := Editor.CanInsertButton;
MenuItemInsertControl.Enabled :=
MenuItemInsertTextBox.Enabled or MenuItemInsertTextArea.Enabled or
MenuItemInsertCheckBox.Enabled or MenuItemInsertRadioButton.Enabled or
MenuItemInsertDropdownBox.Enabled or MenuItemInsertListBox.Enabled or
MenuItemInsertButton.Enabled;
MenuItemInsertIframe.Enabled := Editor.CanInsertIframe;
MenuItemInsertMarquee.Enabled := Editor.CanInsertMarquee;
MenuItemInsertObject.Enabled := Editor.CanDisplayInsertObjectDialog;
MenuItemInsertLineBreak.Enabled := Editor.CanInsertLineBreak(ClearNone);
MenuItemInsertNoBreakSpace.Enabled := Editor.CanInsertNoBreakSpace;
MenuItemFormatStyle.Enabled := Editor.CanSetParagraphStyle;
if MenuItemFormatStyle.Enabled then
begin
SL := TStringList.Create;
try
for I := MenuItemFormatStyle.Count - 1 downto 0 do
MenuItemFormatStyle.Items[I].Free;
if Editor.GetParagraphStyles(SL) then
begin
Style := Editor.ParagraphStyle;
for I := 0 to SL.Count - 1 do
begin
MenuItemFormatStyle.Add(TMenuItem.Create(MenuItemFormatStyle));
MenuItemFormatStyle.Items[I].Caption := SL[I];
MenuItemFormatStyle.Items[I].RadioItem := True;
if SL[I] = Style then
MenuItemFormatStyle.Items[I].Checked := True;
MenuItemFormatStyle.Items[I].OnClick := SelectStyle
end
end
finally
SL.Free
end
end;
MenuItemFormatFont.Enabled := Editor.CanDisplayFontDialog;
MenuItemBackgroundClear.Enabled := Editor.Background <> '';
MenuItemFormatToggleAbsolutePositioning.Enabled := Editor.CanToggleAbsolutePositioning;
MenuItemTableInsertTable.Enabled := Editor.CanInsertTable;
MenuItemTableInsertColumn.Enabled := Editor.CanTableInsertColumn;
MenuItemTableInsertRow.Enabled := Editor.CanTableInsertRow;
MenuItemTableInsertCell.Enabled := Editor.CanTableInsertCell;
MenuItemTableDeleteColumn.Enabled := Editor.CanTableDeleteColumn;
MenuItemTableDeleteRow.Enabled := Editor.CanTableDeleteRow;
MenuItemTableDeleteCell.Enabled := Editor.CanTableDeleteCell;
MenuItemTableMergeCells.Enabled := Editor.CanTableMergeCells;
MenuItemTableSplitCell.Enabled := Editor.CanTableSplitCell;
MenuItemTableProperties.Enabled := Editor.IsTableSelected;
MenuItemTableShowBorders.Checked := Editor.ShowBorders;
StatusBar.Panels[0].Text := 'Pos: ' + IntToStr(Editor.SelStart + 1);
if Editor.Modified then
StatusBar.Panels[1].Text := 'Modified'
else
StatusBar.Panels[1].Text := '';
StatusBar.Panels[2].Text := Editor.ParagraphStyle;
if Editor.IsTableSelected then
begin
Editor.GetTableInfo(TableRows, TableCols, TableCaption, nil);
StatusBar.Panels[3].Text := 'Table (' + IntToStr(TableCols) + ' columns, ' + IntToStr(TableRows) + ' rows)'
end
else
StatusBar.Panels[3].Text := ''
end;
procedure TForm1.MenuItemFormatToggleAbsolutePositioningClick(Sender: TObject);
begin
Editor.ToggleAbsolutePositioning
end;
procedure TForm1.ComboBoxFontHTMLSizeCloseUp(Sender: TObject);
begin
Editor.SetFocus
end;
procedure TForm1.ComboBoxFontNameCloseUp(Sender: TObject);
begin
Editor.SetFocus
end;
procedure TForm1.ComboBoxFontNameChange(Sender: TObject);
begin
Editor.FontName := (Sender as TComboBox).Text
end;
procedure TForm1.ComboBoxFontHTMLSizeChange(Sender: TObject);
var
S: AnsiString;
begin
S := (Sender as TComboBox).Text;
Editor.FontHTMLSize := StrToInt(S[1])
end;
procedure TForm1.EditorTimeout(Sender: TObject);
begin
ShowMessage(sTimeout)
end;
procedure TForm1.MenuItemInsertObjectClick(Sender: TObject);
begin
Editor.InsertObjectDialog
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -