X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/bec80f4f4a44ce7d1ce24627f87deb0166249c54..4a40cd9bae5e4e76fadb6188b399905028a02bc7:/src/richtext/richtextbuffer.cpp diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index 86be3e8394..924074a586 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -3607,7 +3607,7 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style) wxArrayInt partialExtents; wxSize paraSize; - int paraDescent; + int paraDescent = 0; // This calculates the partial text extents GetRangeSize(GetRange(), paraSize, paraDescent, dc, wxRICHTEXT_UNFORMATTED|wxRICHTEXT_CACHE_SIZE, wxPoint(0,0), & partialExtents); @@ -5117,7 +5117,7 @@ bool wxRichTextPlainText::DrawTabbedString(wxDC& dc, const wxRichTextAttr& attr, dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); } - wxCoord x_orig = x; + wxCoord x_orig = GetParent()->GetPosition().x; while (hasTabs) { // the string has a tab @@ -5216,6 +5216,7 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz wxRichTextParagraph* para = wxDynamicCast(GetParent(), wxRichTextParagraph); wxASSERT (para != NULL); + int relativeX = position.x - GetParent()->GetPosition().x; wxRichTextAttr textAttr(para ? para->GetCombinedAttributes(GetAttributes()) : GetAttributes()); @@ -5302,9 +5303,9 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz partialExtents->Add(oldWidth + p[j]); if (partialExtents->GetCount() > 0) - absoluteWidth = (*partialExtents)[(*partialExtents).GetCount()-1] + position.x; + absoluteWidth = (*partialExtents)[(*partialExtents).GetCount()-1] + relativeX; else - absoluteWidth = position.x; + absoluteWidth = relativeX; } else { @@ -5331,7 +5332,7 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz } notFound = false; - width = nextTabPos - position.x; + width = nextTabPos - relativeX; if (partialExtents) partialExtents->Add(width); @@ -6535,7 +6536,11 @@ bool wxRichTextBuffer::PasteFromClipboard(long position) delete richTextBuffer; } } - else if (wxTheClipboard->IsSupported(wxDF_TEXT) || wxTheClipboard->IsSupported(wxDF_UNICODETEXT)) + else if (wxTheClipboard->IsSupported(wxDF_TEXT) +#if wxUSE_UNICODE + || wxTheClipboard->IsSupported(wxDF_UNICODETEXT) +#endif // wxUSE_UNICODE + ) { wxTextDataObject data; wxTheClipboard->GetData(data); @@ -6599,9 +6604,12 @@ bool wxRichTextBuffer::CanPasteFromClipboard() const #if wxUSE_CLIPBOARD && wxUSE_DATAOBJ if (!wxTheClipboard->IsOpened() && wxTheClipboard->Open()) { - if (wxTheClipboard->IsSupported(wxDF_TEXT) || wxTheClipboard->IsSupported(wxDF_UNICODETEXT) || - wxTheClipboard->IsSupported(wxDataFormat(wxRichTextBufferDataObject::GetRichTextBufferFormatId())) || - wxTheClipboard->IsSupported(wxDF_BITMAP)) + if (wxTheClipboard->IsSupported(wxDF_TEXT) +#if wxUSE_UNICODE + || wxTheClipboard->IsSupported(wxDF_UNICODETEXT) +#endif // wxUSE_UNICODE + || wxTheClipboard->IsSupported(wxDataFormat(wxRichTextBufferDataObject::GetRichTextBufferFormatId())) + || wxTheClipboard->IsSupported(wxDF_BITMAP)) { canPaste = true; } @@ -6866,26 +6874,59 @@ bool wxRichTextStdRenderer::EnumerateStandardBulletNames(wxArrayString& bulletNa IMPLEMENT_DYNAMIC_CLASS(wxRichTextBox, wxRichTextCompositeObject) wxRichTextBox::wxRichTextBox(wxRichTextObject* parent): - wxRichTextParagraphLayoutBox(parent) + wxRichTextCompositeObject(parent) { } /// Draw the item -bool wxRichTextBox::Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int style) +bool wxRichTextBox::Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& WXUNUSED(rect), int descent, int style) { - return wxRichTextParagraphLayoutBox::Draw(dc, range, selectionRange, rect, descent, style); + wxRichTextObjectList::compatibility_iterator node = m_children.GetFirst(); + while (node) + { + wxRichTextObject* child = node->GetData(); + + wxRect childRect = wxRect(child->GetPosition(), child->GetCachedSize()); + child->Draw(dc, range, selectionRange, childRect, descent, style); + + node = node->GetNext(); + } + return true; } /// Lay the item out bool wxRichTextBox::Layout(wxDC& dc, const wxRect& rect, int style) { - return wxRichTextParagraphLayoutBox::Layout(dc, rect, style); + wxRichTextObjectList::compatibility_iterator node = m_children.GetFirst(); + while (node) + { + wxRichTextObject* child = node->GetData(); + child->Layout(dc, rect, style); + + node = node->GetNext(); + } + m_dirty = false; + return true; + } /// Copy void wxRichTextBox::Copy(const wxRichTextBox& obj) { - wxRichTextParagraphLayoutBox::Copy(obj); + wxRichTextCompositeObject::Copy(obj); +} + +/// Get/set the size for the given range. Assume only has one child. +bool wxRichTextBox::GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position, wxArrayInt* partialExtents) const +{ + wxRichTextObjectList::compatibility_iterator node = m_children.GetFirst(); + if (node) + { + wxRichTextObject* child = node->GetData(); + return child->GetRangeSize(range, size, descent, dc, flags, position, partialExtents); + } + else + return false; } /* @@ -7804,7 +7845,7 @@ bool wxRichTextImageBlock::DoMakeImageBlock(const wxImage& image, wxBitmapType i unsigned char* block = new unsigned char[memStream.GetSize()]; if (!block) - return NULL; + return false; if (m_data) delete[] m_data; @@ -8656,6 +8697,16 @@ void wxTextAttrDimension::CollectCommonAttributes(const wxTextAttrDimension& att absentAttr.SetPresent(true); } +wxTextAttrDimensionConverter::wxTextAttrDimensionConverter(wxDC& dc, double scale, const wxSize& parentSize) +{ + m_ppi = dc.GetPPI().x; m_scale = scale; m_parentSize = parentSize; +} + +wxTextAttrDimensionConverter::wxTextAttrDimensionConverter(int ppi, double scale, const wxSize& parentSize) +{ + m_ppi = ppi; m_scale = scale; m_parentSize = parentSize; +} + int wxTextAttrDimensionConverter::ConvertTenthsMMToPixels(int units) const { return wxRichTextObject::ConvertTenthsMMToPixels(m_ppi, units, m_scale);