Border drawing corrections
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75878 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -772,6 +772,18 @@ bool wxRichTextObject::DrawBorder(wxDC& dc, wxRichTextBuffer* buffer, const wxRi
|
|||||||
if (cornerRadius > 0)
|
if (cornerRadius > 0)
|
||||||
{
|
{
|
||||||
borderLeft = converter.GetPixels(borders.GetLeft().GetWidth());
|
borderLeft = converter.GetPixels(borders.GetLeft().GetWidth());
|
||||||
|
|
||||||
|
// Compensate for border thickness, since the rectangle borders are centred on the rect
|
||||||
|
wxRect rect2(rect);
|
||||||
|
if (borderLeft > 1)
|
||||||
|
{
|
||||||
|
int inc = (int) ((double(borderLeft) / 2.0) + 0.5);
|
||||||
|
rect2.x += inc;
|
||||||
|
rect2.y += inc;
|
||||||
|
rect2.width -= (2*inc - 1);
|
||||||
|
rect2.height -= (2*inc - 1);
|
||||||
|
}
|
||||||
|
|
||||||
wxColour col(borders.GetLeft().GetColour());
|
wxColour col(borders.GetLeft().GetColour());
|
||||||
wxPenStyle penStyle = wxPENSTYLE_SOLID;
|
wxPenStyle penStyle = wxPENSTYLE_SOLID;
|
||||||
if (borders.GetLeft().GetStyle() == wxTEXT_BOX_ATTR_BORDER_DOTTED)
|
if (borders.GetLeft().GetStyle() == wxTEXT_BOX_ATTR_BORDER_DOTTED)
|
||||||
@@ -786,11 +798,26 @@ bool wxRichTextObject::DrawBorder(wxDC& dc, wxRichTextBuffer* buffer, const wxRi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't do this, since it can mess up cell drawing in tables when
|
||||||
|
// there are inconsistencies between rectangle and line drawing.
|
||||||
|
#if 0
|
||||||
// Draw the border in one go if all the borders are the same
|
// Draw the border in one go if all the borders are the same
|
||||||
if (borders.GetLeft().IsValid() && (borders.GetLeft().GetWidth().GetValue() > 0) && borders.GetTop().IsValid() && borders.GetRight().IsValid() &&borders.GetBottom().IsValid() &&
|
if (borders.GetLeft().IsValid() && (borders.GetLeft().GetWidth().GetValue() > 0) && borders.GetTop().IsValid() && borders.GetRight().IsValid() &&borders.GetBottom().IsValid() &&
|
||||||
(borders.GetLeft() == borders.GetTop()) && (borders.GetLeft() == borders.GetRight()) && (borders.GetLeft() == borders.GetBottom()))
|
(borders.GetLeft() == borders.GetTop()) && (borders.GetLeft() == borders.GetRight()) && (borders.GetLeft() == borders.GetBottom()))
|
||||||
{
|
{
|
||||||
borderLeft = converter.GetPixels(borders.GetLeft().GetWidth());
|
borderLeft = converter.GetPixels(borders.GetLeft().GetWidth());
|
||||||
|
|
||||||
|
// Compensate for border thickness, since the rectangle borders are centred on the rect
|
||||||
|
wxRect rect2(rect);
|
||||||
|
if (borderLeft > 1)
|
||||||
|
{
|
||||||
|
int inc = (int) ((double(borderLeft) / 2.0) + 0.5);
|
||||||
|
rect2.x += inc;
|
||||||
|
rect2.y += inc;
|
||||||
|
rect2.width -= (2*inc - 1);
|
||||||
|
rect2.height -= (2*inc - 1);
|
||||||
|
}
|
||||||
|
|
||||||
wxColour col(borders.GetLeft().GetColour());
|
wxColour col(borders.GetLeft().GetColour());
|
||||||
wxPenStyle penStyle = wxPENSTYLE_SOLID;
|
wxPenStyle penStyle = wxPENSTYLE_SOLID;
|
||||||
if (borders.GetLeft().GetStyle() == wxTEXT_BOX_ATTR_BORDER_DOTTED)
|
if (borders.GetLeft().GetStyle() == wxTEXT_BOX_ATTR_BORDER_DOTTED)
|
||||||
@@ -804,6 +831,7 @@ bool wxRichTextObject::DrawBorder(wxDC& dc, wxRichTextBuffer* buffer, const wxRi
|
|||||||
dc.DrawRectangle(rect);
|
dc.DrawRectangle(rect);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (borders.GetLeft().IsValid() && (borders.GetLeft().GetWidth().GetValue() > 0) && (borders.GetLeft().GetStyle() != wxTEXT_BOX_ATTR_BORDER_NONE))
|
if (borders.GetLeft().IsValid() && (borders.GetLeft().GetWidth().GetValue() > 0) && (borders.GetLeft().GetStyle() != wxTEXT_BOX_ATTR_BORDER_NONE))
|
||||||
{
|
{
|
||||||
@@ -819,8 +847,14 @@ bool wxRichTextObject::DrawBorder(wxDC& dc, wxRichTextBuffer* buffer, const wxRi
|
|||||||
{
|
{
|
||||||
wxPen pen(col, borderLeft, penStyle);
|
wxPen pen(col, borderLeft, penStyle);
|
||||||
dc.SetPen(pen);
|
dc.SetPen(pen);
|
||||||
// Note that the last point is not drawn.
|
|
||||||
dc.DrawLine(rect.x, rect.y, rect.x, rect.y + rect.height);
|
// Note that the last point is not drawn, at least on GTK+ and Windows.
|
||||||
|
// On Mac, we must compensate.
|
||||||
|
int inc = 0;
|
||||||
|
#ifdef __WXMAC__
|
||||||
|
inc = 1;
|
||||||
|
#endif
|
||||||
|
dc.DrawLine(rect.x, rect.y, rect.x, rect.y + rect.height - inc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -848,8 +882,12 @@ bool wxRichTextObject::DrawBorder(wxDC& dc, wxRichTextBuffer* buffer, const wxRi
|
|||||||
{
|
{
|
||||||
wxPen pen(col, borderRight, penStyle);
|
wxPen pen(col, borderRight, penStyle);
|
||||||
dc.SetPen(pen);
|
dc.SetPen(pen);
|
||||||
// Note that the last point is not drawn.
|
// See note above.
|
||||||
dc.DrawLine(rect.x + rect.width - 1, rect.y, rect.x + rect.width - 1, rect.y + rect.height);
|
int inc = 0;
|
||||||
|
#ifdef __WXMAC__
|
||||||
|
inc = 1;
|
||||||
|
#endif
|
||||||
|
dc.DrawLine(rect.x + rect.width - 1, rect.y, rect.x + rect.width - 1, rect.y + rect.height - inc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -882,7 +920,12 @@ bool wxRichTextObject::DrawBorder(wxDC& dc, wxRichTextBuffer* buffer, const wxRi
|
|||||||
penStyle = wxPENSTYLE_LONG_DASH;
|
penStyle = wxPENSTYLE_LONG_DASH;
|
||||||
wxPen pen(col, borderTop, penStyle);
|
wxPen pen(col, borderTop, penStyle);
|
||||||
dc.SetPen(pen);
|
dc.SetPen(pen);
|
||||||
dc.DrawLine(rect.x, rect.y, rect.x + rect.width, rect.y);
|
// See note above.
|
||||||
|
int inc = 0;
|
||||||
|
#ifdef __WXMAC__
|
||||||
|
inc = 1;
|
||||||
|
#endif
|
||||||
|
dc.DrawLine(rect.x, rect.y, rect.x + rect.width - inc, rect.y);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -909,7 +952,12 @@ bool wxRichTextObject::DrawBorder(wxDC& dc, wxRichTextBuffer* buffer, const wxRi
|
|||||||
{
|
{
|
||||||
wxPen pen(col, borderBottom, penStyle);
|
wxPen pen(col, borderBottom, penStyle);
|
||||||
dc.SetPen(pen);
|
dc.SetPen(pen);
|
||||||
dc.DrawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width, rect.y + rect.height - 1);
|
// See note above.
|
||||||
|
int inc = 0;
|
||||||
|
#ifdef __WXMAC__
|
||||||
|
inc = 1;
|
||||||
|
#endif
|
||||||
|
dc.DrawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width - inc, rect.y + rect.height - 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user