]>
Commit | Line | Data |
---|---|---|
4bb6408c | 1 | ///////////////////////////////////////////////////////////////////////////// |
355b4d3d | 2 | // Name: src/motif/frame.cpp |
4bb6408c JS |
3 | // Purpose: wxFrame |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 17/09/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
65571936 | 9 | // Licence: wxWindows licence |
4bb6408c JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
1c4f8f8d VZ |
12 | // ============================================================================ |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
1248b41f MB |
20 | // For compilers that support precompilation, includes "wx.h". |
21 | #include "wx/wxprec.h" | |
4dff3400 | 22 | |
798a4529 | 23 | #include "wx/frame.h" |
e4db172a WS |
24 | |
25 | #ifndef WX_PRECOMP | |
26 | #include "wx/log.h" | |
670f9935 | 27 | #include "wx/app.h" |
de6185e2 | 28 | #include "wx/utils.h" |
3b3dc801 | 29 | #include "wx/menu.h" |
923d28da | 30 | #include "wx/icon.h" |
9eddec69 | 31 | #include "wx/settings.h" |
4e3e485b | 32 | #include "wx/toolbar.h" |
3304646d | 33 | #include "wx/statusbr.h" |
e4db172a WS |
34 | #endif |
35 | ||
338dd992 | 36 | #ifdef __VMS__ |
1c4f8f8d | 37 | #pragma message disable nosimpint |
338dd992 | 38 | #endif |
1c4f8f8d | 39 | |
4bb6408c | 40 | #if defined(__ultrix) || defined(__sgi) |
1c4f8f8d | 41 | #include <Xm/Frame.h> |
4bb6408c JS |
42 | #endif |
43 | ||
44 | #include <Xm/Xm.h> | |
45 | #include <X11/Shell.h> | |
f618020a | 46 | #include <X11/Core.h> |
4bb6408c | 47 | #if XmVersion >= 1002 |
1c4f8f8d | 48 | #include <Xm/XmAll.h> |
4bb6408c | 49 | #else |
1c4f8f8d | 50 | #include <Xm/Frame.h> |
4bb6408c JS |
51 | #endif |
52 | #include <Xm/MwmUtil.h> | |
53 | #include <Xm/BulletinB.h> | |
54 | #include <Xm/Form.h> | |
55 | #include <Xm/MainW.h> | |
56 | #include <Xm/RowColumn.h> | |
57 | #include <Xm/Label.h> | |
58 | #include <Xm/AtomMgr.h> | |
59 | #include <Xm/LabelG.h> | |
60 | #include <Xm/Frame.h> | |
61 | #if XmVersion > 1000 | |
1c4f8f8d | 62 | #include <Xm/Protocols.h> |
4bb6408c | 63 | #endif |
1c4f8f8d | 64 | |
338dd992 | 65 | #ifdef __VMS__ |
1c4f8f8d | 66 | #pragma message enable nosimpint |
338dd992 | 67 | #endif |
4bb6408c JS |
68 | |
69 | #include "wx/motif/private.h" | |
f618020a | 70 | #include "wx/unix/utilsx11.h" |
4bb6408c | 71 | |
1c4f8f8d VZ |
72 | // ---------------------------------------------------------------------------- |
73 | // private functions | |
74 | // ---------------------------------------------------------------------------- | |
75 | ||
dfe1eee3 | 76 | static void wxFrameMapProc(Widget frameShell, XtPointer clientData, |
798a4529 | 77 | XCrossingEvent* event); |
4bb6408c | 78 | |
1c4f8f8d VZ |
79 | // ---------------------------------------------------------------------------- |
80 | // globals | |
81 | // ---------------------------------------------------------------------------- | |
82 | ||
4bb6408c | 83 | extern wxList wxModelessWindows; |
4bb6408c | 84 | |
1c4f8f8d VZ |
85 | // ---------------------------------------------------------------------------- |
86 | // wxWin macros | |
87 | // ---------------------------------------------------------------------------- | |
88 | ||
1c4f8f8d VZ |
89 | BEGIN_EVENT_TABLE(wxFrame, wxFrameBase) |
90 | EVT_ACTIVATE(wxFrame::OnActivate) | |
91 | EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged) | |
4bb6408c JS |
92 | END_EVENT_TABLE() |
93 | ||
88793548 | 94 | IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow) |
4bb6408c | 95 | |
1c4f8f8d VZ |
96 | // ============================================================================ |
97 | // implementation | |
98 | // ============================================================================ | |
1ccbb61a | 99 | |
1c4f8f8d VZ |
100 | // ---------------------------------------------------------------------------- |
101 | // frame construction | |
102 | // ---------------------------------------------------------------------------- | |
dfe1eee3 | 103 | |
1c4f8f8d VZ |
104 | void wxFrame::Init() |
105 | { | |
96be256b | 106 | m_iconized = false; |
dfe1eee3 | 107 | |
4bb6408c JS |
108 | //// Motif-specific |
109 | m_frameShell = (WXWidget) NULL; | |
d0ee33f5 WS |
110 | m_mainWidget = (WXWidget) NULL; |
111 | m_workArea = (WXWidget) NULL; | |
112 | m_clientArea = (WXWidget) NULL; | |
4bb6408c JS |
113 | } |
114 | ||
115 | bool wxFrame::Create(wxWindow *parent, | |
2d120f83 JS |
116 | wxWindowID id, |
117 | const wxString& title, | |
118 | const wxPoint& pos, | |
119 | const wxSize& size, | |
120 | long style, | |
121 | const wxString& name) | |
4bb6408c | 122 | { |
798a4529 MB |
123 | if( !wxTopLevelWindow::Create( parent, id, title, pos, size, style, |
124 | name ) ) | |
96be256b | 125 | return false; |
dfe1eee3 | 126 | |
447a039f MB |
127 | int x = pos.x, y = pos.y; |
128 | int width = size.x, height = size.y; | |
da8bed9b VZ |
129 | |
130 | // Set reasonable values for position and size if defaults have been | |
131 | // requested | |
447a039f | 132 | // |
da8bed9b VZ |
133 | // MB TODO: something better than these arbitrary values ? |
134 | // VZ should use X resources for this... | |
135 | if ( width == -1 ) | |
136 | width = 400; | |
137 | if ( height == -1 ) | |
138 | height = 400; | |
447a039f MB |
139 | |
140 | int displayW, displayH; | |
141 | wxDisplaySize( &displayW, &displayH ); | |
142 | ||
143 | if ( x == -1 ) | |
144 | { | |
145 | x = (displayW - width) / 2; | |
146 | if (x < 10) x = 10; | |
147 | } | |
148 | if ( y == -1 ) | |
149 | { | |
150 | y = (displayH - height) / 2; | |
da8bed9b | 151 | if (y < 10) y = 10; |
447a039f | 152 | } |
da8bed9b | 153 | |
798a4529 MB |
154 | SetTitle( title ); |
155 | ||
156 | wxLogTrace(wxTRACE_Messages, | |
1bc822df MB |
157 | "Created frame (0x%p) with work area 0x%p and client " |
158 | "area 0x%p", m_mainWidget, m_workArea, m_clientArea); | |
798a4529 | 159 | |
96be256b | 160 | XtAddEventHandler((Widget) m_clientArea, ExposureMask,False, |
798a4529 MB |
161 | wxUniversalRepaintProc, (XtPointer) this); |
162 | ||
163 | if (x > -1) | |
164 | XtVaSetValues((Widget) m_frameShell, XmNx, x, NULL); | |
165 | if (y > -1) | |
166 | XtVaSetValues((Widget) m_frameShell, XmNy, y, NULL); | |
167 | if (width > -1) | |
168 | XtVaSetValues((Widget) m_frameShell, XmNwidth, width, NULL); | |
169 | if (height > -1) | |
170 | XtVaSetValues((Widget) m_frameShell, XmNheight, height, NULL); | |
171 | ||
105fbe1f | 172 | PostCreation(); |
798a4529 MB |
173 | PreResize(); |
174 | ||
355b4d3d WS |
175 | wxSize newSize(width, height); |
176 | wxSizeEvent sizeEvent(newSize, GetId()); | |
798a4529 MB |
177 | sizeEvent.SetEventObject(this); |
178 | ||
937013e0 | 179 | HandleWindowEvent(sizeEvent); |
798a4529 | 180 | |
96be256b | 181 | return true; |
798a4529 MB |
182 | } |
183 | ||
355b4d3d WS |
184 | bool wxFrame::XmDoCreateTLW(wxWindow* WXUNUSED(parent), |
185 | wxWindowID WXUNUSED(id), | |
186 | const wxString& WXUNUSED(title), | |
187 | const wxPoint& WXUNUSED(pos), | |
188 | const wxSize& WXUNUSED(size), | |
f58585c0 VZ |
189 | long style, |
190 | const wxString& name) | |
798a4529 | 191 | { |
eb6fa4b4 | 192 | Widget frameShell; |
798a4529 | 193 | |
eb6fa4b4 MB |
194 | frameShell = XtCreatePopupShell( name, topLevelShellWidgetClass, |
195 | (Widget)wxTheApp->GetTopLevelWidget(), | |
196 | NULL, 0 ); | |
dfe1eee3 | 197 | |
eb6fa4b4 | 198 | XtVaSetValues(frameShell, |
2d120f83 JS |
199 | // Allows menu to resize |
200 | XmNallowShellResize, True, | |
201 | XmNdeleteResponse, XmDO_NOTHING, | |
202 | XmNmappedWhenManaged, False, | |
96be256b | 203 | XmNiconic, (style & wxICONIZE) ? True : False, |
2d120f83 | 204 | NULL); |
dfe1eee3 | 205 | |
eb6fa4b4 | 206 | m_frameShell = (WXWidget)frameShell; |
dfe1eee3 | 207 | |
798a4529 | 208 | m_mainWidget = (WXWidget) XtVaCreateManagedWidget("main_window", |
eb6fa4b4 | 209 | xmMainWindowWidgetClass, frameShell, |
2d120f83 JS |
210 | XmNresizePolicy, XmRESIZE_NONE, |
211 | NULL); | |
dfe1eee3 | 212 | |
2d120f83 | 213 | m_workArea = (WXWidget) XtVaCreateWidget("form", |
798a4529 | 214 | xmFormWidgetClass, (Widget) m_mainWidget, |
2d120f83 JS |
215 | XmNresizePolicy, XmRESIZE_NONE, |
216 | NULL); | |
dfe1eee3 | 217 | |
2d120f83 JS |
218 | m_clientArea = (WXWidget) XtVaCreateWidget("client", |
219 | xmBulletinBoardWidgetClass, (Widget) m_workArea, | |
220 | XmNmarginWidth, 0, | |
221 | XmNmarginHeight, 0, | |
222 | XmNrightAttachment, XmATTACH_FORM, | |
223 | XmNleftAttachment, XmATTACH_FORM, | |
224 | XmNtopAttachment, XmATTACH_FORM, | |
225 | XmNbottomAttachment, XmATTACH_FORM, | |
2d120f83 | 226 | NULL); |
0492c5a0 | 227 | |
798a4529 | 228 | XtVaSetValues((Widget) m_mainWidget, |
2d120f83 JS |
229 | XmNworkWindow, (Widget) m_workArea, |
230 | NULL); | |
dfe1eee3 | 231 | |
2d120f83 JS |
232 | XtManageChild((Widget) m_clientArea); |
233 | XtManageChild((Widget) m_workArea); | |
dfe1eee3 | 234 | |
798a4529 MB |
235 | XtTranslations ptr = XtParseTranslationTable( "<Configure>: resize()" ); |
236 | XtOverrideTranslations( (Widget) m_workArea, ptr ); | |
237 | XtFree( (char *)ptr ); | |
dfe1eee3 | 238 | |
2d120f83 | 239 | /* Part of show-&-hide fix */ |
eb6fa4b4 | 240 | XtAddEventHandler( frameShell, StructureNotifyMask, |
798a4529 MB |
241 | False, (XtEventHandler)wxFrameMapProc, |
242 | (XtPointer)this ); | |
dfe1eee3 | 243 | |
eb6fa4b4 | 244 | XtRealizeWidget(frameShell); |
dfe1eee3 | 245 | |
798a4529 MB |
246 | wxAddWindowToTable( (Widget)m_workArea, this); |
247 | wxAddWindowToTable( (Widget)m_clientArea, this); | |
dfe1eee3 | 248 | |
798a4529 | 249 | wxModelessWindows.Append( this ); |
dfe1eee3 | 250 | |
96be256b | 251 | return true; |
4bb6408c JS |
252 | } |
253 | ||
254 | wxFrame::~wxFrame() | |
255 | { | |
c6212a0c | 256 | SendDestroyEvent(); |
da8bed9b | 257 | |
2e35f56f | 258 | if (m_clientArea) |
dc1efb1d | 259 | { |
96be256b | 260 | XtRemoveEventHandler((Widget) m_clientArea, ExposureMask, False, |
2e35f56f | 261 | wxUniversalRepaintProc, (XtPointer) this); |
dc1efb1d | 262 | } |
2e35f56f | 263 | |
2d120f83 | 264 | if (GetMainWidget()) |
96be256b | 265 | Show(false); |
0492c5a0 | 266 | |
2d120f83 JS |
267 | if (m_frameMenuBar) |
268 | { | |
269 | m_frameMenuBar->DestroyMenuBar(); | |
5276b0a5 | 270 | wxDELETE(m_frameMenuBar); |
2d120f83 | 271 | } |
dfe1eee3 | 272 | |
5276b0a5 | 273 | wxDELETE(m_frameStatusBar); |
2187eef5 MB |
274 | |
275 | PreDestroy(); | |
dfe1eee3 | 276 | |
798a4529 | 277 | Widget frameShell = (Widget)GetShellWidget(); |
2b5f62a0 | 278 | |
2187eef5 MB |
279 | if( frameShell ) |
280 | XtRemoveEventHandler( frameShell, StructureNotifyMask, | |
281 | False, (XtEventHandler)wxFrameMapProc, | |
282 | (XtPointer)this ); | |
dfe1eee3 | 283 | |
798a4529 | 284 | if( m_clientArea ) |
4bb6408c | 285 | { |
798a4529 MB |
286 | wxDeleteWindowFromTable( (Widget)m_clientArea ); |
287 | XtDestroyWidget( (Widget)m_clientArea ); | |
4bb6408c | 288 | } |
dfe1eee3 | 289 | |
798a4529 | 290 | if( m_workArea ) |
2d120f83 | 291 | { |
798a4529 MB |
292 | XtVaSetValues( (Widget)m_mainWidget, |
293 | XmNworkWindow, (Widget)NULL, | |
294 | NULL ); | |
dfe1eee3 | 295 | |
798a4529 MB |
296 | wxDeleteWindowFromTable( (Widget)m_workArea ); |
297 | XtDestroyWidget( (Widget)m_workArea ); | |
298 | } | |
dfe1eee3 | 299 | |
798a4529 MB |
300 | if( m_mainWidget ) |
301 | XtDestroyWidget( (Widget)m_mainWidget ); | |
dfe1eee3 | 302 | |
798a4529 MB |
303 | if( frameShell ) |
304 | XtDestroyWidget( frameShell ); | |
4bb6408c JS |
305 | } |
306 | ||
307 | // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc. | |
449f38b5 | 308 | void wxFrame::DoGetClientSize(int *x, int *y) const |
4bb6408c | 309 | { |
2d120f83 JS |
310 | Dimension xx, yy; |
311 | XtVaGetValues((Widget) m_workArea, XmNwidth, &xx, XmNheight, &yy, NULL); | |
dfe1eee3 | 312 | |
2d120f83 JS |
313 | if (m_frameStatusBar) |
314 | { | |
315 | int sbw, sbh; | |
316 | m_frameStatusBar->GetSize(& sbw, & sbh); | |
355b4d3d | 317 | yy = (Dimension)(yy - sbh); |
2d120f83 | 318 | } |
1ccbb61a | 319 | #if wxUSE_TOOLBAR |
2d120f83 JS |
320 | if (m_frameToolBar) |
321 | { | |
322 | int tbw, tbh; | |
323 | m_frameToolBar->GetSize(& tbw, & tbh); | |
324 | if (m_frameToolBar->GetWindowStyleFlag() & wxTB_VERTICAL) | |
355b4d3d | 325 | xx = (Dimension)(xx - tbw); |
2d120f83 | 326 | else |
355b4d3d | 327 | yy = (Dimension)(yy - tbh); |
2d120f83 | 328 | } |
1ccbb61a | 329 | #endif // wxUSE_TOOLBAR |
34e8f097 CE |
330 | |
331 | //CE found a call here with NULL y pointer | |
332 | if (x) | |
d0ee33f5 | 333 | *x = xx; |
34e8f097 CE |
334 | if (y) |
335 | *y = yy; | |
4bb6408c JS |
336 | } |
337 | ||
338 | // Set the client size (i.e. leave the calculation of borders etc. | |
77ffb593 | 339 | // to wxWidgets) |
bfc6fde4 | 340 | void wxFrame::DoSetClientSize(int width, int height) |
4bb6408c | 341 | { |
2d120f83 JS |
342 | // Calculate how large the new main window should be |
343 | // by finding the difference between the client area and the | |
344 | // main window area, and adding on to the new client area | |
345 | if (width > -1) | |
346 | XtVaSetValues((Widget) m_workArea, XmNwidth, width, NULL); | |
dfe1eee3 | 347 | |
2d120f83 | 348 | if (height > -1) |
a4294b78 | 349 | { |
2d120f83 JS |
350 | if (m_frameStatusBar) |
351 | { | |
352 | int sbw, sbh; | |
353 | m_frameStatusBar->GetSize(& sbw, & sbh); | |
354 | height += sbh; | |
355 | } | |
1ccbb61a | 356 | #if wxUSE_TOOLBAR |
2d120f83 JS |
357 | if (m_frameToolBar) |
358 | { | |
359 | int tbw, tbh; | |
360 | m_frameToolBar->GetSize(& tbw, & tbh); | |
361 | if (m_frameToolBar->GetWindowStyleFlag() & wxTB_VERTICAL) | |
362 | width += tbw; | |
363 | else | |
364 | height += tbh; | |
365 | } | |
1ccbb61a | 366 | #endif // wxUSE_TOOLBAR |
dfe1eee3 | 367 | |
2d120f83 | 368 | XtVaSetValues((Widget) m_workArea, XmNheight, height, NULL); |
a4294b78 | 369 | } |
2d120f83 | 370 | PreResize(); |
dfe1eee3 | 371 | |
355b4d3d WS |
372 | wxSize newSize(width, height); |
373 | wxSizeEvent sizeEvent(newSize, GetId()); | |
2d120f83 | 374 | sizeEvent.SetEventObject(this); |
dfe1eee3 | 375 | |
937013e0 | 376 | HandleWindowEvent(sizeEvent); |
dfe1eee3 | 377 | |
4bb6408c JS |
378 | } |
379 | ||
449f38b5 | 380 | void wxFrame::DoGetSize(int *width, int *height) const |
4bb6408c | 381 | { |
105fbe1f MB |
382 | if (!m_frameShell) |
383 | { | |
384 | *width = -1; *height = -1; | |
385 | return; | |
386 | } | |
387 | ||
2d120f83 JS |
388 | Dimension xx, yy; |
389 | XtVaGetValues((Widget) m_frameShell, XmNwidth, &xx, XmNheight, &yy, NULL); | |
390 | *width = xx; *height = yy; | |
4bb6408c JS |
391 | } |
392 | ||
af111fc3 | 393 | void wxFrame::DoSetSize(int x, int y, int width, int height, int WXUNUSED(sizeFlags)) |
4bb6408c | 394 | { |
2d120f83 JS |
395 | if (x > -1) |
396 | XtVaSetValues((Widget) m_frameShell, XmNx, x, NULL); | |
397 | if (y > -1) | |
398 | XtVaSetValues((Widget) m_frameShell, XmNy, y, NULL); | |
399 | if (width > -1) | |
798a4529 | 400 | XtVaSetValues((Widget) m_mainWidget, XmNwidth, width, NULL); |
2d120f83 | 401 | if (height > -1) |
798a4529 | 402 | XtVaSetValues((Widget) m_mainWidget, XmNheight, height, NULL); |
dfe1eee3 | 403 | |
2d120f83 JS |
404 | if (!(height == -1 && width == -1)) |
405 | { | |
406 | PreResize(); | |
2d120f83 | 407 | } |
4bb6408c JS |
408 | } |
409 | ||
798a4529 | 410 | bool wxFrame::Show( bool show ) |
4bb6408c | 411 | { |
5a2e3d8c MB |
412 | if( !wxWindowBase::Show( show ) ) |
413 | return false; | |
dfe1eee3 | 414 | |
2d120f83 | 415 | m_isShown = show; |
1c4f8f8d | 416 | |
798a4529 MB |
417 | Widget shell = (Widget)GetShellWidget(); |
418 | if (!shell) | |
419 | return wxWindow::Show(show); | |
dfe1eee3 | 420 | |
798a4529 MB |
421 | SetVisibleStatus(show); |
422 | if (show) | |
423 | { | |
5a2e3d8c | 424 | XtPopup(shell, XtGrabNone); |
798a4529 MB |
425 | } |
426 | else | |
427 | { | |
5a2e3d8c | 428 | XtPopdown(shell); |
798a4529 | 429 | } |
4bb6408c | 430 | |
5a2e3d8c | 431 | return true; |
6f63ec3f JS |
432 | } |
433 | ||
4bb6408c JS |
434 | void wxFrame::SetTitle(const wxString& title) |
435 | { | |
798a4529 MB |
436 | wxString oldTitle = GetTitle(); |
437 | if( title == oldTitle ) | |
2d120f83 | 438 | return; |
dfe1eee3 | 439 | |
798a4529 | 440 | wxTopLevelWindow::SetTitle( title ); |
dfe1eee3 | 441 | |
798a4529 MB |
442 | if( !title.empty() ) |
443 | XtVaSetValues( (Widget)m_frameShell, | |
6991087b VS |
444 | XmNtitle, (const char*)title.mb_str(), |
445 | XmNiconName, (const char*)title.mb_str(), | |
798a4529 | 446 | NULL ); |
4bb6408c JS |
447 | } |
448 | ||
f618020a | 449 | void wxFrame::DoSetIcon(const wxIcon& icon) |
4bb6408c | 450 | { |
2d120f83 JS |
451 | if (!m_frameShell) |
452 | return; | |
dfe1eee3 | 453 | |
aae0472b | 454 | if (!icon.Ok() || !icon.GetDrawable()) |
2d120f83 | 455 | return; |
dfe1eee3 | 456 | |
aae0472b MB |
457 | XtVaSetValues((Widget) m_frameShell, |
458 | XtNiconPixmap, icon.GetDrawable(), | |
459 | NULL); | |
4bb6408c JS |
460 | } |
461 | ||
f618020a MB |
462 | void wxFrame::SetIcons(const wxIconBundle& icons) |
463 | { | |
464 | wxFrameBase::SetIcons( icons ); | |
465 | ||
466 | if (!m_frameShell) | |
467 | return; | |
468 | ||
469 | DoSetIcon( m_icons.GetIcon( -1 ) ); | |
470 | wxSetIconsX11(GetXDisplay(), | |
471 | (WXWindow) XtWindow( (Widget) m_frameShell ), icons); | |
472 | } | |
473 | ||
4bb6408c JS |
474 | void wxFrame::PositionStatusBar() |
475 | { | |
50414e24 | 476 | if (!m_frameStatusBar) |
2d120f83 | 477 | return; |
dfe1eee3 | 478 | |
4bb6408c JS |
479 | int w, h; |
480 | GetClientSize(&w, &h); | |
481 | int sw, sh; | |
482 | m_frameStatusBar->GetSize(&sw, &sh); | |
dfe1eee3 | 483 | |
4bb6408c JS |
484 | // Since we wish the status bar to be directly under the client area, |
485 | // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS. | |
89c7e962 | 486 | m_frameStatusBar->SetSize(0, h, w, sh); |
4bb6408c JS |
487 | } |
488 | ||
489 | WXWidget wxFrame::GetMenuBarWidget() const | |
490 | { | |
2d120f83 JS |
491 | if (GetMenuBar()) |
492 | return GetMenuBar()->GetMainWidget(); | |
493 | else | |
494 | return (WXWidget) NULL; | |
4bb6408c JS |
495 | } |
496 | ||
497 | void wxFrame::SetMenuBar(wxMenuBar *menuBar) | |
498 | { | |
499 | if (!menuBar) | |
500 | { | |
501 | m_frameMenuBar = NULL; | |
502 | return; | |
503 | } | |
dfe1eee3 | 504 | |
4bb6408c | 505 | // Currently can't set it twice |
d3b9f782 | 506 | // wxASSERT_MSG( (m_frameMenuBar == NULL), "Cannot set the menubar more than once"); |
dfe1eee3 | 507 | |
621793f4 | 508 | if (m_frameMenuBar) |
4bb6408c | 509 | { |
621793f4 JS |
510 | m_frameMenuBar->DestroyMenuBar(); |
511 | delete m_frameMenuBar; | |
4bb6408c | 512 | } |
dfe1eee3 | 513 | |
621793f4 JS |
514 | m_frameMenuBar = menuBar; |
515 | m_frameMenuBar->CreateMenuBar(this); | |
4bb6408c JS |
516 | } |
517 | ||
4bb6408c JS |
518 | // Responds to colour changes, and passes event on to children. |
519 | void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event) | |
520 | { | |
a756f210 | 521 | SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE)); |
4bb6408c | 522 | Refresh(); |
dfe1eee3 | 523 | |
4bb6408c JS |
524 | if ( m_frameStatusBar ) |
525 | { | |
526 | wxSysColourChangedEvent event2; | |
527 | event2.SetEventObject( m_frameStatusBar ); | |
937013e0 | 528 | m_frameStatusBar->HandleWindowEvent(event2); |
4bb6408c | 529 | } |
dfe1eee3 | 530 | |
4bb6408c JS |
531 | // Propagate the event to the non-top-level children |
532 | wxWindow::OnSysColourChanged(event); | |
533 | } | |
534 | ||
4bb6408c JS |
535 | // Default activation behaviour - set the focus for the first child |
536 | // subwindow found. | |
537 | void wxFrame::OnActivate(wxActivateEvent& event) | |
538 | { | |
af111fc3 JS |
539 | if (!event.GetActive()) |
540 | return; | |
541 | ||
ac32ba44 | 542 | for(wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); node; |
fd304d98 | 543 | node = node->GetNext()) |
4bb6408c | 544 | { |
2d120f83 | 545 | // Find a child that's a subwindow, but not a dialog box. |
fd304d98 | 546 | wxWindow *child = node->GetData(); |
798a4529 | 547 | if (!child->IsTopLevel()) |
2d120f83 JS |
548 | { |
549 | child->SetFocus(); | |
550 | return; | |
551 | } | |
4bb6408c | 552 | } |
4bb6408c JS |
553 | } |
554 | ||
1ccbb61a | 555 | #if wxUSE_TOOLBAR |
dfe1eee3 | 556 | |
1c4f8f8d VZ |
557 | wxToolBar* wxFrame::CreateToolBar(long style, |
558 | wxWindowID id, | |
559 | const wxString& name) | |
4bb6408c | 560 | { |
1c4f8f8d | 561 | if ( wxFrameBase::CreateToolBar(style, id, name) ) |
4bb6408c | 562 | { |
4bb6408c | 563 | PositionToolBar(); |
4bb6408c | 564 | } |
4bb6408c | 565 | |
1ccbb61a VZ |
566 | return m_frameToolBar; |
567 | } | |
568 | ||
46675b46 MB |
569 | void wxFrame::SetToolBar(wxToolBar *toolbar) |
570 | { | |
571 | wxFrameBase::SetToolBar(toolbar); | |
572 | SendSizeEvent(); | |
573 | } | |
574 | ||
4bb6408c JS |
575 | void wxFrame::PositionToolBar() |
576 | { | |
798a4529 MB |
577 | wxToolBar* tb = GetToolBar(); |
578 | if (tb) | |
4bb6408c | 579 | { |
1c4f8f8d VZ |
580 | int cw, ch; |
581 | GetClientSize(& cw, &ch); | |
582 | ||
4bb6408c | 583 | int tw, th; |
798a4529 | 584 | tb->GetSize(& tw, & th); |
dfe1eee3 | 585 | |
798a4529 | 586 | if (tb->GetWindowStyleFlag() & wxTB_VERTICAL) |
4bb6408c JS |
587 | { |
588 | // Use the 'real' position. wxSIZE_NO_ADJUSTMENTS | |
589 | // means, pretend we don't have toolbar/status bar, so we | |
590 | // have the original client size. | |
798a4529 | 591 | th = ch + th; |
4bb6408c JS |
592 | } |
593 | else | |
594 | { | |
595 | // Use the 'real' position | |
798a4529 | 596 | tw = cw; |
4bb6408c | 597 | } |
4bb6408c | 598 | |
aae91497 | 599 | tb->SetSize(0, 0, -1, -1, wxSIZE_NO_ADJUSTMENTS); |
4bb6408c | 600 | } |
4bb6408c | 601 | } |
798a4529 | 602 | #endif // wxUSE_TOOLBAR |
4bb6408c JS |
603 | |
604 | //// Motif-specific | |
605 | bool wxFrame::PreResize() | |
606 | { | |
1ccbb61a | 607 | #if wxUSE_TOOLBAR |
2d120f83 | 608 | PositionToolBar(); |
1ccbb61a | 609 | #endif // wxUSE_TOOLBAR |
1c4f8f8d VZ |
610 | |
611 | #if wxUSE_STATUSBAR | |
2d120f83 | 612 | PositionStatusBar(); |
1c4f8f8d VZ |
613 | #endif // wxUSE_STATUSBAR |
614 | ||
96be256b | 615 | return true; |
4bb6408c JS |
616 | } |
617 | ||
50414e24 JS |
618 | WXWidget wxFrame::GetClientWidget() const |
619 | { | |
2d120f83 | 620 | return m_clientArea; |
50414e24 JS |
621 | } |
622 | ||
af111fc3 | 623 | void wxFrame::ChangeFont(bool WXUNUSED(keepOriginalSize)) |
0d57be45 JS |
624 | { |
625 | // TODO | |
626 | } | |
627 | ||
628 | void wxFrame::ChangeBackgroundColour() | |
629 | { | |
621793f4 | 630 | if (GetClientWidget()) |
a8680e3e | 631 | wxDoChangeBackgroundColour(GetClientWidget(), m_backgroundColour); |
0d57be45 JS |
632 | } |
633 | ||
634 | void wxFrame::ChangeForegroundColour() | |
635 | { | |
621793f4 | 636 | if (GetClientWidget()) |
a8680e3e | 637 | wxDoChangeForegroundColour(GetClientWidget(), m_foregroundColour); |
0d57be45 JS |
638 | } |
639 | ||
798a4529 MB |
640 | /* MATTEW: Used to insure that hide-&-show within an event cycle works */ |
641 | static void wxFrameMapProc( Widget frameShell, XtPointer clientData, | |
642 | XCrossingEvent* event ) | |
4bb6408c | 643 | { |
798a4529 | 644 | wxFrame *tli = (wxFrame*)clientData; |
dfe1eee3 | 645 | |
798a4529 | 646 | XEvent *e = (XEvent *)event; |
dfe1eee3 | 647 | |
798a4529 | 648 | if( e->xany.type == MapNotify ) |
dc1efb1d | 649 | { |
798a4529 MB |
650 | // Iconize fix |
651 | XtVaSetValues( frameShell, XmNiconic, (Boolean)False, NULL ); | |
652 | if( !tli->GetVisibleStatus() ) | |
dc1efb1d | 653 | { |
798a4529 MB |
654 | /* We really wanted this to be hidden! */ |
655 | XtUnmapWidget( frameShell ); | |
dc1efb1d JS |
656 | } |
657 | } | |
798a4529 MB |
658 | else if( e->xany.type == UnmapNotify ) |
659 | // Iconize fix | |
660 | XtVaSetValues( frameShell, XmNiconic, (Boolean)True, NULL ); | |
dc1efb1d | 661 | } |