Implemented vertical image alignment.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@77723 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2014-09-18 14:40:03 +00:00
parent 9a8aa7899c
commit e99be2e276

View File

@@ -12169,11 +12169,26 @@ bool wxRichTextImage::Draw(wxDC& dc, wxRichTextDrawingContext& context, const wx
wxRichTextAttr attr(GetAttributes());
AdjustAttributes(attr, context);
DrawBoxAttributes(dc, GetBuffer(), attr, wxRect(rect.GetPosition(), GetCachedSize()));
wxPoint position = rect.GetPosition();
if (attr.GetTextBoxAttr().HasVerticalAlignment() &&
(attr.GetTextBoxAttr().GetVerticalAlignment() > wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_TOP))
{
int leftOverSpace = rect.height - GetCachedSize().y;
if (leftOverSpace > 0)
{
if (attr.GetTextBoxAttr().GetVerticalAlignment() == wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_CENTRE)
position.y += (leftOverSpace/2);
else if (attr.GetTextBoxAttr().GetVerticalAlignment() == wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_BOTTOM)
position.y += leftOverSpace;
}
}
DrawBoxAttributes(dc, GetBuffer(), attr, wxRect(position, GetCachedSize()));
wxSize imageSize(m_imageCache.GetWidth(), m_imageCache.GetHeight());
wxRect marginRect, borderRect, contentRect, paddingRect, outlineRect;
marginRect = rect; // outer rectangle, will calculate contentRect
marginRect = wxRect(position, GetCachedSize()); // outer rectangle, will calculate contentRect
GetBoxRects(dc, GetBuffer(), attr, marginRect, borderRect, contentRect, paddingRect, outlineRect);
dc.DrawBitmap(m_imageCache, contentRect.x, contentRect.y, true);