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

📄 crvfdata.pas

📁 richview1.7 full.source
💻 PAS
📖 第 1 页 / 共 5 页
字号:
       if max=0 then
         if newline
         {$IFNDEF RVDONOTUSELISTS}
         or (AtStart and (ItemNo>0) and (GetItemStyle(ItemNo-1)=rvsListMarker))
         {$ENDIF}
          then begin
             max := 1;
             {$IFNDEF RVDONOTUSEUNICODE}
             if RVNT and (rvioUnicode in li.ItemOptions) then
               max := AdjustMaxFitR(max);
             {$ENDIF}
           end
         else begin
           x:=0;
           IsParaStart := False;
           newline := true;
           continue;
         end;
       if max<sourceStrPtrLen then begin
           {$IFNDEF RVDONOTUSEUNICODE}
           if rvioUnicode in li.ItemOptions then
             strSpacePos := RVU_FindLineBreak(PRVWordArray(sourceStrPtr), max) // MyStrRScanW(sourceStrPtr,' ',max)
           else
           {$ENDIF}
             strSpacePos := MyStrRScanA(sourceStrPtr,' ',max);
           if strSpacePos<>nil then begin
             {$IFNDEF RVDONOTUSEUNICODE}
             if rvioUnicode in li.ItemOptions then begin
               if (rvflTrim in Flags) and (PRVWordArray(strSpacePos)[0]=UNI_Space) then begin
                 max := (strSpacePos-sourceStrPtr) div 2;
                 SpaceEated := True;
                 end
               else
                 max := (strSpacePos-sourceStrPtr) div 2+1;
               end
             else
             {$ENDIF}
             begin
               if rvflTrim in Flags then begin
                 max := strSpacePos-sourceStrPtr;
                 SpaceEated := True;
                 end
               else
                 max := strSpacePos-sourceStrPtr+1;
             end;
             end
           else if not (newline
           {$IFNDEF RVDONOTUSELISTS}
           or (AtStart and (ItemNo>0) and (GetItemStyle(ItemNo-1)=rvsListMarker))
           {$ENDIF}
           )
           then begin
             IsParaStart := False;
             newline := true;
             continue;
           end;
       end;
       {$IFNDEF RVDONOTUSEUNICODE}
       if rvioUnicode in li.ItemOptions then begin
         Offs := (sourceStrPtr - PChar(Text)) div 2+1;
         StrForAdd := sourceStrPtr;
         inc(sourceStrPtr,max*2);
         dec(sourceStrPtrLen,max);
         if SpaceEated then begin
           inc(sourceStrPtr, 2);
           dec(sourceStrPtrLen);
           SpaceEated := False;
         end;
         end
       else
       {$ENDIF}
       begin
         Offs := sourceStrPtr - PChar(Text)+1;
         StrForAdd := sourceStrPtr;
         inc(sourceStrPtr,max);
         dec(sourceStrPtrLen,max);
         if SpaceEated then begin
           inc(sourceStrPtr);
           dec(sourceStrPtrLen);
           SpaceEated := False;
         end;
       end;
       if (newline or (max<>0)) then begin
         dli := TRVDrawLineInfo.Create;
         dli.ItemNo := ItemNo;
         dli.Offs := Offs;
         if {(sourceStrPtrLen<>0) and} ((max<>max2) or (sourceStrPtr2<>sourceStrPtr) or (rvpaoNoWrap in pi.Options)) then
          {$IFNDEF RVDONOTUSEUNICODE}
           if rvioUnicode in li.ItemOptions then
             GetTextExtentPoint32W(Canvas.Handle,Pointer(strForAdd),max,sz)
           else
           {$ENDIF}
             GetTextExtentPoint32(Canvas.Handle,strForAdd,max,sz);
         if not newline then begin {continue line}
           AdjustLineHeight(ExternalLeading+TextMetric.tmAscent+VerticalOffs);
           y := baseline - (ExternalLeading+TextMetric.tmAscent+VerticalOffs);
           dli.FromNewLine := False;
           end
         else  begin { new line }
           dli.FromNewLine := True;
           x :=0;
           inc(baseline, ExtraSpaceBelowLine);
           y := baseline+prevDesc;
           prevabove := ExternalLeading+TextMetric.tmAscent+VerticalOffs;
           inc(baseline, prevDesc+prevabove);
         end;
         dli.Left   :=x+FirstIndent;
         dli.Top    := y;
         dli.Width  := sz.cx;
         dli.Height := sz.cy;
         dli.Length := max;
         DrawItems.Insert(LastDrawItem,dli);
         if AtStart and not ShareItems then
           li.DrawItemNo := LastDrawItem;
         inc(LastDrawItem);
         if (rvflUseJumps in Flags) and RVStyle.TextStyles[li.StyleNo].Jump then begin
           jmpinfo := TRVJumpInfo.Create;
           jmpinfo.w := sz.cx;
           jmpinfo.h := sz.cy;
           jmpinfo.id := nJmps;
           if StartOffs>0 then dec(jmpinfo.id);
           jmpinfo.DrawItemNo := LastDrawItem-1;
           jmpinfo.Cursor := RVStyle.TextStyles[li.StyleNo].JumpCursor;
           jmpinfo.RVData := Self;
           jumps.Add(jmpinfo);
         end;
         if newline or (prevDesc < TextMetric.tmDescent-VerticalOffs) then
           prevDesc := TextMetric.tmDescent-VerticalOffs;
         inc(x,sz.cx);
         newline := True;
         IsParaStart := False;
         AtStart := False;
         end
       else
         newline := true;
     end; { while }
     if RVStyle.TextStyles[li.StyleNo].Jump and (StartOffs=0) then begin
       TCustomRVItemInfo(Items.Objects[ItemNo]).JumpID := nJmps;
       inc(nJmps);
     end;
  end;
