git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44612
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
r.WriteText(wxT("colour, like this red bit."));
r.EndTextColour();
r.WriteText(wxT("colour, like this red bit."));
r.EndTextColour();
- r.BeginTextColour(wxColour(0, 0, 255));
- r.WriteText(wxT(" And this blue bit."));
- r.EndTextColour();
+ wxRichTextAttr backgroundColourAttr;
+ backgroundColourAttr.SetBackgroundColour(*wxGREEN);
+ backgroundColourAttr.SetTextColour(wxColour(0, 0, 255));
+ r.BeginStyle(backgroundColourAttr);
+ r.WriteText(wxT(" And this blue on green bit."));
+ r.EndStyle();
r.WriteText(wxT(" Naturally you can make things "));
r.BeginBold();
r.WriteText(wxT(" Naturally you can make things "));
r.BeginBold();
// Don't use the base style, just the default style, and the base style will
// be combined at display time.
// Divide into paragraph and character styles.
// Don't use the base style, just the default style, and the base style will
// be combined at display time.
// Divide into paragraph and character styles.
wxTextAttrEx defaultCharStyle;
wxTextAttrEx defaultParaStyle;
wxTextAttrEx defaultCharStyle;
wxTextAttrEx defaultParaStyle;
// Don't use the base style, just the default style, and the base style will
// be combined at display time.
// Divide into paragraph and character styles.
// Don't use the base style, just the default style, and the base style will
// be combined at display time.
// Divide into paragraph and character styles.
wxTextAttrEx defaultCharStyle;
wxTextAttrEx defaultParaStyle;
wxRichTextSplitParaCharStyles(GetDefaultStyle(), defaultParaStyle, defaultCharStyle);
wxTextAttrEx defaultCharStyle;
wxTextAttrEx defaultParaStyle;
wxRichTextSplitParaCharStyles(GetDefaultStyle(), defaultParaStyle, defaultCharStyle);
// Don't use the base style, just the default style, and the base style will
// be combined at display time.
// Divide into paragraph and character styles.
// Don't use the base style, just the default style, and the base style will
// be combined at display time.
// Divide into paragraph and character styles.
wxTextAttrEx defaultCharStyle;
wxTextAttrEx defaultParaStyle;
wxRichTextSplitParaCharStyles(GetDefaultStyle(), defaultParaStyle, defaultCharStyle);
wxTextAttrEx defaultCharStyle;
wxTextAttrEx defaultParaStyle;
wxRichTextSplitParaCharStyles(GetDefaultStyle(), defaultParaStyle, defaultCharStyle);
{
// We need to find the bits in the new style that are different:
// just look at those bits that are specified by the new style.
{
// We need to find the bits in the new style that are different:
// just look at those bits that are specified by the new style.
int currentRelevantTextEffects = currentStyle.GetTextEffects() & style.GetTextEffectFlags();
int newRelevantTextEffects = style.GetTextEffects() & style.GetTextEffectFlags();
int currentRelevantTextEffects = currentStyle.GetTextEffects() & style.GetTextEffectFlags();
int newRelevantTextEffects = style.GetTextEffects() & style.GetTextEffectFlags();
{
// Find the text effects that were different, using XOR
int differentEffects = currentRelevantTextEffects ^ newRelevantTextEffects;
{
// Find the text effects that were different, using XOR
int differentEffects = currentRelevantTextEffects ^ newRelevantTextEffects;
// Clash of style - mark as such
multipleTextEffectAttributes |= differentEffects;
currentStyle.SetTextEffectFlags(currentStyle.GetTextEffectFlags() & ~differentEffects);
// Clash of style - mark as such
multipleTextEffectAttributes |= differentEffects;
currentStyle.SetTextEffectFlags(currentStyle.GetTextEffectFlags() & ~differentEffects);
// The attributes that aren't valid because of multiple styles within the range
long multipleStyleAttributes = 0;
int multipleTextEffectAttributes = 0;
// The attributes that aren't valid because of multiple styles within the range
long multipleStyleAttributes = 0;
int multipleTextEffectAttributes = 0;
wxRichTextObjectList::compatibility_iterator node = GetChildren().GetFirst();
while (node)
{
wxRichTextObjectList::compatibility_iterator node = GetChildren().GetFirst();
while (node)
{
Clear();
AddParagraph(wxEmptyString);
Clear();
AddParagraph(wxEmptyString);
Invalidate(wxRICHTEXT_ALL);
}
Invalidate(wxRICHTEXT_ALL);
}
bool wxRichTextParagraphLayoutBox::SetListStyle(const wxRichTextRange& range, wxRichTextListStyleDefinition* def, int flags, int startFrom, int specifiedLevel)
{
wxRichTextStyleSheet* styleSheet = GetStyleSheet();
bool wxRichTextParagraphLayoutBox::SetListStyle(const wxRichTextRange& range, wxRichTextListStyleDefinition* def, int flags, int startFrom, int specifiedLevel)
{
wxRichTextStyleSheet* styleSheet = GetStyleSheet();
bool withUndo = ((flags & wxRICHTEXT_SETSTYLE_WITH_UNDO) != 0);
// bool applyMinimal = ((flags & wxRICHTEXT_SETSTYLE_OPTIMIZE) != 0);
bool specifyLevel = ((flags & wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL) != 0);
bool withUndo = ((flags & wxRICHTEXT_SETSTYLE_WITH_UNDO) != 0);
// bool applyMinimal = ((flags & wxRICHTEXT_SETSTYLE_OPTIMIZE) != 0);
bool specifyLevel = ((flags & wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL) != 0);
{
if (!previousParagraph->GetAttributes().HasFlag(wxTEXT_ATTR_BULLET_STYLE) || previousParagraph->GetAttributes().GetBulletStyle() == wxTEXT_ATTR_BULLET_STYLE_NONE)
return false;
{
if (!previousParagraph->GetAttributes().HasFlag(wxTEXT_ATTR_BULLET_STYLE) || previousParagraph->GetAttributes().GetBulletStyle() == wxTEXT_ATTR_BULLET_STYLE_NONE)
return false;
wxRichTextStyleSheet* styleSheet = GetStyleSheet();
if (styleSheet && !previousParagraph->GetAttributes().GetListStyleName().IsEmpty())
{
wxRichTextStyleSheet* styleSheet = GetStyleSheet();
if (styleSheet && !previousParagraph->GetAttributes().GetListStyleName().IsEmpty())
{
{
// int thisIndent = previousParagraph->GetAttributes().GetLeftIndent();
// int thisLevel = def->FindLevelForIndent(thisIndent);
{
// int thisIndent = previousParagraph->GetAttributes().GetLeftIndent();
// int thisLevel = def->FindLevelForIndent(thisIndent);
bool isOutline = (previousParagraph->GetAttributes().GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_OUTLINE) != 0;
attr.SetFlags(previousParagraph->GetAttributes().GetFlags() & (wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_BULLET_TEXT|wxTEXT_ATTR_BULLET_NAME));
bool isOutline = (previousParagraph->GetAttributes().GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_OUTLINE) != 0;
attr.SetFlags(previousParagraph->GetAttributes().GetFlags() & (wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_BULLET_TEXT|wxTEXT_ATTR_BULLET_NAME));
attr.SetBulletName(previousParagraph->GetAttributes().GetBulletName());
attr.SetBulletStyle(previousParagraph->GetAttributes().GetBulletStyle());
attr.SetListStyleName(previousParagraph->GetAttributes().GetListStyleName());
attr.SetBulletName(previousParagraph->GetAttributes().GetBulletName());
attr.SetBulletStyle(previousParagraph->GetAttributes().GetBulletStyle());
attr.SetListStyleName(previousParagraph->GetAttributes().GetListStyleName());
int nextNumber = previousParagraph->GetAttributes().GetBulletNumber() + 1;
attr.SetBulletNumber(nextNumber);
int nextNumber = previousParagraph->GetAttributes().GetBulletNumber() + 1;
attr.SetBulletNumber(nextNumber);
if (isOutline)
{
wxString text = previousParagraph->GetAttributes().GetBulletText();
if (isOutline)
{
wxString text = previousParagraph->GetAttributes().GetBulletText();
attr.SetBulletText(text);
}
}
attr.SetBulletText(text);
}
}
if (wxRichTextBuffer::GetRenderer())
wxRichTextBuffer::GetRenderer()->DrawBitmapBullet(this, dc, bulletAttr, bulletRect);
}
if (wxRichTextBuffer::GetRenderer())
wxRichTextBuffer::GetRenderer()->DrawBitmapBullet(this, dc, bulletAttr, bulletRect);
}
- else if (attr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_STANDARD)
- {
+ else if (attr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_STANDARD)
+ {
if (wxRichTextBuffer::GetRenderer())
wxRichTextBuffer::GetRenderer()->DrawStandardBullet(this, dc, bulletAttr, bulletRect);
}
else
{
wxString bulletText = GetBulletText();
if (wxRichTextBuffer::GetRenderer())
wxRichTextBuffer::GetRenderer()->DrawStandardBullet(this, dc, bulletAttr, bulletRect);
}
else
{
wxString bulletText = GetBulletText();
if (!bulletText.empty() && wxRichTextBuffer::GetRenderer())
wxRichTextBuffer::GetRenderer()->DrawTextBullet(this, dc, bulletAttr, bulletRect, bulletText);
}
if (!bulletText.empty() && wxRichTextBuffer::GetRenderer())
wxRichTextBuffer::GetRenderer()->DrawTextBullet(this, dc, bulletAttr, bulletRect, bulletText);
}
while (node2)
{
wxRichTextObject* child = node2->GetData();
while (node2)
{
wxRichTextObject* child = node2->GetData();
if (!child->GetRange().IsOutside(lineRange) && !lineRange.IsOutside(range))
{
// Draw this part of the line at the correct position
if (!child->GetRange().IsOutside(lineRange) && !lineRange.IsOutside(range))
{
// Draw this part of the line at the correct position
// We may only be looking at part of a child, if we searched back for wrapping
// and found a suitable point some way into the child. So get the size for the fragment
// if necessary.
// We may only be looking at part of a child, if we searched back for wrapping
// and found a suitable point some way into the child. So get the size for the fragment
// if necessary.
long nextBreakPos = GetFirstLineBreakPosition(lastEndPos+1);
long lastPosToUse = child->GetRange().GetEnd();
bool lineBreakInThisObject = (nextBreakPos > -1 && nextBreakPos <= child->GetRange().GetEnd());
long nextBreakPos = GetFirstLineBreakPosition(lastEndPos+1);
long lastPosToUse = child->GetRange().GetEnd();
bool lineBreakInThisObject = (nextBreakPos > -1 && nextBreakPos <= child->GetRange().GetEnd());
if (lineBreakInThisObject)
lastPosToUse = nextBreakPos;
wxSize childSize;
int childDescent = 0;
if (lineBreakInThisObject)
lastPosToUse = nextBreakPos;
wxSize childSize;
int childDescent = 0;
if ((nextBreakPos == -1) && (lastEndPos == child->GetRange().GetStart() - 1)) // i.e. we want to get the whole thing
{
childSize = child->GetCachedSize();
if ((nextBreakPos == -1) && (lastEndPos == child->GetRange().GetStart() - 1)) // i.e. we want to get the whole thing
{
childSize = child->GetCachedSize();
{
text = GetAttributes().GetBulletText();
}
{
text = GetAttributes().GetBulletText();
}
if (GetAttributes().GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_OUTLINE)
{
// The outline style relies on the text being computed statically,
if (GetAttributes().GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_OUTLINE)
{
// The outline style relies on the text being computed statically,
wxString str = m_text;
wxString toRemove = wxRichTextLineBreakChar;
str.Replace(toRemove, wxT(" "));
wxString str = m_text;
wxString toRemove = wxRichTextLineBreakChar;
str.Replace(toRemove, wxT(" "));
long len = range.GetLength();
wxString stringChunk = str.Mid(range.GetStart() - offset, (size_t) len);
if (textAttr.HasTextEffects() && (textAttr.GetTextEffects() & wxTEXT_ATTR_EFFECT_CAPITALS))
long len = range.GetLength();
wxString stringChunk = str.Mid(range.GetStart() - offset, (size_t) len);
if (textAttr.HasTextEffects() && (textAttr.GetTextEffects() & wxTEXT_ATTR_EFFECT_CAPITALS))
dc.SetBrush(*wxBLACK_BRUSH);
dc.SetPen(*wxBLACK_PEN);
dc.SetTextForeground(*wxWHITE);
dc.SetBrush(*wxBLACK_BRUSH);
dc.SetPen(*wxBLACK_PEN);
dc.SetTextForeground(*wxWHITE);
- dc.SetBackgroundMode(wxTRANSPARENT);
}
else
{
dc.SetTextForeground(attr.GetTextColour());
}
else
{
dc.SetTextForeground(attr.GetTextColour());
- dc.SetBackgroundMode(wxTRANSPARENT);
+ if (attr.HasFlag(wxTEXT_ATTR_BACKGROUND_COLOUR) && attr.GetBackgroundColour().IsOk())
+ {
+ dc.SetBackgroundMode(wxSOLID);
+ dc.SetTextBackground(attr.GetBackgroundColour());
+ }
+ else
+ dc.SetBackgroundMode(wxTRANSPARENT);
+
while (hasTabs)
{
// the string has a tab
while (hasTabs)
{
// the string has a tab
int startPos = range.GetStart() - GetRange().GetStart();
long len = range.GetLength();
int startPos = range.GetStart() - GetRange().GetStart();
long len = range.GetLength();
wxString str(m_text);
wxString toReplace = wxRichTextLineBreakChar;
str.Replace(toReplace, wxT(" "));
wxString str(m_text);
wxString toReplace = wxRichTextLineBreakChar;
str.Replace(toReplace, wxT(" "));
wxRichTextObject* wxRichTextPlainText::DoSplit(long pos)
{
long index = pos - GetRange().GetStart();
wxRichTextObject* wxRichTextPlainText::DoSplit(long pos)
{
long index = pos - GetRange().GetStart();
if (index < 0 || index >= (int) m_text.length())
return NULL;
if (index < 0 || index >= (int) m_text.length())
return NULL;
newObject->SetRange(wxRichTextRange(pos, GetRange().GetEnd()));
GetRange().SetEnd(pos-1);
newObject->SetRange(wxRichTextRange(pos, GetRange().GetEnd()));
GetRange().SetEnd(pos-1);
void wxRichTextBuffer::ResetAndClearCommands()
{
Reset();
void wxRichTextBuffer::ResetAndClearCommands()
{
Reset();
GetCommandProcessor()->ClearCommands();
Modify(false);
GetCommandProcessor()->ClearCommands();
Modify(false);
{
wxRichTextAttr attr;
bool foundAttributes = false;
{
wxRichTextAttr attr;
bool foundAttributes = false;
// Look for a matching paragraph style
if (lookUpNewParaStyle && !para->GetAttributes().GetParagraphStyleName().IsEmpty() && GetStyleSheet())
{
// Look for a matching paragraph style
if (lookUpNewParaStyle && !para->GetAttributes().GetParagraphStyleName().IsEmpty() && GetStyleSheet())
{
attr = nextParaDef->GetStyleMergedWithBase(GetStyleSheet());
}
}
attr = nextParaDef->GetStyleMergedWithBase(GetStyleSheet());
}
}
// If we didn't find the 'next style', use this style instead.
if (!foundAttributes)
{
// If we didn't find the 'next style', use this style instead.
if (!foundAttributes)
{
(~ wxTEXT_ATTR_BACKGROUND_COLOUR) );
attr.SetFlags(flags);
}
(~ wxTEXT_ATTR_BACKGROUND_COLOUR) );
attr.SetFlags(flags);
}
// Now see if we need to number the paragraph.
if (attr.HasBulletStyle())
{
// Now see if we need to number the paragraph.
if (attr.HasBulletStyle())
{
m_eventHandlers.Erase(node);
if (deleteHandler)
delete handler;
m_eventHandlers.Erase(node);
if (deleteHandler)
delete handler;
bool wxRichTextBuffer::SetStyleSheetAndNotify(wxRichTextStyleSheet* sheet)
{
wxRichTextStyleSheet* oldSheet = GetStyleSheet();
bool wxRichTextBuffer::SetStyleSheetAndNotify(wxRichTextStyleSheet* sheet)
{
wxRichTextStyleSheet* oldSheet = GetStyleSheet();
wxWindowID id = wxID_ANY;
if (GetRichTextCtrl())
id = GetRichTextCtrl()->GetId();
wxWindowID id = wxID_ANY;
if (GetRichTextCtrl())
id = GetRichTextCtrl()->GetId();
wxRichTextEvent event(wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING, id);
event.SetEventObject(GetRichTextCtrl());
event.SetOldStyleSheet(oldSheet);
event.SetNewStyleSheet(sheet);
event.Allow();
wxRichTextEvent event(wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING, id);
event.SetEventObject(GetRichTextCtrl());
event.SetOldStyleSheet(oldSheet);
event.SetNewStyleSheet(sheet);
event.Allow();
if (SendEvent(event) && !event.IsAllowed())
{
if (sheet != oldSheet)
if (SendEvent(event) && !event.IsAllowed())
{
if (sheet != oldSheet)
dc.SetFont(font);
int charHeight = dc.GetCharHeight();
dc.SetFont(font);
int charHeight = dc.GetCharHeight();
int bulletWidth = (int) (((float) charHeight) * wxRichTextBuffer::GetBulletProportion());
int bulletHeight = bulletWidth;
int x = rect.x;
int bulletWidth = (int) (((float) charHeight) * wxRichTextBuffer::GetBulletProportion());
int bulletHeight = bulletWidth;
int x = rect.x;
// Calculate the top position of the character (as opposed to the whole line height)
int y = rect.y + (rect.height - charHeight);
// Calculate the top position of the character (as opposed to the whole line height)
int y = rect.y + (rect.height - charHeight);
// Calculate where the bullet should be positioned
y = y + (charHeight+1)/2 - (bulletHeight+1)/2;
// Calculate where the bullet should be positioned
y = y + (charHeight+1)/2 - (bulletHeight+1)/2;
// The margin between a bullet and text.
int margin = paragraph->ConvertTenthsMMToPixels(dc, wxRichTextBuffer::GetBulletRightMargin());
// The margin between a bullet and text.
int margin = paragraph->ConvertTenthsMMToPixels(dc, wxRichTextBuffer::GetBulletRightMargin());
if (bulletAttr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT)
x = rect.x + rect.width - bulletWidth - margin;
else if (bulletAttr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE)
x = x + (rect.width)/2 - bulletWidth/2;
if (bulletAttr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT)
x = rect.x + rect.width - bulletWidth - margin;
else if (bulletAttr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE)
x = x + (rect.width)/2 - bulletWidth/2;
if (bulletAttr.GetBulletName() == wxT("standard/square"))
{
dc.DrawRectangle(x, y, bulletWidth, bulletHeight);
if (bulletAttr.GetBulletName() == wxT("standard/square"))
{
dc.DrawRectangle(x, y, bulletWidth, bulletHeight);
pts[1].x = x + bulletWidth/2; pts[1].y = y;
pts[2].x = x + bulletWidth; pts[2].y = y + bulletHeight/2;
pts[3].x = x + bulletWidth/2; pts[3].y = y + bulletHeight;
pts[1].x = x + bulletWidth/2; pts[1].y = y;
pts[2].x = x + bulletWidth; pts[2].y = y + bulletHeight/2;
pts[3].x = x + bulletWidth/2; pts[3].y = y + bulletHeight;
dc.DrawPolygon(4, pts);
}
else if (bulletAttr.GetBulletName() == wxT("standard/triangle"))
dc.DrawPolygon(4, pts);
}
else if (bulletAttr.GetBulletName() == wxT("standard/triangle"))
pts[0].x = x; pts[0].y = y;
pts[1].x = x + bulletWidth; pts[1].y = y + bulletHeight/2;
pts[2].x = x; pts[2].y = y + bulletHeight;
pts[0].x = x; pts[0].y = y;
pts[1].x = x + bulletWidth; pts[1].y = y + bulletHeight/2;
pts[2].x = x; pts[2].y = y + bulletHeight;
dc.DrawPolygon(3, pts);
}
else // "standard/circle", and catch-all
{
dc.DrawEllipse(x, y, bulletWidth, bulletHeight);
dc.DrawPolygon(3, pts);
}
else // "standard/circle", and catch-all
{
dc.DrawEllipse(x, y, bulletWidth, bulletHeight);
int x = rect.x;
// Calculate the top position of the character (as opposed to the whole line height)
int x = rect.x;
// Calculate the top position of the character (as opposed to the whole line height)
- int y = rect.y + (rect.height - charHeight);
+ int y = rect.y + (rect.height - charHeight);
// The margin between a bullet and text.
int margin = paragraph->ConvertTenthsMMToPixels(dc, wxRichTextBuffer::GetBulletRightMargin());
// The margin between a bullet and text.
int margin = paragraph->ConvertTenthsMMToPixels(dc, wxRichTextBuffer::GetBulletRightMargin());
if (attr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT)
x = (rect.x + rect.width) - tw - margin;
else if (attr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE)
x = x + (rect.width)/2 - tw/2;
dc.DrawText(text, x, y);
if (attr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT)
x = (rect.x + rect.width) - tw - margin;
else if (attr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE)
x = x + (rect.width)/2 - tw/2;
dc.DrawText(text, x, y);
wxSize clientSize = m_ctrl->GetClientSize();
wxPoint firstVisiblePt = m_ctrl->GetFirstVisiblePoint();
int lastY = firstVisiblePt.y + clientSize.y;
wxSize clientSize = m_ctrl->GetClientSize();
wxPoint firstVisiblePt = m_ctrl->GetFirstVisiblePoint();
int lastY = firstVisiblePt.y + clientSize.y;
wxRichTextParagraph* para = m_buffer->GetParagraphAtPosition(GetPosition());
wxRichTextObjectList::compatibility_iterator node = m_buffer->GetChildren().Find(para);
while (node)
wxRichTextParagraph* para = m_buffer->GetParagraphAtPosition(GetPosition());
wxRichTextObjectList::compatibility_iterator node = m_buffer->GetChildren().Find(para);
while (node)
wxRichTextLine* line = node2->GetData();
wxPoint pt = line->GetAbsolutePosition();
wxRichTextRange range = line->GetAbsoluteRange();
wxRichTextLine* line = node2->GetData();
wxPoint pt = line->GetAbsolutePosition();
wxRichTextRange range = line->GetAbsoluteRange();
if (pt.y > lastY)
{
node2 = wxRichTextLineList::compatibility_iterator();
node = wxRichTextObjectList::compatibility_iterator();
}
else if (range.GetStart() > GetPosition() && pt.y >= firstVisiblePt.y)
if (pt.y > lastY)
{
node2 = wxRichTextLineList::compatibility_iterator();
node = wxRichTextObjectList::compatibility_iterator();
}
else if (range.GetStart() > GetPosition() && pt.y >= firstVisiblePt.y)
optimizationLineCharPositions.Add(range.GetStart());
optimizationLineYPositions.Add(pt.y);
}
optimizationLineCharPositions.Add(range.GetStart());
optimizationLineYPositions.Add(pt.y);
}
if (node2)
node2 = node2->GetNext();
}
if (node2)
node2 = node2->GetNext();
}
if (node)
node = node->GetNext();
}
if (node)
node = node->GetNext();
}
#endif
m_buffer->InsertFragment(GetPosition(), m_newParagraphs);
#endif
m_buffer->InsertFragment(GetPosition(), m_newParagraphs);
- newCaretPosition = wxMin(newCaretPosition, (m_buffer->GetRange().GetEnd()-1));
+ newCaretPosition = wxMin(newCaretPosition, (m_buffer->GetRange().GetEnd()-1));
if (optimizationLineCharPositions.GetCount() > 0)
UpdateAppearance(newCaretPosition, true /* send update event */, & optimizationLineCharPositions, & optimizationLineYPositions);
else
UpdateAppearance(newCaretPosition, true /* send update event */);
if (optimizationLineCharPositions.GetCount() > 0)
UpdateAppearance(newCaretPosition, true /* send update event */, & optimizationLineCharPositions, & optimizationLineYPositions);
else
UpdateAppearance(newCaretPosition, true /* send update event */);
wxRichTextEvent cmdEvent(
wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED,
m_ctrl ? m_ctrl->GetId() : -1);
cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer);
cmdEvent.SetRange(GetRange());
cmdEvent.SetPosition(GetRange().GetStart());
wxRichTextEvent cmdEvent(
wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED,
m_ctrl ? m_ctrl->GetId() : -1);
cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer);
cmdEvent.SetRange(GetRange());
cmdEvent.SetPosition(GetRange().GetStart());
m_buffer->SendEvent(cmdEvent);
break;
m_buffer->SendEvent(cmdEvent);
break;
cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer);
cmdEvent.SetRange(GetRange());
cmdEvent.SetPosition(GetRange().GetStart());
cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer);
cmdEvent.SetRange(GetRange());
cmdEvent.SetPosition(GetRange().GetStart());
m_buffer->SendEvent(cmdEvent);
break;
m_buffer->SendEvent(cmdEvent);
break;
cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer);
cmdEvent.SetRange(GetRange());
cmdEvent.SetPosition(GetRange().GetStart());
cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer);
cmdEvent.SetRange(GetRange());
cmdEvent.SetPosition(GetRange().GetStart());
m_buffer->SendEvent(cmdEvent);
break;
m_buffer->SendEvent(cmdEvent);
break;
m_buffer->Invalidate(wxRichTextRange(GetRange().GetStart(), GetRange().GetStart()));
long newCaretPosition = GetPosition() - 1;
m_buffer->Invalidate(wxRichTextRange(GetRange().GetStart(), GetRange().GetStart()));
long newCaretPosition = GetPosition() - 1;
UpdateAppearance(newCaretPosition, true /* send update event */);
wxRichTextEvent cmdEvent(
UpdateAppearance(newCaretPosition, true /* send update event */);
wxRichTextEvent cmdEvent(
cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer);
cmdEvent.SetRange(GetRange());
cmdEvent.SetPosition(GetRange().GetStart());
cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer);
cmdEvent.SetRange(GetRange());
cmdEvent.SetPosition(GetRange().GetStart());
m_buffer->SendEvent(cmdEvent);
break;
m_buffer->SendEvent(cmdEvent);
break;
cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer);
cmdEvent.SetRange(GetRange());
cmdEvent.SetPosition(GetRange().GetStart());
cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer);
cmdEvent.SetRange(GetRange());
cmdEvent.SetPosition(GetRange().GetStart());
m_buffer->SendEvent(cmdEvent);
break;
m_buffer->SendEvent(cmdEvent);
break;
cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer);
cmdEvent.SetRange(GetRange());
cmdEvent.SetPosition(GetRange().GetStart());
cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer);
cmdEvent.SetRange(GetRange());
cmdEvent.SetPosition(GetRange().GetStart());
m_buffer->SendEvent(cmdEvent);
break;
m_buffer->SendEvent(cmdEvent);
break;
{
m_ctrl->LayoutContent();
m_ctrl->PositionCaret();
{
m_ctrl->LayoutContent();
m_ctrl->PositionCaret();
#if wxRICHTEXT_USE_OPTIMIZED_DRAWING
// Find refresh rectangle if we are in a position to optimise refresh
if (m_cmdId == wxRICHTEXT_INSERT && optimizationLineCharPositions && optimizationLineCharPositions->GetCount() > 0)
{
size_t i;
#if wxRICHTEXT_USE_OPTIMIZED_DRAWING
// Find refresh rectangle if we are in a position to optimise refresh
if (m_cmdId == wxRICHTEXT_INSERT && optimizationLineCharPositions && optimizationLineCharPositions->GetCount() > 0)
{
size_t i;
wxSize clientSize = m_ctrl->GetClientSize();
wxPoint firstVisiblePt = m_ctrl->GetFirstVisiblePoint();
wxSize clientSize = m_ctrl->GetClientSize();
wxPoint firstVisiblePt = m_ctrl->GetFirstVisiblePoint();
// Start/end positions
int firstY = 0;
int lastY = firstVisiblePt.y + clientSize.y;
// Start/end positions
int firstY = 0;
int lastY = firstVisiblePt.y + clientSize.y;
bool foundStart = false;
bool foundEnd = false;
bool foundStart = false;
bool foundEnd = false;
// position offset - how many characters were inserted
int positionOffset = GetRange().GetLength();
// find the first line which is being drawn at the same position as it was
// before. Since we're talking about a simple insertion, we can assume
// that the rest of the window does not need to be redrawn.
// position offset - how many characters were inserted
int positionOffset = GetRange().GetLength();
// find the first line which is being drawn at the same position as it was
// before. Since we're talking about a simple insertion, we can assume
// that the rest of the window does not need to be redrawn.
wxRichTextParagraph* para = m_buffer->GetParagraphAtPosition(GetPosition());
wxRichTextObjectList::compatibility_iterator node = m_buffer->GetChildren().Find(para);
while (node)
wxRichTextParagraph* para = m_buffer->GetParagraphAtPosition(GetPosition());
wxRichTextObjectList::compatibility_iterator node = m_buffer->GetChildren().Find(para);
while (node)
wxRichTextLine* line = node2->GetData();
wxPoint pt = line->GetAbsolutePosition();
wxRichTextRange range = line->GetAbsoluteRange();
wxRichTextLine* line = node2->GetData();
wxPoint pt = line->GetAbsolutePosition();
wxRichTextRange range = line->GetAbsoluteRange();
// we want to find the first line that is in the same position
// as before. This will mean we're at the end of the changed text.
// we want to find the first line that is in the same position
// as before. This will mean we're at the end of the changed text.
if (pt.y > lastY) // going past the end of the window, no more info
{
node2 = wxRichTextLineList::compatibility_iterator();
if (pt.y > lastY) // going past the end of the window, no more info
{
node2 = wxRichTextLineList::compatibility_iterator();
- // search for this line being at the same position as before
+ // search for this line being at the same position as before
for (i = 0; i < optimizationLineCharPositions->GetCount(); i++)
{
if (((*optimizationLineCharPositions)[i] + positionOffset == range.GetStart()) &&
for (i = 0; i < optimizationLineCharPositions->GetCount(); i++)
{
if (((*optimizationLineCharPositions)[i] + positionOffset == range.GetStart()) &&
node = wxRichTextObjectList::compatibility_iterator();
break;
node = wxRichTextObjectList::compatibility_iterator();
break;
}
}
if (node2)
node2 = node2->GetNext();
}
}
}
if (node2)
node2 = node2->GetNext();
}
if (node)
node = node->GetNext();
}
if (node)
node = node->GetNext();
}
if (!foundStart)
firstY = firstVisiblePt.y;
if (!foundEnd)
if (!foundStart)
firstY = firstVisiblePt.y;
if (!foundEnd)
wxRect rect(firstVisiblePt.x, firstY, firstVisiblePt.x + clientSize.x, lastY - firstY);
m_ctrl->RefreshRect(rect);
wxRect rect(firstVisiblePt.x, firstY, firstVisiblePt.x + clientSize.x, lastY - firstY);
m_ctrl->RefreshRect(rect);
// TODO: we need to make sure that lines are only drawn if in the update region. The rect
// passed to Draw is currently used in different ways (to pass the position the content should
// be drawn at as well as the relevant region).
}
// TODO: we need to make sure that lines are only drawn if in the update region. The rect
// passed to Draw is currently used in different ways (to pass the position the content should
// be drawn at as well as the relevant region).
}
#endif
m_ctrl->Refresh(false);
#endif
m_ctrl->Refresh(false);
int srcBits = style.GetTextEffects();
int srcFlags = style.GetTextEffectFlags();
int srcBits = style.GetTextEffects();
int srcFlags = style.GetTextEffectFlags();
wxRichTextCombineBitlists(destBits, srcBits, destFlags, srcFlags);
wxRichTextCombineBitlists(destBits, srcBits, destFlags, srcFlags);
destStyle.SetTextEffects(destBits);
destStyle.SetTextEffectFlags(destFlags);
}
destStyle.SetTextEffects(destBits);
destStyle.SetTextEffectFlags(destFlags);
}
int srcBits = style.GetTextEffects();
int srcFlags = style.GetTextEffectFlags();
int srcBits = style.GetTextEffects();
int srcFlags = style.GetTextEffectFlags();
wxRichTextCombineBitlists(destBits, srcBits, destFlags, srcFlags);
wxRichTextCombineBitlists(destBits, srcBits, destFlags, srcFlags);
destStyle.SetTextEffects(destBits);
destStyle.SetTextEffectFlags(destFlags);
}
destStyle.SetTextEffects(destBits);
destStyle.SetTextEffectFlags(destFlags);
}
// We want to apply B's bits to A, taking into account each's flags which indicate which bits
// are to be taken into account. A zero in B's bits should reset that bit in A but only if B's flags
// indicate it.
// We want to apply B's bits to A, taking into account each's flags which indicate which bits
// are to be taken into account. A zero in B's bits should reset that bit in A but only if B's flags
// indicate it.
// First, reset the 0 bits from B. We make a mask so we're only dealing with B's zero
// bits at this point, ignoring any 1 bits in B or 0 bits in B that are not relevant.
int valueA2 = ~(~valueB & flagsB) & valueA;
// First, reset the 0 bits from B. We make a mask so we're only dealing with B's zero
// bits at this point, ignoring any 1 bits in B or 0 bits in B that are not relevant.
int valueA2 = ~(~valueB & flagsB) & valueA;
// Now combine the 1 bits.
int valueA3 = (valueB & flagsB) | valueA2;
// Now combine the 1 bits.
int valueA3 = (valueB & flagsB) | valueA2;
valueA = valueA3;
flagsA = (flagsA | flagsB);
valueA = valueA3;
flagsA = (flagsA | flagsB);
wxRichTextApplyStyle(charStyle, defaultCharStyle1);
wxRichTextApplyStyle(parStyle, defaultParaStyle1);
wxRichTextApplyStyle(charStyle, defaultCharStyle1);
wxRichTextApplyStyle(parStyle, defaultParaStyle1);
// operators
void wxRichTextAttr::operator= (const wxRichTextAttr& attr)
// operators
void wxRichTextAttr::operator= (const wxRichTextAttr& attr)
GetFontWeight() == attr.GetFontWeight() &&
GetFontUnderlined() == attr.GetFontUnderlined() &&
GetFontFaceName() == attr.GetFontFaceName() &&
GetFontWeight() == attr.GetFontWeight() &&
GetFontUnderlined() == attr.GetFontUnderlined() &&
GetFontFaceName() == attr.GetFontFaceName() &&
GetURL() == attr.GetURL();
}
GetURL() == attr.GetURL();
}
{
wxRichTextAttr destStyle = (*this);
destStyle.Apply(style, compareWith);
{
wxRichTextAttr destStyle = (*this);
destStyle.Apply(style, compareWith);
return destStyle;
}
bool wxRichTextAttr::Apply(const wxRichTextAttr& style, const wxRichTextAttr* compareWith)
{
wxRichTextAttr& destStyle = (*this);
return destStyle;
}
bool wxRichTextAttr::Apply(const wxRichTextAttr& style, const wxRichTextAttr* compareWith)
{
wxRichTextAttr& destStyle = (*this);
if (style.HasFontWeight())
{
if (!(compareWith && compareWith->HasFontWeight() && compareWith->GetFontWeight() == style.GetFontWeight()))
if (style.HasFontWeight())
{
if (!(compareWith && compareWith->HasFontWeight() && compareWith->GetFontWeight() == style.GetFontWeight()))
int srcBits = style.GetTextEffects();
int srcFlags = style.GetTextEffectFlags();
int srcBits = style.GetTextEffects();
int srcFlags = style.GetTextEffectFlags();
wxRichTextCombineBitlists(destBits, srcBits, destFlags, srcFlags);
wxRichTextCombineBitlists(destBits, srcBits, destFlags, srcFlags);
destStyle.SetTextEffects(destBits);
destStyle.SetTextEffectFlags(destFlags);
}
destStyle.SetTextEffects(destBits);
destStyle.SetTextEffectFlags(destFlags);
}
wxString newLine = wxRichTextLineBreakChar;
text.Replace(newLine, wxT("\n"));
wxString newLine = wxRichTextLineBreakChar;
text.Replace(newLine, wxT("\n"));
wxCharBuffer buf = text.ToAscii();
stream.Write((const char*) buf, text.length());
wxCharBuffer buf = text.ToAscii();
stream.Write((const char*) buf, text.length());