1) A default text direction (rve.BiDiMode) is made equal to rvbdLeftToRight:
- rve.BiDiMode := rvbdLeftToRight is assigned in "File | New"
- in "File | Open", if rve.BiDiMode=rvbdUnspecified, it is assigned equal to rvbdLeftToRight.
These changes do not allow rve.BiDiMode to be equal to rvbdUnspecified - it must be either RTL or LTR. In a real application, you can implement:
- commands to change the document default BiDiMode (just assign a value to rve.BiDiMode)
- implement an option dialog where users can choose the default text direction for new documents.
2) Two new buttons are added for changing BiDiMode of paragraphs to RTL or RTL. The buttons have a new unique value of GroupIndex and AllowAllUp=True.
Possible state of these buttons:
- LTR button is pressed: rvbdLeftToRight
- RTL button is pressed: rvbdRightToLeft
- both buttons unpressed: rvbdUnspecified (using a default document text direction, i.e. rvbdLeftToRight in this demo).
This value is returned in function GetParaBiDiFromUI: TRVBiDiMode.
A state of the buttons is updated in rve.OnCurParaStyleChanged.
A new constant is added to PARA_*** constants:
PARA_BIDIMODE = 5;
When the buttons are clicked:
Code: Select all
Code: Select all
var ParaInfo: TParaInfo; OldBiDiMode, NewBiDiMode: TRVBiDiMode; ... PARA_BIDIMODE: begin OldBiDiMode := ParaInfo.BiDiMode; if OldBiDiMode=rvbdUnspecified then OldBiDiMode := rve.BiDiMode; NewBiDiMode := GetParaBiDiFromUI; if NewBiDiMode=rvbdUnspecified then NewBiDiMode := rve.BiDiMode; if OldBiDiMode<>NewBiDiMode then case ParaInfo.Alignment of rvaLeft: ParaInfo.Alignment := rvaRight; rvaRight: ParaInfo.Alignment := rvaLeft; end; ParaInfo.BiDiMode := GetParaBiDiFromUI; end;
3) A new button is added to show special characters. It is useful, because TRichViewEdit shows a paragraph text direction in "end of paragraph" marks.
This demo does not include commands to change BiDiMode of selected text fragments, because changing paragraph properties is enough for the most cases.
PS: If you use RichViewActions, you can just use the following actions: TrvActionParaRTL, TrvActionParaLTR, TrvActionTextRTL, TrvActionTextLTR.