⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rvstyle.pas

📁 richview1.7 full.source
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    {$ENDIF}
    {$IFNDEF RVDONOTUSEUNICODE}
    FUnicode: Boolean;
    {$ENDIF}
    FProtection: TRVProtectOptions;
    FOptions: TRVTextOptions;
    FCharScale, FCharSpacing: Integer;
    procedure SingleSymbolsReader(reader: TReader);
  protected
    procedure DefineProperties(Filer: TFiler);override;
    function IsSimpleEqual(Value: TCustomRVInfo; IgnoreReferences: Boolean): Boolean; override;
    function IsSimpleEqualEx(Value: TCustomRVInfo; Mapping: TRVIntegerList): 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 AssignToLogFont(var LogFont: TLogFont; Canvas: TCanvas);
    procedure Apply(Canvas: TCanvas; DefBiDiMode: TRVBiDiMode);
    procedure ApplyColor(Canvas: TCanvas;
                                 RVStyle: TRVStyle;
                                 DrawState: TRVTextDrawStates);
    procedure Draw(const s: String; Canvas: TCanvas;
                   ThisStyleNo: Integer;
                   SpaceBefore, Left, Top, Width, Height: Integer;
                   RVStyle: TRVStyle;
                   DrawState: TRVTextDrawStates;
                   Printing: Boolean);
    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);
    function IsEqual(Value: TFontInfo; IgnoreList: TRVFontInfoProperties): Boolean;
    procedure SaveToINI(ini: TRVIniFile; const Section, fs: String);
    procedure LoadFromINI(ini: TRVIniFile; const Section, fs: String;
                          JumpByDefault: Boolean; DefJumpCursor: TCursor);
   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 NextStyleNo: Integer   read FNextStyleNo write FNextStyleNo default -1;
    property BiDiMode: TRVBiDiMode  read FBiDiMode   write FBiDiMode   default rvbdUnspecified;
    {$IFNDEF RVDONOTUSEUNICODE}
    property Unicode: Boolean       read FUnicode    write FUnicode    default False;
    {$ENDIF}
    {$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 [];
  end;


{-----------------------------------------------------------------------}
 TCustomRVInfos = class (TCollection)
    private
      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);
 end;
{-----------------------------------------------------------------------}
 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}
      procedure SaveToINI(ini: TRVIniFile; const Section: String);
      procedure LoadFromINI(ini: TRVIniFile; const Section: String;
                          DefJumpCursor: TCursor);
      property Items[Index: Integer]: TFontInfo
                read GetItem write SetItem; default;
      property InvalidItem: TFontInfo read GetInvalidItem write SetInvalidItem;
  end;

{-----------------------------------------------------------------------}
  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 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;
      procedure SaveToINI(ini: TRVIniFile; const Section, fs: String);
      procedure LoadFromINI(ini: TRVIniFile; const Section, fs: String);
    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 = 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;
      function IsEqual(Value: TRVBooleanRect): Boolean;
      function IsEqual2(ALeft, ATop, ARight, ABottom: Boolean): Boolean;
      function IsAllEqual(Value: Boolean): Boolean;
      procedure SaveToINI(ini: TRVIniFile; const Section, fs: String);
      procedure LoadFromINI(ini: TRVIniFile; const Section, fs: String);
    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;
{-----------------------------------------------------------------------}
  TRVBorderStyle = (rvbNone, rvbSingle, rvbDouble, rvbTriple,
                    rvbThickInside, rvbThickOutside);
  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);
    public
      constructor Create;
      destructor Destroy; override;
      procedure Draw(Rect: TRect; Canvas: TCanvas);
      procedure DrawSaD(Rect: TRect; Canvas: TCanvas; const sad: TRVScreenAndDevice);
      procedure Assign(Source: TPersistent); override;
      function IsEqual(Value: TRVBorder): Boolean;
      function IsEqual_Para(Value: TRVBorder; IgnoreList: TRVParaInfoProperties): Boolean;
      procedure SaveToINI(ini: TRVIniFile; const Section, fs: String);
      procedure LoadFromINI(ini: TRVIniFile; const Section, fs: String);
      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 = 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);
      function IsEqual(Value: TRVBackgroundRect): Boolean;
      function IsEqual_Para(Value: TRVBackgroundRect; IgnoreList: TRVParaInfoProperties): Boolean;
      procedure SaveToINI(ini: TRVIniFile; const Section, fs: String);
      procedure LoadFromINI(ini: TRVIniFile; const Section, fs: String);
    published
      property Color: TColor read FColor write FColor default clNone;
      property BorderOffsets: TRVRect read FBorderOffsets write SetBorderOffsets;
  end;
{-----------------------------------------------------------------------}
  TParaInfo = class (TCustomRVInfo)
    private
      FFirstIndent: Integer;
      FLeftIndent: Integer;
      FRightIndent: Integer;
      FSpaceBefore: Integer;
      FSpaceAfter: Integer;
      FLineSpacing: Integer;
      FLineSpacingType: TRVLineSpacingType;
      FAlignment: TRVAlignment;
      FBorder: TRVBorder;
      FNextParaNo: Integer;
      FBackground: TRVBackgroundRect;
      FOptions: TRVParaOptions;
      FBiDiMode: TRVBiDiMode;
      procedure SetBorder(const Value: TRVBorder);
      procedure SetBackground(const Value: TRVBackgroundRect);
      function ExtraLineSpacing: Boolean;
    protected
      function IsSimpleEqual(Value: TCustomRVInfo; IgnoreReferences: Boolean): Boolean; override;
      function IsSimpleEqualEx(Value: TCustomRVInfo; Mapping: TRVIntegerList): Boolean; override;      
      function SimilarityValue(Value: TCustomRVInfo): Integer; override;
    public
      constructor Create(Collection: TCollection); override;
      destructor Destroy; override;
      procedure Assign(Source: TPersistent); override;
      procedure SaveToINI(ini: TRVIniFile; const Section, fs: String);
      procedure LoadFromINI(ini: TRVIniFile; const Section, fs: String);
      function IsEqual(Value: TParaInfo; IgnoreList: TRVParaInfoProperties): 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 NextParaNo: Integer        read FNextParaNo  write FNextParaNo default -1;
      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;
      property BiDiMode: TRVBiDiMode      read FBiDiMode    write FBidiMode default rvbdUnspecified;
  end;
{-----------------------------------------------------------------------}
  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;
      procedure SaveToINI(ini: TRVIniFile; const Section: String);
      procedure LoadFromINI(ini: TRVIniFile; const Section: String);
      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;
{-----------------------------------------------------------------------}
  TRVListType = (rvlstBullet, rvlstPicture, rvlstImageList,
                 rvlstDecimal, rvlstLowerAlpha, rvlstUpperAlpha,
                 rvlstLowerRoman, rvlstUpperRoman, rvlstImageListCounter
                 {$IFNDEF RVDONOTUSEUNICODE}
                 ,rvlstUnicodeBullet

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -