2003-12-08 20:23:28 -05: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
|
|
|
|
|
2001-11-30 16:16:36 -05:00
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
2003-12-08 20:23:28 -05: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 16:16:36 -05:00
|
|
|
|
|
|
|
# make an image list
|
2001-11-30 18:18:30 -05:00
|
|
|
im1 = im2 = -1
|
2003-12-08 20:23:28 -05:00
|
|
|
self.il = wx.ImageList(16, 16)
|
2005-05-24 16:55:42 -04:00
|
|
|
im1 = self.il.Add(wx.ArtProvider.GetBitmap(wx.ART_FOLDER, wx.ART_TOOLBAR, (16,16)))
|
|
|
|
im2 = self.il.Add(wx.ArtProvider.GetBitmap(wx.ART_NORMAL_FILE, wx.ART_TOOLBAR, (16,16)))
|
2001-12-03 15:41:03 -05:00
|
|
|
self.SetImageList(self.il)
|
2001-11-30 16:16:36 -05:00
|
|
|
|
|
|
|
# Add some items
|
|
|
|
root = self.AddRoot("Root")
|
2003-12-08 20:23:28 -05:00
|
|
|
|
2001-11-30 16:16:36 -05:00
|
|
|
for i in range(30):
|
|
|
|
item = self.AppendItem(root, "Item %d" % i, im1)
|
2003-12-08 20:23:28 -05:00
|
|
|
|
2001-11-30 16:16:36 -05:00
|
|
|
for j in range(10):
|
2001-12-03 15:41:03 -05:00
|
|
|
child = self.AppendItem(item, "Child %d" % j, im2)
|
2001-11-30 16:16:36 -05:00
|
|
|
|
|
|
|
self.Expand(root)
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
class TestValueWindow(gizmos.TreeCompanionWindow):
|
|
|
|
def __init__(self, parent, style=0):
|
|
|
|
gizmos.TreeCompanionWindow.__init__(self, parent, -1, style=style)
|
2001-11-30 16:16:36 -05:00
|
|
|
self.SetBackgroundColour("WHITE")
|
|
|
|
|
|
|
|
# This method is called to draw each item in the value window
|
|
|
|
def DrawItem(self, dc, itemId, rect):
|
|
|
|
tree = self.GetTreeCtrl()
|
2003-12-08 20:23:28 -05:00
|
|
|
|
2001-11-30 16:16:36 -05:00
|
|
|
if tree:
|
|
|
|
text = "This is "
|
|
|
|
parent = tree.GetItemParent(itemId)
|
2003-12-08 20:23:28 -05:00
|
|
|
|
2001-11-30 16:16:36 -05:00
|
|
|
if parent.IsOk():
|
|
|
|
ptext = tree.GetItemText(parent)
|
|
|
|
text = text + ptext + " --> "
|
2003-12-08 20:23:28 -05:00
|
|
|
|
2001-11-30 16:16:36 -05:00
|
|
|
text = text + tree.GetItemText(itemId)
|
2003-12-08 20:23:28 -05:00
|
|
|
pen = wx.Pen(
|
2004-01-20 18:26:57 -05:00
|
|
|
wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DLIGHT),
|
2003-12-08 20:23:28 -05:00
|
|
|
1, wx.SOLID
|
|
|
|
)
|
|
|
|
|
2001-12-03 15:41:03 -05:00
|
|
|
dc.SetPen(pen)
|
2003-12-08 20:23:28 -05:00
|
|
|
dc.SetBrush(wx.Brush(self.GetBackgroundColour(), wx.SOLID))
|
2004-05-01 22:41:33 -04:00
|
|
|
dc.DrawRectangle(rect.x, rect.y, rect.width+1, rect.height+1)
|
2001-11-30 16:16:36 -05:00
|
|
|
dc.SetTextForeground("BLACK")
|
2003-12-08 20:23:28 -05:00
|
|
|
dc.SetBackgroundMode(wx.TRANSPARENT)
|
2001-11-30 16:16:36 -05:00
|
|
|
tw, th = dc.GetTextExtent(text)
|
|
|
|
x = 5
|
|
|
|
y = rect.y + max(0, (rect.height - th) / 2)
|
2004-05-01 22:41:33 -04:00
|
|
|
dc.DrawText(text, x, y)
|
2001-11-30 16:16:36 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
class TestPanel(wx.Panel):
|
2001-11-30 16:16:36 -05:00
|
|
|
def __init__(self, parent, log):
|
2005-04-22 19:30:03 -04:00
|
|
|
wx.Panel.__init__(self, parent, -1, size=(640,480))
|
2001-11-30 16:16:36 -05:00
|
|
|
self.log = log
|
|
|
|
|
2003-12-08 20:23:28 -05: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 16:16:36 -05:00
|
|
|
splitter.SetSashSize(2)
|
2004-01-20 18:26:57 -05: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-08 20:23:28 -05:00
|
|
|
|
|
|
|
valueWindow = TestValueWindow(splitter, style=wx.NO_BORDER)
|
2001-11-30 16:16:36 -05:00
|
|
|
|
2005-04-22 10:30:03 -04:00
|
|
|
wx.CallAfter(splitter.SplitVertically, tree, valueWindow, 150)
|
2001-12-10 16:20:48 -05:00
|
|
|
scroller.SetTargetWindow(tree)
|
2003-03-25 01:35:27 -05:00
|
|
|
scroller.EnableScrolling(False, False)
|
2001-11-30 16:16:36 -05:00
|
|
|
|
2001-12-10 16:20:48 -05:00
|
|
|
valueWindow.SetTreeCtrl(tree)
|
|
|
|
tree.SetCompanionWindow(valueWindow)
|
2001-11-30 16:16:36 -05:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
sizer = wx.BoxSizer(wx.VERTICAL)
|
|
|
|
sizer.Add(scroller, 1, wx.EXPAND|wx.ALL, 25)
|
2002-01-14 23:54:19 -05:00
|
|
|
self.SetSizer(sizer)
|
2005-04-22 19:30:03 -04:00
|
|
|
self.Layout()
|
2001-11-30 16:16:36 -05:00
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def runTest(frame, nb, log):
|
2003-12-08 20:23:28 -05:00
|
|
|
if wx.Platform == "__WXMAC__":
|
2004-11-01 14:39:09 -05:00
|
|
|
from Main import MessagePanel
|
|
|
|
win = MessagePanel(nb, 'This demo currently fails on the Mac. The problem is being looked into...',
|
|
|
|
'Sorry', wx.ICON_WARNING)
|
|
|
|
return win
|
2003-03-25 01:35:27 -05:00
|
|
|
|
2001-11-30 16:16:36 -05: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-08 20:23:28 -05:00
|
|
|
item. The classes are wx.RemotelyScrolledTreeCtrl, wx.TreeCompanionWindow,
|
|
|
|
wx.ThinSplitterWindow, and wx.SplitterScrolledWindow, some of which may
|
2001-11-30 16:16:36 -05:00
|
|
|
also be useful by themselves.
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
2002-07-11 16:41:21 -04:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
import sys,os
|
|
|
|
import run
|
2004-03-04 19:06:33 -05:00
|
|
|
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|
2002-07-11 16:41:21 -04:00
|
|
|
|