RVStyle.pas
上传用户:daoqigc
上传日期:2021-04-20
资源大小:2795k
文件大小:330k
- {*******************************************************}
- { }
- { RichView }
- { TRVStyle: settings and formatting for }
- { RichView. }
- { (registered on "RichView" page of }
- { the Component Palette) }
- { Declarations of types used elsewhere. }
- { }
- { Copyright (c) Sergey Tkachenko }
- { svt@trichview.com }
- { http://www.trichview.com }
- { }
- {*******************************************************}
- unit RVStyle;
- interface
- {$R RVStyle}
- {$I RV_Defs.inc}
- {$IFDEF RICHVIEWDEF6}
- {$WARN SYMBOL_DEPRECATED OFF}
- {$ENDIF}
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
- {$IFNDEF RVDONOTUSEINI}
- IniFiles, Registry,
- {$ENDIF}
- {$IFDEF RICHVIEWDEF4}
- ImgList,
- {$ENDIF}
- RVClasses, RVMapWht, RVScroll;
- {---------------------------------------------------------------------------- }
-
- const
- { Cursors }
- crJump = 101; // hand point, used as a default value for TRVStyle.JumpCursor
- // property
- crRVFlipArrow = 106; // arrow to top right, used as a default value for
- // TRVStyle.LineSelectCursor property
- { Indices for TRVStyle.TextStyles in its default state }
- rvsNormal = 0;
- rvsHeading = 1;
- rvsSubheading = 2;
- rvsKeyword = 3;
- rvsJump1 = 4;
- rvsJump2 = 5;
- { Standard item types (styles) }
- rvsBreak = -1; // "break" - horizontal line
- rvsCheckpoint = -2; // "checkpoint" (not an item, for internal use)
- rvsPicture = -3; // picture (in class inherited from TGraphic)
- rvsHotspot = -4; // "hotspot": hypertext image from image-list
- rvsComponent = -5; // component (inherited from TControl)
- rvsBullet = -6; // "bullet": image from image-list
- rvsBack = -7; // background (not an item)
- rvsVersionInfo= -8; // version info (not an item, for internal use)
- rvsDocProperty= -9; // document property (not an item, for internal use)
- rvsHotPicture = -10; // "hot picture": hypertext picture
- rvsListMarker = -11; // list marker (paragraph bullet/numbering)
- rvsTab = -12; // tab character
- LAST_DEFAULT_STYLE_NO = rvsJump2;
- { constant used for representing default text style for paragraph }
- rvsDefStyle = MaxInt;
- {---------------------------------------------------------------------------- }
- type
- { Structure containing information for resolutions of screen and some
- device, for internal use }
- TRVScreenAndDevice = record
- ppixScreen, ppiyScreen, ppixDevice, ppiyDevice: Integer;
- LeftMargin, RightMargin: Integer;
- end;
- PRVScreenAndDevice= ^TRVScreenAndDevice;
- TParaInfo = class;
- { Saving format }
- TRVSaveFormat = (rvsfText, rvsfHTML, rvsfRTF, rvsfRVF);
- { Loading format }
- TRVLoadFormat = (rvlfText, rvlfHTML { not implemented }, rvlfRTF, rvlfRVF,
- rvlfURL, rvlfOther);
- { Part of RTF file, used in TCustomRichView.OnSaveRTFExtra }
- TRVRTFSaveArea = (
- rv_rtfs_TextStyle, // in character attributes
- rv_rtfs_ParaStyle, // in paragraph attributes
- rv_rtfs_CellProps, // in table cell
- rv_rtfs_RowProps, // in table row
- rv_rtfs_Doc); // at the beginning of document
- { Part of HTML file, used in TCustomRichView.OnSaveHTMLExtra }
- TRVHTMLSaveArea = (
- rv_thms_Head, // <HEAD>*</HEAD>
- rv_thms_BodyAttribute, // <BODY *>
- rv_thms_Body, // <BODY>*
- rv_thms_End // *</BODY>
- );
- { Values for TCustomRichView.RTFReadProperties.UnicodeMode }
- TRVReaderUnicode = (
- rvruMixed, // Use ANSI text as possible, Unicode if necessary
- rvruNoUnicode, // Use only ANSI text, ignore Unicode in RTF
- rvruOnlyUnicode); // Use Unicode text, convert all text from RTF to Unicode
- { Values for TCustomRichView.RTFReadProperties.TextStyleMode and
- .ParaStyleMode }
- TRVReaderStyleMode = (
- rvrsUseSpecified, // Use the specified style
- // (TCustomRichView.RTFReadProperties.TextStyleNo or
- // .ParaStyleNo)
- rvrsUseClosest, // Use the most similar of existing styles, do not
- // modify collection of styles
- rvrsAddIfNeeded); // Add new styles if necessary (result is the most
- // similar to the original RTF
- { Values for TCustomRichView.RVFTextStylesReadMode and
- .RVFParaStylesReadMode }
- TRVFReaderStyleMode = (
- rvf_sIgnore, // Ignore styles in RVF.
- rvf_sInsertMap, // RVF loading: styles from RVF replace previous styles.
- // RVF inserting: use the most similar of existing
- // styles, do not modify collection of styles.
- rvf_sInsertMerge); // RVF loading: styles from RVF replace previous styles.
- // RVF inserting: add new styles if necessary
- { Values for TCustomRVPrint.ColorMode }
- TRVColorMode = (
- rvcmColor, // Colors are not changed
- rvcmPrinterColor, // Colors are not changed, except for some system colors
- // converted to black and white
- rvcmGrayScale, // Colors are converted to shades of gray
- rvcmBlackAndWhite, // Colors are converted to black and white
- rvcmBlackOnWhite); // Black text on white background
- { Code page, for example TRVStyle.DefCodePage }
- TRVCodePage = type cardinal;
- { Background style of item (for example, of table or table cell }
- TRVItemBackgroundStyle = (
- rvbsColor, // no image
- rvbsStretched, // stretched image
- rvbsTiled, // tiled image
- rvbsCentered); // image in center
- { Reference to information about "checkpoint" }
- TCheckpointData = type Pointer;
- TRVStyle = class;
- { Text properties, used in TRVStyle.OnDrawStyleText }
- TRVTextDrawState = (
- rvtsSelected, // selected
- rvtsHover, // under mouse
- rvtsItemStart, // starting item
- rvtsItemEnd, // ending item
- rvtsDrawItemStart, // starting drawing item
- rvtsDrawItemEnd, // ending drawing item
- rvtsControlFocused, // set if TRichView has input focus
- rvtsSpecialCharacters); // display dots in spaces
- TRVTextDrawStates = set of TRVTextDrawState;
- { Type of page break }
- TRVPageBreakType = (
- rvpbSoftPageBreak, // "soft" page break (created automatically)
- rvpbPageBreak); // page break set by user
- { Visual style of "break" (horizontal line), not used }
- TRVBreakStyle =
- (rvbsLine, // line of the given width
- rvbsRectangle, // rectangle of the given height (border width=1)
- rvbs3d); // sunken rectangle of the given height (border width=1)
- { Vertical alignment of item }
- TRVVAlign = (
- rvvaBaseline, // bottom of picture -> baseline
- rvvaMiddle // center of picture -> baseline
- // may be in future:
- //rvvaAbsTop, // top of picture -> top of line
- //rvvaAbsBottom, // bottom of picture -> bottom of line
- //rvvaAbsMiddle // center of picture -> center of line
- );
- { Types of paragraph border, TParaInfo.Border.Style }
- TRVBorderStyle = (rvbNone, rvbSingle, rvbDouble, rvbTriple,
- rvbThickInside, rvbThickOutside);
- { Paragraph list type, TRVListLevel.ListType property }
- TRVListType = (rvlstBullet, rvlstPicture, rvlstImageList,
- rvlstDecimal, rvlstLowerAlpha, rvlstUpperAlpha, rvlstLowerRoman,
- rvlstUpperRoman, rvlstImageListCounter
- {$IFNDEF RVDONOTUSEUNICODE}
- ,rvlstUnicodeBullet
- {$ENDIF});
- { Alignment of paragraph marker, TRVListLevel.MarkerAlignment property }
- TRVMarkerAlignment = (rvmaLeft, rvmaRight, rvmaCenter);
- { Options for paragraph bullets/numbering, TRVListLevel.Options }
- TRVListLevelOption = (
- rvloContinuous, // (reserved for future use, must always be set)
- rvloLevelReset, // Reset numbering on each level - normal behavior
- rvloLegalStyleNumbering); // Use decimal representation of numbering of
- // other levels
- TRVListLevelOptions = set of TRVListLevelOption;
- TRVMarkerFormatString = type String;
- {$IFNDEF RVDONOTUSEUNICODE}
- {$IFDEF RICHVIEWCBDEF3}
- TRVMarkerFormatStringW = type WideString;
- {$ENDIF}
- {$ENDIF}
- { Options for saving/loading RVF files/streams }
- TRVFOption = (
- rvfoSavePicturesBody, // Save pictures (if not set - images are requested
- // in event)
- rvfoSaveControlsBody, // Save controls (if not set - controls are
- // requested in event)
- rvfoIgnoreUnknownPicFmt, // Ignore pictures of unknown types
- // (if not set - report error)
- rvfoIgnoreUnknownCtrls, // Ignore controls of unknown types
- // (if not set - report error)
- rvfoConvUnknownStylesToZero, // Convert unknown text, paragraph or list
- // styles to 0-th styke (if not set - report error)
- rvfoConvLargeImageIdxToZero, // Convert too large image indices in "bullets"
- // and "hotspots" to 0 (if not set - report error)
- rvfoSaveBinary, // Binary RVF saving mode
- rvfoUseStyleNames, // (Obsolete)
- rvfoSaveBack, // Save background
- rvfoLoadBack, // Load background
- rvfoSaveTextStyles, // Save collection of text styles (RVStyle.TextStyles)
- rvfoSaveParaStyles, // Save collections of paragraph and list styles
- // (RVStyle.ParaStyles and .ListStyles)
- rvfoSaveLayout, // Save layout properties (margins, etc.)
- rvfoLoadLayout, // Load layout properties
- rvfoSaveDocProperties,// Save DocProperties stringlist
- rvfoLoadDocProperties // Load DocProperties stringlist
- );
- TRVFOptions = set of TRVFOption;
- { Operation, see TRichView.OnProgress event. }
- TRVLongOperation = (
- rvloLoading, // Saving
- rvloConverting); // Not used by the component. Allows to call
- { Operation progress, see TRichView.OnProgress event. }
- TRVProgressStage = (
- rvpstgStarting, // The operation is about to begin
- rvpstgRunning, // The operation is underway and has not yet completed
- rvpstgEnding); // The operation has just completed
- { Warnings for loading RVF files/streams }
- TRVFWarning = (
- rvfwUnknownPicFmt, // Picture of unknown/unregistered type (use RegisterClass)
- rvfwUnknownCtrls, // Control of unknown/unregistered type (use RegisterClass)
- rvfwConvUnknownStyles, // Invalid index of text/paragraph/list style
- rvfwConvLargeImageIdx, // Invalid image index in "bullet" or "hotspot"
- rvfwConvToUnicode, // Mismatched Unicode/ANSI type of text
- // (was converted to Unicode)
- rvfwConvFromUnicode, // Mismatched Unicode/ANSI type of text
- // (was converted to ANSI)
- rvfwInvalidPicture, // Invalid picture data (was replaced with
- // RVStyle.InvalidPicture.Graphic)
- rvfwUnknownStyleProperties); // Unknown properties of items in the collections
- // of text/paragraph/lists. Probably, RVF was saved with
- // newer version of component
- TRVFWarnings = set of TRVFWarning;
- { Action with controls inserted in TRichView, parameter of
- TCustomRichView.OnControlAction }
- TRVControlAction = (
- rvcaAfterRVFLoad, // Control is loaded from RVF file or stream
- rvcaDestroy, // Control is being destroyed (in TCustomRichView)
- rvcaMoveToUndoList, // Control is moved from editor to undo/redo buffer
- rvcaMoveFromUndoList, // Control is moved from undo/redo buffer back to editor
- rvcaDestroyInUndoList, // Control is being destroyed (in undo buffer)
- rvcaBeforeRVFSave, // Before saving control to RVF file or stream
- rvcaAfterRVFSave); // After saving control to RVF file or stream
- { Action with items, parameter of TCustomRichView.OnItemAction }
- TRVItemAction = (
- rviaInserting, // Before insertion in TCustomRichView
- rviaInserted, // After insertion in TCustomRichView
- rviaTextModifying, // Text of item is being modified as a result of
- // editing operation
- rviaDestroying, // Item is being destroyed
- rviaMovingToUndoList); // Item is moved to undo/redo buffer
- { Options for protected text, TFontInfo.Protection property }
- TRVProtectOption = (
- rvprStyleProtect, // Protect from ApplyTextStyle
- rvprModifyProtect, // Protect from text modifying (but not from
- // deletion as a whole)
- rvprDeleteProtect, // Protect from deletion as a whole
- rvprConcateProtect, // Protect from concatenation with adjacent text
- rvprRVFInsertProtect, // Protect from insertion from RVF
- rvprDoNotAutoSwitch, // TCustomRichViewEdit.CurTextStyleNo will never
- // be set to the text of this style automatically
- rvprParaStartProtect, // (See the help file)
- rvprSticking, // Disallows inserting between protected text items
- rvprStickToTop, // If this text is at the beginning, disallow inserting
- // before it
- rvprStickToBottom); // If this text is at the end, disallow inserting
- // after it
- TRVProtectOptions = set of TRVProtectOption;
- { Options for paragraph styles, TParaInfo.Options property }
- TRVParaOption = (
- rvpaoNoWrap, // Disallow word wrapping
- rvpaoReadOnly, // Disallow changes in paragraph (but it can be deleted
- // as a whole
- rvpaoStyleProtect, // Protect from ApplyParaStyle
- rvpaoDoNotWantReturns, // Ignore ENTER key
- rvpaoKeepLinesTogether, // Print the whole paragraph on one page, if possible
- rvpaoKeepWithNext); // Print this paragraph on the same page as the next one
- TRVParaOptions = set of TRVParaOption;
- { Options for text styles, TTextInfo.Options property }
- TRVTextOption = (
- rvteoHTMLCode, // Save text to HTML as is
- rvteoRTFCode); // Save text to RTF as is
- TRVTextOptions = set of TRVTextOption;
- { Options for saving HTML files, TCustomRichView.SaveHTML and SaveHTMLEx methods }
- TRVSaveOption = (
- rvsoOverrideImages, // Overwrite image files (if not set - use unique)
- rvsoFirstOnly, // Save only heading part of HTML
- rvsoMiddleOnly, // Save only middle part of HTML (document itself)
- rvsoLastOnly, // Save only ending part of HTML
- rvsoDefault0Style, // Do not save properties for the 0-th text style
- // (only for SaveHTML)
- rvsoNoHypertextImageBorders, // Supress borders for hypertext images
- rvsoImageSizes, // Write image size
- rvsoForceNonTextCSS,// Always use CSS for non-text items
- rvsoUseCheckpointsNames, // Use "checkpoint names" instead of indices
- rvsoMarkersAsText, // Save paragraph bullets/numbering without <UL>/<OL>
- rvsoInlineCSS, // Write CSS directly in <P> and <SPAN> tags
- // (only for SaveHTMLEx)
- rvsoNoDefCSSStyle, // Use named CSS for all text styles, even for
- // TextStyles[0] (by default, properties of
- // TextStyles[0] are assigned to BODY and TABLE).
- // This option generates larger HTML (not recommended).
- // (only for SaveHTMLEx)
- rvsoUseItemImageFileNames, // If set, images having specified
- // (in extra string properties) file names will not
- // be saved, but their file names will be written
- // in HTML (relative to the HTML file path)
- rvsoXHTML, // Save XHTML (only for SaveHTMLEx)
- rvsoUTF8); // Use UTF8 encoding
- TRVSaveOptions = set of TRVSaveOption;
- { Options for saving RTF files, TCustomRichView.RTFOptions }
- TRVRTFOption = (
- rvrtfSaveStyleSheet, // Save style sheet
- rvrtfDuplicateUnicode, // Save optional ANSI representation of Unicode text
- rvrtfSaveEMFAsWMF, // Save 32-bit metafiles as 16-bit metafiles
- // (more compatible RTF)
- rvrtfSaveJpegAsJpeg, // Save TJpegImage as jpeg (less compatible RTF)
- rvrtfSaveBitmapDefault, // Save "exotic" picture types as bitmaps (if not
- // set - as metafiles)
- rvrtfSaveEMFDefault); // Save "exotic" picture types as 32-bit metafiles
- TRVRTFOptions = set of TRVRTFOption;
- { Advanced font styles, TFontInfo.StyleEx }
- TRVFontStyle = (
- rvfsOverline, // Line above text
- rvfsAllCaps // All capitals
- {$IFDEF RVTEXTFOOTNOTES}
- , rvfsFootnotes
- {$ENDIF}
- );
- TRVFontStyles = set of TRVFontStyle;
- { Paragraph alignment, TParaInfo.Alignment }
- TRVAlignment = (rvaLeft, rvaRight, rvaCenter, rvaJustify);
- {$IFNDEF RVDONOTUSEINI}
- {$IFDEF RICHVIEWDEF4}
- TRVIniFile = TCustomIniFile;
- {$ELSE}
- TRVIniFile = TIniFile;
- {$ENDIF}
- {$ENDIF}
- { Parameters of TRVStyle.SaveCSS }
- TRVSaveCSSOption = (
- rvcssOnlyDifference, // do not use
- rvcssIgnoreLeftAlignment, // do not use
- rvcssNoDefCSSStyle, // see rvsoNoDefCSSStyle
- rvcssUTF8); // convert font names to UTF8
- TRVSaveCSSOptions = set of TRVSaveCSSOption;
- { Enumeration of properties of TFontInfo }
- TRVFontInfoProperty = (
- rvfiFontName, rvfiSize, rvfiCharset, rvfiUnicode,
- rvfiBold, rvfiItalic, rvfiUnderline, rvfiStrikeout,
- rvfiOverline, rvfiAllCaps,
- {$IFDEF RVTEXTFOOTNOTES}
- rvfiFootnotes,
- {$ENDIF}
- rvfiVShift, rvfiColor, rvfiBackColor,
- rvfiJump, rvfiHoverBackColor, rvfiHoverColor, rvfiJumpCursor,
- rvfiNextStyleNo, rvfiProtection, rvfiCharScale, rvfiBaseStyleNo,
- rvfiBiDiMode, rvfiCharSpacing, rvfiHTMLCode, rvfiRTFCode,
- {$IFDEF RVLANGUAGEPROPERTY}
- rvfiLanguage,
- {$ENDIF}
- rvfiCustom);
- { Enumeration of properies of TParaInfo }
- TRVParaInfoProperty = (
- rvpiFirstIndent, rvpiLeftIndent, rvpiRightIndent,
- rvpiSpaceBefore, rvpiSpaceAfter, rvpiAlignment,
- rvpiNextParaNo, rvpiDefStyleNo, rvpiLineSpacing, rvpiLineSpacingType,
- rvpiBackground_Color,
- rvpiBackground_BO_Left, rvpiBackground_BO_Top,
- rvpiBackground_BO_Right, rvpiBackground_BO_Bottom,
- rvpiBorder_Color, rvpiBorder_Style,
- rvpiBorder_Width, rvpiBorder_InternalWidth,
- rvpiBorder_BO_Left, rvpiBorder_BO_Top,
- rvpiBorder_BO_Right, rvpiBorder_BO_Bottom,
- rvpiBorder_Vis_Left, rvpiBorder_Vis_Top,
- rvpiBorder_Vis_Right, rvpiBorder_Vis_Bottom,
- rvpiNoWrap, rvpiReadOnly, rvpiStyleProtect, rvpiDoNotWantReturns,
- rvpiKeepLinesTogether, rvpiKeepWithNext, rvpiTabs,
- rvpiBiDiMode, rvpiCustom);
- TRVParaInfoProperty1 = rvpiFirstIndent..rvpiBorder_Vis_Bottom;
- TRVParaInfoProperty2 = rvpiNoWrap..rvpiBiDiMode;
- TRVFontInfoProperties = set of TRVFontInfoProperty;
- TRVParaInfoProperties = set of TRVParaInfoProperty;
- TRVParaInfoProperties1 = set of TRVParaInfoProperty1;
- TRVParaInfoProperties2 = set of TRVParaInfoProperty2;
- { Type of line spacing, TParaInfo.LineSpacingType }
- TRVLineSpacingType = (
- rvlsPercent, // TParaInfo.LineSpacing specifies spacing in percents
- rvlsSpaceBetween // ... in pixels
- {, rvlsAtLeast});
- { Mode of merging collections of styles, for internal use }
- TRVStyleMergeMode = (
- rvs_merge_SmartMerge, // Reuse styles, add if necessary
- rvs_merge_Map, // Use the most similar of existing styles. Do not add styles
- rvs_merge_Append); // Append one collection to another
- { Text selection mode }
- TRVSelectionMode = (
- rvsmChar, // Select by characters
- rvsmWord, // Select by word
- rvsmParagraph); // Select by paragraphs
- { Text selection style }
- TRVSelectionStyle = (
- rvssItems, // Highlighted items
- rvssLines); // Highlighted lines (like in Word). Not supported,
- // if BiDiMode<>rvbdUnspecified
- { Tab alignment (relative to text after the tab) }
- TRVTabAlign = ( rvtaLeft, rvtaRight, rvtaCenter );
- { Type for TRVStyleTemplate.Id and references to it }
- TRVStyleTemplateId = type Integer;
- { Type for TRVStyleTemplate.Name }
- TRVStyleTemplateName = type String;
- { Characters shown in "show special characters" mode.
- Type of RVVisibleSpecialCharacters variable }
- TRVSpecialCharacter = (rvscSpace, rvscNBSP, rvscParagraph, rvscSoftHyphen);
- TRVSpecialCharacters = set of TRVSpecialCharacter;
- { --------------------- Types for events of TRVStyle ----------------------- }
- TRVDrawTextBackEvent = procedure (Sender: TRVStyle; Canvas: TCanvas;
- StyleNo: Integer; Left, Top, Width, Height: Integer;
- DrawState: TRVTextDrawStates; var DoDefault: Boolean) of object;
- TRVApplyStyleEvent = procedure (Sender: TRVStyle; Canvas: TCanvas;
- StyleNo: Integer; var DoDefault: Boolean) of object;
- TRVApplyStyleColorEvent = procedure (Sender: TRVStyle; Canvas: TCanvas;
- StyleNo: Integer; DrawState: TRVTextDrawStates;
- var DoDefault: Boolean) of object;
- TRVDrawStyleTextEvent = procedure (Sender: TRVStyle; const s: String;
- Canvas: TCanvas; StyleNo: Integer; SpaceBefore,
- Left, Top, Width, Height: Integer;
- DrawState: TRVTextDrawStates; var DoDefault: Boolean) of object;
- TRVStyleHoverSensitiveEvent = procedure (Sender: TRVStyle; StyleNo: Integer;
- var Sensitive: Boolean) of object;
- TRVDrawCheckpointEvent = procedure (Sender: TRVStyle; Canvas: TCanvas;
- X,Y, ItemNo, XShift: Integer; RaiseEvent: Boolean; Control: TControl;
- var DoDefault: Boolean) of object;
- TRVDrawPageBreakEvent = procedure (Sender: TRVStyle; Canvas: TCanvas;
- Y, XShift: Integer; PageBreakType: TRVPageBreakType; Control: TControl;
- var DoDefault: Boolean) of object;
- TRVDrawParaRectEvent = procedure (Sender: TRVStyle; Canvas: TCanvas;
- ParaNo: Integer; ARect: TRect; var DoDefault: Boolean) of object;
- { ---------------------------------------------------------------------------
- TCustomRVInfo: ancestor class for text, paragraph and list styles
- (TFontInfo, TParaInfo, TRVListInfo)
- Properties:
- - BaseStyleNo - index of base style (reserved for future use)
- - StyleName - name of style
- - Standard - if True, this is a "real" style; if False, this style
- represents formatting and can be deleted by
- TCustomRichView.DeleteUnusedStyles
- - StyleTemplateId - id of TRVStyle.StyleTemplates collection item,
- or value <= 0 for no style template.
- }
- TCustomRVInfo = class(TCollectionItem)
- private
- FBaseStyleNo: Integer;
- FName: String;
- FStandard: Boolean;
- {$IFNDEF RVDONOTUSESTYLETEMPLATES}
- FStyleTemplateId: TRVStyleTemplateId;
- {$ENDIF}
- protected
- function IsSimpleEqual(Value: TCustomRVInfo; IgnoreReferences: Boolean;
- IgnoreID: Boolean{$IFDEF RICHVIEWDEF4}=True{$ENDIF}): Boolean; dynamic;
- function IsSimpleEqualEx(Value: TCustomRVInfo; Mapping: TRVIntegerList): Boolean; dynamic;
- function SimilarityValue(Value: TCustomRVInfo): Integer; dynamic;
- public
- constructor Create(Collection: TCollection); override;
- procedure Assign(Source: TPersistent); override;
- {$IFDEF RICHVIEWCBDEF3}
- function GetDisplayName: String; override;
- {$ENDIF}
- {$IFNDEF RVDONOTUSEINI}
- procedure SaveToINI(ini: TRVIniFile; const Section, fs: String);
- procedure LoadFromINI(ini: TRVIniFile; const Section, fs, DefName: String);
- {$ENDIF}
- published
- property BaseStyleNo: Integer read FBaseStyleNo write FBaseStyleNo default -1;
- property StyleName: String read FName write FName;
- property Standard: Boolean read FStandard write FStandard default True;
- {$IFNDEF RVDONOTUSESTYLETEMPLATES}
- property StyleTemplateId: TRVStyleTemplateId read FStyleTemplateId write FStyleTemplateId default -1;
- {$ENDIF}
- end;
- { ---------------------------------------------------------------------------
- TCustomRVFontInfo: ancestor of TFontInfo and TRVSTFontInfo
- Properties:
- - Charset, FontName, Size, Style, Color - see properties for TFont
- (FontName = Name)
- - VShift - vertical offet of text, % of text height.
- Positive values - up, negative values - down.
- - BackColor - color of text background, clNone for transparent
- - HoverBackColor - color of text background under mouse (only for hypertext),
- clNone for no effect
- - HoverColor - color of text under mouse (only for hypertext), clNone to
- use TRVStyle.HoverColor
- - StyleEx - advanced visual text styles, see TRVFontStyles
- - Jump - if true, this text is a hypertext
- - JumpCursor - cursor for hypertext
- - CharScale - horizontal character scale value, %
- - CharSpacing - spacing between characters, pixels
- - BiDiMode - bi-di mode of text
- - Language - text language (enabled by RVLANGUAGEPROPERTY compiler define)
- - Protection - protection options, see TRVProtectOptions
- - Options - see TRVTextOptions
- }
- TCustomRVFontInfo = class(TCustomRVInfo)
- private
- { Private declarations }
- FBiDiMode: TRVBiDiMode;
- FJump: Boolean;
- FJumpCursor: TCursor;
- FFontName: TFontName;
- FSize: Integer;
- FColor, FBackColor, FHoverColor, FHoverBackColor: TColor;
- FStyle: TFontStyles;
- FStyleEx: TRVFontStyles;
- FVShift: Integer;
- {$IFDEF RICHVIEWCBDEF3}
- FCharset: TFontCharset;
- {$ENDIF}
- {$IFDEF RVLANGUAGEPROPERTY}
- FLanguage: Cardinal;
- {$ENDIF}
- FProtection: TRVProtectOptions;
- FOptions: TRVTextOptions;
- FCharScale, FCharSpacing: Integer;
- {$IFDEF RVTEXTFOOTNOTES}
- FFootNote: String;
- {$ENDIF}
- procedure SingleSymbolsReader(reader: TReader);
- protected
- procedure DefineProperties(Filer: TFiler);override;
- function IsSimpleEqual(Value: TCustomRVInfo; IgnoreReferences: Boolean;
- IgnoreID: Boolean{$IFDEF RICHVIEWDEF4}=True{$ENDIF}): Boolean; override;
- function SimilarityValue(Value: TCustomRVInfo): Integer; override;
- public
- { Public declarations }
- constructor Create(Collection: TCollection); override;
- procedure Assign(Source: TPersistent); override;
- procedure AssignTo(Dest: TPersistent); override;
- procedure AssignSelectedProperties(Source: TCustomRVFontInfo; Props: TRVFontInfoProperties);
- procedure AssignToLogFont(var LogFont: TLogFont; Canvas: TCanvas; CanUseCustomPPI: Boolean);
- procedure Apply(Canvas: TCanvas; DefBiDiMode: TRVBiDiMode; CanUseCustomPPI: Boolean);
- procedure ApplyBiDiMode(Canvas: TCanvas; DefBiDiMode: TRVBiDiMode);
- procedure ApplyColor(Canvas: TCanvas; RVStyle: TRVStyle;
- DrawState: TRVTextDrawStates; Printing: Boolean; ColorMode: TRVColorMode);
- function IsEqual(Value: TCustomRVFontInfo; IgnoreList: TRVFontInfoProperties): Boolean; dynamic;
- {$IFNDEF RVDONOTUSEINI}
- procedure SaveToINI(ini: TRVIniFile; const Section, fs: String); dynamic;
- procedure LoadFromINI(ini: TRVIniFile; const Section, fs: String;
- JumpByDefault: Boolean; DefJumpCursor: TCursor); dynamic;
- {$ENDIF}
- procedure SaveCSSToStream(Stream: TStream; BaseStyle: TCustomRVFontInfo;
- Multiline, UTF8: Boolean);
- published
- { Published declarations }
- {$IFDEF RICHVIEWCBDEF3}
- property Charset: TFontCharset read FCharset write FCharset default DEFAULT_CHARSET;
- {$ENDIF}
- property FontName: TFontName read FFontName write FFontName;
- property Size: Integer read FSize write FSize default 10;
- property Style: TFontStyles read FStyle write FStyle default [];
- property VShift: Integer read FVShift write FVShift default 0;
- property Color: TColor read FColor write FColor default clWindowText;
- property BackColor: TColor read FBackColor write FBackColor default clNone;
- property HoverBackColor: TColor read FHoverBackColor write FHoverBackColor default clNone;
- property HoverColor: TColor read FHoverColor write FHoverColor default clNone;
- property StyleEx: TRVFontStyles read FStyleEx write FStyleEx default [];
- property Jump: Boolean read FJump write FJump default False;
- property JumpCursor: TCursor read FJumpCursor write FJumpCursor default crJump;
- property CharScale: Integer read FCharScale write FCharScale default 100;
- property CharSpacing: Integer read FCharSpacing write FCharSpacing default 0;
- property BiDiMode: TRVBiDiMode read FBiDiMode write FBiDiMode default rvbdUnspecified;
- {$IFDEF RVLANGUAGEPROPERTY}
- property Language: Cardinal read FLanguage write FLanguage default 0;
- {$ENDIF}
- property Protection: TRVProtectOptions read FProtection write FProtection default [];
- property Options: TRVTextOptions read FOptions write FOptions default [];
- {$IFDEF RVTEXTFOOTNOTES}
- property FootNote: String read FFootNote write FFootNote;
- {$ENDIF}
- end;
- { ---------------------------------------------------------------------------
- TFontInfo: text style, item in the collection TRVStyle.TextStyles
- (collection type is TFontInfos)
- Properties:
- - NextStyleNo - index of text style for the next paragraph, if user
- pressed ENTER at the end of paragraph of this style. -1 for the same style
- - Unicode - if False, this text has ANSI encoding. If True, it is Unicode
- - ModifiedProperties - list of properties which are not inherited
- from StyleTemplate identified by StyleTemplateId property
- }
- TFontInfo = class (TCustomRVFontInfo)
- private
- {$IFNDEF RVDONOTUSEUNICODE}
- FUnicode: Boolean;
- {$ENDIF}
- FNextStyleNo: Integer;
- {$IFNDEF RVDONOTUSESTYLETEMPLATES}
- FModifiedProperties: TRVFontInfoProperties;
- {$ENDIF}
- protected
- function IsSimpleEqualEx(Value: TCustomRVInfo; Mapping: TRVIntegerList): Boolean; override;
- function IsSimpleEqual(Value: TCustomRVInfo; IgnoreReferences: Boolean;
- IgnoreID: Boolean{$IFDEF RICHVIEWDEF4}=True{$ENDIF}): Boolean; override;
- {$IFNDEF RVDONOTUSESTYLETEMPLATES}
- procedure ExcludeUnmodifiedProperties(Source: TCustomRVFontInfo;
- PossibleProps: TRVFontInfoProperties);
- {$ENDIF}
- public
- constructor Create(Collection: TCollection); override;
- procedure Assign(Source: TPersistent); override;
- function IsEqual(Value: TCustomRVFontInfo; IgnoreList: TRVFontInfoProperties): Boolean; override;
- procedure Draw(const s: String; Canvas: TCanvas; ThisStyleNo: Integer;
- SpaceBefore, Left, Top, Width, Height: Integer; RVStyle: TRVStyle;
- DrawState: TRVTextDrawStates; Printing, PreviewCorrection: Boolean;
- ColorMode: TRVColorMode; DefBiDiMode: TRVBiDiMode);
- procedure DrawVertical(const s: String; Canvas: TCanvas; // <- do not ask me what is it :)
- ThisStyleNo: Integer; SpaceBefore, Left, Top, Width, Height: Integer;
- RVStyle: TRVStyle; DrawState: TRVTextDrawStates);
- {$IFNDEF RVDONOTUSEINI}
- procedure SaveToINI(ini: TRVIniFile; const Section, fs: String); override;
- procedure LoadFromINI(ini: TRVIniFile; const Section, fs: String;
- JumpByDefault: Boolean; DefJumpCursor: TCursor); override;
- {$ENDIF}
- published
- property NextStyleNo: Integer read FNextStyleNo write FNextStyleNo default -1;
- {$IFNDEF RVDONOTUSEUNICODE}
- property Unicode: Boolean read FUnicode write FUnicode default False;
- {$ENDIF}
- {$IFNDEF RVDONOTUSESTYLETEMPLATES}
- property ModifiedProperties: TRVFontInfoProperties
- read FModifiedProperties write FModifiedProperties default [];
- {$ENDIF}
- end;
- { ---------------------------------------------------------------------------
- TCustomRVInfos: ancestor class for collections of styles
- (TFontInfos, TParaInfos, TRVListInfos)
- }
- TCustomRVInfos = class (TCollection)
- protected
- FOwner: TPersistent;
- public
- constructor Create(ItemClass: TCollectionItemClass; Owner: TPersistent);
- {$IFDEF RICHVIEWCBDEF3}
- function GetOwner: TPersistent; override;
- {$ENDIF}
- procedure AssignTo(Dest: TPersistent); override;
- procedure MergeWith(Styles:TCustomRVInfos; Mode:TRVStyleMergeMode;
- Mapping: TRVIntegerList; TextStyleMapping: TRVIntegerList);
- end;
- {----------------------------------------------------------------------------
- TFontInfos: collection of text styles (of TFontInfo), TRVStyle.TextStyles
- Properties:
- - Items[] - items
- - InvalidItem - returned when accessing item with invalid index
- }
- TFontInfos = class (TCustomRVInfos)
- private
- FInvalidItem: TFontInfo;
- function GetItem(Index: Integer): TFontInfo;
- procedure SetItem(Index: Integer; Value: TFontInfo);
- function GetInvalidItem: TFontInfo;
- procedure SetInvalidItem(const Value: TFontInfo);
- public
- PixelsPerInch: Integer;
- destructor Destroy; override;
- {$IFDEF RICHVIEWCBDEF3}
- function FindStyleWithCharset(BaseStyle: Integer;
- Charset: TFontCharset): Integer;
- {$ENDIF}
- function FindStyleWithFontStyle(BaseStyle: Integer; Value,
- Mask: TFontStyles): Integer;
- function FindStyleWithFontSize(BaseStyle: Integer; Size: Integer): Integer;
- function FindStyleWithColor(BaseStyle: Integer;
- Color, BackColor: TColor): Integer;
- function FindStyleWithFontName(BaseStyle: Integer;
- const FontName: TFontName): Integer;
- function FindSuchStyle(BaseStyle: Integer; Style: TFontInfo;
- Mask: TRVFontInfoProperties): Integer;
- function FindStyleWithFont(BaseStyle: Integer; Font: TFont): Integer;
- function Add: TFontInfo;
- function AddFont(Name: TFontName; Size: Integer; Color, BackColor: TColor;
- Style:TFontStyles): TFontInfo;
- {$IFDEF RICHVIEWCBDEF3}
- function AddFontEx(Name: TFontName; Size: Integer; Color, BackColor: TColor;
- Style:TFontStyles; Charset: TFontCharset): TFontInfo;
- {$ENDIF}
- {$IFNDEF RVDONOTUSEINI}
- procedure SaveToINI(ini: TRVIniFile; const Section: String);
- procedure LoadFromINI(ini: TRVIniFile; const Section: String;
- DefJumpCursor: TCursor);
- {$ENDIF}
- property Items[Index: Integer]: TFontInfo read GetItem write SetItem; default;
- property InvalidItem: TFontInfo read GetInvalidItem write SetInvalidItem;
- end;
- { ---------------------------------------------------------------------------
- TRVRect: rectangle.
- Properties:
- - Left, Top, Right, Bottom
- }
- TRVRect = class (TPersistent)
- private
- FTop: Integer;
- FLeft: Integer;
- FRight: Integer;
- FBottom: Integer;
- function IsEqualEx(Value: TRVRect; IgnL,IgnT,IgnR,IgnB: Boolean): Boolean;
- function SimilarityValue(Value: TRVRect; Weight: Integer): Integer;
- public
- procedure Assign(Source: TPersistent); override;
- procedure AssignValidProperties(Source: TRVRect; ValL, ValT, ValR, ValB: Boolean);
- procedure SetAll(Value: Integer);
- procedure InflateRect(var Rect: TRect);
- procedure InflateRectSaD(var Rect: TRect; const sad: TRVScreenAndDevice);
- procedure AssignToRect(var Rect: TRect);
- procedure AssignToRectIfGreater(var Rect: TRect);
- function IsEqual(Value: TRVRect): Boolean;
- {$IFNDEF RVDONOTUSEINI}
- procedure SaveToINI(ini: TRVIniFile; const Section, fs: String);
- procedure LoadFromINI(ini: TRVIniFile; const Section, fs: String);
- {$ENDIF}
- published
- property Left: Integer read FLeft write FLeft default 0;
- property Right: Integer read FRight write FRight default 0;
- property Top: Integer read FTop write FTop default 0;
- property Bottom: Integer read FBottom write FBottom default 0;
- end;
- { ---------------------------------------------------------------------------
- TRVBooleanRect: 4 boolean values
- Properties:
- - Left, Top, Right, Bottom
- }
- TRVBooleanRect = class (TPersistent)
- private
- FTop: Boolean;
- FLeft: Boolean;
- FRight: Boolean;
- FBottom: Boolean;
- function IsEqualEx(Value: TRVBooleanRect; IgnL,IgnT,IgnR,IgnB: Boolean): Boolean;
- public
- constructor Create(DefValue: Boolean);
- procedure SetAll(Value: Boolean);
- procedure SetValues(ALeft, ATop, ARight, ABottom: Boolean);
- procedure Assign(Source: TPersistent); override;
- procedure AssignValidProperties(Source: TRVBooleanRect;
- ValL, ValT, ValR, ValB: Boolean);
- function IsEqual(Value: TRVBooleanRect): Boolean;
- function IsEqual2(ALeft, ATop, ARight, ABottom: Boolean): Boolean;
- function IsAllEqual(Value: Boolean): Boolean;
- {$IFNDEF RVDONOTUSEINI}
- procedure SaveToINI(ini: TRVIniFile; const Section, fs: String);
- procedure LoadFromINI(ini: TRVIniFile; const Section, fs: String);
- {$ENDIF}
- published
- property Left: Boolean read FLeft write FLeft default True;
- property Right: Boolean read FRight write FRight default True;
- property Top: Boolean read FTop write FTop default True;
- property Bottom: Boolean read FBottom write FBottom default True;
- end;
- { ---------------------------------------------------------------------------
- TRVBorder: paragraph border
- Properties:
- - Width - [thin] line width
- - InternalWidth - spacing between border lines (for double or triple borders)
- - Color - border color
- - Style - border type, see TRVBorderStyle
- - VisibleBorders - turn on/off border sides
- - BorderOffsets - padding between text and border
- }
- TRVBorder = class (TPersistent)
- private
- FColor: TColor;
- FStyle: TRVBorderStyle;
- FWidth: Integer;
- FInternalWidth: Integer;
- FVisibleBorders: TRVBooleanRect;
- FBorderOffsets: TRVRect;
- procedure SetBorderOffsets(const Value: TRVRect);
- procedure SetVisibleBorders(const Value: TRVBooleanRect);
- function SimilarityValue(Value: TRVBorder): Integer;
- protected
- procedure DoDraw(Rect: TRect; Canvas: TCanvas;
- Width, InternalWidth, OnePixelWidth: Integer;
- ColorMode: TRVColorMode);
- public
- constructor Create;
- destructor Destroy; override;
- procedure Draw(Rect: TRect; Canvas: TCanvas);
- procedure DrawSaD(Rect: TRect; Canvas: TCanvas; const sad: TRVScreenAndDevice;
- ColorMode: TRVColorMode);
- procedure Assign(Source: TPersistent); override;
- function IsEqual(Value: TRVBorder): Boolean;
- function IsEqual_Para(Value: TRVBorder; IgnoreList: TRVParaInfoProperties): Boolean;
- procedure AssignValidProperties(Source: TRVBorder; ValidProperties: TRVParaInfoProperties1);
- {$IFNDEF RVDONOTUSEINI}
- procedure SaveToINI(ini: TRVIniFile; const Section, fs: String);
- procedure LoadFromINI(ini: TRVIniFile; const Section, fs: String);
- {$ENDIF}
- function GetTotalWidth: Integer;
- published
- property Width: Integer read FWidth write FWidth default 1;
- property InternalWidth: Integer read FInternalWidth write FInternalWidth default 1;
- property Color: TColor read FColor write FColor default clWindowText;
- property Style: TRVBorderStyle read FStyle write FStyle default rvbNone;
- property VisibleBorders: TRVBooleanRect read FVisibleBorders write SetVisibleBorders;
- property BorderOffsets: TRVRect read FBorderOffsets write SetBorderOffsets;
- end;
- { ---------------------------------------------------------------------------
- TRVBackgroundRect: properties for paragraph background
- Properties:
- - Color - background color (clNone for transparent)
- - BorderOffsets - padding (widths of colored area around paragraph text)
- }
- TRVBackgroundRect = class (TPersistent)
- private
- FBorderOffsets: TRVRect;
- FColor: TColor;
- procedure SetBorderOffsets(const Value: TRVRect);
- function SimilarityValue(Value: TRVBackgroundRect): Integer;
- public
- constructor Create;
- destructor Destroy; override;
- procedure Assign(Source: TPersistent); override;
- procedure PrepareDraw(var Rect: TRect);
- procedure PrepareDrawSaD(var Rect: TRect; const sad: TRVScreenAndDevice);
- procedure Draw(Rect: TRect; Canvas: TCanvas; Printing: Boolean;
- ColorMode: TRVColorMode);
- function IsEqual(Value: TRVBackgroundRect): Boolean;
- function IsEqual_Para(Value: TRVBackgroundRect;
- IgnoreList: TRVParaInfoProperties): Boolean;
- procedure AssignValidProperties(Source: TRVBackgroundRect;
- ValidProperties: TRVParaInfoProperties1);
- {$IFNDEF RVDONOTUSEINI}
- procedure SaveToINI(ini: TRVIniFile; const Section, fs: String);
- procedure LoadFromINI(ini: TRVIniFile; const Section, fs: String);
- {$ENDIF}
- published
- property Color: TColor read FColor write FColor default clNone;
- property BorderOffsets: TRVRect read FBorderOffsets write SetBorderOffsets;
- end;
- {$IFNDEF RVDONOTUSETABS}
- {----------------------------------------------------------------------------
- TRVTabInfo: properties of paragraph's tabs.
- Properties:
- - Align - alignment of tab relative to the next text
- - Position - distance between the left (right for RTL) margin and the tab;
- assignment resorts the tab collection
- - Leader - characters to fill the tab }
- TRVTabInfo = class (TCollectionItem)
- private
- FPosition: Integer;
- FLeader: String;
- FAlign: TRVTabAlign;
- function StoreLeader: Boolean;
- procedure SetPosition(const Value: Integer);
- protected
- {$IFDEF RICHVIEWCBDEF3}
- function GetDisplayName: String; override;
- {$ENDIF}
- public
- function IsEqual(Value: TRVTabInfo): Boolean;
- function SimilarityValue(Value: TRVTabInfo): Integer;
- procedure Assign(Source: TPersistent); override;
- {$IFNDEF RVDONOTUSEINI}
- procedure SaveToINI(ini: TRVIniFile; const Section, fs: String);
- procedure LoadFromINI(ini: TRVIniFile; const Section, fs: String);
- {$ENDIF}
- published
- property Align: TRVTabAlign read FAlign write FAlign default rvtaLeft;
- property Position: Integer read FPosition write SetPosition;
- property Leader: String read FLeader write FLeader stored StoreLeader;
- end;
- {----------------------------------------------------------------------------
- { TRVTabInfos: tabs of paragraphs, type of TParaInfo.Tabs
- (collection of TRVTabInfo)
- Properties:
- Items[] - tabs
- }
- TRVTabInfos = class (TCollection)
- private
- FOwner: TPersistent;
- function GetItem(Index: Integer): TRVTabInfo;
- procedure SetItem(Index: Integer; Value: TRVTabInfo);
- public
- constructor Create(Owner: TPersistent);
- {$IFDEF RICHVIEWCBDEF3}
- function GetOwner: TPersistent; override;
- {$ENDIF}
- {$IFNDEF RVDONOTUSEINI}
- procedure SaveToINI(ini: TRVIniFile; const Section, fs: String);
- procedure LoadFromINI(ini: TRVIniFile; const Section, fs: String);
- {$ENDIF}
- function Add: TRVTabInfo;
- procedure SortTabs;
- function IsEqual(Value: TRVTabInfos): Boolean;
- function Find(Position: Integer): Integer;
- function SimilarityValue(Value: TRVTabInfos): Integer;
- procedure Intersect(Value: TRVTabInfos);
- procedure AddFrom(Source: TRVTabInfos);
- procedure DeleteList(Positions: TRVIntegerList);
- property Items[Index: Integer]: TRVTabInfo
- read GetItem write SetItem; default;
- end;
- {$ENDIF}
- {----------------------------------------------------------------------------
- TCustomRVParaInfo: ancestor of TParaInfo and TRVSTParaInfo
- Properties:
- - FirstIndent - first line indent, pixels (added to LeftIndent, can be negative)
- - LeftIndent, RightIndent, SpaceBefore, SpaceAfter - indents to the left,
- right, top, bottom of the paragraph, pixels
- - Alignment - paragraph alignmentm see TRVAlignment
- - Border - paragraph border, see TRVBorder
- - Background - paragraph background, see TRVBackgroundRect
- - LineSpacing - line spacing value, pixels or percents
- - LineSpacingType - line spacing type, see TRVLineSpacingType
- - Options - see TRVParaOptions
- - BiDiMode - paragraph bi-di mode
- }
- TCustomRVParaInfo = class (TCustomRVInfo)
- private
- FFirstIndent: Integer;
- FLeftIndent: Integer;
- FRightIndent: Integer;
- FSpaceBefore: Integer;
- FSpaceAfter: Integer;
- FLineSpacing: Integer;
- FLineSpacingType: TRVLineSpacingType;
- FAlignment: TRVAlignment;
- FBorder: TRVBorder;
- FBackground: TRVBackgroundRect;
- FOptions: TRVParaOptions;
- FBiDiMode: TRVBiDiMode;
- {$IFNDEF RVDONOTUSETABS}
- FTabs: TRVTabInfos;
- {$ENDIF}
- procedure SetBorder(const Value: TRVBorder);
- procedure SetBackground(const Value: TRVBackgroundRect);
- function ExtraLineSpacing: Boolean;
- {$IFNDEF RVDONOTUSETABS}
- procedure SetTabs(const Value: TRVTabInfos);
- {$ENDIF}
- protected
- function IsSimpleEqual(Value: TCustomRVInfo; IgnoreReferences: Boolean;
- IgnoreID: Boolean{$IFDEF RICHVIEWDEF4}=True{$ENDIF}): Boolean; override;
- function SimilarityValue(Value: TCustomRVInfo): Integer; override;
- public
- constructor Create(Collection: TCollection); override;
- destructor Destroy; override;
- procedure Assign(Source: TPersistent); override;
- procedure AssignSelectedProperties(Source: TCustomRVParaInfo;
- Props: TRVParaInfoProperties);
- {$IFNDEF RVDONOTUSEINI}
- procedure SaveToINI(ini: TRVIniFile; const Section, fs: String); dynamic;
- procedure LoadFromINI(ini: TRVIniFile; const Section, fs: String); dynamic;
- {$ENDIF}
- function IsEqual(Value: TCustomRVParaInfo; IgnoreList: TRVParaInfoProperties): Boolean; dynamic;
- procedure SaveCSSToStream(Stream: TStream; BaseStyle: TParaInfo;
- Multiline, IgnoreLeftAlignment, IgnoreLeftIndents: Boolean);
- published
- property FirstIndent: Integer read FFirstIndent write FFirstIndent default 0;
- property LeftIndent: Integer read FLeftIndent write FLeftIndent default 0;
- property RightIndent: Integer read FRightIndent write FRightIndent default 0;
- property SpaceBefore: Integer read FSpaceBefore write FSpaceBefore default 0;
- property SpaceAfter: Integer read FSpaceAfter write FSpaceAfter default 0;
- property Alignment: TRVAlignment read FAlignment write FAlignment default rvaLeft;
- property Border: TRVBorder read FBorder write SetBorder;
- property Background: TRVBackgroundRect read FBackground write SetBackground;
- property LineSpacing: Integer read FLineSpacing write FLineSpacing default 100;
- property LineSpacingType: TRVLineSpacingType read FLineSpacingType write FLineSpacingType default rvlsPercent;
- property Options: TRVParaOptions read FOptions write FOptions default [];
- property BiDiMode: TRVBiDiMode read FBiDiMode write FBidiMode default rvbdUnspecified;
- {$IFNDEF RVDONOTUSETABS}
- property Tabs: TRVTabInfos read FTabs write SetTabs;
- {$ENDIF}
- end;
- {----------------------------------------------------------------------------
- TParaInfo: paragraph style, item in the collection TRVStyle.ParaStyles
- (collection type is TParaInfos)
- Properties:
- - NextParaNo - index of paragraph style for the next paragraph, if user
- pressed ENTER at the end of paragraph of this style. -1 for the same style
- - DefStyleNo - index of text style used for this paragraph by default
- - ModifiedProperties1, ModifiedProperties2 - list of properties not inherited
- from StyleTemplate identified by StyleTemplateId property
- }
- TParaInfo = class (TCustomRVParaInfo)
- private
- FNextParaNo: Integer;
- FDefStyleNo: Integer;
- {$IFNDEF RVDONOTUSESTYLETEMPLATES}
- FModifiedProperties1: TRVParaInfoProperties1;
- FModifiedProperties2: TRVParaInfoProperties2;
- {$ENDIF}
- protected
- function IsSimpleEqualEx(Value: TCustomRVInfo; Mapping: TRVIntegerList): Boolean; override;
- function IsSimpleEqual(Value: TCustomRVInfo; IgnoreReferences: Boolean;
- IgnoreID: Boolean{$IFDEF RICHVIEWDEF4}=True{$ENDIF}): Boolean; override;
- {$IFNDEF RVDONOTUSESTYLETEMPLATES}
- procedure ExcludeUnmodifiedProperties(Source: TCustomRVParaInfo;
- PossibleProps: TRVParaInfoProperties);
- {$ENDIF}
- public
- constructor Create(Collection: TCollection); override;
- procedure Assign(Source: TPersistent); override;
- function IsEqual(Value: TCustomRVParaInfo; IgnoreList: TRVParaInfoProperties): Boolean; override;
- {$IFNDEF RVDONOTUSEINI}
- procedure SaveToINI(ini: TRVIniFile; const Section, fs: String); override;
- procedure LoadFromINI(ini: TRVIniFile; const Section, fs: String); override;
- {$ENDIF}
- published
- property NextParaNo: Integer read FNextParaNo write FNextParaNo default -1;
- property DefStyleNo: Integer read FDefStyleNo write FDefStyleNo default -1;
- {$IFNDEF RVDONOTUSESTYLETEMPLATES}
- property ModifiedProperties1: TRVParaInfoProperties1
- read FModifiedProperties1 write FModifiedProperties1 default [];
- property ModifiedProperties2: TRVParaInfoProperties2
- read FModifiedProperties2 write FModifiedProperties2 default [];
- {$ENDIF}
- end;
- { ---------------------------------------------------------------------------
- TParaInfos: collection of paragraph styles (of TParaInfo), TRVStyle.ParaStyles
- Properties:
- - Items[] - items
- - InvalidItem - returned when accessing item with invalid index
- }
- TParaInfos = class(TCustomRVInfos)
- private
- FInvalidItem: TParaInfo;
- function GetItem(Index: Integer): TParaInfo;
- procedure SetItem(Index: Integer; Value: TParaInfo);
- function GetInvalidItem: TParaInfo;
- procedure SetInvalidItem(const Value: TParaInfo);
- public
- function Add: TParaInfo;
- procedure AssignTo(Dest: TPersistent); override;
- destructor Destroy; override;
- {$IFNDEF RVDONOTUSEINI}
- procedure SaveToINI(ini: TRVIniFile; const Section: String);
- procedure LoadFromINI(ini: TRVIniFile; const Section: String);
- {$ENDIF}
- function FindSuchStyle(BaseStyle: Integer; Style: TParaInfo;
- Mask: TRVParaInfoProperties): Integer;
- function FindStyleWithAlignment(BaseStyle: Integer;
- Alignment: TRVAlignment): Integer;
- property Items[Index: Integer]: TParaInfo
- read GetItem write SetItem; default;
- property InvalidItem: TParaInfo read GetInvalidItem write SetInvalidItem;
- end;
- { ---------------------------------------------------------------------------
- TRVMarkerFont: font for paragraph marker.
- Overrides default values of properties (to Arial, 8pt)
- }
- 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: level of paragraph bullets/numbering. Item of collection
- RVListInfo.Levels (collection type is TRVListLevelCollection)
- Properties:
- - ListType - type of bullets/numbering, see TRVListType
- - StartFrom - level numbering starts from this value
- - ImageList, ImageIndex - used if ListType = rvlstImageList or
- rvlstImageListCounter
- - FormatString - format string for ListType = rvlstBullet or text numbering
- - FormatStringW - text, used if ListType = rvlstUnicodeBullet
- - LeftIndent - left indent (right indent for RTL paragraphs), pixels;
- overrides setting for paragraph
- - FirstIndent - first line indent, pixels; added to left indent,
- overrides setting for paragraph
- - MarkerIndent - indent of list marker, pixels (see also MarkerAlignment)
- - MarkerAlignment - alignment of list marker relative to position specified
- in MarkerIndent
- - Picture - used if ListType = rvlstPicture
- - Font - font of list marker, used for text list types
- - Options - see TRVListLevelOptions
- }
- 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;
- {$IFNDEF RVDONOTUSEINI}
- procedure SaveToINI(ini: TRVIniFile; const Section, fs: String);
- procedure LoadFromINI(ini: TRVIniFile; const Section, fs: String);
- {$ENDIF}
- 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: collection of levels of paragraph bullets/numbering.
- A type of TRVListInfo.Levels. Type of collection item is TRVListLevel
- Properties:
- Items[] - list levels
- }
- 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: style of paragraph bullets/numbering, item in the collection
- TRVStyle.ListStyles (collection type is TRVListInfos)
- Properties:
- - Levels[] - collection of list levels; must have at least one item in
- order to display bullet/numbering
- - OneLevelPreview - for using in user interface (if True, preview
- of this paragraph list should show only one level)
- - ListID (read-only) - a random number for distinguishing lists with the same
- properties when pasting RVF
- }
- TRVListInfo = class (TCustomRVInfo)
- private
- FLevels: TRVListLevelCollection;
- FOneLevelPreview: Boolean;
- FListID: Integer;
- procedure SetLevels(const Value: TRVListLevelCollection);
- function GetListID: Integer;
- procedure ReadListID(Reader: TReader);
- procedure WriteListID(Writer: TWriter);
- protected
- function SimilarityValue(Value: TCustomRVInfo): Integer; override;
- procedure DefineProperties(Filer: TFiler); override;
- public
- function IsSimpleEqual(Value: TCustomRVInfo; IgnoreReferences: Boolean;
- IgnoreID: Boolean{$IFDEF RICHVIEWDEF4}=True{$ENDIF}): Boolean; override;
- function IsSimpleEqualEx(Value: TCustomRVInfo; Mapping: TRVIntegerList): Boolean; override;
- constructor Create(Collection: TCollection); override;
- destructor Destroy; override;
- procedure Assign(Source: TPersistent); override;
- {$IFNDEF RVDONOTUSEINI}
- procedure SaveToINI(ini: TRVIniFile; const Section, fs: String); dynamic;
- procedure LoadFromINI(ini: TRVIniFile; const Section, fs: String); dynamic;
- {$ENDIF}
- function HasNumbering: Boolean;
- function AllNumbered: Boolean;
- function HasVariableWidth: Boolean;
- property ListID: Integer read GetListID;
- published
- property Levels: TRVListLevelCollection read FLevels write SetLevels;
- property OneLevelPreview: Boolean read FOneLevelPreview write FOneLevelPreview default False;
- end;
- { ---------------------------------------------------------------------------
- TRVListInfos: collection of styles of paragraph lists (of TRVListInfo),
- TRVStyle.ListStyles
- Properties:
- - Items[] - items
- }
- 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}
- {$IFNDEF RVDONOTUSEINI}
- procedure LoadFromINI(ini: TRVIniFile; const Section: String);
- procedure SaveToINI(ini: TRVIniFile; const Section: String);
- {$ENDIF}
- 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;
- {$IFNDEF RVDONOTUSESTYLETEMPLATES}
- { ---------------------------------------------------------------------------
- TRVSTFontInfo, TRVSTParaInfo, TRVSTListInfo: classes for properties of
- TRVStyleTemplate. Hide some properties.
- }
- TRVSTFontInfo = class (TCustomRVFontInfo)
- private
- {$IFDEF RICHVIEWCBDEF3}
- FOwner: TPersistent;
- {$ENDIF}
- procedure SetNoProp(const Value: Integer);
- public
- {$IFDEF RICHVIEWCBDEF3}
- function GetOwner: TPersistent; override;
- {$ENDIF}
- published
- property StyleTemplateId: Integer write SetNoProp;
- property StyleName: Integer write SetNoProp;
- property Standard: Integer write SetNoProp;
- property BaseStyleNo: Integer write SetNoProp;
- end;
- TRVSTParaInfo = class (TCustomRVParaInfo)
- private
- {$IFDEF RICHVIEWCBDEF3}
- FOwner: TPersistent;
- {$ENDIF}
- procedure SetNoProp(const Value: Integer);
- public
- {$IFDEF RICHVIEWCBDEF3}
- function GetOwner: TPersistent; override;
- {$ENDIF}
- published
- property StyleTemplateId: Integer write SetNoProp;
- property StyleName: Integer write SetNoProp;
- property Standard: Integer write SetNoProp;
- property BaseStyleNo: Integer write SetNoProp;
- end;
- TRVSTListInfo = class (TRVListInfo)
- private
- {$IFDEF RICHVIEWCBDEF3}
- FOwner: TPersistent;
- {$ENDIF}
- procedure SetNoProp(const Value: Integer);
- public
- {$IFDEF RICHVIEWCBDEF3}
- function GetOwner: TPersistent; override;
- {$ENDIF}
- published
- property StyleTemplateId: Integer write SetNoProp;
- property StyleName: Integer write SetNoProp;
- property Standard: Integer write SetNoProp;
- property BaseStyleNo: Integer write SetNoProp;
- end;
- TRVStyleTemplate = class (TCollectionItem)
- private
- FName: TRVStyleTemplateName;
- FId: TRVStyleTemplateId;
- FParentId: TRVStyleTemplateId;
- FTextStyle: TRVSTFontInfo;
- FParaStyle: TRVSTParaInfo;
- FListStyle: TRVSTListInfo;
- FValidTextProperties: TRVFontInfoProperties;
- FValidParaProperties1: TRVParaInfoProperties1;
- FValidParaProperties2: TRVParaInfoProperties2;
- FParent: TRVStyleTemplate;
- FChildren: TList;
- function GetId: TRVStyleTemplateId;
- procedure SetTextStyle(const Value: TRVSTFontInfo);
- // procedure SetListStyle(const Value: TRVSTListInfo);
- procedure SetParaStyle(const Value: TRVSTParaInfo);
- procedure ReadID(Reader: TReader);
- procedure WriteID(Writer: TWriter);
- procedure AddChild(Child: TRVStyleTemplate);
- procedure RemoveChild(Child: TRVStyleTemplate);
- procedure SetParentId(const Value: TRVStyleTemplateId);
- procedure UpdateParentReference;
- procedure SetName(const Value: TRVStyleTemplateName);
- protected
- procedure DefineProperties(Filer: TFiler); override;
- function AssignToTextStyle(ATextStyle: TCustomRVFontInfo;
- AllowedProps: TRVFontInfoProperties): TRVFontInfoProperties;
- function AssignToParaStyle(AParaStyle: TCustomRVParaInfo;
- AllowedProps: TRVParaInfoProperties): TRVParaInfoProperties;
- procedure AssignTo(Dest: TPersistent); override;
- public
- constructor Create(Collection: TCollection); override;
- destructor Destroy; override;
- {$IFDEF RICHVIEWCBDEF3}
- function GetDisplayName: String; override;
- {$ENDIF}
- procedure Assign(Source: TPersistent); override;
- function IsAncestorFor(StyleTemplate: TRVStyleTemplate): Boolean;
- procedure ExcludeUnmodifiedTextStyleProperties(ATextStyle: TFontInfo;
- PossibleProps: TRVFontInfoProperties);
- procedure ExcludeUnmodifiedParaStyleProperties(AParaStyle: TParaInfo;
- PossibleProps: TRVParaInfoProperties);
- procedure ApplyToTextStyle(ATextStyle: TCustomRVFontInfo;
- AParaStyle: TCustomRVParaInfo; OverrideModifiedProperties: Boolean);
- procedure ApplyToParaStyle(AParaStyle: TCustomRVParaInfo;
- OverrideModifiedProperties: Boolean);
- published
- property TextStyle: TRVSTFontInfo read FTextStyle write SetTextStyle;
- property ParaStyle: TRVSTParaInfo read FParaStyle write SetParaStyle;
- // property ListStyle: TRVSTListInfo read FListStyle write SetListStyle;
- property ValidTextProperties: TRVFontInfoProperties
- read FValidTextProperties write FValidTextProperties default [];
- property ValidParaProperties1: TRVParaInfoProperties1
- read FValidParaProperties1 write FValidParaProperties1 default [];
- property ValidParaProperties2: TRVParaInfoProperties2
- read FValidParaProperties2 write FValidParaProperties2 default [];
- property Name: TRVStyleTemplateName read FName write SetName;
- property Id: TRVStyleTemplateId read GetId;
- property ParentId: TRVStyleTemplateId read FParentId write SetParentId default -1;
- end;
- TRVStyleTemplateCollection = class (TCollection)
- private
- FNameCounter: Integer;
- FDefStyleName: String;
- FNormalStyleTemplate: TRVStyleTemplate;
- function GetItem(Index: Integer): TRVStyleTemplate;
- procedure SetItem(Index: Integer; const Value: TRVStyleTemplate);
- procedure AssignUniqueNameTo(Item: TRVStyleTemplate);
- function StoreDefStyleName: Boolean;
- procedure UpdateParentReferences;
- protected
- FOwner: TPersistent;
- public
- constructor Create(Owner: TPersistent);
- procedure ResetNameCounter;
- procedure Sort;
- function FindById(Id: TRVStyleTemplateId): Integer;
- function FindByName(const Name: TRVStyleTemplateName): Integer;
- function GetNormalStyleTemplate: TRVStyleTemplate;
- procedure AssignToStrings(Strings: TStrings; AssignObjects: Boolean);
- procedure Assign(Source: TPersistent); override;
- procedure AssignStyleTemplates(Source: TRVStyleTemplateCollection; CopyIds: Boolean);
- procedure ClearParaFormat(AParaStyle: TCustomRVParaInfo);
- procedure ClearTextFormat(ATextStyle: TCustomRVFontInfo; AParaStyle: TCustomRVParaInfo);
- {$IFDEF RICHVIEWCBDEF3}
- function GetOwner: TPersistent; override;
- {$ENDIF}
- property Items[Index: Integer]: TRVStyleTemplate read GetItem write SetItem; default;
- published
- property DefStyleName: String read FDefStyleName write FDefStyleName stored StoreDefStyleName;
- end;
- {$ENDIF}
- { ---------------------------------------------------------------------------
- TRVStyle: component. Contains properties affecting TCustomRichView.
- Assign TCustomRichView.Style to TRVStyle object.
- Properties:
- - TextStyles - collection of text styles, see TFontInfos, TFontInfo
- - ParaStyles - collection of paragraph styles, see TParaInfos, TParaInfo
- - ListStyles - collection of styles of paragraph lists, see TRVListInfos,
- TRVListInfo
- - SpacesInTab - a number of space characters used to replace TAB;
- If zero, TABs will not be replaced but inserted as a special item type.
- - DefTabWidth - default tab width for the document
- - JumpCursor - hypertext cursor for non-text items ("hot-pictures",
- "hotspots")
- - LineSelectCursor - cursor for line selection (when mouse pointer is
- above the left margin of RichView
- - Color - background color, if TCustomRichView.Color = clNone
- - HoverColor - color of hypertext under mouse (if TFontInfo.HoverColor =
- clNone), clNone for no effect.
- - CurrentItemColor - color of border around current image or control in
- editor. clNone for no effect.
- - SelColor - background color of selection, clNone for invisible selection
- (i.s.). Used if TCustomRichView has input focus.
- - SelTextColor - color of selected text, clNone for i.s. Used if
- TCustomRichView has input focus.
- - InactiveSelColor - background color of selection, clNone for i.s. Used if
- TCustomRichView does not have input focus.
- - InactiveSelTextColor - color of selected text, clNone for i.s. Used if
- TCustomRichView does not have input focus.
- - CheckpointColor - color of "checkpoints"; used if rvoShowCheckpoints is
- in TCustomRichView.Options. For "checkpoints" with no "raise-event" flag
- - CheckpointEvColor - the same, but for "checkpoints" with "raise-event"
- flag
- - PageBreakColor - color of explicit page breaks. Used if rvoShowPageBreaks
- is in TCustomRichView.Options.
- - SoftPageBreakColor - the same for "soft" (automatic) page breaks
- - LiveSpellingColor - color of live spelling underline
- - SelectionMode: mode of making selection, see TRVSelectionMode
- - SelectionStyle: visual appearance of selection, see TRVSelectionStyle
- - FullRedraw - (see the help file)
- - UseSound - allows beeping on incorrect operations (such as attempting
- deleting protected text)
- - DefUnicodeStyle - index (in TextStyles) of style that should be used
- for Unicode (if Unicode operation is performed in TCustomRichViewEdit
- but the current style is not Unicode). -1 for no special processing.
- - DefCodePage - code page for ANSI <-> Unicode conversion
- - InvalidPicture - picture to replace invalid/damaged pictures
- Events:
- - OnApplyStyle: TRVApplyStyleEvent - allows to set additional properties
- to Canvas then applying text style (by default font, spacing, bidi-mode
- are set)
- - OnApplyStyleColor: TRVApplyStyleColorEvent - allows to override color
- applied to Canvas's font and brush then applying text style
- - OnDrawStyleText: TRVDrawStyleTextEvent - event for text custom drawing
- - OnStyleHoverSensitive - asks, if the text should be redrawn when mouse
- enters/leaves it; used for custom drawing
- - OnDrawTextBack: TRVDrawTextBackEvent - event for text custom drawing
- (drawing text background)
- - OnDrawCheckpoint: TRVDrawCheckpointEvent - allows to override default
- drawing of "checkpoints"
- - OnDrawPageBreak: TRVDrawPageBreakEvent - allows to override default
- drawing of page breaks
- - OnDrawParaBack: TRVDrawParaRectEvent - custom drawing of paragraph
- background
- }
- TRVStyle = class(TComponent)
- private
- { Private declarations }
- FInvalidPicture: TPicture;
- FColor, FHoverColor, FCurrentItemColor, FSelColor, FSelTextColor,
- FInactiveSelColor, FInactiveSelTextColor,
- FCheckpointColor, FCheckpointEvColor: TColor;
- FJumpCursor: TCursor;
- FTextStyles: TFontInfos;
- FParaStyles: TParaInfos;
- FListStyles: TRVListInfos;
- FFullRedraw: Boolean;
- FSpacesInTab: Integer;
- FDefTabWidth: Integer;
- FPageBreakColor, FSoftPageBreakColor: TColor;
- FLiveSpellingColor: 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;
- FSelectionMode: TRVSelectionMode;
- FSelectionStyle: TRVSelectionStyle;
- FLineSelectCursor: TCursor;
- {$IFNDEF RVDONOTUSESTYLETEMPLATES}
- FStyleTemplates: TRVStyleTemplateCollection;
- {$ENDIF}
- 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);
- {$IFNDEF RVDONOTUSESTYLETEMPLATES}
- procedure SetStyleTemplates(const Value: TRVStyleTemplateCollection);
- {$ENDIF}
- protected
- { Protected declarations }
- procedure ReadState(Reader: TReader);override;
- procedure Notification(AComponent: TComponent;
- Operation: TOperation); override;
- procedure Loaded; 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;
- procedure GetNextTab(ParaNo, X: Integer; sad: TRVScreenAndDevice;
- var Position: Integer; var Leader: String; var Align: TRVTabAlign;
- DefBiDiMode: TRVBiDiMode; LeftIndent, RightIndent: Integer);
- function AddTextStyle: Integer; {$IFDEF RICHVIEWDEF6}deprecated;{$ENDIF}
- procedure DeleteTextStyle(Index: Integer); {$IFDEF RICHVIEWDEF6}deprecated;{$ENDIF}
- {$IFNDEF RVDONOTUSEINI}
- 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}
- {$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; CanUseCustomPPI: Boolean);
- procedure ApplyStyleColor(Canvas: TCanvas; StyleNo: Integer;
- DrawState: TRVTextDrawStates; Printing: Boolean; ColorMode: TRVColorMode);
- procedure DrawStyleText(const s: String; Canvas: TCanvas;
- ItemNo, OffsetInItem, StyleNo: Integer; RVData: TPersistent;
- SpaceBefore, Left, Top, Width, Height: Integer;
- DrawState: TRVTextDrawStates; Printing, PreviewCorrection: Boolean;
- ColorMode: TRVColorMode; DefBiDiMode: TRVBidiMode);
- procedure DrawCheckpoint(Canvas: TCanvas; X,Y, AreaLeft, Width: Integer;
- RVData: TPersistent; 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;
- Printing: Boolean; ColorMode: TRVColorMode);
- function StyleHoverSensitive(StyleNo: Integer): Boolean;
- 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: Integer read FSpacesInTab write FSpacesInTab default 0;
- property DefTabWidth: Integer read FDefTabWidth write FDefTabWidth default 48;
- property JumpCursor: TCursor read FJumpCursor write FJumpCursor default crJump;
- property LineSelectCursor: TCursor read FLineSelectCursor write FLineSelectCursor default crRVFlipArrow;
- 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 CurrentItemColor: TColor read FCurrentItemColor write FCurrentItemColor 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;
- property LiveSpellingColor: TColor read FLiveSpellingColor write FLiveSpellingColor default clRed;
- property SelectionMode: TRVSelectionMode read FSelectionMode write FSelectionMode default rvsmWord;
- property SelectionStyle: TRVSelectionStyle read FSelectionStyle write FSelectionStyle default rvssItems;
- {$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;
- property OnApplyStyleColor: TRVApplyStyleColorEvent read FOnApplyStyleColor write FOnApplyStyleColor;
- property OnDrawStyleText: TRVDrawStyleTextEvent read FOnDrawStyleText write FOnDrawStyleText;
- property OnStyleHoverSensitive: TRVStyleHoverSensitiveEvent read FOnStyleHoverSensitive write FOnStyleHoverSensitive;
- property OnDrawTextBack: TRVDrawTextBackEvent read FOnDrawTextBack write FOnDrawTextBack;
- property OnDrawCheckpoint: TRVDrawCheckpointEvent read FOnDrawCheckpoint write FOnDrawCheckpoint;
- property OnDrawPageBreak: TRVDrawPageBreakEvent read FOnDrawPageBreak write FOnDrawPageBreak;
- property OnDrawParaBack: TRVDrawParaRectEvent read FOnDrawParaBack write FOnDrawParaBack;
- {$IFNDEF RVDONOTUSESTYLETEMPLATES}
- property StyleTemplates: TRVStyleTemplateCollection read FStyleTemplates write SetStyleTemplates;
- {$ENDIF}
- end;
- procedure RVWrite(Stream: TStream; const s: String);
- procedure RVWriteLn(Stream: TStream; const s: String);
- procedure RVWriteX(Stream: TStream; const s: String; Multiline: Boolean);
- const
- { default value for TCustomRichView.RTFOptions }
- rvrtfDefault: TRVRTFOptions =
- [rvrtfDuplicateUnicode, rvrtfSaveEMFAsWMF, rvrtfSaveJpegAsJpeg];
- { all properties of TFontInfo }
- RVAllFontInfoProperties: TRVFontInfoProperties =
- [Low(TRVFontInfoProperty)..High(TRVFontInfoProperty)];
- { all properties of TParaInfo }
- RVAllParaInfoProperties: TRVParaInfoProperties =
- [Low(TRVParaInfoProperty)..High(TRVParaInfoProperty)];
- { ...divided into 2 parts }
- RVAllParaInfoProperties1: TRVParaInfoProperties =
- [Low(TRVParaInfoProperty1)..High(TRVParaInfoProperty1)];
- RVAllParaInfoProperties2: TRVParaInfoProperties =
- [Low(TRVParaInfoProperty2)..High(TRVParaInfoProperty2)];
- { all properties of TRVBackgroundRect }
- RVAllParaBackgroundProperties: TRVParaInfoProperties =
- [rvpiBackground_Color..rvpiBackground_BO_Bottom];
- { all properties of TRVBorder }
- RVAllParaBorderProperties: TRVParaInfoProperties =
- [rvpiBorder_Color..rvpiBorder_Vis_Bottom];
- { If True, Standard properties of styles added from inserted RVF will
- be reset to False. }
- RichViewResetStandardFlag: Boolean = True;
- { If True, 'LstId' pseudo-property will not be saved when storing
- list styles in RVF. This pseudo-property allows smarter inserting RVF
- with lists, but does not allow aplications built with older version of
- TRichView to load new RVFs }
- RVNoLstIDProperty: Boolean = False;
- { If True, FindSuchStyle method take StyleName property into account when
- comparing styles }
- RichViewCompareStyleNames: Boolean = False;
- { Visible special characters }
- RVVisibleSpecialCharacters: TRVSpecialCharacters = [rvscSpace..rvscSoftHyphen];
- implementation
- uses RVUni, RVStr, CRVData, RVItem, RVFuncs, RVFMisc;
- {==============================================================================}
- {$IFNDEF RVDONOTUSEINI}
- const arrNoYes: array [False..True] of String = (RVINIFILENO,RVINIFILEYES);
- { Write integer Value to ini only if it is not equal to DefValue }
- procedure WriteIntToIniIfNE(ini: TRVIniFile; const Section, Key: String;
- Value, DefValue: Integer);
- begin
- if Value<>DefValue then
- ini.WriteInteger(Section, Key, Value);
- end;
- {------------------------------------------------------------------------------}
- { Write boolean Value to ini only if it is not equal to DefValue.
- Value is written as "Yes" or "No" }
- procedure WriteBoolToIniIfNE(ini: TRVIniFile; const Section, Key: String;
- Value, DefValue: Boolean);
- begin
- if Value<>DefValue then
- ini.WriteString(Section, Key, arrNoYes[Value]);
- end;
- {------------------------------------------------------------------------------}
- { Read boolean value ("Yes"/"No" from ini }
- function IniReadBool(ini: TRVIniFile; const Section, Key: String;
- DefValue: Boolean): Boolean;
- begin
- Result := UpperCase(ini.ReadString(Section, Key, arrNoYes[DefValue]))=RVINIFILEYESU;
- end;
- {------------------------------------------------------------------------------}
- { Writing long string to ini. String is splitted on parts by 500 characters.
- String is written in keys Key+'_'+number. Number is 0-based }
- procedure WriteLongStringToINI(ini: TRVIniFile; const Section, Key, Value: String);
- var l,i: Integer;
- s: String;
- begin
- i := 0;
- l := 500;
- while l<Length(Value) do begin
- s := Copy(Value, l-500+1, 500);
- ini.WriteString(Section, Key+'_'+IntToStr(i), s);
- inc(i);
- inc(l,500);
- end;
- s := Copy(Value, l-500+1, Length(Value));
- if s<>'' then
- ini.WriteString(Section, Key+'_'+IntToStr(i), s);
- end;
- {------------------------------------------------------------------------------}
- { Reading strings saved with WriteLongStringToINI }
- function ReadLongStringFromINI(ini: TRVIniFile; const Section, Key: String): String;
- var i: Integer;
- s: String;
- begin
- Result := '';
- i := 0;
- while True do begin
- s := ini.ReadString(Section, Key+'_'+IntToStr(i), '');
- if s='' then
- break;
- Result := Result+s;
- inc(i);
- end;
- end;
- {------------------------------------------------------------------------------}
- { Encoding font styles in string }
- function FontStylesToString(Styles: TFontStyles): String;
- begin
- Result := '';
- if fsBold in Styles then
- Result := Result + 'B';
- if fsItalic in Styles then
- Result := Result + 'I';
- if fsUnderline in Styles then
- Result := Result + 'U';
- if fsStrikeOut in Styles then
- Result := Result + 'S';
- end;
- {------------------------------------------------------------------------------}
- { Decoding string in font styles }
- function StringToFontStyles(const Styles: string): TFontStyles;
- var i: Integer;
- begin
- Result := [];
- for i := 1 to Length(Styles) do
- case Styles[i] of
- 'B','b':
- Include(Result, fsBold);
- 'I','i':
- Include(Result, fsItalic);
- 'U','u':
- Include(Result, fsUnderline);
- 'S','s':
- Include(Result, fsStrikeOut);
- end;
- end;
- {------------------------------------------------------------------------------}
- { Encoding font in string like "Arial,8,BI,0,clWindowText,0" }
- function FontToString(Font: TFont): String;
- begin
- with Font do
- Result := Format('%s,%d,%s,%d,%s,%d', [Name, Height,
- FontStylesToString(Style), Ord(Pitch), ColorToString(Color),
- {$IFDEF RICHVIEWCBDEF3} Charset {$ELSE} 0 {$ENDIF}]);
- end;
- {------------------------------------------------------------------------------}
- { Decoding string created with FontToString }
- procedure StringToFont(const s: string; Font: TFont);
- var
- i,j, State: Integer;
- s2: string;
- begin
- i := 1;
- State := 1;
- while i<=Length(s) do begin
- j := i;
- while (j<=Length(s)) and (s[j]<>',') do
- inc(j);
- if (j<=Length(s)) and (s[j]=',') then begin
- s2 := Copy(s, i, j-i);
- i := j+1;
- end
- else begin
- s2 := Copy(s, i, j-i+1);
- i := j;
- end;
- case State of
- 1: Font.Name := s2;
- 2: Font.Height := StrToInt(s2);
- 3: Font.Style := StringToFontStyles(s2);
- 4: Font.Pitch := TFontPitch(StrToInt(s2));
- 5: Font.Color := StringToColor(s2);
- {$IFDEF RICHVIEWCBDEF3}
- 6: Font.Charset := TFontCharset(StrToInt(s2));
- {$ENDIF}
- end;
- inc(State);
- end;
- end;
- {$ENDIF}
- {------------------------------------------------------------------------------}
- { Are rectangles r1 and r2 equal? }
- function AreRectsEqual(const r1,r2: TRect): Boolean;
- begin
- Result := (r1.Left=r2.Left) and (r1.Top=r2.Top) and
- (r1.Bottom=r2.Bottom) and (r1.Right=r2.Right);
- end;
- {------------------------------------------------------------------------------}
- procedure ScaleRect(var R: TRect; sad: TRVScreenAndDevice);
- begin
- exit;
- R.Left := MulDiv(R.Left, sad.ppixDevice, sad.ppixScreen);
- R.Right := MulDiv(R.Right, sad.ppixDevice, sad.ppixScreen);
- R.Top := MulDiv(R.Top, sad.ppiyDevice, sad.ppiyScreen);
- R.Bottom := MulDiv(R.Bottom, sad.ppiyDevice, sad.ppiyScreen);
- end;
- (*
- {------------------------------------------------------------------------------}
- procedure IniSavePen(ini: TRVIniFile; const Section,Key: String; Pen: TPen;
- DefStyle: TPenStyle; DefColor: TColor);
- begin
- WriteIntToIniIfNE(ini, Section, Key+'Style', ord(Pen.Style), ord(DefStyle));
- WriteIntToIniIfNE(ini, Section, Key+'Color', Pen.Color, DefColor);
- WriteIntToIniIfNE(ini, Section, Key+'Width', Pen.Width, 1);
- WriteIntToIniIfNE(ini, Section, Key+'Mode', ord(Pen.Mode), ord(pmCopy));
- end;
- {------------------------------------------------------------------------------}
- procedure IniLoadPen(ini: TRVIniFile; const Section,Key: String; Pen: TPen;
- DefStyle: TPenStyle; DefColor: TColor);
- begin
- Pen.Style := TPenStyle(ini.ReadInteger(Section, Key+'Style', ord(DefStyle)));
- Pen.Color := ini.ReadInteger(Section, Key+'Color', DefColor);
- Pen.Width := ini.ReadInteger(Section, Key+'Width', 1);
- Pen.Mode := TPenMode(ini.ReadInteger(Section, Key+'Mode', ord(pmCopy)));
- end;
- *)
- {=========================== TCustomRVInfo ====================================}
- { Constructor }
- constructor TCustomRVInfo.Create(Collection: TCollection);
- begin
- inherited Create(Collection);
- FBaseStyleNo := -1;
- FStandard := True;
- {$IFNDEF RVDONOTUSESTYLETEMPLATES}
- FStyleTemplateId := -1;
- {$ENDIF}
- end;
- {------------------------------------------------------------------------------}
- { Assigns properties of Source to Self, if source is TCustomRVInfo }
- procedure TCustomRVInfo.Assign(Source: TPersistent);
- begin
- if Source is TCustomRVInfo then begin
- FName := TCustomRVInfo(Source).FName;
- FBaseStyleNo := TCustomRVInfo(Source).FBaseStyleNo;
- FStandard := TCustomRVInfo(Source).FStandard;
- {$IFNDEF RVDONOTUSESTYLETEMPLATES}
- FStyleTemplateId := TCustomRVInfo(Source).FStyleTemplateId;
- {$ENDIF}
- end
- else
- inherited Assign(Source);
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVInfo.IsSimpleEqual(Value: TCustomRVInfo;
- IgnoreReferences: Boolean; IgnoreID: Boolean{$IFDEF RICHVIEWDEF4}=True{$ENDIF}): Boolean;
- begin
- Result := False;
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVInfo.IsSimpleEqualEx(Value: TCustomRVInfo; Mapping: TRVIntegerList): Boolean;
- begin
- Result := False;
- end;
- {------------------------------------------------------------------------------}
- function TCustomRVInfo.SimilarityValue(Value: TCustomRVInfo): Integer;
- begin
- Result := 0;
- end;
- {------------------------------------------------------------------------------}
- {$IFNDEF RVDONOTUSEINI}
- { Loads properties from the ini-file, from the section Section.
- fs is a format string for keys, it is like 'Font%s1', 'Font%s2', etc.
- DefName is a default style name. }
- procedure TCustomRVInfo.LoadFromINI(ini: TRVIniFile; const Section,
- fs, DefName: String);
- begin
- StyleName := ini.ReadString (Section, Format(fs,[RVINI_STYLENAME]), DefName);
- BaseStyleNo := ini.ReadInteger(Section, Format(fs,[RVINI_BASESTYLENO]), -1);
- Standard := Boolean(ini.ReadInteger(Section, Format(fs,[RVINI_STANDARD]), Integer(True)));
- end;
- {------------------------------------------------------------------------------}
- { Saves properties to the ini-file, in the section Section, using the format
- string fs for keys. }
- procedure TCustomRVInfo.SaveToINI(ini: TRVIniFile; const Section, fs: String);
- begin
- ini.WriteString(Section, Format(fs,[RVINI_STYLENAME]), StyleName);
- WriteIntToIniIfNE(ini, Section, Format(fs,[RVINI_BASESTYLENO]),BaseStyleNo,-1);
- WriteIntToIniIfNE(ini, Section, Format(fs,[RVINI_STANDARD]), Integer(Standard), Integer(True));
- end;
- {$ENDIF}
- {------------------------------------------------------------------------------}
- {$IFDEF RICHVIEWCBDEF3}
- { Returns a name of the collection item, for design-time collection editor. }
- function TCustomRVInfo.GetDisplayName: String;
- begin
- Result := FName;
- end;
- {$ENDIF}
- {============================= TCustomRVInfos =================================}
- { Constructor }
- constructor TCustomRVInfos.Create(ItemClass: TCollectionItemClass;
- Owner: TPersistent);
- begin
- inherited Create(ItemClass);
- FOwner := Owner;
- end;
- {------------------------------------------------------------------------------}
- { Allows assigning properties to TStrings: style names are assigned. }
- procedure TCustomRVInfos.AssignTo(Dest: TPersistent);
- var i: Integer;
- begin
- if Dest is TStrings then begin
- TStrings(Dest).Clear;
- for i:=0 to Count-1 do
- TStrings(Dest).Add(TCustomRVInfo(Items[i]).FName);
- end
- else
- inherited AssignTo(Dest);
- end;
- {------------------------------------------------------------------------------}
- {$IFDEF RICHVIEWCBDEF3}
- { For designtime collection editor. }
- function TCustomRVInfos.GetOwner: TPersistent;
- begin
- Result := FOwner;
- end;
- {$ENDIF}
- {------------------------------------------------------------------------------}
- { Adds items from Styles according to the method specified in the Mode.
- Mapping is filled: on exit, Mapping.Count = Styles.Count, and
- Mapping[i] is an index of the item of this collection which was created basing
- on Styles[i].
- Reference properties (BaseStyleNo, NextStyleNo, NextParaNo, DefStyleNo) are
- adjusted in the added items.
- If the global variable RichViewResetStandardFlag is True (default), Standard
- properties of all added styles are set to False.
- This method assumes that Styles have the same type as Self.
- Notes:
- * in rvs_merge_Map mode:
- - SimilarityValue method of items is used;
- - the method tries to keep Jump and Unicode properties if possible.
- * in rvs_merge_SmartMerge mode:
- - the method tries to map the style to the style with the same index,
- if possible;
- - IsSimpleEqualEx method of items is used;
- - several styles can be mapped in the same style, except for numbered lists:
- they are always mapped to the unique style.
- }
- procedure TCustomRVInfos.MergeWith(Styles: TCustomRVInfos;
- Mode: TRVStyleMergeMode; Mapping: TRVIntegerList;
- TextStyleMapping: TRVIntegerList);
- var i,j,idx,oldcount: Integer;
- Style: TCustomRVInfo;
- wht, maxwht: Integer;
- ForbiddenStyles: TRVIntegerList;
- {.............................................}
- procedure AdjustReferences;
- var i: Integer;
- Style: TCustomRVInfo;
- begin
- for i := oldcount to Count-1 do begin
- Style := TCustomRVInfo(Items[i]);
- if RichViewResetStandardFlag then
- Style.Standard := False;
- if Style.BaseStyleNo>=0 then
- Style.BaseStyleNo := Mapping[Style.BaseStyleNo];
- if (Style is TFontInfo) and (TFontInfo(Style).NextStyleNo>=0) then
- TFontInfo(Style).NextStyleNo := Mapping[TFontInfo(Style).NextStyleNo];
- if (Style is TParaInfo) then begin
- if (TParaInfo(Style).NextParaNo>=0) then
- TParaInfo(Style).NextParaNo := Mapping[TParaInfo(Style).NextParaNo];
- if (TParaInfo(Style).DefStyleNo>=0) and (TextStyleMapping<>nil) then
- TParaInfo(Style).DefStyleNo :=
- TextStyleMapping[TParaInfo(Style).DefStyleNo];
- end;
- end;
- end;
- {.............................................}
- begin
- Mapping.Clear;
- Mapping.Capacity := Styles.Count;
- oldcount := Count;
- case Mode of
- rvs_merge_Append: // Append one collection to another
- for i := 0 to Styles.Count-1 do begin
- Mapping.Add(Count);
- Add.Assign(Styles.Items[i]);
- end;
- rvs_merge_Map: // Use the most similar of existing styles. Do not add styles
- for i := 0 to Styles.Count-1 do begin
- Style := TCustomRVInfo(Styles.Items[i]);
- maxwht := 0;
- idx := -1;
- if (Style is TFontInfo) then begin
- {$IFNDEF RVDONOTUSEUNICODE}
- for j := 0 to Count-1 do
- if (TFontInfo(Items[j]).Jump=TFontInfo(Style).Jump) and
- (TFontInfo(Items[j]).Unicode=TFontInfo(Style).Unicode) then begin
- wht := Style.SimilarityValue(TFontInfo(Items[j]));
- if (idx=-1) or (wht>maxwht) then begin
- maxwht := wht;
- idx := j;
- end;
- end;
- {$ENDIF}
- if idx=-1 then
- for j := 0 to Count-1 do
- if (TCustomRVFontInfo(Items[j]).Jump=TCustomRVFontInfo(Style).Jump) then begin
- wht := Style.SimilarityValue(TCustomRVInfo(Items[j]));
- if (idx=-1) or (wht>maxwht) then begin
- maxwht := wht;
- idx := j;
- end;
- end;
- {$IFNDEF RVDONOTUSEUNICODE}
- if idx=-1 then
- for j := 0 to Count-1 do
- if (TFontInfo(Items[j]).Unicode=TFontInfo(Style).Unicode) then begin
- wht := Style.SimilarityValue(TCustomRVInfo(Items[j]));
- if (idx=-1) or (wht>maxwht) then begin
- maxwht := wht;
- idx := j;
- end;
- end;
- {$ENDIF}
- end;
- if idx=-1 then
- for j := 0 to Count-1 do begin
- wht := Style.SimilarityValue(TCustomRVInfo(Items[j]));
- if (idx=-1) or (wht>maxwht) then begin
- maxwht := wht;
- idx := j;
- end;
- end;
- Mapping.Add(idx);
- end;
- rvs_merge_SmartMerge: // Reuse styles, add if necessary
- begin
- if Self is TRVListInfos then
- ForbiddenStyles := TRVIntegerList.Create
- else
- ForbiddenStyles := nil;
- for i := 0 to Styles.Count-1 do begin
- idx := -1;
- Style := TCustomRVInfo(Styles.Items[i]);
- if (i<Count) and Style.IsSimpleEqualEx(TCustomRVInfo(Items[i]), Mapping) and
- ((ForbiddenStyles=nil) or (ForbiddenStyles.IndexOf(Pointer(i))<0)) then
- idx := i;
- if idx<0 then
- for j := 0 to Count-1 do
- if Style.IsSimpleEqualEx(TCustomRVInfo(Items[j]), Mapping) and
- ((ForbiddenStyles=nil) or (ForbiddenStyles.IndexOf(Pointer(j))<0)) then begin
- idx := j;
- break;
- end;
- if idx<0 then begin
- idx := Count;
- Add.Assign(Styles.Items[i]);
- if Self is TRVListInfos then
- TRVListInfo(Items[idx]).FListID := TRVListInfo(Styles.Items[i]).ListID;
- end;
- Mapping.Add(idx);
- if ForbiddenStyles<>nil then begin
- if TRVListInfo(Style).HasNumbering then
- ForbiddenStyles.Add(idx);
- end;
- end;
- ForbiddenStyles.Free;
- end;
- end;
- AdjustReferences;
- end;
- {=========================== TCustomRVFontInfo ================================}
- { Constructor }
- constructor TCustomRVFontInfo.Create(Collection: TCollection);
- begin
- inherited Create(Collection);
- FFontName := RVDEFAULTSTYLEFONT;
- FSize := 10;
- FColor := clWindowText;
- FBackColor := clNone;
- FHoverBackColor := clNone;
- FHoverColor := clNone;
- FStyle := [];
- FStyleEx := [];
- {$IFDEF RICHVIEWCBDEF3}
- FCharset := DEFAULT_CHARSET;
- {$ENDIF}
- Jump := False;
- JumpCursor := crJump;
- FName := RVDEFAULTTEXTSTYLENAME;
- FVShift := 0;
- FCharScale := 100;
- end;
- {------------------------------------------------------------------------------}
- { Assigns properties of Source to Self, if it is TCustomRVFontInfo or TFont. }
- procedure TCustomRVFontInfo.Assign(Source: TPersistent);
- begin
- if Source is TCustomRVFontInfo then begin
- FFontName := TCustomRVFontInfo(Source).FFontName;
- FSize := TCustomRVFontInfo(Source).FSize;
- FColor := TCustomRVFontInfo(Source).FColor;
- FBackColor := TCustomRVFontInfo(Source).FBackColor;
- FHoverBackColor := TCustomRVFontInfo(Source).FHoverBackColor;
- FHoverColor := TCustomRVFontInfo(Source).FHoverColor;
- FStyle := TCustomRVFontInfo(Source).FStyle;
- FStyleEx := TCustomRVFontInfo(Source).FStyleEx;
- {$IFDEF RICHVIEWCBDEF3}
- FCharset := TCustomRVFontInfo(Source).FCharset;
- {$ENDIF}
- {$IFDEF RVLANGUAGEPROPERTY}
- FLanguage := TCustomRVFontInfo(Source).FLanguage;
- {$ENDIF}
- FJump := TCustomRVFontInfo(Source).FJump;
- FJumpCursor := TCustomRVFontInfo(Source).FJumpCursor;
- FProtection := TCustomRVFontInfo(Source).FProtection;
- FOptions := TCustomRVFontInfo(Source).FOptions;
- FVShift := TCustomRVFontInfo(Source).FVShift;
- FCharScale := TCustomRVFontInfo(Source).FCharScale;
- FCharSpacing := TCustomRVFontInfo(Source).FCharSpacing;
- FBiDiMode := TCustomRVFontInfo(Source).FBiDiMode;
- {$IFDEF RVTEXTFOOTNOTES}
- FFootNote := TCustomRVFontInfo(Source).FFootNote;
- {$ENDIF}
- inherited Assign(Source);
- end
- else if Source is TFont then begin
- FFontName := TFont(Source).Name;
- FSize := TFont(Source).Size;
- FColor := TFont(Source).Color;
- FStyle := TFont(Source).Style;
- {$IFDEF RICHVIEWCBDEF3}
- FCharset := TFont(Source).Charset;
- {$ENDIF}
- end
- else
- inherited Assign(Source);
- end;
- {------------------------------------------------------------------------------}
- { Allows assigning properties to TFont. }
- procedure TCustomRVFontInfo.AssignTo(Dest: TPersistent);
- begin
- if Dest is TFont then begin
- TFont(Dest).Name := FFontName;
- TFont(Dest).Size := FSize;
- TFont(Dest).Color := FColor;
- TFont(Dest).Style := FStyle;
- {$IFDEF RICHVIEWCBDEF3}
- TFont(Dest).Charset := FCharset;
- {$ENDIF}
- end
- else
- inherited AssignTo(Dest);
- end;
- {------------------------------------------------------------------------------}
- { Assigns properties listed in Props to Self. }
- procedure TCustomRVFontInfo.AssignSelectedProperties(
- Source: TCustomRVFontInfo; Props: TRVFontInfoProperties);
- {.............................................................}
- procedure ChangeFontStyle(FontStyle: TFontStyle; TextPropId: TRVFontInfoProperty);
- begin
- if TextPropId in Props then
- if FontStyle in Source.Style then
- Style := Style+[FontStyle]
- else
- Style := Style-[FontStyle];
- end;
- {.............................................................}
- procedure ChangeFontStyleEx(FontStyle: TRVFontStyle; TextPropId: TRVFontInfoProperty);
- begin
- if TextPropId in Props then
- if FontStyle in Source.StyleEx then
- StyleEx := StyleEx+[FontStyle]
- else
- StyleEx := StyleEx-[FontStyle];
- end;
- {.............................................................}
- procedure ChangeTextOption(TextOption: TRVTextOption; TextOptionId: TRVFontInfoProperty);
- begin
- if TextOptionId in Props then
- if TextOption in Source.Options then
- Options := Options+[TextOption]
- else
- Options := Options-[TextOption];
- end;
- {.............................................................}
- begin
- if (rvfiFontName in Props) then
- FontName := Source.FontName;
- if (rvfiSize in Props) then
- Size := Source.Size;
- {$IFDEF RICHVIEWCBDEF3}
- if (rvfiCharset in Props) then
- Charset := Source.Charset;
- {$ENDIF}
- ChangeFontStyle(fsBold, rvfiBold);
- ChangeFontStyle(fsItalic, rvfiItalic);
- ChangeFontStyle(fsUnderline, rvfiUnderline);
- ChangeFontStyle(fsStrikeOut, rvfiStrikeOut);
- ChangeFontStyleEx(rvfsOverline, rvfiOverline);
- ChangeFontStyleEx(rvfsAllCaps, rvfiAllCaps);
- if (rvfiVShift in Props) then
- VShift := Source.VShift;
- if (rvfiColor in Props) then
- Color := Source.Color;
- if (rvfiBackColor in Props) then
- BackColor := Source.BackColor;
- if (rvfiJump in Props) then
- Jump := Source.Jump;
- if (rvfiHoverBackColor in Props) then
- HoverBackColor := Source.HoverBackColor;
- if (rvfiHoverColor in Props) then
- HoverColor := Source.HoverColor;
- if (rvfiJumpCursor in Props) then
- JumpCursor := Source.JumpCursor;
- if (rvfiProtection in Props) then
- Protection := Source.Protection;
- if (rvfiCharScale in Props) then
- CharScale := Source.CharScale;
- if (rvfiBiDiMode in Props) then
- BiDiMode := Source.BiDiMode;
- if (rvfiCharSpacing in Props) then
- CharSpacing := Source.CharSpacing;
- ChangeTextOption(rvteoHTMLCode, rvfiHTMLCode);
- ChangeTextOption(rvteoRTFCode, rvfiRTFCode);
- {$IFDEF RVLANGUAGEPROPERTY}
- if (rvfiLanguage in Props) then
- Language := Source.Language;
- {$ENDIF}
- { rvfiBaseStyleNo, rvfiNextStyleNo - not assigned }
- {$IFDEF RVTEXTFOOTNOTES}
- { rvfiFootnotes ??? }
- {$ENDIF}
- { rvfiUnicode ??? }
- end;
- {------------------------------------------------------------------------------}
- { Assigns properties to TLogFont record. If CanUseCustomPPI and
- TextStyles.PixelsPerInch is nonzero, it is used instead of
- Canvas.Font.PixelsPerInch }
- procedure TCustomRVFontInfo.AssignToLogFont(var LogFont: TLogFont; Canvas: TCanvas;
- CanUseCustomPPI: Boolean);
- var ppi: Integer;
- begin
- FillChar(LogFont, sizeof(LogFont), 0);
- with LogFont do begin
- ppi := 0;
- if CanUseCustomPPI and (Collection<>nil) then
- ppi := TFontInfos(Collection).PixelsPerInch;
- if ppi=0 then
- ppi := Canvas.Font.PixelsPerInch;
- lfHeight := -MulDiv(Size, ppi, 72);
- if fsBold in Style then
- lfWeight := FW_BOLD
- else
- lfWeight := FW_NORMAL;
- lfItalic := Byte(fsItalic in Style);
- lfUnderline := Byte(fsUnderline in Style);
- lfStrikeOut := Byte(fsStrikeOut in Style);
- {$IFDEF RICHVIEWCBDEF3}
- lfCharSet := Byte(Charset);
- {$ENDIF}
- StrPCopy(lfFaceName, FontName);
- lfQuality := DEFAULT_QUALITY;
- lfOutPrecision := OUT_DEFAULT_PRECIS;
- lfClipPrecision := CLIP_DEFAULT_PRECIS;
- lfPitchAndFamily := DEFAULT_PITCH;
- end;
- end;
- {------------------------------------------------------------------------------}
- { Is this item equal to Value (all properties are equal)?
- if IgnoreReferences=True, NextStyleNo property is ignored, otherwise they
- must be equal.
- IgnoreID is not used (used only in TRVListInfo). }
- function TCustomRVFontInfo.IsSimpleEqual(Value: TCustomRVInfo;
- IgnoreReferences, IgnoreID: Boolean): Boolean;
- begin
- Result := (Size = TCustomRVFontInfo(Value).Size ) and
- {$IFDEF RICHVIEWCBDEF3}
- (Charset = TCustomRVFontInfo(Value).Charset) and
- {$ENDIF}
- (Style = TCustomRVFontInfo(Value).Style ) and
- (StyleEx = TCustomRVFontInfo(Value).StyleEx) and
- (AnsiCompareText(FontName, TCustomRVFontInfo(Value).FontName)=0) and
- (VShift = TCustomRVFontInfo(Value).VShift ) and
- (Color = TCustomRVFontInfo(Value).Color ) and
- (BackColor = TCustomRVFontInfo(Value).BackColor) and
- (Jump = TCustomRVFontInfo(Value).Jump ) and
- {$IFDEF RVLANGUAGEPROPERTY}
- (Language = TCustomRVFontInfo(Value).Language) and
- {$ENDIF}
- (not Jump or
- ((HoverColor = TCustomRVFontInfo(Value).HoverColor ) and
- (HoverBackColor = TCustomRVFontInfo(Value).HoverBackColor) and
- (JumpCursor = TCustomRVFontInfo(Value).JumpCursor ))
- ) and
- (Protection = TCustomRVFontInfo(Value).Protection ) and
- (Options = TCustomRVFontInfo(Value).Options ) and
- (CharScale = TCustomRVFontInfo(Value).CharScale ) and
- (CharSpacing = TCustomRVFontInfo(Value).CharSpacing) and
- (BiDiMode = TCustomRVFontInfo(Value).BiDiMode ) and
- (not RichViewCompareStyleNames or (StyleName=TCustomRVFontInfo(Value).StyleName));
- end;
- {------------------------------------------------------------------------------}
- { Calculates a similarity value between Self and Value.
- The larger value means more similar. }
- function TCustomRVFontInfo.SimilarityValue(Value: TCustomRVInfo): Integer;
- var fs: TFontStyle;
- begin
- Result :=
- RV_CompareInts(TCustomRVFontInfo(Value).Size, Size, RVSMW_FONTSIZE)+
- RV_CompareInts(TCustomRVFontInfo(Value).VShift, VShift, RVSMW_VSHIFTRATIO)+
- RV_CompareInts(TCustomRVFontInfo(Value).CharScale, CharScale, RVSMW_CHARSCALE)+
- RV_CompareInts(TCustomRVFontInfo(Value).CharSpacing, CharSpacing, RVSMW_CHARSPACING)+
- RV_CompareColors(TCustomRVFontInfo(Value).Color, Color, RVSMW_EACHRGBCOLOR, RVSMW_COLORSET)+
- RV_CompareColors(TCustomRVFontInfo(Value).BackColor, BackColor, RVSMW_EACHRGBBCOLOR, RVSMW_BCOLORSET);
- if TCustomRVFontInfo(Value).BiDiMode=BiDiMode then
- inc(Result, RVSMW_BIDIMODE);
- if AnsiCompareText(TCustomRVFontInfo(Value).FontName, FontName)=0 then
- inc(Result, RVSMW_FONTNAME);
- for fs := Low(TFontStyle) to High(TFontStyle) do
- if (fs in TCustomRVFontInfo(Value).Style) = (fs in Style) then
- inc(Result, RVSMW_FONTEACHSTYLE);
- if (rvfsOverline in TCustomRVFontInfo(Value).StyleEx)=(rvfsOverline in StyleEx) then
- inc(Result, RVSMW_OVERLINE);
- if (rvfsAllCaps in TCustomRVFontInfo(Value).StyleEx)=(rvfsAllCaps in StyleEx) then
- inc(Result, RVSMW_OVERLINE);
- if ((TCustomRVFontInfo(Value).Style=[]) and (TCustomRVFontInfo(Value).StyleEx=[]))
- =
- ((Style=[]) and (StyleEx=[])) then
- inc(Result, RVSMW_FONTSTYLESET);
- {$IFDEF RVLANGUAGEPROPERTY}
- if TCustomRVFontInfo(Value).Language = Language then
- inc(Result, RVSMW_LANGUAGE);
- {$ENDIF}
- if Jump and TCustomRVFontInfo(Value).Jump then begin
- if TCustomRVFontInfo(Value).JumpCursor=JumpCursor then
- inc(Result, RVSMW_CURSOR);
- inc(Result,
- RV_CompareColors(TCustomRVFontInfo(Value).HoverColor,HoverColor, RVSMW_EACHRGBCOLOR, RVSMW_COLORSET) div 2+
- RV_CompareColors(TCustomRVFontInfo(Value).HoverBackColor,HoverBackColor, RVSMW_EACHRGBBCOLOR, RVSMW_BCOLORSET) div 2);
- end;
- if TCustomRVFontInfo(Value).Protection<>Protection then
- dec(Result, RVSMW_PROTECTION);
- if (rvteoHTMLCode in TCustomRVFontInfo(Value).Options)=(rvteoHTMLCode in Options) then
- inc(Result, RVSMW_SPECIALCODE);
- if (rvteoRTFCode in TCustomRVFontInfo(Value).Options)=(rvteoRTFCode in Options) then
- inc(Result, RVSMW_SPECIALCODE);
- {$IFDEF RICHVIEWCBDEF3}
- if Charset=TCustomRVFontInfo(Value).Charset then
- inc(Result, RVSMW_FONTCHARSET)
- else
- if (Charset=DEFAULT_CHARSET) or
- (TCustomRVFontInfo(Value).Charset=DEFAULT_CHARSET) then
- inc(Result, RVSMW_FONTCHARSET div 4);
- {$ENDIF}
- end;
- {------------------------------------------------------------------------------}
- { Is this item equal to Value?
- Equality is determined by comparing all properties NOT included in IgnoreList. }
- function TCustomRVFontInfo.IsEqual(Value: TCustomRVFontInfo; IgnoreList: TRVFontInfoProperties): Boolean;
- begin
- Result := ((rvfiSize in IgnoreList) or (Size = Value.Size )) and
- {$IFDEF RICHVIEWCBDEF3}
- ((rvfiCharset in IgnoreList) or (Charset = Value.Charset )) and
- {$ENDIF}
- ((rvfiBold in IgnoreList) or ((fsBold in Style) = (fsBold in Value.Style ))) and
- ((rvfiItalic in IgnoreList) or ((fsItalic in Style) = (fsItalic in Value.Style ))) and
- ((rvfiUnderline in IgnoreList) or ((fsUnderline in Style) = (fsUnderline in Value.Style ))) and
- ((rvfiStrikeout in IgnoreList) or ((fsStrikeout in Style) = (fsStrikeout in Value.Style ))) and
- ((rvfiOverline in IgnoreList) or ((rvfsOverline in StyleEx) = (rvfsOverline in Value.StyleEx))) and
- ((rvfiAllCaps in IgnoreList) or ((rvfsAllCaps in StyleEx) = (rvfsAllCaps in Value.StyleEx))) and
- ((rvfiFontName in IgnoreList) or (AnsiCompareText(FontName,Value.FontName)=0)) and
- ((rvfiVShift in IgnoreList) or (VShift = Value.VShift )) and
- ((rvfiColor in IgnoreList) or (Color = Value.Color )) and
- ((rvfiBackColor in IgnoreList) or (BackColor = Value.BackColor )) and
- ((rvfiJump in IgnoreList) or (Jump = Value.Jump )) and
- {$IFDEF RVLANGUAGEPROPERTY}
- ((rvfiLanguage in IgnoreList) or (Language = Value.Language )) and
- {$ENDIF}
- (not Jump or
- ((rvfiHoverColor in IgnoreList) or (HoverColor = Value.HoverColor )) and
- ((rvfiHoverBackColor in IgnoreList) or (HoverBackColor = Value.HoverBackColor)) and
- ((rvfiJumpCursor in IgnoreList) or (JumpCursor = Value.JumpCursor))
- ) and
- ((rvfiProtection in IgnoreList) or (Protection = Value.Protection)) and
- ((rvfiRTFCode in IgnoreList) or ((rvteoRTFCode in Options) = (rvteoRTFCode in Value.Options))) and
- ((rvfiHTMLCode in IgnoreList) or ((rvteoHTMLCode in Options) = (rvteoHTMLCode in Value.Options))) and
- ((rvfiCharScale in IgnoreList) or (CharScale = Value.CharScale)) and
- ((rvfiCharSpacing in IgnoreList) or (CharSpacing = Value.CharSpacing)) and
- ((rvfiBiDiMode in IgnoreList) or (BiDiMode = Value.BiDiMode)) and
- ((rvfiBaseStyleNo in IgnoreList) or (BaseStyleNo = Value.BaseStyleNo));
- if Result and RichViewCompareStyleNames then
- Result := StyleName=Value.StyleName;
- end;
- {------------------------------------------------------------------------------}
- { Applies this text style to the Canvas. Colors are not applied, see ApplyColor.
- DefBiDiMode is a bi-di mode of paragraph containing text item of this style.
- Notes:
- - if FCharScale=100, this method assigns Canvas.Font properties,
- otherwise it assigns Canvas.Font.Handle.
- - if CanUseCustomPPI and owning collection is defined and has nonzero
- PixelsPerInch property, font size is assigned according to this PixelsPerInch.
- }
- procedure TCustomRVFontInfo.Apply(Canvas: TCanvas; DefBiDiMode: TRVBiDiMode;
- CanUseCustomPPI: Boolean);
- var LogFont: TLogFont;
- ppi, h: Integer;
- tm: TTextMetric;
- Font: TFont;
- begin
- {$IFNDEF RVDONOTUSECHARSCALE}
- if FCharScale=100 then begin
- {$ENDIF}
- Font := Canvas.Font;
- {$IFDEF RVDONOTUSECHARSCALE}
- if Font.Style<>Style then
- {$ENDIF}
- Font.Style := Style;
- ppi := 0;
- if CanUseCustomPPI and (Collection<>nil) then
- ppi := TFontInfos(Collection).PixelsPerInch;
- if ppi=0 then begin
- if Font.Size<>Size then
- Font.Size := Size
- end
- else begin
- h := - MulDiv(Size, ppi, 72);
- if Font.Height<>h then
- Font.Height := h;
- end;
- if AnsiCompareText(Font.Name,FontName)<>0 then
- Font.Name := FontName;
- {$IFDEF RICHVIEWCBDEF3}
- if Font.CharSet<>CharSet then
- Font.CharSet := CharSet;
- {$ENDIF}
- {$IFNDEF RVDONOTUSECHARSCALE}
- end
- else begin
- AssignToLogFont(LogFont, Canvas, CanUseCustomPPI);
- Canvas.Font.Handle := CreateFontIndirect(LogFont);
- if GetTextMetrics(Canvas.Handle, tm) then
- LogFont.lfWidth := tm.tmAveCharWidth*FCharScale div 100
- else
- LogFont.lfWidth := Canvas.TextWidth('x')*FCharScale div 100;
- Canvas.Font.Handle := CreateFontIndirect(LogFont);
- end;
- {$ENDIF}
- if BiDiMode<>rvbdUnspecified then
- DefBiDiMode := BiDiMode;
- case DefBiDiMode of
- rvbdLeftToRight:
- begin
- {$IFNDEF RVDONOTUSECHARSPACING}
- SetTextCharacterExtra(Canvas.Handle, 0);
- {$ENDIF}
- SetTextAlign(Canvas.Handle, TA_LEFT);
- end;
- rvbdRightToLeft:
- begin
- {$IFNDEF RVDONOTUSECHARSPACING}
- SetTextCharacterExtra(Canvas.Handle, 0);
- {$ENDIF}
- SetTextAlign(Canvas.Handle, TA_RTLREADING);
- end;
- else begin
- {$IFNDEF RVDONOTUSECHARSPACING}
- SetTextCharacterExtra(Canvas.Handle, FCharSpacing);
- {$ENDIF}
- end;
- end;
- end;
- {------------------------------------------------------------------------------}
- { Applies BiDiMode and CharSpacing to Canvas }
- procedure TCustomRVFontInfo.ApplyBiDiMode(Canvas: TCanvas; DefBiDiMode: TRVBiDiMode);
- begin
- if BiDiMode<>rvbdUnspecified then
- DefBiDiMode := BiDiMode;
- case DefBiDiMode of
- rvbdLeftToRight:
- begin
- {$IFNDEF RVDONOTUSECHARSPACING}
- SetTextCharacterExtra(Canvas.Handle, 0);
- {$ENDIF}
- SetTextAlign(Canvas.Handle, TA_LEFT);
- end;
- rvbdRightToLeft:
- begin
- {$IFNDEF RVDONOTUSECHARSPACING}
- SetTextCharacterExtra(Canvas.Handle, 0);
- {$ENDIF}
- SetTextAlign(Canvas.Handle, TA_RTLREADING);
- end;
- else begin
- {$IFNDEF RVDONOTUSECHARSPACING}
- SetTextCharacterExtra(Canvas.Handle, FCharSpacing);
- {$ENDIF}
- end;
- end;
- end;
- {------------------------------------------------------------------------------}
- { Applies color properties of this style to the Canvas.
- Colors depend on values in DrawState (specifically: rvtsSelected, rvtsHover,
- rvtsControlFocused).
- ColorMode is used to adjust colors. }
- procedure TCustomRVFontInfo.ApplyColor(Canvas: TCanvas; RVStyle: TRVStyle;
- DrawState: TRVTextDrawStates; Printing: Boolean; ColorMode: TRVColorMode);
- begin
- if rvtsSelected in DrawState then begin
- Canvas.Brush.Style := bsSolid;
- if rvtsControlFocused in DrawState then
- Canvas.Brush.Color := RVStyle.SelColor
- else
- Canvas.Brush.Color := RVStyle.InactiveSelColor;
- {$IFDEF RVUSETEXTHOVERCOLORWITHSELECTED}
- if rvtsHover in DrawState then begin
- Canvas.Font.Color := RVStyle.GetHoverColorByColor(HoverColor);
- if Canvas.Font.Color=clNone then
- Canvas.Font.Color := Color;
- end
- else
- {$ENDIF}
- if rvtsControlFocused in DrawState then
- Canvas.Font.Color := RVStyle.SelTextColor
- else
- Canvas.Font.Color := RVStyle.InactiveSelTextColor;
- if Canvas.Font.Color=clNone then
- Canvas.Font.Color := Color;
- end
- else begin
- if rvtsHover in DrawState then begin
- Canvas.Font.Color := RVStyle.GetHoverColorByColor(HoverColor);
- if Canvas.Font.Color=clNone then
- Canvas.Font.Color := Color;
- Canvas.Brush.Color := HoverBackColor;
- end
- else if not Printing then begin
- Canvas.Font.Color := Color;
- Canvas.Brush.Color := BackColor;
- end
- else
- case ColorMode of
- rvcmColor:
- begin
- Canvas.Font.Color := Color;
- Canvas.Brush.Color := BackColor;
- end;
- rvcmPrinterColor:
- begin
- Canvas.Font.Color := RV_GetPrnColor(Color);
- Canvas.Brush.Color := RV_GetPrnColor(BackColor);
- end;
- rvcmGrayScale:
- begin
- Canvas.Font.Color := RV_GetGray(RV_GetPrnColor(Color));
- Canvas.Brush.Color := RV_GetGray(RV_GetPrnColor(BackColor));
- end;
- rvcmBlackAndWhite:
- begin
- if BackColor=clNone then begin
- Canvas.Brush.Color := clNone;
- if RV_GetPrnColor(Color)<>clWhite then
- Canvas.Font.Color := clBlack