]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/SashWindow.py
Added wrappers for wx.MediaCtrl
[wxWidgets.git] / wxPython / demo / SashWindow.py
CommitLineData
cf694132 1
8fa876ca 2import wx
cf694132
RD
3
4#---------------------------------------------------------------------------
5
8fa876ca 6class TestSashWindow(wx.Panel):
cf694132
RD
7 ID_WINDOW_TOP = 5100
8 ID_WINDOW_LEFT1 = 5101
9 ID_WINDOW_LEFT2 = 5102
10 ID_WINDOW_BOTTOM = 5103
11
12
13 def __init__(self, parent, log):
8fa876ca 14 wx.Panel.__init__(self, parent, -1)
cf694132
RD
15
16 self.log = log
17
1b62f00d 18 # will occupy the space not used by the Layout Algorithm
8fa876ca 19 self.remainingSpace = wx.Panel(self, -1, style=wx.SUNKEN_BORDER)
de20db99 20
8fa876ca
RD
21 self.Bind(
22 wx.EVT_SASH_DRAGGED_RANGE, self.OnSashDrag,
23 id=self.ID_WINDOW_TOP, id2=self.ID_WINDOW_BOTTOM,
24 )
25
26 self.Bind(wx.EVT_SIZE, self.OnSize)
cf694132
RD
27
28
29 # Create some layout windows
30 # A window like a toolbar
8fa876ca
RD
31 win = wx.SashLayoutWindow(
32 self, self.ID_WINDOW_TOP, wx.DefaultPosition, (200, 30),
33 wx.NO_BORDER|wx.SW_3D
34 )
35
36 win.SetDefaultSize((1000, 30))
37 win.SetOrientation(wx.LAYOUT_HORIZONTAL)
38 win.SetAlignment(wx.LAYOUT_TOP)
39 win.SetBackgroundColour(wx.Colour(255, 0, 0))
40 win.SetSashVisible(wx.SASH_BOTTOM, True)
cf694132
RD
41
42 self.topWindow = win
43
44
45 # A window like a statusbar
8fa876ca
RD
46 win = wx.SashLayoutWindow(
47 self, self.ID_WINDOW_BOTTOM, wx.DefaultPosition, (200, 30),
48 wx.NO_BORDER|wx.SW_3D
49 )
cf694132 50
8fa876ca
RD
51 win.SetDefaultSize((1000, 30))
52 win.SetOrientation(wx.LAYOUT_HORIZONTAL)
53 win.SetAlignment(wx.LAYOUT_BOTTOM)
54 win.SetBackgroundColour(wx.Colour(0, 0, 255))
55 win.SetSashVisible(wx.SASH_TOP, True)
cf694132 56
8fa876ca 57 self.bottomWindow = win
cf694132
RD
58
59 # A window to the left of the client window
8fa876ca
RD
60 win = wx.SashLayoutWindow(
61 self, self.ID_WINDOW_LEFT1, wx.DefaultPosition, (200, 30),
62 wx.NO_BORDER|wx.SW_3D
63 )
64
65 win.SetDefaultSize((120, 1000))
66 win.SetOrientation(wx.LAYOUT_VERTICAL)
67 win.SetAlignment(wx.LAYOUT_LEFT)
68 win.SetBackgroundColour(wx.Colour(0, 255, 0))
69 win.SetSashVisible(wx.SASH_RIGHT, True)
cf694132 70 win.SetExtraBorderSize(10)
8fa876ca
RD
71 textWindow = wx.TextCtrl(
72 win, -1, "", wx.DefaultPosition, wx.DefaultSize,
73 wx.TE_MULTILINE|wx.SUNKEN_BORDER
74 )
75
de20db99 76 textWindow.SetValue("A sub window")
cf694132
RD
77
78 self.leftWindow1 = win
79
80
81 # Another window to the left of the client window
8fa876ca
RD
82 win = wx.SashLayoutWindow(
83 self, self.ID_WINDOW_LEFT2, wx.DefaultPosition, (200, 30),
84 wx.NO_BORDER|wx.SW_3D
85 )
86
87 win.SetDefaultSize((120, 1000))
88 win.SetOrientation(wx.LAYOUT_VERTICAL)
89 win.SetAlignment(wx.LAYOUT_LEFT)
90 win.SetBackgroundColour(wx.Colour(0, 255, 255))
91 win.SetSashVisible(wx.SASH_RIGHT, True)
cf694132
RD
92
93 self.leftWindow2 = win
94
95
96 def OnSashDrag(self, event):
8fa876ca 97 if event.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE:
cf694132
RD
98 return
99
100 eID = event.GetId()
8fa876ca 101
cf694132 102 if eID == self.ID_WINDOW_TOP:
8fa876ca 103 self.topWindow.SetDefaultSize((1000, event.GetDragRect().height))
cf694132
RD
104
105 elif eID == self.ID_WINDOW_LEFT1:
8fa876ca 106 self.leftWindow1.SetDefaultSize((event.GetDragRect().width, 1000))
cf694132
RD
107
108
109 elif eID == self.ID_WINDOW_LEFT2:
8fa876ca 110 self.leftWindow2.SetDefaultSize((event.GetDragRect().width, 1000))
cf694132
RD
111
112 elif eID == self.ID_WINDOW_BOTTOM:
8fa876ca 113 self.bottomWindow.SetDefaultSize((1000, event.GetDragRect().height))
cf694132 114
8fa876ca 115 wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace)
de20db99 116 self.remainingSpace.Refresh()
cf694132
RD
117
118 def OnSize(self, event):
8fa876ca 119 wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace)
cf694132
RD
120
121#---------------------------------------------------------------------------
122
123def runTest(frame, nb, log):
124 win = TestSashWindow(nb, log)
125 return win
126
127#---------------------------------------------------------------------------
128
129
1fded56b 130overview = """\
95bfd958 131wx.SashLayoutWindow responds to OnCalculateLayout events generated by
8fa876ca
RD
132wxLayoutAlgorithm. It allows the application to use simple accessors to
133specify how the window should be laid out, rather than having to respond
95bfd958 134to events. The fact that the class derives from wx.SashWindow allows sashes
8fa876ca 135to be used if required, to allow the windows to be user-resizable.
cf694132 136
95bfd958 137The documentation for wx.LayoutAlgorithm explains the purpose of this class
8fa876ca 138in more detail.
cf694132 139
8fa876ca 140"""
cf694132
RD
141
142
1fded56b
RD
143if __name__ == '__main__':
144 import sys,os
145 import run
8eca4fef 146 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])