Style woes

General TRichView support forum. Please post your questions here
Post Reply
shoebuddy
Posts: 33
Joined: Thu Sep 10, 2015 5:09 pm

Style woes

Post by shoebuddy »

I don't understand what I'm doing wrong. I have set my RVStyle single item to have the font Times New Roman size 12. But every time I start a new note: the style is calibri 11?????

How to I initiate the editor so every note starts out Times New Roman 12?
Sergey Tkachenko
Site Admin
Posts: 17571
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

How do you start a new note?
Do you use RichViewActions?
Do you use StyleTemplates (is rve.UseStyleTemplates True of False)
shoebuddy
Posts: 33
Joined: Thu Sep 10, 2015 5:09 pm

Post by shoebuddy »

I'm using a db version and solved the problem by not using a template
shoebuddy
Posts: 33
Joined: Thu Sep 10, 2015 5:09 pm

Post by shoebuddy »

I set it to false.
Sergey Tkachenko
Site Admin
Posts: 17571
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Actually, in all cases, the default font is defined in RVStyle.TextStyles[0].

When using StyleTemplates, the proper way for implementing New command includes resetting properties of RVStyle.TextStyles[0] to values defined in "Normal" style template. TrvActionNew does it automatically. Without RichViewActions, implementation is shown in Demos\DelphiUnicode\Editors\StyleTemplates\

But even if you do not use StyleTemplates, it's normally not enough to define properties of RVStyle.TextStyles[0] one time. Your editor can load RVF documents (from DB or file), and collections of styles will be replaced.
For TDBRichViewEdit, you can set default text style in OnNewDocument event:

Code: Select all

procedure TForm1.DBRichViewEdit1NewDocument(Sender: TObject);
var RVStyle: TRVStyle;
begin
  RVStyle := (Sender as TCustomRichView).Style;
  RVStyle.TextStyles.Clear;
  RVStyle.ParaStyles.Clear;
  RVStyle.ListStyles.Clear;
  with RVStyle.TextStyles.Add do
  begin
    FontName := 'Times New Roman';
    Size := 12;
  end;
  RVStyle.ParaStyles.Add;
end;
shoebuddy
Posts: 33
Joined: Thu Sep 10, 2015 5:09 pm

Post by shoebuddy »

Thanks!
Post Reply