Multi style conversion

General TRichView support forum. Please post your questions here
Post Reply
Jim Knopf
Posts: 241
Joined: Mon Dec 30, 2013 10:07 pm
Location: Austria
Contact:

Multi style conversion

Post 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
Jim Knopf
Posts: 241
Joined: Mon Dec 30, 2013 10:07 pm
Location: Austria
Contact:

Post by Jim Knopf »

No hint ...?
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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;
Jim Knopf
Posts: 241
Joined: Mon Dec 30, 2013 10:07 pm
Location: Austria
Contact:

Post by Jim Knopf »

Thank you Sergey, very helpful idea! :D
Post Reply