📄 rvstyle.pas
字号:
{$ENDIF}
);
TRVMarkerFormatString = type String;
{$IFNDEF RVDONOTUSEUNICODE}
{$IFDEF RICHVIEWCBDEF3}
TRVMarkerFormatStringW = type WideString;
{$ENDIF}
{$ENDIF}
TRVMarkerAlignment = (rvmaLeft, rvmaRight, rvmaCenter);
TRVListLevelOption = (rvloContinuous, rvloLevelReset, rvloLegalStyleNumbering);
TRVListLevelOptions = set of TRVListLevelOption;
TRVMarkerFont = class (TFont)
private
function StoreName: Boolean;
function StoreHeight: Boolean;
public
constructor Create;
function IsEqual(Font: TFont): Boolean;
function IsDefault: Boolean;
published
{$IFDEF RICHVIEWCBDEF3}
property Charset default DEFAULT_CHARSET;
{$ENDIF}
property Color default clWindowText;
property Name stored StoreName;
property Style default [];
property Height stored StoreHeight;
end;
TRVListLevel = class (TCollectionItem)
private
FListType: TRVListType;
FPicture: TPicture;
FImageList: TCustomImageList;
FImageIndex: Integer;
FFormatString: TRVMarkerFormatString;
{$IFNDEF RVDONOTUSEUNICODE}
{$IFDEF RICHVIEWCBDEF3}
FFormatStringW: TRVMarkerFormatStringW;
{$ENDIF}
{$ENDIF}
FLeftIndent, FFirstIndent, FMarkerIndent: Integer;
FMarkerAlignment: TRVMarkerAlignment;
FFont: TRVMarkerFont;
FOptions: TRVListLevelOptions;
FStartFrom: Integer;
function GetPicture: TPicture;
procedure SetPicture(const Value: TPicture);
function GetFont: TRVMarkerFont;
procedure SetFont(const Value: TRVMarkerFont);
function StoreFont: Boolean;
function StorePicture: Boolean;
procedure ImageListTagWriter(Writer: TWriter);
procedure ImageListTagReader(Reader: TReader);
{$IFNDEF RVDONOTUSEUNICODE}
{$IFDEF RICHVIEWCBDEF3}
procedure FormatStringWCodeWriter(Writer: TWriter);
procedure FormatStringWCodeReader(Reader: TReader);
{$ENDIF}
{$ENDIF}
procedure FormatStringCodeWriter(Writer: TWriter);
procedure FormatStringCodeReader(Reader: TReader);
function StoreImageList: Boolean;
function GetRVFRVData: TPersistent;
protected
{$IFDEF RICHVIEWCBDEF3}
function GetDisplayName: String; override;
{$ENDIF}
function IsSimpleEqual(Value: TRVListLevel): Boolean;
procedure DefineProperties(Filer: TFiler); override;
function SimilarityValue(Value: TRVListLevel): Integer;
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
function GetHTMLOpenTagForCSS: String;
function GetIndentCSSForTextVersion: String;
procedure HTMLOpenTag(Stream: TStream; UseCSS: Boolean);
procedure HTMLCloseTag(Stream: TStream; UseCSS: Boolean);
function HasPicture: Boolean;
function UsesFont: Boolean;
function HasNumbering: Boolean;
function HasVariableWidth: Boolean;
procedure SaveToINI(ini: TRVIniFile; const Section, fs: String);
procedure LoadFromINI(ini: TRVIniFile; const Section, fs: String);
published
property ListType: TRVListType read FListType write FListType default rvlstBullet;
property StartFrom: Integer read FStartFrom write FStartFrom default 1;
property ImageList: TCustomImageList read FImageList write FImageList stored StoreImageList;
property ImageIndex: Integer read FImageIndex write FImageIndex default 0;
property FormatString: TRVMarkerFormatString read FFormatString write FFormatString stored False;
{$IFNDEF RVDONOTUSEUNICODE}
{$IFDEF RICHVIEWCBDEF3}
property FormatStringW: TRVMarkerFormatStringW read FFormatStringW write FFormatStringW stored False;
{$ENDIF}
{$ENDIF}
property LeftIndent: Integer read FLeftIndent write FLeftIndent default 0;
property FirstIndent: Integer read FFirstIndent write FFirstIndent default 10;
property MarkerIndent: Integer read FMarkerIndent write FMarkerIndent default 0;
property MarkerAlignment: TRVMarkerAlignment read FMarkerAlignment write FMarkerAlignment default rvmaLeft;
property Picture: TPicture read GetPicture write SetPicture stored StorePicture;
property Font: TRVMarkerFont read GetFont write SetFont stored StoreFont;
property Options: TRVListLevelOptions read FOptions write FOptions default [rvloContinuous, rvloLevelReset];
end;
TRVListLevelCollection = class (TCollection)
private
FOwner: TPersistent;
function GetItem(Index: Integer): TRVListLevel;
procedure SetItem(Index: Integer; const Value: TRVListLevel);
public
constructor Create(Owner: TPersistent);
{$IFDEF RICHVIEWCBDEF3}
function GetOwner: TPersistent; override;
{$ENDIF}
function Add: TRVListLevel;
{$IFDEF RICHVIEWDEF4}
function Insert(Index: Integer): TRVListLevel;
{$ENDIF}
function IsSimpleEqual(Value: TRVListLevelCollection): Boolean;
property Items[Index: Integer]: TRVListLevel
read GetItem write SetItem; default;
end;
TRVListInfo = class (TCustomRVInfo)
private
FLevels: TRVListLevelCollection;
FOneLevelPreview: Boolean;
procedure SetLevels(const Value: TRVListLevelCollection);
protected
function SimilarityValue(Value: TCustomRVInfo): Integer; override;
public
function IsSimpleEqual(Value: TCustomRVInfo; IgnoreReferences: Boolean): Boolean; override;
function IsSimpleEqualEx(Value: TCustomRVInfo; Mapping: TRVIntegerList): Boolean; override;
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
procedure SaveToINI(ini: TRVIniFile; const Section, fs: String);
procedure LoadFromINI(ini: TRVIniFile; const Section, fs: String);
function HasNumbering: Boolean;
function AllNumbered: Boolean;
function HasVariableWidth: Boolean;
published
property Levels: TRVListLevelCollection read FLevels write SetLevels;
property OneLevelPreview: Boolean read FOneLevelPreview write FOneLevelPreview default False;
end;
TRVListInfos = class (TCustomRVInfos)
private
function GetItem(Index: Integer): TRVListInfo;
procedure SetItem(Index: Integer; const Value: TRVListInfo);
procedure RemoveImageList(ImageList: TCustomImageList);
public
FRVData: TPersistent;
function Add: TRVListInfo;
{$IFDEF RICHVIEWDEF4}
function Insert(Index: Integer): TRVListInfo;
{$ENDIF}
procedure LoadFromINI(ini: TRVIniFile; const Section: String);
procedure SaveToINI(ini: TRVIniFile; const Section: String);
function FindSuchStyle(Style: TRVListInfo; AddIfNotFound: Boolean): Integer;
function FindStyleWithLevels(Levels: TRVListLevelCollection;
const StyleNameForAdding: String; AddIfNotFound: Boolean): Integer;
property Items[Index: Integer]: TRVListInfo
read GetItem write SetItem; default;
end;
{-----------------------------------------------------------------------}
TRVFontInfoClass = class of TFontInfo;
TRVParaInfoClass = class of TParaInfo;
TRVListInfoClass = class of TRVListInfo;
TRVStyle = class(TComponent)
private
{ Private declarations }
// FModified: Boolean;
FInvalidPicture: TPicture;
FColor, FHoverColor, FSelColor, FSelTextColor,
FInactiveSelColor, FInactiveSelTextColor,
FCheckpointColor, FCheckpointEvColor: TColor;
FCursor: TCursor;
FTextStyles: TFontInfos;
FParaStyles: TParaInfos;
FListStyles: TRVListInfos;
FFullRedraw: Boolean;
FSpacesInTab: SmallInt;
FPageBreakColor, FSoftPageBreakColor: TColor;
FOnApplyStyleColor: TRVApplyStyleColorEvent;
FOnApplyStyle: TRVApplyStyleEvent;
FOnDrawStyleText: TRVDrawStyleTextEvent;
FOnStyleHoverSensitive: TRVStyleHoverSensitiveEvent;
FOnDrawTextBack: TRVDrawTextBackEvent;
FOnDrawCheckpoint: TRVDrawCheckpointEvent;
FOnDrawPageBreak: TRVDrawPageBreakEvent;
FOnDrawParaBack: TRVDrawParaRectEvent;
{$IFNDEF RVDONOTUSEUNICODE}
FDefUnicodeStyle: Integer;
{$ENDIF}
FDefCodePage:TRVCodePage;
FUseSound: Boolean;
procedure SetTextStyles(Value: TFontInfos);
procedure SetParaStyles(Value: TParaInfos);
procedure SetListStyles(Value: TRVListInfos);
function GetHoverColorByColor(Color: TColor): TColor;
function GetInvalidPicture: TPicture;
procedure SetInvalidPicture(const Value: TPicture);
protected
{ Protected declarations }
procedure ReadState(Reader: TReader);override;
procedure Notification(AComponent: TComponent; Operation: TOperation);override;
public
ItemNo, OffsetInItem: Integer;
RVData: TPersistent;
procedure ResetTextStyles;
procedure ResetParaStyles;
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function GetTextStyleClass: TRVFontInfoClass; virtual;
function GetParaStyleClass: TRVParaInfoClass; virtual;
function GetListStyleClass: TRVListInfoClass; virtual;
function AddTextStyle: Integer; {$IFDEF RICHVIEWDEF6}deprecated;{$ENDIF}
procedure DeleteTextStyle(Index: Integer); {$IFDEF RICHVIEWDEF6}deprecated;{$ENDIF}
procedure SaveINI(const FileName, Section: String); {WARNING: before saving all Section will be removed}
procedure LoadINI(const FileName, Section: String);
procedure SaveToINI(ini: TRVIniFile; Section: String);
procedure LoadFromINI(ini: TRVIniFile; Section: String);
{$IFDEF RICHVIEWDEF4}
procedure SaveReg(const BaseKey: String); {WARNING: will be created 'RVStyle' subkey. If it
already exists, all data and subkeys in this 'RVStyle'
key will be erased}
procedure LoadReg(const BaseKey: String);
{$ENDIF}
{$IFNDEF RVDONOTUSEHTML}
procedure SaveCSSToStream(Stream: TStream; AOptions: TRVSaveCSSOptions);
function SaveCSS(const FileName: String; AOptions: TRVSaveCSSOptions): Boolean;
{$ENDIF}
function GetHoverColor(StyleNo: Integer): TColor;
procedure DrawTextBack(Canvas: TCanvas; ItemNo, StyleNo: Integer;
RVData: TPersistent;
Left, Top, Width, Height: Integer;
DrawState: TRVTextDrawStates);
procedure ApplyStyle(Canvas: TCanvas; StyleNo: Integer; DefBiDiMode: TRVBiDiMode);
procedure ApplyStyleColor(Canvas: TCanvas; StyleNo: Integer;
DrawState: TRVTextDrawStates);
procedure DrawStyleText(const s: String;
Canvas: TCanvas;
ItemNo, OffsetInItem, StyleNo: Integer;
RVData: TPersistent;
SpaceBefore, Left, Top, Width, Height: Integer;
DrawState: TRVTextDrawStates;
Printing: Boolean);
procedure DrawCheckpoint(Canvas: TCanvas;
X,Y, ItemNo, XShift: Integer;
RaiseEvent: Boolean;
Control: TControl);
procedure DrawPageBreak(Canvas: TCanvas;
Y, XShift: Integer;
PageBreakType: TRVPageBreakType;
Control: TControl);
procedure DrawParaBack(Canvas: TCanvas;
ParaNo: Integer;
const Rect: TRect);
function StyleHoverSensitive(StyleNo: Integer): Boolean;
// property Modified: Boolean read FModified write FModified;
published
{ Published declarations }
property TextStyles: TFontInfos read FTextStyles write SetTextStyles;
property ParaStyles: TParaInfos read FParaStyles write SetParaStyles;
property ListStyles: TRVListInfos read FListStyles write SetListStyles;
property SpacesInTab: SmallInt read FSpacesInTab write FSpacesInTab default 8;
property JumpCursor: TCursor read FCursor write FCursor default crJump;
property FullRedraw: Boolean read FFullRedraw write FFullRedraw default False;
property UseSound: Boolean read FUseSound write FUseSound default True;
property Color: TColor read FColor write FColor default clWindow;
property HoverColor: TColor read FHoverColor write FHoverColor default clNone;
property SelColor: TColor read FSelColor write FSelColor default clHighlight;
property SelTextColor: TColor read FSelTextColor write FSelTextColor default clHighlightText;
property InactiveSelColor: TColor read FInactiveSelColor write FInactiveSelColor default clHighlight;
property InactiveSelTextColor: TColor read FInactiveSelTextColor write FInactiveSelTextColor default clHighlightText;
property CheckpointColor: TColor read FCheckpointColor write FCheckpointColor default clGreen;
property CheckpointEvColor: TColor read FCheckpointEvColor write FCheckpointEvColor default clLime;
property PageBreakColor: TColor read FPageBreakColor write FPageBreakColor default clBtnShadow;
property SoftPageBreakColor: TColor read FSoftPageBreakColor write FSoftPageBreakColor default clBtnFace;
{$IFNDEF RVDONOTUSEUNICODE}
property DefUnicodeStyle: Integer read FDefUnicodeStyle write FDefUnicodeStyle default -1;
{$ENDIF}
property DefCodePage: TRVCodePage read FDefCodePage write FDefCodePage default CP_ACP;
property InvalidPicture: TPicture read GetInvalidPicture write SetInvalidPicture;
property OnApplyStyle: TRVApplyStyleEvent read FOnApplyStyle write FOnApplyStyle;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -