]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/wxSashWindow.py
Added some docs
[wxWidgets.git] / wxPython / demo / wxSashWindow.py
CommitLineData
cf694132
RD
1
2from wxPython.wx import *
3
4#---------------------------------------------------------------------------
5
6class TestSashWindow(wxPanel):
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):
14 wxPanel.__init__(self, parent, -1)
15
16 self.log = log
17
18 EVT_SASH_DRAGGED_RANGE(self, self.ID_WINDOW_TOP,
19 self.ID_WINDOW_BOTTOM, self.OnSashDrag)
f6bcfd97 20 EVT_SIZE(self, self.OnSize)
cf694132
RD
21
22
23 # Create some layout windows
24 # A window like a toolbar
25 win = wxSashLayoutWindow(self, self.ID_WINDOW_TOP, wxDefaultPosition,
26 wxSize(200, 30), wxNO_BORDER|wxSW_3D)
27 win.SetDefaultSize(wxSize(1000, 30))
28 win.SetOrientation(wxLAYOUT_HORIZONTAL)
29 win.SetAlignment(wxLAYOUT_TOP)
30 win.SetBackgroundColour(wxColour(255, 0, 0))
31 win.SetSashVisible(wxSASH_BOTTOM, true)
32
33 self.topWindow = win
34
35
36 # A window like a statusbar
37 win = wxSashLayoutWindow(self, self.ID_WINDOW_BOTTOM,
38 wxDefaultPosition, wxSize(200, 30),
39 wxNO_BORDER|wxSW_3D)
40 win.SetDefaultSize(wxSize(1000, 30))
41 win.SetOrientation(wxLAYOUT_HORIZONTAL)
42 win.SetAlignment(wxLAYOUT_BOTTOM)
43 win.SetBackgroundColour(wxColour(0, 0, 255))
44 win.SetSashVisible(wxSASH_TOP, true)
45
46 self.bottomWindow = win
47
48
49 # A window to the left of the client window
50 win = wxSashLayoutWindow(self, self.ID_WINDOW_LEFT1,
51 wxDefaultPosition, wxSize(200, 30),
52 wxNO_BORDER|wxSW_3D)
53 win.SetDefaultSize(wxSize(120, 1000))
54 win.SetOrientation(wxLAYOUT_VERTICAL)
55 win.SetAlignment(wxLAYOUT_LEFT)
56 win.SetBackgroundColour(wxColour(0, 255, 0))
57 win.SetSashVisible(wxSASH_RIGHT, TRUE)
58 win.SetExtraBorderSize(10)
59
60 textWindow = wxTextCtrl(win, -1, "", wxDefaultPosition, wxDefaultSize,
61 wxTE_MULTILINE|wxSUNKEN_BORDER)
62 textWindow.SetValue("A help window")
63
64 self.leftWindow1 = win
65
66
67 # Another window to the left of the client window
68 win = wxSashLayoutWindow(self, self.ID_WINDOW_LEFT2,
69 wxDefaultPosition, wxSize(200, 30),
70 wxNO_BORDER|wxSW_3D)
71 win.SetDefaultSize(wxSize(120, 1000))
72 win.SetOrientation(wxLAYOUT_VERTICAL)
73 win.SetAlignment(wxLAYOUT_LEFT)
74 win.SetBackgroundColour(wxColour(0, 255, 255))
75 win.SetSashVisible(wxSASH_RIGHT, TRUE)
76
77 self.leftWindow2 = win
78
79
80 def OnSashDrag(self, event):
81 if event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE:
82 return
83
84 eID = event.GetId()
85 if eID == self.ID_WINDOW_TOP:
86 self.topWindow.SetDefaultSize(wxSize(1000, event.GetDragRect().height))
87
88 elif eID == self.ID_WINDOW_LEFT1:
89 self.leftWindow1.SetDefaultSize(wxSize(event.GetDragRect().width, 1000))
90
91
92 elif eID == self.ID_WINDOW_LEFT2:
93 self.leftWindow2.SetDefaultSize(wxSize(event.GetDragRect().width, 1000))
94
95 elif eID == self.ID_WINDOW_BOTTOM:
96 self.bottomWindow.SetDefaultSize(wxSize(1000, event.GetDragRect().height))
97
98 wxLayoutAlgorithm().LayoutWindow(self)
99
100
101 def OnSize(self, event):
102 wxLayoutAlgorithm().LayoutWindow(self)
103
104#---------------------------------------------------------------------------
105
106def runTest(frame, nb, log):
107 win = TestSashWindow(nb, log)
108 return win
109
110#---------------------------------------------------------------------------
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127overview = """\
128wxSashLayoutWindow responds to OnCalculateLayout events generated by wxLayoutAlgorithm. It allows the application to use simple accessors to specify how the window should be laid out, rather than having to respond to events. The fact that the class derives from wxSashWindow allows sashes to be used if required, to allow the windows to be user-resizable.
129
130wxSashLayoutWindow()
131-------------------------------------------
132
133Default constructor.
134
135wxSashLayoutWindow(wxSashLayoutWindow* parent, wxSashLayoutWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCLIP_CHILDREN | wxSW_3D, const wxString& name = "layoutWindow")
136
137Constructs a sash layout window, which can be a child of a frame, dialog or any other non-control window.
138
139Parameters
140-------------------
141
142parent = Pointer to a parent window.
143
144id = Window identifier. If -1, will automatically create an identifier.
145
146pos = Window position. wxDefaultPosition is (-1, -1) which indicates that wxSashLayoutWindows should generate a default position for the window. If using the wxSashLayoutWindow class directly, supply an actual position.
147
148size = Window size. wxDefaultSize is (-1, -1) which indicates that wxSashLayoutWindows should generate a default size for the window.
149
150style = Window style. For window styles, please see wxSashLayoutWindow.
151
152name = Window name.
153"""