📄 richview.pas
字号:
RVData.AddBreakEx(Width,Style,Color);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.AddBreakTag(Tag: Integer);
begin
RVData.AddBreakTag(Tag);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.AddBreak;
begin
RVData.AddBreakTag(0);
end;
{------------------------------------------------------------------------------}
function TCustomRichView.AddNamedCheckpointExTag(const CpName: String;
RaiseEvent: Boolean;
Tag: Integer): Integer;
begin
Result := RVData.AddNamedCheckpointExTag(CpName, RaiseEvent, Tag);
end;
{------------------------------------------------------------------------------}
{
function TCustomRichView.AddNamedCheckpointTag(const CpName: String; Tag: Integer): Integer;
begin
Result := AddNamedCheckpointExTag(CpName, False, Tag);
end;
}
{------------------------------------------------------------------------------}
function TCustomRichView.AddNamedCheckpointEx(const CpName: String;
RaiseEvent: Boolean): Integer;
begin
Result := RVData.AddNamedCheckpointExTag(CpName, RaiseEvent, 0);
end;
{------------------------------------------------------------------------------}
function TCustomRichView.AddNamedCheckpoint(CpName: String): Integer;
begin
Result := RVData.AddNamedCheckpointExTag(CpName, False, 0);
end;
{------------------------------------------------------------------------------}
function TCustomRichView.AddCheckpointTag(Tag: Integer): Integer;
begin
Result := RVData.AddNamedCheckpointExTag('',False,Tag);
end;
{------------------------------------------------------------------------------}
function TCustomRichView.AddCheckpoint: Integer;
begin
Result := RVData.AddNamedCheckpointExTag('',False,0);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.AddHotspotExTag(const Name: String;
ImageIndex, HotImageIndex: Integer;
ImageList: TCustomImageList;
ParaNo, Tag: Integer);
begin
RVData.AddHotspotExTag(Name, ImageIndex, HotImageIndex, ImageList, ParaNo, Tag);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.AddHotspotEx(const Name: String;
ImageIndex, HotImageIndex: Integer;
ImageList: TCustomImageList;
ParaNo: Integer);
begin
RVData.AddHotspotEx(Name, ImageIndex, HotImageIndex, ImageList, ParaNo);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.AddHotspot(ImageIndex: Integer; ImageList: TCustomImageList;
fromnewline: Boolean);
begin
if FromNewLine then
RVData.AddHotspotExTag('', ImageIndex, ImageIndex, ImageList, 0, 0)
else
RVData.AddHotspotExTag('', ImageIndex, ImageIndex, ImageList, -1, 0);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.AddBulletExTag(const Name: String; ImageIndex: Integer;
ImageList: TCustomImageList;
ParaNo, Tag: Integer);
begin
RVData.AddBulletExTag(Name, ImageIndex, ImageList, ParaNo, Tag);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.AddBulletEx(const Name: String; ImageIndex: Integer;
ImageList: TCustomImageList;
ParaNo: Integer);
begin
RVData.AddBulletEx(Name, ImageIndex, ImageList, ParaNo);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.AddBullet(ImageIndex: Integer; ImageList: TCustomImageList; fromnewline: Boolean);
begin
if FromNewLine then
RVData.AddBulletExTag('', ImageIndex, ImageList, 0, 0)
else
RVData.AddBulletExTag('', ImageIndex, ImageList, -1, 0);
end;
{------------------------------------------------------------------------------}
{ "gr" does not copied, do not free it!}
procedure TCustomRichView.AddPictureExTag(const Name: String; gr: TGraphic;
ParaNo: Integer; VAlign: TRVVAlign; Tag: Integer);
begin
RVData.AddPictureExTag(Name, gr, ParaNo, VAlign, Tag);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.AddPictureEx(const Name: String; gr: TGraphic; ParaNo: Integer; VAlign: TRVVAlign); { gr does not copied, do not free it!}
begin
RVData.AddPictureExTag(Name, gr, ParaNo, VAlign, 0);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.AddHotPictureTag(const Name: String; gr: TGraphic;
ParaNo: Integer; VAlign: TRVVAlign; Tag: Integer);
begin
RVData.AddHotPictureTag(Name, gr, ParaNo, VAlign, Tag);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.AddHotPicture(const Name: String; gr: TGraphic; ParaNo: Integer;
VAlign: TRVVAlign);
begin
RVData.AddHotPictureTag(Name, gr, ParaNo, VAlign, 0);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.AddPicture(gr: TGraphic); { gr not copied, do not free it!}
begin
RVData.AddPictureExTag('', gr, 1, rvvaBaseline, 0);
end;
{------------------------------------------------------------------------------}
{ do not free ctrl yourself! }
procedure TCustomRichView.AddControlExTag(const Name: String; ctrl: TControl;
ParaNo: Integer; VAlign: TRVVAlign; Tag: Integer);
begin
RVData.AddControlExTag(Name, ctrl, ParaNo, VAlign, Tag);
end;
{------------------------------------------------------------------------------}
{ do not free ctrl yourself! }
procedure TCustomRichView.AddControlEx(const Name: String; ctrl: TControl; ParaNo: Integer;
VAlign: TRVVAlign);
begin
RVData.AddControlEx(Name, ctrl, ParaNo, VAlign);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.AddControl(ctrl: TControl; center: Boolean); { do not free ctrl! }
begin
if Center then
RVData.AddControlExTag('',ctrl, 1, rvvaBaseline, 0)
else
RVData.AddControlExTag('',ctrl, 0, rvvaBaseline, 0);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.Format_(OnlyResized,ForceFormat:Boolean; Canvas: TCanvas;
OnlyTail, NoCaching: Boolean);
begin
if VSmallStep = 0 then exit;
if (csDesigning in ComponentState) then exit;
{$IFDEF RVDEBUG}{$I Debug\g.inc}{$ENDIF}
RVData.Format_(OnlyResized, ForceFormat, False, 0, Canvas, OnlyTail, NoCaching);
end;
{------------------------------------------------------------------------------}
function TCustomRichView.GetFirstItemVisible: Integer;
begin
Result := RVData.GetFirstItemVisible;
end;
{------------------------------------------------------------------------------}
function TCustomRichView.GetLastItemVisible: Integer;
begin
Result := RVData.GetLastItemVisible;
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.Paint;
{.......................................................}
procedure DrawDesignInfo(const msg: String);
var r: TRect;
begin
Canvas.Brush.Color := GetColor;
Canvas.Brush.Style := bsSolid;
if Ctl3d then
Canvas.Pen.Color := clWindow
else
Canvas.Pen.Color := clWindowText;
Canvas.Font.Color := clWindowText;
Canvas.Font.Name := RVDEFAULTDESIGNFONT;
Canvas.Font.Size := 8;
Canvas.Font.Style := [];
Canvas.FillRect(Canvas.ClipRect);
r := ClientRect;
DrawText(Canvas.Handle, PChar(msg), Length(msg), r, DT_TOP or DT_WORDBREAK);
if not Ctl3d then begin
Canvas.Brush.Color := clWindowText;
Canvas.FrameRect(ClientRect);
end;
end;
{.......................................................}
var NeedXOR: Boolean;
begin
if (csDesigning in ComponentState) then
DrawDesignInfo(SysUtils.Format('%s %s (%s)', [ClassName, RVVersion, RVAddress]))
else if not Assigned(FStyle) then
DrawDesignInfo(SysUtils.Format(RVNOSTYLEMSG, [Name]))
else begin
NeedXOR := RVData.ClearXorDrawing;
//if Assigned(FOnPaint) then
// FOnPaint(Self, Canvas, True);
RVData.PaintBuffered;
if Assigned(FOnPaint) then
FOnPaint(Self, Canvas, False);
if NeedXOR then
RVData.XorDrawing;
end;
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.CMMouseLeave(var Message: TMessage);
begin
RVData.MouseLeave;
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.MouseMove(Shift: TShiftState; X, Y: Integer);
begin
if {RVData.CaptureMouseItem=nil} True then begin
if Y<-20 then
VScrollDelta := -10
else if Y<0 then
VScrollDelta := -1
else if Y>ClientHeight+20 then
VScrollDelta := 10
else if Y>ClientHeight then
VScrollDelta := 1
else
VScrollDelta := 0;
if X<-20 then
HScrollDelta := -10
else if X<0 then
HScrollDelta := -1
else if X>ClientWidth+20 then
HScrollDelta := 10
else if X>ClientWidth then
HScrollDelta := 1
else
HScrollDelta := 0;
inherited MouseMove(Shift, X, Y);
end;
RVData.MouseMove(Shift, X, Y);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
{$IFDEF RICHVIEWDEF5}
var p: TPoint;
Handled: Boolean;
{$ENDIF}
begin
inherited MouseUp(Button, Shift, X, Y);
if (Button=mbLeft) and ScrollTimerActive then begin
KillTimer(Handle,1);
ScrollTimerActive := False;
end;
RVData.MouseUp(Button, Shift, X, Y);
{$IFDEF RICHVIEWDEF5}
if not (csDesigning in ComponentState) and
(TCustomRichView(RVData.GetAbsoluteRootData.GetParentControl).PopupMenu<>nil) and
TCustomRichView(RVData.GetAbsoluteRootData.GetParentControl).PopupMenu.AutoPopup and
(Button=mbRight) then begin
Handled := False;
p.X := X;
p.Y := Y;
p := ClientToScreen(p);
DoContextPopup(p, Handled);
if Handled then
exit;
SendCancelMode(nil);
TCustomRichView(RVData.GetAbsoluteRootData.GetParentControl).PopupMenu.PopupComponent := Self;
TCustomRichView(RVData.GetAbsoluteRootData.GetParentControl).PopupMenu.Popup(p.X, p.Y);
end;
{$ENDIF}
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.SelectNext_(GoForward: Boolean);
begin
SelectNext(nil,GoForward,True);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if InplaceEditor=nil then begin
Include(RVData.State,rvstDoNotTab);
Windows.SetFocus(Handle);
end;
inherited MouseDown(Button, Shift, X, Y);
RVData.MouseDown(Button, Shift, X, Y);
if (Button=mbLeft) then
ActivateScrollTimer;
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.ActivateScrollTimer;
begin
if not ScrollTimerActive then begin
SetTimer(Handle,1,100,nil);
ScrollTimerActive := True;
end;
end;
{------------------------------------------------------------------------------}
function TCustomRichView.CompareTags(Tag1, Tag2: Integer): Boolean;
begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -