]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/wx/lib/ogl/_basic.py
frame should call skip on child focus event to give owner a chance
[wxWidgets.git] / wxPython / wx / lib / ogl / _basic.py
index 142ee3366af332fb2a3109413bfd7dea6a35ec28..4ace078e4435960bed9b8ed49734a38ca6ed0ca8 100644 (file)
@@ -19,7 +19,6 @@ from _oglmisc import *
 DragOffsetX = 0.0
 DragOffsetY = 0.0
 
 DragOffsetX = 0.0
 DragOffsetY = 0.0
 
-
 def OGLInitialize():
     global WhiteBackgroundPen, WhiteBackgroundBrush, TransparentPen
     global BlackForegroundPen, NormalFont
 def OGLInitialize():
     global WhiteBackgroundPen, WhiteBackgroundBrush, TransparentPen
     global BlackForegroundPen, NormalFont
@@ -82,7 +81,11 @@ class ShapeEvtHandler(object):
 
     def GetPreviousHandler(self):
         return self._previousHandler
 
     def GetPreviousHandler(self):
         return self._previousHandler
-    
+
+    def OnDelete(self):
+        if self!=self.GetShape():
+            del self
+            
     def OnDraw(self, dc):
         if self._previousHandler:
             self._previousHandler.OnDraw(dc)
     def OnDraw(self, dc):
         if self._previousHandler:
             self._previousHandler.OnDraw(dc)
@@ -283,20 +286,33 @@ class Shape(ShapeEvtHandler):
 
     def GetClassName(self):
         return str(self.__class__).split(".")[-1][:-2]
 
     def GetClassName(self):
         return str(self.__class__).split(".")[-1][:-2]
-    
-    def __del__(self):
+
+    def Delete(self):
+        """
+        Fully disconnect this shape from parents, children, the
+        canvas, etc.
+        """
         if self._parent:
         if self._parent:
-            i = self._parent.GetChildren().index(self)
-            self._parent.GetChildren(i).remove(self)
+            self._parent.GetChildren().remove(self)
+
+        for child in self.GetChildren():
+            child.Delete()
 
         self.ClearText()
         self.ClearRegions()
         self.ClearAttachments()
 
 
         self.ClearText()
         self.ClearRegions()
         self.ClearAttachments()
 
+        self._handlerShape = None
+        
         if self._canvas:
         if self._canvas:
-            self._canvas.RemoveShape(self)
+            self.RemoveFromCanvas(self._canvas)
 
 
-        self.GetEventHandler().OnDelete()
+        if self.GetEventHandler():
+            self.GetEventHandler().OnDelete()
+        self._eventHandler = None
+        
+    def __del__(self):
+        ShapeEvtHandler.__del__(self)
 
     def Draggable(self):
         """TRUE if the shape may be dragged by the user."""
 
     def Draggable(self):
         """TRUE if the shape may be dragged by the user."""
@@ -386,6 +402,10 @@ class Shape(ShapeEvtHandler):
         else:
             self._shadowMode = mode
 
         else:
             self._shadowMode = mode
 
+    def GetShadowMode(self):
+        """Return the current shadow mode setting"""
+        return self._shadowMode
+
     def SetCanvas(self, theCanvas):
         """Identical to Shape.Attach."""
         self._canvas = theCanvas
     def SetCanvas(self, theCanvas):
         """Identical to Shape.Attach."""
         self._canvas = theCanvas
@@ -416,6 +436,8 @@ class Shape(ShapeEvtHandler):
         """Remove the shape from the canvas."""
         if self.Selected():
             self.Select(False)
         """Remove the shape from the canvas."""
         if self.Selected():
             self.Select(False)
+        
+        self._canvas = None
         theCanvas.RemoveShape(self)
         for object in self._children:
             object.RemoveFromCanvas(theCanvas)
         theCanvas.RemoveShape(self)
         for object in self._children:
             object.RemoveFromCanvas(theCanvas)
@@ -633,7 +655,7 @@ class Shape(ShapeEvtHandler):
         """Get the colour for the specified text region."""
         if regionId >= len(self._regions):
             return ""
         """Get the colour for the specified text region."""
         if regionId >= len(self._regions):
             return ""
-        return self._regions[regionId].GetTextColour()
+        return self._regions[regionId].GetColour()
 
     def SetRegionName(self, name, regionId = 0):
         """Set the name for this region.
 
     def SetRegionName(self, name, regionId = 0):
         """Set the name for this region.
@@ -734,18 +756,18 @@ class Shape(ShapeEvtHandler):
         if self._pen:
             dc.SetPen(self._pen)
 
         if self._pen:
             dc.SetPen(self._pen)
 
-        region = self._regions[0]
-        if region.GetFont():
-            dc.SetFont(region.GetFont())
+        for region in self._regions:
+            if region.GetFont():
+                dc.SetFont(region.GetFont())
 
 
-        dc.SetTextForeground(region.GetActualColourObject())
-        dc.SetBackgroundMode(wx.TRANSPARENT)
-        if not self._formatted:
-            CentreText(dc, region.GetFormattedText(), self._xpos, self._ypos, bound_x - 2 * self._textMarginX, bound_y - 2 * self._textMarginY, region.GetFormatMode())
-            self._formatted = True
+            dc.SetTextForeground(region.GetActualColourObject())
+            dc.SetBackgroundMode(wx.TRANSPARENT)
+            if not self._formatted:
+                CentreText(dc, region.GetFormattedText(), self._xpos, self._ypos, bound_x - 2 * self._textMarginX, bound_y - 2 * self._textMarginY, region.GetFormatMode())
+                self._formatted = True
 
 
-        if not self.GetDisableLabel():
-            DrawFormattedText(dc, region.GetFormattedText(), self._xpos, self._ypos, bound_x - 2 * self._textMarginX, bound_y - 2 * self._textMarginY, region.GetFormatMode())
+            if not self.GetDisableLabel():
+                DrawFormattedText(dc, region.GetFormattedText(), self._xpos, self._ypos, bound_x - 2 * self._textMarginX, bound_y - 2 * self._textMarginY, region.GetFormatMode())
             
 
     def DrawContents(self, dc):
             
 
     def DrawContents(self, dc):
@@ -814,7 +836,7 @@ class Shape(ShapeEvtHandler):
 
         for line in self._lines:
             if attachment == -1 or (line.GetTo() == self and line.GetAttachmentTo() == attachment or line.GetFrom() == self and line.GetAttachmentFrom() == attachment):
 
         for line in self._lines:
             if attachment == -1 or (line.GetTo() == self and line.GetAttachmentTo() == attachment or line.GetFrom() == self and line.GetAttachmentFrom() == attachment):
-                line.GetEventHandler().Draw(dc)
+                line.Draw(dc)
                 
         if recurse:
             for child in self._children:
                 
         if recurse:
             for child in self._children:
@@ -1144,7 +1166,7 @@ class Shape(ShapeEvtHandler):
         """Flash the shape."""
         if self.GetCanvas():
             dc = wx.ClientDC(self.GetCanvas())
         """Flash the shape."""
         if self.GetCanvas():
             dc = wx.ClientDC(self.GetCanvas())
-            self.GetCanvas.PrepareDC(dc)
+            self.GetCanvas().PrepareDC(dc)
 
             dc.SetLogicalFunction(OGLRBLF)
             self.Draw(dc)
 
             dc.SetLogicalFunction(OGLRBLF)
             self.Draw(dc)
@@ -1372,13 +1394,13 @@ class Shape(ShapeEvtHandler):
 
         Does not redraw the shape.
         """
 
         Does not redraw the shape.
         """
-        for control in self._controlPoints:
+        for control in self._controlPoints[:]:
             if dc:
                 control.GetEventHandler().OnErase(dc)
             if dc:
                 control.GetEventHandler().OnErase(dc)
-            self._canvas.RemoveShape(control)
-            del control
+            control.Delete()
+            self._controlPoints.remove(control)
         self._controlPoints = []
         self._controlPoints = []
-
+        
         # Children of divisions are contained objects,
         # so stop here
         if not isinstance(self, DivisionShape):
         # Children of divisions are contained objects,
         # so stop here
         if not isinstance(self, DivisionShape):
@@ -1540,11 +1562,6 @@ class Shape(ShapeEvtHandler):
                 return True
         return False
 
                 return True
         return False
 
-    # Clears points from a list of wxRealPoints, and clears list
-    # Useless in python? /pi
-    def ClearPointList(self, list):
-        list = []
-
     # Assuming the attachment lies along a vertical or horizontal line,
     # calculate the position on that point.
     def CalcSimpleAttachment(self, pt1, pt2, nth, noArcs, line):
     # Assuming the attachment lies along a vertical or horizontal line,
     # calculate the position on that point.
     def CalcSimpleAttachment(self, pt1, pt2, nth, noArcs, line):
@@ -1797,15 +1814,15 @@ class Shape(ShapeEvtHandler):
             dc.SetBrush(wx.BLACK_BRUSH)
 
         # Draw neck
             dc.SetBrush(wx.BLACK_BRUSH)
 
         # Draw neck
-        dc.DrawLine(root, neck)
+        dc.DrawLine(root[0], root[1], neck[0], neck[1])
 
         if count > 1:
             # Draw shoulder-to-shoulder line
 
         if count > 1:
             # Draw shoulder-to-shoulder line
-            dc.DrawLine(shoulder1, shoulder2)
+            dc.DrawLine(shoulder1[0], shoulder1[1], shoulder2[0], shoulder2[1])
         # Draw all the little branches
         for i in range(count):
             pt, stemPt = self.GetBranchingAttachmentPoint(attachment, i)
         # Draw all the little branches
         for i in range(count):
             pt, stemPt = self.GetBranchingAttachmentPoint(attachment, i)
-            dc.DrawLine(stemPt, pt)
+            dc.DrawLine(stemPt[0], stemPt[1], pt[0], pt[1])
 
             if self.GetBranchStyle() & BRANCHING_ATTACHMENT_BLOB and count > 1:
                 blobSize = 6.0
 
             if self.GetBranchStyle() & BRANCHING_ATTACHMENT_BLOB and count > 1:
                 blobSize = 6.0
@@ -2161,7 +2178,7 @@ class Shape(ShapeEvtHandler):
         dc.SetLogicalFunction(OGLRBLF)
 
         bound_x, bound_y = self.GetBoundingBoxMin()
         dc.SetLogicalFunction(OGLRBLF)
 
         bound_x, bound_y = self.GetBoundingBoxMin()
-        self.GetEventHandler().OnEndSize(bound_x, bound_y)
+        self.GetEventHandler().OnBeginSize(bound_x, bound_y)
 
         # Choose the 'opposite corner' of the object as the stationary
         # point in case this is non-centring resizing.
 
         # Choose the 'opposite corner' of the object as the stationary
         # point in case this is non-centring resizing.
@@ -2227,7 +2244,7 @@ class Shape(ShapeEvtHandler):
             elif pt._type == CONTROL_POINT_VERTICAL:
                 newX1 = pt._controlPointDragStartX
                 newX2 = newX1 + pt._controlPointDragStartWidth
             elif pt._type == CONTROL_POINT_VERTICAL:
                 newX1 = pt._controlPointDragStartX
                 newX2 = newX1 + pt._controlPointDragStartWidth
-            elif pt._type == CONTROL_POINT_DIAGONAL and (keys & KEYS or self.GetMaintainAspectRatio()):
+            elif pt._type == CONTROL_POINT_DIAGONAL and (keys & KEY_SHIFT or self.GetMaintainAspectRatio()):
                 newH = (newX2 - newX1) * (float(pt._controlPointDragStartHeight) / pt._controlPointDragStartWidth)
                 if pt.GetY() > pt._controlPointDragStartY:
                     newY2 = newY1 + newH
                 newH = (newX2 - newX1) * (float(pt._controlPointDragStartHeight) / pt._controlPointDragStartWidth)
                 if pt.GetY() > pt._controlPointDragStartY:
                     newY2 = newY1 + newH
@@ -3030,7 +3047,7 @@ class ShapeRegion(object):
             return None
         if self._penColour=="Invisible":
             return None
             return None
         if self._penColour=="Invisible":
             return None
-        self._actualPenObject = wx.ThePenList.FindOrCreatePen(self._penColour, 1, self._penStyle)
+        self._actualPenObject = wx.Pen(self._penColour, 1, self._penStyle)
         return self._actualPenObject
 
     def SetText(self, s):
         return self._actualPenObject
 
     def SetText(self, s):