X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9e05364039a615196ff8c6e222e116f96892a172..9c112555198f51fcec71106530cddba95a17f3dc:/contrib/src/ogl/lines.cpp?ds=inline diff --git a/contrib/src/ogl/lines.cpp b/contrib/src/ogl/lines.cpp index 73710978f7..5db7a49046 100644 --- a/contrib/src/ogl/lines.cpp +++ b/contrib/src/ogl/lines.cpp @@ -6,7 +6,7 @@ // Created: 12/07/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -25,28 +25,18 @@ #include #endif -#include +#if wxUSE_PROLOGIO +#include +#endif #ifdef new #undef new #endif -#if wxUSE_IOSTREAMH -#include -#else -#include -#endif - #include -#include -#include -#include -#include -#include -#include -#include -#include +#include "wx/ogl/ogl.h" + // Line shape IMPLEMENT_DYNAMIC_CLASS(wxLineShape, wxShape) @@ -54,7 +44,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxLineShape, wxShape) wxLineShape::wxLineShape() { m_sensitivity = OP_CLICK_LEFT | OP_CLICK_RIGHT; - m_draggable = FALSE; + m_draggable = false; m_attachmentTo = 0; m_attachmentFrom = 0; /* @@ -63,11 +53,11 @@ wxLineShape::wxLineShape() */ m_from = NULL; m_to = NULL; - m_erasing = FALSE; + m_erasing = false; m_arrowSpacing = 5.0; // For the moment, don't bother saving this to file. - m_ignoreArrowOffsets = FALSE; - m_isSpline = FALSE; - m_maintainStraightLines = FALSE; + m_ignoreArrowOffsets = false; + m_isSpline = false; + m_maintainStraightLines = false; m_alignmentStart = 0; m_alignmentEnd = 0; @@ -106,7 +96,7 @@ wxLineShape::~wxLineShape() { if (m_labelObjects[i]) { - m_labelObjects[i]->Select(FALSE); + m_labelObjects[i]->Select(false); m_labelObjects[i]->RemoveFromCanvas(m_canvas); delete m_labelObjects[i]; m_labelObjects[i] = NULL; @@ -124,8 +114,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); @@ -137,10 +126,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); @@ -153,17 +142,17 @@ wxNode *wxLineShape::InsertLineControlPoint(wxDC* dc) bool wxLineShape::DeleteLineControlPoint() { - if (m_lineControlPoints->Number() < 3) - return FALSE; + 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; - return TRUE; + return true; } void wxLineShape::Initialise() @@ -171,19 +160,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; @@ -200,7 +189,7 @@ void wxLineShape::Initialise() point->x = ((x2 - x1)/2 + x1); point->y = ((y2 - y1)/2 + y1); } - node = node->Next(); + node = node->GetNext(); } } } @@ -212,13 +201,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()); @@ -231,13 +220,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; @@ -252,7 +241,7 @@ void wxLineShape::FormatText(wxDC& dc, const wxString& s, int i) EraseRegion(dc, region, xx, yy); if (m_labelObjects[i]) { - m_labelObjects[i]->Select(FALSE, &dc); + m_labelObjects[i]->Select(false, &dc); m_labelObjects[i]->Erase(dc); m_labelObjects[i]->SetSize(actualW, actualH); } @@ -261,13 +250,13 @@ void wxLineShape::FormatText(wxDC& dc, const wxString& s, int i) if (m_labelObjects[i]) { - m_labelObjects[i]->Select(TRUE, & dc); + m_labelObjects[i]->Select(true, & dc); m_labelObjects[i]->Draw(dc); } } } oglCentreText(dc, &(region->GetFormattedText()), m_xpos, m_ypos, actualW, actualH, region->GetFormatMode()); - m_formatted = TRUE; + m_formatted = true; } void wxLineShape::DrawRegion(wxDC& dc, wxShapeRegion *region, double x, double y) @@ -286,7 +275,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()); @@ -297,7 +286,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()); @@ -322,7 +311,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()); @@ -341,14 +330,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); @@ -358,16 +347,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: @@ -396,29 +385,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) @@ -439,10 +428,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; @@ -456,10 +445,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,17 +463,17 @@ void wxLineShape::SetAttachments(int from_attach, int to_attach) bool wxLineShape::HitTest(double x, double y, int *attachment, double *distance) { if (!m_lineControlPoints) - return FALSE; + return false; // Look at label regions in case mouse is over a label - bool inLabelRegion = FALSE; + 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); @@ -499,42 +488,43 @@ bool wxLineShape::HitTest(double x, double y, int *attachment, double *distance) double rBottom = (double)(cy + (ch/2.0)); if (x > rLeft && x < rRight && y > rTop && y < rBottom) { - inLabelRegion = TRUE; + inLabelRegion = true; i = 3; } } } } - 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)); - return TRUE; + *distance = distance_from_seg; + return true; } - node = node->Next(); + node = node->GetNext(); } - return FALSE; + return false; } void wxLineShape::DrawArrows(wxDC& dc) @@ -544,20 +534,20 @@ 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: { if ((arrow->GetXOffset() != 0.0) && !m_ignoreArrowOffsets) // If specified, x offset is proportional to line length - DrawArrow(dc, arrow, arrow->GetXOffset(), TRUE); + DrawArrow(dc, arrow, arrow->GetXOffset(), true); else { - DrawArrow(dc, arrow, startArrowPos, FALSE); // Absolute distance + DrawArrow(dc, arrow, startArrowPos, false); // Absolute distance startArrowPos += arrow->GetSize() + arrow->GetSpacing(); } break; @@ -565,10 +555,10 @@ void wxLineShape::DrawArrows(wxDC& dc) case ARROW_POSITION_END: { if ((arrow->GetXOffset() != 0.0) && !m_ignoreArrowOffsets) - DrawArrow(dc, arrow, arrow->GetXOffset(), TRUE); + DrawArrow(dc, arrow, arrow->GetXOffset(), true); else { - DrawArrow(dc, arrow, endArrowPos, FALSE); + DrawArrow(dc, arrow, endArrowPos, false); endArrowPos += arrow->GetSize() + arrow->GetSpacing(); } break; @@ -577,36 +567,36 @@ void wxLineShape::DrawArrows(wxDC& dc) { arrow->SetXOffset(middleArrowPos); if ((arrow->GetXOffset() != 0.0) && !m_ignoreArrowOffsets) - DrawArrow(dc, arrow, arrow->GetXOffset(), TRUE); + DrawArrow(dc, arrow, arrow->GetXOffset(), true); else { - DrawArrow(dc, arrow, middleArrowPos, FALSE); + DrawArrow(dc, arrow, middleArrowPos, false); middleArrowPos += arrow->GetSize() + arrow->GetSpacing(); } 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; + double positionOnLineX = 0.0, positionOnLineY = 0.0; // 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()) { @@ -677,7 +667,7 @@ void wxLineShape::DrawArrow(wxDC& dc, wxArrowHead *arrow, double xOffset, bool p * Add yOffset to arrow, if any */ - const double myPi = (double) 3.14159265; + const double myPi = (double) M_PI; // The translation that the y offset may give double deltaX = 0.0; double deltaY = 0.0; @@ -699,7 +689,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 @@ -754,7 +744,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); @@ -865,11 +855,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); } @@ -888,10 +878,10 @@ void wxLineShape::OnErase(wxDC& dc) } else { - m_erasing = TRUE; + m_erasing = true; GetEventHandler()->OnDraw(dc); GetEventHandler()->OnEraseControlPoints(dc); - m_erasing = FALSE; + m_erasing = false; } if (old_pen) SetPen(old_pen); @@ -905,17 +895,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); @@ -930,7 +920,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; @@ -940,7 +930,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) { @@ -964,18 +954,18 @@ 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; - wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT); + wxPen dottedPen(*wxBLACK, 1, wxDOT); SetPen(& dottedPen); SetBrush( wxTRANSPARENT_BRUSH ); @@ -987,20 +977,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(); } } @@ -1013,10 +1003,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 @@ -1027,7 +1017,7 @@ bool wxLineShape::OnMovePre(wxDC& dc, double x, double y, double old_x, double o m_labelObjects[i]->Move(dc, xp+xr, yp+yr); } } - return TRUE; + return true; } void wxLineShape::OnMoveLink(wxDC& dc, bool moveControlPoints) @@ -1035,7 +1025,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 @@ -1045,10 +1035,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; @@ -1072,16 +1062,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(); } } @@ -1099,26 +1089,26 @@ void wxLineShape::FindLineEndPoints(double *fromX, double *fromY, double *toX, d // Do each end - nothing in the middle. User has to move other points // manually if necessary. - double end_x, end_y; - double other_end_x, other_end_y; + double end_x = 0.0, end_y = 0.0; + double other_end_x = 0.0, other_end_y = 0.0; - 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) { int nth, no_arcs; - FindNth(m_from, &nth, &no_arcs, FALSE); // Not incoming + FindNth(m_from, &nth, &no_arcs, false); // Not incoming m_from->GetAttachmentPosition(m_attachmentFrom, &end_x, &end_y, nth, no_arcs, this); } else @@ -1129,7 +1119,7 @@ void wxLineShape::FindLineEndPoints(double *fromX, double *fromY, double *toX, d if (m_to->GetAttachmentMode() != ATTACHMENT_MODE_NONE) { int nth, no_arcs; - FindNth(m_to, &nth, &no_arcs, TRUE); // Incoming + FindNth(m_to, &nth, &no_arcs, true); // Incoming m_to->GetAttachmentPosition(m_attachmentTo, &other_end_x, &other_end_y, nth, no_arcs, this); } else @@ -1147,7 +1137,7 @@ void wxLineShape::FindLineEndPoints(double *fromX, double *fromY, double *toX, d if (m_from->GetAttachmentMode() != ATTACHMENT_MODE_NONE) { int nth, no_arcs; - FindNth(m_from, &nth, &no_arcs, FALSE); + FindNth(m_from, &nth, &no_arcs, false); m_from->GetAttachmentPosition(m_attachmentFrom, &end_x, &end_y, nth, no_arcs, this); fromX = end_x; fromY = end_y; @@ -1156,7 +1146,7 @@ void wxLineShape::FindLineEndPoints(double *fromX, double *fromY, double *toX, d if (m_to->GetAttachmentMode() != ATTACHMENT_MODE_NONE) { int nth, no_arcs; - FindNth(m_to, &nth, &no_arcs, TRUE); + FindNth(m_to, &nth, &no_arcs, true); m_to->GetAttachmentPosition(m_attachmentTo, &other_end_x, &other_end_y, nth, no_arcs, this); toX = other_end_x; toY = other_end_y; @@ -1187,12 +1177,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); } @@ -1248,15 +1238,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)) { } @@ -1290,10 +1280,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); @@ -1315,10 +1305,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, @@ -1328,10 +1318,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, @@ -1341,7 +1331,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, @@ -1356,19 +1346,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(); } } } @@ -1379,30 +1369,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); @@ -1410,20 +1400,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())); @@ -1438,9 +1428,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); } } @@ -1460,20 +1450,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; @@ -1559,7 +1549,7 @@ void wxLineShape::ReadAttributes(wxExpr *clause) wxExpr *spacingExpr = node->Nth(7); if (type_expr) - arrowType = (int)type_expr->IntegerValue(); + arrowType = (WXTYPE)type_expr->IntegerValue(); if (end_expr) arrowEnd = (int)end_expr->IntegerValue(); if (dist_expr) @@ -1606,11 +1596,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) @@ -1621,23 +1611,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(); } } @@ -1649,11 +1639,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); @@ -1661,16 +1651,16 @@ void wxLineShape::Select(bool select, wxDC* dc) GetLabelPosition(i, &xx, &yy); if (m_labelObjects[i]) { - m_labelObjects[i]->Select(FALSE); + m_labelObjects[i]->Select(false); m_labelObjects[i]->RemoveFromCanvas(m_canvas); delete m_labelObjects[i]; } m_labelObjects[i] = OnCreateLabelShape(this, region, w, h); m_labelObjects[i]->AddToCanvas(m_canvas); - m_labelObjects[i]->Show(TRUE); + m_labelObjects[i]->Show(true); if (dc) m_labelObjects[i]->Move(*dc, (double)(x + xx), (double)(y + yy)); - m_labelObjects[i]->Select(TRUE, dc); + m_labelObjects[i]->Select(true, dc); } } } @@ -1681,7 +1671,7 @@ void wxLineShape::Select(bool select, wxDC* dc) { if (m_labelObjects[i]) { - m_labelObjects[i]->Select(FALSE, dc); + m_labelObjects[i]->Select(false, dc); m_labelObjects[i]->Erase(*dc); m_labelObjects[i]->RemoveFromCanvas(m_canvas); delete m_labelObjects[i]; @@ -1734,7 +1724,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; @@ -1743,7 +1733,7 @@ void wxLineShape::OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, doub dc.SetLogicalFunction(OGLRBLF); - wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT); + wxPen dottedPen(*wxBLACK, 1, wxDOT); dc.SetPen(dottedPen); dc.SetBrush((* wxTRANSPARENT_BRUSH)); @@ -1759,11 +1749,11 @@ void wxLineShape::OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, doub wxPen *old_pen = lineShape->GetPen(); wxBrush *old_brush = lineShape->GetBrush(); - wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT); + wxPen dottedPen(*wxBLACK, 1, wxDOT); lineShape->SetPen(& dottedPen); lineShape->SetBrush(wxTRANSPARENT_BRUSH); - lineShape->GetEventHandler()->OnMoveLink(dc, FALSE); + lineShape->GetEventHandler()->OnMoveLink(dc, false); lineShape->SetPen(old_pen); lineShape->SetBrush(old_brush); @@ -1776,7 +1766,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; @@ -1798,7 +1788,7 @@ void wxLineShape::OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, lineShape->GetTo()->OnDraw(dc); lineShape->GetTo()->OnDrawContents(dc); - this->SetDisableLabel(TRUE); + this->SetDisableLabel(true); dc.SetLogicalFunction(OGLRBLF); lpt->m_xpos = x; lpt->m_ypos = y; @@ -1807,11 +1797,11 @@ void wxLineShape::OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, wxPen *old_pen = lineShape->GetPen(); wxBrush *old_brush = lineShape->GetBrush(); - wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT); + wxPen dottedPen(*wxBLACK, 1, wxDOT); lineShape->SetPen(& dottedPen); lineShape->SetBrush(wxTRANSPARENT_BRUSH); - lineShape->GetEventHandler()->OnMoveLink(dc, FALSE); + lineShape->GetEventHandler()->OnMoveLink(dc, false); lineShape->SetPen(old_pen); lineShape->SetBrush(old_brush); @@ -1824,14 +1814,14 @@ 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; wxClientDC dc(GetCanvas()); GetCanvas()->PrepareDC(dc); - this->SetDisableLabel(FALSE); + this->SetDisableLabel(false); wxLineShape *lineShape = (wxLineShape *)this; if (lpt->m_type == CONTROL_POINT_LINE) @@ -1880,8 +1870,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 @@ -1900,7 +1890,7 @@ bool wxLineShape::OnMoveMiddleControlPoint(wxDC& dc, wxLineControlPoint* lpt, co GetEventHandler()->OnMoveLink(dc); - return TRUE; + return true; } // Implement movement of endpoint to a new attachment @@ -1987,8 +1977,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); @@ -2029,33 +2019,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; + 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; + 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 @@ -2066,21 +2056,21 @@ bool wxLineShape::AddArrowOrdered(wxArrowHead *arrow, wxList& referenceList, int m_arcArrows.Insert(currNode, arrow); else m_arcArrows.Append(arrow); - return TRUE; + return true; } - refNode = refNode->Next(); + refNode = refNode->GetNext(); } m_arcArrows.Append(arrow); - return TRUE; + return true; } 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: @@ -2123,19 +2113,19 @@ 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; + return true; } - node = node->Next(); + node = node->GetNext(); } - return FALSE; + return false; } /* @@ -2145,27 +2135,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; } @@ -2177,38 +2167,38 @@ 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)) { delete arrow; delete node; - return TRUE; + return true; } - node = node->Next(); + node = node->GetNext(); } - return FALSE; + return false; } // 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; + return true; } - node = node->Next(); + node = node->GetNext(); } - return FALSE; + return false; } /* @@ -2220,15 +2210,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 @@ -2325,8 +2315,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. @@ -2334,13 +2324,13 @@ 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; + return NULL; } /* @@ -2365,7 +2355,7 @@ wxArrowHead::wxArrowHead(WXTYPE type, int end, double size, double dist, const w m_id = wxNewId(); } -wxArrowHead::wxArrowHead(wxArrowHead& toCopy) +wxArrowHead::wxArrowHead(wxArrowHead& toCopy):wxObject() { m_arrowType = toCopy.m_arrowType; m_arrowEnd = toCopy.GetArrowEnd(); m_arrowSize = toCopy.m_arrowSize; @@ -2417,7 +2407,7 @@ wxLabelShape::wxLabelShape(wxLineShape *parent, wxShapeRegion *region, double w, { m_lineShape = parent; m_shapeRegion = region; - SetPen(wxThePenList->FindOrCreatePen(wxColour(0, 0, 0), 1, wxDOT)); + SetPen(wxThePenList->FindOrCreatePen(*wxBLACK, 1, wxDOT)); } wxLabelShape::~wxLabelShape() @@ -2447,7 +2437,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)) { } @@ -2471,20 +2461,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 ++; } } @@ -2505,7 +2495,7 @@ bool wxLineShape::OnLabelMovePre(wxDC& dc, wxLabelShape* labelShape, double x, d labelShape->FormatText(dc, s, i); DrawRegion(dc, labelShape->m_shapeRegion, xx, yy); } - return TRUE; + return true; } // Divert left and right clicks to line object