trichview.support
Re: Applying TextStyle to an whole paragraph |
Author |
Message |
Sergey Tkachenko |
Posted: 04/03/2002 23:50:05 The code for selection of current paragraph: procedure SelectParagraph(rve: TCustomRichViewEdit); var ItemNo1,ItemNo2,Offs1,Offs2: Integer; begin while rve.InplaceEditor<>nil do rve := TCustomRichViewEdit(rve.InplaceEditor); rve.GetSelectionBounds(ItemNo1,Offs1,ItemNo2,Offs2, True); if ItemNo1<0 then begin ItemNo1 := rve.CurItemNo; ItemNo2 := ItemNo1; end; while (ItemNo1>0) and not rve.IsParaStart(ItemNo1) do dec(ItemNo1); inc(ItemNo2); while (ItemNo2<rve.ItemCount) and not rve.IsParaStart(ItemNo2) do inc(ItemNo2); dec(ItemNo2); rve.SetSelectionBounds(ItemNo1, rve.GetOffsBeforeItem(ItemNo1), ItemNo2, rve.GetOffsAfterItem(ItemNo2)); rve.Invalidate; end; Restoring caret position (and selection) is more complicated. RichView document consists of items, and after applying a text style some items may be concatenated together. This is possible, though. If you feel that it's necessary, I'll give you a code. > > I'm evaluating Richview for eventual use in my project. Paragraphs as defined > in my application has to have not only the properties defined by ParaStyles > but should include the font info as well (defined by TextStyles). > > I figure that to apply TextStyle to a paragraph, I have to write the code > to: > 1. remember the caret position (and ev. selection) > 2. select the whole paragraph > 3. apply the needed TextStyle to the paragraph > 4. deselect the paragraph > 5. restore the caret (and ev. selection) > > Richview is new to me, so I cant figure out how to do the 2.(i.e. select > the whole paragraph), neither from demos nor from docs. > > Also, I wonder if there is more elegant way to do it (perhaps the best would > be if the component itself could change the whole paragraph?)? > > Any help and/or suggestion is welcome. > > Regards, Vladimir |
Powered by ABC Amber Outlook Express Converter