end;
{------------------------------------------------------------------------------}
procedure TCustomRVFormattedData.FormatWords(ItemNo: Integer;
                             var x, baseline, prevdesc, prevabove: Integer;
                             Canvas: TCanvas;
                             var sad: TRVScreenAndDevice;
                             var IsParaStart: Boolean;
                             var LineWidth, FirstIndent, LastDrawItem,
                             VerticalOffs: Integer;
                             var DontFSL: Boolean;
                             var LastTextStyle: Integer;
                             var TextMetric: TTextMetric;
                             var FirstParaItemNo: Integer;
                             NoCaching: Boolean);
var offs: Integer;
    LinesNo, TmpStr, SpacePos: PChar;
    Len, WordLen: Integer;
    {$IFNDEF RVDONOTUSEUNICODE}
    Unicode: Boolean;
    {$ENDIF}
    Text: String;
begin
  Len := Length(Items[ItemNo]);
  if Len=0 then begin
    FormatLine('', 0, Len, ItemNo, x, baseline, prevdesc, prevabove,
                  Canvas, sad, IsParaStart,
                  LineWidth, FirstIndent, LastDrawItem, VerticalOffs,
                  DontFSL,LastTextStyle, TextMetric, FirstParaItemNo, NoCaching);
    exit;
  end;
  {$IFNDEF RVDONOTUSEUNICODE}
  Unicode := rvioUnicode in GetItemOptions(ItemNo);
  if Unicode then
    Len := Len div 2;
  {$ENDIF}
  offs := 0;
  {$IFNDEF RVDONOTUSEALLCAPS}
    Text := RV_ReturnCapitalized(Items[ItemNo], GetRVStyle.TextStyles[TCustomRVItemInfo(Items.Objects[ItemNo]).StyleNo]);
  {$ELSE}
    Text := Items[ItemNo];
  {$ENDIF}
  LinesNo := PChar(Text);
  while Len>0 do begin
    TmpStr := LinesNo;
    {$IFNDEF RVDONOTUSEUNICODE}
    if Unicode then begin
      if (PWord(TmpStr)^ = ord(' ')) then
        inc(PChar(TmpStr), 2);
      SpacePos := RVU_StrScanW(TmpStr, ord(' '), Len)
      end
    else
    {$ENDIF}
    begin
      if (TmpStr^ = ' ') then
        inc(TmpStr);
      SpacePos := StrScan(TmpStr, ' ');
    end;
    if SpacePos=nil then
      WordLen := Len
    else begin
      WordLen := SpacePos-LinesNo;
      {$IFNDEF RVDONOTUSEUNICODE}
      if Unicode then
        WordLen := WordLen div 2;
      {$ENDIF}
    end;
    FormatLine(Text, Offs, WordLen, ItemNo, x, baseline, prevdesc, prevabove,
                  Canvas, sad, IsParaStart,
                  LineWidth, FirstIndent, LastDrawItem, VerticalOffs,
                  DontFSL, LastTextStyle, TextMetric, FirstParaItemNo, NoCaching);
    inc(offs, WordLen);
    inc(LinesNo, WordLen);
    {$IFNDEF RVDONOTUSEUNICODE}
    if Unicode then
      inc(LinesNo, WordLen);
    {$ENDIF}
    dec(Len, WordLen);
  end;
