X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f54b065ea7323231fab3fec0f6160899ac132c2e..31d7fc0f9cb3f5913ecd4a039a816487a6753a93:/contrib/src/ogl/lines.cpp?ds=sidebyside diff --git a/contrib/src/ogl/lines.cpp b/contrib/src/ogl/lines.cpp index fac1286eac..95e02cb53a 100644 --- a/contrib/src/ogl/lines.cpp +++ b/contrib/src/ogl/lines.cpp @@ -25,7 +25,9 @@ #include #endif -#include +#if wxUSE_PROLOGIO +#include +#endif #ifdef new #undef new @@ -34,13 +36,8 @@ #include #include -#include -#include -#include -#include -#include -#include -#include +#include "wx/ogl/ogl.h" + // Line shape IMPLEMENT_DYNAMIC_CLASS(wxLineShape, wxShape) @@ -118,8 +115,7 @@ void wxLineShape::MakeLineControlPoints(int n) } m_lineControlPoints = new wxList; - int i = 0; - for (i = 0; i < n; i++) + for (int i = 0; i < n; i++) { wxRealPoint *point = new wxRealPoint(-999, -999); m_lineControlPoints->Append((wxObject*) point); @@ -131,10 +127,10 @@ wxNode *wxLineShape::InsertLineControlPoint(wxDC* dc) if (dc) Erase(*dc); - wxNode *last = m_lineControlPoints->Last(); - wxNode *second_last = last->Previous(); - wxRealPoint *last_point = (wxRealPoint *)last->Data(); - wxRealPoint *second_last_point = (wxRealPoint *)second_last->Data(); + wxNode *last = m_lineControlPoints->GetLast(); + wxNode *second_last = last->GetPrevious(); + wxRealPoint *last_point = (wxRealPoint *)last->GetData(); + wxRealPoint *second_last_point = (wxRealPoint *)second_last->GetData(); // Choose a point half way between the last and penultimate points double line_x = ((last_point->x + second_last_point->x)/2); @@ -147,13 +143,13 @@ wxNode *wxLineShape::InsertLineControlPoint(wxDC* dc) bool wxLineShape::DeleteLineControlPoint() { - if (m_lineControlPoints->Number() < 3) + if (m_lineControlPoints->GetCount() < 3) return FALSE; - wxNode *last = m_lineControlPoints->Last(); - wxNode *second_last = last->Previous(); + wxNode *last = m_lineControlPoints->GetLast(); + wxNode *second_last = last->GetPrevious(); - wxRealPoint *second_last_point = (wxRealPoint *)second_last->Data(); + wxRealPoint *second_last_point = (wxRealPoint *)second_last->GetData(); delete second_last_point; delete second_last; @@ -165,19 +161,19 @@ void wxLineShape::Initialise() if (m_lineControlPoints) { // Just move the first and last control points - wxNode *first = m_lineControlPoints->First(); - wxRealPoint *first_point = (wxRealPoint *)first->Data(); + wxNode *first = m_lineControlPoints->GetFirst(); + wxRealPoint *first_point = (wxRealPoint *)first->GetData(); - wxNode *last = m_lineControlPoints->Last(); - wxRealPoint *last_point = (wxRealPoint *)last->Data(); + wxNode *last = m_lineControlPoints->GetLast(); + wxRealPoint *last_point = (wxRealPoint *)last->GetData(); // If any of the line points are at -999, we must // initialize them by placing them half way between the first // and the last. - wxNode *node = first->Next(); + wxNode *node = first->GetNext(); while (node) { - wxRealPoint *point = (wxRealPoint *)node->Data(); + wxRealPoint *point = (wxRealPoint *)node->GetData(); if (point->x == -999) { double x1, y1, x2, y2; @@ -194,7 +190,7 @@ void wxLineShape::Initialise() point->x = ((x2 - x1)/2 + x1); point->y = ((y2 - y1)/2 + y1); } - node = node->Next(); + node = node->GetNext(); } } } @@ -206,13 +202,13 @@ void wxLineShape::FormatText(wxDC& dc, const wxString& s, int i) double w, h; ClearText(i); - if (m_regions.Number() < 1) + if (m_regions.GetCount() < 1) return; - wxNode *node = m_regions.Nth(i); + wxNode *node = m_regions.Item(i); if (!node) return; - wxShapeRegion *region = (wxShapeRegion *)node->Data(); + wxShapeRegion *region = (wxShapeRegion *)node->GetData(); region->SetText(s); dc.SetFont(* region->GetFont()); @@ -225,13 +221,13 @@ void wxLineShape::FormatText(wxDC& dc, const wxString& s, int i) } wxStringList *string_list = oglFormatText(dc, s, (w-5), (h-5), region->GetFormatMode()); - node = string_list->First(); + node = (wxNode*)string_list->GetFirst(); while (node) { - wxChar *s = (wxChar *)node->Data(); + wxChar *s = (wxChar *)node->GetData(); wxShapeTextLine *line = new wxShapeTextLine(0.0, 0.0, s); region->GetFormattedText().Append((wxObject *)line); - node = node->Next(); + node = node->GetNext(); } delete string_list; double actualW = w; @@ -280,7 +276,7 @@ void wxLineShape::DrawRegion(wxDC& dc, wxShapeRegion *region, double x, double y double yp = yy + y; // First, clear a rectangle for the text IF there is any - if (region->GetFormattedText().Number() > 0) + if (region->GetFormattedText().GetCount() > 0) { dc.SetPen(GetBackgroundPen()); dc.SetBrush(GetBackgroundBrush()); @@ -291,7 +287,7 @@ void wxLineShape::DrawRegion(wxDC& dc, wxShapeRegion *region, double x, double y dc.DrawRectangle((long)(xp - w/2.0), (long)(yp - h/2.0), (long)w, (long)h); if (m_pen) dc.SetPen(* m_pen); - dc.SetTextForeground(* region->GetActualColourObject()); + dc.SetTextForeground(region->GetActualColourObject()); #ifdef __WXMSW__ dc.SetTextBackground(GetBackgroundBrush().GetColour()); @@ -316,7 +312,7 @@ void wxLineShape::EraseRegion(wxDC& dc, wxShapeRegion *region, double x, double double xp = xx + x; double yp = yy + y; - if (region->GetFormattedText().Number() > 0) + if (region->GetFormattedText().GetCount() > 0) { dc.SetPen(GetBackgroundPen()); dc.SetBrush(GetBackgroundBrush()); @@ -335,14 +331,14 @@ void wxLineShape::GetLabelPosition(int position, double *x, double *y) case 0: { // Want to take the middle section for the label - int n = m_lineControlPoints->Number(); + int n = m_lineControlPoints->GetCount(); int half_way = (int)(n/2); // Find middle of this line - wxNode *node = m_lineControlPoints->Nth(half_way - 1); - wxRealPoint *point = (wxRealPoint *)node->Data(); - wxNode *next_node = node->Next(); - wxRealPoint *next_point = (wxRealPoint *)next_node->Data(); + wxNode *node = m_lineControlPoints->Item(half_way - 1); + wxRealPoint *point = (wxRealPoint *)node->GetData(); + wxNode *next_node = node->GetNext(); + wxRealPoint *next_point = (wxRealPoint *)next_node->GetData(); double dx = (next_point->x - point->x); double dy = (next_point->y - point->y); @@ -352,16 +348,16 @@ void wxLineShape::GetLabelPosition(int position, double *x, double *y) } case 1: { - wxNode *node = m_lineControlPoints->First(); - *x = ((wxRealPoint *)node->Data())->x; - *y = ((wxRealPoint *)node->Data())->y; + wxNode *node = m_lineControlPoints->GetFirst(); + *x = ((wxRealPoint *)node->GetData())->x; + *y = ((wxRealPoint *)node->GetData())->y; break; } case 2: { - wxNode *node = m_lineControlPoints->Last(); - *x = ((wxRealPoint *)node->Data())->x; - *y = ((wxRealPoint *)node->Data())->y; + wxNode *node = m_lineControlPoints->GetLast(); + *x = ((wxRealPoint *)node->GetData())->x; + *y = ((wxRealPoint *)node->GetData())->y; break; } default: @@ -390,29 +386,29 @@ void GraphicsStraightenLine(wxRealPoint *point1, wxRealPoint *point2) void wxLineShape::Straighten(wxDC *dc) { - if (!m_lineControlPoints || m_lineControlPoints->Number() < 3) + if (!m_lineControlPoints || m_lineControlPoints->GetCount() < 3) return; if (dc) Erase(* dc); - wxNode *first_point_node = m_lineControlPoints->First(); - wxNode *last_point_node = m_lineControlPoints->Last(); - wxNode *second_last_point_node = last_point_node->Previous(); + wxNode *first_point_node = m_lineControlPoints->GetFirst(); + wxNode *last_point_node = m_lineControlPoints->GetLast(); + wxNode *second_last_point_node = last_point_node->GetPrevious(); - wxRealPoint *last_point = (wxRealPoint *)last_point_node->Data(); - wxRealPoint *second_last_point = (wxRealPoint *)second_last_point_node->Data(); + wxRealPoint *last_point = (wxRealPoint *)last_point_node->GetData(); + wxRealPoint *second_last_point = (wxRealPoint *)second_last_point_node->GetData(); GraphicsStraightenLine(last_point, second_last_point); wxNode *node = first_point_node; while (node && (node != second_last_point_node)) { - wxRealPoint *point = (wxRealPoint *)node->Data(); - wxRealPoint *next_point = (wxRealPoint *)(node->Next()->Data()); + wxRealPoint *point = (wxRealPoint *)node->GetData(); + wxRealPoint *next_point = (wxRealPoint *)(node->GetNext()->GetData()); GraphicsStraightenLine(point, next_point); - node = node->Next(); + node = node->GetNext(); } if (dc) @@ -433,10 +429,10 @@ void wxLineShape::Unlink() void wxLineShape::SetEnds(double x1, double y1, double x2, double y2) { // Find centre point - wxNode *first_point_node = m_lineControlPoints->First(); - wxNode *last_point_node = m_lineControlPoints->Last(); - wxRealPoint *first_point = (wxRealPoint *)first_point_node->Data(); - wxRealPoint *last_point = (wxRealPoint *)last_point_node->Data(); + wxNode *first_point_node = m_lineControlPoints->GetFirst(); + wxNode *last_point_node = m_lineControlPoints->GetLast(); + wxRealPoint *first_point = (wxRealPoint *)first_point_node->GetData(); + wxRealPoint *last_point = (wxRealPoint *)last_point_node->GetData(); first_point->x = x1; first_point->y = y1; @@ -450,10 +446,10 @@ void wxLineShape::SetEnds(double x1, double y1, double x2, double y2) // Get absolute positions of ends void wxLineShape::GetEnds(double *x1, double *y1, double *x2, double *y2) { - wxNode *first_point_node = m_lineControlPoints->First(); - wxNode *last_point_node = m_lineControlPoints->Last(); - wxRealPoint *first_point = (wxRealPoint *)first_point_node->Data(); - wxRealPoint *last_point = (wxRealPoint *)last_point_node->Data(); + wxNode *first_point_node = m_lineControlPoints->GetFirst(); + wxNode *last_point_node = m_lineControlPoints->GetLast(); + wxRealPoint *first_point = (wxRealPoint *)first_point_node->GetData(); + wxRealPoint *last_point = (wxRealPoint *)last_point_node->GetData(); *x1 = first_point->x; *y1 = first_point->y; *x2 = last_point->x; *y2 = last_point->y; @@ -474,11 +470,11 @@ bool wxLineShape::HitTest(double x, double y, int *attachment, double *distance) bool inLabelRegion = FALSE; for (int i = 0; i < 3; i ++) { - wxNode *regionNode = m_regions.Nth(i); + wxNode *regionNode = m_regions.Item(i); if (regionNode) { - wxShapeRegion *region = (wxShapeRegion *)regionNode->Data(); - if (region->m_formattedText.Number() > 0) + wxShapeRegion *region = (wxShapeRegion *)regionNode->GetData(); + if (region->m_formattedText.GetCount() > 0) { double xp, yp, cx, cy, cw, ch; GetLabelPosition(i, &xp, &yp); @@ -500,33 +496,34 @@ bool wxLineShape::HitTest(double x, double y, int *attachment, double *distance) } } - wxNode *node = m_lineControlPoints->First(); + wxNode *node = m_lineControlPoints->GetFirst(); - while (node && node->Next()) + while (node && node->GetNext()) { - wxRealPoint *point1 = (wxRealPoint *)node->Data(); - wxRealPoint *point2 = (wxRealPoint *)node->Next()->Data(); + 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; } - node = node->Next(); + node = node->GetNext(); } return FALSE; } @@ -538,10 +535,10 @@ void wxLineShape::DrawArrows(wxDC& dc) double endArrowPos = 0.0; double middleArrowPos = 0.0; - wxNode *node = m_arcArrows.First(); + wxNode *node = m_arcArrows.GetFirst(); while (node) { - wxArrowHead *arrow = (wxArrowHead *)node->Data(); + wxArrowHead *arrow = (wxArrowHead *)node->GetData(); switch (arrow->GetArrowEnd()) { case ARROW_POSITION_START: @@ -580,27 +577,27 @@ void wxLineShape::DrawArrows(wxDC& dc) break; } } - node = node->Next(); + node = node->GetNext(); } } void wxLineShape::DrawArrow(wxDC& dc, wxArrowHead *arrow, double xOffset, bool proportionalOffset) { - wxNode *first_line_node = m_lineControlPoints->First(); - wxRealPoint *first_line_point = (wxRealPoint *)first_line_node->Data(); - wxNode *second_line_node = first_line_node->Next(); - wxRealPoint *second_line_point = (wxRealPoint *)second_line_node->Data(); + wxNode *first_line_node = m_lineControlPoints->GetFirst(); + wxRealPoint *first_line_point = (wxRealPoint *)first_line_node->GetData(); + wxNode *second_line_node = first_line_node->GetNext(); + wxRealPoint *second_line_point = (wxRealPoint *)second_line_node->GetData(); - wxNode *last_line_node = m_lineControlPoints->Last(); - wxRealPoint *last_line_point = (wxRealPoint *)last_line_node->Data(); - wxNode *second_last_line_node = last_line_node->Previous(); - wxRealPoint *second_last_line_point = (wxRealPoint *)second_last_line_node->Data(); + wxNode *last_line_node = m_lineControlPoints->GetLast(); + wxRealPoint *last_line_point = (wxRealPoint *)last_line_node->GetData(); + wxNode *second_last_line_node = last_line_node->GetPrevious(); + wxRealPoint *second_last_line_point = (wxRealPoint *)second_last_line_node->GetData(); // Position where we want to start drawing double positionOnLineX, positionOnLineY; // Position of start point of line, at the end of which we draw the arrow. - double startPositionX, startPositionY; + double startPositionX = 0.0 , startPositionY = 0.0; switch (arrow->GetPosition()) { @@ -693,7 +690,7 @@ void wxLineShape::DrawArrow(wxDC& dc, wxArrowHead *arrow, double xOffset, bool p double y3 = positionOnLineY; double d = -arrow->GetYOffset(); // Negate so +offset is above line - double theta = 0.0; + double theta; if (x3 == x1) theta = (double)(myPi/2.0); else @@ -748,7 +745,7 @@ void wxLineShape::DrawArrow(wxDC& dc, wxArrowHead *arrow, double xOffset, bool p dc.SetPen(* m_pen); if (arrow->_GetType() == ARROW_HOLLOW_CIRCLE) - dc.SetBrush(* g_oglWhiteBackgroundBrush); + dc.SetBrush(GetBackgroundBrush()); else dc.SetBrush(* m_brush); @@ -859,11 +856,11 @@ void wxLineShape::OnErase(wxDC& dc) // Undraw text regions for (int i = 0; i < 3; i++) { - wxNode *node = m_regions.Nth(i); + wxNode *node = m_regions.Item(i); if (node) { double x, y; - wxShapeRegion *region = (wxShapeRegion *)node->Data(); + wxShapeRegion *region = (wxShapeRegion *)node->GetData(); GetLabelPosition(i, &x, &y); EraseRegion(dc, region, x, y); } @@ -899,17 +896,17 @@ void wxLineShape::GetBoundingBoxMin(double *w, double *h) double x2 = -10000; double y2 = -10000; - wxNode *node = m_lineControlPoints->First(); + wxNode *node = m_lineControlPoints->GetFirst(); while (node) { - wxRealPoint *point = (wxRealPoint *)node->Data(); + wxRealPoint *point = (wxRealPoint *)node->GetData(); if (point->x < x1) x1 = point->x; if (point->y < y1) y1 = point->y; if (point->x > x2) x2 = point->x; if (point->y > y2) y2 = point->y; - node = node->Next(); + node = node->GetNext(); } *w = (double)(x2 - x1); *h = (double)(y2 - y1); @@ -924,7 +921,7 @@ void wxLineShape::FindNth(wxShape *image, int *nth, int *no_arcs, bool incoming) { int n = -1; int num = 0; - wxNode *node = image->GetLines().First(); + wxNode *node = image->GetLines().GetFirst(); int this_attachment; if (image == m_to) this_attachment = m_attachmentTo; @@ -934,7 +931,7 @@ void wxLineShape::FindNth(wxShape *image, int *nth, int *no_arcs, bool incoming) // Find number of lines going into/out of this particular attachment point while (node) { - wxLineShape *line = (wxLineShape *)node->Data(); + wxLineShape *line = (wxLineShape *)node->GetData(); if (line->m_from == image) { @@ -958,13 +955,13 @@ void wxLineShape::FindNth(wxShape *image, int *nth, int *no_arcs, bool incoming) num ++; } - node = node->Next(); + node = node->GetNext(); } *nth = n; *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; @@ -981,20 +978,20 @@ void wxLineShape::OnDrawOutline(wxDC& dc, double x, double y, double w, double h 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; if (m_lineControlPoints && !(x_offset == 0.0 && y_offset == 0.0)) { - wxNode *node = m_lineControlPoints->First(); + wxNode *node = m_lineControlPoints->GetFirst(); while (node) { - wxRealPoint *point = (wxRealPoint *)node->Data(); + wxRealPoint *point = (wxRealPoint *)node->GetData(); point->x += x_offset; point->y += y_offset; - node = node->Next(); + node = node->GetNext(); } } @@ -1007,10 +1004,10 @@ bool wxLineShape::OnMovePre(wxDC& dc, double x, double y, double old_x, double o m_labelObjects[i]->Erase(dc); double xp, yp, xr, yr; GetLabelPosition(i, &xp, &yp); - wxNode *node = m_regions.Nth(i); + wxNode *node = m_regions.Item(i); if (node) { - wxShapeRegion *region = (wxShapeRegion *)node->Data(); + wxShapeRegion *region = (wxShapeRegion *)node->GetData(); region->GetPosition(&xr, &yr); } else @@ -1029,7 +1026,7 @@ void wxLineShape::OnMoveLink(wxDC& dc, bool moveControlPoints) if (!m_from || !m_to) return; - if (m_lineControlPoints->Number() > 2) + if (m_lineControlPoints->GetCount() > 2) Initialise(); // Do each end - nothing in the middle. User has to move other points @@ -1039,10 +1036,10 @@ void wxLineShape::OnMoveLink(wxDC& dc, bool moveControlPoints) FindLineEndPoints(&end_x, &end_y, &other_end_x, &other_end_y); - wxNode *first = m_lineControlPoints->First(); - wxRealPoint *first_point = (wxRealPoint *)first->Data(); - wxNode *last = m_lineControlPoints->Last(); - wxRealPoint *last_point = (wxRealPoint *)last->Data(); + wxNode *first = m_lineControlPoints->GetFirst(); + /* wxRealPoint *first_point = */ (wxRealPoint *)first->GetData(); + wxNode *last = m_lineControlPoints->GetLast(); + /* wxRealPoint *last_point = */ (wxRealPoint *)last->GetData(); /* This is redundant, surely? Done by SetEnds. first_point->x = end_x; first_point->y = end_y; @@ -1066,16 +1063,16 @@ void wxLineShape::OnMoveLink(wxDC& dc, bool moveControlPoints) // 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() != ATTACHMENT_MODE_NONE) && moveControlPoints && m_lineControlPoints && !(x_offset == 0.0 && y_offset == 0.0)) { - wxNode *node = m_lineControlPoints->First(); + wxNode *node = m_lineControlPoints->GetFirst(); while (node) { - if ((node != m_lineControlPoints->First()) && (node != m_lineControlPoints->Last())) + if ((node != m_lineControlPoints->GetFirst()) && (node != m_lineControlPoints->GetLast())) { - wxRealPoint *point = (wxRealPoint *)node->Data(); + wxRealPoint *point = (wxRealPoint *)node->GetData(); point->x += x_offset; point->y += y_offset; } - node = node->Next(); + node = node->GetNext(); } } @@ -1096,18 +1093,18 @@ void wxLineShape::FindLineEndPoints(double *fromX, double *fromY, double *toX, d double end_x, end_y; double other_end_x, other_end_y; - wxNode *first = m_lineControlPoints->First(); - wxRealPoint *first_point = (wxRealPoint *)first->Data(); - wxNode *last = m_lineControlPoints->Last(); - wxRealPoint *last_point = (wxRealPoint *)last->Data(); + wxNode *first = m_lineControlPoints->GetFirst(); + /* wxRealPoint *first_point = */ (wxRealPoint *)first->GetData(); + wxNode *last = m_lineControlPoints->GetLast(); + /* wxRealPoint *last_point = */ (wxRealPoint *)last->GetData(); - wxNode *second = first->Next(); - wxRealPoint *second_point = (wxRealPoint *)second->Data(); + wxNode *second = first->GetNext(); + wxRealPoint *second_point = (wxRealPoint *)second->GetData(); - wxNode *second_last = last->Previous(); - wxRealPoint *second_last_point = (wxRealPoint *)second_last->Data(); + wxNode *second_last = last->GetPrevious(); + wxRealPoint *second_last_point = (wxRealPoint *)second_last->GetData(); - if (m_lineControlPoints->Number() > 2) + if (m_lineControlPoints->GetCount() > 2) { if (m_from->GetAttachmentMode() != ATTACHMENT_MODE_NONE) { @@ -1181,12 +1178,12 @@ void wxLineShape::OnDraw(wxDC& dc) if (m_brush) dc.SetBrush(* m_brush); - int n = m_lineControlPoints->Number(); + int n = m_lineControlPoints->GetCount(); wxPoint *points = new wxPoint[n]; int i; for (i = 0; i < n; i++) { - wxRealPoint* point = (wxRealPoint*) m_lineControlPoints->Nth(i)->Data(); + wxRealPoint* point = (wxRealPoint*) m_lineControlPoints->Item(i)->GetData(); points[i].x = WXROUND(point->x); points[i].y = WXROUND(point->y); } @@ -1242,15 +1239,15 @@ void wxLineShape::OnEraseControlPoints(wxDC& dc) 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)) { } @@ -1284,10 +1281,10 @@ void wxLineShape::OnDrawContents(wxDC& dc) for (int i = 0; i < 3; i++) { - wxNode *node = m_regions.Nth(i); + wxNode *node = m_regions.Item(i); if (node) { - wxShapeRegion *region = (wxShapeRegion *)node->Data(); + wxShapeRegion *region = (wxShapeRegion *)node->GetData(); double x, y; GetLabelPosition(i, &x, &y); DrawRegion(dc, region, x, y); @@ -1309,10 +1306,10 @@ void wxLineShape::MakeControlPoints() { if (m_canvas && m_lineControlPoints) { - wxNode *first = m_lineControlPoints->First(); - wxNode *last = m_lineControlPoints->Last(); - wxRealPoint *first_point = (wxRealPoint *)first->Data(); - wxRealPoint *last_point = (wxRealPoint *)last->Data(); + wxNode *first = m_lineControlPoints->GetFirst(); + wxNode *last = m_lineControlPoints->GetLast(); + wxRealPoint *first_point = (wxRealPoint *)first->GetData(); + wxRealPoint *last_point = (wxRealPoint *)last->GetData(); wxLineControlPoint *control = new wxLineControlPoint(m_canvas, this, CONTROL_POINT_SIZE, first_point->x, first_point->y, @@ -1322,10 +1319,10 @@ void wxLineShape::MakeControlPoints() m_controlPoints.Append(control); - wxNode *node = first->Next(); + wxNode *node = first->GetNext(); while (node != last) { - wxRealPoint *point = (wxRealPoint *)node->Data(); + wxRealPoint *point = (wxRealPoint *)node->GetData(); control = new wxLineControlPoint(m_canvas, this, CONTROL_POINT_SIZE, point->x, point->y, @@ -1335,7 +1332,7 @@ void wxLineShape::MakeControlPoints() m_canvas->AddShape(control); m_controlPoints.Append(control); - node = node->Next(); + node = node->GetNext(); } control = new wxLineControlPoint(m_canvas, this, CONTROL_POINT_SIZE, last_point->x, last_point->y, @@ -1350,19 +1347,19 @@ void wxLineShape::MakeControlPoints() void wxLineShape::ResetControlPoints() { - if (m_canvas && m_lineControlPoints && m_controlPoints.Number() > 0) + if (m_canvas && m_lineControlPoints && m_controlPoints.GetCount() > 0) { - wxNode *node = m_controlPoints.First(); - wxNode *control_node = m_lineControlPoints->First(); + wxNode *node = m_controlPoints.GetFirst(); + wxNode *control_node = m_lineControlPoints->GetFirst(); while (node && control_node) { - wxRealPoint *point = (wxRealPoint *)control_node->Data(); - wxLineControlPoint *control = (wxLineControlPoint *)node->Data(); + wxRealPoint *point = (wxRealPoint *)control_node->GetData(); + wxLineControlPoint *control = (wxLineControlPoint *)node->GetData(); control->SetX(point->x); control->SetY(point->y); - node = node->Next(); - control_node = control_node->Next(); + node = node->GetNext(); + control_node = control_node->GetNext(); } } } @@ -1373,30 +1370,30 @@ void wxLineShape::WriteAttributes(wxExpr *clause) 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); - wxNode *node = m_lineControlPoints->First(); + wxNode *node = m_lineControlPoints->GetFirst(); while (node) { - wxRealPoint *point = (wxRealPoint *)node->Data(); + wxRealPoint *point = (wxRealPoint *)node->GetData(); wxExpr *point_list = new wxExpr(wxExprList); wxExpr *x_expr = new wxExpr((double) point->x); wxExpr *y_expr = new wxExpr((double) point->y); @@ -1404,20 +1401,20 @@ void wxLineShape::WriteAttributes(wxExpr *clause) point_list->Append(y_expr); list->Append(point_list); - node = node->Next(); + 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: // (arrowType arrowEnd xOffset arrowSize) - if (m_arcArrows.Number() > 0) + if (m_arcArrows.GetCount() > 0) { wxExpr *arrow_list = new wxExpr(wxExprList); - node = m_arcArrows.First(); + node = m_arcArrows.GetFirst(); while (node) { - wxArrowHead *head = (wxArrowHead *)node->Data(); + wxArrowHead *head = (wxArrowHead *)node->GetData(); wxExpr *head_list = new wxExpr(wxExprList); head_list->Append(new wxExpr((long)head->_GetType())); head_list->Append(new wxExpr((long)head->GetArrowEnd())); @@ -1432,9 +1429,9 @@ void wxLineShape::WriteAttributes(wxExpr *clause) arrow_list->Append(head_list); - node = node->Next(); + node = node->GetNext(); } - clause->AddAttributeValue("arrows", arrow_list); + clause->AddAttributeValue(_T("arrows"), arrow_list); } } @@ -1454,20 +1451,20 @@ void wxLineShape::ReadAttributes(wxExpr *clause) clause->AssignAttributeValue(wxT("align_end"), &m_alignmentEnd); // Compatibility: check for no regions. - if (m_regions.Number() == 0) + 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.Number() > 0) + if (m_text.GetCount() > 0) { newRegion->ClearText(); - wxNode *node = m_text.First(); + wxNode *node = m_text.GetFirst(); while (node) { - wxShapeTextLine *textLine = (wxShapeTextLine *)node->Data(); - wxNode *next = node->Next(); + wxShapeTextLine *textLine = (wxShapeTextLine *)node->GetData(); + wxNode *next = node->GetNext(); newRegion->GetFormattedText().Append((wxObject *)textLine); delete node; node = next; @@ -1600,11 +1597,11 @@ void wxLineShape::Copy(wxShape& copy) lineCopy.m_maintainStraightLines = m_maintainStraightLines; lineCopy.m_lineOrientations.Clear(); - wxNode *node = m_lineOrientations.First(); + wxNode *node = m_lineOrientations.GetFirst(); while (node) { - lineCopy.m_lineOrientations.Append(node->Data()); - node = node->Next(); + lineCopy.m_lineOrientations.Append(node->GetData()); + node = node->GetNext(); } if (lineCopy.m_lineControlPoints) @@ -1615,23 +1612,23 @@ void wxLineShape::Copy(wxShape& copy) lineCopy.m_lineControlPoints = new wxList; - node = m_lineControlPoints->First(); + node = m_lineControlPoints->GetFirst(); while (node) { - wxRealPoint *point = (wxRealPoint *)node->Data(); + wxRealPoint *point = (wxRealPoint *)node->GetData(); wxRealPoint *new_point = new wxRealPoint(point->x, point->y); lineCopy.m_lineControlPoints->Append((wxObject*) new_point); - node = node->Next(); + node = node->GetNext(); } // Copy arrows lineCopy.ClearArrowsAtPosition(-1); - node = m_arcArrows.First(); + node = m_arcArrows.GetFirst(); while (node) { - wxArrowHead *arrow = (wxArrowHead *)node->Data(); + wxArrowHead *arrow = (wxArrowHead *)node->GetData(); lineCopy.m_arcArrows.Append(new wxArrowHead(*arrow)); - node = node->Next(); + node = node->GetNext(); } } @@ -1643,11 +1640,11 @@ void wxLineShape::Select(bool select, wxDC* dc) { for (int i = 0; i < 3; i++) { - wxNode *node = m_regions.Nth(i); + wxNode *node = m_regions.Item(i); if (node) { - wxShapeRegion *region = (wxShapeRegion *)node->Data(); - if (region->m_formattedText.Number() > 0) + wxShapeRegion *region = (wxShapeRegion *)node->GetData(); + if (region->m_formattedText.GetCount() > 0) { double w, h, x, y, xx, yy; region->GetSize(&w, &h); @@ -1728,7 +1725,7 @@ void wxLineControlPoint::OnEndDragLeft(double x, double y, int keys, int attachm // 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; @@ -1770,7 +1767,7 @@ void wxLineShape::OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, doub } -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; @@ -1818,7 +1815,7 @@ void wxLineShape::OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, } } -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; @@ -1874,8 +1871,8 @@ void wxLineShape::OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, in // Needed? #if 0 int i = 0; - for (i = 0; i < lineShape->GetLineControlPoints()->Number(); i++) - if (((wxRealPoint *)(lineShape->GetLineControlPoints()->Nth(i)->Data())) == lpt->m_point) + for (i = 0; i < lineShape->GetLineControlPoints()->GetCount(); i++) + if (((wxRealPoint *)(lineShape->GetLineControlPoints()->Item(i)->GetData())) == lpt->m_point) break; // N.B. in OnMoveControlPoint, an event handler in Hardy could have deselected @@ -1981,8 +1978,8 @@ void wxLineControlPoint::OnEndDragRight(double x, double y, int keys, int attach } } int i = 0; - for (i = 0; i < lineShape->GetLineControlPoints()->Number(); i++) - if (((wxRealPoint *)(lineShape->GetLineControlPoints()->Nth(i)->Data())) == m_point) + for (i = 0; i < lineShape->GetLineControlPoints()->GetCount(); i++) + if (((wxRealPoint *)(lineShape->GetLineControlPoints()->Item(i)->GetData())) == m_point) break; lineShape->OnMoveControlPoint(i+1, x, y); if (!m_canvas->GetQuickEditMode()) m_canvas->Redraw(dc); @@ -2023,33 +2020,33 @@ wxArrowHead *wxLineShape::AddArrow(WXTYPE type, int end, double size, double xOf */ bool wxLineShape::AddArrowOrdered(wxArrowHead *arrow, wxList& referenceList, int end) { - wxNode *refNode = referenceList.First(); - wxNode *currNode = m_arcArrows.First(); + wxNode *refNode = referenceList.GetFirst(); + wxNode *currNode = m_arcArrows.GetFirst(); wxString targetName(arrow->GetName()); if (!refNode) return FALSE; // First check whether we need to insert in front of list, // because this arrowhead is the first in the reference // list and should therefore be first in the current list. - wxArrowHead *refArrow = (wxArrowHead *)refNode->Data(); + wxArrowHead *refArrow = (wxArrowHead *)refNode->GetData(); if (refArrow->GetName() == targetName) { m_arcArrows.Insert(arrow); return TRUE; } + wxArrowHead *currArrow = (wxArrowHead *)currNode->GetData(); while (refNode && currNode) { - wxArrowHead *currArrow = (wxArrowHead *)currNode->Data(); - refArrow = (wxArrowHead *)refNode->Data(); + refArrow = (wxArrowHead *)refNode->GetData(); // Matching: advance current arrow pointer if ((currArrow->GetArrowEnd() == end) && (currArrow->GetName() == refArrow->GetName())) { - currNode = currNode->Next(); // Could be NULL now + currNode = currNode->GetNext(); // Could be NULL now if (currNode) - currArrow = (wxArrowHead *)currNode->Data(); + currArrow = (wxArrowHead *)currNode->GetData(); } // Check if we're at the correct position in the @@ -2062,7 +2059,7 @@ bool wxLineShape::AddArrowOrdered(wxArrowHead *arrow, wxList& referenceList, int m_arcArrows.Append(arrow); return TRUE; } - refNode = refNode->Next(); + refNode = refNode->GetNext(); } m_arcArrows.Append(arrow); return TRUE; @@ -2070,11 +2067,11 @@ bool wxLineShape::AddArrowOrdered(wxArrowHead *arrow, wxList& referenceList, int void wxLineShape::ClearArrowsAtPosition(int end) { - wxNode *node = m_arcArrows.First(); + wxNode *node = m_arcArrows.GetFirst(); while (node) { - wxArrowHead *arrow = (wxArrowHead *)node->Data(); - wxNode *next = node->Next(); + wxArrowHead *arrow = (wxArrowHead *)node->GetData(); + wxNode *next = node->GetNext(); switch (end) { case -1: @@ -2117,17 +2114,17 @@ void wxLineShape::ClearArrowsAtPosition(int end) bool wxLineShape::ClearArrow(const wxString& name) { - wxNode *node = m_arcArrows.First(); + wxNode *node = m_arcArrows.GetFirst(); while (node) { - wxArrowHead *arrow = (wxArrowHead *)node->Data(); + wxArrowHead *arrow = (wxArrowHead *)node->GetData(); if (arrow->GetName() == name) { delete arrow; delete node; return TRUE; } - node = node->Next(); + node = node->GetNext(); } return FALSE; } @@ -2139,27 +2136,27 @@ bool wxLineShape::ClearArrow(const wxString& name) wxArrowHead *wxLineShape::FindArrowHead(int position, const wxString& name) { - wxNode *node = m_arcArrows.First(); + wxNode *node = m_arcArrows.GetFirst(); while (node) { - wxArrowHead *arrow = (wxArrowHead *)node->Data(); + wxArrowHead *arrow = (wxArrowHead *)node->GetData(); if (((position == -1) || (position == arrow->GetArrowEnd())) && (arrow->GetName() == name)) return arrow; - node = node->Next(); + node = node->GetNext(); } return NULL; } wxArrowHead *wxLineShape::FindArrowHead(long arrowId) { - wxNode *node = m_arcArrows.First(); + wxNode *node = m_arcArrows.GetFirst(); while (node) { - wxArrowHead *arrow = (wxArrowHead *)node->Data(); + wxArrowHead *arrow = (wxArrowHead *)node->GetData(); if (arrowId == arrow->GetId()) return arrow; - node = node->Next(); + node = node->GetNext(); } return NULL; } @@ -2171,10 +2168,10 @@ wxArrowHead *wxLineShape::FindArrowHead(long arrowId) bool wxLineShape::DeleteArrowHead(int position, const wxString& name) { - wxNode *node = m_arcArrows.First(); + wxNode *node = m_arcArrows.GetFirst(); while (node) { - wxArrowHead *arrow = (wxArrowHead *)node->Data(); + wxArrowHead *arrow = (wxArrowHead *)node->GetData(); if (((position == -1) || (position == arrow->GetArrowEnd())) && (arrow->GetName() == name)) { @@ -2182,7 +2179,7 @@ bool wxLineShape::DeleteArrowHead(int position, const wxString& name) delete node; return TRUE; } - node = node->Next(); + node = node->GetNext(); } return FALSE; } @@ -2190,17 +2187,17 @@ bool wxLineShape::DeleteArrowHead(int position, const wxString& name) // Overloaded DeleteArrowHead: pass arrowhead id. bool wxLineShape::DeleteArrowHead(long id) { - wxNode *node = m_arcArrows.First(); + wxNode *node = m_arcArrows.GetFirst(); while (node) { - wxArrowHead *arrow = (wxArrowHead *)node->Data(); + wxArrowHead *arrow = (wxArrowHead *)node->GetData(); if (arrow->GetId() == id) { delete arrow; delete node; return TRUE; } - node = node->Next(); + node = node->GetNext(); } return FALSE; } @@ -2214,15 +2211,15 @@ bool wxLineShape::DeleteArrowHead(long id) double wxLineShape::FindMinimumWidth() { double minWidth = 0.0; - wxNode *node = m_arcArrows.First(); + wxNode *node = m_arcArrows.GetFirst(); while (node) { - wxArrowHead *arrowHead = (wxArrowHead *)node->Data(); + wxArrowHead *arrowHead = (wxArrowHead *)node->GetData(); minWidth += arrowHead->GetSize(); - if (node->Next()) + if (node->GetNext()) minWidth += arrowHead->GetSpacing(); - node = node->Next(); + node = node->GetNext(); } // We have ABSOLUTE minimum now. So // scale it to give it reasonable aesthetics @@ -2319,8 +2316,8 @@ int wxLineShape::GetAlignmentType(bool isEnd) wxRealPoint *wxLineShape::GetNextControlPoint(wxShape *nodeObject) { - int n = m_lineControlPoints->Number(); - int nn = 0; + int n = m_lineControlPoints->GetCount(); + int nn; if (m_to == nodeObject) { // Must be END of line, so we want (n - 1)th control point. @@ -2328,10 +2325,10 @@ wxRealPoint *wxLineShape::GetNextControlPoint(wxShape *nodeObject) nn = n - 2; } else nn = 1; - wxNode *node = m_lineControlPoints->Nth(nn); + wxNode *node = m_lineControlPoints->Item(nn); if (node) { - return (wxRealPoint *)node->Data(); + return (wxRealPoint *)node->GetData(); } else return FALSE; @@ -2441,7 +2438,7 @@ void wxLabelShape::OnDraw(wxDC& dc) dc.DrawRectangle(WXROUND(x1), WXROUND(y1), WXROUND(m_width), WXROUND(m_height)); } -void wxLabelShape::OnDrawContents(wxDC& dc) +void wxLabelShape::OnDrawContents(wxDC& WXUNUSED(dc)) { } @@ -2465,20 +2462,20 @@ bool wxLabelShape::OnMovePre(wxDC& dc, double x, double y, double old_x, double 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()); // Find position in line's region list int i = 0; - wxNode *node = GetRegions().First(); + wxNode *node = GetRegions().GetFirst(); while (node) { - if (labelShape->m_shapeRegion == (wxShapeRegion *)node->Data()) + if (labelShape->m_shapeRegion == (wxShapeRegion *)node->GetData()) node = NULL; else { - node = node->Next(); + node = node->GetNext(); i ++; } }