]> git.saurik.com Git - wxWidgets.git/blame - src/motif/frame.cpp
byte length for interim UniChar String corrected
[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
9// Licence: wxWindows licence
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
4dff3400
JJ
24
25#ifdef __VMS
26#define XtDisplay XTDISPLAY
27#define XtWindow XTWINDOW
28#define XtScreen XTSCREEN
29#endif
30
798a4529 31#include "wx/frame.h"
4bb6408c
JS
32#include "wx/statusbr.h"
33#include "wx/toolbar.h"
4bb6408c 34#include "wx/menu.h"
4bb6408c 35#include "wx/settings.h"
4bb6408c 36#include "wx/utils.h"
176513eb 37#include "wx/log.h"
798a4529 38#include "wx/app.h"
ed39ff57 39#include "wx/icon.h"
4bb6408c 40
338dd992 41#ifdef __VMS__
1c4f8f8d 42 #pragma message disable nosimpint
338dd992 43#endif
1c4f8f8d 44
4bb6408c 45#if defined(__ultrix) || defined(__sgi)
1c4f8f8d 46 #include <Xm/Frame.h>
4bb6408c
JS
47#endif
48
49#include <Xm/Xm.h>
50#include <X11/Shell.h>
f618020a 51#include <X11/Core.h>
4bb6408c 52#if XmVersion >= 1002
1c4f8f8d 53 #include <Xm/XmAll.h>
4bb6408c 54#else
1c4f8f8d 55 #include <Xm/Frame.h>
4bb6408c
JS
56#endif
57#include <Xm/MwmUtil.h>
58#include <Xm/BulletinB.h>
59#include <Xm/Form.h>
60#include <Xm/MainW.h>
61#include <Xm/RowColumn.h>
62#include <Xm/Label.h>
63#include <Xm/AtomMgr.h>
64#include <Xm/LabelG.h>
65#include <Xm/Frame.h>
66#if XmVersion > 1000
1c4f8f8d 67 #include <Xm/Protocols.h>
4bb6408c 68#endif
1c4f8f8d 69
338dd992 70#ifdef __VMS__
1c4f8f8d 71 #pragma message enable nosimpint
338dd992 72#endif
4bb6408c
JS
73
74#include "wx/motif/private.h"
f618020a 75#include "wx/unix/utilsx11.h"
4bb6408c 76
1c4f8f8d
VZ
77// ----------------------------------------------------------------------------
78// private functions
79// ----------------------------------------------------------------------------
80
dfe1eee3 81static void wxFrameMapProc(Widget frameShell, XtPointer clientData,
798a4529 82 XCrossingEvent* event);
4bb6408c 83
1c4f8f8d
VZ
84// ----------------------------------------------------------------------------
85// globals
86// ----------------------------------------------------------------------------
87
4bb6408c
JS
88extern wxList wxModelessWindows;
89extern wxList wxPendingDelete;
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{
4bb6408c 112 m_iconized = FALSE;
dfe1eee3 113
4bb6408c
JS
114 //// Motif-specific
115 m_frameShell = (WXWidget) NULL;
798a4529 116 m_mainWidget = (WXWidget) NULL;;
4bb6408c
JS
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 ) )
131 return FALSE;
dfe1eee3 132
798a4529
MB
133 m_backgroundColour =
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
MB
170
171 XtAddEventHandler((Widget) m_clientArea, ExposureMask,FALSE,
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
183 ChangeFont(FALSE);
184
185 ChangeBackgroundColour();
186
187 PreResize();
188
189 wxSizeEvent sizeEvent(wxSize(width, height), GetId());
190 sizeEvent.SetEventObject(this);
191
192 GetEventHandler()->ProcessEvent(sizeEvent);
193
194 return TRUE;
195}
196
197bool wxFrame::DoCreate( wxWindow* parent, wxWindowID id,
198 const wxString& title,
199 const wxPoint& pos,
200 const wxSize& size,
201 long style,
202 const wxString& name )
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,
215 XmNiconic, (style & wxICONIZE) ? TRUE : FALSE,
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
2d120f83 263 return TRUE;
4bb6408c
JS
264}
265
266wxFrame::~wxFrame()
267{
3ab377bd 268 m_isBeingDeleted = TRUE;
da8bed9b 269
2e35f56f 270 if (m_clientArea)
dc1efb1d 271 {
2e35f56f
JS
272 XtRemoveEventHandler((Widget) m_clientArea, ExposureMask, FALSE,
273 wxUniversalRepaintProc, (XtPointer) this);
dc1efb1d 274 }
2e35f56f 275
2d120f83
JS
276 if (GetMainWidget())
277 Show(FALSE);
0492c5a0 278
2d120f83
JS
279 if (m_frameMenuBar)
280 {
281 m_frameMenuBar->DestroyMenuBar();
dfe1eee3 282
2d120f83 283 // Hack to stop core dump on Ultrix, OSF, for some strange reason.
4bb6408c 284#if MOTIF_MENUBAR_DELETE_FIX
2d120f83 285 GetMenuBar()->SetMainWidget((WXWidget) NULL);
4bb6408c 286#endif
2d120f83
JS
287 delete m_frameMenuBar;
288 m_frameMenuBar = NULL;
289 }
dfe1eee3 290
2d120f83 291 if (m_frameStatusBar)
1c4f8f8d 292 {
2d120f83 293 delete m_frameStatusBar;
1c4f8f8d
VZ
294 m_frameStatusBar = NULL;
295 }
2187eef5
MB
296
297 PreDestroy();
298 DoDestroy();
798a4529 299}
dfe1eee3 300
798a4529
MB
301void wxFrame::DoDestroy()
302{
303 Widget frameShell = (Widget)GetShellWidget();
2b5f62a0 304
2187eef5
MB
305 if( frameShell )
306 XtRemoveEventHandler( frameShell, StructureNotifyMask,
307 False, (XtEventHandler)wxFrameMapProc,
308 (XtPointer)this );
dfe1eee3 309
798a4529 310 if( m_clientArea )
4bb6408c 311 {
798a4529
MB
312 wxDeleteWindowFromTable( (Widget)m_clientArea );
313 XtDestroyWidget( (Widget)m_clientArea );
4bb6408c 314 }
dfe1eee3 315
798a4529 316 if( m_workArea )
2d120f83 317 {
798a4529
MB
318 XtVaSetValues( (Widget)m_mainWidget,
319 XmNworkWindow, (Widget)NULL,
320 NULL );
dfe1eee3 321
798a4529
MB
322 wxDeleteWindowFromTable( (Widget)m_workArea );
323 XtDestroyWidget( (Widget)m_workArea );
324 }
dfe1eee3 325
798a4529
MB
326 if( m_mainWidget )
327 XtDestroyWidget( (Widget)m_mainWidget );
dfe1eee3 328
798a4529
MB
329 if( frameShell )
330 XtDestroyWidget( frameShell );
4bb6408c
JS
331}
332
333// Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
449f38b5 334void wxFrame::DoGetClientSize(int *x, int *y) const
4bb6408c 335{
2d120f83
JS
336 Dimension xx, yy;
337 XtVaGetValues((Widget) m_workArea, XmNwidth, &xx, XmNheight, &yy, NULL);
dfe1eee3 338
2d120f83
JS
339 if (m_frameStatusBar)
340 {
341 int sbw, sbh;
342 m_frameStatusBar->GetSize(& sbw, & sbh);
343 yy -= sbh;
344 }
1ccbb61a 345#if wxUSE_TOOLBAR
2d120f83
JS
346 if (m_frameToolBar)
347 {
348 int tbw, tbh;
349 m_frameToolBar->GetSize(& tbw, & tbh);
350 if (m_frameToolBar->GetWindowStyleFlag() & wxTB_VERTICAL)
351 xx -= tbw;
352 else
353 yy -= tbh;
354 }
1ccbb61a 355#endif // wxUSE_TOOLBAR
2d120f83 356 *x = xx; *y = yy;
4bb6408c
JS
357}
358
359// Set the client size (i.e. leave the calculation of borders etc.
360// to wxWindows)
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
2d120f83
JS
393 wxSizeEvent sizeEvent(wxSize(width, height), GetId());
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{
798a4529
MB
426 if( !wxTopLevelWindowMotif::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 {
438 XtMapWidget (shell);
439 XRaiseWindow (XtDisplay(shell), XtWindow(shell));
440 }
441 else
442 {
443 XtUnmapWidget(shell);
444 }
4bb6408c 445
798a4529 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
2d120f83 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}