dpagesetup.pas
来自「一个mwEdit控件原码,比mwCuuEdit0.92a功能先进.」· PAS 代码 · 共 564 行 · 第 1/2 页
PAS
564 行
{-------------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is: DPageSetup.pas, released 2000-06-01.
The Original Code is part of the TestPP project, written by
Morten J. Skovrup for the SynEdit component suite.
All Rights Reserved.
Contributors to the SynEdit project are listed in the Contributors.txt file.
Alternatively, the contents of this file may be used under the terms of the
GNU General Public License Version 2 or later (the "GPL"), in which case
the provisions of the GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms
of the GPL and not to allow others to use your version of this file
under the MPL, indicate your decision by deleting the provisions above and
replace them with the notice and other provisions required by the GPL.
If you do not delete the provisions above, a recipient may use your version
of this file under either the MPL or the GPL.
$Id: DPageSetup.pas,v 1.2 2000/11/22 08:37:05 mghie Exp $
You may retrieve the latest version of this file at the SynEdit home page,
located at http://SynEdit.SourceForge.net
Known Issues:
-------------------------------------------------------------------------------}
unit DPageSetup;
{$I SynEdit.inc}
interface
uses
Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
Buttons, ExtCtrls, ComCtrls, ToolWin, ImgList, ActnList, Dialogs,
SynEditPrintTypes, SynEditPrint, SynEditPrintMargins,
SynEditPrintHeaderFooter;
type
TPageSetupDlg = class(TForm)
OKBtn: TButton;
CancelBtn: TButton;
PageControl: TPageControl;
Margins: TTabSheet;
HeaderFooter: TTabSheet;
Image1: TImage;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
CBMirrorMargins: TCheckBox;
EditLeft: TEdit;
EditRight: TEdit;
EditTop: TEdit;
EditBottom: TEdit;
EditGutter: TEdit;
EditHeader: TEdit;
EditFooter: TEdit;
EditHFInternalMargin: TEdit;
EditLeftHFTextIndent: TEdit;
EditRightHFTextIndent: TEdit;
CBUnits: TComboBox;
GroupBox1: TGroupBox;
REHeaderLeft: TRichEdit;
REHeaderCenter: TRichEdit;
REHeaderRight: TRichEdit;
CBHeaderMirror: TCheckBox;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
GroupBox2: TGroupBox;
CBHeaderLine: TCheckBox;
CBHeaderBox: TCheckBox;
CBHeaderShadow: TCheckBox;
HeaderLineColorBtn: TButton;
HeaderShadowColorBtn: TButton;
PBHeaderLine: TPaintBox;
PBHeaderShadow: TPaintBox;
GroupBox3: TGroupBox;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
REFooterLeft: TRichEdit;
REFooterCenter: TRichEdit;
REFooterRight: TRichEdit;
CBFooterMirror: TCheckBox;
GroupBox4: TGroupBox;
PBFooterLine: TPaintBox;
PBFooterShadow: TPaintBox;
CBFooterLine: TCheckBox;
CBFooterBox: TCheckBox;
CBFooterShadow: TCheckBox;
FooterLineColorBtn: TButton;
FooterShadowColorBtn: TButton;
ImageList1: TImageList;
ActionList1: TActionList;
PageNumCmd: TAction;
PagesCmd: TAction;
TimeCmd: TAction;
DateCmd: TAction;
FontCmd: TAction;
BoldCmd: TAction;
ItalicCmd: TAction;
UnderlineCmd: TAction;
CBLineNumbers: TCheckBox;
CBLineNumbersInMargin: TCheckBox;
CBHighlight: TCheckBox;
CBColors: TCheckBox;
CBWrap: TCheckBox;
FontDialog: TFontDialog;
ColorDialog: TColorDialog;
TitleCmd: TAction;
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
ToolButton11: TToolButton;
ToolButton12: TToolButton;
ToolButton6: TToolButton;
ToolButton10: TToolButton;
ToolButton7: TToolButton;
ToolButton8: TToolButton;
ToolButton9: TToolButton;
procedure PageNumCmdExecute(Sender: TObject);
procedure PagesCmdExecute(Sender: TObject);
procedure TimeCmdExecute(Sender: TObject);
procedure DateCmdExecute(Sender: TObject);
procedure FontCmdExecute(Sender: TObject);
procedure BoldCmdExecute(Sender: TObject);
procedure ItalicCmdExecute(Sender: TObject);
procedure UnderlineCmdExecute(Sender: TObject);
procedure REHeaderLeftEnter(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure CBFooterLineEnter(Sender: TObject);
procedure PageControlChange(Sender: TObject);
procedure HeaderLineColorBtnClick(Sender: TObject);
procedure PBHeaderLinePaint(Sender: TObject);
procedure HeaderShadowColorBtnClick(Sender: TObject);
procedure FooterLineColorBtnClick(Sender: TObject);
procedure FooterShadowColorBtnClick(Sender: TObject);
procedure REHeaderLeftSelectionChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure CBUnitsChange(Sender: TObject);
procedure TitleCmdExecute(Sender: TObject);
private
{ Private declarations }
Editor: TRichEdit;
CharPos: TPoint;
OldStart: Integer;
FMargins: TSynEditPrintMargins;
FInternalCall: Boolean;
procedure SetOptions;
procedure UpdateCursorPos;
procedure SelectLine(LineNum: Integer);
function CurrText: TTextAttributes;
procedure SetMargins(SynEditMargins: TSynEditPrintMargins);
procedure GetMargins(SynEditMargins: TSynEditPrintMargins);
procedure AddLines(HeadFoot: THeaderFooter; AEdit: TRichEdit;
Al: TALignment);
procedure SelectNone;
public
{ Public declarations }
procedure SetValues(SynEditPrint: TSynEditPrint);
procedure GetValues(SynEditPrint: TSynEditPrint);
end;
var
PageSetupDlg: TPageSetupDlg;
implementation
uses
RichEdit, ShellAPI, Messages;
{$R *.DFM}
procedure TPageSetupDlg.FormCreate(Sender: TObject);
begin
FMargins := TSynEditPrintMargins.Create;
FInternalCall := False;
end;
procedure TPageSetupDlg.FormDestroy(Sender: TObject);
begin
FMargins.Free;
end;
procedure TPageSetupDlg.FormShow(Sender: TObject);
begin
Editor := REHeaderLeft;
PageControl.ActivePage := Margins;
SetOptions;
UpdateCursorPos;
end;
procedure TPageSetupDlg.SetOptions;
begin
PageNumCmd.Enabled := Editor.Focused;
PagesCmd.Enabled := Editor.Focused;
TimeCmd.Enabled := Editor.Focused;
DateCmd.Enabled := Editor.Focused;
TitleCmd.Enabled := Editor.Focused;
FontCmd.Enabled := Editor.Focused;
BoldCmd.Enabled := Editor.Focused;
ItalicCmd.Enabled := Editor.Focused;
UnderlineCmd.Enabled := Editor.Focused;
end;
procedure TPageSetupDlg.REHeaderLeftEnter(Sender: TObject);
begin
Editor := Sender as TRichEdit;
SetOptions;
end;
procedure TPageSetupDlg.CBFooterLineEnter(Sender: TObject);
begin
SetOptions;
end;
procedure TPageSetupDlg.REHeaderLeftSelectionChange(Sender: TObject);
begin
UpdateCursorPos;
end;
procedure TPageSetupDlg.UpdateCursorPos;
begin
CharPos.Y := SendMessage(Editor.Handle, EM_EXLINEFROMCHAR, 0, Editor.SelStart);
CharPos.X := (Editor.SelStart - SendMessage(Editor.Handle, EM_LINEINDEX, CharPos.Y, 0));
end;
procedure TPageSetupDlg.SelectLine(LineNum: Integer);
begin
OldStart := Editor.SelStart;
Editor.SelStart := SendMessage(Editor.Handle, EM_LINEINDEX, LineNum, 0);
Editor.SelLength := Length(Editor.Lines[LineNum]);
end;
procedure TPageSetupDlg.SelectNone;
begin
Editor.SelStart := OldStart;
Editor.SelLength := 0;
end;
function TPageSetupDlg.CurrText: TTextAttributes;
begin
Result := Editor.SelAttributes;
end;
procedure TPageSetupDlg.PageNumCmdExecute(Sender: TObject);
begin
Editor.SelText := '$PAGENUM$';
end;
procedure TPageSetupDlg.PagesCmdExecute(Sender: TObject);
begin
Editor.SelText := '$PAGECOUNT$';
end;
procedure TPageSetupDlg.TimeCmdExecute(Sender: TObject);
begin
Editor.SelText := '$TIME$';
end;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?