Centre/right justification fix when there is a right indent

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@57004 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2008-11-28 16:05:11 +00:00
parent 4b08e76925
commit 2f4390c06b

View File

@@ -3834,6 +3834,8 @@ static int wxRichTextGetRangeWidth(const wxRichTextParagraph& para, const wxRich
return w; return w;
} }
static wxDC* g_globalDC = NULL;
/// Lay the item out /// Lay the item out
bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style) bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style)
{ {
@@ -4099,7 +4101,9 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style)
ClearUnusedLines(lineCount); ClearUnusedLines(lineCount);
// Apply styles to wrapped lines // Apply styles to wrapped lines
g_globalDC = & dc;
ApplyParagraphStyle(attr, rect); ApplyParagraphStyle(attr, rect);
g_globalDC = NULL;
SetCachedSize(wxSize(maxWidth, currentPosition.y + spaceBeforePara + spaceAfterPara)); SetCachedSize(wxSize(maxWidth, currentPosition.y + spaceBeforePara + spaceAfterPara));
@@ -4169,12 +4173,14 @@ void wxRichTextParagraph::ApplyParagraphStyle(const wxTextAttrEx& attr, const wx
// centering, right-justification // centering, right-justification
if (attr.HasAlignment() && GetAttributes().GetAlignment() == wxTEXT_ALIGNMENT_CENTRE) if (attr.HasAlignment() && GetAttributes().GetAlignment() == wxTEXT_ALIGNMENT_CENTRE)
{ {
pos.x = (rect.GetWidth() - (pos.x - rect.x) - size.x)/2 + pos.x; int rightIndent = ConvertTenthsMMToPixels(* g_globalDC, attr.GetRightIndent());
pos.x = (rect.GetWidth() - (pos.x - rect.x) - rightIndent - size.x)/2 + pos.x;
line->SetPosition(pos); line->SetPosition(pos);
} }
else if (attr.HasAlignment() && GetAttributes().GetAlignment() == wxTEXT_ALIGNMENT_RIGHT) else if (attr.HasAlignment() && GetAttributes().GetAlignment() == wxTEXT_ALIGNMENT_RIGHT)
{ {
pos.x = rect.x + rect.GetWidth() - size.x; int rightIndent = ConvertTenthsMMToPixels(* g_globalDC, attr.GetRightIndent());
pos.x = rect.x + rect.GetWidth() - size.x - rightIndent;
line->SetPosition(pos); line->SetPosition(pos);
} }