1999-04-29 23:29:54 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
import wx
|
1999-04-29 23:29:54 -04:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
class TestSashWindow(wx.Panel):
|
1999-04-29 23:29:54 -04:00
|
|
|
ID_WINDOW_TOP = 5100
|
|
|
|
ID_WINDOW_LEFT1 = 5101
|
|
|
|
ID_WINDOW_LEFT2 = 5102
|
|
|
|
ID_WINDOW_BOTTOM = 5103
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, parent, log):
|
2003-12-08 20:23:28 -05:00
|
|
|
wx.Panel.__init__(self, parent, -1)
|
1999-04-29 23:29:54 -04:00
|
|
|
|
|
|
|
self.log = log
|
|
|
|
|
2001-02-16 03:19:50 -05:00
|
|
|
# will occupy the space not used by the Layout Algorithm
|
2003-12-08 20:23:28 -05:00
|
|
|
self.remainingSpace = wx.Panel(self, -1, style=wx.SUNKEN_BORDER)
|
2000-12-10 03:37:52 -05:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
self.Bind(
|
|
|
|
wx.EVT_SASH_DRAGGED_RANGE, self.OnSashDrag,
|
|
|
|
id=self.ID_WINDOW_TOP, id2=self.ID_WINDOW_BOTTOM,
|
|
|
|
)
|
|
|
|
|
|
|
|
self.Bind(wx.EVT_SIZE, self.OnSize)
|
1999-04-29 23:29:54 -04:00
|
|
|
|
|
|
|
|
|
|
|
# Create some layout windows
|
|
|
|
# A window like a toolbar
|
2003-12-08 20:23:28 -05:00
|
|
|
win = wx.SashLayoutWindow(
|
|
|
|
self, self.ID_WINDOW_TOP, wx.DefaultPosition, (200, 30),
|
|
|
|
wx.NO_BORDER|wx.SW_3D
|
|
|
|
)
|
|
|
|
|
|
|
|
win.SetDefaultSize((1000, 30))
|
|
|
|
win.SetOrientation(wx.LAYOUT_HORIZONTAL)
|
|
|
|
win.SetAlignment(wx.LAYOUT_TOP)
|
|
|
|
win.SetBackgroundColour(wx.Colour(255, 0, 0))
|
|
|
|
win.SetSashVisible(wx.SASH_BOTTOM, True)
|
1999-04-29 23:29:54 -04:00
|
|
|
|
|
|
|
self.topWindow = win
|
|
|
|
|
|
|
|
|
|
|
|
# A window like a statusbar
|
2003-12-08 20:23:28 -05:00
|
|
|
win = wx.SashLayoutWindow(
|
|
|
|
self, self.ID_WINDOW_BOTTOM, wx.DefaultPosition, (200, 30),
|
|
|
|
wx.NO_BORDER|wx.SW_3D
|
|
|
|
)
|
1999-04-29 23:29:54 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
win.SetDefaultSize((1000, 30))
|
|
|
|
win.SetOrientation(wx.LAYOUT_HORIZONTAL)
|
|
|
|
win.SetAlignment(wx.LAYOUT_BOTTOM)
|
|
|
|
win.SetBackgroundColour(wx.Colour(0, 0, 255))
|
|
|
|
win.SetSashVisible(wx.SASH_TOP, True)
|
1999-04-29 23:29:54 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
self.bottomWindow = win
|
1999-04-29 23:29:54 -04:00
|
|
|
|
|
|
|
# A window to the left of the client window
|
2003-12-08 20:23:28 -05:00
|
|
|
win = wx.SashLayoutWindow(
|
|
|
|
self, self.ID_WINDOW_LEFT1, wx.DefaultPosition, (200, 30),
|
|
|
|
wx.NO_BORDER|wx.SW_3D
|
|
|
|
)
|
|
|
|
|
|
|
|
win.SetDefaultSize((120, 1000))
|
|
|
|
win.SetOrientation(wx.LAYOUT_VERTICAL)
|
|
|
|
win.SetAlignment(wx.LAYOUT_LEFT)
|
|
|
|
win.SetBackgroundColour(wx.Colour(0, 255, 0))
|
|
|
|
win.SetSashVisible(wx.SASH_RIGHT, True)
|
1999-04-29 23:29:54 -04:00
|
|
|
win.SetExtraBorderSize(10)
|
2003-12-08 20:23:28 -05:00
|
|
|
textWindow = wx.TextCtrl(
|
|
|
|
win, -1, "", wx.DefaultPosition, wx.DefaultSize,
|
|
|
|
wx.TE_MULTILINE|wx.SUNKEN_BORDER
|
|
|
|
)
|
|
|
|
|
2000-12-10 03:37:52 -05:00
|
|
|
textWindow.SetValue("A sub window")
|
1999-04-29 23:29:54 -04:00
|
|
|
|
|
|
|
self.leftWindow1 = win
|
|
|
|
|
|
|
|
|
|
|
|
# Another window to the left of the client window
|
2003-12-08 20:23:28 -05:00
|
|
|
win = wx.SashLayoutWindow(
|
|
|
|
self, self.ID_WINDOW_LEFT2, wx.DefaultPosition, (200, 30),
|
|
|
|
wx.NO_BORDER|wx.SW_3D
|
|
|
|
)
|
|
|
|
|
|
|
|
win.SetDefaultSize((120, 1000))
|
|
|
|
win.SetOrientation(wx.LAYOUT_VERTICAL)
|
|
|
|
win.SetAlignment(wx.LAYOUT_LEFT)
|
|
|
|
win.SetBackgroundColour(wx.Colour(0, 255, 255))
|
|
|
|
win.SetSashVisible(wx.SASH_RIGHT, True)
|
1999-04-29 23:29:54 -04:00
|
|
|
|
|
|
|
self.leftWindow2 = win
|
|
|
|
|
|
|
|
|
|
|
|
def OnSashDrag(self, event):
|
2003-12-08 20:23:28 -05:00
|
|
|
if event.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE:
|
1999-04-29 23:29:54 -04:00
|
|
|
return
|
|
|
|
|
|
|
|
eID = event.GetId()
|
2003-12-08 20:23:28 -05:00
|
|
|
|
1999-04-29 23:29:54 -04:00
|
|
|
if eID == self.ID_WINDOW_TOP:
|
2003-12-08 20:23:28 -05:00
|
|
|
self.topWindow.SetDefaultSize((1000, event.GetDragRect().height))
|
1999-04-29 23:29:54 -04:00
|
|
|
|
|
|
|
elif eID == self.ID_WINDOW_LEFT1:
|
2003-12-08 20:23:28 -05:00
|
|
|
self.leftWindow1.SetDefaultSize((event.GetDragRect().width, 1000))
|
1999-04-29 23:29:54 -04:00
|
|
|
|
|
|
|
|
|
|
|
elif eID == self.ID_WINDOW_LEFT2:
|
2003-12-08 20:23:28 -05:00
|
|
|
self.leftWindow2.SetDefaultSize((event.GetDragRect().width, 1000))
|
1999-04-29 23:29:54 -04:00
|
|
|
|
|
|
|
elif eID == self.ID_WINDOW_BOTTOM:
|
2003-12-08 20:23:28 -05:00
|
|
|
self.bottomWindow.SetDefaultSize((1000, event.GetDragRect().height))
|
1999-04-29 23:29:54 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace)
|
2000-12-10 03:37:52 -05:00
|
|
|
self.remainingSpace.Refresh()
|
1999-04-29 23:29:54 -04:00
|
|
|
|
|
|
|
def OnSize(self, event):
|
2003-12-08 20:23:28 -05:00
|
|
|
wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace)
|
1999-04-29 23:29:54 -04:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
def runTest(frame, nb, log):
|
|
|
|
win = TestSashWindow(nb, log)
|
|
|
|
return win
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2003-07-02 19:13:10 -04:00
|
|
|
overview = """\
|
2004-01-12 22:17:17 -05:00
|
|
|
wx.SashLayoutWindow responds to OnCalculateLayout events generated by
|
2003-12-08 20:23:28 -05:00
|
|
|
wxLayoutAlgorithm. It allows the application to use simple accessors to
|
|
|
|
specify how the window should be laid out, rather than having to respond
|
2004-01-12 22:17:17 -05:00
|
|
|
to events. The fact that the class derives from wx.SashWindow allows sashes
|
2003-12-08 20:23:28 -05:00
|
|
|
to be used if required, to allow the windows to be user-resizable.
|
1999-04-29 23:29:54 -04:00
|
|
|
|
2004-01-12 22:17:17 -05:00
|
|
|
The documentation for wx.LayoutAlgorithm explains the purpose of this class
|
2003-12-08 20:23:28 -05:00
|
|
|
in more detail.
|
1999-04-29 23:29:54 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
"""
|
1999-04-29 23:29:54 -04:00
|
|
|
|
|
|
|
|
2003-07-02 19:13:10 -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:])
|