end;
{------------------------------------------------------------------------------}
function TCustomRVFormattedData.GetHOffs: Integer;
begin
  Result := 0;
end;
{------------------------------------------------------------------------------}
function TCustomRVFormattedData.GetVOffs: Integer;
begin
  Result := 0;
end;
{------------------------------------------------------------------------------}
procedure TCustomRVFormattedData.Format(NoCaching: Boolean);
begin
  Format_(False, True, False, 0, GetCanvas, False, NoCaching);
end;
{------------------------------------------------------------------------------}
procedure TCustomRVFormattedData.ApplyZoom(Canvas: TCanvas);
begin
  {
  if ZoomPercent<>100 then begin
    SetMapMode(Canvas.Handle,MM_ANISOTROPIC);
    SetWindowExtEx(Canvas.Handle,100,100,nil);
    SetViewportExtEx(Canvas.Handle,ZoomPercent,ZoomPercent,nil);
  end;
  }
end;
{------------------------------------------------------------------------------}
procedure TCustomRVFormattedData.RestoreZoom(Canvas: TCanvas);
begin
  {
  if ZoomPercent<>100 then
    SetMapMode(Canvas.Handle,MM_TEXT);
  }
end;
{------------------------------------------------------------------------------}
procedure TCustomRVFormattedData.ZoomInt(var v: Integer);
begin
  v := v;
  //v := MulDiv(v,100,ZoomPercent);
end;
{------------------------------------------------------------------------------}
procedure TCustomRVFormattedData.ZoomRectDown(var r: TRect);
begin
  {
  with r do begin
    Left := MulDiv(Left,100,ZoomPercent);
    Top := MulDiv(Top,100,ZoomPercent);
    Right := MulDiv(Right,100,ZoomPercent);
    Bottom := MulDiv(Bottom,100,ZoomPercent);
  end;
  }
end;
{------------------------------------------------------------------------------}
procedure TCustomRVFormattedData.GetSADForFormatting(Canvas: TCanvas; var sad: TRVScreenAndDevice);
begin
//  ApplyZoom(Canvas);
  RV_InfoAboutSaD(sad, Canvas);
end;
{------------------------------------------------------------------------------}
procedure TCustomRVFormattedData.Format_(OnlyResized,ForceFormat,NoScroll: Boolean; depth: Integer;
                                         Canvas: TCanvas; OnlyTail, NoCaching: Boolean);
var i: Integer;
    x,b,d,a: Integer;
    oldtextwidth, olddocumentwidth, cw, ch: Integer;
    sad: TRVScreenAndDevice;
    StartLine: Integer;
    StartNo, EndNo, StartOffs, EndOffs: Integer;
    DevMinTextWidth, DevMaxTextWidth: Integer;
    FV, DeltaFV, LineWidth, Indent, LastDrawItem: Integer;
    IsParaStart: Boolean;
    DontFSL: Boolean;
    LastTextStyle, VerticalOffs: Integer;
    TextMetric: TTextMetric;
    RVStyle: TRVStyle;
    ExtraSpaceBelowLine: Integer;
    FirstParaItemNo: Integer;
begin
   if AlreadyFormatted then begin
     AlreadyFormatted := False;
     exit;
   end;
   if (depth>1) or (GetRVStyle=nil) or (rvstSkipformatting in State) then exit;
   if Canvas=nil then
     Canvas := GetCanvas;
   if depth=0 then begin
     StartFormatting;
     if OnlyResized then
       State := State+[rvstResizing];
   end;
   try
     FirstParaItemNo := -1;
     LastTextStyle := -1;
     IsParaStart := True;
     FV := -1;     { avoiding warings }
     DeltaFV := 0; { avoiding warings }
     if depth=0 then begin
        if OnlyResized then begin
          StoreSelBounds(StartNo, EndNo, StartOffs, EndOffs, False);
          if not NoScroll then begin
            FV := GetDrawItemNo(GetVOffs, gdinFirstVisible);
            if FV>=DrawItems.Count then FV:=DrawItems.Count-1;
            if FV<>-1 then  begin
              DeltaFV := GetVOffs-DrawItems[FV].Top;
              FV := DrawItems[FV].ItemNo;
            end;
          end;
        end;
        if OnlyTail then FV := GetVOffs;
     end;

     oldtextwidth := TextWidth;
     olddocumentwidth := DocumentWidth;

     GetSADForFormatting(Canvas, sad);

     sad.LeftMargin := MulDiv(GetLeftMargin,  sad.ppixDevice, sad.ppixScreen);
     sad.RightMargin := MulDiv(GetRightMargin,  sad.

⌨️ 快捷键说明

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