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