📄 labelitem.pas
字号:
{------------------------------------------------------------------------------}
function TRVLabelItemInfo.GetBoolValueEx(Prop: TRVItemBoolPropertyEx;
RVStyle: TRVStyle): Boolean;
begin
case Prop of
rvbpJump, rvbpAllowsFocus,rvbpXORFocus:
Result := RVStyle.TextStyles[TextStyleNo].Jump;
rvbpHotColdJump:
Result := RVStyle.TextStyles[TextStyleNo].Jump and
RVStyle.StyleHoverSensitive(StyleNo);
rvbpPrintToBMP:
Result := False;
else
Result := inherited GetBoolValueEx(Prop, RVStyle);
end;
end;
{------------------------------------------------------------------------------}
function TRVLabelItemInfo.GetBoolValue(Prop: TRVItemBoolProperty): Boolean;
begin
case Prop of
rvbpAlwaysInText:
Result := True;
rvbpDrawingChangesFont:
Result := True;
rvbpSwitchToAssStyleNo:
Result := not ProtectTextStyleNo;
else
Result := inherited GetBoolValue(Prop);
end;
end;
{------------------------------------------------------------------------------}
function TRVLabelItemInfo.GetDescent: Integer;
begin
Result := Descend;
end;
{------------------------------------------------------------------------------}
function TRVLabelItemInfo.GetHeight: Integer;
begin
Result := Height;
end;
{------------------------------------------------------------------------------}
function TRVLabelItemInfo.GetWidth: Integer;
begin
Result := Width;
end;
{------------------------------------------------------------------------------}
function TRVLabelItemInfo.GetMinWidth(sad: PRVScreenAndDevice; Canvas: TCanvas; RVData: TPersistent): Integer;
begin
Result := Width;
if MinWidth>Result then
Result := MinWidth;
if Sad<>nil then
Result := MulDiv(Result, sad.ppixDevice, sad.ppixScreen);
end;
{------------------------------------------------------------------------------}
procedure TRVLabelItemInfo.SaveRVF(Stream: TStream; RVData: TPersistent;
ItemNo, ParaNo: Integer; const Name: String; Part: TRVMultiDrawItemPart;
ForceSameAsPrev: Boolean);
begin
// if you want to modify saving/loading, modify
// 1) second parameter in header - number of additional lines
// 2) lines after header
// Do not change other parameters in header
RVFWriteLine(Stream,
Format('%d %d %s %d %d %s %s',
[StyleNo, 6+GetRVFExtraPropertyCount {Line count after header},
RVFItemSavePara(ParaNo, TCustomRVData(RVData), ForceSameAsPrev),
Byte(RVFGetItemOptions(ItemOptions, ForceSameAsPrev)) and RVItemOptionsMask,
0 {text mode saving},
RVFSaveTag(rvoTagsArePChars in TCustomRVData(RVData).Options,Tag),
SaveRVFHeaderTail(RVData)]));
// lines after header
RVFWriteLine(Stream, Text);
RVFWriteLine(Stream, IntToStr(TextStyleNo));
RVFWriteLine(Stream, IntToStr(MinWidth));
RVFWriteLine(Stream, IntToStr(ord(Alignment)));
if ProtectTextStyleNo then
RVFWriteLine(Stream, 'protect')
else
RVFWriteLine(Stream, 'no-protect');
RVFWriteLine(Stream, Name);
SaveRVFExtraProperties(Stream);
end;
{------------------------------------------------------------------------------}
function TRVLabelItemInfo.ReadRVFLine(const s: String; RVData: TPersistent;
ReadType, LineNo, LineCount: Integer; var Name: String;
var ReadMode: TRVFReadMode; var ReadState: TRVFReadState): Boolean;
begin
case LineNo of
0:
Text := s;
1:
begin
TextStyleNo := StrToInt(s);
RVStyle := TCustomRVData(RVData).GetRVStyle;
end;
2:
MinWidth := StrToInt(s);
3:
Alignment := TAlignment(StrToInt(s));
4:
ProtectTextStyleNo := s='protect';
5:
Name := s;
else
SetExtraPropertyFromRVFStr(s);
end;
Result := True;
end;
{------------------------------------------------------------------------------}
procedure TRVLabelItemInfo.MarkStylesInUse(Data: TRVDeleteUnusedStylesData);
begin
inherited MarkStylesInUse(Data);
Data.UsedTextStyles[TextStyleNo] := 1;
end;
{------------------------------------------------------------------------------}
procedure TRVLabelItemInfo.UpdateStyles(Data: TRVDeleteUnusedStylesData);
begin
inherited UpdateStyles(Data);
dec(TextStyleNo,Data.UsedTextStyles[TextStyleNo]-1);
end;
{------------------------------------------------------------------------------}
procedure TRVLabelItemInfo.ApplyStyleConversion(RVData: TPersistent;
ItemNo, UserData: Integer);
begin
if ProtectTextStyleNo then
exit;
TCustomRVFormattedData(RVData).DoCurrentTextStyleConversion(TextStyleNo, ParaNo,
ItemNo, UserData, False);
UpdateMe;
end;
{------------------------------------------------------------------------------}
{$IFNDEF RVDONOTUSERTF}
procedure TRVLabelItemInfo.SaveRTF(Stream: TStream; const Path: String;
RVData: TPersistent; ItemNo: Integer; const Name: String; TwipsPerPixel: Double;
Level: Integer; ColorList: TRVColorList; StyleToFont,
ListOverrideOffsetsList1, ListOverrideOffsetsList2: TRVIntegerList;
FontTable: TRVList);
begin
RVFWrite(Stream, RVMakeRTFStr(Text, False, True));
end;
{$ENDIF}
{------------------------------------------------------------------------------}
{$IFNDEF RVDONOTUSEHTML}
procedure TRVLabelItemInfo.SaveToHTML(Stream: TStream; RVData: TPersistent;
ItemNo: Integer; const Text, Path, imgSavePrefix: String;
var imgSaveNo: Integer; CurrentFileColor: TColor;
SaveOptions: TRVSaveOptions; UseCSS: Boolean; Bullets: TRVList);
begin
RVFWrite(Stream, RV_MakeHTMLStr(Self.Text, False));
end;
{$ENDIF}
{------------------------------------------------------------------------------}
function TRVLabelItemInfo.AsText(LineWidth: Integer; RVData: TPersistent;
const Text, Path: String; TextOnly, Unicode: Boolean): String;
begin
Result := Self.Text;
end;
{------------------------------------------------------------------------------}
procedure TRVLabelItemInfo.Inserted(RVData: TObject; ItemNo: Integer);
begin
if RVData<>nil then begin
RVStyle := TCustomRVData(RVData).GetRVStyle;
FCanUseCustomPPI := rvflCanUseCustomPPI in TCustomRVData(RVData).Flags;
end;
end;
{------------------------------------------------------------------------------}
procedure TRVLabelItemInfo.Execute(RVData: TPersistent);
begin
if RVData is TCustomRVFormattedData then begin
if GetBoolValueEx(rvbpJump, TCustomRVData(RVData).GetRVStyle) then
TCustomRVFormattedData(RVData).DoJump(JumpID+
TCustomRVFormattedData(RVData).FirstJumpNo)
end;
end;
{------------------------------------------------------------------------------}
procedure TRVLabelItemInfo.SetMinWidth(const Value: Integer);
begin
if FMinWidth<>Value then begin
FMinWidth := Value;
UpdateMe;
end;
end;
{------------------------------------------------------------------------------}
procedure TRVLabelItemInfo.SetAlignment(const Value: TAlignment);
begin
FAlignment := Value;
end;
{------------------------------------------------------------------------------}
procedure TRVLabelItemInfo.OnDocWidthChange(DocWidth: Integer;
dli: TRVDrawLineInfo; Printing: Boolean; Canvas: TCanvas;
RVData: TPersistent; sad: PRVScreenAndDevice; var HShift, Desc: Integer;
NoCaching, Reformatting: Boolean);
begin
inherited;
Desc := GetDescent;
end;
{------------------------------------------------------------------------------}
function TRVLabelItemInfo.MouseMove(Shift: TShiftState; X, Y,
ItemNo: Integer; RVData: TObject): Boolean;
begin
Result := inherited MouseMove(Shift, X, Y, ItemNo, RVData);
if Cursor<>crDefault then begin
TCustomRVFormattedData(RVData).SetCursor(Cursor);
Result := True;
end;
end;
{------------------------------------------------------------------------------}
function TRVLabelItemInfo.GetAssociatedTextStyleNo: Integer;
begin
Result := TextStyleNo;
end;
{------------------------------------------------------------------------------}
procedure TRVLabelItemInfo.SetAssociatedTextStyleNo(Value: Integer);
begin
TextStyleNo := Value;
end;
initialization
RegisterRichViewItemClass(rvsLabel, TRVLabelItemInfo);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -