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
show linespacing after changing fontname
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Thanks Sergey.
I think I have found the (my) mistake.
procedure TForm1.memoCurParaStyleChanged(Sender: TObject);
var aa, za: integer;
begin
SetAlignmentToUI(rvs.ParaStyles[memo.CurParaStyleNo].Alignment);
za:= rvs.ParaStyles[memo.CurParaStyleNo].lineSpacing;
aa:= rvs.ParaStyles[memo.CurParaStyleNo].SpaceAfter;
cbZeilenabstand.Text:= ''; //geht auch in Tabellen
if za= StrToInt(cmbFontSize.Text)*8 then cbZeilenabstand.Text:= '0,5' //optisch gesehen
else if za= StrToInt(cmbFontSize.Text)*10 then cbZeilenabstand.Text:= '1' //Standard
else if za= StrToInt(cmbFontSize.Text)*12 then cbZeilenabstand.Text:= '1,5'
else if za= StrToInt(cmbFontSize.Text)*15 then cbZeilenabstand.Text:= '2'
else if za= StrToInt(cmbFontSize.Text)*17 then cbZeilenabstand.Text:= '2,5'
else if za= StrToInt(cmbFontSize.Text)*20 then cbZeilenabstand.Text:= '3'
else cbZeilenabstand.Text:= '1';
cbAbsatzAbstand.Text:= '';
if aa=0 then cbAbsatzAbstand.Text:= '1'
else if aa= trunc(strTofloat(cmbFontSize.Text)*0.5)then cbAbsatzAbstand.Text:= '1,5'
else if aa= trunc(strTofloat(cmbFontSize.Text)) then cbAbsatzAbstand.Text:= '2'
else if aa= trunc(strTofloat(cmbFontSize.Text)*1.5) then cbAbsatzAbstand.Text:= '2,5'
else if aa= trunc(strTofloat(cmbFontSize.Text)*2) then cbAbsatzAbstand.Text:= '3'
else if aa= trunc(strTofloat(cmbFontSize.Text)*2.5) then cbAbsatzAbstand.Text:= '3,5'
else if aa= trunc(strTofloat(cmbFontSize.Text)*3) then cbAbsatzAbstand.Text:= '4'
else if aa= trunc(strTofloat(cmbFontSize.Text)*3.5) then cbAbsatzAbstand.Text:= '4,5'
else if aa= trunc(strTofloat(cmbFontSize.Text)*4) then cbAbsatzAbstand.Text:= '5'
else cbAbsatzAbstand.Text:= '1';
end;
procedure TForm1.memoParaStyleConversion(Sender: TCustomRichViewEdit; StyleNo, UserData: Integer; AppliedToText: Boolean; var NewStyleNo: Integer);
var ParaInfo: TParaInfo;
Tabs: TRVTabInfos;
za, aa: integer;
begin
ParaInfo := TParaInfo.Create(nil);
try
ParaInfo.Assign(rvs.ParaStyles[StyleNo]);
case UserData of
PARA_ALIGNMENT: ParaInfo.Alignment := GetAlignmentFromUI;
...
PARA_LINESPACE:
begin //in Memo.Click ebenfalls MemoCurParaStyleChanged(Self); setzen
case cbZeilenAbstand.ItemIndex of //geht auch in Tabellen
0: za:= StrToInt(cmbFontSize.Text)*8; //optisch 0,5-facher Abstand
1: za:= StrToInt(cmbFontSize.Text)*10; //1-facher (Standard)
2: za:= StrToInt(cmbFontSize.Text)*12; //1,5-facher
3: za:= StrToInt(cmbFontSize.Text)*15; //2-facher
4: za:= StrToInt(cmbFontSize.Text)*17; //2,5-facher
5: za:= StrToInt(cmbFontSize.Text)*20; //3-facher
end; // of case
if cbZeilenAbstand.ItemIndex<6 then ParaInfo.linespacing:= za;
end;
PARA_PARAGRAPHSPACE:
begin
case cbAbsatzAbstand.ItemIndex of
0: begin
ParaInfo.spaceAfter:= 0; //Standard
ParaInfo.spaceBefore:= 0;
end;
1: aa:= trunc(strTofloat(cmbFontSize.Text)*0.5); //1,5- facher Abstand
2: aa:= trunc(strTofloat(cmbFontSize.Text)); //2-facher
3: aa:= trunc(strTofloat(cmbFontSize.Text)*1.5); //2,5-facher
4: aa:= trunc(strTofloat(cmbFontSize.Text)*2); //3-facher
5: aa:= trunc(strTofloat(cmbFontSize.Text)*2.5); //3,5-facher
6: aa:= trunc(strTofloat(cmbFontSize.Text)*3); //4-facher
7: aa:= trunc(strTofloat(cmbFontSize.Text)*3.5); //4,5-facher
8: aa:= trunc(strTofloat(cmbFontSize.Text)*4); //5-facher
end; // of case
if (cbAbsatzAbstand.ItemIndex>0) then ParaInfo.spaceAfter:= aa;
end; //of begin
PARA_COLOR: ParaInfo.Background.Color := cd.Color;
end; //o case
...
end;
I think I have found the (my) mistake.
procedure TForm1.memoCurParaStyleChanged(Sender: TObject);
var aa, za: integer;
begin
SetAlignmentToUI(rvs.ParaStyles[memo.CurParaStyleNo].Alignment);
za:= rvs.ParaStyles[memo.CurParaStyleNo].lineSpacing;
aa:= rvs.ParaStyles[memo.CurParaStyleNo].SpaceAfter;
cbZeilenabstand.Text:= ''; //geht auch in Tabellen
if za= StrToInt(cmbFontSize.Text)*8 then cbZeilenabstand.Text:= '0,5' //optisch gesehen
else if za= StrToInt(cmbFontSize.Text)*10 then cbZeilenabstand.Text:= '1' //Standard
else if za= StrToInt(cmbFontSize.Text)*12 then cbZeilenabstand.Text:= '1,5'
else if za= StrToInt(cmbFontSize.Text)*15 then cbZeilenabstand.Text:= '2'
else if za= StrToInt(cmbFontSize.Text)*17 then cbZeilenabstand.Text:= '2,5'
else if za= StrToInt(cmbFontSize.Text)*20 then cbZeilenabstand.Text:= '3'
else cbZeilenabstand.Text:= '1';
cbAbsatzAbstand.Text:= '';
if aa=0 then cbAbsatzAbstand.Text:= '1'
else if aa= trunc(strTofloat(cmbFontSize.Text)*0.5)then cbAbsatzAbstand.Text:= '1,5'
else if aa= trunc(strTofloat(cmbFontSize.Text)) then cbAbsatzAbstand.Text:= '2'
else if aa= trunc(strTofloat(cmbFontSize.Text)*1.5) then cbAbsatzAbstand.Text:= '2,5'
else if aa= trunc(strTofloat(cmbFontSize.Text)*2) then cbAbsatzAbstand.Text:= '3'
else if aa= trunc(strTofloat(cmbFontSize.Text)*2.5) then cbAbsatzAbstand.Text:= '3,5'
else if aa= trunc(strTofloat(cmbFontSize.Text)*3) then cbAbsatzAbstand.Text:= '4'
else if aa= trunc(strTofloat(cmbFontSize.Text)*3.5) then cbAbsatzAbstand.Text:= '4,5'
else if aa= trunc(strTofloat(cmbFontSize.Text)*4) then cbAbsatzAbstand.Text:= '5'
else cbAbsatzAbstand.Text:= '1';
end;
procedure TForm1.memoParaStyleConversion(Sender: TCustomRichViewEdit; StyleNo, UserData: Integer; AppliedToText: Boolean; var NewStyleNo: Integer);
var ParaInfo: TParaInfo;
Tabs: TRVTabInfos;
za, aa: integer;
begin
ParaInfo := TParaInfo.Create(nil);
try
ParaInfo.Assign(rvs.ParaStyles[StyleNo]);
case UserData of
PARA_ALIGNMENT: ParaInfo.Alignment := GetAlignmentFromUI;
...
PARA_LINESPACE:
begin //in Memo.Click ebenfalls MemoCurParaStyleChanged(Self); setzen
case cbZeilenAbstand.ItemIndex of //geht auch in Tabellen
0: za:= StrToInt(cmbFontSize.Text)*8; //optisch 0,5-facher Abstand
1: za:= StrToInt(cmbFontSize.Text)*10; //1-facher (Standard)
2: za:= StrToInt(cmbFontSize.Text)*12; //1,5-facher
3: za:= StrToInt(cmbFontSize.Text)*15; //2-facher
4: za:= StrToInt(cmbFontSize.Text)*17; //2,5-facher
5: za:= StrToInt(cmbFontSize.Text)*20; //3-facher
end; // of case
if cbZeilenAbstand.ItemIndex<6 then ParaInfo.linespacing:= za;
end;
PARA_PARAGRAPHSPACE:
begin
case cbAbsatzAbstand.ItemIndex of
0: begin
ParaInfo.spaceAfter:= 0; //Standard
ParaInfo.spaceBefore:= 0;
end;
1: aa:= trunc(strTofloat(cmbFontSize.Text)*0.5); //1,5- facher Abstand
2: aa:= trunc(strTofloat(cmbFontSize.Text)); //2-facher
3: aa:= trunc(strTofloat(cmbFontSize.Text)*1.5); //2,5-facher
4: aa:= trunc(strTofloat(cmbFontSize.Text)*2); //3-facher
5: aa:= trunc(strTofloat(cmbFontSize.Text)*2.5); //3,5-facher
6: aa:= trunc(strTofloat(cmbFontSize.Text)*3); //4-facher
7: aa:= trunc(strTofloat(cmbFontSize.Text)*3.5); //4,5-facher
8: aa:= trunc(strTofloat(cmbFontSize.Text)*4); //5-facher
end; // of case
if (cbAbsatzAbstand.ItemIndex>0) then ParaInfo.spaceAfter:= aa;
end; //of begin
PARA_COLOR: ParaInfo.Background.Color := cd.Color;
end; //o case
...
end;