📄 crvdata.pas
字号:
s:=AdjustLineBreaks(s);
repeat
p := Pos(crlf,s);
if p=0 then begin
AddNLTag(s,StyleNo,ParaNo, GetTag);
SetAddParagraphMode(ANP);
break;
end;
AddNLTag(System.Copy(s,1,p-1), StyleNo, ParaNo, GetTag);
if FirstTime then begin
SetAddParagraphMode(False);
FirstTime := False;
end;
Delete(s,1, p+1);
until False;
{$IFDEF RICHVIEWDEF4}
if tap and (Tag<>0) then
StrDispose(PChar(Tag));
{$ENDIF}
end;
{------------------------------------------------------------------------------}
function TCustomRVData.AddNamedCheckpointExTag(const CpName: String;
RaiseEvent: Boolean;
Tag: Integer): Integer;
begin
{$IFDEF RVALLOWCPBYCP}
if NotAddedCP<>nil then begin
Result := CPCount-1;
exit;
end;
{$ELSE}
if NotAddedCP<>nil then
raise ERichViewError.Create(errCPByCP);
{$ENDIF}
NotAddedCP := TRVCPInfo.Create;
NotAddedCP.Name := CPName;
NotAddedCP.Tag := Tag;
NotAddedCP.Next := nil;
NotAddedCP.Prev := nil;
//NotAddedCP.ItemNo := -1;
NotAddedCP.RaiseEvent := RaiseEvent;
Result := CPCount;
inc(CPCount);
end;
{------------------------------------------------------------------------------}
procedure TCustomRVData.AddBreakExTag(Width: Byte; Style: TRVBreakStyle;
Color: TColor; Tag: Integer);
var Item: TRVBreakItemInfo;
begin
Item := TRVBreakItemInfo.CreateEx(Self, Width, Style, Color);
Item.SameAsPrev := False;
Item.ParaNo := 0;
Item.Tag := Tag;
AddItem('',Item);
end;
{------------------------------------------------------------------------------}
procedure TCustomRVData.AddBreakEx(Width: Byte; Style: TRVBreakStyle;
Color: TColor);
begin
AddBreakExTag(Width, Style, Color, 0);
end;
{------------------------------------------------------------------------------}
procedure TCustomRVData.AddBreakTag(Tag: Integer);
begin
AddBreakExTag(1, rvbsLine, clNone, Tag);
end;
{------------------------------------------------------------------------------}
procedure TCustomRVData.AddBreak;
begin
AddBreakTag(0);
end;
{------------------------------------------------------------------------------}
procedure TCustomRVData.AddHotspotExTag(const Name: String;
ImageIndex, HotImageIndex: Integer;
ImageList: TCustomImageList;
ParaNo, Tag: Integer);
var Item: TRVHotspotItemInfo;
begin
Item := TRVHotspotItemInfo.CreateEx(Self, ImageIndex, HotImageIndex,
ImageList, rvvaBaseLine);
Item.ParaNo := ParaNo;
Item.Tag := Tag;
AddItem(Name, Item);
end;
{------------------------------------------------------------------------------}
procedure TCustomRVData.AddHotspotEx(const Name: String;
ImageIndex, HotImageIndex: Integer;
ImageList: TCustomImageList;
ParaNo: Integer);
begin
AddHotspotExTag(Name, ImageIndex, HotImageIndex, ImageList, ParaNo, 0);
end;
{------------------------------------------------------------------------------}
procedure TCustomRVData.AddBulletExTag(const Name: String; ImageIndex: Integer;
ImageList: TCustomImageList;
ParaNo, Tag: Integer);
var Item: TRVBulletItemInfo;
begin
Item := TRVBulletItemInfo.CreateEx(Self, ImageIndex, ImageList, rvvaBaseline);
Item.ParaNo := ParaNo;
Item.Tag := Tag;
AddItem(Name, Item);
end;
{------------------------------------------------------------------------------}
procedure TCustomRVData.AddBulletEx(const Name: String; ImageIndex: Integer;
ImageList: TCustomImageList;
ParaNo: Integer);
begin
AddBulletExTag(Name, ImageIndex, ImageList, ParaNo, 0)
end;
{------------------------------------------------------------------------------}
{ "gr" does not copied, do not free it! }
procedure TCustomRVData.AddPictureExTag(const Name: String; gr: TGraphic;
ParaNo: Integer; VAlign: TRVVAlign;
Tag: Integer);
var Item: TRVGraphicItemInfo;
begin
Item := TRVGraphicItemInfo.CreateEx(Self, gr, VAlign);
Item.ParaNo := ParaNo;
Item.Tag := Tag;
AddItem(Name, Item);
end;
{------------------------------------------------------------------------------}
{ gr does not copied, do not free it! }
procedure TCustomRVData.AddPictureEx(const Name: String; gr: TGraphic;
ParaNo: Integer;
VAlign: TRVVAlign);
begin
AddPictureExTag(Name, gr, ParaNo, VAlign, 0);
end;
{------------------------------------------------------------------------------}
procedure TCustomRVData.AddHotPicture(const Name: String; gr: TGraphic;
ParaNo: Integer; VAlign: TRVVAlign);
begin
AddHotPictureTag(Name, gr, ParaNo, VAlign, 0);
end;
{------------------------------------------------------------------------------}
procedure TCustomRVData.AddHotPictureTag(const Name: String; gr: TGraphic;
ParaNo: Integer; VAlign: TRVVAlign; Tag: Integer);
var Item: TRVHotGraphicItemInfo;
begin
Item := TRVHotGraphicItemInfo.CreateEx(Self, gr, VAlign);
Item.ParaNo := ParaNo;
Item.Tag := Tag;
AddItem(Name, Item);
end;
{------------------------------------------------------------------------------}
{ do not free ctrl yourself! }
procedure TCustomRVData.AddControlExTag(const Name: String; ctrl: TControl;
ParaNo: Integer; VAlign: TRVVAlign;
Tag: Integer);
var Item: TRVControlItemInfo;
begin
Item := TRVControlItemInfo.CreateEx(Self, ctrl, VAlign);
Item.StyleNo := rvsComponent;
Item.ParaNo := ParaNo;
Item.Tag := Tag;
AddItem(Name, Item);
ctrl.Parent := GetParentControl;
end;
{------------------------------------------------------------------------------}
{ do not free ctrl yourself! }
procedure TCustomRVData.AddControlEx(const Name: String; ctrl: TControl;
ParaNo: Integer;
VAlign: TRVVAlign);
begin
AddControlExTag(Name, ctrl, ParaNo, VAlign, 0);
end;
{------------------------------------------------------------------------------}
procedure TCustomRVData.SetAddParagraphMode(AllowNewPara: Boolean);
begin
FAllowNewPara := AllowNewPara;
end;
{------------------------------------------------------------------------------}
procedure TCustomRVData.SetCP(Item: TCustomRVItemInfo; var PrevCP, CP: TRVCPInfo);
begin
if CP=nil then
exit;
CP.Prev := PrevCP;
CP.ItemInfo := Item;
if (PrevCP=nil) then begin // inserting before first, making first
if FirstCP<>nil then
FirstCP.Prev := CP;
CP.Next := FirstCP;
FirstCP := CP;
end
else
CP.Next := PrevCP.Next;
if PrevCP<>nil then
PrevCP.Next := CP;
if CP.Next<>nil then
CP.Next.Prev := CP;
if PrevCP=LastCP then
LastCP := CP;
Item.Checkpoint := CP;
CP := nil;
end;
{------------------------------------------------------------------------------}
procedure TCustomRVData.UnlinkCheckpoint(cp: TRVCPInfo; DecCPCount: Boolean);
begin
if cp<>nil then begin
cp.ItemInfo := nil;
if FirstCP = cp then FirstCP := cp.Next;
if LastCP = cp then LastCP := cp.Prev;
if cp.Prev<>nil then cp.Prev.Next := cp.Next;
if cp.Next<>nil then cp.Next.Prev := cp.Prev;
if DecCPCount then
dec(CPCount);
end;
end;
{------------------------------------------------------------------------------}
procedure TCustomRVData.FreeCheckpoint(var cp: TRVCPInfo; AdjustLinks,DecCPCount: Boolean);
begin
if cp<>nil then begin
if AdjustLinks then
UnlinkCheckpoint(cp,False);
if rvoTagsArePChars in Options then
StrDispose(PChar(cp.Tag));
cp.Free;
cp := nil;
if DecCPCount then
dec(CPCount);
end;
end;
{------------------------------------------------------------------------------}
function TCustomRVData.ShareItems: Boolean;
begin
Result := False;
end;
{------------------------------------------------------------------------------}
function TCustomRVData.CanLoadLayout: Boolean;
begin
Result := False;
end;
{------------------------------------------------------------------------------}
procedure TCustomRVData.DeleteItems(FirstItemNo, Count: Integer);
var i: Integer;
begin
if ShareItems then exit;
if FirstItemNo>=Items.Count then exit;
if FirstItemNo+Count>Items.Count then
Count := Items.Count-FirstItemNo;
Items.BeginUpdate;
try
for i := FirstItemNo to FirstItemNo+Count-1 do
FreeItem(i,False);
for i :=1 to Count do
Items.Delete(FirstItemNo);
finally
Items.EndUpdate;
end;
end;
{------------------------------------------------------------------------------}
procedure TCustomRVData.DeleteSection(const CpName: String);
var startno, endno: Integer;
cp: TRVCPInfo;
begin
if ShareItems then exit;
cp := FirstCP;
startno := -1;
endno := -1;
while cp<>nil do begin
if cp.Name=CpName then begin
startno := Items.IndexOfObject(cp.ItemInfo);
endno := Items.Count-1;
break;
end;
cp := cp.Next;
end;
if startno=-1 then exit;
cp := cp.Next;
while cp<>nil do begin
if cp.Name<>'' then begin
endno := Items.IndexOfObject(cp.ItemInfo)-1;
break;
end;
cp := cp.Next;
end;
DeleteItems(startno, endno-startno+1);
end;
{------------------------------------------------------------------------------}
procedure TCustomRVData.InternalFreeItem(item: TCustomRVItemInfo; Clearing: Boolean);
begin
if Item=nil then
exit;
{$IFNDEF RVDONOTUSELISTS}
DeleteMarkerFromList(item, Clearing);
{$ENDIF}
FreeCheckpoint(Item.Checkpoint, True, True);
if rvoTagsArePChars in Options then
StrDispose(PChar(Item.Tag));
Item.Free;
end;
{------------------------------------------------------------------------------}
procedure TCustomRVData.FreeItem(ItemNo: Integer; Clearing: Boolean);
var item: TCustomRVItemInfo;
s: String;
begin
item := TCustomRVItemInfo(Items.Objects[ItemNo]);
s := Items[ItemNo];
ItemAction(rviaDestroying, item, s, Self);
ControlAction(rvcaDestroy, ItemNo, item);
InternalFreeItem(item, Clearing);
end;
{------------------------------------------------------------------------------}
procedure TCustomRVData.Clear;
var i: Integer;
Clearing: Boolean;
begin
Clearing := rvstClearing in State;
Include(State, rvstClearing);
try
if not ShareItems then begin
Items.BeginUpdate;
for i:=0 to Items.Count-1 do
FreeItem(i,True);
Items.Clear;
Items.EndUpdate;
end;
FreeCheckpoint(NotAddedCP, False, True);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -