]> git.saurik.com Git - wxWidgets.git/blob - src/mac/mdi.cpp
Added global skope too FinControl()
[wxWidgets.git] / src / mac / mdi.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: mdi.cpp
3 // Purpose: MDI classes
4 // Author: AUTHOR
5 // Modified by:
6 // Created: ??/??/98
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "mdi.h"
14 #endif
15
16 #include "wx/mdi.h"
17 #include "wx/menu.h"
18 #include "wx/settings.h"
19
20 #include "wx/mac/private.h"
21
22 extern wxWindowList wxModelessWindows;
23
24 #if !USE_SHARED_LIBRARY
25 IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame, wxFrame)
26 IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame, wxFrame)
27 IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow, wxWindow)
28
29 BEGIN_EVENT_TABLE(wxMDIParentFrame, wxFrame)
30 EVT_SIZE(wxMDIParentFrame::OnSize)
31 EVT_ACTIVATE(wxMDIParentFrame::OnActivate)
32 EVT_SYS_COLOUR_CHANGED(wxMDIParentFrame::OnSysColourChanged)
33 END_EVENT_TABLE()
34
35 BEGIN_EVENT_TABLE(wxMDIClientWindow, wxWindow)
36 EVT_SCROLL(wxMDIClientWindow::OnScroll)
37 END_EVENT_TABLE()
38
39 #endif
40
41 static const int IDM_WINDOWTILE = 4001;
42 static const int IDM_WINDOWTILEHOR = 4001;
43 static const int IDM_WINDOWCASCADE = 4002;
44 static const int IDM_WINDOWICONS = 4003;
45 static const int IDM_WINDOWNEXT = 4004;
46 static const int IDM_WINDOWTILEVERT = 4005;
47
48 // This range gives a maximum of 500 MDI children. Should be enough :-)
49 static const int wxFIRST_MDI_CHILD = 4100;
50 static const int wxLAST_MDI_CHILD = 4600;
51
52 // Status border dimensions
53 static const int wxTHICK_LINE_BORDER = 3;
54
55 // Parent frame
56
57 wxMDIParentFrame::wxMDIParentFrame()
58 {
59 m_clientWindow = NULL;
60 m_currentChild = NULL;
61 m_windowMenu = (wxMenu*) NULL;
62 m_parentFrameActive = TRUE;
63 }
64
65 bool wxMDIParentFrame::Create(wxWindow *parent,
66 wxWindowID id,
67 const wxString& title,
68 const wxPoint& pos,
69 const wxSize& size,
70 long style,
71 const wxString& name)
72 {
73 m_clientWindow = NULL;
74 m_currentChild = NULL;
75
76 // this style can be used to prevent a window from having the standard MDI
77 // "Window" menu
78 if ( style & wxFRAME_NO_WINDOW_MENU )
79 {
80 m_windowMenu = (wxMenu *)NULL;
81 style -= wxFRAME_NO_WINDOW_MENU ;
82 }
83 else // normal case: we have the window menu, so construct it
84 {
85 m_windowMenu = new wxMenu;
86
87 m_windowMenu->Append(IDM_WINDOWCASCADE, wxT("&Cascade"));
88 m_windowMenu->Append(IDM_WINDOWTILEHOR, wxT("Tile &Horizontally"));
89 m_windowMenu->Append(IDM_WINDOWTILEVERT, wxT("Tile &Vertically"));
90 m_windowMenu->AppendSeparator();
91 m_windowMenu->Append(IDM_WINDOWICONS, wxT("&Arrange Icons"));
92 m_windowMenu->Append(IDM_WINDOWNEXT, wxT("&Next"));
93 }
94
95 wxFrame::Create( parent , id , title , wxPoint( 2000 , 2000 ) , size , style , name ) ;
96 m_parentFrameActive = TRUE;
97
98 OnCreateClient();
99
100 return TRUE;
101 }
102
103 wxMDIParentFrame::~wxMDIParentFrame()
104 {
105 DestroyChildren();
106 // already delete by DestroyChildren()
107 m_frameToolBar = NULL;
108 m_frameStatusBar = NULL;
109 m_clientWindow = NULL ;
110
111 if (m_windowMenu)
112 {
113 delete m_windowMenu;
114 m_windowMenu = (wxMenu*) NULL;
115 }
116
117 if ( m_clientWindow )
118 {
119 delete m_clientWindow;
120 m_clientWindow = NULL ;
121 }
122 }
123
124
125 // Get size *available for subwindows* i.e. excluding menu bar.
126 void wxMDIParentFrame::DoGetClientSize(int *x, int *y) const
127 {
128 wxDisplaySize( x , y ) ;
129 }
130
131 void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar)
132 {
133 wxFrame::SetMenuBar( menu_bar ) ;
134 }
135
136 void wxMDIParentFrame::OnSize(wxSizeEvent& event)
137 {
138 #if wxUSE_CONSTRAINTS
139 if (GetAutoLayout())
140 Layout();
141 #endif
142 int x = 0;
143 int y = 0;
144 int width, height;
145 GetClientSize(&width, &height);
146
147 if ( GetClientWindow() )
148 GetClientWindow()->SetSize(x, y, width, height);
149 }
150
151 void wxMDIParentFrame::OnActivate(wxActivateEvent& event)
152 {
153 if ( m_currentChild && event.GetActive() )
154 {
155 wxActivateEvent event(wxEVT_ACTIVATE, TRUE, m_currentChild->GetId());
156 event.SetEventObject( m_currentChild );
157 m_currentChild->GetEventHandler()->ProcessEvent(event) ;
158 }
159 else if ( event.GetActive() )
160 {
161 if ( m_frameMenuBar != NULL )
162 {
163 m_frameMenuBar->MacInstallMenuBar() ;
164 }
165
166 }
167 }
168
169 // Returns the active MDI child window
170 wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const
171 {
172 return m_currentChild ;
173 }
174
175 // Create the client window class (don't Create the window,
176 // just return a new class)
177 wxMDIClientWindow *wxMDIParentFrame::OnCreateClient()
178 {
179 m_clientWindow = new wxMDIClientWindow( this );
180 return m_clientWindow;
181 }
182
183 // Responds to colour changes, and passes event on to children.
184 void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
185 {
186 // TODO
187
188 // Propagate the event to the non-top-level children
189 wxFrame::OnSysColourChanged(event);
190 }
191
192 // MDI operations
193 void wxMDIParentFrame::Cascade()
194 {
195 // TODO
196 }
197
198 void wxMDIParentFrame::Tile()
199 {
200 // TODO
201 }
202
203 void wxMDIParentFrame::ArrangeIcons()
204 {
205 // TODO
206 }
207
208 void wxMDIParentFrame::ActivateNext()
209 {
210 // TODO
211 }
212
213 void wxMDIParentFrame::ActivatePrevious()
214 {
215 // TODO
216 }
217
218 // Child frame
219
220 wxMDIChildFrame::wxMDIChildFrame()
221 {
222 Init() ;
223 }
224 void wxMDIChildFrame::Init()
225 {
226 }
227
228 bool wxMDIChildFrame::Create(wxMDIParentFrame *parent,
229 wxWindowID id,
230 const wxString& title,
231 const wxPoint& pos,
232 const wxSize& size,
233 long style,
234 const wxString& name)
235 {
236 SetName(name);
237
238 if ( id > -1 )
239 m_windowId = id;
240 else
241 m_windowId = (int)NewControlId();
242
243 if (parent) parent->AddChild(this);
244
245 MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ;
246
247 m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ;
248 SetThemeWindowBackground( (WindowRef) m_macWindow , m_macWindowBackgroundTheme , false ) ;
249
250 wxModelessWindows.Append(this);
251 return FALSE;
252 }
253
254 wxMDIChildFrame::~wxMDIChildFrame()
255 {
256 DestroyChildren();
257 // already delete by DestroyChildren()
258 m_frameToolBar = NULL;
259 m_frameStatusBar = NULL;
260 }
261
262 void wxMDIChildFrame::SetMenuBar(wxMenuBar *menu_bar)
263 {
264 return wxFrame::SetMenuBar( menu_bar ) ;
265 }
266
267 // MDI operations
268 void wxMDIChildFrame::Maximize()
269 {
270 wxFrame::Maximize() ;
271 }
272
273 void wxMDIChildFrame::Restore()
274 {
275 wxFrame::Restore() ;
276 }
277
278 void wxMDIChildFrame::Activate()
279 {
280 }
281
282 //-----------------------------------------------------------------------------
283 // wxMDIClientWindow
284 //-----------------------------------------------------------------------------
285
286 wxMDIClientWindow::wxMDIClientWindow()
287 {
288 }
289
290 wxMDIClientWindow::~wxMDIClientWindow()
291 {
292 DestroyChildren();
293 }
294
295 bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style)
296 {
297
298 m_windowId = (int)NewControlId();
299
300 if ( parent )
301 {
302 parent->AddChild(this);
303 }
304 m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE);
305
306 wxModelessWindows.Append(this);
307 return TRUE;
308 }
309
310 // Explicitly call default scroll behaviour
311 void wxMDIClientWindow::OnScroll(wxScrollEvent& event)
312 {
313 }
314