📄 urxriched.pas
字号:
{*******************************************************}
{ }
{ Delphi VCL Extensions (RX) }
{ }
{ Copyright (c) 2001,2002 SGB Software }
{ Copyright (c) 1997, 1998 Fedor Koshevnikov, }
{ Igor Pavluk and Serge Korolev }
{ }
{*******************************************************}
unit URxRichEd;
{*******************************************************}
{ }
{ RX Library include file }
{ Copyright (c) 1996 AO ROSNO }
{ Copyright (c) 1997, 1998 Master-Bank }
{ }
{*******************************************************}
{ RX.INC is included in all RX Library units so you can specify
global compiler options here. RX.INC is included before each units'
required compiler options and the options specified here can be
overridden by hardcode options in the source files }
{ Conditional defines that affect compilation }
{$DEFINE DCS}
{ Client/Server or Enterprise version. Deactivate this define if you
have Delphi Desktop, Standard or Professional Edition }
{.$DEFINE RX_MIDAS}
{ RX MIDAS components }
{.$DEFINE RX_ADO}
{ RX ADO components }
{$DEFINE USE_RX_GIF}
{ This define enables GIF image support. Deactivate this define
if you are using another GIF image support library. See README.TXT
for the legal aspects }
{$IFDEF WIN32}
{.$DEFINE USE_PROGRESSBAR}
{ Activate this define if you do not want to use TGauge Borland sample
component in TDBProgress component and FileUtil routines. In this case
TProgressBar component will be used }
{$ENDIF}
{$DEFINE USE_FOUR_DIGIT_YEAR}
{ This define controls whether FourDigitYear variable is used to control
date format in TDateEdit, TDBDateEdit components. When this define is not
active the ShortDateFormat variable is used instead }
{.$DEFINE USE_OLD_DBLISTS}
{ Activate this define to install old BDE lists components for backward
compatibility with oldest RX versions }
{$DEFINE DEFAULT_POPUP_CALENDAR}
{ This define controls whether a popup calendar is used as default
instead of a modal dialog in TDateEdit, TDBDateEdit components }
{ ------------ !! DO NOT CHANGE DEFINES BELOW THIS LINE !! ------------ }
{$B-} {- Complete Boolean Evaluation }
{$R-} {- Range-Checking }
{$V-} {- Var-String Checking }
{$T-} {- Typed @ operator }
{$X+} {- Extended syntax }
{$P+} {- Open string params }
{$IFDEF WIN32}
{$J+} {- Writeable structured consts }
{$H+} {- Use long strings by default }
{$ENDIF}
{$IFDEF VER93} { Borland C++Builder 1.0 }
{$DEFINE CBUILDER}
{$ENDIF}
{$IFDEF VER100} { Borland Delphi 3.0 }
{$DEFINE RX_D3}
{$ENDIF}
{$IFDEF VER110} { Borland C++Builder 3.0 }
{$DEFINE CBUILDER}
{$ObjExportAll On}
{$UNDEF DCS}
{$ENDIF}
{$IFDEF VER120} { Borland Delphi 4.0 }
{$DEFINE RX_D3}
{$DEFINE RX_D4}
{$ENDIF}
{$IFDEF VER125} { Borland C++Builder 4.0 }
{$DEFINE CBUILDER}
{$ObjExportAll On}
{$UNDEF DCS}
{$ENDIF}
{$IFDEF VER130} { Borland Delphi 5.0 }
{$DEFINE RX_D3}
{$DEFINE RX_D4}
{$DEFINE RX_D5}
{$ENDIF}
{$IFDEF VER140} { Borland Delphi 6.0 }
{$DEFINE RX_D3}
{$DEFINE RX_D4}
{$DEFINE RX_D5}
{$DEFINE RX_D6}
{$WARN SYMBOL_PLATFORM OFF}
{$WARN UNIT_PLATFORM OFF}
{$ENDIF}
{$IFDEF VER150} { Borland Delphi 7.0 }
{$DEFINE RX_D3}
{$DEFINE RX_D4}
{$DEFINE RX_D5}
{$DEFINE RX_D6}
{$DEFINE RX_D7}
{$WARN SYMBOL_PLATFORM OFF}
{$WARN UNIT_PLATFORM OFF}
{$ENDIF}
{$IFNDEF VER80} { Delphi 1.0 }
{$IFNDEF VER90} { Delphi 2.0 }
{$IFNDEF VER93} { C++Builder 1.0 }
{$DEFINE RX_D3} { Delphi 3.0 or higher }
{$IFNDEF VER100}
{$DEFINE RX_V110} { C++Builder 3.0 or higher }
{$IFNDEF VER110}
{$DEFINE RX_D4} { Delphi 4.0 or higher }
{$IFNDEF VER120}
{$DEFINE RX_V125} { C++Builder 4.0 or higher }
{$IFNDEF VER125}
{$DEFINE RX_D5} { Delphi 5.0 or higher }
{$ENDIF}
{$ENDIF}
{$ENDIF}
{$ENDIF}
{$ENDIF}
{$ENDIF}
{$ENDIF}
{$IFDEF CBUILDER}
{$DEFINE USE_PROGRESSBAR}
{$UNDEF USE_OLD_DBLISTS}
{$IFNDEF VER93}
{$DEFINE RX_V110} { C++Builder 3.0 or higher }
{$IFNDEF VER110}
{$DEFINE RX_V125} { C++Builder 4.0 or higher }
{$ENDIF}
{$ENDIF}
{$ENDIF}
{$IFNDEF RX_D3}
{$DEFINE DCS}
{$UNDEF RX_MIDAS}
{$ENDIF}
{$IFNDEF RX_D5}
{$UNDEF RX_ADO}
{$ENDIF}
{$IFNDEF DCS}
{$UNDEF RX_MIDAS}
{$UNDEF RX_ADO}
{$ENDIF}
{.$DEFINE RICHEDIT_VER_10}
{$R-}
interface
uses Windows, {$IFDEF RX_D3} ActiveX, ComObj {$ELSE} Ole2, OleAuto {$ENDIF},
CommCtrl, Messages, SysUtils, Classes, Controls, Forms, Graphics, StdCtrls,
Dialogs, RichEdit, Menus, ComCtrls;
type
TRichEditVersion = 1..3;
{$IFNDEF RX_D3}
TCharFormat2A = record
cbSize: UINT;
dwMask: DWORD;
dwEffects: DWORD;
yHeight: Longint;
yOffset: Longint;
crTextColor: TColorRef;
bCharSet: Byte;
bPitchAndFamily: Byte;
szFaceName: array[0..LF_FACESIZE - 1] of AnsiChar;
{ new fields in version 2.0 }
wWeight: Word; { Font weight (LOGFONT value) }
sSpacing: Smallint; { Amount to space between letters }
crBackColor: TColorRef; { Background color }
lid: LCID; { Locale ID }
dwReserved: DWORD; { Reserved. Must be 0 }
sStyle: Smallint; { Style handle }
wKerning: Word; { Twip size above which to kern char pair }
bUnderlineType: Byte; { Underline type }
bAnimation: Byte; { Animated text like marching ants }
bRevAuthor: Byte; { Revision author index }
bReserved1: Byte;
end;
TCharFormat2 = TCharFormat2A;
TParaFormat2 = record
cbSize: UINT;
dwMask: DWORD;
wNumbering: Word;
wReserved: Word;
dxStartIndent: Longint;
dxRightIndent: Longint;
dxOffset: Longint;
wAlignment: Word;
cTabCount: Smallint;
rgxTabs: array [0..MAX_TAB_STOPS - 1] of Longint;
{ new fields in version 2.0 }
dySpaceBefore: Longint; { Vertical spacing before paragraph }
dySpaceAfter: Longint; { Vertical spacing after paragraph }
dyLineSpacing: Longint; { Line spacing depending on Rule }
sStyle: Smallint; { Style handle }
bLineSpacingRule: Byte; { Rule for line spacing (see tom.doc) }
bCRC: Byte; { Reserved for CRC for rapid searching }
wShadingWeight: Word; { Shading in hundredths of a per cent }
wShadingStyle: Word; { Nibble 0: style, 1: cfpat, 2: cbpat }
wNumberingStart: Word; { Starting value for numbering }
wNumberingStyle: Word; { Alignment, roman/arabic, (), ), ., etc.}
wNumberingTab: Word; { Space bet 1st indent and 1st-line text }
wBorderSpace: Word; { Space between border and text (twips) }
wBorderWidth: Word; { Border pen width (twips) }
wBorders: Word; { Byte 0: bits specify which borders }
{ Nibble 2: border style, 3: color index }
end;
{$ENDIF RX_D3}
{$IFDEF RX_D5}
TCharFormat2 = TCharFormat2A;
{$ENDIF}
type
TRxCustomRichEdit = class;
{ TRxTextAttributes }
TRxAttributeType = (atDefaultText, atSelected, atWord);
TRxConsistentAttribute = (caBold, caColor, caFace, caItalic, caSize,
caStrikeOut, caUnderline, caProtected, caOffset, caHidden, caLink,
caBackColor, caDisabled, caWeight, caSubscript, caRevAuthor);
TRxConsistentAttributes = set of TRxConsistentAttribute;
TSubscriptStyle = (ssNone, ssSubscript, ssSuperscript);
TUnderlineType = (utNone, utSolid, utWord, utDouble, utDotted, utWave);
TRxTextAttributes = class(TPersistent)
private
RichEdit: TRxCustomRichEdit;
FType: TRxAttributeType;
procedure AssignFont(Font: TFont);
procedure GetAttributes(var Format: TCharFormat2);
{$IFNDEF VER90}
function GetCharset: TFontCharset;
procedure SetCharset(Value: TFontCharset);
{$ENDIF}
function GetSubscriptStyle: TSubscriptStyle;
procedure SetSubscriptStyle(Value: TSubscriptStyle);
function GetBackColor: TColor;
function GetColor: TColor;
function GetConsistentAttributes: TRxConsistentAttributes;
function GetHeight: Integer;
function GetHidden: Boolean;
function GetDisabled: Boolean;
function GetLink: Boolean;
function GetName: TFontName;
function GetOffset: Integer;
function GetPitch: TFontPitch;
function GetProtected: Boolean;
function GetRevAuthorIndex: Byte;
function GetSize: Integer;
function GetStyle: TFontStyles;
function GetUnderlineType: TUnderlineType;
procedure SetAttributes(var Format: TCharFormat2);
procedure SetBackColor(Value: TColor);
procedure SetColor(Value: TColor);
procedure SetDisabled(Value: Boolean);
procedure SetHeight(Value: Integer);
procedure SetHidden(Value: Boolean);
procedure SetLink(Value: Boolean);
procedure SetName(Value: TFontName);
procedure SetOffset(Value: Integer);
procedure SetPitch(Value: TFontPitch);
procedure SetProtected(Value: Boolean);
procedure SetRevAuthorIndex(Value: Byte);
procedure SetSize(Value: Integer);
procedure SetStyle(Value: TFontStyles);
procedure SetUnderlineType(Value: TUnderlineType);
protected
procedure InitFormat(var Format: TCharFormat2);
procedure AssignTo(Dest: TPersistent); override;
public
constructor Create(AOwner: TRxCustomRichEdit; AttributeType: TRxAttributeType);
procedure Assign(Source: TPersistent); override;
{$IFNDEF VER90}
property Charset: TFontCharset read GetCharset write SetCharset;
{$ENDIF}
property BackColor: TColor read GetBackColor write SetBackColor;
property Color: TColor read GetColor write SetColor;
property ConsistentAttributes: TRxConsistentAttributes read GetConsistentAttributes;
property Disabled: Boolean read GetDisabled write SetDisabled;
property Hidden: Boolean read GetHidden write SetHidden;
property Link: Boolean read GetLink write SetLink;
property Name: TFontName read GetName write SetName;
property Offset: Integer read GetOffset write SetOffset;
property Pitch: TFontPitch read GetPitch write SetPitch;
property Protected: Boolean read GetProtected write SetProtected;
property RevAuthorIndex: Byte read GetRevAuthorIndex write SetRevAuthorIndex;
property SubscriptStyle: TSubscriptStyle read GetSubscriptStyle write SetSubscriptStyle;
property Size: Integer read GetSize write SetSize;
property Style: TFontStyles read GetStyle write SetStyle;
property Height: Integer read GetHeight write SetHeight;
property UnderlineType: TUnderlineType read GetUnderlineType write SetUnderlineType;
end;
{ TRxParaAttributes }
TRxNumbering = (nsNone, nsBullet, nsArabicNumbers, nsLoCaseLetter,
nsUpCaseLetter, nsLoCaseRoman, nsUpCaseRoman);
TRxNumberingStyle = (nsParenthesis, nsPeriod, nsEnclosed, nsSimple);
TParaAlignment = (paLeftJustify, paRightJustify, paCenter, paJustify);
TLineSpacingRule = (lsSingle, lsOneAndHalf, lsDouble, lsSpecifiedOrMore,
lsSpecified, lsMultiple);
THeadingStyle = 0..9;
TParaTableStyle = (tsNone, tsTableRow, tsTableCellEnd, tsTableCell);
TRxParaAttributes = class(TPersistent)
private
RichEdit: TRxCustomRichEdit;
procedure GetAttributes(var Paragraph: TParaFormat2);
function GetAlignment: TParaAlignment;
function GetFirstIndent: Longint;
function GetHeadingStyle: THeadingStyle;
function GetLeftIndent: Longint;
function GetRightIndent: Longint;
function GetSpaceAfter: Longint;
function GetSpaceBefore: Longint;
function GetLineSpacing: Longint;
function GetLineSpacingRule: TLineSpacingRule;
function GetNumbering: TRxNumbering;
function GetNumberingStyle: TRxNumberingStyle;
function GetNumberingTab: Word;
function GetTab(Index: Byte): Longint;
function GetTabCount: Integer;
function GetTableStyle: TParaTableStyle;
procedure SetAlignment(Value: TParaAlignment);
procedure SetAttributes(var Paragraph: TParaFormat2);
procedure SetFirstIndent(Value: Longint);
procedure SetHeadingStyle(Value: THeadingStyle);
procedure SetLeftIndent(Value: Longint);
procedure SetRightIndent(Value: Longint);
procedure SetSpaceAfter(Value: Longint);
procedure SetSpaceBefore(Value: Longint);
procedure SetLineSpacing(Value: Longint);
procedure SetLineSpacingRule(Value: TLineSpacingRule);
procedure SetNumbering(Value: TRxNumbering);
procedure SetNumberingStyle(Value: TRxNumberingStyle);
procedure SetNumberingTab(Value: Word);
procedure SetTab(Index: Byte; Value: Longint);
procedure SetTabCount(Value: Integer);
procedure SetTableStyle(Value: TParaTableStyle);
protected
procedure InitPara(var Paragraph: TParaFormat2);
procedure AssignTo(Dest: TPersistent); override;
public
constructor Create(AOwner: TRxCustomRichEdit);
procedure Assign(Source: TPersistent); override;
property Alignment: TParaAlignment read GetAlignment write SetAlignment;
property FirstIndent: Longint read GetFirstIndent write SetFirstIndent;
property HeadingStyle: THeadingStyle read GetHeadingStyle write SetHeadingStyle;
property LeftIndent: Longint read GetLeftIndent write SetLeftIndent;
property LineSpacing: Longint read GetLineSpacing write SetLineSpacing;
property LineSpacingRule: TLineSpacingRule read GetLineSpacingRule write SetLineSpacingRule;
property Numbering: TRxNumbering read GetNumbering write SetNumbering;
property NumberingStyle: TRxNumberingStyle read GetNumberingStyle write SetNumberingStyle;
property NumberingTab: Word read GetNumberingTab write SetNumberingTab;
property RightIndent: Longint read GetRightIndent write SetRightIndent;
property SpaceAfter: Longint read GetSpaceAfter write SetSpaceAfter;
property SpaceBefore: Longint read GetSpaceBefore write SetSpaceBefore;
property Tab[Index: Byte]: Longint read GetTab write SetTab;
property TabCount: Integer read GetTabCount write SetTabCount;
property TableStyle: TParaTableStyle read GetTableStyle write SetTableStyle;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -