2003-12-09 01:23:28 +00:00
|
|
|
# 11/13/2003 - Jeff Grimmett (grimmtooth@softhome.net)
|
|
|
|
#
|
|
|
|
# o Updated for wx namespace
|
|
|
|
#
|
|
|
|
# 11/26/2003 - Jeff Grimmett (grimmtooth@softhome.net)
|
|
|
|
#
|
|
|
|
# o Bigtime errors on startup. Blows up with a program error.
|
|
|
|
# Error:
|
|
|
|
#
|
|
|
|
# 21:04:11: Debug: ..\..\src\msw\treectrl.cpp(1508): assert "IsVisible(item)"
|
|
|
|
# failed: The item you call GetNextVisible() for must be visible itself!
|
|
|
|
#
|
|
|
|
# I suspect this error is in the lib itself.
|
|
|
|
#
|
|
|
|
|
|
|
|
import wx
|
|
|
|
import wx.gizmos as gizmos
|
|
|
|
|
|
|
|
import images
|
2001-11-30 21:16:36 +00:00
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
class TestTree(gizmos.RemotelyScrolledTreeCtrl):
|
|
|
|
def __init__(self, parent, style=wx.TR_HAS_BUTTONS):
|
|
|
|
gizmos.RemotelyScrolledTreeCtrl.__init__(self, parent, -1, style=style)
|
2001-11-30 21:16:36 +00:00
|
|
|
|
|
|
|
# make an image list
|
2001-11-30 23:18:30 +00:00
|
|
|
im1 = im2 = -1
|
2003-12-09 01:23:28 +00:00
|
|
|
self.il = wx.ImageList(16, 16)
|
2001-12-03 20:41:03 +00:00
|
|
|
im1 = self.il.Add(images.getFolder1Bitmap())
|
|
|
|
im2 = self.il.Add(images.getFile1Bitmap())
|
|
|
|
self.SetImageList(self.il)
|
2001-11-30 21:16:36 +00:00
|
|
|
|
|
|
|
# Add some items
|
|
|
|
root = self.AddRoot("Root")
|
2003-12-09 01:23:28 +00:00
|
|
|
|
2001-11-30 21:16:36 +00:00
|
|
|
for i in range(30):
|
|
|
|
item = self.AppendItem(root, "Item %d" % i, im1)
|
2003-12-09 01:23:28 +00:00
|
|
|
|
2001-11-30 21:16:36 +00:00
|
|
|
for j in range(10):
|
2001-12-03 20:41:03 +00:00
|
|
|
child = self.AppendItem(item, "Child %d" % j, im2)
|
2001-11-30 21:16:36 +00:00
|
|
|
|
|
|
|
self.Expand(root)
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
class TestValueWindow(gizmos.TreeCompanionWindow):
|
|
|
|
def __init__(self, parent, style=0):
|
|
|
|
gizmos.TreeCompanionWindow.__init__(self, parent, -1, style=style)
|
2001-11-30 21:16:36 +00:00
|
|
|
self.SetBackgroundColour("WHITE")
|
2003-12-09 01:23:28 +00:00
|
|
|
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OEB)
|
2001-12-03 20:41:03 +00:00
|
|
|
|
|
|
|
def OEB(self, evt):
|
|
|
|
pass
|
2001-11-30 21:16:36 +00:00
|
|
|
|
|
|
|
# This method is called to draw each item in the value window
|
|
|
|
def DrawItem(self, dc, itemId, rect):
|
|
|
|
tree = self.GetTreeCtrl()
|
2003-12-09 01:23:28 +00:00
|
|
|
|
2001-11-30 21:16:36 +00:00
|
|
|
if tree:
|
|
|
|
text = "This is "
|
|
|
|
parent = tree.GetItemParent(itemId)
|
2003-12-09 01:23:28 +00:00
|
|
|
|
2001-11-30 21:16:36 +00:00
|
|
|
if parent.IsOk():
|
|
|
|
ptext = tree.GetItemText(parent)
|
|
|
|
text = text + ptext + " --> "
|
2003-12-09 01:23:28 +00:00
|
|
|
|
2001-11-30 21:16:36 +00:00
|
|
|
text = text + tree.GetItemText(itemId)
|
2003-12-09 01:23:28 +00:00
|
|
|
pen = wx.Pen(
|
2004-01-20 23:26:57 +00:00
|
|
|
wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DLIGHT),
|
2003-12-09 01:23:28 +00:00
|
|
|
1, wx.SOLID
|
|
|
|
)
|
|
|
|
|
2001-12-03 20:41:03 +00:00
|
|
|
dc.SetPen(pen)
|
2003-12-09 01:23:28 +00:00
|
|
|
dc.SetBrush(wx.Brush(self.GetBackgroundColour(), wx.SOLID))
|
|
|
|
dc.DrawRectangle((rect.x, rect.y), (rect.width+1, rect.height+1))
|
2001-11-30 21:16:36 +00:00
|
|
|
dc.SetTextForeground("BLACK")
|
2003-12-09 01:23:28 +00:00
|
|
|
dc.SetBackgroundMode(wx.TRANSPARENT)
|
2001-11-30 21:16:36 +00:00
|
|
|
tw, th = dc.GetTextExtent(text)
|
|
|
|
x = 5
|
|
|
|
y = rect.y + max(0, (rect.height - th) / 2)
|
2003-12-09 01:23:28 +00:00
|
|
|
dc.DrawText(text, (x, y))
|
2001-11-30 21:16:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
class TestPanel(wx.Panel):
|
2001-11-30 21:16:36 +00:00
|
|
|
def __init__(self, parent, log):
|
2003-12-09 01:23:28 +00:00
|
|
|
wx.Panel.__init__(self, parent, -1)
|
2001-11-30 21:16:36 +00:00
|
|
|
self.log = log
|
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
scroller = gizmos.SplitterScrolledWindow(
|
|
|
|
self, -1, style=wx.NO_BORDER | wx.CLIP_CHILDREN | wx.VSCROLL
|
|
|
|
)
|
|
|
|
|
|
|
|
splitter = gizmos.ThinSplitterWindow(
|
|
|
|
scroller, -1, style=wx.SP_3DBORDER | wx.CLIP_CHILDREN
|
|
|
|
)
|
|
|
|
|
2001-11-30 21:16:36 +00:00
|
|
|
splitter.SetSashSize(2)
|
2004-01-20 23:26:57 +00:00
|
|
|
tree = TestTree(splitter, style = wx.TR_HAS_BUTTONS |
|
|
|
|
wx.TR_NO_LINES |
|
|
|
|
wx.TR_ROW_LINES |
|
|
|
|
#wx.TR_HIDE_ROOT |
|
|
|
|
wx.NO_BORDER )
|
2003-12-09 01:23:28 +00:00
|
|
|
|
|
|
|
valueWindow = TestValueWindow(splitter, style=wx.NO_BORDER)
|
2001-11-30 21:16:36 +00:00
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
splitter.SplitVertically(tree, valueWindow, 150)
|
2001-12-10 21:20:48 +00:00
|
|
|
scroller.SetTargetWindow(tree)
|
2003-03-25 06:35:27 +00:00
|
|
|
scroller.EnableScrolling(False, False)
|
2001-11-30 21:16:36 +00:00
|
|
|
|
2001-12-10 21:20:48 +00:00
|
|
|
valueWindow.SetTreeCtrl(tree)
|
|
|
|
tree.SetCompanionWindow(valueWindow)
|
2001-11-30 21:16:36 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
sizer = wx.BoxSizer(wx.VERTICAL)
|
|
|
|
sizer.Add(scroller, 1, wx.EXPAND|wx.ALL, 25)
|
2003-03-25 06:35:27 +00:00
|
|
|
self.SetAutoLayout(True)
|
2002-01-15 04:54:19 +00:00
|
|
|
self.SetSizer(sizer)
|
2001-11-30 21:16:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def runTest(frame, nb, log):
|
2003-12-09 01:23:28 +00:00
|
|
|
if wx.Platform == "__WXMAC__":
|
|
|
|
wx.MessageBox("This demo currently fails on the Mac. The problem is being looked into...", "Sorry")
|
2003-03-25 06:35:27 +00:00
|
|
|
return
|
|
|
|
|
2001-11-30 21:16:36 +00:00
|
|
|
win = TestPanel(nb, log)
|
|
|
|
return win
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
overview = """\
|
|
|
|
This demo shows a collection of classes that were designed to operate
|
|
|
|
together and provide a tree control with additional columns for each
|
2003-12-09 01:23:28 +00:00
|
|
|
item. The classes are wx.RemotelyScrolledTreeCtrl, wx.TreeCompanionWindow,
|
|
|
|
wx.ThinSplitterWindow, and wx.SplitterScrolledWindow, some of which may
|
2001-11-30 21:16:36 +00:00
|
|
|
also be useful by themselves.
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
2002-07-11 20:41:21 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
import sys,os
|
|
|
|
import run
|
2004-03-05 00:06:33 +00:00
|
|
|
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|
2002-07-11 20:41:21 +00:00
|
|
|
|