From c9c5fdc03a38ca1d2be6e2f64eed1768a4ff6b86 Mon Sep 17 00:00:00 2001 From: iwbnwif Date: Wed, 19 Apr 2017 19:54:27 +0100 Subject: [PATCH] Wherever the height and width components of a rectangle are used in conjunction with dc.DrawRectangle, 1 needs to be subtracted. This is because rect.x + rect.width != rect.right (in fact it equals rect.right + 1) A better fix for #18. --- src/axis/labelaxis.cpp | 8 ++++---- src/axisplot.cpp | 8 +++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/axis/labelaxis.cpp b/src/axis/labelaxis.cpp index 5ea32bd4..13ed7aa7 100755 --- a/src/axis/labelaxis.cpp +++ b/src/axis/labelaxis.cpp @@ -300,9 +300,9 @@ void LabelAxis::DrawGridLines(wxDC &dc, wxRect rc) if (IsVertical()) { // Vertical axis, so gridlines are horizontal. - wxCoord y = ToGraphics(dc, rc.y, rc.height, value); + wxCoord y = ToGraphics(dc, rc.y, rc.height - 1, value); - if (y == rc.y || y == (rc.y + rc.height)) + if (y == rc.y || y == (rc.y + rc.height - 1)) continue; dc.DrawLine(rc.x + 1, y, rc.x + rc.width - 1, y); @@ -311,9 +311,9 @@ void LabelAxis::DrawGridLines(wxDC &dc, wxRect rc) else { // Horizontal axis, so gridlines are vertical. - wxCoord x = ToGraphics(dc, rc.x, rc.width, value); + wxCoord x = ToGraphics(dc, rc.x, rc.width - 1, value); - if (x == rc.x || x == (rc.x + rc.width)) + if (x == rc.x || x == (rc.x + rc.width - 1)) continue; dc.DrawLine(x, rc.y + 1, x, rc.y + rc.height - 1); diff --git a/src/axisplot.cpp b/src/axisplot.cpp index 4ec29575..265fe178 100755 --- a/src/axisplot.cpp +++ b/src/axisplot.cpp @@ -435,7 +435,7 @@ void AxisPlot::DrawAxesArray(wxDC &dc, wxRect rc, AxisArray *axes, bool vertical void AxisPlot::DrawAxes(wxDC &dc, wxRect &rc, wxRect rcData) { if (m_leftAxes.Count() != 0) { - wxRect rcLeftAxes(rc.x, rcData.y, (rcData.x - rc.x), rcData.height); + wxRect rcLeftAxes(rc.x, rcData.y, (rcData.x - rc.x), rcData.height - 1); DrawAxesArray(dc, rcLeftAxes, &m_leftAxes, true); } if (m_rightAxes.Count() != 0) { @@ -448,7 +448,7 @@ void AxisPlot::DrawAxes(wxDC &dc, wxRect &rc, wxRect rcData) DrawAxesArray(dc, rcTopAxes, &m_topAxes, false); } if (m_bottomAxes.Count() != 0) { - wxRect rcBottomAxes(rcData.x, rcData.y + rcData.height, rcData.width, (rc.y + rc.height - rcData.y - rcData.height - 1)); + wxRect rcBottomAxes(rcData.x, rcData.y + rcData.height - 1, rcData.width, (rc.y + rc.height - rcData.y - rcData.height - 1)); DrawAxesArray(dc, rcBottomAxes, &m_bottomAxes, false); } } @@ -491,9 +491,7 @@ void AxisPlot::DrawBackground(ChartDC& cdc, wxRect rc) // Calculate the rectangle where the actual data is plotted. CalcDataArea(dc, rc, rcPlot, rcLegend); - // Draw the background of the plot area. - // Is there a bug in dc.DrawRectangle? It seems the rectangle is 1 pixel smaller in height than it should be. - m_dataBackground->Draw(dc, wxRect(rcPlot.x, rcPlot.y, rcPlot.width, rcPlot.height + 1)); + m_dataBackground->Draw(dc, rcPlot); // m_background->Draw(dc, rcPlot); // Draw all static items.