show linespacing after changing fontname
Posted: Sun Aug 12, 2007 11:26 am
Hello,
I try to affect the linespacing in a rve-memo.
My trials seem to be ok until I change fontname (I mark the text and choose another fontname). Then linespacing (‘afterSpace’) is not shown (in a combobox).
Can someone help me to show ‘afterspace’ after changing fontname (afterspace is the same as before changing)
Code in combobox.click, where I set linespacing (as spaceAfter) and where ‘afterSpace’ is shown if I change paragraph (Absatz):
procedure TForm1.cbZeilenabstandClick(Sender: TObject);
begin
memo.ApplyParaStyleConversion(PARA_LINESPACE);
memo.setfocus;
end;
Content of combobox.Items (cbZeilenabstand.items):
1
1,5
2
…
5
Code in memoCurParaStyleChanged, where afterSpace is set to combobox.text
procedure TForm1.memoCurParaStyleChanged(Sender: TObject);
var x: integer; r,r1,r2: real;
begin
SetAlignmentToUI(rvs.ParaStyles[memo.CurParaStyleNo].Alignment);
x:= rvs.ParaStyles[memo.CurParaStyleNo].SpaceAfter; //I think CurParaStyleNo is the problem
if x= 0 then cbZeilenabstand.Text:= '1'
else if x= round(strTofloat(cmbFontSize.Text)*0.5)then cbZeilenabstand.Text:= '1,5'
else if x= round(strTofloat(cmbFontSize.Text)) then cbZeilenabstand.Text:= '2'
else if x= round(strTofloat(cmbFontSize.Text)*1.5) then cbZeilenabstand.Text:= '2,5'
else if x= round(strTofloat(cmbFontSize.Text)*2) then cbZeilenabstand.Text:= '3'
else if x= round(strTofloat(cmbFontSize.Text)*2.5) then cbZeilenabstand.Text:= '3,5'
else if x= round(strTofloat(cmbFontSize.Text)*3) then cbZeilenabstand.Text:= '4'
else if x= round(strTofloat(cmbFontSize.Text)*3.5) then cbZeilenabstand.Text:= '4,5'
else if x= round(strTofloat(cmbFontSize.Text)*4) then cbZeilenabstand.Text:= '5';
end;
This procedure is needed likewise:
procedure TForm1.memoParaStyleConversion(Sender: TCustomRichViewEdit; StyleNo, UserData: Integer; AppliedToText: Boolean; var NewStyleNo: Integer);
var ParaInfo: TParaInfo;
Tabs: TRVTabInfos;
zabst: integer;
begin
ParaInfo := TParaInfo.Create(nil);
try
ParaInfo.Assign(rvs.ParaStyles[StyleNo]);
case UserData of
PARA_ALIGNMENT: ParaInfo.Alignment := GetAlignmentFromUI;
…
PARA_LINESPACE:
begin
case cbZeilenabstand.ItemIndex of
0: begin //normaler Abstand
ParaInfo.spaceAfter:= 0;
ParaInfo.spaceBefore:= 0;
end;
1: zei_abst:= strTofloat(cmbFontSize.Text)*0.5; //1,5-facher Abstand
2: zei_abst:= strTofloat(cmbFontSize.Text); //2-facher
3: zei_abst:= strTofloat(cmbFontSize.Text)*1.5; //2,5-facher
4: zei_abst:= strTofloat(cmbFontSize.Text)*2 ; //3-facher
5: zei_abst:= strTofloat(cmbFontSize.Text)*2.5; //3,5-facher
6: zei_abst:= strTofloat(cmbFontSize.Text)*3; //4-facher
7: zei_abst:= strTofloat(cmbFontSize.Text)*3.5; //4,5-facher
8: zei_abst:= strTofloat(cmbFontSize.Text)*4; //5-facher
end; // of case
if (cbZeilenabstand.ItemIndex>0) and (cbZeilenabstand.ItemIndex<9) then begin
zabst:= round(zei_abst);
ParaInfo.spaceAfter:= zabst;
end;
end; //of begin
PARA_COLOR: ParaInfo.Background.Color := cd.Color;
end; //of case
NewStyleNo := rvs.ParaStyles.FindSuchStyle(StyleNo,ParaInfo,RVAllParaInfoProperties);
if NewStyleNo=-1 then begin
rvs.ParaStyles.Add;
NewStyleNo := rvs.ParaStyles.Count-1;
rvs.ParaStyles[NewStyleNo].Assign(ParaInfo);
rvs.ParaStyles[NewStyleNo].Standard := False;
end;
finally
ParaInfo.Free;
end;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
const
//rv
rv_MAKEBOLD = 1;
…
rv_NORMAL = 15;
// Parameters for ApplyParaStyleConversion
PARA_ALIGNMENT = 1;
…
PARA_LINESPACE = 6;
//rv-Ende
I try to affect the linespacing in a rve-memo.
My trials seem to be ok until I change fontname (I mark the text and choose another fontname). Then linespacing (‘afterSpace’) is not shown (in a combobox).
Can someone help me to show ‘afterspace’ after changing fontname (afterspace is the same as before changing)
Code in combobox.click, where I set linespacing (as spaceAfter) and where ‘afterSpace’ is shown if I change paragraph (Absatz):
procedure TForm1.cbZeilenabstandClick(Sender: TObject);
begin
memo.ApplyParaStyleConversion(PARA_LINESPACE);
memo.setfocus;
end;
Content of combobox.Items (cbZeilenabstand.items):
1
1,5
2
…
5
Code in memoCurParaStyleChanged, where afterSpace is set to combobox.text
procedure TForm1.memoCurParaStyleChanged(Sender: TObject);
var x: integer; r,r1,r2: real;
begin
SetAlignmentToUI(rvs.ParaStyles[memo.CurParaStyleNo].Alignment);
x:= rvs.ParaStyles[memo.CurParaStyleNo].SpaceAfter; //I think CurParaStyleNo is the problem
if x= 0 then cbZeilenabstand.Text:= '1'
else if x= round(strTofloat(cmbFontSize.Text)*0.5)then cbZeilenabstand.Text:= '1,5'
else if x= round(strTofloat(cmbFontSize.Text)) then cbZeilenabstand.Text:= '2'
else if x= round(strTofloat(cmbFontSize.Text)*1.5) then cbZeilenabstand.Text:= '2,5'
else if x= round(strTofloat(cmbFontSize.Text)*2) then cbZeilenabstand.Text:= '3'
else if x= round(strTofloat(cmbFontSize.Text)*2.5) then cbZeilenabstand.Text:= '3,5'
else if x= round(strTofloat(cmbFontSize.Text)*3) then cbZeilenabstand.Text:= '4'
else if x= round(strTofloat(cmbFontSize.Text)*3.5) then cbZeilenabstand.Text:= '4,5'
else if x= round(strTofloat(cmbFontSize.Text)*4) then cbZeilenabstand.Text:= '5';
end;
This procedure is needed likewise:
procedure TForm1.memoParaStyleConversion(Sender: TCustomRichViewEdit; StyleNo, UserData: Integer; AppliedToText: Boolean; var NewStyleNo: Integer);
var ParaInfo: TParaInfo;
Tabs: TRVTabInfos;
zabst: integer;
begin
ParaInfo := TParaInfo.Create(nil);
try
ParaInfo.Assign(rvs.ParaStyles[StyleNo]);
case UserData of
PARA_ALIGNMENT: ParaInfo.Alignment := GetAlignmentFromUI;
…
PARA_LINESPACE:
begin
case cbZeilenabstand.ItemIndex of
0: begin //normaler Abstand
ParaInfo.spaceAfter:= 0;
ParaInfo.spaceBefore:= 0;
end;
1: zei_abst:= strTofloat(cmbFontSize.Text)*0.5; //1,5-facher Abstand
2: zei_abst:= strTofloat(cmbFontSize.Text); //2-facher
3: zei_abst:= strTofloat(cmbFontSize.Text)*1.5; //2,5-facher
4: zei_abst:= strTofloat(cmbFontSize.Text)*2 ; //3-facher
5: zei_abst:= strTofloat(cmbFontSize.Text)*2.5; //3,5-facher
6: zei_abst:= strTofloat(cmbFontSize.Text)*3; //4-facher
7: zei_abst:= strTofloat(cmbFontSize.Text)*3.5; //4,5-facher
8: zei_abst:= strTofloat(cmbFontSize.Text)*4; //5-facher
end; // of case
if (cbZeilenabstand.ItemIndex>0) and (cbZeilenabstand.ItemIndex<9) then begin
zabst:= round(zei_abst);
ParaInfo.spaceAfter:= zabst;
end;
end; //of begin
PARA_COLOR: ParaInfo.Background.Color := cd.Color;
end; //of case
NewStyleNo := rvs.ParaStyles.FindSuchStyle(StyleNo,ParaInfo,RVAllParaInfoProperties);
if NewStyleNo=-1 then begin
rvs.ParaStyles.Add;
NewStyleNo := rvs.ParaStyles.Count-1;
rvs.ParaStyles[NewStyleNo].Assign(ParaInfo);
rvs.ParaStyles[NewStyleNo].Standard := False;
end;
finally
ParaInfo.Free;
end;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
const
//rv
rv_MAKEBOLD = 1;
…
rv_NORMAL = 15;
// Parameters for ApplyParaStyleConversion
PARA_ALIGNMENT = 1;
…
PARA_LINESPACE = 6;
//rv-Ende