Page 1 of 1

Multi style conversion

Posted: Tue Jun 10, 2014 4:53 pm
by Jim Knopf
How can I solve this problem easy:

I have to sets of styles:
style 0..4 is normal
style 5..9 are the same styles but with an other color

User marks a text that contains different styles, e.g. normal bold and italic (set 0..4) if he releases the mouse the whole marked text should be converted. E.g. 0 > 5 (normal), 1 > 6 (bold) and 2 > 7 (italic)

thank you
Martin

Posted: Wed Jun 18, 2014 5:25 pm
by Jim Knopf
No hint ...?

Posted: Thu Jun 19, 2014 8:34 am
by Sergey Tkachenko
Sorry for the delay.

Process OnRVMouseUp:

Code: Select all

procedure TForm3.RichViewEdit1RVMouseUp(Sender: TCustomRichView;
  Button: TMouseButton; Shift: TShiftState; ItemNo, X, Y: Integer);
begin
  if RichViewEdit1.SelectionExists then
    RichViewEdit1.ApplyStyleConversion(0);
end;
And OnStyleConversion:

Code: Select all

procedure TForm3.RichViewEdit1StyleConversion(Sender: TCustomRichViewEdit;
  StyleNo, UserData: Integer; AppliedToText: Boolean; var NewStyleNo: Integer);
begin
  NewStyleNo := StyleNo;
  if StyleNo<5 then
   inc(NewStyleNo, 5);
end;

Posted: Fri Jun 20, 2014 9:20 am
by Jim Knopf
Thank you Sergey, very helpful idea! :D