]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/ogl/src/basic2.cpp
Configure support for OGL
[wxWidgets.git] / utils / ogl / src / basic2.cpp
index d959c5e5c1ee19fdc014494fcedd54f878545d7b..4bc1c10363ef039eea7bb48266596d0b911754c5 100644 (file)
@@ -10,6 +10,7 @@
 /////////////////////////////////////////////////////////////////////////////
 
 #ifdef __GNUG__
 /////////////////////////////////////////////////////////////////////////////
 
 #ifdef __GNUG__
+#pragma implementation "basicp.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>
@@ -308,7 +307,7 @@ bool wxPolygonShape::HitTest(double x, double y, int *attachment, double *distan
   for (i = 0; i < n; i++)
   {
     double xp, yp;
   for (i = 0; i < n; i++)
   {
     double xp, yp;
-    if (GetAttachmentPosition(i, &xp, &yp))
+    if (GetAttachmentPositionEdge(i, &xp, &yp))
     {
       double l = (double)sqrt(((xp - x) * (xp - x)) +
                  ((yp - y) * (yp - y)));
     {
       double l = (double)sqrt(((xp - x) * (xp - x)) +
                  ((yp - y) * (yp - y)));
@@ -329,7 +328,7 @@ bool wxPolygonShape::HitTest(double x, double y, int *attachment, double *distan
 void wxPolygonShape::SetSize(double new_width, double new_height, bool recursive)
 {
   SetAttachmentSize(new_width, new_height);
 void wxPolygonShape::SetSize(double new_width, double new_height, bool recursive)
 {
   SetAttachmentSize(new_width, new_height);
-  
+
   // Multiply all points by proportion of new size to old size
   double x_proportion = (double)(fabs(new_width/m_originalWidth));
   double y_proportion = (double)(fabs(new_height/m_originalHeight));
   // Multiply all points by proportion of new size to old size
   double x_proportion = (double)(fabs(new_width/m_originalWidth));
   double y_proportion = (double)(fabs(new_height/m_originalHeight));
@@ -439,7 +438,7 @@ bool wxPolygonShape::GetPerimeterPoint(double x1, double y1,
   // and we would want to connect to a point on that vertical --
   // oglFindEndForPolyline can't cope with this (the arrow
   // gets drawn to the wrong place).
   // and we would want to connect to a point on that vertical --
   // oglFindEndForPolyline can't cope with this (the arrow
   // gets drawn to the wrong place).
-  if ((!m_attachmentMode) && (x1 == x2))
+  if ((m_attachmentMode == ATTACHMENT_MODE_NONE) && (x1 == x2))
   {
     // Look for the point we'd be connecting to. This is
     // a heuristic...
   {
     // Look for the point we'd be connecting to. This is
     // a heuristic...
@@ -465,7 +464,7 @@ bool wxPolygonShape::GetPerimeterPoint(double x1, double y1,
       node = node->Next();
     }
   }
       node = node->Next();
     }
   }
-  
+
   double *xpoints = new double[n];
   double *ypoints = new double[n];
 
   double *xpoints = new double[n];
   double *ypoints = new double[n];
 
@@ -480,7 +479,7 @@ bool wxPolygonShape::GetPerimeterPoint(double x1, double y1,
     i ++;
   }
 
     i ++;
   }
 
-  oglFindEndForPolyline(n, xpoints, ypoints, 
+  oglFindEndForPolyline(n, xpoints, ypoints,
                         x1, y1, x2, y2, x3, y3);
 
   delete[] xpoints;
                         x1, y1, x2, y2, x3, y3);
 
   delete[] xpoints;
@@ -504,8 +503,8 @@ void wxPolygonShape::OnDraw(wxDC& dc)
     if (m_shadowMode != SHADOW_NONE)
     {
       if (m_shadowBrush)
     if (m_shadowMode != SHADOW_NONE)
     {
       if (m_shadowBrush)
-        dc.SetBrush(m_shadowBrush);
-      dc.SetPen(g_oglTransparentPen);
+        dc.SetBrush(m_shadowBrush);
+      dc.SetPen(g_oglTransparentPen);
 
       dc.DrawPolygon(n, intPoints, WXROUND(m_xpos + m_shadowOffsetX), WXROUND(m_ypos + m_shadowOffsetY));
     }
 
       dc.DrawPolygon(n, intPoints, WXROUND(m_xpos + m_shadowOffsetX), WXROUND(m_ypos + m_shadowOffsetY));
     }
@@ -513,12 +512,12 @@ void wxPolygonShape::OnDraw(wxDC& dc)
     if (m_pen)
     {
       if (m_pen->GetWidth() == 0)
     if (m_pen)
     {
       if (m_pen->GetWidth() == 0)
-        dc.SetPen(g_oglTransparentPen);
+        dc.SetPen(g_oglTransparentPen);
       else
       else
-        dc.SetPen(m_pen);
+        dc.SetPen(m_pen);
     }
     if (m_brush)
     }
     if (m_brush)
-      dc.SetBrush(m_brush);
+      dc.SetBrush(m_brush);
     dc.DrawPolygon(n, intPoints, WXROUND(m_xpos), WXROUND(m_ypos));
 
     delete[] intPoints;
     dc.DrawPolygon(n, intPoints, WXROUND(m_xpos), WXROUND(m_ypos));
 
     delete[] intPoints;
@@ -526,7 +525,7 @@ void wxPolygonShape::OnDraw(wxDC& dc)
 
 void wxPolygonShape::OnDrawOutline(wxDC& dc, double x, double y, double w, double h)
 {
 
 void wxPolygonShape::OnDrawOutline(wxDC& dc, double x, double y, double w, double h)
 {
-  dc.SetBrush(wxTRANSPARENT_BRUSH);
+  dc.SetBrush(wxTRANSPARENT_BRUSH);
   // Multiply all points by proportion of new size to old size
   double x_proportion = (double)(fabs(w/m_originalWidth));
   double y_proportion = (double)(fabs(h/m_originalHeight));
   // Multiply all points by proportion of new size to old size
   double x_proportion = (double)(fabs(w/m_originalWidth));
   double y_proportion = (double)(fabs(h/m_originalHeight));
@@ -785,7 +784,7 @@ int wxPolygonShape::GetNumberOfAttachments() const
 bool wxPolygonShape::GetAttachmentPosition(int attachment, double *x, double *y,
                                          int nth, int no_arcs, wxLineShape *line)
 {
 bool wxPolygonShape::GetAttachmentPosition(int attachment, double *x, double *y,
                                          int nth, int no_arcs, wxLineShape *line)
 {
-  if (m_attachmentMode && m_points && attachment < m_points->Number())
+  if ((m_attachmentMode == ATTACHMENT_MODE_EDGE) && m_points && attachment < m_points->Number())
   {
     wxRealPoint *point = (wxRealPoint *)m_points->Nth(attachment)->Data();
     *x = point->x + m_xpos;
   {
     wxRealPoint *point = (wxRealPoint *)m_points->Nth(attachment)->Data();
     *x = point->x + m_xpos;
@@ -800,7 +799,7 @@ bool wxPolygonShape::AttachmentIsValid(int attachment)
 {
   if (!m_points)
     return FALSE;
 {
   if (!m_points)
     return FALSE;
-    
+
   if ((attachment >= 0) && (attachment < m_points->Number()))
     return TRUE;
 
   if ((attachment >= 0) && (attachment < m_points->Number()))
     return TRUE;
 
@@ -880,8 +879,8 @@ void wxRectangleShape::OnDraw(wxDC& dc)
     if (m_shadowMode != SHADOW_NONE)
     {
       if (m_shadowBrush)
     if (m_shadowMode != SHADOW_NONE)
     {
       if (m_shadowBrush)
-        dc.SetBrush(m_shadowBrush);
-      dc.SetPen(g_oglTransparentPen);
+        dc.SetBrush(m_shadowBrush);
+      dc.SetPen(g_oglTransparentPen);
 
       if (m_cornerRadius != 0.0)
         dc.DrawRoundedRectangle(WXROUND(x1 + m_shadowOffsetX), WXROUND(y1 + m_shadowOffsetY),
 
       if (m_cornerRadius != 0.0)
         dc.DrawRoundedRectangle(WXROUND(x1 + m_shadowOffsetX), WXROUND(y1 + m_shadowOffsetY),
@@ -893,12 +892,12 @@ void wxRectangleShape::OnDraw(wxDC& dc)
     if (m_pen)
     {
       if (m_pen->GetWidth() == 0)
     if (m_pen)
     {
       if (m_pen->GetWidth() == 0)
-        dc.SetPen(g_oglTransparentPen);
+        dc.SetPen(g_oglTransparentPen);
       else
       else
-        dc.SetPen(m_pen);
+        dc.SetPen(m_pen);
     }
     if (m_brush)
     }
     if (m_brush)
-      dc.SetBrush(m_brush);
+      dc.SetBrush(m_brush);
 
     if (m_cornerRadius != 0.0)
       dc.DrawRoundedRectangle(WXROUND(x1), WXROUND(y1), WXROUND(m_width), WXROUND(m_height), m_cornerRadius);
 
     if (m_cornerRadius != 0.0)
       dc.DrawRoundedRectangle(WXROUND(x1), WXROUND(y1), WXROUND(m_width), WXROUND(m_height), m_cornerRadius);
@@ -989,61 +988,7 @@ int wxRectangleShape::GetNumberOfAttachments() const
 bool wxRectangleShape::GetAttachmentPosition(int attachment, double *x, double *y,
                                          int nth, int no_arcs, wxLineShape *line)
 {
 bool wxRectangleShape::GetAttachmentPosition(int attachment, double *x, double *y,
                                          int nth, int no_arcs, wxLineShape *line)
 {
-  if (m_attachmentMode)
-  {
-    double top = (double)(m_ypos + m_height/2.0);
-    double bottom = (double)(m_ypos - m_height/2.0);
-    double left = (double)(m_xpos - m_width/2.0);
-    double right = (double)(m_xpos + m_width/2.0);
-
-    bool isEnd = (line && line->IsEnd(this));
-
-    // Simplified code
-    switch (attachment)
-    {
-      case 0:
-      {
-        wxRealPoint pt = CalcSimpleAttachment(wxRealPoint(left, bottom), wxRealPoint(right, bottom),
-            nth, no_arcs, line);
-
-        *x = pt.x; *y = pt.y;
-        break;
-      }
-      case 1:
-      {
-        wxRealPoint pt = CalcSimpleAttachment(wxRealPoint(right, bottom), wxRealPoint(right, top),
-            nth, no_arcs, line);
-
-        *x = pt.x; *y = pt.y;
-        break;
-      }
-      case 2:
-      {
-        wxRealPoint pt = CalcSimpleAttachment(wxRealPoint(left, top), wxRealPoint(right, top),
-            nth, no_arcs, line);
-
-        *x = pt.x; *y = pt.y;
-        break;
-      }
-      case 3:
-      {
-        wxRealPoint pt = CalcSimpleAttachment(wxRealPoint(left, bottom), wxRealPoint(left, top),
-            nth, no_arcs, line);
-
-        *x = pt.x; *y = pt.y;
-        break;
-      }
-      default:
-      {
-        return wxShape::GetAttachmentPosition(attachment, x, y, nth, no_arcs, line);
-        break;
-      }
-    }
-
-    return TRUE;
-  }
-  else
-  { *x = m_xpos; *y = m_ypos; return TRUE; }
+    return wxShape::GetAttachmentPosition(attachment, x, y, nth, no_arcs, line);
 }
 
 // Text object (no box)
 }
 
 // Text object (no box)
@@ -1104,23 +1049,23 @@ void wxEllipseShape::OnDraw(wxDC& dc)
     if (m_shadowMode != SHADOW_NONE)
     {
       if (m_shadowBrush)
     if (m_shadowMode != SHADOW_NONE)
     {
       if (m_shadowBrush)
-        dc.SetBrush(m_shadowBrush);
-      dc.SetPen(g_oglTransparentPen);
-      dc.DrawEllipse((m_xpos - GetWidth()/2) + m_shadowOffsetX,
-                      (m_ypos - GetHeight()/2) + m_shadowOffsetY,
-                      GetWidth(), GetHeight());
+        dc.SetBrush(m_shadowBrush);
+      dc.SetPen(g_oglTransparentPen);
+      dc.DrawEllipse((long) ((m_xpos - GetWidth()/2) + m_shadowOffsetX),
+                      (long) ((m_ypos - GetHeight()/2) + m_shadowOffsetY),
+                      (long) GetWidth(), (long) GetHeight());
     }
 
     if (m_pen)
     {
       if (m_pen->GetWidth() == 0)
     }
 
     if (m_pen)
     {
       if (m_pen->GetWidth() == 0)
-        dc.SetPen(g_oglTransparentPen);
+        dc.SetPen(g_oglTransparentPen);
       else
       else
-        dc.SetPen(m_pen);
+        dc.SetPen(m_pen);
     }
     if (m_brush)
     }
     if (m_brush)
-      dc.SetBrush(m_brush);
-    dc.DrawEllipse((m_xpos - GetWidth()/2), (m_ypos - GetHeight()/2), GetWidth(), GetHeight());
+      dc.SetBrush(m_brush);
+    dc.DrawEllipse((long) (m_xpos - GetWidth()/2), (long) (m_ypos - GetHeight()/2), (long) GetWidth(), (long) GetHeight());
 }
 
 void wxEllipseShape::SetSize(double x, double y, bool recursive)
 }
 
 void wxEllipseShape::SetSize(double x, double y, bool recursive)
@@ -1179,13 +1124,19 @@ int wxEllipseShape::GetNumberOfAttachments() const
 bool wxEllipseShape::GetAttachmentPosition(int attachment, double *x, double *y,
                                          int nth, int no_arcs, wxLineShape *line)
 {
 bool wxEllipseShape::GetAttachmentPosition(int attachment, double *x, double *y,
                                          int nth, int no_arcs, wxLineShape *line)
 {
-  if (m_attachmentMode)
+  if (m_attachmentMode == ATTACHMENT_MODE_BRANCHING)
+    return wxShape::GetAttachmentPosition(attachment, x, y, nth, no_arcs, line);
+
+  if (m_attachmentMode != ATTACHMENT_MODE_NONE)
   {
     double top = (double)(m_ypos + m_height/2.0);
     double bottom = (double)(m_ypos - m_height/2.0);
     double left = (double)(m_xpos - m_width/2.0);
     double right = (double)(m_xpos + m_width/2.0);
   {
     double top = (double)(m_ypos + m_height/2.0);
     double bottom = (double)(m_ypos - m_height/2.0);
     double left = (double)(m_xpos - m_width/2.0);
     double right = (double)(m_xpos + m_width/2.0);
-    switch (attachment)
+
+    int physicalAttachment = LogicalToPhysicalAttachment(attachment);
+
+    switch (physicalAttachment)
     {
       case 0:
       {
     {
       case 0:
       {
@@ -1256,7 +1207,7 @@ bool wxCircleShape::GetPerimeterPoint(double x1, double y1,
                                       double x2, double y2,
                                       double *x3, double *y3)
 {
                                       double x2, double y2,
                                       double *x3, double *y3)
 {
-  oglFindEndForCircle(m_width/2, 
+  oglFindEndForCircle(m_width/2,
                       m_xpos, m_ypos,  // Centre of circle
                       x2, y2,  // Other end of line
                       x3, y3);
                       m_xpos, m_ypos,  // Centre of circle
                       x2, y2,  // Other end of line
                       x3, y3);
@@ -1351,7 +1302,7 @@ void wxShape::OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y
   wxClientDC dc(GetCanvas());
   GetCanvas()->PrepareDC(dc);
 
   wxClientDC dc(GetCanvas());
   GetCanvas()->PrepareDC(dc);
 
-  dc.SetLogicalFunction(wxXOR);
+  dc.SetLogicalFunction(OGLRBLF);
 
   wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT);
   dc.SetPen(dottedPen);
 
   wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT);
   dc.SetPen(dottedPen);
@@ -1387,7 +1338,7 @@ void wxShape::OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y
 
     if (this->GetFixedWidth())
       new_width = bound_x;
 
     if (this->GetFixedWidth())
       new_width = bound_x;
-      
+
     if (this->GetFixedHeight())
       new_height = bound_y;
 
     if (this->GetFixedHeight())
       new_height = bound_y;
 
@@ -1439,7 +1390,7 @@ void wxShape::OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y
     pt->sm_controlPointDragPosY = (double)(newY1 + (newHeight/2.0));
     if (this->GetFixedWidth())
       newWidth = bound_x;
     pt->sm_controlPointDragPosY = (double)(newY1 + (newHeight/2.0));
     if (this->GetFixedWidth())
       newWidth = bound_x;
-     
+
     if (this->GetFixedHeight())
       newHeight = bound_y;
 
     if (this->GetFixedHeight())
       newHeight = bound_y;
 
@@ -1460,7 +1411,7 @@ void wxShape::OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int
     this->Erase(dc);
 */
 
     this->Erase(dc);
 */
 
-  dc.SetLogicalFunction(wxXOR);
+  dc.SetLogicalFunction(OGLRBLF);
 
   double bound_x;
   double bound_y;
 
   double bound_x;
   double bound_y;
@@ -1520,7 +1471,7 @@ void wxShape::OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int
 
     if (this->GetFixedWidth())
       new_width = bound_x;
 
     if (this->GetFixedWidth())
       new_width = bound_x;
-      
+
     if (this->GetFixedHeight())
       new_height = bound_y;
 
     if (this->GetFixedHeight())
       new_height = bound_y;
 
@@ -1615,11 +1566,11 @@ void wxShape::OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int ke
   if (!eraseIt)
     theObject->Show(TRUE);
 */
   if (!eraseIt)
     theObject->Show(TRUE);
 */
-    
+
   // Recursively redraw links if we have a composite.
   if (theObject->GetChildren().Number() > 0)
     theObject->DrawLinks(dc, -1, TRUE);
   // Recursively redraw links if we have a composite.
   if (theObject->GetChildren().Number() > 0)
     theObject->DrawLinks(dc, -1, TRUE);
-    
+
   double width, height;
   theObject->GetBoundingBoxMax(&width, &height);
   theObject->GetEventHandler()->OnEndSize(width, height);
   double width, height;
   theObject->GetBoundingBoxMax(&width, &height);
   theObject->GetEventHandler()->OnEndSize(width, height);
@@ -1685,7 +1636,7 @@ void wxPolygonShape::OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, d
   wxClientDC dc(GetCanvas());
   GetCanvas()->PrepareDC(dc);
 
   wxClientDC dc(GetCanvas());
   GetCanvas()->PrepareDC(dc);
 
-  dc.SetLogicalFunction(wxXOR);
+  dc.SetLogicalFunction(OGLRBLF);
 
   wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT);
   dc.SetPen(dottedPen);
 
   wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT);
   dc.SetPen(dottedPen);
@@ -1724,7 +1675,7 @@ void wxPolygonShape::OnSizingBeginDragLeft(wxControlPoint* pt, double x, double
 
   this->Erase(dc);
 
 
   this->Erase(dc);
 
-  dc.SetLogicalFunction(wxXOR);
+  dc.SetLogicalFunction(OGLRBLF);
 
   double bound_x;
   double bound_y;
 
   double bound_x;
   double bound_y;