]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/ogl/src/lines.cpp
Added test for sprintf and vsnprintf to fix string.cpp for non-GNU systems.
[wxWidgets.git] / utils / ogl / src / lines.cpp
index a3e1222bfee4ae76b8cc388b2751686504118aaa..a44bb7d2c6322972b2e8f737ffffec87bdc12ec4 100644 (file)
@@ -11,6 +11,7 @@
 
 #ifdef __GNUG__
 #pragma implementation "lines.h"
 
 #ifdef __GNUG__
 #pragma implementation "lines.h"
+#pragma implementation "linesp.h"
 #endif
 
 // For compilers that support precompilation, includes "wx.h".
 #endif
 
 // For compilers that support precompilation, includes "wx.h".
 #include <wx/wx.h>
 #endif
 
 #include <wx/wx.h>
 #endif
 
-#ifdef PROLOGIO
 #include <wx/wxexpr.h>
 #include <wx/wxexpr.h>
-#endif
 
 
-#if USE_IOSTREAMH
+#if wxUSE_IOSTREAMH
 #include <iostream.h>
 #else
 #include <iostream>
 #include <iostream.h>
 #else
 #include <iostream>
@@ -291,7 +290,7 @@ void wxLineShape::DrawRegion(wxDC& dc, wxShapeRegion *region, double x, double y
       // Now draw the text
       if (region->GetFont()) dc.SetFont(region->GetFont());
 
       // Now draw the text
       if (region->GetFont()) dc.SetFont(region->GetFont());
 
-      dc.DrawRectangle((double)(xp - w/2.0), (double)(yp - h/2.0), (double)w, (double)h);
+      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());
 
       if (m_pen) dc.SetPen(m_pen);
       dc.SetTextForeground(* region->GetActualColourObject());
@@ -324,7 +323,7 @@ void wxLineShape::EraseRegion(wxDC& dc, wxShapeRegion *region, double x, double
       dc.SetPen(g_oglWhiteBackgroundPen);
       dc.SetBrush(g_oglWhiteBackgroundBrush);
 
       dc.SetPen(g_oglWhiteBackgroundPen);
       dc.SetBrush(g_oglWhiteBackgroundBrush);
 
-      dc.DrawRectangle((double)(xp - w/2.0), (double)(yp - h/2.0), (double)w, (double)h);
+      dc.DrawRectangle((long)(xp - w/2.0), (long)(yp - h/2.0), (long)w, (long)h);
   }
 }
 
   }
 }
 
@@ -723,10 +722,10 @@ void wxLineShape::DrawArrow(wxDC& dc, wxArrowHead *arrow, double xOffset, bool p
                        &side1_x, &side1_y, &side2_x, &side2_y);
 
       wxPoint points[4];
                        &side1_x, &side1_y, &side2_x, &side2_y);
 
       wxPoint points[4];
-      points[0].x = tip_x; points[0].y = tip_y;
-      points[1].x = side1_x; points[1].y = side1_y;
-      points[2].x = side2_x; points[2].y = side2_y;
-      points[3].x = tip_x; points[3].y = tip_y;
+      points[0].x = (int) tip_x; points[0].y = (int) tip_y;
+      points[1].x = (int) side1_x; points[1].y = (int) side1_y;
+      points[2].x = (int) side2_x; points[2].y = (int) side2_y;
+      points[3].x = (int) tip_x; points[3].y = (int) tip_y;
 
       dc.SetPen(m_pen);
       dc.SetBrush(m_brush);
 
       dc.SetPen(m_pen);
       dc.SetBrush(m_brush);
@@ -755,7 +754,7 @@ void wxLineShape::DrawArrow(wxDC& dc, wxArrowHead *arrow, double xOffset, bool p
       else
         dc.SetBrush(m_brush);
 
       else
         dc.SetBrush(m_brush);
 
-      dc.DrawEllipse(x1, y1, diameter, diameter);
+      dc.DrawEllipse((long) x1, (long) y1, (long) diameter, (long) diameter);
       break;
     }
     case ARROW_SINGLE_OBLIQUE:
       break;
     }
     case ARROW_SINGLE_OBLIQUE:
@@ -832,8 +831,8 @@ void wxLineShape::DrawArrow(wxDC& dc, wxArrowHead *arrow, double xOffset, bool p
           arrow->GetMetaFile()->GetBounds(&minX, &minY, &maxX, &maxY);
           // Make erasing rectangle slightly bigger or you get droppings.
           int extraPixels = 4;
           arrow->GetMetaFile()->GetBounds(&minX, &minY, &maxX, &maxY);
           // Make erasing rectangle slightly bigger or you get droppings.
           int extraPixels = 4;
-          dc.DrawRectangle((double)(deltaX + x + minX - (extraPixels/2.0)), (double)(deltaY + y + minY - (extraPixels/2.0)),
-                           (double)(maxX - minX + extraPixels), (double)(maxY - minY + extraPixels));
+          dc.DrawRectangle((long)(deltaX + x + minX - (extraPixels/2.0)), (long)(deltaY + y + minY - (extraPixels/2.0)),
+                           (long)(maxX - minX + extraPixels), (long)(maxY - minY + extraPixels));
         }
         else
           arrow->GetMetaFile()->Draw(dc, x+deltaX, y+deltaY);
         }
         else
           arrow->GetMetaFile()->Draw(dc, x+deltaX, y+deltaY);
@@ -878,8 +877,8 @@ void wxLineShape::OnErase(wxDC& dc)
     // of 1.
     if (old_pen && (old_pen->GetWidth() > 1))
     {
     // of 1.
     if (old_pen && (old_pen->GetWidth() > 1))
     {
-      dc.DrawRectangle((double)(m_xpos - (bound_x/2.0) - 2.0), (double)(m_ypos - (bound_y/2.0) - 2.0),
-                        (double)(bound_x+4.0),  (double)(bound_y+4.0));
+      dc.DrawRectangle((long)(m_xpos - (bound_x/2.0) - 2.0), (long)(m_ypos - (bound_y/2.0) - 2.0),
+                        (long)(bound_x+4.0),  (long)(bound_y+4.0));
     }
     else
     {
     }
     else
     {
@@ -1065,7 +1064,7 @@ void wxLineShape::OnMoveLink(wxDC& dc, bool moveControlPoints)
 
 //    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 (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)
     {
       wxNode *node = m_lineControlPoints->First();
       while (node)
@@ -1110,7 +1109,7 @@ void wxLineShape::FindLineEndPoints(double *fromX, double *fromY, double *toX, d
 
   if (m_lineControlPoints->Number() > 2)
   {
 
   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
     {
       int nth, no_arcs;
       FindNth(m_from, &nth, &no_arcs, FALSE); // Not incoming
@@ -1121,7 +1120,7 @@ void wxLineShape::FindLineEndPoints(double *fromX, double *fromY, double *toX, d
                                    (double)second_point->x, (double)second_point->y,
                                     &end_x, &end_y);
 
                                    (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
     {
       int nth, no_arcs;
       FindNth(m_to, &nth, &no_arcs, TRUE); // Incoming
@@ -1139,7 +1138,7 @@ void wxLineShape::FindLineEndPoints(double *fromX, double *fromY, double *toX, d
     double toX = m_to->GetX();
     double toY = m_to->GetY();
 
     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);
     {
       int nth, no_arcs;
       FindNth(m_from, &nth, &no_arcs, FALSE);
@@ -1148,7 +1147,7 @@ void wxLineShape::FindLineEndPoints(double *fromX, double *fromY, double *toX, d
       fromY = end_y;
     }
 
       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);
     {
       int nth, no_arcs;
       FindNth(m_to, &nth, &no_arcs, TRUE);
@@ -1157,12 +1156,12 @@ void wxLineShape::FindLineEndPoints(double *fromX, double *fromY, double *toX, d
       toY = other_end_y;
     }
 
       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);
 
       (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);
       (void) m_to->GetPerimeterPoint(m_to->GetX(), m_to->GetY(),
                                 fromX, fromY,
                                 &other_end_x, &other_end_y);
@@ -1393,12 +1392,12 @@ void wxLineShape::WriteAttributes(wxExpr *clause)
     clause->AddAttributeValue("keep_lines_straight", (long)m_maintainStraightLines);
 
   // Make a list of lists for the (sp)line controls
     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();
   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);
     wxExpr *x_expr = new wxExpr((double) point->x);
     wxExpr *y_expr = new wxExpr((double) point->y);
     point_list->Append(x_expr);
@@ -1414,17 +1413,17 @@ void wxLineShape::WriteAttributes(wxExpr *clause)
   // (arrowType arrowEnd xOffset arrowSize)
   if (m_arcArrows.Number() > 0)
   {
   // (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();
     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((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_list->Append(new wxExpr(head->GetId()));
 
       // New members of wxArrowHead
       head_list->Append(new wxExpr(head->GetId()));
 
       // New members of wxArrowHead