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