📄 itemproprvfrm.pas
字号:
try
if Filter<>'' then
opd.Filter := Filter;
if opd.Execute then begin
img.Picture.LoadFromFile(opd.FileName);
img.Stretch := (img.Picture.Graphic.Width>img.Width) or (img.Picture.Graphic.Height>img.Height);
end;
finally
SetControlCaption(_lblDefSize, Format(RVA_GetS(rvam_ip_DefaultSize), [img.Picture.Graphic.Width, img.Picture.Graphic.Height]));
_gbTransp.Visible := img.Picture.Graphic is TBitmap;
opd.Free;
end;
end;
procedure TfrmRVItemProp.cmbBreakColorColorChange(Sender: TObject);
begin
_cmbWidth.Invalidate;
end;
procedure TfrmRVItemProp.FormCreate(Sender: TObject);
begin
_gbTransp := gbTransp;
_gbSize := gbSize;
_gbCellBorder := gbCellBorder;
_cbTransp := cbTransp;
_cbCellWidth := cbCellWidth;
_cbCellHeight := cbCellHeight;
_cbNoSplit := cbNoSplit;
_cmbAlignTo := cmbAlignTo;
_cmbVShiftType := cmbVShiftType;
_cmbWType := cmbWType;
_cmbHType := cmbHType;
_cmbWidth := cmbWidth;
_cmbTWType := cmbTWType;
_cmbCellBWType := cmbCellBWType;
_pc := pc;
_tsImage := tsImage;
_tsImgLayout := tsImgLayout;
_tsBreak := tsBreak;
_tsTable := tsTable;
_tsCells := tsCells;
_tsRows := tsRows;
_lblDefSize := lblDefSize;
_lblCellBorderColor := lblCellBorderColor;
_lblCellBorderLightColor := lblCellBorderLightColor;
_txtAlt := txtAlt;
inherited;
{$IFDEF RICHVIEWDEF6}
img.Proportional := True;
{$ENDIF}
end;
procedure TfrmRVItemProp.SetTable(table: TRVTableItemInfo;
TableOnly: Boolean);
var r,c,sr,sc,rs,cs: Integer;
rowselected, firstrow: Boolean;
EditedCell, FirstCell, CurCell: TRVTableCellData;
begin
HelpContext := 91000;
_pc.HandleNeeded;
HideTabSheet(_tsBreak);
HideTabSheet(_tsImage);
HideTabSheet(_tsImgLayout);
if TableOnly then begin
HideTabSheet(_tsCells);
HideTabSheet(_tsRows);
end;
SetPageControlActivePage(_pc, _tsTable);
if table.BestWidth>0 then begin
SetXBoxItemIndex(_cmbTWType, 1);
seTableWidth.Value := table.BestWidth;
end
else if table.BestWidth<0 then begin
SetXBoxItemIndex(_cmbTWType, 0);
seTableWidth.Value := -table.BestWidth;
end;
SetCheckBoxChecked(_cbNoSplit, not (rvtoRowsSplit in table.PrintOptions));
seHRC.Value := table.HeadingRowCount;
cmbTableColor.ChosenColor := table.Color;
seCellPadding.Value := table.CellPadding;
CellHSpacing := table.CellHSpacing;
CellVSpacing := table.CellVSpacing;
BorderHSpacing := table.BorderHSpacing;
BorderVSpacing := table.BorderVSpacing;
if (CellHSpacing=CellVSpacing) and
(BorderHSpacing=BorderVSpacing) and
(BorderHSpacing=CellHSpacing) then
seCellSpacing.Value := BorderHSpacing;
BorderWidth := table.BorderWidth;
BorderStyle := table.BorderStyle;
BorderColorD := table.BorderColor;
BorderColorL := table.BorderLightColor;
CellBorderWidth := table.CellBorderWidth;
CellBorderColorD := table.CellBorderColor;
CellBorderColorL := table.CellBorderLightColor;
CellBorderStyle := table.CellBorderStyle;
if table.BackgroundImage=nil then
TableBackgroundImage := nil
else begin
try
TableBackgroundImage := RV_CreateGraphics(TGraphicClass(table.BackgroundImage.ClassType));
TableBackgroundImage.Assign(table.BackgroundImage);
except;
end;
end;
TableBackgroundStyle := table.BackgroundStyle;
if TableOnly then
exit;
if not table.GetNormalizedSelectionBounds(True, sr,sc,cs,rs) then begin
HideTabSheet(_tsCells);
HideTabSheet(_tsRows);
exit;
end;
if table.GetEditedCell(r,c)<>nil then
EditedCell := table.Cells[r,c]
else
EditedCell := nil;
firstrow := True;
FirstCell := nil;
FDefCellColorD := True;
FDefCellColorL := True;
if EditedCell<>nil then begin
CellBackgroundStyle := EditedCell.BackgroundStyle;
if EditedCell.BackgroundImage=nil then
CellBackgroundImage := nil
else begin
try
CellBackgroundImage := RV_CreateGraphics(TGraphicClass(EditedCell.BackgroundImage.ClassType));
CellBackgroundImage.Assign(EditedCell.BackgroundImage);
except;
end;
end;
end;
for r := 0 to table.Rows.Count-1 do begin
rowselected := False;
for c := 0 to table.Rows[r].Count-1 do
if (table.Cells[r,c]<>nil) and
(table.IsCellSelected(r,c) or (EditedCell=table.Cells[r,c])) then begin
rowselected := True;
if CellBackgroundImage=nil then begin
CellBackgroundStyle := table.Cells[r,c].BackgroundStyle;
if table.Cells[r,c].BackgroundImage=nil then
CellBackgroundImage := nil
else begin
try
CellBackgroundImage := RV_CreateGraphics(TGraphicClass(table.Cells[r,c].BackgroundImage.ClassType));
CellBackgroundImage.Assign(table.Cells[r,c].BackgroundImage);
except;
end;
end;
end;
if FirstCell=nil then begin
FirstCell := table.Cells[r,c];
if FirstCell.BestWidth>0 then begin
seCellBestWidth.Value := FirstCell.BestWidth;
SetXBoxItemIndex(_cmbCellBWType, 1);
end
else if FirstCell.BestWidth<0 then begin
seCellBestWidth.Value := -FirstCell.BestWidth;
SetXBoxItemIndex(_cmbCellBWType, 0);
end;
if FirstCell.BestHeight>0 then
seCellBestHeight.Value := FirstCell.BestHeight;
cmbCellColor.ChosenColor := FirstCell.Color;
rgCellVAlign.ItemIndex := ord(FirstCell.VAlign);
btnLeft.Down := FirstCell.VisibleBorders.Left;
btnTop.Down := FirstCell.VisibleBorders.Top;
btnRight.Down := FirstCell.VisibleBorders.Right;
btnBottom.Down := FirstCell.VisibleBorders.Bottom;
cmbCellBorderColor.ChosenColor := FirstCell.BorderColor;
cmbCellBorderLightColor.ChosenColor := FirstCell.BorderLightColor;
FDefCellColorD := FirstCell.BorderColor=clNone;
FDefCellColorL := FirstCell.BorderLightColor=clNone;
end
else begin
CurCell := table.Cells[r,c];
if CurCell.BestWidth<>FirstCell.BestWidth then
SetCheckBoxState(_cbCellWidth, cbGrayed);
if CurCell.BestHeight<>FirstCell.BestHeight then
SetCheckBoxState(_cbCellHeight, cbGrayed);
if CurCell.Color<>FirstCell.Color then
cmbCellColor.Indeterminate := True;
if CurCell.VAlign<>FirstCell.VAlign then
rgCellVAlign.ItemIndex := -1;
if CurCell.VisibleBorders.Left<>FirstCell.VisibleBorders.Left then begin
btnLeft.Down := False;
btnLeft.Flat := True;
end;
if CurCell.VisibleBorders.Top<>FirstCell.VisibleBorders.Top then begin
btnTop.Down := False;
btnTop.Flat := True;
end;
if CurCell.VisibleBorders.Right<>FirstCell.VisibleBorders.Right then begin
btnRight.Down := False;
btnRight.Flat := True;
end;
if CurCell.VisibleBorders.Bottom<>FirstCell.VisibleBorders.Bottom then begin
btnBottom.Down := False;
btnBottom.Flat := True;
end;
if CurCell.BorderColor<>FirstCell.BorderColor then begin
cmbCellBorderColor.Indeterminate := True;
FDefCellColorD := False;
end;
if CurCell.BorderLightColor<>FirstCell.BorderLightColor then begin
cmbCellBorderLightColor.Indeterminate := True;
FDefCellColorL := False;
end;
end;
end;
if rowselected then
if firstrow then begin
firstrow := False;
case table.Rows[r].VAlign of
rvcMiddle:
rgRowVAlign.ItemIndex := 1;
rvcBottom:
rgRowVAlign.ItemIndex := 2;
else
rgRowVAlign.ItemIndex := 0;
end
end
else begin
if ((rgRowVAlign.ItemIndex=0) and not (table.Rows[r].VAlign in [rvcVDefault, rvcTop])) or
((rgRowVAlign.ItemIndex=1) and (table.Rows[r].VAlign<>rvcMiddle)) or
((rgRowVAlign.ItemIndex=2) and (table.Rows[r].VAlign<>rvcBottom)) then
rgRowVAlign.ItemIndex := -1;
end;
end;
UpdateCellBorders;
end;
procedure TfrmRVItemProp.GetTable(rve: TCustomRichViewEdit; table: TRVTableItemInfo);
var Data, ItemNo: Integer;
var r,c,sr,sc,rs,cs,v: Integer;
rowselected: Boolean;
EditedCell: TRVTableCellData;
vl, vt, vr, vb: Boolean;
function SetVB(def: Boolean; btn: TSpeedButton): Boolean;
begin
if btn.Flat then
Result := def
else
Result := btn.Down;
end;
begin
ItemNo := table.GetMyItemNo;
rve.BeginItemModify(ItemNo, Data);
if seTableWidth.Indeterminate or (seTableWidth.AsInteger=0) then
table.BestWidth := 0
else if GetXBoxItemIndex(_cmbTWType) = 0 then begin
if seTableWidth.AsInteger>100 then
table.BestWidth := -100
else
table.BestWidth := - seTableWidth.AsInteger;
end
else if GetXBoxItemIndex(_cmbTWType) = 1 then
table.BestWidth := seTableWidth.AsInteger;
if not cmbTableColor.Indeterminate then
table.Color := cmbTableColor.ChosenColor;
if not seCellPadding.Indeterminate then
table.CellPadding := seCellPadding.AsInteger;
table.CellHSpacing := CellHSpacing;
table.CellVSpacing := CellVSpacing;
table.BorderHSpacing := BorderHSpacing;
table.BorderVSpacing := BorderVSpacing;
table.BorderWidth := BorderWidth;
table.BorderStyle := BorderStyle;
table.BorderColor := BorderColorD;
table.BorderLightColor := BorderColorL;
table.CellBorderWidth := CellBorderWidth;
table.CellBorderColor := CellBorderColorD;
table.CellBorderLightColor := CellBorderColorL;
table.CellBorderStyle := CellBorderStyle;
if TableBackgroundChanged then begin
table.BackgroundStyle := TableBackgroundStyle;
table.BackgroundImage := TableBackgroundImage;
end;
if GetCheckBoxChecked(_cbNoSplit) then
table.PrintOptions := table.PrintOptions - [rvtoRowsSplit]
else
table.PrintOptions := table.PrintOptions + [rvtoRowsSplit];
table.HeadingRowCount := seHRC.AsInteger;
if IsTabSheetVisible(_tsRows) and (rgRowVAlign.ItemIndex>=0) then begin
if not table.GetNormalizedSelectionBounds(True, sr,sc,cs,rs) then
exit;
if table.GetEditedCell(r,c)<>nil then
EditedCell := table.Cells[r,c]
else
EditedCell := nil;
for r := 0 to table.Rows.Count-1 do begin
rowselected := False;
for c := 0 to table.Rows[r].Count-1 do
if (table.Cells[r,c]<>nil) and
(table.IsCellSelected(r,c) or (EditedCell=table.Cells[r,c])) then begin
rowselected := True;
if CellBackgroundChanged then begin
table.SetCellBackgroundStyle(CellBackgroundStyle, r,c);
table.SetCellBackgroundImage(CellBackgroundImage, r,c);
end;
if GetCheckBoxState(_cbCellWidth)=cbChecked then begin
if seCellBestWidth.Indeterminate then
v := 0
else if GetXBoxItemIndex(_cmbCellBWType)=0 then begin
v := -seCellBestWidth.AsInteger;
if v<-100 then
v := -100;
end
else
v := seCellBestWidth.AsInteger;
table.SetCellBestWidth(v, r, c);
end;
if GetCheckBoxState(_cbCellHeight)=cbChecked then
if seCellBestHeight.Indeterminate then
table.SetCellBestHeight(0, r, c)
else
table.SetCellBestHeight(seCellBestHeight.AsInteger, r, c);
if not cmbCellColor.Indeterminate then
table.SetCellColor(cmbCellColor.ChosenColor, r,c);
if rgCellVAlign.ItemIndex>=0 then
table.SetCellVAlign(TRVCellVAlign(rgCellVAlign.ItemIndex), r, c);
if _gbCellBorder.Visible then begin
vl := SetVB(table.Cells[r,c].VisibleBorders.Left, btnLeft);
vt := SetVB(table.Cells[r,c].VisibleBorders.Top, btnTop);
vr := SetVB(table.Cells[r,c].VisibleBorders.Right, btnRight);
vb := SetVB(table.Cells[r,c].VisibleBorders.Bottom, btnBottom);
table.SetCellVisibleBorders(vl,vt,vr,vb, r, c);
if cmbCellBorderColor.Visible and not cmbCellBorderColor.Indeterminate then
if cmbCellBorderColor.ChosenColor=cmbCellBorderColor.AutoColor then
table.SetCellBorderColor(clNone, r,c)
else
table.SetCellBorderColor(cmbCellBorderColor.ChosenColor, r,c);
if cmbCellBorderLightColor.Visible and not cmbCellBorderLightColor.Indeterminate then
if cmbCellBorderLightColor.ChosenColor=cmbCellBorderLightColor.AutoColor then
table.SetCellBorderLightColor(clNone, r,c)
else
table.SetCellBorderLightColor(cmbCellBorderLightColor.ChosenColor, r,c);
end;
end;
if rowselected then
case rgRowVAlign.ItemIndex of
0:
table.Rows[r].VAlign := rvcTop;
1:
table.Rows[r].VAlign := rvcMiddle;
2:
table.Rows[r].VAlign := rvcBottom;
end;
end;
end;
rve.EndItemModify(ItemNo, Data);
rve.Change;
end;
procedure TfrmRVItemProp.seTableWidthChange(Sender: TObject);
begin
if not Visible then
exit;
if not seTableWidth.Indeterminate and (GetXBoxItemIndex(_cmbTWType)<0) then
SetXBoxItemIndex(_cmbTWType, 1);
end;
procedure TfrmRVItemProp.btnSpacingClick(Sender: TObject);
var frm:TfrmRVSpacing;
BHS, CHS, BVS, CVS: Integer;
UBHS, UCHS, UBVS, UCVS: Boolean;
begin
frm := TfrmRVSpacing.Create(Application);
try
frm.SetValues(BorderHSpacing, CellHSpacing, BorderVSpacing, CellVSpacing,
True,True,True,True);
if frm.ShowModal=mrOk then begin
frm.GetValues(BHS, CHS, BVS, CVS, UBHS, UCHS, UBVS, UCVS);
if UBHS then
BorderHSpacing := BHS;
if UBVS then
BorderVSpacing := BVS;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -