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

📄 richview.pas

📁 richview1.7 full.source
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    {$IFDEF RICHVIEWDEF5}
    property OnContextPopup;
    {$ENDIF}
    property OnDblClick;
    property OnDragDrop;
    property OnDragOver;
    property OnEndDrag;
    property OnEnter;
    property OnExit;
    property OnKeyDown;
    property OnKeyPress;
    property OnKeyUp;
    property OnMouseMove;
    {$IFDEF RICHVIEWDEF4}
    property OnMouseWheel;
    property OnMouseWheelDown;
    property OnMouseWheelUp;
    property OnResize;    
    {$ENDIF}
    property OnStartDrag;
    { Published RichView properties }
    property BackgroundBitmap;
    property BackgroundStyle default bsNoBitmap;
    property BiDiMode;
    property BorderStyle default bsSingle;
    property BottomMargin;
    property CPEventKind default cpeNone;
    property Cursor default crDefault;
    property Delimiters;
    property DoInPaletteMode;
    property FirstJumpNo;
    property HScrollVisible;
    property LeftMargin;
    property MaxTextWidth;
    property MinTextWidth;
    property Options;
    property RightMargin;
    property RTFOptions;
    property RTFReadProperties;
    property RVFOptions;
    property RVFParaStylesReadMode;
    property RVFTextStylesReadMode;
    {$IFDEF RVFLATSCROLLBARS}
    property ScrollBarColor;
    property ScrollBarStyle;
    {$ENDIF}
    property Style;
    property TabNavigation;
    property TopMargin;
    property Tracking;
    property VScrollVisible;
    {$IFDEF RICHVIEWDEF4}
    property WheelStep;
    {$ENDIF}
    { Published RichView events }
    property OnCheckpointVisible;
    property OnControlAction;
    property OnCopy;
    {$IFDEF RV_ODHC}
    property OnDocumentHeightChange;
    {$ENDIF}
    property OnItemAction;    
    property OnJump;
    property OnHScrolled;    
    property OnHTMLSaveImage;
    property OnPaint;
    property OnReadHyperlink;
    property OnRVDblClick;
    property OnRVFImageListNeeded;
    property OnRVFControlNeeded;
    property OnRVFPictureNeeded;
    property OnRVMouseDown;
    property OnRVMouseMove;
    property OnRVMouseUp;
    property OnRVRightClick;
    property OnSaveComponentToFile;
    property OnSaveHTMLExtra;
    property OnSaveRTFExtra;
    property OnSelect;
    property OnURLNeeded;
    property OnVScrolled;
    { obsolete properties }
    property AllowSelection;
    property SingleClick;
  end;

{------------------------------------------------------------------------------}
implementation
uses ShellApi, PtblRV, RVStr;
{============================= TCustomRichView ======================================}
{$IFDEF RVDEBUG}{$I Debug\Decl.inc}{$ENDIF}
constructor TCustomRichView.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  RVData := GetDataClass.Create(Self);
  Cursor         := crDefault;
  Color          := clNone;
  FLeftMargin    := 5;
  FRightMargin   := 5;
  FTopMargin     := 5;
  FBottomMargin  := 5;
  FMaxTextWidth  := 0;
  {$IFDEF RVDEBUG}{$I Debug\l.inc}{$ENDIF}
  FMinTextWidth  := 0;
  FStyle         := nil;

  Background     := TRVBackground.Create;
  Background.Bitmap.OnChange := DoOnBackBitmapChange;
  Width          := 100;
  Height         := 40;
  Flags          := [rvflUseJumps, rvflTrim, rvflUseExternalLeading, rvflRoot];
  FDelimiters    := RVDEFAULTDELEMITERS;
  ScrollTimerActive := False;
  FOptions       := [rvoAllowSelection, rvoScrollToEnd, rvoAutoCopyText,
                     rvoAutoCopyImage, rvoAutoCopyRVF, rvoAutoCopyRTF,
                     rvoDblClickSelectsWord, rvoRClickDeselects,
                     rvoFormatInvalidate,
                     rvoShowPageBreaks];
  FRVFOptions    := [rvfoSavePicturesBody, rvfoSaveControlsBody, rvfoSaveBinary];
  FRTFOptions    := [rvrtfDuplicateUnicode, rvrtfSaveEMFAsWMF, rvrtfSaveJpegAsJpeg];
  BorderStyle    := bsSingle;
  FRVFTextStylesReadMode := rvf_sInsertMerge;
  FRVFParaStylesReadMode := rvf_sInsertMerge;
end;
{------------------------------------------------------------------------------}
function TCustomRichView.GetDataClass: TRichViewRVDataClass;
begin
  Result := TRichViewRVData;
end;
{------------------------------------------------------------------------------}
destructor TCustomRichView.Destroy;
begin
  Destroying;
  Background.Free;
  Clear;
  RVData.Free;
  RTFReadProperties := nil;
  inherited Destroy;
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.GetTabOrderList(List: TList);
var i: Integer;
begin
  inherited GetTabOrderList(List);
  if TabNavigation<>rvtnNone then begin
    for i := List.Count-1 downto 2 do
      if TWinControl(List[i]).Parent=Self then
        List.Insert(i,Self);
    if List.Count>1 then
      List.Add(Self);
  end;
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.Notification(AComponent: TComponent; Operation: TOperation);
begin
  inherited Notification(AComponent, Operation);
  if (Operation=opRemove) and (AComponent=FStyle) then begin
      Style := nil;
  end;
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.WMSize(var Message: TWMSize);
begin
  Format_(True, False, Canvas, False, False);
  inherited;
//  if Assigned(FOnResized) then FOnResized(Self);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.Format;
begin
  Format_(False, True, Canvas, False, True);
  if rvoFormatInvalidate in Options then Invalidate;
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.FormatTail;
begin
  Format_(False, True, Canvas, True, True);
  if rvoFormatInvalidate in Options then Invalidate;
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.ClearTemporal;
begin
  if ScrollTimerActive then begin
    if HandleAllocated then KillTimer(Handle,1);
    ScrollTimerActive := False;
  end;
  RVData.ClearTemporal;
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.Deselect;
begin
  RVData.Deselect(nil, True);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.SelectAll;
begin
  RVData.SelectAll;
end;
{------------------------------------------------------------------------------}
function TCustomRichView.GetOffsBeforeItem(ItemNo: Integer): Integer;
begin
  Result := RVData.GetOffsBeforeItem(ItemNo);
end;
{------------------------------------------------------------------------------}
function TCustomRichView.GetOffsAfterItem(ItemNo: Integer): Integer;
begin
  Result := RVData.GetOffsAfterItem(ItemNo);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.Clear;
begin
  ClearTemporal;
  RVData.Clear;
end;
{------------------------------------------------------------------------------}
function TCustomRichView.GetFirstJumpNo: Integer;
begin
  Result := RVData.FirstJumpNo;
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.SetFirstJumpNo(Value: Integer);
begin
  RVData.FirstJumpNo := Value;
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.AddNLTag(const s: String; StyleNo, ParaNo, Tag: Integer);
begin
  RVData.AddNLTag(s, StyleNo, ParaNo, Tag);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.AddItem(const Text: String; Item: TCustomRVItemInfo);
begin
  RVData.AddItem(Text, Item);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.AddNL(const s: String; StyleNo, ParaNo: Integer);
begin
  RVData.AddNL(s, StyleNo, ParaNo);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.AddFmt(const FormatStr: String; const Args: array of const;
                           StyleNo, ParaNo: Integer);
begin
  RVData.AddFmt(FormatStr, Args, StyleNo, ParaNo);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.AddFromNewLine(const s: String; StyleNo:Integer);
begin
  RVData.AddNLTag(s, StyleNo, 0, 0);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.AddTag(const s: String; StyleNo,Tag:Integer);
begin
  RVData.AddNLTag(s, StyleNo, -1, Tag);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.Add(const s: String; StyleNo:Integer);
begin
  RVData.AddNLTag(s, StyleNo, -1, 0);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.AddText(const s: String;StyleNo:Integer);
begin
  RVData.AddTextNL(s, StyleNo, -1, 0);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.AddTextFromNewLine(const s: String;StyleNo:Integer);
begin
  RVData.AddTextNL(s, StyleNo, 0, 0);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.AddTextNL(const s: String; StyleNo, FirstParaNo, OtherParaNo : Integer);
begin
  RVData.AddTextNL(s, StyleNo, FirstParaNo, OtherParaNo);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.AddTextBlockNL(s: String; StyleNo, ParaNo: Integer);
begin
  RVData.AddTextBlockNL(s, StyleNo, ParaNo);
end;
{------------------------------------------------------------------------------}
{
procedure TCustomRichView.AddTextNLTag(s: String; StyleNo, ParaNo, Tag: Integer);
begin

end;
}
{------------------------------------------------------------------------------}
procedure TCustomRichView.AddCenterLine(const s: String;StyleNo:Integer);
begin
  RVData.AddNLTag(s, StyleNo, 1, 0);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.AddBreakExTag(Width: Byte; Style: TRVBreakStyle; Color: TColor; Tag: Integer);
begin
  RVData.AddBreakExTag(Width,Style,Color,Tag);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.AddBreakEx(Width: Byte; Style: TRVBreakStyle; Color: TColor);
begin

⌨️ 快捷键说明

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