From 5804937f5858af9eb5dd94e3237bb79371604e7e Mon Sep 17 00:00:00 2001 From: skalogryz Date: Mon, 29 Feb 2016 04:48:34 +0000 Subject: [PATCH] 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 --- components/richmemo/richmemo.pas | 12 ++++++++++-- components/richmemo/win32/win32richmemoproc.pas | 4 +++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/components/richmemo/richmemo.pas b/components/richmemo/richmemo.pas index 3998cfe40..eaa512138 100644 --- a/components/richmemo/richmemo.pas +++ b/components/richmemo/richmemo.pas @@ -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; diff --git a/components/richmemo/win32/win32richmemoproc.pas b/components/richmemo/win32/win32richmemoproc.pas index ca958da51..b9cd19a36 100644 --- a/components/richmemo/win32/win32richmemoproc.pas +++ b/components/richmemo/win32/win32richmemoproc.pas @@ -383,6 +383,8 @@ class function TRichEditManager.SetSelectedTextStyle(RichEditWnd: Handle; var w : WPARAM; fmt : TCHARFORMAT2; +const + CFM_STYLESONLY = CFM_BOLD or CFM_ITALIC or CFM_UNDERLINE or CFM_STRIKEOUT or CFM_SUBSCRIPT or CFM_SUPERSCRIPT; begin if RichEditWnd = 0 then begin Result := false; @@ -411,7 +413,7 @@ begin end; if not useMask or (tmm_Styles in AModifyMask) then begin - fmt.dwMask := fmt.dwMask or CFM_EFFECTS or CFM_SUBSCRIPT or CFM_SUPERSCRIPT; + fmt.dwMask := fmt.dwMask or CFM_STYLESONLY; fmt.dwEffects := FontStylesToEffects(Params.Style) or VScriptPosToEffects(Params.VScriptPos); end;