]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/MDISashDemo.py
define wxTC_MULTILINE explicitly as wxNB_MULTILINE is not necessarily defined where...
[wxWidgets.git] / wxPython / demo / MDISashDemo.py
CommitLineData
de20db99
RD
1#!/usr/bin/env python
2
8fa876ca
RD
3import wx
4
299647ac 5import ScrolledWindow
de20db99
RD
6
7#----------------------------------------------------------------------
8fa876ca
RD
8# There are better ways to do IDs, but this demo requires that the window
9# IDs be in a specific range. There are better ways to do that, too, but
10# this will do for purposes of this demo.
de20db99 11
8fa876ca
RD
12ID_Menu_New = 5004
13ID_Menu_Exit = 5005
de20db99 14
8fa876ca
RD
15ID_WINDOW_TOP = 5000
16ID_WINDOW_LEFT1 = 5001
17ID_WINDOW_LEFT2 = 5002
18ID_WINDOW_BOTTOM = 5003
19
20#----------------------------------------------------------------------
21
22class MyParentFrame(wx.MDIParentFrame):
de20db99 23 def __init__(self):
8fa876ca
RD
24 wx.MDIParentFrame.__init__(
25 self, None, -1, "MDI Parent", size=(600,400),
26 style = wx.DEFAULT_FRAME_STYLE | wx.HSCROLL | wx.VSCROLL
27 )
de20db99
RD
28
29 self.winCount = 0
8fa876ca
RD
30 menu = wx.Menu()
31 menu.Append(ID_Menu_New, "&New Window")
de20db99 32 menu.AppendSeparator()
8fa876ca 33 menu.Append(ID_Menu_Exit, "E&xit")
de20db99 34
8fa876ca 35 menubar = wx.MenuBar()
de20db99
RD
36 menubar.Append(menu, "&File")
37 self.SetMenuBar(menubar)
38
39 #self.CreateStatusBar()
40
8fa876ca
RD
41 self.Bind(wx.EVT_MENU, self.OnNewWindow, id=ID_Menu_New)
42 self.Bind(wx.EVT_MENU, self.OnExit, id=ID_Menu_Exit)
de20db99 43
8fa876ca
RD
44 self.Bind(
45 wx.EVT_SASH_DRAGGED_RANGE, self.OnSashDrag, id=ID_WINDOW_TOP,
46 id2=ID_WINDOW_BOTTOM
47 )
de20db99 48
8fa876ca 49 self.Bind(wx.EVT_SIZE, self.OnSize)
de20db99
RD
50
51
52 # Create some layout windows
53 # A window like a toolbar
8fa876ca 54 win = wx.SashLayoutWindow(self, ID_WINDOW_TOP, style=wx.NO_BORDER|wx.SW_3D)
de20db99 55 win.SetDefaultSize((1000, 30))
8fa876ca
RD
56 win.SetOrientation(wx.LAYOUT_HORIZONTAL)
57 win.SetAlignment(wx.LAYOUT_TOP)
58 win.SetBackgroundColour(wx.Colour(255, 0, 0))
59 win.SetSashVisible(wx.SASH_BOTTOM, True)
de20db99
RD
60
61 self.topWindow = win
62
63
64 # A window like a statusbar
8fa876ca 65 win = wx.SashLayoutWindow(self, ID_WINDOW_BOTTOM, style=wx.NO_BORDER|wx.SW_3D)
de20db99 66 win.SetDefaultSize((1000, 30))
8fa876ca
RD
67 win.SetOrientation(wx.LAYOUT_HORIZONTAL)
68 win.SetAlignment(wx.LAYOUT_BOTTOM)
69 win.SetBackgroundColour(wx.Colour(0, 0, 255))
70 win.SetSashVisible(wx.SASH_TOP, True)
de20db99
RD
71
72 self.bottomWindow = win
73
74
75 # A window to the left of the client window
8fa876ca 76 win = wx.SashLayoutWindow(self, ID_WINDOW_LEFT1, style=wx.NO_BORDER|wx.SW_3D)
de20db99 77 win.SetDefaultSize((120, 1000))
8fa876ca
RD
78 win.SetOrientation(wx.LAYOUT_VERTICAL)
79 win.SetAlignment(wx.LAYOUT_LEFT)
80 win.SetBackgroundColour(wx.Colour(0, 255, 0))
81 win.SetSashVisible(wx.SASH_RIGHT, True)
de20db99 82 win.SetExtraBorderSize(10)
8fa876ca 83 textWindow = wx.TextCtrl(win, -1, "", style=wx.TE_MULTILINE|wx.SUNKEN_BORDER)
de20db99
RD
84 textWindow.SetValue("A sub window")
85
86 self.leftWindow1 = win
87
88
89 # Another window to the left of the client window
8fa876ca 90 win = wx.SashLayoutWindow(self, ID_WINDOW_LEFT2, style=wx.NO_BORDER|wx.SW_3D)
de20db99 91 win.SetDefaultSize((120, 1000))
8fa876ca
RD
92 win.SetOrientation(wx.LAYOUT_VERTICAL)
93 win.SetAlignment(wx.LAYOUT_LEFT)
94 win.SetBackgroundColour(wx.Colour(0, 255, 255))
95 win.SetSashVisible(wx.SASH_RIGHT, True)
de20db99
RD
96
97 self.leftWindow2 = win
98
99
100 def OnSashDrag(self, event):
8fa876ca 101 if event.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE:
de20db99
RD
102 return
103
104 eID = event.GetId()
8fa876ca
RD
105
106 if eID == ID_WINDOW_TOP:
107 self.topWindow.SetDefaultSize((1000, event.GetDragRect().height))
de20db99 108
8fa876ca
RD
109 elif eID == ID_WINDOW_LEFT1:
110 self.leftWindow1.SetDefaultSize((event.GetDragRect().width, 1000))
de20db99 111
8fa876ca
RD
112 elif eID == ID_WINDOW_LEFT2:
113 self.leftWindow2.SetDefaultSize((event.GetDragRect().width, 1000))
de20db99 114
8fa876ca
RD
115 elif eID == ID_WINDOW_BOTTOM:
116 self.bottomWindow.SetDefaultSize((1000, event.GetDragRect().height))
de20db99 117
8fa876ca 118 wx.LayoutAlgorithm().LayoutMDIFrame(self)
de20db99
RD
119 self.GetClientWindow().Refresh()
120
121
122 def OnSize(self, event):
8fa876ca 123 wx.LayoutAlgorithm().LayoutMDIFrame(self)
de20db99
RD
124
125
126 def OnExit(self, evt):
1e4a197e 127 self.Close(True)
de20db99
RD
128
129
130 def OnNewWindow(self, evt):
131 self.winCount = self.winCount + 1
8fa876ca 132 win = wx.MDIChildFrame(self, -1, "Child Window: %d" % self.winCount)
299647ac 133 canvas = ScrolledWindow.MyCanvas(win)
1e4a197e 134 win.Show(True)
de20db99
RD
135
136
137#----------------------------------------------------------------------
138
9c67cbec 139if __name__ == '__main__':
8fa876ca 140 class MyApp(wx.App):
9c67cbec 141 def OnInit(self):
8fa876ca 142 wx.InitAllImageHandlers()
9c67cbec 143 frame = MyParentFrame()
1e4a197e 144 frame.Show(True)
9c67cbec 145 self.SetTopWindow(frame)
1e4a197e 146 return True
de20db99 147
8fa876ca 148 app = MyApp(False)
9c67cbec 149 app.MainLoop()
de20db99
RD
150
151
152