📄 unit1.pas
字号:
end;
procedure TForm1.MenuItemInsertPictureClick(Sender: TObject);
begin
Editor.PictureDialog
end;
procedure TForm1.MenuItemInsertHyperlinkClick(Sender: TObject);
begin
Editor.HyperlinkDialog
end;
procedure TForm1.MenuItemEditFindClick(Sender: TObject);
begin
Editor.FindDialog
end;
procedure TForm1.SelectStyle(Sender: TObject);
var
Style: WideString;
P: Integer;
begin
Style := (Sender as TMenuItem).Caption;
P := Pos('&', Style);
if P > 0 then
Delete(Style, P, 1);
Editor.ParagraphStyle := Style
end;
procedure TForm1.MenuItemFormatFontClick(Sender: TObject);
begin
Editor.FontDialog
end;
procedure TForm1.MenuItemBackgroundColorClick(Sender: TObject);
begin
ColorDialog1.Color := Editor.BgColor;
if ColorDialog1.Execute then
Editor.BgColor := ColorDialog1.Color
end;
procedure TForm1.ToolButtonBoldClick(Sender: TObject);
begin
(Sender as TToolButton).Down := True;
Editor.ToggleBold(True)
end;
procedure TForm1.ToolButtonItalicClick(Sender: TObject);
begin
(Sender as TToolButton).Down := True;
Editor.ToggleItalic(True)
end;
procedure TForm1.ToolButtonUnderlineClick(Sender: TObject);
begin
(Sender as TToolButton).Down := True;
Editor.ToggleUnderline(True)
end;
procedure TForm1.ToolButtonUndoClick(Sender: TObject);
begin
Editor.Undo
end;
procedure TForm1.ToolButtonRedoClick(Sender: TObject);
begin
Editor.Redo
end;
procedure TForm1.ToolButtonCutClick(Sender: TObject);
begin
Editor.CutToClipboard
end;
procedure TForm1.ToolButtonCopyClick(Sender: TObject);
begin
Editor.CopyToClipboard
end;
procedure TForm1.ToolButtonPasteClick(Sender: TObject);
begin
Editor.PasteFromClipboard
end;
procedure TForm1.ToolButtonPrintClick(Sender: TObject);
begin
Editor.Print
end;
procedure TForm1.MenuItemFileNewClick(Sender: TObject);
begin
FileNew
end;
procedure TForm1.MenuItemFormatIncreaseIndentClick(Sender: TObject);
begin
Editor.IncreaseIndentation
end;
procedure TForm1.MenuItemFormatDecreaseIndentClick(Sender: TObject);
begin
Editor.DecreaseIndentation
end;
procedure TForm1.MenuItemJustifyNoneClick(Sender: TObject);
begin
Editor.Justify := JustifyNone
end;
procedure TForm1.MenuItemJustifyLeftClick(Sender: TObject);
begin
Editor.Justify := JustifyLeft
end;
procedure TForm1.MenuItemJustifyCenterClick(Sender: TObject);
begin
Editor.Justify := JustifyCenter
end;
procedure TForm1.MenuItemJustifyRightClick(Sender: TObject);
begin
Editor.Justify := JustifyRight
end;
procedure TForm1.MenuItemJustifyFullClick(Sender: TObject);
begin
Editor.Justify := JustifyFull
end;
procedure TForm1.MenuItemNumbersClick(Sender: TObject);
begin
Editor.Numbering := True
end;
procedure TForm1.MenuItemBulletsClick(Sender: TObject);
begin
Editor.Bullets := True
end;
procedure TForm1.MenuItemBulletsNoneClick(Sender: TObject);
begin
Editor.Numbering := False;
Editor.Bullets := False
end;
procedure TForm1.MenuItemTableInsertColumnClick(Sender: TObject);
begin
Editor.TableInsertColumn
end;
procedure TForm1.MenuItemTableInsertRowClick(Sender: TObject);
begin
Editor.TableInsertRow
end;
procedure TForm1.MenuItemTableDeleteColumnClick(Sender: TObject);
begin
Editor.TableDeleteColumn
end;
procedure TForm1.MenuItemTableDeleteRowClick(Sender: TObject);
begin
Editor.TableDeleteRow
end;
procedure TForm1.ToolButtonNewClick(Sender: TObject);
begin
FileNew
end;
procedure TForm1.FileNew;
var
FileName: AnsiString;
begin
if Editor.Modified then
begin
FileName := Editor.FileName;
if FileName = '' then
FileName := sUntitled;
case MessageDlg(Format(sSaveChanges, [FileName]), mtConfirmation, mbYesNoCancel, 0) of
idYes:
if not FileSave then
Exit;
idNo:
;
idCancel:
Exit
end
end;
Editor.NewDocument
end;
procedure TForm1.ToolButtonPreviewClick(Sender: TObject);
begin
Editor.PrintPreviewDialog
end;
procedure TForm1.ToolButtonNumberingClick(Sender: TObject);
begin
(Sender as TToolButton).Down := True;
Editor.ToggleNumbering
end;
procedure TForm1.ToolButtonBulletsClick(Sender: TObject);
begin
(Sender as TToolButton).Down := True;
Editor.ToggleBullets
end;
procedure TForm1.ToolButtonDecIndClick(Sender: TObject);
begin
Editor.DecreaseIndentation
end;
procedure TForm1.ToolButtonIncIndClick(Sender: TObject);
begin
Editor.IncreaseIndentation
end;
procedure TForm1.ToolButtonJustifyLeftClick(Sender: TObject);
begin
(Sender as TToolButton).Down := True;
Editor.Justify := JustifyLeft
end;
procedure TForm1.ToolButtonJustifyCenterClick(Sender: TObject);
begin
(Sender as TToolButton).Down := True;
Editor.Justify := JustifyCenter
end;
procedure TForm1.ToolButtonJustifyRightClick(Sender: TObject);
begin
(Sender as TToolButton).Down := True;
Editor.Justify := JustifyRight
end;
procedure TForm1.ToolButtonJustifyFullClick(Sender: TObject);
begin
(Sender as TToolButton).Down := True;
Editor.Justify := JustifyFull
end;
procedure TForm1.ToolButtonInsertHyperlinkClick(Sender: TObject);
begin
MenuItemInsertHyperlinkClick(nil)
end;
procedure TForm1.ToolButtonInsertPictureClick(Sender: TObject);
begin
Editor.PictureDialog
end;
procedure TForm1.ToolButtonForeColorClick(Sender: TObject);
begin
if ColorDialog1.Execute then
Editor.ForeColor := ColorDialog1.Color
end;
procedure TForm1.ToolButtonBackColorClick(Sender: TObject);
begin
if ColorDialog1.Execute then
Editor.BackColor := ColorDialog1.Color
end;
procedure TForm1.ToolButtonSaveClick(Sender: TObject);
begin
FileSave
end;
procedure TForm1.MenuItemFileSaveClick(Sender: TObject);
begin
FileSave
end;
function TForm1.FileSave: Boolean;
begin
Result := True;
if Editor.FileName <> '' then
Editor.SaveToFile(Editor.FileName)
else
if Editor.SaveDialog('') = '' then
Result := False
end;
procedure TForm1.MenuItemFileSaveAsClick(Sender: TObject);
begin
Editor.SaveDialog('')
end;
procedure TForm1.MenuItemFilePageSetupClick(Sender: TObject);
begin
Editor.PageSetupDialog
end;
procedure TForm1.MenuItemFileOpenClick(Sender: TObject);
begin
FileOpen
end;
procedure TForm1.ToolButtonOpenClick(Sender: TObject);
begin
FileOpen
end;
procedure TForm1.FileOpen;
var
FileName: AnsiString;
begin
if Editor.Modified then
begin
FileName := Editor.FileName;
case MessageDlg(Format(sSaveChanges, [FileName]), mtConfirmation, mbYesNoCancel, 0) of
idYes:
if not FileSave then
Exit;
idNo:
;
idCancel:
Exit
end
end;
Editor.OpenDialog('')
end;
procedure TForm1.MenuItemBackgroundChooseClick(Sender: TObject);
begin
if OpenDialogBackground.Execute then
Editor.Background := OpenDialogBackground.FileName
end;
procedure TForm1.MenuItemBackgroundClearClick(Sender: TObject);
begin
Editor.Background := ''
end;
procedure TForm1.MenuItemTableShowBordersClick(Sender: TObject);
begin
(Sender as TMenuItem).Checked := not (Sender as TMenuItem).Checked;
Editor.ShowBorders := (Sender as TMenuItem).Checked
end;
procedure TForm1.MenuItemViewDetailsClick(Sender: TObject);
begin
Editor.ShowDetails := not Editor.ShowDetails
end;
procedure TForm1.MenuItemInsertHTMLClick(Sender: TObject);
begin
if FormInsertHTML.ShowModal = mrOK then
Editor.InsertHTML(FormInsertHTML.Memo1.Text)
end;
procedure TForm1.MenuItemInsertCommentClick(Sender: TObject);
begin
if FormInsertComment.ShowModal = mrOK then
Editor.InsertComment(FormInsertComment.Memo1.Text)
end;
procedure TForm1.MenuItemAboutClick(Sender: TObject);
begin
FormAbout.ShowModal
end;
procedure TForm1.MenuItemViewSourceClick(Sender: TObject);
begin
Screen.Cursor := crHourGlass;
SetRichEditText(FormSource.RichEdit1, Editor.Source);
Screen.Cursor := crDefault;
FormSource.ShowModal
end;
procedure TForm1.MenuItemFormatPagePropertiesClick(Sender: TObject);
begin
FormPageProperties.EditTile.Text := Editor.Title;
FormPageProperties.PanelText.Color := Editor.TextColor;
FormPageProperties.PanelLink.Color := Editor.LinkColor;
FormPageProperties.PanelVisitedLink.Color := Editor.LinkColorVisited;
FormPageProperties.PanelActiveLink.Color := Editor.LinkColorActive;
if FormPageProperties.ShowModal = mrOK then
begin
Editor.Title := FormPageProperties.EditTile.Text;
Editor.TextColor := FormPageProperties.PanelText.Color;
Editor.LinkColor := FormPageProperties.PanelLink.Color;
Editor.LinkColorVisited := FormPageProperties.PanelVisitedLink.Color;
Editor.LinkColorActive := FormPageProperties.PanelActiveLink.Color
end
end;
procedure TForm1.MenuItemTableMergeCellsClick(Sender: TObject);
begin
Editor.TableMergeCells
end;
procedure TForm1.MenuItemTableSplitCellClick(Sender: TObject);
begin
Editor.TableSplitCell
end;
procedure TForm1.MenuItemTableInsertCellClick(Sender: TObject);
begin
Editor.TableInsertCell
end;
procedure TForm1.MenuItemTableDeleteCellClick(Sender: TObject);
begin
Editor.TableDeleteCell
end;
procedure TForm1.MenuItemTableInsertTableClick(Sender: TObject);
var
I, J: Integer;
begin
FormTable.ButtonOK.Caption := 'Insert Table';
FormTable.ButtonCancel.Caption := 'Cancel';
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;
if FormTable.ShowModal = mrOK then
begin
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.TableCellAttrs.Align := THTMLAlign(FormTable.RadioGroupCellAlignment.ItemIndex);
Editor.TableCellAttrs.VAlign := THTMLVAlign(FormTable.RadioGroupCellVAlignment.ItemIndex);
Editor.TableCellAttrs.NoWrap := FormTable.CheckBoxNoWrap.Checked;
Editor.TableCellAttrs.Background := FormTable.EditCellBackground.Text;
Editor.TableCellAttrs.BgColor := FormTable.PanelCellBgColor.Color;
Editor.TableCellAttrs.BorderColor := FormTable.PanelCellBorderColor.Color;
Editor.TableCellAttrs.Width := StrToIntDef(FormTable.EditCellWidth.Text, 0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -