Various small fixes and tweaks
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4775 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
		@@ -60,6 +60,8 @@ Added wxPython.lib.spashscreen from Mike Fletcher.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
Added wxPython.lib.filebrowsebutton also from Mike Fletcher.
 | 
					Added wxPython.lib.filebrowsebutton also from Mike Fletcher.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Renamed wxTreeCtrl.GetParent to GetItemParent to avoid a name clash
 | 
				
			||||||
 | 
					with wxWindow.GetParent.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
from wxPython.wx import *
 | 
					from wxPython.wx import *
 | 
				
			||||||
from wxPython.lib.filebrowsebtn import FileBrowseButton
 | 
					from wxPython.lib.filebrowsebutton import FileBrowseButton
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#----------------------------------------------------------------------
 | 
					#----------------------------------------------------------------------
 | 
				
			||||||
 
 | 
				
			|||||||
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 89 KiB  | 
@@ -13,7 +13,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
In this module you will find wxGridSizer and wxFlexgridSizer.
 | 
					In this module you will find wxGridSizer and wxFlexGridSizer.
 | 
				
			||||||
wxGridSizer arrainges its items in a grid in which all the widths and
 | 
					wxGridSizer arrainges its items in a grid in which all the widths and
 | 
				
			||||||
heights are the same.  wxFlexgridSizer allows different widths and
 | 
					heights are the same.  wxFlexgridSizer allows different widths and
 | 
				
			||||||
heights, and you can also specify rows and/or columns that are
 | 
					heights, and you can also specify rows and/or columns that are
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -90,7 +90,7 @@ class LayoutEngine:
 | 
				
			|||||||
    """
 | 
					    """
 | 
				
			||||||
    def __init__(self, tree):
 | 
					    def __init__(self, tree):
 | 
				
			||||||
        self.tree = tree
 | 
					        self.tree = tree
 | 
				
			||||||
    def layout(self, node):
 | 
					    def Layout(self, node):
 | 
				
			||||||
        raise NotImplementedError
 | 
					        raise NotImplementedError
 | 
				
			||||||
    def GetNodeList(self):
 | 
					    def GetNodeList(self):
 | 
				
			||||||
        raise NotImplementedError
 | 
					        raise NotImplementedError
 | 
				
			||||||
@@ -101,7 +101,7 @@ class Transform:
 | 
				
			|||||||
    """
 | 
					    """
 | 
				
			||||||
    def __init__(self, tree):
 | 
					    def __init__(self, tree):
 | 
				
			||||||
        self.tree = tree
 | 
					        self.tree = tree
 | 
				
			||||||
    def transform(self, node, offset, rotation):
 | 
					    def Transform(self, node, offset, rotation):
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        This method should only change the projx and projy attributes of
 | 
					        This method should only change the projx and projy attributes of
 | 
				
			||||||
        the node. These represent the position of the node as it should
 | 
					        the node. These represent the position of the node as it should
 | 
				
			||||||
@@ -141,7 +141,7 @@ class Painter:
 | 
				
			|||||||
        return self.bmp
 | 
					        return self.bmp
 | 
				
			||||||
    def ClearBuffer(self):
 | 
					    def ClearBuffer(self):
 | 
				
			||||||
        self.bmp = None
 | 
					        self.bmp = None
 | 
				
			||||||
    def paint(self, dc, node, doubleBuffered=1, paintBackground=1):
 | 
					    def Paint(self, dc, node, doubleBuffered=1, paintBackground=1):
 | 
				
			||||||
        raise NotImplementedError
 | 
					        raise NotImplementedError
 | 
				
			||||||
    def GetTextColour(self):
 | 
					    def GetTextColour(self):
 | 
				
			||||||
        return self.textcolor
 | 
					        return self.textcolor
 | 
				
			||||||
@@ -187,18 +187,18 @@ class Painter:
 | 
				
			|||||||
        if evt.LeftDClick():
 | 
					        if evt.LeftDClick():
 | 
				
			||||||
            x, y = self.tree.CalcUnscrolledPosition(evt.GetX(), evt.GetY())
 | 
					            x, y = self.tree.CalcUnscrolledPosition(evt.GetX(), evt.GetY())
 | 
				
			||||||
            for item in self.rectangles:
 | 
					            for item in self.rectangles:
 | 
				
			||||||
                if item[1].contains((x,y)):
 | 
					                if item[1].Contains((x,y)):
 | 
				
			||||||
                    self.tree.Edit(item[0].data)
 | 
					                    self.tree.Edit(item[0].data)
 | 
				
			||||||
                    self.tree.OnNodeClick(item[0], evt)
 | 
					                    self.tree.OnNodeClick(item[0], evt)
 | 
				
			||||||
                    return
 | 
					                    return
 | 
				
			||||||
        elif evt.ButtonDown():
 | 
					        elif evt.ButtonDown():
 | 
				
			||||||
            x, y = self.tree.CalcUnscrolledPosition(evt.GetX(), evt.GetY())
 | 
					            x, y = self.tree.CalcUnscrolledPosition(evt.GetX(), evt.GetY())
 | 
				
			||||||
            for item in self.rectangles:
 | 
					            for item in self.rectangles:
 | 
				
			||||||
                if item[1].contains((x, y)):
 | 
					                if item[1].Contains((x, y)):
 | 
				
			||||||
                    self.tree.OnNodeClick(item[0], evt)
 | 
					                    self.tree.OnNodeClick(item[0], evt)
 | 
				
			||||||
                    return
 | 
					                    return
 | 
				
			||||||
            for item in self.knobs:
 | 
					            for item in self.knobs:
 | 
				
			||||||
                if item[1].contains((x, y)):
 | 
					                if item[1].Contains((x, y)):
 | 
				
			||||||
                    self.tree.OnKnobClick(item[0])
 | 
					                    self.tree.OnKnobClick(item[0])
 | 
				
			||||||
                    return
 | 
					                    return
 | 
				
			||||||
        evt.Skip()
 | 
					        evt.Skip()
 | 
				
			||||||
@@ -242,7 +242,7 @@ class NodePainter:
 | 
				
			|||||||
    """
 | 
					    """
 | 
				
			||||||
    def __init__(self, painter):
 | 
					    def __init__(self, painter):
 | 
				
			||||||
        self.painter = painter
 | 
					        self.painter = painter
 | 
				
			||||||
    def paint(self, node, dc, location = None):
 | 
					    def Paint(self, node, dc, location = None):
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        location should be provided only to draw in an unusual position
 | 
					        location should be provided only to draw in an unusual position
 | 
				
			||||||
        (not the node's normal position), otherwise the node's projected x and y
 | 
					        (not the node's normal position), otherwise the node's projected x and y
 | 
				
			||||||
@@ -256,7 +256,7 @@ class LinePainter:
 | 
				
			|||||||
    """
 | 
					    """
 | 
				
			||||||
    def __init__(self, painter):
 | 
					    def __init__(self, painter):
 | 
				
			||||||
        self.painter = painter
 | 
					        self.painter = painter
 | 
				
			||||||
    def paint(self, parent, child, dc):
 | 
					    def Paint(self, parent, child, dc):
 | 
				
			||||||
        raise NotImplementedError
 | 
					        raise NotImplementedError
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class TextConverter:
 | 
					class TextConverter:
 | 
				
			||||||
@@ -265,7 +265,7 @@ class TextConverter:
 | 
				
			|||||||
    """
 | 
					    """
 | 
				
			||||||
    def __init__(self, painter):
 | 
					    def __init__(self, painter):
 | 
				
			||||||
        self.painter = painter
 | 
					        self.painter = painter
 | 
				
			||||||
    def convert(node):
 | 
					    def Convert(node):
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        Should return a string. The node argument will be an
 | 
					        Should return a string. The node argument will be an
 | 
				
			||||||
        MVCTreeNode.
 | 
					        MVCTreeNode.
 | 
				
			||||||
@@ -450,14 +450,14 @@ class LateFSTreeModel(FSTreeModel):
 | 
				
			|||||||
        return not os.path.isdir(node.path + os.sep + node.fileName)
 | 
					        return not os.path.isdir(node.path + os.sep + node.fileName)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class StrTextConverter(TextConverter):
 | 
					class StrTextConverter(TextConverter):
 | 
				
			||||||
    def convert(self, node):
 | 
					    def Convert(self, node):
 | 
				
			||||||
        return str(node.data)
 | 
					        return str(node.data)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class NullTransform(Transform):
 | 
					class NullTransform(Transform):
 | 
				
			||||||
    def GetSize(self):
 | 
					    def GetSize(self):
 | 
				
			||||||
        return tuple(self.size)
 | 
					        return tuple(self.size)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def transform(self, node, offset, rotation):
 | 
					    def Transform(self, node, offset, rotation):
 | 
				
			||||||
        self.size = [0,0]
 | 
					        self.size = [0,0]
 | 
				
			||||||
        list = self.tree.GetLayoutEngine().GetNodeList()
 | 
					        list = self.tree.GetLayoutEngine().GetNodeList()
 | 
				
			||||||
        for node in list:
 | 
					        for node in list:
 | 
				
			||||||
@@ -481,7 +481,7 @@ class Rect:
 | 
				
			|||||||
        name = ['x', 'y', 'width', 'height'][index]
 | 
					        name = ['x', 'y', 'width', 'height'][index]
 | 
				
			||||||
        setattr(self, name, value)
 | 
					        setattr(self, name, value)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def contains(self, other):
 | 
					    def Contains(self, other):
 | 
				
			||||||
        if type(other) == type(()):
 | 
					        if type(other) == type(()):
 | 
				
			||||||
            other = Rect(other[0], other[1], 0, 0)
 | 
					            other = Rect(other[0], other[1], 0, 0)
 | 
				
			||||||
        if other.x >= self.x:
 | 
					        if other.x >= self.x:
 | 
				
			||||||
@@ -504,7 +504,7 @@ class TreeLayout(LayoutEngine):
 | 
				
			|||||||
        self.NODE_HEIGHT = 20
 | 
					        self.NODE_HEIGHT = 20
 | 
				
			||||||
        self.nodelist = []
 | 
					        self.nodelist = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def layout(self, node):
 | 
					    def Layout(self, node):
 | 
				
			||||||
        self.nodelist = []
 | 
					        self.nodelist = []
 | 
				
			||||||
        self.NODE_HEIGHT = self.tree.GetFont().GetPointSize() * 2
 | 
					        self.NODE_HEIGHT = self.tree.GetFont().GetPointSize() * 2
 | 
				
			||||||
        self.layoutwalk(node)
 | 
					        self.layoutwalk(node)
 | 
				
			||||||
@@ -543,7 +543,7 @@ class TreePainter(Painter):
 | 
				
			|||||||
        self.textConverter = textConverter
 | 
					        self.textConverter = textConverter
 | 
				
			||||||
        self.charWidths = []
 | 
					        self.charWidths = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def paint(self, dc, node, doubleBuffered=1, paintBackground=1):
 | 
					    def Paint(self, dc, node, doubleBuffered=1, paintBackground=1):
 | 
				
			||||||
        if not self.charWidths:
 | 
					        if not self.charWidths:
 | 
				
			||||||
            self.charWidths = []
 | 
					            self.charWidths = []
 | 
				
			||||||
            for i in range(25):
 | 
					            for i in range(25):
 | 
				
			||||||
@@ -603,8 +603,8 @@ class TreePainter(Painter):
 | 
				
			|||||||
        self.dashpen = wxPen(pen.GetColour(), 1, wxDOT)
 | 
					        self.dashpen = wxPen(pen.GetColour(), 1, wxDOT)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def paintWalk(self, node, dc, paintRects=0):
 | 
					    def paintWalk(self, node, dc, paintRects=0):
 | 
				
			||||||
        self.linePainter.paint(node.parent, node, dc)
 | 
					        self.linePainter.Paint(node.parent, node, dc)
 | 
				
			||||||
        self.nodePainter.paint(node, dc, drawRects = paintRects)
 | 
					        self.nodePainter.Paint(node, dc, drawRects = paintRects)
 | 
				
			||||||
        if node.expanded:
 | 
					        if node.expanded:
 | 
				
			||||||
            for kid in node.kids:
 | 
					            for kid in node.kids:
 | 
				
			||||||
                if not self.paintWalk(kid, dc, paintRects):
 | 
					                if not self.paintWalk(kid, dc, paintRects):
 | 
				
			||||||
@@ -638,8 +638,8 @@ class TreePainter(Painter):
 | 
				
			|||||||
        Painter.OnMouse(self, evt)
 | 
					        Painter.OnMouse(self, evt)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class TreeNodePainter(NodePainter):
 | 
					class TreeNodePainter(NodePainter):
 | 
				
			||||||
    def paint(self, node, dc, location = None, drawRects = 0):
 | 
					    def Paint(self, node, dc, location = None, drawRects = 0):
 | 
				
			||||||
        text = self.painter.textConverter.convert(node)
 | 
					        text = self.painter.textConverter.Convert(node)
 | 
				
			||||||
        extent = dc.GetTextExtent(text)
 | 
					        extent = dc.GetTextExtent(text)
 | 
				
			||||||
        node.width = extent[0]
 | 
					        node.width = extent[0]
 | 
				
			||||||
        node.height = extent[1]
 | 
					        node.height = extent[1]
 | 
				
			||||||
@@ -658,7 +658,7 @@ class TreeNodePainter(NodePainter):
 | 
				
			|||||||
        self.painter.rectangles.append((node, Rect(node.projx, node.projy, node.width, node.height)))
 | 
					        self.painter.rectangles.append((node, Rect(node.projx, node.projy, node.width, node.height)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class TreeLinePainter(LinePainter):
 | 
					class TreeLinePainter(LinePainter):
 | 
				
			||||||
    def paint(self, parent, child, dc):
 | 
					    def Paint(self, parent, child, dc):
 | 
				
			||||||
        dc.SetPen(self.painter.GetDashPen())
 | 
					        dc.SetPen(self.painter.GetDashPen())
 | 
				
			||||||
        px = py = cx = cy = 0
 | 
					        px = py = cx = cy = 0
 | 
				
			||||||
        if parent is None or child == self.painter.tree.currentRoot:
 | 
					        if parent is None or child == self.painter.tree.currentRoot:
 | 
				
			||||||
@@ -836,7 +836,7 @@ class wxMVCTree(wxScrolledWindow):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def GetDisplayText(self, node):
 | 
					    def GetDisplayText(self, node):
 | 
				
			||||||
        treenode = self.nodemap[node]
 | 
					        treenode = self.nodemap[node]
 | 
				
			||||||
        return self.painter.textConverter.convert(treenode)
 | 
					        return self.painter.textConverter.Convert(treenode)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def IsDoubleBuffered(self):
 | 
					    def IsDoubleBuffered(self):
 | 
				
			||||||
        return self.doubleBuffered
 | 
					        return self.doubleBuffered
 | 
				
			||||||
@@ -975,8 +975,8 @@ class wxMVCTree(wxScrolledWindow):
 | 
				
			|||||||
        else:
 | 
					        else:
 | 
				
			||||||
            e = wxMVCTreeEvent(wxEVT_MVCTREE_ITEM_COLLAPSED, self.GetId(), node)
 | 
					            e = wxMVCTreeEvent(wxEVT_MVCTREE_ITEM_COLLAPSED, self.GetId(), node)
 | 
				
			||||||
        self.GetEventHandler().ProcessEvent(e)
 | 
					        self.GetEventHandler().ProcessEvent(e)
 | 
				
			||||||
        self.layout.layout(self.currentRoot)
 | 
					        self.layout.Layout(self.currentRoot)
 | 
				
			||||||
        self.transform.transform(self.currentRoot, self.offset, self.rotation)
 | 
					        self.transform.Transform(self.currentRoot, self.offset, self.rotation)
 | 
				
			||||||
        self.Refresh()
 | 
					        self.Refresh()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def IsExpanded(self, node):
 | 
					    def IsExpanded(self, node):
 | 
				
			||||||
@@ -1033,7 +1033,7 @@ class wxMVCTree(wxScrolledWindow):
 | 
				
			|||||||
        self.PrepareDC(dc)
 | 
					        self.PrepareDC(dc)
 | 
				
			||||||
        for node in changeparents:
 | 
					        for node in changeparents:
 | 
				
			||||||
            if node:
 | 
					            if node:
 | 
				
			||||||
                self.painter.paint(dc, node, doubleBuffered = 0, paintBackground = 0)
 | 
					                self.painter.Paint(dc, node, doubleBuffered = 0, paintBackground = 0)
 | 
				
			||||||
        self.painter.ClearBuffer()
 | 
					        self.painter.ClearBuffer()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def RemoveFromSelection(self, nodeTuple):
 | 
					    def RemoveFromSelection(self, nodeTuple):
 | 
				
			||||||
@@ -1051,7 +1051,7 @@ class wxMVCTree(wxScrolledWindow):
 | 
				
			|||||||
        self.PrepareDC(dc)
 | 
					        self.PrepareDC(dc)
 | 
				
			||||||
        for node in changeparents:
 | 
					        for node in changeparents:
 | 
				
			||||||
            if node:
 | 
					            if node:
 | 
				
			||||||
                self.painter.paint(dc, node, doubleBuffered = 0, paintBackground = 0)
 | 
					                self.painter.Paint(dc, node, doubleBuffered = 0, paintBackground = 0)
 | 
				
			||||||
        self.painter.ClearBuffer()
 | 
					        self.painter.ClearBuffer()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1090,11 +1090,11 @@ class wxMVCTree(wxScrolledWindow):
 | 
				
			|||||||
        try:
 | 
					        try:
 | 
				
			||||||
            self.EnableScrolling(false, false)
 | 
					            self.EnableScrolling(false, false)
 | 
				
			||||||
            if not self.laidOut:
 | 
					            if not self.laidOut:
 | 
				
			||||||
                self.layout.layout(self.currentRoot)
 | 
					                self.layout.Layout(self.currentRoot)
 | 
				
			||||||
                self.laidOut = true
 | 
					                self.laidOut = true
 | 
				
			||||||
                self.transformed = false
 | 
					                self.transformed = false
 | 
				
			||||||
            if not self.transformed:
 | 
					            if not self.transformed:
 | 
				
			||||||
                self.transform.transform(self.currentRoot, self.offset, self.rotation)
 | 
					                self.transform.Transform(self.currentRoot, self.offset, self.rotation)
 | 
				
			||||||
                self.transformed = true
 | 
					                self.transformed = true
 | 
				
			||||||
            tsize = None
 | 
					            tsize = None
 | 
				
			||||||
            tsize = list(self.transform.GetSize())
 | 
					            tsize = list(self.transform.GetSize())
 | 
				
			||||||
@@ -1111,7 +1111,7 @@ class wxMVCTree(wxScrolledWindow):
 | 
				
			|||||||
            dc = wxPaintDC(self)
 | 
					            dc = wxPaintDC(self)
 | 
				
			||||||
            self.PrepareDC(dc)
 | 
					            self.PrepareDC(dc)
 | 
				
			||||||
            dc.SetFont(self.GetFont())
 | 
					            dc.SetFont(self.GetFont())
 | 
				
			||||||
            self.painter.paint(dc, self.currentRoot, self.doubleBuffered)
 | 
					            self.painter.Paint(dc, self.currentRoot, self.doubleBuffered)
 | 
				
			||||||
        except:
 | 
					        except:
 | 
				
			||||||
            traceback.print_exc()
 | 
					            traceback.print_exc()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user