Page 1 of 1

Space line example

Posted: Mon Jan 23, 2012 10:05 am
by alexandreq
Hello

I am really lost how to work with TCustomRVParaInfo.

I need to use double line space and could you give me an exemple how to do it and working with TCustomRVParaInfo?

Thanks

Posted: Mon Jan 23, 2012 3:03 pm
by Sergey Tkachenko
Do you need to set double line spacing for selected paragraphs?
Or do you want to generate a document with double line spacing?

Values for double line spacing:
ParaInfo.LineSpacingType = rvlsPercent
ParaInfo.LineSpacing = 200

Posted: Mon Jan 23, 2012 4:27 pm
by alexandreq
Sergey,

That example what you gave me I found. My problem is how to reach this and apply into my DBSRICHView.

Imagine that I have a button on a form, how to do this after clicking on my button? How to trigger everthing? Give me this example, the code inside of a button.

thanks Sergey

Posted: Tue Jan 24, 2012 10:49 am
by Sergey Tkachenko
First, consider using RichViewActions. In this case, you do not need to write any code: just create a button and assign rvActionLineSpacing200 to its Action property, and it works!

If you do not want using RichViewActions, you need to process OnParaStyleConversion event to apply commands to paragraphs.
You can use this demo as a sample:
http://www.trichview.com/forums/viewtopic.php?t=2074

How to add commands for the double and the single line spacings:
1) add new constants having unique values among other PARA_* constants:

Code: Select all

PARA_LINESPACING_DOUBLE = 5;
PARA_LINESPACING_SINGLE = 6;
2) add buttons btnLineSpacingDouble, btnLineSpacingSingle (this demo uses TSpeedButtons). Assign their properties: GroupIndex 5 (it's a coincidence that it equals to the constant above; just choose any value that does not equal to GroupIndex of other buttons), AllowAllUp = True
3) In OnClick of btnLineSpacingDouble:

Code: Select all

ApplyParaStyleConversion(PARA_LINESPACING_DOUBLE)
In OnClick of btnLineSpacingSingle

Code: Select all

ApplyParaStyleConversion(PARA_LINESPACING_SINGLE)
4) Add in TForm1.rveParaStyleConversion, above the line "// add your code here....":

Code: Select all

PARA_LINESPACING_DOUBLE:
  begin
    ParaInfo.LineSpacing := 200;
    ParaInfo.LineSpacingType = rvlsPercent 
  end;
PARA_LINESPACING_SINGLE:
  begin
    ParaInfo.LineSpacing := 100;
    ParaInfo.LineSpacingType = rvlsPercent 
  end;
5) Change TForm1.rveCurParaStyleChanged:

Code: Select all

var pi: TParaInfo;
begin
  pi := rvs.ParaStyles[dbrve.CurParaStyleNo];
  SetAlignmentToUI(pi.Alignment);
  btnLineSpacingDouble.Down := (pi.LineSpacing=200) and (pi.LineSpacingType=rvlsPercent);
  btnLineSpacingSingle.Down := (pi.LineSpacing=100) and (pi.LineSpacingType=rvlsPercent);
end;

Posted: Tue Jan 24, 2012 11:31 am
by alexandreq
Hi Sergey

Thanks for your help once again. This project that I am doing I can't use action.

I was able to use double line space in my code, but I am having a problem.

When I change the space line of my text, the change is not record with my text in the table, and when I open the text once again, it didn't come the way that I have formated, with double line space.

I made a small program with access database, I'd like you to show it and tell me what I am doing wrong.

Another thing, you can see that I have two text in my table, the beatle and the calf. Each one I have a different margins. I'd like you to show me how to make the rulers obay the formatted margins.

This will solve my problem

thanks

Please, get my code from here

http://www.infosoftlanguages.com/arquivos/editorg.zip

Posted: Tue Jan 24, 2012 12:11 pm
by alexandreq
Friend, I got it :))

Thank very much a lot

Now the only problem that I am having is with ruler :cry:

Help me with this please

Posted: Tue Jan 24, 2012 1:50 pm
by alexandreq
Sergey, just one thing:

Why do I need to use OnParaStyleConversion if this way works fine too?

Take a look at this code:

const
PARA_LINESPACING_DOUBLE = 5;
PARA_LINESPACING_SINGLE = 6;

procedure TForm1.FormCreate(Sender: TObject);
begin
Qdocs.Open;
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
RVStyle1.ParaStyles.Items[0].LineSpacing := 150;
RVStyle1.ParaStyles.Items[0].LineSpacingType := rvlsPercent;
DBSRichViewEdit1.RichViewEdit.Format;
DBSRichViewEdit1.RichViewEdit.ApplyParaStyleConversion(PARA_LINESPACING_DOUBLE);
DBSRichViewEdit1.RichViewEdit.DataSource.DataSet.Post;
end;

procedure TForm1.BitBtn2Click(Sender: TObject);
begin
RVStyle1.ParaStyles.Items[0].LineSpacing := 100;
RVStyle1.ParaStyles.Items[0].LineSpacingType := rvlsPercent;
DBSRichViewEdit1.RichViewEdit.Format;
DBSRichViewEdit1.RichViewEdit.ApplyParaStyleConversion(PARA_LINESPACING_SINGLE);
DBSRichViewEdit1.RichViewEdit.DataSource.DataSet.Post;
end;

Posted: Tue Jan 24, 2012 2:10 pm
by Sergey Tkachenko
ApplyParaStyleConversion calls OnParaStyleConversion. Without this event, this method is useless

Posted: Tue Jan 24, 2012 2:16 pm
by Sergey Tkachenko
Direct assigning to ParaStyle.Items[N] changes properties of all paragraphs that use the N-th paragraph style. These paragraphs are not necessary selected, or may be even document does not have such paragraphs at all.

Posted: Wed Jan 25, 2012 10:15 am
by alexandreq
Solved.

You deserve to spend your time here in Brazil.

Our carnival is coming. :D