\item wxRICHTEXT\_SETSTYLE\_CHARACTERS\_ONLY: specifies that the style should only be applied to characters,
and not the paragraph. This allows content styling to be preserved independently from that of e.g. a named paragraph style.
\item wxRICHTEXT\_SETSTYLE\_RESET: resets (clears) the existing style before applying the new style.
+\item wxRICHTEXT\_SETSTYLE\_REMOVE: removes the specified style. Only the style flags are used in this operation.
\end{itemize}
\membersection{wxRichTextBuffer::SetStyleSheet}\label{wxrichtextbuffersetstylesheet}
\item wxRICHTEXT\_SETSTYLE\_CHARACTERS\_ONLY: specifies that the style should only be applied to characters,
and not the paragraph. This allows content styling to be preserved independently from that of e.g. a named paragraph style.
\item wxRICHTEXT\_SETSTYLE\_RESET: resets (clears) the existing style before applying the new style.
+\item wxRICHTEXT\_SETSTYLE\_REMOVE: removes the specified style. Only the style flags are used in this operation.
\end{itemize}
\membersection{wxRichTextCtrl::SetStyleSheet}\label{wxrichtextctrlsetstylesheet}
// Resets the existing style before applying the new style
#define wxRICHTEXT_SETSTYLE_RESET 0x40
+// Removes the given style instead of applying it
+#define wxRICHTEXT_SETSTYLE_REMOVE 0x80
+
/*!
* Flags for text insertion
*/
WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxTextAttrEx& destStyle, const wxRichTextAttr& style, wxRichTextAttr* compareWith = NULL);
WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxRichTextAttr& destStyle, const wxRichTextAttr& style, wxRichTextAttr* compareWith = NULL);
+// Remove attributes
+WXDLLIMPEXP_RICHTEXT bool wxRichTextRemoveStyle(wxTextAttrEx& destStyle, const wxRichTextAttr& style);
+
/// Combine two bitlists
WXDLLIMPEXP_RICHTEXT bool wxRichTextCombineBitlists(int& valueA, int valueB, int& flagsA, int flagsB);
bool parasOnly = ((flags & wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY) != 0);
bool charactersOnly = ((flags & wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY) != 0);
bool resetExistingStyle = ((flags & wxRICHTEXT_SETSTYLE_RESET) != 0);
+ bool removeStyle = ((flags & wxRICHTEXT_SETSTYLE_REMOVE) != 0);
// Apply paragraph style first, if any
wxRichTextAttr wholeStyle(style);
- if (wholeStyle.HasParagraphStyleName() && GetStyleSheet())
+ if (!removeStyle && wholeStyle.HasParagraphStyleName() && GetStyleSheet())
{
wxRichTextParagraphStyleDefinition* def = GetStyleSheet()->FindParagraphStyle(wholeStyle.GetParagraphStyleName());
if (def)
wxRichTextAttr characterAttributes(wholeStyle);
characterAttributes.SetFlags(characterAttributes.GetFlags() & (wxTEXT_ATTR_CHARACTER));
- if (characterAttributes.HasCharacterStyleName() && GetStyleSheet())
+ if (!removeStyle && characterAttributes.HasCharacterStyleName() && GetStyleSheet())
{
wxRichTextCharacterStyleDefinition* def = GetStyleSheet()->FindCharacterStyle(characterAttributes.GetCharacterStyleName());
if (def)
// to be included in the paragraph style
if ((paragraphStyle || parasOnly) && !charactersOnly)
{
- if (resetExistingStyle)
+ if (removeStyle)
+ {
+ // Removes the given style from the paragraph
+ wxRichTextRemoveStyle(newPara->GetAttributes(), style);
+ }
+ else if (resetExistingStyle)
newPara->GetAttributes() = wholeStyle;
else
{
{
wxRichTextObject* child = node2->GetData();
- if (resetExistingStyle)
+ if (removeStyle)
+ {
+ // Removes the given style from the paragraph
+ wxRichTextRemoveStyle(child->GetAttributes(), style);
+ }
+ else if (resetExistingStyle)
child->GetAttributes() = characterAttributes;
else
{
return true;
}
+// Remove attributes
+bool wxRichTextRemoveStyle(wxTextAttrEx& destStyle, const wxRichTextAttr& style)
+{
+ int flags = style.GetFlags();
+ int destFlags = destStyle.GetFlags();
+
+ destStyle.SetFlags(destFlags & ~flags);
+
+ return true;
+}
+
/// Combine two bitlists, specifying the bits of interest with separate flags.
bool wxRichTextCombineBitlists(int& valueA, int valueB, int& flagsA, int flagsB)
{