Compile fix

Centre/right justification fix when there is a right indent


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57003 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2008-11-28 16:04:55 +00:00
parent 34b4899df5
commit 43a0d1e1e9
2 changed files with 8 additions and 6 deletions

View File

@@ -980,7 +980,7 @@ public:
// Implementation // Implementation
/// Apply paragraph styles such as centering to the wrapped lines /// Apply paragraph styles such as centering to the wrapped lines
virtual void ApplyParagraphStyle(const wxTextAttr& attr, const wxRect& rect); virtual void ApplyParagraphStyle(const wxTextAttr& attr, const wxRect& rect, wxDC& dc);
/// Insert text at the given position /// Insert text at the given position
virtual bool InsertText(long pos, const wxString& text); virtual bool InsertText(long pos, const wxString& text);

View File

@@ -3550,7 +3550,7 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style)
ClearUnusedLines(lineCount); ClearUnusedLines(lineCount);
// Apply styles to wrapped lines // Apply styles to wrapped lines
ApplyParagraphStyle(attr, rect); ApplyParagraphStyle(attr, rect, dc);
SetCachedSize(wxSize(maxWidth, currentPosition.y + spaceBeforePara + spaceAfterPara)); SetCachedSize(wxSize(maxWidth, currentPosition.y + spaceBeforePara + spaceAfterPara));
@@ -3602,7 +3602,7 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style)
} }
/// Apply paragraph styles, such as centering, to wrapped lines /// Apply paragraph styles, such as centering, to wrapped lines
void wxRichTextParagraph::ApplyParagraphStyle(const wxTextAttr& attr, const wxRect& rect) void wxRichTextParagraph::ApplyParagraphStyle(const wxTextAttr& attr, const wxRect& rect, wxDC& dc)
{ {
if (!attr.HasAlignment()) if (!attr.HasAlignment())
return; return;
@@ -3618,12 +3618,14 @@ void wxRichTextParagraph::ApplyParagraphStyle(const wxTextAttr& attr, const wxRe
// 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(dc, 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(dc, attr.GetRightIndent());
pos.x = rect.x + rect.GetWidth() - size.x - rightIndent;
line->SetPosition(pos); line->SetPosition(pos);
} }
@@ -4228,7 +4230,7 @@ bool wxRichTextParagraph::FindWrapPosition(const wxRichTextRange& range, wxDC& d
widthBefore = 0; widthBefore = 0;
size_t i; size_t i;
for (i = (size_t) range.GetStart(); i= < (size_t) range.GetEnd(); i++) for (i = (size_t) range.GetStart(); i <= (size_t) range.GetEnd(); i++)
{ {
int widthFromStartOfThisRange = (*partialExtents)[i - GetRange().GetStart()] - widthBefore; int widthFromStartOfThisRange = (*partialExtents)[i - GetRange().GetStart()] - widthBefore;