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

📄 richview.pas

📁 richview1.7 full.source
💻 PAS
📖 第 1 页 / 共 5 页
字号:
  if (rvoTagsArePChars in Options) then
    if (Tag1=0) then
      if (Tag2=0) then
        Result := True
      else
        Result := False
    else
      if (Tag2=0) then
        Result := False
      else
        Result := StrComp(PChar(Tag1),PChar(Tag2))=0
  else
    Result := Tag1=Tag2;
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.AppendFrom(Source: TCustomRichView);
begin
  RVData.AppendFrom(Source.RVData);
end;
{------------------------------------------------------------------------------}
function TCustomRichView.GetBackBitmap: TBitmap;
begin
  Result := Background.Bitmap;
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.SetBackBitmap(Value: TBitmap);
begin
  Background.Bitmap.Assign(Value);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.DoOnBackBitmapChange(Sender: TObject);
begin
  if not RVData.UpdatingBAckgroundPalette then begin
    FullRedraw := Background.ScrollRequiresFullRedraw;//or (RVData.FZoomPercent<>100);
    RVData.UpdateBackgroundPaletteInfo(Background);
    if rvoFormatInvalidate in Options then Invalidate;
  end;
end;
{------------------------------------------------------------------------------}
function TCustomRichView.GetBackgroundStyle: TBackgroundStyle;
begin
  Result := Background.Style;
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.SetBackgroundStyle(Value: TBackgroundStyle);
begin
  Background.Style := Value;
  DoOnBackBitmapChange(nil);
end;
{------------------------------------------------------------------------------}
function TCustomRichView.GetColor: TColor;
begin
  {$IFDEF RVDEBUG}{$I Debug\e.inc}{$ENDIF}
  if Color<>clNone then
    Result := Color
  else if Assigned(FStyle) then
    Result := FStyle.Color
  else
    Result := clWindow;
end;
{------------------------------------------------------------------------------}
function TCustomRichView.GetHoverColor(Color: TColor):TColor;
begin
  if Color<>clNone then
    Result := Color
  else
    Result := FStyle.HoverColor;
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.WMEraseBkgnd(var Message: TWMEraseBkgnd);
begin
  Message.Result := 1;
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.SetVSmallStep(Value: Integer);
begin
   if (Value<=0) or (DocumentHeight div Value > 32000) then exit;
   inherited SetVSmallStep(Value);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.SetBiDiModeRV(const Value: TRVBiDiMode);
begin
  if Value<>BiDiMode then begin
    inherited SetBiDiModeRV(Value);
    Format;
  end;
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.SelectWordAt(X,Y: Integer);
begin
  RVData.SelectWordAt(X, Y);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.DblClick;
begin
  RVData.DblClick;
  inherited DblClick;
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.DeleteSection(const CpName: String);
begin
  RVData.DeleteSection(CpName);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.DeleteItems(FirstItemNo, Count: Integer);
begin
  RVData.DeleteItems(FirstItemNo, Count);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.DeleteParas(FirstItemNo, LastItemNo: Integer);
begin
  RVData.DeleteParas(FirstItemNo, LastItemNo);
end;
{------------------------------------------------------------------------------}
function TCustomRichView.GetLineCount: Integer;
begin
  Result := RVData.Items.Count;
end;
{------------------------------------------------------------------------------}
function TCustomRichView.SelectionExists: Boolean;
begin
  Result := RVData.SelectionExists(True, True);
end;
{------------------------------------------------------------------------------}
function TCustomRichView.GetSelectedImage: TGraphic;
begin
  Result := RVData.GetSelectedImage;
end;
{------------------------------------------------------------------------------}
function TCustomRichView.GetSelText: String;
begin
  Result := RVData.GetSelText(False);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.CopyText;
begin
  RVData.CopyText;
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.CopyTextW;
begin
  RVData.CopyTextW;
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.CopyImage;
begin
  RVData.CopyImage;
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.Copy;
begin
  RVData.Copy(GetColor, Background);
end;
{------------------------------------------------------------------------------}
function TCustomRichView.IsCopyShortcut(Shift: TShiftState; Key: Word): Boolean;
begin
  Result := (ssCtrl in Shift) and ((Key = ord('C')) or (Key = VK_INSERT)) and not (ssAlt in Shift);
end;
{------------------------------------------------------------------------------}
function TCustomRichView.IsCutShortcut(Shift: TShiftState; Key: Word): Boolean;
begin
  Result := ((ssCtrl in Shift) and (Key = ord('X')) and not (ssAlt in Shift)) or
            ((ssShift in Shift) and (Key = VK_DELETE));
end;
{------------------------------------------------------------------------------}
function TCustomRichView.IsPasteShortcut(Shift: TShiftState; Key: Word): Boolean;
begin
  Result := ((ssCtrl in Shift) and (Key = ord('V')) and not (ssAlt in Shift)) or
            ((ssShift in Shift) and (Key = VK_INSERT));
