]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/demo/wxOGL.py
fixed array tests compilation and a bug in obj array test
[wxWidgets.git] / wxPython / demo / wxOGL.py
index 934152255a55f29bef1279a381acc68a181fef83..32b0676cfaf1cac2e2bfc28fbe23e71dd0ceee05 100644 (file)
@@ -2,6 +2,8 @@
 from wxPython.wx import *
 from wxPython.ogl import *
 
+import images
+
 #----------------------------------------------------------------------
 # This creates some pens and brushes that the OGL library uses.
 
@@ -41,40 +43,6 @@ class RoundedRectangleShape(wxRectangleShape):
         self.SetCornerRadius(-0.3)
 
 
-#----------------------------------------------------------------------
-
-## class LabeledBitmapShape(wxBitmapShape):
-##     def __init__(self, bmp, text):
-##         wxBitmapShape.__init__(self)
-##         self.SetBitmap(bmp)
-##         self.region = r = wxShapeRegion()
-##         r.SetPosition(0, 0) #bmp.GetHeight())
-##         r.SetSize(bmp.GetWidth(), bmp.GetHeight())
-##         r.SetText(text)
-##         self.AddRegion(r)
-
-##     def OnMovePost(self, dc, x, y, old_x, old_y, display):
-##         self.region.SetPosition(x, y)
-##         self.base_OnMovePost(dc, x, y, old_x, old_y, display)
-
-
-## class LabeledBitmapShape(wxCompositeShape):
-##     def __init__(self, canvas, bmp, text):
-##         wxCompositeShape.__init__(self)
-##         self.bs = wxBitmapShape()
-##         self.bs.SetBitmap(bmp)
-##         self.ts = wxTextShape()
-##         self.ts.AddText(text)
-
-##         self.AddChild(self.bs)
-##         self.AddChild(self.ts, self.bs)
-
-##         self.AddConstrainedShapes(gyCONSTRAINT_CENTRED_VERTICALLY, self, [self.bs, self.ts])
-##         self.AddSimpleConstraint(gyCONSTRAINT_BELOW, self.bs, self.ts)
-##         self.AddSimpleConstraint(gyCONSTRAINT_ALIGNED_TOP, self, self.bs)
-##         self.AddSimpleConstraint(gyCONSTRAINT_ALIGNED_BOTTOM, self, self.ts)
-
-
 #----------------------------------------------------------------------
 
 class MyEvtHandler(wxShapeEvtHandler):
@@ -92,6 +60,7 @@ class MyEvtHandler(wxShapeEvtHandler):
 
     def OnLeftClick(self, x, y, keys = 0, attachment = 0):
         shape = self.GetShape()
+        print shape.__class__
         canvas = shape.GetCanvas()
         dc = wxClientDC(canvas)
         canvas.PrepareDC(dc)
@@ -154,7 +123,7 @@ class TestWindow(wxShapeCanvas):
 
         self.log = log
         self.frame = frame
-        self.SetBackgroundColour(wxWHITE)
+        self.SetBackgroundColour("LIGHT BLUE") #wxWHITE)
         self.diagram = wxDiagram()
         self.SetDiagram(self.diagram)
         self.diagram.SetCanvas(self)
@@ -168,19 +137,9 @@ class TestWindow(wxShapeCanvas):
         self.MyAddShape(DiamondShape(90, 90), 345, 235, wxPen(wxBLUE, 3, wxDOT), wxRED_BRUSH, "Polygon")
         self.MyAddShape(RoundedRectangleShape(95,70), 140, 255, wxPen(wxRED, 1), rRectBrush, "Rounded Rect")
 
-        bmp = wxBitmap('bitmaps/test2.bmp', wxBITMAP_TYPE_BMP)
+        bmp = images.getTest2Bitmap()
         mask = wxMaskColour(bmp, wxBLUE)
         bmp.SetMask(mask)
-##         s = LabeledBitmapShape(self, bmp, "Hello")
-##         self.MyAddShape(s, 225, 150, None, None, None)
-##         print s.Recompute()
-##         s.CalculateSize()
-##         print s.GetX(), s.GetY()
-##         s.SetSize(225)
-##         s.SetY(150)
-##         s.SetSize(80, 80)
-##         print s.GetX(), s.GetY()
-##         #print s.GetSize()
 
         s = wxBitmapShape()
         s.SetBitmap(bmp)
@@ -207,6 +166,11 @@ class TestWindow(wxShapeCanvas):
             # for some reason, the shapes have to be moved for the line to show up...
             fromShape.Move(dc, fromShape.GetX(), fromShape.GetY())
 
+##         EVT_PAINT(self, self.OnPaint)
+
+##     def OnPaint(self, evt):
+##         evt.Skip()
+##         print "TheLists:", wxThePenList.GetCount(), wxTheBrushList.GetCount(), wxTheFontList.GetCount()
 
 
     def MyAddShape(self, shape, x, y, pen, brush, text):
@@ -235,6 +199,14 @@ class TestWindow(wxShapeCanvas):
             if shape.GetParent() == None:
                 shape.SetCanvas(None)
                 shape.Destroy()
+        self.diagram.Destroy()
+
+
+    def OnBeginDragLeft(self, x, y, keys):
+        self.log.write("OnBeginDragLeft: %s, %s, %s\n" % (x, y, keys))
+
+    def OnEndDragLeft(self, x, y, keys):
+        self.log.write("OnEndDragLeft: %s, %s, %s\n" % (x, y, keys))
 
 
 #----------------------------------------------------------------------