]>
Commit | Line | Data |
---|---|---|
ebf4302c RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: gizmos.i | |
3 | // Purpose: Wrappers for the "gizmo" classes in wx/contrib | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 23-Nov-2001 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 2001 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | %module gizmos | |
14 | ||
15 | ||
16 | %{ | |
17 | #include "export.h" | |
18 | #include "wx/gizmos/dynamicsash.h" | |
19 | %} | |
20 | ||
21 | //--------------------------------------------------------------------------- | |
22 | ||
23 | %include typemaps.i | |
24 | %include my_typemaps.i | |
25 | ||
26 | %extern wx.i | |
27 | %extern windows.i | |
28 | %extern _defs.i | |
29 | %extern events.i | |
30 | %extern controls.i | |
31 | ||
32 | ||
33 | //---------------------------------------------------------------------- | |
34 | ||
35 | enum { | |
36 | wxEVT_DYNAMIC_SASH_SPLIT, | |
37 | wxEVT_DYNAMIC_SASH_UNIFY, | |
38 | ||
39 | wxDS_MANAGE_SCROLLBARS, | |
40 | wxDS_DRAG_CORNER, | |
41 | }; | |
42 | ||
43 | ||
44 | /* | |
45 | wxDynamicSashSplitEvents are sent to your view by wxDynamicSashWindow | |
46 | whenever your view is being split by the user. It is your | |
47 | responsibility to handle this event by creating a new view window as | |
48 | a child of the wxDynamicSashWindow. wxDynamicSashWindow will | |
49 | automatically reparent it to the proper place in its window hierarchy. | |
50 | */ | |
51 | class wxDynamicSashSplitEvent : public wxCommandEvent { | |
52 | public: | |
53 | wxDynamicSashSplitEvent(wxObject *target); | |
54 | }; | |
55 | ||
56 | ||
57 | /* | |
58 | wxDynamicSashUnifyEvents are sent to your view by wxDynamicSashWindow | |
59 | whenever the sash which splits your view and its sibling is being | |
60 | reunified such that your view is expanding to replace its sibling. | |
61 | You needn't do anything with this event if you are allowing | |
62 | wxDynamicSashWindow to manage your view's scrollbars, but it is useful | |
63 | if you are managing the scrollbars yourself so that you can keep | |
64 | the scrollbars' event handlers connected to your view's event handler | |
65 | class. | |
66 | */ | |
67 | class wxDynamicSashUnifyEvent : public wxCommandEvent { | |
68 | public: | |
69 | wxDynamicSashUnifyEvent(wxObject *target); | |
70 | }; | |
71 | ||
72 | ||
73 | ||
74 | /* | |
75 | ||
76 | wxDynamicSashWindow | |
77 | ||
78 | wxDynamicSashWindow widgets manages the way other widgets are viewed. | |
79 | When a wxDynamicSashWindow is first shown, it will contain one child | |
80 | view, a viewport for that child, and a pair of scrollbars to allow the | |
81 | user to navigate the child view area. Next to each scrollbar is a small | |
82 | tab. By clicking on either tab and dragging to the appropriate spot, a | |
83 | user can split the view area into two smaller views separated by a | |
84 | draggable sash. Later, when the user wishes to reunify the two subviews, | |
85 | the user simply drags the sash to the side of the window. | |
86 | wxDynamicSashWindow will automatically reparent the appropriate child | |
87 | view back up the window hierarchy, and the wxDynamicSashWindow will have | |
88 | only one child view once again. | |
89 | ||
90 | As an application developer, you will simply create a wxDynamicSashWindow | |
91 | using either the Create() function or the more complex constructor | |
92 | provided below, and then create a viewfrom wxPython.wx import * window whose parent is the | |
93 | wxDynamicSashWindow. The child should respond to | |
94 | wxDynamicSashSplitEvents -- perhaps with an OnSplit() event handler -- by | |
95 | constructing a new view window whose parent is also the | |
96 | wxDynamicSashWindow. That's it! Now your users can dynamically split | |
97 | and reunify the view you provided. | |
98 | ||
99 | If you wish to handle the scrollbar events for your view, rather than | |
100 | allowing wxDynamicSashWindow to do it for you, things are a bit more | |
101 | complex. (You might want to handle scrollbar events yourself, if, | |
102 | for instance, you wish to scroll a subwindow of the view you add to | |
103 | your wxDynamicSashWindow object, rather than scrolling the whole view.) | |
104 | In this case, you will need to construfrom wxPython.wx import *ct your wxDynamicSashWindow without | |
105 | the wxDS_MANAGE_SCROLLBARS style and you will need to use the | |
106 | GetHScrollBar() and GetVScrollBar() methods to retrieve the scrollbar | |
107 | controls and call SetEventHanler() on them to redirect the scrolling | |
108 | events whenever your window is reparented by wxDyanmicSashWindow. | |
109 | You will need to set the scrollbars' event handler at three times: | |
110 | ||
111 | * When your view is created | |
112 | * When your view receives a wxDynamicSashSplitEvent | |
113 | * When your view receives a wxDynamicSashUnifyEvent | |
114 | ||
115 | See the dynsash_switch sample application for an example which does this. | |
116 | ||
117 | */ | |
118 | ||
119 | class wxDynamicSashWindow : public wxWindow { | |
120 | public: | |
121 | wxDynamicSashWindow(wxWindow *parent, wxWindowID id, | |
122 | const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, | |
123 | long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER, | |
124 | const char* name = "dynamicSashWindow"); | |
125 | %name(wxPreDynamicSashWindow)wxDynamicSashWindow(); | |
126 | ||
127 | bool Create(wxWindow *parent, wxWindowID id, | |
128 | const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, | |
129 | long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER, | |
130 | const char* name = "dynamicSashWindow"); | |
131 | ||
132 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
133 | %pragma(python) addtomethod = "wxPreDynamicSashWindow:val._setOORInfo(val)" | |
134 | ||
135 | wxScrollBar *GetHScrollBar(const wxWindow *child) const; | |
136 | wxScrollBar *GetVScrollBar(const wxWindow *child) const; | |
137 | }; | |
138 | ||
139 | ||
140 | ||
141 | //---------------------------------------------------------------------- | |
142 | // Python functions to act like the event macros | |
143 | ||
144 | %pragma(python) code = " | |
145 | def EVT_DYNAMIC_SASH_SPLIT(win, id, func): | |
146 | win.Connect(id, -1, wxEVT_DYNAMIC_SASH_SPLIT, func) | |
147 | ||
148 | def EVT_DYNAMIC_SASH_UNIFY(win, id, func): | |
149 | win.Connect(id, -1, wxEVT_DYNAMIC_SASH_UNIFY, func) | |
150 | " | |
151 | ||
152 | //---------------------------------------------------------------------- | |
153 | ||
154 | %init %{ | |
155 | ||
156 | wxClassInfo::CleanUpClasses(); | |
157 | wxClassInfo::InitializeClasses(); | |
158 | ||
159 | %} | |
160 | ||
161 | ||
162 | //---------------------------------------------------------------------- | |
163 | ||
164 | %pragma(python) include="_gizmoextras.py"; | |
165 | ||
166 | //---------------------------------------------------------------------- | |
167 | //---------------------------------------------------------------------- | |
168 | ||
169 |