]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/demo/OGL.py
warning fix
[wxWidgets.git] / wxPython / demo / OGL.py
index 22798f67ae2c8d9f1d39f05416e75e6bea53839f..af0c047845b5dd7d763d6e958737c727c7ff71fb 100644 (file)
@@ -8,6 +8,10 @@
 # o Changed to use the python version of OGL
 # o Added TextShape, CompositeShape and CompositeShape with divisions
 #
+# 20040830 - Pierre Hjälm
+#
+# o Added DrawnShape
+#
 
 import wx
 import wx.lib.ogl as ogl
@@ -16,6 +20,38 @@ import  images
 
 #----------------------------------------------------------------------
 
+class DrawnShape(ogl.DrawnShape):
+    def __init__(self):
+        ogl.DrawnShape.__init__(self)
+
+        self.SetDrawnBrush(wx.WHITE_BRUSH)
+        self.SetDrawnPen(wx.BLACK_PEN)
+        self.DrawArc((0, -10), (30, 0), (-30, 0))
+
+        self.SetDrawnPen(wx.Pen("#ff8030"))
+        self.DrawLine((-30, 5), (30, 5))
+
+        self.SetDrawnPen(wx.Pen("#00ee10"))
+        self.DrawRoundedRectangle((-20, 10, 40, 10), 5)
+
+        self.SetDrawnPen(wx.Pen("#9090f0"))
+        self.DrawEllipse((-30, 25, 60, 20))
+
+        self.SetDrawnTextColour(wx.BLACK)
+        self.SetDrawnFont(wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL))
+        self.DrawText("DrawText", (-26, 28))
+
+        self.SetDrawnBrush(wx.GREEN_BRUSH)
+        self.DrawPolygon([(-100, 5), (-45, 30), (-35, 20), (-30, 5)])
+
+        self.SetDrawnPen(wx.BLACK_PEN)
+        self.DrawLines([(30, -45), (40, -45), (40 ,45), (30, 45)])
+
+        # Make sure to call CalculateSize when all drawing is done
+        self.CalculateSize()
+        
+#----------------------------------------------------------------------
+
 class DiamondShape(ogl.PolygonShape):
     def __init__(self, w=0.0, h=0.0):
         ogl.PolygonShape.__init__(self)
@@ -247,7 +283,7 @@ class TestWindow(ogl.ShapeCanvas):
 
         self.MyAddShape(
             CompositeDivisionShape(self), 
-            310, 310, wx.BLACK_PEN, wx.BLUE_BRUSH, "Division"
+            270, 310, wx.BLACK_PEN, wx.BLUE_BRUSH, "Division"
             )
         
         self.MyAddShape(
@@ -270,14 +306,19 @@ class TestWindow(ogl.ShapeCanvas):
             305, 60, wx.BLACK_PEN, wx.LIGHT_GREY_BRUSH, "Rectangle"
             )
 
+        self.MyAddShape(
+            DrawnShape(),
+            500, 80, wx.BLACK_PEN, wx.BLACK_BRUSH, "DrawnShape"
+            )
+
         ds = self.MyAddShape(
             DividedShape(140, 150, self), 
-            515, 145, wx.BLACK_PEN, dsBrush, ''
+            520, 265, wx.BLACK_PEN, dsBrush, ''
             )
 
         self.MyAddShape(
             DiamondShape(90, 90), 
-            445, 305, wx.Pen(wx.BLUE, 3, wx.DOT), wx.RED_BRUSH, "Polygon"
+            355, 260, wx.Pen(wx.BLUE, 3, wx.DOT), wx.RED_BRUSH, "Polygon"
             )
             
         self.MyAddShape(
@@ -327,7 +368,9 @@ class TestWindow(ogl.ShapeCanvas):
         shape.SetY(y)
         if pen:    shape.SetPen(pen)
         if brush:  shape.SetBrush(brush)
-        if text:   shape.AddText(text)
+        if text:
+            for line in text.split('\n'):
+                shape.AddText(line)
         #shape.SetShadowMode(ogl.SHADOW_RIGHT)
         self.diagram.AddShape(shape)
         shape.Show(True)