m_bottomMargin = bottomMargin;
}
-// Convert units in tends of a millimetre to device units
+// Convert units in tenths of a millimetre to device units
int wxRichTextObject::ConvertTenthsMMToPixels(wxDC& dc, int units)
{
- int ppi = dc.GetPPI().x;
+ int p = ConvertTenthsMMToPixels(dc.GetPPI().x, units);
+ // Unscale
+ wxRichTextBuffer* buffer = GetBuffer();
+ if (buffer)
+ p = (int) ((double)p / buffer->GetScale());
+ return p;
+}
+
+// Convert units in tenths of a millimetre to device units
+int wxRichTextObject::ConvertTenthsMMToPixels(int ppi, int units)
+{
// There are ppi pixels in 254.1 "1/10 mm"
double pixels = ((double) units * (double)ppi) / 254.1;
stream << wxString::Format(wxT("Text colour: %d,%d,%d."), (int) m_attributes.GetTextColour().Red(), (int) m_attributes.GetTextColour().Green(), (int) m_attributes.GetTextColour().Blue()) << wxT("\n");
}
+/// Gets the containing buffer
+wxRichTextBuffer* wxRichTextObject::GetBuffer() const
+{
+ const wxRichTextObject* obj = this;
+ while (obj && !obj->IsKindOf(CLASSINFO(wxRichTextBuffer)))
+ obj = obj->GetParent();
+ return wxDynamicCast(obj, wxRichTextBuffer);
+}
/*!
* wxRichTextCompositeObject
{
wxRect childRect(child->GetPosition(), child->GetCachedSize());
- if (childRect.GetTop() > rect.GetBottom() || childRect.GetBottom() < rect.GetTop())
+ if (((style & wxRICHTEXT_DRAW_IGNORE_CACHE) == 0) && childRect.GetTop() > rect.GetBottom() || childRect.GetBottom() < rect.GetTop())
{
// Skip
}
else
- child->Draw(dc, child->GetRange(), selectionRange, childRect, descent, style);
+ child->Draw(dc, range, selectionRange, childRect, descent, style);
}
node = node->GetNext();
bool formatRect = (style & wxRICHTEXT_LAYOUT_SPECIFIED_RECT) == wxRICHTEXT_LAYOUT_SPECIFIED_RECT;
// If only laying out a specific area, the passed rect has a different meaning:
- // the visible part of the buffer.
+ // the visible part of the buffer. This is used in wxRichTextCtrl::OnSize,
+ // so that during a size, only the visible part will be relaid out, or
+ // it would take too long causing flicker. As an approximation, we assume that
+ // everything up to the start of the visible area is laid out correctly.
if (formatRect)
{
availableSpace = wxRect(0 + m_leftMargin,
Clear();
AddParagraph(wxEmptyString);
+
+ Invalidate(wxRICHTEXT_ALL);
}
/// Invalidate the buffer. With no argument, invalidates whole buffer.
}
/// Draw the item
-bool wxRichTextParagraph::Draw(wxDC& dc, const wxRichTextRange& WXUNUSED(range), const wxRichTextRange& selectionRange, const wxRect& WXUNUSED(rect), int WXUNUSED(descent), int style)
+bool wxRichTextParagraph::Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& WXUNUSED(rect), int WXUNUSED(descent), int style)
{
#if wxRICHTEXT_USE_DYNAMIC_STYLES
wxTextAttrEx attr = GetCombinedAttributes();
while (node2)
{
wxRichTextObject* child = node2->GetData();
- if (!child->GetRange().IsOutside(lineRange))
+
+ if (!child->GetRange().IsOutside(lineRange) && !lineRange.IsOutside(range))
{
// Draw this part of the line at the correct position
wxRichTextRange objectRange(child->GetRange());
}
else if (attr.HasAlignment() && GetAttributes().GetAlignment() == wxTEXT_ALIGNMENT_RIGHT)
{
- pos.x = rect.GetRight() - size.x;
+ pos.x = pos.x + rect.GetWidth() - size.x;
line->SetPosition(pos);
}
m_batchedCommand = NULL;
m_suppressUndo = 0;
m_handlerFlags = 0;
+ m_scale = 1.0;
}
/// Initialisation
ClearEventHandlers();
}
-void wxRichTextBuffer::Clear()
+void wxRichTextBuffer::ResetAndClearCommands()
{
- DeleteChildren();
+ Reset();
+
GetCommandProcessor()->ClearCommands();
- Modify(false);
- Invalidate(wxRICHTEXT_ALL);
-}
-void wxRichTextBuffer::Reset()
-{
- DeleteChildren();
- AddParagraph(wxEmptyString);
- GetCommandProcessor()->ClearCommands();
Modify(false);
Invalidate(wxRICHTEXT_ALL);
}
{
wxRichTextAttr numberingAttr;
if (FindNextParagraphNumber(para, numberingAttr))
- wxRichTextApplyStyle(attr, numberingAttr);
+ wxRichTextApplyStyle(attr, (const wxRichTextAttr&) numberingAttr);
}
return attr;
sm_renderer = renderer;
}
-bool wxRichTextStdRenderer::DrawStandardBullet(wxRichTextParagraph* WXUNUSED(paragraph), wxDC& dc, const wxTextAttrEx& bulletAttr, const wxRect& rect)
+bool wxRichTextStdRenderer::DrawStandardBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttrEx& bulletAttr, const wxRect& rect)
{
if (bulletAttr.GetTextColour().Ok())
{
y = y + (charHeight+1)/2 - (bulletHeight+1)/2;
// The margin between a bullet and text.
- int margin = wxRichTextObject::ConvertTenthsMMToPixels(dc, wxRichTextBuffer::GetBulletRightMargin());
+ int margin = paragraph->ConvertTenthsMMToPixels(dc, wxRichTextBuffer::GetBulletRightMargin());
if (bulletAttr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT)
x = rect.x + rect.width - bulletWidth - margin;
return true;
}
-bool wxRichTextStdRenderer::DrawTextBullet(wxRichTextParagraph* WXUNUSED(paragraph), wxDC& dc, const wxTextAttrEx& attr, const wxRect& rect, const wxString& text)
+bool wxRichTextStdRenderer::DrawTextBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttrEx& attr, const wxRect& rect, const wxString& text)
{
if (!text.empty())
{
int y = rect.y + (rect.height - charHeight);
// The margin between a bullet and text.
- int margin = wxRichTextObject::ConvertTenthsMMToPixels(dc, wxRichTextBuffer::GetBulletRightMargin());
+ int margin = paragraph->ConvertTenthsMMToPixels(dc, wxRichTextBuffer::GetBulletRightMargin());
if (attr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT)
x = (rect.x + rect.width) - tw - margin;
return true;
}
+bool wxRichTextApplyStyle(wxRichTextAttr& destStyle, const wxRichTextAttr& style, wxRichTextAttr* compareWith)
+{
+ wxTextAttrEx attr(destStyle);
+ wxRichTextApplyStyle(attr, style, compareWith);
+ destStyle = attr;
+ return true;
+}
+
bool wxRichTextApplyStyle(wxTextAttrEx& destStyle, const wxRichTextAttr& style, wxRichTextAttr* compareWith)
{
// Whole font. Avoiding setting individual attributes if possible, since