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

📄 richviewactions.pas

📁 richviewaction 1.58 需要richview 1.9.46
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    procedure SetActionReplace(const Value: TrvActionReplace);
    function GetActionReplace: TrvActionReplace;
  protected
    procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  public
    constructor Create(AOwner: TComponent); override;
    procedure UpdateTarget(Target: TObject); override;
    procedure ExecuteTarget(Target: TObject); override;
    procedure CloseDialog;
    destructor Destroy; override;
  published
    property ActionReplace: TrvActionReplace read FActionReplace write SetActionReplace;
  end;

  TrvActionFindNext = class(TrvAction)
  private
    FActionFind: TrvActionFind;
    procedure SetActionFind(const Value: TrvActionFind);
    function GetActionFind: TrvActionFind;
  protected
    procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  public
    constructor Create(AOwner: TComponent); override;
    procedure ExecuteTarget(Target: TObject); override;
  published
    property ActionFind: TrvActionFind read FActionFind write SetActionFind;
  end;

  TRVAReplacingEvent = procedure (Sender: TObject; Editor: TCustomRichViewEdit;
    const NewText: String) of object;


  TrvActionReplace = class(TrvAction)
  private
    FEdit: TCustomRichViewEdit;
    FReplaceDialog: TRVABasicReplaceDialog;
    FShowReplaceAllSummary: Boolean;
    FActionFind: TrvActionFind;
    FOnReplacing: TRVAReplacingEvent;
    FOnReplaceAllEnd: TRVAEditEvent;
    FOnReplaceAllStart: TRVAEditEvent;
    procedure ReplaceDialogFind(Sender: TObject);
    procedure ReplaceDialogReplace(Sender: TObject);
    procedure SetActionFind(const Value: TrvActionFind);
    function GetActionFind: TrvActionFind;
    procedure DoReplacing(Editor: TCustomRichViewEdit;
      const NewText: String);
  protected
    procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    procedure UpdateTarget(Target: TObject); override;
    procedure ExecuteTarget(Target: TObject); override;
    procedure CloseDialog;
  published
    property ShowReplaceAllSummary: Boolean read FShowReplaceAllSummary write FShowReplaceAllSummary default True;
    property ActionFind: TrvActionFind read FActionFind write SetActionFind;
    property OnReplacing: TRVAReplacingEvent read FOnReplacing write FOnReplacing;
    property OnReplaceAllStart: TRVAEditEvent read FOnReplaceAllStart write FOnReplaceAllStart;
    property OnReplaceAllEnd: TRVAEditEvent read FOnReplaceAllEnd write FOnReplaceAllEnd;
  end;

  { ------------------ Edit ------------------------- }

  TrvCustomEditAction = class(TrvAction)
  protected
    function IsDifferentEditor(Target: TObject): Boolean;
  public
    function HandlesTarget(Target: TObject): Boolean; override;
    procedure UpdateTarget(Target: TObject); override;
  end;

  TrvActionUndo = class(TrvCustomEditAction)
  public
    constructor Create(AOwner: TComponent); override;
    procedure ExecuteTarget(Target: TObject); override;
    procedure UpdateTarget(Target: TObject); override;
  end;

  TrvActionRedo = class(TrvAction)
  public
    constructor Create(AOwner: TComponent); override;
    procedure ExecuteTarget(Target: TObject); override;
    procedure UpdateTarget(Target: TObject); override;
  end;

  TrvActionCut = class(TrvCustomEditAction)
  public
    constructor Create(AOwner: TComponent); override;
    procedure ExecuteTarget(Target: TObject); override;
  end;

  TrvActionCopy = class(TrvCustomEditAction)
  public
    constructor Create(AOwner: TComponent); override;
    procedure ExecuteTarget(Target: TObject); override;
  end;

  TrvActionPaste = class(TrvCustomEditAction)
  private
    {$IFDEF USERVHTML}
    function AllowPasteHTML: Boolean;
    {$ENDIF}
  public
    constructor Create(AOwner: TComponent); override;
    procedure ExecuteTarget(Target: TObject); override;
    procedure UpdateTarget(Target: TObject); override;
  end;

  TrvActionPasteSpecial = class(TrvActionPaste)
  public
    constructor Create(AOwner: TComponent); override;
    procedure ExecuteTarget(Target: TObject); override;
  end;

  TrvActionSelectAll = class(TrvAction)
  public
    constructor Create(AOwner: TComponent); override;
    procedure ExecuteTarget(Target: TObject); override;
  end;

  TrvActionCharCase = class(TrvAction)
  public
    constructor Create(AOwner: TComponent); override;
    procedure ExecuteTarget(Target: TObject); override;
    procedure UpdateTarget(Target: TObject); override;    
  end;

  { ------------------ Basic Color Action  ------------------------- }

  TrvActionCustomColor = class(TrvAction)
  private
    FColorPicker: TForm;
    FColor: TColor;
    FOnHideColorPicker: TNotifyEvent;
    FOnShowColorPicker: TNotifyEvent;
    FUserInterface: TrvaColorInterface;
    FEdit: TCustomRichViewEdit;
    FDefaultColor: TColor;
    FCallerControl: TControl;
    procedure ColorPickerDestroy(Sender: TObject);
    procedure InitColorDialog(var AColorDialog: TColorDialog; var ACreated: Boolean);
    procedure DoneColorDialog(AColorDialog: TColorDialog; ACreated: Boolean);
    procedure SetCallerControl(const Value: TControl);
    procedure SetColor(const Value: TColor);
  protected
    procedure Notification(AComponent: TComponent; Operation: TOperation); override;
    procedure ExecuteCommand(rve: TCustomRichViewEdit; Command: Integer); virtual; abstract;
    function GetCurrentColor(FEdit: TCustomRichViewEdit): TColor; virtual; abstract;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    procedure ExecuteTarget(Target: TObject); override;
    procedure Localize; override;
    function GetColorName: String;
  published
    property CallerControl: TControl read FCallerControl write SetCallerControl;
    property Color: TColor read FColor write SetColor default clNone;
    property UserInterface: TrvaColorInterface read FUserInterface write FUserInterface default rvacAdvanced;
    property OnShowColorPicker: TNotifyEvent read FOnShowColorPicker write FOnShowColorPicker;
    property OnHideColorPicker: TNotifyEvent read FOnHideColorPicker write FOnHideColorPicker;
  end;

  { ------------------ Text Styles ------------------------- }

  TrvActionTextStyles = class(TrvAction)
  private
    procedure NewOnStyleConversion(Sender: TCustomRichViewEdit;
      StyleNo, UserData: Integer; AppliedToText: Boolean; var NewStyleNo: Integer);
  protected
    procedure ExecuteCommand(rve: TCustomRichViewEdit; Command: Integer);
    procedure ApplyConversion(Editor: TCustomRichViewEdit; FontInfo: TFontInfo;
      StyleNo, Command: Integer); virtual; abstract;
  public
    procedure ExecuteTarget(Target: TObject); override;
  end;

  TrvActionFontCustomColor = class(TrvActionCustomColor)
  private
    procedure NewOnStyleConversion(Sender: TCustomRichViewEdit;
      StyleNo, UserData: Integer; AppliedToText: Boolean; var NewStyleNo: Integer);
  protected
    procedure ExecuteCommand(rve: TCustomRichViewEdit; Command: Integer); override;
    procedure ApplyConversion(Editor: TCustomRichViewEdit; FontInfo: TFontInfo;
      StyleNo, Command: Integer); virtual; abstract;
  end;

  TrvActionFontColor = class(TRVActionFontCustomColor)
  protected
    procedure ApplyConversion(Editor: TCustomRichViewEdit; FontInfo: TFontInfo;
      StyleNo, Command: Integer); override;
    function GetCurrentColor(FEdit: TCustomRichViewEdit): TColor; override;
  public
    constructor Create(AOwner: TComponent); override;
  published
    property Color default clWindowText;
  end;

  TrvActionFontBackColor = class(TRVActionFontCustomColor)
  protected
    procedure ApplyConversion(Editor: TCustomRichViewEdit; FontInfo: TFontInfo;
      StyleNo, Command: Integer); override;
    function GetCurrentColor(FEdit: TCustomRichViewEdit): TColor; override;
  public
    constructor Create(AOwner: TComponent); override;
  end;

  TrvActionFonts = class(TrvActionTextStyles)
  private
    FFont: TFont;
    FUserInterface: Boolean;
    procedure SetFont(const Value: TFont);
  protected
    procedure ApplyConversion(Editor: TCustomRichViewEdit; FontInfo: TFontInfo;
      StyleNo, Command: Integer); override;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    procedure ExecuteTarget(Target: TObject); override;
    property Font: TFont read FFont write SetFont;
  published
    property UserInterface: Boolean read FUserInterface write FUserInterface default True;
  end;

  TRVFontInfoMainProperty = (rvfimFontName, rvfimSize, rvfimCharset,
    rvfimBold, rvfimItalic, rvfimUnderline, rvfimStrikeout,
    rvfimOverline, rvfimAllCaps, rvfimVShift, rvfimColor,
    rvfimCharScale, rvfimCharSpacing, rvfimSubSuperScriptType,
    rvfimUnderlineType, rvfimUnderlineColor);

  TRVFontInfoMainProperties = set of TRVFontInfoMainProperty;

  TrvActionFontEx = class(TrvActionFonts)
  private
    FValidProperties: TRVFontInfoMainProperties;
    FVShift: Integer;
    FCharScale: Integer;
    FFontStyleEx: TRVFontStyles;
    FCharSpacing: Integer;
    FSubSuperScriptType: TRVSubSuperScriptType;
    FUnderlineColor: TColor;
    FUnderlineType: TRVUnderlineType;
  protected
    procedure ApplyConversion(Editor: TCustomRichViewEdit; FontInfo: TFontInfo;
      StyleNo, Command: Integer); override;
    procedure IterateProc(RVData: TCustomRVData; ItemNo: Integer;
      rve: TCustomRichViewEdit; var CustomData: Integer); override;
    function ContinueIteration(var CustomData: Integer): Boolean; override;
  public
    constructor Create(AOwner: TComponent); override;
    procedure ExecuteTarget(Target: TObject); override;
    procedure GetFromEditor(rve: TCustomRichViewEdit);

    property FontStyleEx: TRVFontStyles read FFontStyleEx write FFontStyleEx;
    property VShift: Integer read FVShift write FVShift;
    property CharScale: Integer read FCharScale write FCharScale;
    property CharSpacing: Integer read FCharSpacing write FCharSpacing;
    property SubSuperScriptType: TRVSubSuperScriptType read FSubSuperScriptType write FSubSuperScriptType;
    property UnderlineType: TRVUnderlineType read FUnderlineType write FUnderlineType;
    property UnderlineColor: TColor read FUnderlineColor write FUnderlineColor;
    property ValidProperties: TRVFontInfoMainProperties read FValidProperties write FValidProperties;
  end;

  TrvActionFontStyle = class(TrvActionTextStyles)
  protected
    FFontStyle: TFontStyle;
    procedure ApplyConversion(Editor: TCustomRichViewEdit; FontInfo: TFontInfo;
      StyleNo, Command: Integer); override;
    procedure IterateProc(RVData: TCustomRVData; ItemNo: Integer;
      rve: TCustomRichViewEdit; var CustomData: Integer); override;
    function ContinueIteration(var CustomData: Integer): Boolean; override;
    function AdditionalCheckCondition(TextStyle: TFontInfo): Boolean; virtual;
  public
    procedure UpdateTarget(Target: TObject); override;
  end;

  TrvActionFontBold = class(TrvActionFontStyle)
  public
    constructor Create(AOwner: TComponent); override;
  end;

  TrvActionFontItalic = class(TrvActionFontStyle)
  public
    constructor Create(AOwner: TComponent); override;
  end;

  TrvActionFontUnderline = class(TrvActionFontStyle)
  protected
    procedure ApplyConversion(Editor: TCustomRichViewEdit; FontInfo: TFontInfo;
      StyleNo, Command: Integer); override;
    function AdditionalCheckCondition(TextStyle: TFontInfo): Boolean; override;
  public
    constructor Create(AOwner: TComponent); override;
  end;

  TrvActionFontStrikeout = class(TrvActionFontStyle)
  public
    constructor Create(AOwner: TComponent); override;
  end;

  TrvActionFontStyleEx = class(TrvActionTextStyles)
  protected
    FFontStyleEx: TRVFontStyle;
    procedure ApplyConversion(Editor: TCustomRichViewEdit; FontInfo: TFontInfo;
      StyleNo, Command: Integer); override;
    procedure IterateProc(RVData: TCustomRVData; ItemNo: Integer;
      rve: TCustomRichViewEdit; var CustomData: Integer); override;
    function ContinueIteration(var CustomData: Integer): Boolean; override;
  public
    procedure UpdateTarget(Target: TObject); override;
  end;

⌨️ 快捷键说明

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