]> git.saurik.com Git - wxWidgets.git/commitdiff
Shapes will now draw the right background color when erased if the
authorRobin Dunn <robin@alldunn.com>
Tue, 27 Nov 2001 00:35:36 +0000 (00:35 +0000)
committerRobin Dunn <robin@alldunn.com>
Tue, 27 Nov 2001 00:35:36 +0000 (00:35 +0000)
canvas is not white.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12715 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

contrib/include/wx/ogl/basic.h
contrib/include/wx/ogl/misc.h
contrib/src/ogl/basic.cpp
contrib/src/ogl/canvas.cpp
contrib/src/ogl/lines.cpp
contrib/src/ogl/misc.cpp

index 9c52020c85cb51c74798493cf4d7400422ff18bd..d447693dfaa134376cf4ca0413f6ac4ef06a783a 100644 (file)
@@ -515,6 +515,11 @@ class wxShape: public wxShapeEvtHandler
   // Clears points from a list of wxRealPoints
   void ClearPointList(wxList& list);
 
+  // Return pen or brush of the right colour for the background
+  wxPen GetBackgroundPen();
+  wxBrush GetBackgroundBrush();
+
+
  private:
   wxObject*             m_clientData;
 
index 4e6abfb6b24f2c5b6855f35ed68ec2e17e1a721d..c8096d81bbb644f03f57c63841e104c108ba0be8 100644 (file)
@@ -53,20 +53,20 @@ void oglDrawFormattedText(wxDC& context, wxList *text_list,
 // Give it a list of points, finds the centre.
 void oglFindPolylineCentroid(wxList *points, double *x, double *y);
 
-void oglCheckLineIntersection(double x1, double y1, double x2, double y2, 
+void oglCheckLineIntersection(double x1, double y1, double x2, double y2,
                              double x3, double y3, double x4, double y4,
                              double *ratio1, double *ratio2);
 
-void oglFindEndForPolyline(double n, double xvec[], double yvec[], 
+void oglFindEndForPolyline(double n, double xvec[], double yvec[],
                            double x1, double y1, double x2, double y2, double *x3, double *y3);
 
 
-void oglFindEndForBox(double width, double height, 
+void oglFindEndForBox(double width, double height,
                       double x1, double y1,         // Centre of box (possibly)
                       double x2, double y2,         // other end of line
                       double *x3, double *y3);      // End on box edge
 
-void oglFindEndForCircle(double radius, 
+void oglFindEndForCircle(double radius,
                          double x1, double y1,  // Centre of circle
                          double x2, double y2,  // Other end of line
                          double *x3, double *y3);
@@ -83,7 +83,7 @@ void oglGetArrowPoints(double x1, double y1, double x2, double y2,
  * This function assumes that the centre of the ellipse is at x1, y1, and the
  * ellipse has a width of a1 and a height of b1. It also assumes you are
  * wanting to draw an arc FROM point x2, y2 TOWARDS point x3, y3.
- * This function calculates the x,y coordinates of the intersection point of 
+ * This function calculates the x,y coordinates of the intersection point of
  * the arc with the ellipse.
  * Author: Ian Harrison
  */
@@ -99,7 +99,6 @@ extern wxPen*           g_oglWhiteBackgroundPen;
 extern wxPen*           g_oglTransparentPen;
 extern wxBrush*         g_oglWhiteBackgroundBrush;
 extern wxPen*           g_oglBlackForegroundPen;
-extern wxCursor*        g_oglBullseyeCursor;
 
 extern wxFont*          oglMatchFont(int point_size);
 
index f5bdab84e5a1b484e2789b5392c4a3563a92f3e2..29e50b9c9320bf882ee6c1c19f2914825459b1bb 100644 (file)
@@ -997,8 +997,9 @@ void wxShape::OnEraseContents(wxDC& dc)
     if (m_pen)
       penWidth = m_pen->GetWidth();
 
-    dc.SetPen(* g_oglWhiteBackgroundPen);
-    dc.SetBrush(* g_oglWhiteBackgroundBrush);
+    dc.SetPen(GetBackgroundPen());
+    dc.SetBrush(GetBackgroundBrush());
+
     dc.DrawRectangle(WXROUND(topLeftX - penWidth), WXROUND(topLeftY - penWidth),
                       WXROUND(maxX + penWidth*2.0 + 4.0), WXROUND(maxY + penWidth*2.0 + 4.0));
 }
@@ -3281,3 +3282,25 @@ void wxShape::Rotate(double WXUNUSED(x), double WXUNUSED(y), double theta)
     }
 }
 
+
+wxPen wxShape::GetBackgroundPen()
+{
+    if (GetCanvas())
+    {
+        wxColour c = GetCanvas()->GetBackgroundColour();
+        return wxPen(c, 1, wxSOLID);
+    }
+    return * g_oglWhiteBackgroundPen;
+}
+
+
+wxBrush wxShape::GetBackgroundBrush()
+{
+    if (GetCanvas())
+    {
+        wxColour c = GetCanvas()->GetBackgroundColour();
+        return wxBrush(c, wxSOLID);
+    }
+    return * g_oglWhiteBackgroundBrush;
+}
+
index ac81c3d692a05a3589fe70292e6c09d38d903a30..aa04b2d01caf76d019063087fe79fb4b3067b6dc 100644 (file)
@@ -61,8 +61,6 @@
 #define CONTROL_POINT_ENDPOINT_FROM 5
 #define CONTROL_POINT_LINE       6
 
-extern wxCursor *g_oglBullseyeCursor;
-
 IMPLEMENT_DYNAMIC_CLASS(wxShapeCanvas, wxScrolledWindow)
 
 BEGIN_EVENT_TABLE(wxShapeCanvas, wxScrolledWindow)
index 60365d3a2dbdd1825b4a78bdb3ec1e405284706f..fb159d7b83f23562d6befbb35a5d2e53fb93cf3e 100644 (file)
@@ -288,8 +288,8 @@ void wxLineShape::DrawRegion(wxDC& dc, wxShapeRegion *region, double x, double y
   // First, clear a rectangle for the text IF there is any
   if (region->GetFormattedText().Number() > 0)
   {
-      dc.SetPen(* g_oglWhiteBackgroundPen);
-      dc.SetBrush(* g_oglWhiteBackgroundBrush);
+      dc.SetPen(GetBackgroundPen());
+      dc.SetBrush(GetBackgroundBrush());
 
       // Now draw the text
       if (region->GetFont()) dc.SetFont(* region->GetFont());
@@ -300,7 +300,7 @@ void wxLineShape::DrawRegion(wxDC& dc, wxShapeRegion *region, double x, double y
       dc.SetTextForeground(* region->GetActualColourObject());
 
 #ifdef __WXMSW__
-      dc.SetTextBackground(g_oglWhiteBackgroundBrush->GetColour());
+      dc.SetTextBackground(GetBackgroundBrush().GetColour());
 #endif
 
       oglDrawFormattedText(dc, &(region->GetFormattedText()), xp, yp, w, h, region->GetFormatMode());
@@ -324,8 +324,8 @@ void wxLineShape::EraseRegion(wxDC& dc, wxShapeRegion *region, double x, double
 
   if (region->GetFormattedText().Number() > 0)
   {
-      dc.SetPen(* g_oglWhiteBackgroundPen);
-      dc.SetBrush(* g_oglWhiteBackgroundBrush);
+      dc.SetPen(GetBackgroundPen());
+      dc.SetBrush(GetBackgroundBrush());
 
       dc.DrawRectangle((long)(xp - w/2.0), (long)(yp - h/2.0), (long)w, (long)h);
   }
@@ -853,8 +853,10 @@ void wxLineShape::OnErase(wxDC& dc)
 {
     wxPen *old_pen = m_pen;
     wxBrush *old_brush = m_brush;
-    SetPen(g_oglWhiteBackgroundPen);
-    SetBrush(g_oglWhiteBackgroundBrush);
+    wxPen bg_pen = GetBackgroundPen();
+    wxBrush bg_brush = GetBackgroundBrush();
+    SetPen(&bg_pen);
+    SetBrush(&bg_brush);
 
     double bound_x, bound_y;
     GetBoundingBoxMax(&bound_x, &bound_y);
@@ -874,8 +876,8 @@ void wxLineShape::OnErase(wxDC& dc)
     }
 
     // Undraw line
-    dc.SetPen(* g_oglWhiteBackgroundPen);
-    dc.SetBrush(* g_oglWhiteBackgroundBrush);
+    dc.SetPen(GetBackgroundPen());
+    dc.SetBrush(GetBackgroundBrush());
 
     // Drawing over the line only seems to work if the line has a thickness
     // of 1.
@@ -1817,7 +1819,7 @@ void wxLineShape::OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y,
 
   if (lpt->m_type == CONTROL_POINT_ENDPOINT_FROM || lpt->m_type == CONTROL_POINT_ENDPOINT_TO)
   {
-    m_canvas->SetCursor(* g_oglBullseyeCursor);
+    m_canvas->SetCursor(wxCursor(wxCURSOR_BULLSEYE));
     lpt->m_oldCursor = wxSTANDARD_CURSOR;
   }
 }
@@ -1933,7 +1935,7 @@ void wxLineControlPoint::OnBeginDragRight(double x, double y, int keys, int atta
       lineShape->GetTo()->GetEventHandler()->OnDraw(dc);
       lineShape->GetTo()->GetEventHandler()->OnDrawContents(dc);
     }
-    m_canvas->SetCursor(g_oglBullseyeCursor);
+    m_canvas->SetCursor(wxCursor(wxCURSOR_BULLSEYE));
     m_oldCursor = wxSTANDARD_CURSOR;
   }
 }
index a9a466c2da6d7315d93c6d82ff9e788cab75416d..d98a6eb596fc5807473c5ca4f1b95298ef765946 100644 (file)
 
 wxFont*         g_oglNormalFont;
 wxPen*          g_oglBlackPen;
-wxPen*          g_oglWhiteBackgroundPen;
 wxPen*          g_oglTransparentPen;
-wxBrush*        g_oglWhiteBackgroundBrush;
 wxPen*          g_oglBlackForegroundPen;
-wxCursor*       g_oglBullseyeCursor = NULL;
+wxPen*          g_oglWhiteBackgroundPen;
+wxBrush*        g_oglWhiteBackgroundBrush;
 
 char*           oglBuffer = NULL;
 
@@ -63,16 +62,12 @@ wxList          oglObjectCopyMapping(wxKEY_INTEGER);
 
 void wxOGLInitialize()
 {
-  g_oglBullseyeCursor = new wxCursor(wxCURSOR_BULLSEYE);
-
-  g_oglNormalFont = new wxFont(10, wxSWISS, wxNORMAL, wxNORMAL);
-
-  g_oglBlackPen = new wxPen("BLACK", 1, wxSOLID);
-
-  g_oglWhiteBackgroundPen = new wxPen("WHITE", 1, wxSOLID);
-  g_oglTransparentPen = new wxPen("WHITE", 1, wxTRANSPARENT);
-  g_oglWhiteBackgroundBrush = new wxBrush("WHITE", wxSOLID);
-  g_oglBlackForegroundPen = new wxPen("BLACK", 1, wxSOLID);
+  g_oglNormalFont = wxTheFontList->FindOrCreateFont(10, wxSWISS, wxNORMAL, wxNORMAL);
+  g_oglBlackPen = wxThePenList->FindOrCreatePen("BLACK", 1, wxSOLID);
+  g_oglTransparentPen = wxThePenList->FindOrCreatePen("WHITE", 1, wxTRANSPARENT);
+  g_oglBlackForegroundPen = wxThePenList->FindOrCreatePen("BLACK", 1, wxSOLID);
+  g_oglWhiteBackgroundPen = wxThePenList->FindOrCreatePen("WHITE", 1, wxSOLID);
+  g_oglWhiteBackgroundBrush = wxTheBrushList->FindOrCreateBrush("WHITE", wxSOLID);
 
   OGLInitializeConstraintTypes();
 
@@ -89,42 +84,13 @@ void wxOGLCleanUp()
         oglBuffer = NULL;
     }
     oglBuffer = NULL;
-    if (g_oglBullseyeCursor)
-    {
-        delete g_oglBullseyeCursor;
-        g_oglBullseyeCursor = NULL;
-    }
 
-    if (g_oglNormalFont)
-    {
-        delete g_oglNormalFont;
-        g_oglNormalFont = NULL;
-    }
-    if (g_oglBlackPen)
-    {
-        delete g_oglBlackPen;
-        g_oglBlackPen = NULL;
-    }
-    if (g_oglWhiteBackgroundPen)
-    {
-        delete g_oglWhiteBackgroundPen;
-        g_oglWhiteBackgroundPen = NULL;
-    }
-    if (g_oglTransparentPen)
-    {
-        delete g_oglTransparentPen;
-        g_oglTransparentPen = NULL;
-    }
-    if (g_oglWhiteBackgroundBrush)
-    {
-        delete g_oglWhiteBackgroundBrush;
-        g_oglWhiteBackgroundBrush = NULL;
-    }
-    if (g_oglBlackForegroundPen)
-    {
-        delete g_oglBlackForegroundPen;
-        g_oglBlackForegroundPen = NULL;
-    }
+    g_oglNormalFont = NULL;             // These will be cleaned up by their GDI list
+    g_oglBlackPen = NULL;
+    g_oglTransparentPen = NULL;
+    g_oglBlackForegroundPen = NULL;
+    g_oglWhiteBackgroundPen = NULL;
+    g_oglWhiteBackgroundBrush = NULL;
 
     OGLCleanUpConstraintTypes();
 }