Clear RichViewEdit completely

General TRichView support forum. Please post your questions here
Post Reply
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Clear RichViewEdit completely

Post by Marsianin »

Just want to know how should I clean RichViewEdit from previous documents?
I need to clear all styles, get defaults etc.

The problem I've got is when I clear RVE and RVStyle the documents here will get fixed width ignoring window size and RVRuler doesn't helps.
Word wrap works fine if window/form size is smaller than RVE document width. And when form width is smaller then document width bottom scrollbar appears.

Here is my code to clear RVE:

Code: Select all

      RichViewEdit1.Clear;
      RVStyle1.TextStyles.Clear;
      RVRuler1.AdjustPosition;
      RichViewEdit1.ApplyStyleConversion(TEXT_APPLYSTYLE);
      // This will apply my default style:
      //   FontInfo.FontName:=EditorFontName;
      //   FontInfo.Size:=EditorFontSize;
      //   FontInfo.Color:=DefTextColor;
      //   FontInfo.BackColor:=clNone;
      //   FontInfo.Style:=[];
      //   ...
      //   NewStyleNo:=RVStyle1.TextStyles.FindSuchStyle(StyleNo,FontInfo,RVAllFontInfoProperties);
      //   if NewStyleNo=-1 then begin
      //   RVStyle1.TextStyles.Add;
      //   ...
And once document width changed with RVRuler it becames fixed and when I make main form smaller than that width - I get bottom scrollbar. How can I bring dynamic document width back?
Sergey Tkachenko
Site Admin
Posts: 17253
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

The code below resets all properties that can be loaded/saved in RVF.

Code: Select all

// document
RichViewEdit1.Clear;
// styles
RVStyle1.TextStyles.Clear;
with RVStyle1.TextStyles.Add do begin
  FontName:=EditorFontName; 
  Size:=EditorFontSize; 
  Color:=DefTextColor; 
end;
RVStyle1.ParaStyles.Clear;
RVStyle1.ParaStyles.Add;
RVStyle1.ListStyles.Clear;
// background
RichViewEdit1.BackgroundStyle := bsNoBitmap;
RichViewEdit1.BackgroundBitmap := nil;
// margins (I assume they are measured in pixels)
RichViewEdit1.LeftMargin := 10; 
RichViewEdit1.RightMargin := 10; 
RichViewEdit1.TopMargin := 10; 
RichViewEdit1.BottomMargin := 10; 
// other layout properties
RichViewEdit1.MinTextWidth := 0;
RichViewEdit1.MaxTextWidth := 0;
RichViewEdit1.BiDiMode := rvbdUnspecified;
// formatting
RichViewEdit1.Format;
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post by Marsianin »

Ok, after this code everything clears and works fine but if the ruler set to some fixed document width (21cm for example) new document in this RVE will use this width too :shock:
So how can I reset RVRuler?
Once you change document width via ruler it became fixed and if form is smaller than this width bottom scrollbar appears. I need to know how to reset it.
Sergey Tkachenko
Site Admin
Posts: 17253
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Call Ruler1.UpdateRulerMargins after this code.
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post by Marsianin »

Tried:

Code: Select all

  RVRuler1.UpdateRulerIndents;
  RVRuler1.UpdateRulerMargins;
Did not help :x
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post by Marsianin »

And when you have RVE with Align=AtClient with RVRuler resizing main window moves right page boundary in the ruler according window size.
But once moved by the user (right page bound in the ruler) it fixes and even if you make window smaller than page width it will not resize.
How can I bring back this dynamic page width behavior?
Sergey Tkachenko
Site Admin
Posts: 17253
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Include rvoClientTextWidth in RichViewEdit.Options

The ruler can work in two modes:
1) rvoClientTextWidth is included in RichViewEdit.Options. In this mode, the ruler only changes margins.
2) If excluded, the ruler changes not only margins, but document width (by assigning MaxTextWidth and MinTextWidth)
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post by Marsianin »

Ok, set rvoClientTextWidth and it helped.

But new document still inherits boundaries from ruler from previous document.
Post Reply