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