]> git.saurik.com Git - wxWidgets.git/blame - src/motif/frame.cpp
Simplify wxWinCE #ifdefs.
[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"
e4db172a
WS
30
31#ifndef WX_PRECOMP
32 #include "wx/log.h"
33#endif
34
4bb6408c
JS
35#include "wx/statusbr.h"
36#include "wx/toolbar.h"
4bb6408c 37#include "wx/menu.h"
4bb6408c 38#include "wx/settings.h"
4bb6408c 39#include "wx/utils.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{
96be256b 114 m_iconized = false;
dfe1eee3 115
4bb6408c
JS
116 //// Motif-specific
117 m_frameShell = (WXWidget) NULL;
d0ee33f5
WS
118 m_mainWidget = (WXWidget) NULL;
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 ) )
96be256b 133 return false;
dfe1eee3 134
d0ee33f5 135 m_backgroundColour =
798a4529 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 172
96be256b 173 XtAddEventHandler((Widget) m_clientArea, ExposureMask,False,
798a4529
MB
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
96be256b 185 ChangeFont(false);
798a4529
MB
186
187 ChangeBackgroundColour();
188
189 PreResize();
190
355b4d3d
WS
191 wxSize newSize(width, height);
192 wxSizeEvent sizeEvent(newSize, GetId());
798a4529
MB
193 sizeEvent.SetEventObject(this);
194
195 GetEventHandler()->ProcessEvent(sizeEvent);
196
96be256b 197 return true;
798a4529
MB
198}
199
355b4d3d
WS
200bool wxFrame::XmDoCreateTLW(wxWindow* WXUNUSED(parent),
201 wxWindowID WXUNUSED(id),
202 const wxString& WXUNUSED(title),
203 const wxPoint& WXUNUSED(pos),
204 const wxSize& WXUNUSED(size),
f58585c0
VZ
205 long style,
206 const wxString& name)
798a4529 207{
eb6fa4b4 208 Widget frameShell;
798a4529 209
eb6fa4b4
MB
210 frameShell = XtCreatePopupShell( name, topLevelShellWidgetClass,
211 (Widget)wxTheApp->GetTopLevelWidget(),
212 NULL, 0 );
dfe1eee3 213
eb6fa4b4 214 XtVaSetValues(frameShell,
2d120f83
JS
215 // Allows menu to resize
216 XmNallowShellResize, True,
217 XmNdeleteResponse, XmDO_NOTHING,
218 XmNmappedWhenManaged, False,
96be256b 219 XmNiconic, (style & wxICONIZE) ? True : False,
2d120f83 220 NULL);
dfe1eee3 221
eb6fa4b4 222 m_frameShell = (WXWidget)frameShell;
dfe1eee3 223
798a4529 224 m_mainWidget = (WXWidget) XtVaCreateManagedWidget("main_window",
eb6fa4b4 225 xmMainWindowWidgetClass, frameShell,
2d120f83
JS
226 XmNresizePolicy, XmRESIZE_NONE,
227 NULL);
dfe1eee3 228
2d120f83 229 m_workArea = (WXWidget) XtVaCreateWidget("form",
798a4529 230 xmFormWidgetClass, (Widget) m_mainWidget,
2d120f83
JS
231 XmNresizePolicy, XmRESIZE_NONE,
232 NULL);
dfe1eee3 233
2d120f83
JS
234 m_clientArea = (WXWidget) XtVaCreateWidget("client",
235 xmBulletinBoardWidgetClass, (Widget) m_workArea,
236 XmNmarginWidth, 0,
237 XmNmarginHeight, 0,
238 XmNrightAttachment, XmATTACH_FORM,
239 XmNleftAttachment, XmATTACH_FORM,
240 XmNtopAttachment, XmATTACH_FORM,
241 XmNbottomAttachment, XmATTACH_FORM,
2d120f83 242 NULL);
0492c5a0 243
798a4529 244 XtVaSetValues((Widget) m_mainWidget,
2d120f83
JS
245 XmNworkWindow, (Widget) m_workArea,
246 NULL);
dfe1eee3 247
2d120f83
JS
248 XtManageChild((Widget) m_clientArea);
249 XtManageChild((Widget) m_workArea);
dfe1eee3 250
798a4529
MB
251 XtTranslations ptr = XtParseTranslationTable( "<Configure>: resize()" );
252 XtOverrideTranslations( (Widget) m_workArea, ptr );
253 XtFree( (char *)ptr );
dfe1eee3 254
2d120f83 255 /* Part of show-&-hide fix */
eb6fa4b4 256 XtAddEventHandler( frameShell, StructureNotifyMask,
798a4529
MB
257 False, (XtEventHandler)wxFrameMapProc,
258 (XtPointer)this );
dfe1eee3 259
eb6fa4b4 260 XtRealizeWidget(frameShell);
dfe1eee3 261
798a4529
MB
262 wxAddWindowToTable( (Widget)m_workArea, this);
263 wxAddWindowToTable( (Widget)m_clientArea, this);
dfe1eee3 264
798a4529 265 wxModelessWindows.Append( this );
dfe1eee3 266
96be256b 267 return true;
4bb6408c
JS
268}
269
270wxFrame::~wxFrame()
271{
96be256b 272 m_isBeingDeleted = true;
da8bed9b 273
2e35f56f 274 if (m_clientArea)
dc1efb1d 275 {
96be256b 276 XtRemoveEventHandler((Widget) m_clientArea, ExposureMask, False,
2e35f56f 277 wxUniversalRepaintProc, (XtPointer) this);
dc1efb1d 278 }
2e35f56f 279
2d120f83 280 if (GetMainWidget())
96be256b 281 Show(false);
0492c5a0 282
2d120f83
JS
283 if (m_frameMenuBar)
284 {
285 m_frameMenuBar->DestroyMenuBar();
2d120f83
JS
286 delete m_frameMenuBar;
287 m_frameMenuBar = NULL;
288 }
dfe1eee3 289
2d120f83 290 if (m_frameStatusBar)
1c4f8f8d 291 {
2d120f83 292 delete m_frameStatusBar;
1c4f8f8d
VZ
293 m_frameStatusBar = NULL;
294 }
2187eef5
MB
295
296 PreDestroy();
dfe1eee3 297
798a4529 298 Widget frameShell = (Widget)GetShellWidget();
2b5f62a0 299
2187eef5
MB
300 if( frameShell )
301 XtRemoveEventHandler( frameShell, StructureNotifyMask,
302 False, (XtEventHandler)wxFrameMapProc,
303 (XtPointer)this );
dfe1eee3 304
798a4529 305 if( m_clientArea )
4bb6408c 306 {
798a4529
MB
307 wxDeleteWindowFromTable( (Widget)m_clientArea );
308 XtDestroyWidget( (Widget)m_clientArea );
4bb6408c 309 }
dfe1eee3 310
798a4529 311 if( m_workArea )
2d120f83 312 {
798a4529
MB
313 XtVaSetValues( (Widget)m_mainWidget,
314 XmNworkWindow, (Widget)NULL,
315 NULL );
dfe1eee3 316
798a4529
MB
317 wxDeleteWindowFromTable( (Widget)m_workArea );
318 XtDestroyWidget( (Widget)m_workArea );
319 }
dfe1eee3 320
798a4529
MB
321 if( m_mainWidget )
322 XtDestroyWidget( (Widget)m_mainWidget );
dfe1eee3 323
798a4529
MB
324 if( frameShell )
325 XtDestroyWidget( frameShell );
4bb6408c
JS
326}
327
328// Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
449f38b5 329void wxFrame::DoGetClientSize(int *x, int *y) const
4bb6408c 330{
2d120f83
JS
331 Dimension xx, yy;
332 XtVaGetValues((Widget) m_workArea, XmNwidth, &xx, XmNheight, &yy, NULL);
dfe1eee3 333
2d120f83
JS
334 if (m_frameStatusBar)
335 {
336 int sbw, sbh;
337 m_frameStatusBar->GetSize(& sbw, & sbh);
355b4d3d 338 yy = (Dimension)(yy - sbh);
2d120f83 339 }
1ccbb61a 340#if wxUSE_TOOLBAR
2d120f83
JS
341 if (m_frameToolBar)
342 {
343 int tbw, tbh;
344 m_frameToolBar->GetSize(& tbw, & tbh);
345 if (m_frameToolBar->GetWindowStyleFlag() & wxTB_VERTICAL)
355b4d3d 346 xx = (Dimension)(xx - tbw);
2d120f83 347 else
355b4d3d 348 yy = (Dimension)(yy - tbh);
2d120f83 349 }
1ccbb61a 350#endif // wxUSE_TOOLBAR
34e8f097
CE
351
352//CE found a call here with NULL y pointer
353 if (x)
d0ee33f5 354 *x = xx;
34e8f097
CE
355 if (y)
356 *y = yy;
4bb6408c
JS
357}
358
359// Set the client size (i.e. leave the calculation of borders etc.
77ffb593 360// to wxWidgets)
bfc6fde4 361void wxFrame::DoSetClientSize(int width, int height)
4bb6408c 362{
2d120f83
JS
363 // Calculate how large the new main window should be
364 // by finding the difference between the client area and the
365 // main window area, and adding on to the new client area
366 if (width > -1)
367 XtVaSetValues((Widget) m_workArea, XmNwidth, width, NULL);
dfe1eee3 368
2d120f83 369 if (height > -1)
a4294b78 370 {
2d120f83
JS
371 if (m_frameStatusBar)
372 {
373 int sbw, sbh;
374 m_frameStatusBar->GetSize(& sbw, & sbh);
375 height += sbh;
376 }
1ccbb61a 377#if wxUSE_TOOLBAR
2d120f83
JS
378 if (m_frameToolBar)
379 {
380 int tbw, tbh;
381 m_frameToolBar->GetSize(& tbw, & tbh);
382 if (m_frameToolBar->GetWindowStyleFlag() & wxTB_VERTICAL)
383 width += tbw;
384 else
385 height += tbh;
386 }
1ccbb61a 387#endif // wxUSE_TOOLBAR
dfe1eee3 388
2d120f83 389 XtVaSetValues((Widget) m_workArea, XmNheight, height, NULL);
a4294b78 390 }
2d120f83 391 PreResize();
dfe1eee3 392
355b4d3d
WS
393 wxSize newSize(width, height);
394 wxSizeEvent sizeEvent(newSize, GetId());
2d120f83 395 sizeEvent.SetEventObject(this);
dfe1eee3 396
2d120f83 397 GetEventHandler()->ProcessEvent(sizeEvent);
dfe1eee3 398
4bb6408c
JS
399}
400
449f38b5 401void wxFrame::DoGetSize(int *width, int *height) const
4bb6408c 402{
2d120f83
JS
403 Dimension xx, yy;
404 XtVaGetValues((Widget) m_frameShell, XmNwidth, &xx, XmNheight, &yy, NULL);
405 *width = xx; *height = yy;
4bb6408c
JS
406}
407
af111fc3 408void wxFrame::DoSetSize(int x, int y, int width, int height, int WXUNUSED(sizeFlags))
4bb6408c 409{
2d120f83
JS
410 if (x > -1)
411 XtVaSetValues((Widget) m_frameShell, XmNx, x, NULL);
412 if (y > -1)
413 XtVaSetValues((Widget) m_frameShell, XmNy, y, NULL);
414 if (width > -1)
798a4529 415 XtVaSetValues((Widget) m_mainWidget, XmNwidth, width, NULL);
2d120f83 416 if (height > -1)
798a4529 417 XtVaSetValues((Widget) m_mainWidget, XmNheight, height, NULL);
dfe1eee3 418
2d120f83
JS
419 if (!(height == -1 && width == -1))
420 {
421 PreResize();
2d120f83 422 }
4bb6408c
JS
423}
424
798a4529 425bool wxFrame::Show( bool show )
4bb6408c 426{
5a2e3d8c
MB
427 if( !wxWindowBase::Show( show ) )
428 return false;
dfe1eee3 429
2d120f83 430 m_isShown = show;
1c4f8f8d 431
798a4529
MB
432 Widget shell = (Widget)GetShellWidget();
433 if (!shell)
434 return wxWindow::Show(show);
dfe1eee3 435
798a4529
MB
436 SetVisibleStatus(show);
437 if (show)
438 {
5a2e3d8c 439 XtPopup(shell, XtGrabNone);
798a4529
MB
440 }
441 else
442 {
5a2e3d8c 443 XtPopdown(shell);
798a4529 444 }
4bb6408c 445
5a2e3d8c 446 return true;
6f63ec3f
JS
447}
448
4bb6408c
JS
449void wxFrame::SetTitle(const wxString& title)
450{
798a4529
MB
451 wxString oldTitle = GetTitle();
452 if( title == oldTitle )
2d120f83 453 return;
dfe1eee3 454
798a4529 455 wxTopLevelWindow::SetTitle( title );
dfe1eee3 456
798a4529
MB
457 if( !title.empty() )
458 XtVaSetValues( (Widget)m_frameShell,
459 XmNtitle, title.c_str(),
460 XmNiconName, title.c_str(),
461 NULL );
4bb6408c
JS
462}
463
f618020a 464void wxFrame::DoSetIcon(const wxIcon& icon)
4bb6408c 465{
2d120f83
JS
466 if (!m_frameShell)
467 return;
dfe1eee3 468
aae0472b 469 if (!icon.Ok() || !icon.GetDrawable())
2d120f83 470 return;
dfe1eee3 471
aae0472b
MB
472 XtVaSetValues((Widget) m_frameShell,
473 XtNiconPixmap, icon.GetDrawable(),
474 NULL);
4bb6408c
JS
475}
476
f618020a
MB
477void wxFrame::SetIcon(const wxIcon& icon)
478{
479 SetIcons( wxIconBundle( icon ) );
480}
481
482void wxFrame::SetIcons(const wxIconBundle& icons)
483{
484 wxFrameBase::SetIcons( icons );
485
486 if (!m_frameShell)
487 return;
488
489 DoSetIcon( m_icons.GetIcon( -1 ) );
490 wxSetIconsX11(GetXDisplay(),
491 (WXWindow) XtWindow( (Widget) m_frameShell ), icons);
492}
493
4bb6408c
JS
494void wxFrame::PositionStatusBar()
495{
50414e24 496 if (!m_frameStatusBar)
2d120f83 497 return;
dfe1eee3 498
4bb6408c
JS
499 int w, h;
500 GetClientSize(&w, &h);
501 int sw, sh;
502 m_frameStatusBar->GetSize(&sw, &sh);
dfe1eee3 503
4bb6408c
JS
504 // Since we wish the status bar to be directly under the client area,
505 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
89c7e962 506 m_frameStatusBar->SetSize(0, h, w, sh);
4bb6408c
JS
507}
508
509WXWidget wxFrame::GetMenuBarWidget() const
510{
2d120f83
JS
511 if (GetMenuBar())
512 return GetMenuBar()->GetMainWidget();
513 else
514 return (WXWidget) NULL;
4bb6408c
JS
515}
516
517void wxFrame::SetMenuBar(wxMenuBar *menuBar)
518{
519 if (!menuBar)
520 {
521 m_frameMenuBar = NULL;
522 return;
523 }
dfe1eee3 524
4bb6408c 525 // Currently can't set it twice
2d120f83 526 // wxASSERT_MSG( (m_frameMenuBar == (wxMenuBar*) NULL), "Cannot set the menubar more than once");
dfe1eee3 527
621793f4 528 if (m_frameMenuBar)
4bb6408c 529 {
621793f4
JS
530 m_frameMenuBar->DestroyMenuBar();
531 delete m_frameMenuBar;
4bb6408c 532 }
dfe1eee3 533
621793f4
JS
534 m_frameMenuBar = menuBar;
535 m_frameMenuBar->CreateMenuBar(this);
4bb6408c
JS
536}
537
4bb6408c
JS
538// Responds to colour changes, and passes event on to children.
539void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
540{
a756f210 541 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE));
4bb6408c 542 Refresh();
dfe1eee3 543
4bb6408c
JS
544 if ( m_frameStatusBar )
545 {
546 wxSysColourChangedEvent event2;
547 event2.SetEventObject( m_frameStatusBar );
548 m_frameStatusBar->ProcessEvent(event2);
549 }
dfe1eee3 550
4bb6408c
JS
551 // Propagate the event to the non-top-level children
552 wxWindow::OnSysColourChanged(event);
553}
554
4bb6408c
JS
555// Default activation behaviour - set the focus for the first child
556// subwindow found.
557void wxFrame::OnActivate(wxActivateEvent& event)
558{
af111fc3
JS
559 if (!event.GetActive())
560 return;
561
ac32ba44 562 for(wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); node;
fd304d98 563 node = node->GetNext())
4bb6408c 564 {
2d120f83 565 // Find a child that's a subwindow, but not a dialog box.
fd304d98 566 wxWindow *child = node->GetData();
798a4529 567 if (!child->IsTopLevel())
2d120f83
JS
568 {
569 child->SetFocus();
570 return;
571 }
4bb6408c 572 }
4bb6408c
JS
573}
574
46675b46
MB
575void wxFrame::SendSizeEvent()
576{
577 wxSizeEvent event(GetSize(), GetId());
578 event.SetEventObject(this);
579 GetEventHandler()->AddPendingEvent(event);
580}
581
1ccbb61a 582#if wxUSE_TOOLBAR
dfe1eee3 583
1c4f8f8d
VZ
584wxToolBar* wxFrame::CreateToolBar(long style,
585 wxWindowID id,
586 const wxString& name)
4bb6408c 587{
1c4f8f8d 588 if ( wxFrameBase::CreateToolBar(style, id, name) )
4bb6408c 589 {
4bb6408c 590 PositionToolBar();
4bb6408c 591 }
4bb6408c 592
1ccbb61a
VZ
593 return m_frameToolBar;
594}
595
46675b46
MB
596void wxFrame::SetToolBar(wxToolBar *toolbar)
597{
598 wxFrameBase::SetToolBar(toolbar);
599 SendSizeEvent();
600}
601
4bb6408c
JS
602void wxFrame::PositionToolBar()
603{
798a4529
MB
604 wxToolBar* tb = GetToolBar();
605 if (tb)
4bb6408c 606 {
1c4f8f8d
VZ
607 int cw, ch;
608 GetClientSize(& cw, &ch);
609
4bb6408c 610 int tw, th;
798a4529 611 tb->GetSize(& tw, & th);
dfe1eee3 612
798a4529 613 if (tb->GetWindowStyleFlag() & wxTB_VERTICAL)
4bb6408c
JS
614 {
615 // Use the 'real' position. wxSIZE_NO_ADJUSTMENTS
616 // means, pretend we don't have toolbar/status bar, so we
617 // have the original client size.
798a4529 618 th = ch + th;
4bb6408c
JS
619 }
620 else
621 {
622 // Use the 'real' position
798a4529 623 tw = cw;
4bb6408c 624 }
4bb6408c 625
aae91497 626 tb->SetSize(0, 0, -1, -1, wxSIZE_NO_ADJUSTMENTS);
4bb6408c 627 }
4bb6408c 628}
798a4529 629#endif // wxUSE_TOOLBAR
4bb6408c
JS
630
631//// Motif-specific
632bool wxFrame::PreResize()
633{
1ccbb61a 634#if wxUSE_TOOLBAR
2d120f83 635 PositionToolBar();
1ccbb61a 636#endif // wxUSE_TOOLBAR
1c4f8f8d
VZ
637
638#if wxUSE_STATUSBAR
2d120f83 639 PositionStatusBar();
1c4f8f8d
VZ
640#endif // wxUSE_STATUSBAR
641
96be256b 642 return true;
4bb6408c
JS
643}
644
50414e24
JS
645WXWidget wxFrame::GetClientWidget() const
646{
2d120f83 647 return m_clientArea;
50414e24
JS
648}
649
af111fc3 650void wxFrame::ChangeFont(bool WXUNUSED(keepOriginalSize))
0d57be45
JS
651{
652 // TODO
653}
654
655void wxFrame::ChangeBackgroundColour()
656{
621793f4 657 if (GetClientWidget())
a8680e3e 658 wxDoChangeBackgroundColour(GetClientWidget(), m_backgroundColour);
0d57be45
JS
659}
660
661void wxFrame::ChangeForegroundColour()
662{
621793f4 663 if (GetClientWidget())
a8680e3e 664 wxDoChangeForegroundColour(GetClientWidget(), m_foregroundColour);
0d57be45
JS
665}
666
798a4529
MB
667/* MATTEW: Used to insure that hide-&-show within an event cycle works */
668static void wxFrameMapProc( Widget frameShell, XtPointer clientData,
669 XCrossingEvent* event )
4bb6408c 670{
798a4529 671 wxFrame *tli = (wxFrame*)clientData;
dfe1eee3 672
798a4529 673 XEvent *e = (XEvent *)event;
dfe1eee3 674
798a4529 675 if( e->xany.type == MapNotify )
dc1efb1d 676 {
798a4529
MB
677 // Iconize fix
678 XtVaSetValues( frameShell, XmNiconic, (Boolean)False, NULL );
679 if( !tli->GetVisibleStatus() )
dc1efb1d 680 {
798a4529
MB
681 /* We really wanted this to be hidden! */
682 XtUnmapWidget( frameShell );
dc1efb1d
JS
683 }
684 }
798a4529
MB
685 else if( e->xany.type == UnmapNotify )
686 // Iconize fix
687 XtVaSetValues( frameShell, XmNiconic, (Boolean)True, NULL );
dc1efb1d 688}