trichview.com

trichview.support




Re: Use of ParaStyles and TextStyles


Return to index


Author

Message

Sergey Tkachenko

Posted: 09/24/2003 18:33:52


You can set protection to

a) paragraphs

and/or

b) text and non-text items


There are limitations in both methods.


a) paragraphs: you can protect only complete paragraphs, so adding text in

these paragraphs is impossible

b) text: you can protect text from deleting and modifying, but it still will

be possible to insert a new text between existing text items (i.e. between

text of different font ("style"). There is a rvprSticking protection

forbidding this, but it also forbids inserting something at the beginning of

document and the protected text, and between the end of the document and the

protected text.

Some tricks can be used for finding a workaround to these limitations.

For example you can add an empty line to the end of the document:

undeletable, but without "sticking" protection. User will be able to insert

text before it.


The example code is below. It assumes that the document that should be

protected is already loaded.


var i: Integer;

begin

// protecting all existing styles

for i := 0 to RVStyle1.TextStyles.Count-1 do

  RVStyle1.TextStyles[i].Protection :=

    RVStyle1.TextStyles[i].Protection +

    [rvprModifyProtect, rvprDeleteProtect,

     rvprDoNotAutoSwitch, rvprRVFInsertProtect,

     rvprParaStartProtect, rvprStyleProtect,

     rvprSticking

     ];

// adding a new style:

// will be used for typing text

with RVStyle1.TextStyles.Add do begin

  Assign(RVStyle1.TextStyles[0]);

  Protection := [];

end;

// adding a new style:

// text of this style will be added at the end

with RVStyle1.TextStyles.Add do begin

  Assign(RVStyle1.TextStyles[0]);

  Protection := [rvprModifyProtect, rvprDeleteProtect,

     rvprDoNotAutoSwitch, rvprRVFInsertProtect,

     rvprParaStartProtect, rvprStyleProtect];

end;

// adding a protected line without rvprSticking protection

RichViewEdit1.AddNL('', RVStyle1.TextStyles.Count-1, 0);

// moving the caret before this line,

// assigning style for typing

with RichViewEdit1 do begin

  SetSelectionBounds(ItemCount-2, GetOffsAfterItem(ItemCount-2),

    ItemCount-2, GetOffsAfterItem(ItemCount-2));

  CurTextStyleNo := RVStyle1.TextStyles.Count-2;

end;

end;


>

> Sergey:

> Although not yet I understand well the operation of the ParaStyles and

TextStyles.

> I want to protect the text loaded from a file and allow the user to write

> after it, without affecting the loaded part, I think that I can make it

with

> Parastyles and TextStyles but don't know like doing it. Can you help me ?

> Example:

> TEXT LOADED AND PROTECT, NEVER CHANGES. the user start typing in the same

> line, following the "CHANGES.".

>

> Thanks

> Fernando Alonso

>





Powered by ABC Amber Outlook Express Converter