]>
Commit | Line | Data |
---|---|---|
cf694132 RD |
1 | |
2 | from wxPython.wx import * | |
3 | ||
4 | #--------------------------------------------------------------------------- | |
5 | ||
6 | class 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 | ||
1b62f00d | 18 | # will occupy the space not used by the Layout Algorithm |
de20db99 RD |
19 | self.remainingSpace = wxPanel(self, -1, style=wxSUNKEN_BORDER) |
20 | ||
cf694132 RD |
21 | EVT_SASH_DRAGGED_RANGE(self, self.ID_WINDOW_TOP, |
22 | self.ID_WINDOW_BOTTOM, self.OnSashDrag) | |
f6bcfd97 | 23 | EVT_SIZE(self, self.OnSize) |
cf694132 RD |
24 | |
25 | ||
26 | # Create some layout windows | |
27 | # A window like a toolbar | |
28 | win = wxSashLayoutWindow(self, self.ID_WINDOW_TOP, wxDefaultPosition, | |
29 | wxSize(200, 30), wxNO_BORDER|wxSW_3D) | |
30 | win.SetDefaultSize(wxSize(1000, 30)) | |
31 | win.SetOrientation(wxLAYOUT_HORIZONTAL) | |
32 | win.SetAlignment(wxLAYOUT_TOP) | |
33 | win.SetBackgroundColour(wxColour(255, 0, 0)) | |
1e4a197e | 34 | win.SetSashVisible(wxSASH_BOTTOM, True) |
cf694132 RD |
35 | |
36 | self.topWindow = win | |
37 | ||
38 | ||
39 | # A window like a statusbar | |
40 | win = wxSashLayoutWindow(self, self.ID_WINDOW_BOTTOM, | |
41 | wxDefaultPosition, wxSize(200, 30), | |
42 | wxNO_BORDER|wxSW_3D) | |
43 | win.SetDefaultSize(wxSize(1000, 30)) | |
44 | win.SetOrientation(wxLAYOUT_HORIZONTAL) | |
45 | win.SetAlignment(wxLAYOUT_BOTTOM) | |
46 | win.SetBackgroundColour(wxColour(0, 0, 255)) | |
1e4a197e | 47 | win.SetSashVisible(wxSASH_TOP, True) |
cf694132 RD |
48 | |
49 | self.bottomWindow = win | |
50 | ||
51 | ||
52 | # A window to the left of the client window | |
53 | win = wxSashLayoutWindow(self, self.ID_WINDOW_LEFT1, | |
54 | wxDefaultPosition, wxSize(200, 30), | |
55 | wxNO_BORDER|wxSW_3D) | |
56 | win.SetDefaultSize(wxSize(120, 1000)) | |
57 | win.SetOrientation(wxLAYOUT_VERTICAL) | |
58 | win.SetAlignment(wxLAYOUT_LEFT) | |
59 | win.SetBackgroundColour(wxColour(0, 255, 0)) | |
1e4a197e | 60 | win.SetSashVisible(wxSASH_RIGHT, True) |
cf694132 | 61 | win.SetExtraBorderSize(10) |
cf694132 RD |
62 | textWindow = wxTextCtrl(win, -1, "", wxDefaultPosition, wxDefaultSize, |
63 | wxTE_MULTILINE|wxSUNKEN_BORDER) | |
de20db99 | 64 | textWindow.SetValue("A sub window") |
cf694132 RD |
65 | |
66 | self.leftWindow1 = win | |
67 | ||
68 | ||
69 | # Another window to the left of the client window | |
70 | win = wxSashLayoutWindow(self, self.ID_WINDOW_LEFT2, | |
71 | wxDefaultPosition, wxSize(200, 30), | |
72 | wxNO_BORDER|wxSW_3D) | |
73 | win.SetDefaultSize(wxSize(120, 1000)) | |
74 | win.SetOrientation(wxLAYOUT_VERTICAL) | |
75 | win.SetAlignment(wxLAYOUT_LEFT) | |
76 | win.SetBackgroundColour(wxColour(0, 255, 255)) | |
1e4a197e | 77 | win.SetSashVisible(wxSASH_RIGHT, True) |
cf694132 RD |
78 | |
79 | self.leftWindow2 = win | |
80 | ||
81 | ||
82 | def OnSashDrag(self, event): | |
83 | if event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE: | |
84 | return | |
85 | ||
86 | eID = event.GetId() | |
87 | if eID == self.ID_WINDOW_TOP: | |
88 | self.topWindow.SetDefaultSize(wxSize(1000, event.GetDragRect().height)) | |
89 | ||
90 | elif eID == self.ID_WINDOW_LEFT1: | |
91 | self.leftWindow1.SetDefaultSize(wxSize(event.GetDragRect().width, 1000)) | |
92 | ||
93 | ||
94 | elif eID == self.ID_WINDOW_LEFT2: | |
95 | self.leftWindow2.SetDefaultSize(wxSize(event.GetDragRect().width, 1000)) | |
96 | ||
97 | elif eID == self.ID_WINDOW_BOTTOM: | |
98 | self.bottomWindow.SetDefaultSize(wxSize(1000, event.GetDragRect().height)) | |
99 | ||
de20db99 RD |
100 | wxLayoutAlgorithm().LayoutWindow(self, self.remainingSpace) |
101 | self.remainingSpace.Refresh() | |
cf694132 RD |
102 | |
103 | def OnSize(self, event): | |
de20db99 | 104 | wxLayoutAlgorithm().LayoutWindow(self, self.remainingSpace) |
cf694132 RD |
105 | |
106 | #--------------------------------------------------------------------------- | |
107 | ||
108 | def runTest(frame, nb, log): | |
109 | win = TestSashWindow(nb, log) | |
110 | return win | |
111 | ||
112 | #--------------------------------------------------------------------------- | |
113 | ||
114 | ||
115 | ||
116 | ||
117 | ||
118 | ||
119 | ||
120 | ||
121 | ||
122 | ||
123 | ||
124 | ||
125 | ||
126 | ||
127 | ||
128 | ||
129 | overview = """\ | |
cf694132 | 130 | """ |