]> git.saurik.com Git - wxWidgets.git/blame - src/mac/mdi.cpp
keep name of wxmac icon for application bundles unstead of renaming it
[wxWidgets.git] / src / mac / mdi.cpp
CommitLineData
e9576ca5
SC
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
76a5e5d2
SC
20#include "wx/mac/private.h"
21
fe08e597 22extern wxWindowList wxModelessWindows;
e9576ca5 23
2f1ae414 24#if !USE_SHARED_LIBRARY
e9576ca5
SC
25IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame, wxFrame)
26IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame, wxFrame)
27IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow, wxWindow)
28
29BEGIN_EVENT_TABLE(wxMDIParentFrame, wxFrame)
30 EVT_SIZE(wxMDIParentFrame::OnSize)
31 EVT_ACTIVATE(wxMDIParentFrame::OnActivate)
32 EVT_SYS_COLOUR_CHANGED(wxMDIParentFrame::OnSysColourChanged)
33END_EVENT_TABLE()
34
35BEGIN_EVENT_TABLE(wxMDIClientWindow, wxWindow)
36 EVT_SCROLL(wxMDIClientWindow::OnScroll)
37END_EVENT_TABLE()
38
2f1ae414 39#endif
e9576ca5 40
0a67a93b
SC
41static const int IDM_WINDOWTILE = 4001;
42static const int IDM_WINDOWTILEHOR = 4001;
43static const int IDM_WINDOWCASCADE = 4002;
44static const int IDM_WINDOWICONS = 4003;
45static const int IDM_WINDOWNEXT = 4004;
46static const int IDM_WINDOWTILEVERT = 4005;
47
48// This range gives a maximum of 500 MDI children. Should be enough :-)
49static const int wxFIRST_MDI_CHILD = 4100;
50static const int wxLAST_MDI_CHILD = 4600;
51
52// Status border dimensions
53static const int wxTHICK_LINE_BORDER = 3;
54
e9576ca5
SC
55// Parent frame
56
57wxMDIParentFrame::wxMDIParentFrame()
58{
0a67a93b
SC
59 m_clientWindow = NULL;
60 m_currentChild = NULL;
61 m_windowMenu = (wxMenu*) NULL;
62 m_parentFrameActive = TRUE;
e9576ca5
SC
63}
64
65bool 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{
0a67a93b
SC
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();
e9576ca5
SC
99
100 return TRUE;
101}
102
103wxMDIParentFrame::~wxMDIParentFrame()
104{
0a67a93b
SC
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 }
e9576ca5
SC
122}
123
0a67a93b 124
e9576ca5 125// Get size *available for subwindows* i.e. excluding menu bar.
7c74e7fe 126void wxMDIParentFrame::DoGetClientSize(int *x, int *y) const
e9576ca5 127{
2f1ae414 128 wxDisplaySize( x , y ) ;
e9576ca5
SC
129}
130
131void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar)
132{
e7549107 133 wxFrame::SetMenuBar( menu_bar ) ;
e9576ca5
SC
134}
135
136void 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
151void wxMDIParentFrame::OnActivate(wxActivateEvent& event)
152{
0a67a93b
SC
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 }
e9576ca5
SC
167}
168
169// Returns the active MDI child window
170wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const
171{
0a67a93b 172 return m_currentChild ;
e9576ca5
SC
173}
174
175// Create the client window class (don't Create the window,
176// just return a new class)
177wxMDIClientWindow *wxMDIParentFrame::OnCreateClient()
178{
0a67a93b
SC
179 m_clientWindow = new wxMDIClientWindow( this );
180 return m_clientWindow;
e9576ca5
SC
181}
182
183// Responds to colour changes, and passes event on to children.
184void 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
193void wxMDIParentFrame::Cascade()
194{
195 // TODO
196}
197
198void wxMDIParentFrame::Tile()
199{
200 // TODO
201}
202
203void wxMDIParentFrame::ArrangeIcons()
204{
205 // TODO
206}
207
208void wxMDIParentFrame::ActivateNext()
209{
210 // TODO
211}
212
213void wxMDIParentFrame::ActivatePrevious()
214{
215 // TODO
216}
217
218// Child frame
219
220wxMDIChildFrame::wxMDIChildFrame()
0a67a93b
SC
221{
222 Init() ;
223}
224void wxMDIChildFrame::Init()
e9576ca5
SC
225{
226}
227
228bool 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
2f1ae414
SC
245 MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ;
246
e4086560
SC
247 m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ;
248 SetThemeWindowBackground( (WindowRef) m_macWindow , m_macWindowBackgroundTheme , false ) ;
e9576ca5
SC
249
250 wxModelessWindows.Append(this);
251 return FALSE;
252}
253
254wxMDIChildFrame::~wxMDIChildFrame()
255{
0a67a93b
SC
256 DestroyChildren();
257 // already delete by DestroyChildren()
258 m_frameToolBar = NULL;
259 m_frameStatusBar = NULL;
e9576ca5
SC
260}
261
262void wxMDIChildFrame::SetMenuBar(wxMenuBar *menu_bar)
263{
e7549107 264 return wxFrame::SetMenuBar( menu_bar ) ;
e9576ca5
SC
265}
266
267// MDI operations
268void wxMDIChildFrame::Maximize()
269{
0a67a93b 270 wxFrame::Maximize() ;
e9576ca5
SC
271}
272
273void wxMDIChildFrame::Restore()
274{
0a67a93b 275 wxFrame::Restore() ;
e9576ca5
SC
276}
277
278void wxMDIChildFrame::Activate()
279{
e9576ca5
SC
280}
281
0a67a93b
SC
282//-----------------------------------------------------------------------------
283// wxMDIClientWindow
284//-----------------------------------------------------------------------------
e9576ca5
SC
285
286wxMDIClientWindow::wxMDIClientWindow()
287{
288}
289
290wxMDIClientWindow::~wxMDIClientWindow()
291{
0a67a93b 292 DestroyChildren();
e9576ca5
SC
293}
294
295bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style)
296{
0a67a93b
SC
297
298 m_windowId = (int)NewControlId();
299
300 if ( parent )
301 {
302 parent->AddChild(this);
303 }
a756f210 304 m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE);
e9576ca5 305
0a67a93b
SC
306 wxModelessWindows.Append(this);
307 return TRUE;
e9576ca5
SC
308}
309
310// Explicitly call default scroll behaviour
311void wxMDIClientWindow::OnScroll(wxScrollEvent& event)
312{
e9576ca5
SC
313}
314