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

📄 unit1.pas

📁 与Action相结合,可以解决中文件显示乱码
💻 PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  RVStyle, RVScroll, RichView, RVEdit, CRVFData;

type
  TForm1 = class(TForm)
    RVStyle1: TRVStyle;
    RichViewEdit1: TRichViewEdit;
    procedure FormCreate(Sender: TObject);
    procedure RVStyle1DrawStyleText(Sender: TRVStyle; const s: String;
      Canvas: TCanvas; StyleNo, SpaceBefore, Left, Top, Width,
      Height: Integer; DrawState: TRVTextDrawStates;
      var DoDefault: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
  with RichViewEdit1 do begin
    Clear;
    AddNL('M',1,0);
    Add('=||m',0);
    Add('i,j',3);
    Add('||',0);
    // Note: rvoTagsArePChars in Options
    AddTag('n',2, Integer(StrNew('m'))); // double scripts are only as an example
                                         // here. They are too imperfect -
                                         // thet assume that upperscript text is narrower
                                         // (or at least not very wider)
                                         // than superscript
    Format;
  end;
end;

procedure TForm1.RVStyle1DrawStyleText(Sender: TRVStyle; const s: String;
  Canvas: TCanvas; StyleNo, SpaceBefore, Left, Top, Width, Height: Integer;
  DrawState: TRVTextDrawStates; var DoDefault: Boolean);
var uppertext: PChar;
begin
  case StyleNo of
    1: // dot
      begin
        // displaying small circle in the right top corner of item
        // and allowing default drawing of item text
        if (rvtsItemEnd in DrawState) and (Length(s)>0) then begin
          Canvas.Pen.Color := Sender.TextStyles[1].Color;
          Canvas.Ellipse(Left+Width-2,Top-2,Left+Width+2,Top+2);
        end;
      end;
    2: // double scripts
      begin
        // displaying tag string as superscript
        // and allowing default drawing of item text (subscript)
        if (rvtsItemStart in DrawState) and (Length(s)>0) then begin
          uppertext := PChar(TCustomRVFormattedData(Sender.RVData).GetItemTag(Sender.ItemNo));
          if uppertext<>nil then
            Canvas.TextOut(Left,Top-Height+5, uppertext);
        end;
      end;
  end;
end;

end.

⌨️ 快捷键说明

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