end;
{------------------------------------------------------------------------------}
function TCustomRichView.CopyDef: Boolean;
begin
  Result := RVData.CopyDef(GetColor, Background);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.WMCopy(var Message: TWMCopy);
begin
  {$IFNDEF RVDONOTUSEINPLACE}
  if (InplaceEditor<>nil) then begin
    PostMessage(InplaceEditor.Handle, WM_COPY, 0, 0);
    exit;
  end;
  {$ENDIF}
  CopyDef;
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.KeyDown(var Key: Word; Shift: TShiftState);
begin
  inherited KeyDown(Key,Shift);
  if IsCopyShortCut(Shift, Key) then
    SendMessage(Handle, WM_COPY, 0, 0);
  if (TabNavigation<>rvtnNone) and
     ((Key=VK_TAB) and not (ssAlt in Shift) and
     (((ssCtrl in Shift) and (TabNavigation=rvtnCtrlTab)) or
       (not (ssCtrl in Shift) and (TabNavigation=rvtnTab)))) then begin
    Exclude(RVData.State,rvstDoNotTab);
    RVData.DoTabNavigation(ssShift in Shift, Self);
  end;
  if (Key=VK_RETURN) then
    RVData.ExecuteFocused;
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.GenerateMouseMove;
var State: TShiftState;
    KeyboardState: TKeyboardState;
    p: TPoint;
begin
  State := [];
  GetKeyboardState(KeyboardState);
  if KeyboardState[VK_SHIFT] and $80 <> 0 then Include(State, ssShift);
  if KeyboardState[VK_CONTROL] and $80 <> 0 then Include(State, ssCtrl);
  if KeyboardState[VK_MENU] and $80 <> 0 then Include(State, ssAlt);
  if KeyboardState[VK_LBUTTON] and $80 <> 0 then Include(State, ssLeft);
  if KeyboardState[VK_RBUTTON] and $80 <> 0 then Include(State, ssRight);
  if KeyboardState[VK_MBUTTON] and $80 <> 0 then Include(State, ssMiddle);
  GetCursorPos(p);
  p := ScreenToClient(p);
  if (p.X>=0) and (p.X<ClientWidth) and
     (p.Y>=0) and (p.Y<ClientHeight) then
    MouseMove(State,p.X,p.Y);
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.WMTimer(var Message: TWMTimer);
begin
  case Message.TimerID of
    1:
      begin
        //if RVData.CaptureMouseItem<>nil then exit;
        if VScrollDelta<>0 then
          VScrollPos := VScrollPos+VScrollDelta;
        if HScrollDelta<>0 then
          SetHPos(HPos+HScrollDelta);
        if (HScrollDelta<>0) or (VScrollDelta<>0) then begin
          {$IFDEF RVDEBUG}{$I Debug\f.inc}{$ENDIF}
          RVData.OnTimerScroll;
          GenerateMouseMove;
        end;
      end;
  end;
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.Loaded;
begin
  inherited Loaded;
  UpdatePaletteInfo;
  Format;
end;
{------------------------------------------------------------------------------}
function TCustomRichView.GetAllowSelection: Boolean;
begin
  Result := rvoAllowSelection in Options;
end;
{------------------------------------------------------------------------------}
function TCustomRichView.GetSingleClick: Boolean;
begin
  Result := rvoSingleClick in Options;
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.SetAllowSelection(const Value: Boolean);
begin
  if Value then
    Include(FOptions, rvoAllowSelection)
  else
    Exclude(FOptions, rvoAllowSelection)
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.SetSingleClick(const Value: Boolean);
begin
  if Value then
    Include(FOptions, rvoSingleClick)
  else
    Exclude(FOptions, rvoSingleClick)
end;
{------------------------------------------------------------------------------}
function TCustomRichView.GetTabNavigation:TRVTabNavigationType;
begin
  Result := RVData.TabNavigation;
end;
{------------------------------------------------------------------------------}
procedure TCustomRichView.SetTabNavigation(const Value: TRVTabNavigationType);
begin
  RVData.TabNavigation := Value;
end;
{------------------------------------------------------------------------------}
function TCustomRichView.SearchText(const s: String; SrchOptions: TRVSearchOptions): Boolean;
begin
  Result := RVData.SearchText(rvsroDown in SrchOptions, rvsroMatchCase in SrchOptions,
                              rvsroWholeWord in SrchOptions, s);
end;
{------------------------------------------------------------------------------}
function TCustomRichView.GetItemStyle(ItemNo: Integer): Integer;
begin
  Result := RVData.GetItemStyle(ItemNo);
end;
{

⌨️ 快捷键说明

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