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