#include <wx/wxexpr.h>
#endif
-#if USE_IOSTREAMH
+#if wxUSE_IOSTREAMH
#include <iostream.h>
#else
#include <iostream>
EraseRegion(dc, region, xx, yy);
if (m_labelObjects[i])
{
- m_labelObjects[i]->Select(FALSE);
+ m_labelObjects[i]->Select(FALSE, &dc);
m_labelObjects[i]->Erase(dc);
m_labelObjects[i]->SetSize(actualW, actualH);
}
else point2->y = point1->y;
}
-void wxLineShape::Straighten(wxDC& dc)
+void wxLineShape::Straighten(wxDC *dc)
{
if (!m_lineControlPoints || m_lineControlPoints->Number() < 3)
return;
- Erase(dc);
+ if (dc)
+ Erase(* dc);
wxNode *first_point_node = m_lineControlPoints->First();
wxNode *last_point_node = m_lineControlPoints->Last();
node = node->Next();
}
- Draw(dc);
+ if (dc)
+ Draw(* dc);
}
// if (moveControlPoints && m_lineControlPoints && !(x_offset == 0.0 && y_offset == 0.0))
// Only move control points if it's a self link. And only works if attachment mode is ON.
- if ((m_from == m_to) && m_from->GetAttachmentMode() && moveControlPoints && m_lineControlPoints && !(x_offset == 0.0 && y_offset == 0.0))
+ if ((m_from == m_to) && (m_from->GetAttachmentMode() != ATTACHMENT_MODE_NONE) && moveControlPoints && m_lineControlPoints && !(x_offset == 0.0 && y_offset == 0.0))
{
wxNode *node = m_lineControlPoints->First();
while (node)
if (m_lineControlPoints->Number() > 2)
{
- if (m_from->GetAttachmentMode())
+ if (m_from->GetAttachmentMode() != ATTACHMENT_MODE_NONE)
{
int nth, no_arcs;
FindNth(m_from, &nth, &no_arcs, FALSE); // Not incoming
(double)second_point->x, (double)second_point->y,
&end_x, &end_y);
- if (m_to->GetAttachmentMode())
+ if (m_to->GetAttachmentMode() != ATTACHMENT_MODE_NONE)
{
int nth, no_arcs;
FindNth(m_to, &nth, &no_arcs, TRUE); // Incoming
double toX = m_to->GetX();
double toY = m_to->GetY();
- if (m_from->GetAttachmentMode())
+ if (m_from->GetAttachmentMode() != ATTACHMENT_MODE_NONE)
{
int nth, no_arcs;
FindNth(m_from, &nth, &no_arcs, FALSE);
fromY = end_y;
}
- if (m_to->GetAttachmentMode())
+ if (m_to->GetAttachmentMode() != ATTACHMENT_MODE_NONE)
{
int nth, no_arcs;
FindNth(m_to, &nth, &no_arcs, TRUE);
toY = other_end_y;
}
- if (!m_from->GetAttachmentMode())
+ if (m_from->GetAttachmentMode() == ATTACHMENT_MODE_NONE)
(void) m_from->GetPerimeterPoint(m_from->GetX(), m_from->GetY(),
toX, toY,
&end_x, &end_y);
- if (!m_to->GetAttachmentMode())
+ if (m_to->GetAttachmentMode() == ATTACHMENT_MODE_NONE)
(void) m_to->GetPerimeterPoint(m_to->GetX(), m_to->GetY(),
fromX, fromY,
&other_end_x, &other_end_y);
}
}
-
-#ifdef PROLOGIO
-char *wxLineShape::GetFunctor()
-{
- return "arc_image";
-}
-#endif
-
void wxLineShape::SetTo(wxShape *object)
{
m_to = object;
}
#ifdef PROLOGIO
-void wxLineShape::WritePrologAttributes(wxExpr *clause)
+void wxLineShape::WriteAttributes(wxExpr *clause)
{
- wxShape::WritePrologAttributes(clause);
+ wxShape::WriteAttributes(clause);
if (m_from)
clause->AddAttributeValue("from", m_from->GetId());
clause->AddAttributeValue("keep_lines_straight", (long)m_maintainStraightLines);
// Make a list of lists for the (sp)line controls
- wxExpr *list = new wxExpr(PrologList);
+ wxExpr *list = new wxExpr(wxExprList);
wxNode *node = m_lineControlPoints->First();
while (node)
{
wxRealPoint *point = (wxRealPoint *)node->Data();
- wxExpr *point_list = new wxExpr(PrologList);
+ wxExpr *point_list = new wxExpr(wxExprList);
wxExpr *x_expr = new wxExpr((double) point->x);
wxExpr *y_expr = new wxExpr((double) point->y);
point_list->Append(x_expr);
// (arrowType arrowEnd xOffset arrowSize)
if (m_arcArrows.Number() > 0)
{
- wxExpr *arrow_list = new wxExpr(PrologList);
+ wxExpr *arrow_list = new wxExpr(wxExprList);
node = m_arcArrows.First();
while (node)
{
wxArrowHead *head = (wxArrowHead *)node->Data();
- wxExpr *head_list = new wxExpr(PrologList);
+ wxExpr *head_list = new wxExpr(wxExprList);
head_list->Append(new wxExpr((long)head->_GetType()));
head_list->Append(new wxExpr((long)head->GetArrowEnd()));
head_list->Append(new wxExpr(head->GetXOffset()));
head_list->Append(new wxExpr(head->GetArrowSize()));
- head_list->Append(new wxExpr(PrologString, (head->GetName() ? head->GetName() : "")));
+ head_list->Append(new wxExpr(wxExprString, (head->GetName() ? head->GetName() : "")));
head_list->Append(new wxExpr(head->GetId()));
// New members of wxArrowHead
}
}
-void wxLineShape::ReadPrologAttributes(wxExpr *clause)
+void wxLineShape::ReadAttributes(wxExpr *clause)
{
- wxShape::ReadPrologAttributes(clause);
+ wxShape::ReadAttributes(clause);
int iVal = (int) m_isSpline;
clause->AssignAttributeValue("is_spline", &iVal);
m_attachmentFrom = 0;
clause->AssignAttributeValue("attachment_to", &m_attachmentTo);
- clause->AssignAttributeValue("attachmen_from", &m_attachmentFrom);
+ clause->AssignAttributeValue("attachment_from", &m_attachmentFrom);
wxExpr *line_list = NULL;
m_labelObjects[i]->RemoveFromCanvas(m_canvas);
delete m_labelObjects[i];
}
- m_labelObjects[i] = new wxLabelShape(this, region, w, h);
+ m_labelObjects[i] = OnCreateLabelShape(this, region, w, h);
m_labelObjects[i]->AddToCanvas(m_canvas);
m_labelObjects[i]->Show(TRUE);
if (dc)
m_labelObjects[i]->Move(*dc, (double)(x + xx), (double)(y + yy));
- m_labelObjects[i]->Select(TRUE);
+ m_labelObjects[i]->Select(TRUE, dc);
}
}
}
if (m_labelObjects[i])
{
m_labelObjects[i]->Select(FALSE, dc);
+ m_labelObjects[i]->Erase(*dc);
m_labelObjects[i]->RemoveFromCanvas(m_canvas);
delete m_labelObjects[i];
m_labelObjects[i] = NULL;
m_xpos = x;
m_ypos = y;
m_type = the_type;
+ m_point = NULL;
}
wxLineControlPoint::~wxLineControlPoint()
if (lpt->m_type == CONTROL_POINT_ENDPOINT_FROM || lpt->m_type == CONTROL_POINT_ENDPOINT_TO)
{
- lpt->SetX(x); lpt->SetY(y);
+// lpt->SetX(x); lpt->SetY(y);
}
}
wxLineShape *lineShape = (wxLineShape *)this;
if (lpt->m_type == CONTROL_POINT_LINE)
{
+ lpt->m_originalPos = * (lpt->m_point);
m_canvas->Snap(&x, &y);
this->Erase(dc);
if (lpt->m_type == CONTROL_POINT_ENDPOINT_FROM || lpt->m_type == CONTROL_POINT_ENDPOINT_TO)
{
- lpt->Erase(dc);
- lineShape->OnDraw(dc);
- if (lpt->m_type == CONTROL_POINT_ENDPOINT_FROM)
- {
- lineShape->GetFrom()->OnDraw(dc);
- lineShape->GetFrom()->OnDrawContents(dc);
- }
- else
- {
- lineShape->GetTo()->OnDraw(dc);
- lineShape->GetTo()->OnDrawContents(dc);
- }
m_canvas->SetCursor(g_oglBullseyeCursor);
lpt->m_oldCursor = wxSTANDARD_CURSOR;
}
{
m_canvas->Snap(&x, &y);
- dc.SetLogicalFunction(wxCOPY);
- lpt->m_xpos = x; lpt->m_ypos = y;
- lpt->m_point->x = x; lpt->m_point->y = y;
+ wxRealPoint pt = wxRealPoint(x, y);
+
+ // Move the control point back to where it was;
+ // MoveControlPoint will move it to the new position
+ // if it decides it wants. We only moved the position
+ // during user feedback so we could redraw the line
+ // as it changed shape.
+ lpt->m_xpos = lpt->m_originalPos.x; lpt->m_ypos = lpt->m_originalPos.y;
+ lpt->m_point->x = lpt->m_originalPos.x; lpt->m_point->y = lpt->m_originalPos.y;
- lineShape->GetEventHandler()->OnMoveLink(dc);
+ OnMoveMiddleControlPoint(dc, lpt, pt);
}
if (lpt->m_type == CONTROL_POINT_ENDPOINT_FROM)
{
if (lpt->m_oldCursor)
m_canvas->SetCursor(lpt->m_oldCursor);
- this->Erase(dc);
- lpt->m_xpos = x; lpt->m_ypos = y;
+// this->Erase(dc);
+
+// lpt->m_xpos = x; lpt->m_ypos = y;
if (lineShape->GetFrom())
{
if (lpt->m_oldCursor)
m_canvas->SetCursor(lpt->m_oldCursor);
- lpt->m_xpos = x; lpt->m_ypos = y;
+// lpt->m_xpos = x; lpt->m_ypos = y;
if (lineShape->GetTo())
{
// N.B. in OnMoveControlPoint, an event handler in Hardy could have deselected
// the line and therefore deleted 'this'. -> GPF, intermittently.
// So assume at this point that we've been blown away.
- wxLineShape *lineObj = lineShape;
- wxShapeCanvas *objCanvas = m_canvas;
- lineObj->OnMoveControlPoint(i+1, x, y);
+ lineShape->OnMoveControlPoint(i+1, x, y);
#endif
}
+// This is called only when a non-end control point is moved.
+bool wxLineShape::OnMoveMiddleControlPoint(wxDC& dc, wxLineControlPoint* lpt, const wxRealPoint& pt)
+{
+ lpt->m_xpos = pt.x; lpt->m_ypos = pt.y;
+ lpt->m_point->x = pt.x; lpt->m_point->y = pt.y;
+
+ GetEventHandler()->OnMoveLink(dc);
+
+ return TRUE;
+}
+
// Implement movement of endpoint to a new attachment
// OBSOLETE: done by dragging with the left button.
}
}
+// Can override this to create a different class of label shape
+wxLabelShape* wxLineShape::OnCreateLabelShape(wxLineShape *parent, wxShapeRegion *region, double w, double h)
+{
+ return new wxLabelShape(parent, region, w, h);
+}
+
/*
* Label object
*
bool wxLabelShape::OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display)
{
- m_shapeRegion->SetSize(m_width, m_height);
+ 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)
+{
+ labelShape->m_shapeRegion->SetSize(labelShape->GetWidth(), labelShape->GetHeight());
// Find position in line's region list
int i = 0;
- wxNode *node = m_lineShape->GetRegions().First();
+ wxNode *node = GetRegions().First();
while (node)
{
- if (m_shapeRegion == (wxShapeRegion *)node->Data())
+ if (labelShape->m_shapeRegion == (wxShapeRegion *)node->Data())
node = NULL;
else
{
}
}
double xx, yy;
- m_lineShape->GetLabelPosition(i, &xx, &yy);
+ GetLabelPosition(i, &xx, &yy);
// Set the region's offset, relative to the default position for
// each region.
- m_shapeRegion->SetPosition((double)(x - xx), (double)(y - yy));
+ labelShape->m_shapeRegion->SetPosition((double)(x - xx), (double)(y - yy));
+
+ labelShape->SetX(x);
+ labelShape->SetY(y);
// Need to reformat to fit region.
- if (m_shapeRegion->GetText())
+ if (labelShape->m_shapeRegion->GetText())
{
- wxString s(m_shapeRegion->GetText());
- m_lineShape->FormatText(dc, s, i);
- m_lineShape->DrawRegion(dc, m_shapeRegion, xx, yy);
+ wxString s(labelShape->m_shapeRegion->GetText());
+ labelShape->FormatText(dc, s, i);
+ DrawRegion(dc, labelShape->m_shapeRegion, xx, yy);
}
return TRUE;
}