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