richmemo: win32 fix style selection on internal change.

modified Internal change. Only allow if styles is fully modified.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4526 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
skalogryz
2016-02-29 04:48:34 +00:00
parent 5f4b958da5
commit 5804937f58
2 changed files with 13 additions and 3 deletions

View File

@ -845,16 +845,24 @@ var
j : Integer;
l : Integer;
p : TFontParams;
allowInternalChange: Boolean;
fp : TFontParams;
const
AllFontStyles : TFontStyles = [fsBold, fsItalic, fsUnderline, fsStrikeOut];
begin
if not HandleAllocated then HandleNeeded;
if (ModifyMask = []) or (TextLength = 0) then Exit;
if TWSCustomRichMemoClass(WidgetSetClass).isInternalChange(Self, ModifyMask) then
allowInternalChange:=(not (tmm_Styles in ModifyMask)) or (AddFontStyle+RemoveFontStyle=AllFontStyles);
if allowInternalChange and (TWSCustomRichMemoClass(WidgetSetClass).isInternalChange(Self, ModifyMask)) then
begin
// more effecient from OS view
fp:=fnt;
if tmm_Styles in ModifyMask then fp.Style:=AddFontStyle;
TWSCustomRichMemoClass(WidgetSetClass).SetTextAttributesInternal(Self,
TextStart, TextLength, ModifyMask, fnt);
TextStart, TextLength, ModifyMask, fp);
Exit;
end;