📄 wwriched.pas
字号:
procedure CreateRuntimeComponents; virtual;
public
DialogRichEdit: TwwCustomRichEdit;
RichEditForm: TForm;
FindDialog1: TFindDialog;
ReplaceDialog1: TReplaceDialog;
FontDialog1: TFontDialog;
FirstLineText: string;
SkipPaint, SkipErase: boolean;
Patch: Variant;
DefaultPopupMenu: TPopupMenu;
BeforePopup: boolean;
LastColor: TColor; // Color to restore to when it gets the focus
ClickTime: longint; // Used to send dbl-click to parent if in grid.
TotalPages: integer;
// {$ifdef wwDelphi4Up}
// function FindText(const SearchStr: string;
// StartPos, Length: Integer; Options: TSearchTypes): Integer; virtual;
// {$endif}
Function EffectiveEditWidth: TwwRichEditWidth;
Procedure SetTextBackgroundColor(BackColor: TColor);
function GetTextBackgroundColor: TColor;
function FindTextBefore(const SearchStr: string;
StartPos, Length: Integer; Options: TSearchTypes): Integer; virtual;
function InsertObjectDialog: Boolean; virtual;
function ObjectPropertiesDialog: Boolean; virtual;
procedure DoVerb(Verb: Integer);
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function Execute: boolean; virtual; { shows dialog }
procedure ExecuteFindDialog; virtual;
procedure ExecuteReplaceDialog; virtual;
procedure ExecuteFontDialog; virtual;
function ExecuteParagraphDialog: boolean; virtual;
Procedure ExecuteTabDialog; virtual;
Procedure FindNextMatch; virtual;
Procedure FindReplace; virtual;
Function FindReplaceText(SearchText, ReplaceText: string; { New IP 2000 method }
SearchTypes: TSearchTypes): boolean; virtual;
procedure SetBullet(val: boolean);
procedure SetBold(val: boolean);
procedure SetItalic(val: boolean);
procedure SetUnderline(val: boolean);
Procedure Undo;
Procedure Redo;
Function CanPaste: boolean;
Function CanUndo: boolean;
Function CanRedo: boolean;
Function CanCut: boolean;
Function CanFindNext: boolean;
procedure InsertBitmap(Pict: TBitmap); // 2007
Procedure CopyRichEditFromBlob(Field: TField);
Procedure CopyRichEdittoBlob(Field: TField);
Procedure CopyRichEditTo(val: TCustomRichEdit);
Procedure AppendRichEditFrom(val: TCustomRichEdit);
Procedure SetRichEditFontAttributes(
FontName: string; FontSize: integer; FontStyle: TFontStyles;
FontColor: TColor);
procedure SetStyleAttribute(Attr: TFontStyle; AttrOn: Boolean);
function GetCharSetOfFontName(const FaceName : string) : integer;
procedure GetParaIndent(var LeftIndent, RightIndent, FirstIndent: integer);
procedure SetParaFormat(
Options: TwwRichEditParaOptions;
alignment: string;
bulletStyle: boolean;
leftindent, rightindent, firstlineindent: integer;
tabCount: integer; tabArray: Pointer;
SpaceBefore, SpaceAfter, LineSpacing: integer;
LineSpacingRule: integer);
Function GetRTFText: string;
procedure SetRtfText(InsertText: string); // 2007
Function GetPrinterRect: TRect;
procedure GetParaFormat(var Format: TwwParaFormat2);
Function UnitStrToTwips(str: string): integer; { Convert to twips }
Function UnitsToTwips(val: double): integer; { Convert to twips }
Function FormatUnitStr(val: double): string; { Append units to number }
Function RoundedFormatUnitStr(units: double; intervals: integer): string; { Append units to number }
Function TwipsToUnits(val: integer): double;
Procedure DoInitDialog(Form: TForm); virtual;
Procedure DoCloseDialog(Form: TForm); virtual;
Procedure DoCreateDialog(Form: TForm); virtual;
Procedure SetEditRect;
procedure Print(const Caption: string);
{$ifdef wwDelphi4Up}override;{$endif}
{$ifdef ver110}override;{$endif}
Procedure UpdatePrinter;
Function ILines: TStrings;
Function MSWordSpellChecker: boolean; virtual;
Function MSWordPrintDocument(TemplateFileName: string): boolean; virtual;
Procedure GetRTFSelection (DestStream: TStream);
Procedure PutRTFSelection (SourceStream: TStream);
Procedure Import(Format: string; FileName: string);
Procedure Export(Format: string; FileName: string);
Procedure PrintPreview;
procedure DoPrintHeader(DrawRect: TRect;
PageNumber: integer;
var LeftText, CenterText, RightText: string;
var DoDefault: boolean); virtual;
procedure DoPrintFooter(DrawRect: TRect;
PageNumber: integer;
var LeftText, CenterText, RightText: string;
var DoDefault: boolean); virtual;
property Field: TField read GetField;
property OleSelObject: IOleObject read FOleSelObject;
property RichEditOle: IRichEditOLE read FRichEditOle;
property RichEditOleCallback: IRichEditOleCallback read FRichEditOleCallback;
{ to be published}
property PopupOptions: TwwRichEditPopupOptions read FPopupOptions write FPopupOptions default
[rpoPopupEdit, rpoPopupCut, rpoPopupCopy, rpoPopupPaste,
rpoPopupFind, rpoPopupReplace, rpoPopupInsertObject,
rpoPopupBullet, rpoPopupFont, rpoPopupParagraph, rpoPopupTabs, rpoPopupMSWordSpellCheck];
property EditorOptions: TwwRichEditOptions read FEditorOptions write FEditorOptions default
[reoShowSaveExit, reoShowPrint, reoShowPrintPreview, reoShowPageSetup,
reoShowFormatBar, reoShowToolbar, reoShowStatusBar,
reoShowHints, reoShowRuler, reoShowInsertObject ,reoCloseOnEscape,
reoFlatButtons, reoShowMainMenuIcons, reoShowSpellCheck];
property RichEditVersion: integer read FRichEditVersion write FRichEditVersion;
property HighlightColor: TColor read FHighlightColor write FHighlightColor default clYellow;
property EditorCaption : string read FEditorCaption write FEditorCaption;
property MeasurementUnits: TwwMeasurementUnits read FUnits write FUnits;
property OnInitDialog: TwwOnRichEditDlgEvent read FOnInitDialog write FOnInitDialog;
property OnCloseDialog: TwwOnRichEditDlgEvent read FOnCloseDialog write FOnCloseDialog;
property OnCreateDialog: TwwOnRichEditDlgEvent read FOnCreateDialog write FOnCreateDialog;
property PrintMargins: TwwPrintMargins read FPrintMargins write FPrintMargins;
property PrintHeader: TwwRTFHeaderFooter read FHeader write FHeader;
property PrintFooter: TwwRTFHeaderFooter read FFooter write FFooter;
property OnPrintHeader : TwwRTFDrawHeaderFooter read FOnPrintHeader write FOnPrintHeader;
property OnPrintFooter : TwwRTFDrawHeaderFooter read FOnPrintFooter write FOnPrintFooter;
property EditWidth: TwwRichEditWidth read FEditWidth write FEditWidth default rewWindowSize;
property EditorPosition: TwwFormPosition read FEditorPosition write FEditorPosition;
property PrintPageSize : integer read FPrintPageSize write SetPrintPageSize default 1;
property OleOptions: TwwRichEditOleOptions read FOleOptions write SetOleOptions
default [reoAdjustPopupMenu]; { publish before lines }
property RichEditCopyMethod: TwwRichEditCopyMethod read FRichEditCopyMethod
write FRichEditCopyMethod default recmByMemory;
property AutoURLDetect: boolean read FAutoURLDetect write SetAutoURLDetect;
property AutoSelect: boolean read FAutoSelect write FAutoSelect default False;
property OnURLOpen: TwwURLOpenEvent read FOnURLOpen write FOnURLOpen;
property UserSpeedButton1: TSpeedButton read FUserSpeedButton1 write SetUserSpeedButton1;
property UserSpeedButton2: TSpeedButton read FUserSpeedButton2 write SetUserSpeedButton2;
{Override so inherited wordwrap is not used in WriteState}
property WordWrap : boolean read FWordWrap write SetWordWrap default True;
property PlainText;
property Frame: TwwEditFrame read FFrame write FFrame;
property PrintJobName: string read FPrintJobName write FPrintJobName;
property GutterWidth : integer read FGutterWidth write FGutterWidth default 3;
property SelectionType: TwwRichSelectionType read GetSelectionType;
property WantNavigationKeys: boolean read FWantNavigationKeys write FWantNavigationKeys default false;
property Title: string read FTitle write SetTitle;
property HideSelection: Boolean read FHideSelection write SetHideSelection default True;
// property Transparent: boolean read FTransparent write FTransparent default false;
// property SpellCheckOptions: TwwSpellCheckOptions read FSpellCheckOptions write FSpellCheckOptions default
// [reoSpellCheck, reoGrammarCheck];
property OnMenuLoadClick : TwwRTFNotifyEvent read FOnMenuLoadClick write FOnMenuLoadClick;
property OnMenuPrintClick : TwwRTFNotifyEvent read FOnMenuPrintClick write FOnMenuPrintClick;
property OnMenuSaveAsClick : TwwRTFNotifyEvent read FOnMenuSaveAsClick write FOnMenuSaveAsClick;
property OnMenuSaveAndExitClick : TwwRTFNotifyEvent read FOnMenuSaveAndExitClick write FOnMenuSaveAndExitClick;
published
property ScrollBars: TScrollStyle read GetScrollBars write SetScrollBars stored StoreScrollBars;
// property ScrollBars stored StoreScrollBars; { Publish before Lines as this causes recreatewnd }
// Publish this later to enable richedit 4 option
property MSVersion: integer read FMSVersion write FMSVersion default 3;
// property Lines stored False; { Backwards compatibility } //Required to be published for proper streaming }
property Lines: TStrings read FLines write SetLines stored False;
end;
TwwDBRichEdit=class;
TwwRulerPanel = class(TPanel)
private
Function TwipsToPixels(Twips: integer): integer;
Function PrinterPixelsToTwipsX(pixels: integer): integer;
Function PixelsToTwipsX(pixels: integer): integer;
protected
procedure Paint; override;
public
RulerRect: TRect;
LeftDragButton: TwwTrackIcon;
RightDragButton: TwwTrackIcon;
FirstLineDragButton: TwwTrackIcon;
RichEdit: TwwDBRichEdit; // Used by RichEditBar
procedure UpdateDragIcons;
procedure UpdateSize(DialogRichEdit: TwwCustomRichEdit);
procedure UpdateRulerProp(Sender: TObject);
end;
TwwDBRichEdit = class(TwwCustomRichEdit)
private
FController: TwwController;
FDataLink: TFieldDataLink;
FAutoDisplay: Boolean;
FMemoLoaded: Boolean;
FDataSave: string;
procedure SetController(Value: TwwController);
Function isBlob: boolean;
procedure DataChange(Sender: TObject);
procedure EditingChange(Sender: TObject);
function GetDataField: string;
function GetDataSource: TDataSource;
{$ifndef wwDelphi4Up} { Move to protected in IP 5 }
function GetField: TField; override;
{$endif}
procedure SetDataField(const Value: string);
procedure SetDataSource(Value: TDataSource);
procedure SetReadOnly(Value: Boolean);
procedure SetAutoDisplay(Value: Boolean);
procedure SetFocused(Value: Boolean);
procedure UpdateData(Sender: TObject);
procedure WMCut(var Message: TMessage); message WM_CUT;
procedure WMPaste(var Message: TMessage); message WM_PASTE;
procedure CMEnter(var Message: TCMEnter); message CM_ENTER;
procedure CMExit(var Message: TCMExit); message CM_EXIT;
procedure WMLButtonDblClk(var Message: TWMLButtonDblClk); message WM_LBUTTONDBLCLK;
procedure CMGetDataLink(var Message: TMessage); message CM_GETDATALINK;
procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
protected
procedure BeginEditing; override;
procedure Change; override;
procedure KeyPress(var Key: Char); override;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure Notification(AComponent: TComponent;
Operation: TOperation); override;
function GetReadOnly: Boolean; override;
procedure UpdateField; override;
procedure SetParent(AParent: TWinControl); override;
procedure CreateWnd; override;
Function IsMemoLoaded: boolean; override;
function GetField: TField; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure LoadMemo; override;
procedure LoadBlobStart(Field: TField; NumPackets: integer = 2);
{$ifdef wwdelphi4up}
function UpdateAction(Action: TBasicAction): Boolean; override;
function ExecuteAction(Action: TBasicAction): Boolean; override;
{$endif}
published
property Controller : TwwController read FController write SetController;
{$ifdef wwDelphi4Up}
property Anchors;
property Constraints;
{$endif}
property BevelEdges;
property BevelInner;
property BevelKind default bkNone;
property BevelOuter;
property Align;
property Alignment;
property AutoURLDetect;
property AutoSelect;
property AutoDisplay: Boolean read FAutoDisplay write SetAutoDisplay default True;
property BorderStyle;
property BorderWidth;
property Color;
property Ctl3D;
property DataField: string read GetDataField write SetDataField;
property DataSource: TDataSource read GetDataSource write SetDataSource;
property DragCursor;
property DragMode;
property Enabled;
property Font;
property Frame;
property GutterWidth;
property HideSelection;
property HideScrollBars;
{$ifdef wwDelphi3Up}
property ImeMode;
property ImeName;
{$endif}
property MaxLength;
property ParentColor;
property ParentCtl3D;
property ParentFont;
property ParentShowHint;
property OleOptions;
property PrintPageSize;
// property Transparent;
// property SpellCheckOptions;
// property RichEditCopyMethod;
property UserSpeedButton1;
property UserSpeedButton2;
property HighlightColor;
property Title;
{ property PlainText;}
property PopupMenu;
property PrintJobName;
property ReadOnly: Boolean read GetReadOnly write SetReadOnly default False;
// property ScrollBars;
property ShowHint;
property TabOrder;
property TabStop;
property Visible;
property WantReturns;
property WantTabs;
property WantNavigationKeys; // 7/9/02 - Don't pass grid these navigation keys -
// VK_UP, VK_DOWN, VK_NEXT, VK_PRIOR:
property WordWrap;
property OnChange;
property OnClick;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnResizeRequest;
property OnSelectionChange;
property OnProtectChange;
property OnSaveClipboard;
property OnStartDrag;
property PopupOptions;
property EditorOptions;
property EditorCaption;
property EditorPosition;
property MeasurementUnits;
property PrintMargins;
property EditWidth;
property OnInitDialog;
property OnCloseDialog;
property OnCreateDialog;
property OnURLOpen;
property OnMenuLoadClick;
property OnMenuPrintClick;
property OnMenuSaveAsClick;
property OnMenuSaveAndExitClick;
property PrintHeader;
property PrintFooter;
property OnPrintHeader;
property OnPrintFooter;
end;
TwwCharFormat2 = record
cbSize: UINT;
dwMask: Longint;
dwEffects: Longint;
yHeight: Longint;
yOffset: Longint;
crTextColor: TColorRef;
bCharSet: Byte;
bPitchAndFamily: Byte;
szFaceName: array[0..LF_FACESIZE - 1] of AnsiChar;
wWeight: Word;
sSpacing: SmallInt; // 1/8/03 - formerly shortint
crBackColor: TColorRef;
lcid: longint;
dwReserved: longint;
style: smallint; // 1/8/03 - formerly shortint
wKerning: word;
bUnderlineType: byte;
bAnimation: byte;
bRevAuthor: byte;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -