#include <wx/wx.h>
#endif
-#include <wx/wxexpr.h>
+#if wxUSE_PROLOGIO
+#include <wx/deprecated/wxexpr.h>
+#endif
#ifdef new
#undef new
#include <ctype.h>
#include <math.h>
-#include <wx/ogl/basic.h>
-#include <wx/ogl/basicp.h>
-#include <wx/ogl/lines.h>
-#include <wx/ogl/linesp.h>
-#include <wx/ogl/drawn.h>
-#include <wx/ogl/misc.h>
-#include <wx/ogl/canvas.h>
+#include "wx/ogl/ogl.h"
+
// Line shape
IMPLEMENT_DYNAMIC_CLASS(wxLineShape, wxShape)
wxRealPoint *point1 = (wxRealPoint *)node->GetData();
wxRealPoint *point2 = (wxRealPoint *)node->GetNext()->GetData();
- // Allow for inaccurate mousing or vert/horiz lines
+ // For inaccurate mousing allow 8 pixel corridor
int extra = 4;
- double left = wxMin(point1->x, point2->x) - extra;
- double right = wxMax(point1->x, point2->x) + extra;
-
- double bottom = wxMin(point1->y, point2->y) - extra;
- double top = wxMax(point1->y, point2->y) + extra;
- if ((x > left && x < right && y > bottom && y < top) || inLabelRegion)
+ double dx = point2->x - point1->x;
+ double dy = point2->y - point1->y;
+ double seg_len = sqrt(dx*dx+dy*dy);
+ double distance_from_seg =
+ seg_len*((x-point1->x)*dy-(y-point1->y)*dx)/(dy*dy+dx*dx);
+ double distance_from_prev =
+ seg_len*((y-point1->y)*dy+(x-point1->x)*dx)/(dy*dy+dx*dx);
+
+ if ((fabs(distance_from_seg) < extra &&
+ distance_from_prev >= 0 && distance_from_prev <= seg_len)
+ || inLabelRegion)
{
- // Work out distance from centre of line
- double centre_x = (double)(left + (right - left)/2.0);
- double centre_y = (double)(bottom + (top - bottom)/2.0);
-
*attachment = 0;
- *distance = (double)sqrt((centre_x - x)*(centre_x - x) + (centre_y - y)*(centre_y - y));
+ *distance = distance_from_seg;
return TRUE;
}
*no_arcs = num;
}
-void wxLineShape::OnDrawOutline(wxDC& dc, double x, double y, double w, double h)
+void wxLineShape::OnDrawOutline(wxDC& dc, double WXUNUSED(x), double WXUNUSED(y), double WXUNUSED(w), double WXUNUSED(h))
{
wxPen *old_pen = m_pen;
wxBrush *old_brush = m_brush;
else SetBrush(NULL);
}
-bool wxLineShape::OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display)
+bool wxLineShape::OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool WXUNUSED(display))
{
double x_offset = x - old_x;
double y_offset = y - old_y;
FindLineEndPoints(&end_x, &end_y, &other_end_x, &other_end_y);
wxNode *first = m_lineControlPoints->GetFirst();
- wxRealPoint *first_point = (wxRealPoint *)first->GetData();
+ /* wxRealPoint *first_point = */ (wxRealPoint *)first->GetData();
wxNode *last = m_lineControlPoints->GetLast();
- wxRealPoint *last_point = (wxRealPoint *)last->GetData();
+ /* wxRealPoint *last_point = */ (wxRealPoint *)last->GetData();
/* This is redundant, surely? Done by SetEnds.
first_point->x = end_x; first_point->y = end_y;
double other_end_x, other_end_y;
wxNode *first = m_lineControlPoints->GetFirst();
- wxRealPoint *first_point = (wxRealPoint *)first->GetData();
+ /* wxRealPoint *first_point = */ (wxRealPoint *)first->GetData();
wxNode *last = m_lineControlPoints->GetLast();
- wxRealPoint *last_point = (wxRealPoint *)last->GetData();
+ /* wxRealPoint *last_point = */ (wxRealPoint *)last->GetData();
wxNode *second = first->GetNext();
wxRealPoint *second_point = (wxRealPoint *)second->GetData();
wxShape::OnEraseControlPoints(dc);
}
-void wxLineShape::OnDragLeft(bool draw, double x, double y, int keys, int attachment)
+void wxLineShape::OnDragLeft(bool WXUNUSED(draw), double WXUNUSED(x), double WXUNUSED(y), int WXUNUSED(keys), int WXUNUSED(attachment))
{
}
-void wxLineShape::OnBeginDragLeft(double x, double y, int keys, int attachment)
+void wxLineShape::OnBeginDragLeft(double WXUNUSED(x), double WXUNUSED(y), int WXUNUSED(keys), int WXUNUSED(attachment))
{
}
-void wxLineShape::OnEndDragLeft(double x, double y, int keys, int attachment)
+void wxLineShape::OnEndDragLeft(double WXUNUSED(x), double WXUNUSED(y), int WXUNUSED(keys), int WXUNUSED(attachment))
{
}
wxShape::WriteAttributes(clause);
if (m_from)
- clause->AddAttributeValue("from", m_from->GetId());
+ clause->AddAttributeValue(_T("from"), m_from->GetId());
if (m_to)
- clause->AddAttributeValue("to", m_to->GetId());
+ clause->AddAttributeValue(_T("to"), m_to->GetId());
if (m_attachmentTo != 0)
- clause->AddAttributeValue("attachment_to", (long)m_attachmentTo);
+ clause->AddAttributeValue(_T("attachment_to"), (long)m_attachmentTo);
if (m_attachmentFrom != 0)
- clause->AddAttributeValue("attachment_from", (long)m_attachmentFrom);
+ clause->AddAttributeValue(_T("attachment_from"), (long)m_attachmentFrom);
if (m_alignmentStart != 0)
- clause->AddAttributeValue("align_start", (long)m_alignmentStart);
+ clause->AddAttributeValue(_T("align_start"), (long)m_alignmentStart);
if (m_alignmentEnd != 0)
- clause->AddAttributeValue("align_end", (long)m_alignmentEnd);
+ clause->AddAttributeValue(_T("align_end"), (long)m_alignmentEnd);
- clause->AddAttributeValue("is_spline", (long)m_isSpline);
+ clause->AddAttributeValue(_T("is_spline"), (long)m_isSpline);
if (m_maintainStraightLines)
- clause->AddAttributeValue("keep_lines_straight", (long)m_maintainStraightLines);
+ clause->AddAttributeValue(_T("keep_lines_straight"), (long)m_maintainStraightLines);
// Make a list of lists for the (sp)line controls
wxExpr *list = new wxExpr(wxExprList);
node = node->GetNext();
}
- clause->AddAttributeValue("controls", list);
+ clause->AddAttributeValue(_T("controls"), list);
// Write arc arrows in new OGL format, if there are any.
// This is a list of lists. Each sublist comprises:
node = node->GetNext();
}
- clause->AddAttributeValue("arrows", arrow_list);
+ clause->AddAttributeValue(_T("arrows"), arrow_list);
}
}
if (m_regions.GetCount() == 0)
{
wxShapeRegion *newRegion = new wxShapeRegion;
- newRegion->SetName("Middle");
+ newRegion->SetName(_T("Middle"));
newRegion->SetSize(150, 50);
m_regions.Append((wxObject *)newRegion);
if (m_text.GetCount() > 0)
wxString arrowName;
long arrowId = -1;
- wxExpr *type_expr = node->Item(0);
- wxExpr *end_expr = node->Item(1);
- wxExpr *dist_expr = node->Item(2);
- wxExpr *size_expr = node->Item(3);
- wxExpr *name_expr = node->Item(4);
- wxExpr *id_expr = node->Item(5);
+ wxExpr *type_expr = node->Nth(0);
+ wxExpr *end_expr = node->Nth(1);
+ wxExpr *dist_expr = node->Nth(2);
+ wxExpr *size_expr = node->Nth(3);
+ wxExpr *name_expr = node->Nth(4);
+ wxExpr *id_expr = node->Nth(5);
// New members of wxArrowHead
- wxExpr *yOffsetExpr = node->Item(6);
- wxExpr *spacingExpr = node->Item(7);
+ wxExpr *yOffsetExpr = node->Nth(6);
+ wxExpr *spacingExpr = node->Nth(7);
if (type_expr)
arrowType = (int)type_expr->IntegerValue();
// Control points ('handles') redirect control to the actual shape, to make it easier
// to override sizing behaviour.
-void wxLineShape::OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y, int keys, int attachment)
+void wxLineShape::OnSizingDragLeft(wxControlPoint* pt, bool WXUNUSED(draw), double x, double y, int WXUNUSED(keys), int WXUNUSED(attachment))
{
wxLineControlPoint* lpt = (wxLineControlPoint*) pt;
}
-void wxLineShape::OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys, int attachment)
+void wxLineShape::OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int WXUNUSED(keys), int WXUNUSED(attachment))
{
wxLineControlPoint* lpt = (wxLineControlPoint*) pt;
}
}
-void wxLineShape::OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int keys, int attachment)
+void wxLineShape::OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int WXUNUSED(keys), int WXUNUSED(attachment))
{
wxLineControlPoint* lpt = (wxLineControlPoint*) pt;
dc.DrawRectangle(WXROUND(x1), WXROUND(y1), WXROUND(m_width), WXROUND(m_height));
}
-void wxLabelShape::OnDrawContents(wxDC& dc)
+void wxLabelShape::OnDrawContents(wxDC& WXUNUSED(dc))
{
}
return m_lineShape->OnLabelMovePre(dc, this, x, y, old_x, old_y, display);
}
-bool wxLineShape::OnLabelMovePre(wxDC& dc, wxLabelShape* labelShape, double x, double y, double old_x, double old_y, bool display)
+bool wxLineShape::OnLabelMovePre(wxDC& dc, wxLabelShape* labelShape, double x, double y, double WXUNUSED(old_x), double WXUNUSED(old_y), bool WXUNUSED(display))
{
labelShape->m_shapeRegion->SetSize(labelShape->GetWidth(), labelShape->GetHeight());