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