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