]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/frame.cpp
removed extra membersections (patch 1702329)
[wxWidgets.git] / src / gtk / frame.cpp
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
93763ad5 2// Name: src/gtk/frame.cpp
c801d85f
KB
3// Purpose:
4// Author: Robert Roebling
a81258be 5// Id: $Id$
01111366 6// Copyright: (c) 1998 Robert Roebling
65571936 7// Licence: wxWindows licence
c801d85f
KB
8/////////////////////////////////////////////////////////////////////////////
9
93763ad5
WS
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
e1bf3ad3 13#include "wx/frame.h"
670f9935
WS
14
15#ifndef WX_PRECOMP
3b3dc801 16 #include "wx/menu.h"
4e3e485b 17 #include "wx/toolbar.h"
7c0ea335 18 #include "wx/statusbr.h"
3304646d 19#endif // WX_PRECOMP
83624f79 20
a1abca32 21#include <gtk/gtk.h>
c801d85f
KB
22#include "wx/gtk/win_gtk.h"
23
7c0ea335 24// ----------------------------------------------------------------------------
2f2aa628 25// constants
7c0ea335 26// ----------------------------------------------------------------------------
2f2aa628 27
c1fa6f52
PC
28static const int wxSTATUS_HEIGHT = 25;
29static const int wxPLACE_HOLDER = 0;
c801d85f 30
7c0ea335
VZ
31// ----------------------------------------------------------------------------
32// event tables
33// ----------------------------------------------------------------------------
34
0d53fc34 35IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow)
2e563988 36
7c0ea335
VZ
37// ============================================================================
38// implementation
39// ============================================================================
40
41// ----------------------------------------------------------------------------
42// GTK callbacks
43// ----------------------------------------------------------------------------
44
6522713c
VZ
45#if wxUSE_MENUS_NATIVE
46
16bcc879
RR
47//-----------------------------------------------------------------------------
48// "child_attached" of menu bar
49//-----------------------------------------------------------------------------
50
865bb325 51extern "C" {
0d53fc34 52static void gtk_menu_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
16bcc879 53{
a2053b27 54 if (!win->m_hasVMT) return;
88ac883a 55
91af0895 56 win->m_menuBarDetached = false;
5b8a521e 57 win->GtkUpdateSize();
16bcc879 58}
865bb325 59}
16bcc879
RR
60
61//-----------------------------------------------------------------------------
62// "child_detached" of menu bar
63//-----------------------------------------------------------------------------
64
865bb325 65extern "C" {
0d53fc34 66static void gtk_menu_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
16bcc879 67{
a2053b27 68 if (!win->m_hasVMT) return;
88ac883a 69
047ac72b
RR
70 // Raise the client area area
71 gdk_window_raise( win->m_wxwindow->window );
72
91af0895 73 win->m_menuBarDetached = true;
5b8a521e 74 win->GtkUpdateSize();
16bcc879 75}
865bb325 76}
6522713c
VZ
77
78#endif // wxUSE_MENUS_NATIVE
16bcc879 79
88ac883a 80#if wxUSE_TOOLBAR
16bcc879
RR
81//-----------------------------------------------------------------------------
82// "child_attached" of tool bar
83//-----------------------------------------------------------------------------
84
865bb325 85extern "C" {
0d53fc34 86static void gtk_toolbar_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
16bcc879 87{
a2053b27 88 if (!win->m_hasVMT) return;
88ac883a 89
91af0895 90 win->m_toolBarDetached = false;
5b8a521e 91 win->GtkUpdateSize();
16bcc879 92}
865bb325 93}
16bcc879
RR
94
95//-----------------------------------------------------------------------------
96// "child_detached" of tool bar
97//-----------------------------------------------------------------------------
98
865bb325 99extern "C" {
0d53fc34 100static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
16bcc879 101{
a2053b27 102 if (!win->m_hasVMT) return;
88ac883a 103
047ac72b
RR
104 // Raise the client area area
105 gdk_window_raise( win->m_wxwindow->window );
106
91af0895 107 win->m_toolBarDetached = true;
5b8a521e 108 win->GtkUpdateSize();
16bcc879 109}
865bb325 110}
88ac883a 111#endif // wxUSE_TOOLBAR
16bcc879 112
117247fd 113
7c0ea335 114// ----------------------------------------------------------------------------
0d53fc34 115// wxFrame itself
7c0ea335
VZ
116// ----------------------------------------------------------------------------
117
f362b96d 118//-----------------------------------------------------------------------------
0d53fc34 119// InsertChild for wxFrame
f362b96d
RR
120//-----------------------------------------------------------------------------
121
0d53fc34 122/* Callback for wxFrame. This very strange beast has to be used because
f362b96d 123 * C++ has no virtual methods in a constructor. We have to emulate a
77ffb593 124 * virtual function here as wxWidgets requires different ways to insert
f362b96d
RR
125 * a child in container classes. */
126
0d53fc34 127static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child )
f362b96d 128{
5fd11f09 129 wxASSERT( GTK_IS_WIDGET(child->m_widget) );
7beba2fc 130
6bc8a1c8 131 if (!parent->m_insertInClientArea)
f362b96d 132 {
047ac72b 133 // These are outside the client area
0d53fc34 134 wxFrame* frame = (wxFrame*) parent;
da048e3d 135 gtk_pizza_put( GTK_PIZZA(frame->m_mainWidget),
a2053b27
RR
136 GTK_WIDGET(child->m_widget),
137 child->m_x,
138 child->m_y,
139 child->m_width,
140 child->m_height );
91af0895 141
caf51f95 142#if wxUSE_TOOLBAR_NATIVE
047ac72b
RR
143 // We connect to these events for recalculating the client area
144 // space when the toolbar is floating
f03fc89f
VZ
145 if (wxIS_KIND_OF(child,wxToolBar))
146 {
147 wxToolBar *toolBar = (wxToolBar*) child;
148 if (toolBar->GetWindowStyle() & wxTB_DOCKABLE)
149 {
9fa72bd2
MR
150 g_signal_connect (toolBar->m_widget, "child_attached",
151 G_CALLBACK (gtk_toolbar_attached_callback),
152 parent);
153 g_signal_connect (toolBar->m_widget, "child_detached",
154 G_CALLBACK (gtk_toolbar_detached_callback),
155 parent);
f03fc89f
VZ
156 }
157 }
88ac883a 158#endif // wxUSE_TOOLBAR
f362b96d
RR
159 }
160 else
161 {
047ac72b 162 // These are inside the client area
da048e3d 163 gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow),
a2053b27
RR
164 GTK_WIDGET(child->m_widget),
165 child->m_x,
166 child->m_y,
167 child->m_width,
168 child->m_height );
f362b96d 169 }
f362b96d
RR
170}
171
7c0ea335 172// ----------------------------------------------------------------------------
0d53fc34 173// wxFrame creation
7c0ea335 174// ----------------------------------------------------------------------------
c801d85f 175
0d53fc34 176void wxFrame::Init()
c801d85f 177{
91af0895
WS
178 m_menuBarDetached = false;
179 m_toolBarDetached = false;
2b5f62a0 180 m_menuBarHeight = 2;
362c6693 181}
c801d85f 182
0d53fc34 183bool wxFrame::Create( wxWindow *parent,
7c0ea335 184 wxWindowID id,
ca8bf976
VZ
185 const wxString& title,
186 const wxPoint& pos,
187 const wxSize& sizeOrig,
7c0ea335
VZ
188 long style,
189 const wxString &name )
c801d85f 190{
7b4c2a06 191 bool rt = wxTopLevelWindow::Create(parent, id, title, pos, sizeOrig,
7d9f12f3 192 style, name);
6bc8a1c8 193 m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame;
91af0895 194
7d9f12f3 195 return rt;
362c6693 196}
c801d85f 197
0d53fc34 198wxFrame::~wxFrame()
c801d85f 199{
91af0895 200 m_isBeingDeleted = true;
7c0ea335 201 DeleteAllBars();
3d0c4d2e
RR
202}
203
7c0ea335
VZ
204// ----------------------------------------------------------------------------
205// overridden wxWindow methods
206// ----------------------------------------------------------------------------
207
0d53fc34 208void wxFrame::DoGetClientSize( int *width, int *height ) const
c801d85f 209{
223d09f6 210 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
7b4c2a06 211
7d9f12f3 212 wxTopLevelWindow::DoGetClientSize( width, height );
8bbe427f 213
fb1585ae 214 if (height)
46dc76ba 215 {
75c9da25 216#if wxUSE_MENUS_NATIVE
047ac72b 217 // menu bar
02112408 218 if (m_frameMenuBar && !(m_fsIsShowing && (m_fsSaveFlag & wxFULLSCREEN_NOMENUBAR) != 0))
f03fc89f 219 {
88ac883a 220 if (!m_menuBarDetached)
2b5f62a0 221 (*height) -= m_menuBarHeight;
f03fc89f
VZ
222 else
223 (*height) -= wxPLACE_HOLDER;
224 }
75c9da25 225#endif // wxUSE_MENUS_NATIVE
88ac883a 226
dcf924a3 227#if wxUSE_STATUSBAR
047ac72b 228 // status bar
f4322df6 229 if (m_frameStatusBar && m_frameStatusBar->IsShown() &&
02112408 230 !(m_fsIsShowing && (m_fsSaveFlag & wxFULLSCREEN_NOSTATUSBAR) != 0))
7d9f12f3 231 (*height) -= wxSTATUS_HEIGHT;
93fa69f8 232#endif // wxUSE_STATUSBAR
c1fa6f52 233 }
88ac883a 234
dcf924a3 235#if wxUSE_TOOLBAR
c1fa6f52
PC
236 // tool bar
237 if (m_frameToolBar && m_frameToolBar->IsShown())
238 {
239 if (m_toolBarDetached)
fb1585ae 240 {
c1fa6f52 241 if (height != NULL)
93fa69f8 242 *height -= wxPLACE_HOLDER;
c1fa6f52
PC
243 }
244 else
245 {
246 int x, y;
247 m_frameToolBar->GetSize( &x, &y );
7a976304 248 if ( m_frameToolBar->IsVertical() )
c1fa6f52
PC
249 {
250 if (width != NULL)
251 *width -= x;
f03fc89f
VZ
252 }
253 else
93fa69f8 254 {
c1fa6f52 255 if (height != NULL)
93fa69f8 256 *height -= y;
93fa69f8 257 }
fb1585ae 258 }
46dc76ba 259 }
c1fa6f52
PC
260#endif // wxUSE_TOOLBAR
261
262 if (width != NULL && *width < 0)
263 *width = 0;
264 if (height != NULL && *height < 0)
265 *height = 0;
362c6693 266}
c801d85f 267
0d53fc34 268void wxFrame::DoSetClientSize( int width, int height )
b593568e 269{
223d09f6 270 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 271
75c9da25 272#if wxUSE_MENUS_NATIVE
047ac72b 273 // menu bar
02112408 274 if (m_frameMenuBar && !(m_fsIsShowing && (m_fsSaveFlag & wxFULLSCREEN_NOMENUBAR) != 0))
f03fc89f 275 {
88ac883a 276 if (!m_menuBarDetached)
2b5f62a0 277 height += m_menuBarHeight;
f03fc89f
VZ
278 else
279 height += wxPLACE_HOLDER;
280 }
75c9da25 281#endif // wxUSE_MENUS_NATIVE
88ac883a 282
dcf924a3 283#if wxUSE_STATUSBAR
047ac72b 284 // status bar
f4322df6 285 if (m_frameStatusBar && m_frameStatusBar->IsShown() &&
02112408 286 !(m_fsIsShowing && (m_fsSaveFlag & wxFULLSCREEN_NOSTATUSBAR) != 0))
0fb2e879 287 height += wxSTATUS_HEIGHT;
dcf924a3 288#endif
88ac883a 289
dcf924a3 290#if wxUSE_TOOLBAR
047ac72b 291 // tool bar
fa755cf1 292 if (m_frameToolBar && m_frameToolBar->IsShown())
41ca191f 293 {
93fa69f8 294 if (m_toolBarDetached)
f03fc89f 295 {
93fa69f8 296 height += wxPLACE_HOLDER;
f03fc89f
VZ
297 }
298 else
93fa69f8
VZ
299 {
300 int x, y;
301 m_frameToolBar->GetSize( &x, &y );
7a976304 302 if ( m_frameToolBar->IsVertical() )
93fa69f8
VZ
303 {
304 width += x;
305 }
306 else
307 {
308 height += y;
309 }
310 }
41ca191f 311 }
dcf924a3 312#endif
88ac883a 313
7d9f12f3 314 wxTopLevelWindow::DoSetClientSize( width, height );
362c6693 315}
b593568e 316
b5e31cc8 317void wxFrame::GtkOnSize()
c801d85f 318{
047ac72b 319 // avoid recursions
e52f60e6 320 if (m_resizing) return;
91af0895 321 m_resizing = true;
8bbe427f 322
047ac72b 323 // this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow
223d09f6 324 wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") );
88ac883a 325
047ac72b 326 // space occupied by m_frameToolBar and m_frameMenuBar
93fa69f8
VZ
327 int client_area_x_offset = 0,
328 client_area_y_offset = 0;
8bbe427f 329
0d53fc34 330 /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses
ab2b3dd4 331 wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
0d53fc34 332 set in wxFrame::Create so it is used to check what kind of frame we
ab2b3dd4
RR
333 have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
334 skip the part which handles m_frameMenuBar, m_frameToolBar and (most
335 importantly) m_mainWidget */
88ac883a 336
e7dda1ff
VS
337 int minWidth = GetMinWidth(),
338 minHeight = GetMinHeight(),
339 maxWidth = GetMaxWidth(),
340 maxHeight = GetMaxHeight();
341
342 if ((minWidth != -1) && (m_width < minWidth)) m_width = minWidth;
343 if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight;
344 if ((maxWidth != -1) && (m_width > maxWidth)) m_width = maxWidth;
345 if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight;
1f3c610d 346
ab2b3dd4 347 if (m_mainWidget)
f5368809 348 {
3a8b3bd1
RR
349 // TODO
350 // Rewrite this terrible code to using GtkVBox
ab2b3dd4 351
3a8b3bd1
RR
352 // m_mainWidget holds the menubar, the toolbar and the client
353 // area, which is represented by m_wxwindow.
88ac883a 354
75c9da25 355#if wxUSE_MENUS_NATIVE
02112408 356 if (m_frameMenuBar && !(m_fsIsShowing && (m_fsSaveFlag & wxFULLSCREEN_NOMENUBAR) != 0))
ab2b3dd4 357 {
3a8b3bd1
RR
358 if (!GTK_WIDGET_VISIBLE(m_frameMenuBar->m_widget))
359 gtk_widget_show( m_frameMenuBar->m_widget );
ab2b3dd4
RR
360 int xx = m_miniEdge;
361 int yy = m_miniEdge + m_miniTitle;
362 int ww = m_width - 2*m_miniEdge;
9cf7a6c0
PC
363 if (ww < 0)
364 ww = 0;
2b5f62a0 365 int hh = m_menuBarHeight;
f03fc89f 366 if (m_menuBarDetached) hh = wxPLACE_HOLDER;
121a3581
RR
367 m_frameMenuBar->m_x = xx;
368 m_frameMenuBar->m_y = yy;
369 m_frameMenuBar->m_width = ww;
370 m_frameMenuBar->m_height = hh;
da048e3d 371 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
88ac883a 372 m_frameMenuBar->m_widget,
f03fc89f
VZ
373 xx, yy, ww, hh );
374 client_area_y_offset += hh;
ab2b3dd4 375 }
3a8b3bd1
RR
376 else
377 {
378 if (m_frameMenuBar)
379 {
380 if (GTK_WIDGET_VISIBLE(m_frameMenuBar->m_widget))
381 gtk_widget_hide( m_frameMenuBar->m_widget );
382 }
383 }
75c9da25 384#endif // wxUSE_MENUS_NATIVE
88ac883a 385
dcf924a3 386#if wxUSE_TOOLBAR
fa755cf1 387 if ((m_frameToolBar) && m_frameToolBar->IsShown() &&
7beba2fc 388 (m_frameToolBar->m_widget->parent == m_mainWidget))
ab2b3dd4
RR
389 {
390 int xx = m_miniEdge;
391 int yy = m_miniEdge + m_miniTitle;
75c9da25 392#if wxUSE_MENUS_NATIVE
41ca191f 393 if (m_frameMenuBar)
f03fc89f 394 {
88ac883a 395 if (!m_menuBarDetached)
2b5f62a0 396 yy += m_menuBarHeight;
88ac883a 397 else
f03fc89f
VZ
398 yy += wxPLACE_HOLDER;
399 }
75c9da25 400#endif // wxUSE_MENUS_NATIVE
93fa69f8 401
121a3581
RR
402 m_frameToolBar->m_x = xx;
403 m_frameToolBar->m_y = yy;
93fa69f8 404
047ac72b 405 // don't change the toolbar's reported height/width
93fa69f8
VZ
406 int ww, hh;
407 if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL )
408 {
409 ww = m_toolBarDetached ? wxPLACE_HOLDER
410 : m_frameToolBar->m_width;
411 hh = m_height - 2*m_miniEdge;
412
413 client_area_x_offset += ww;
414 }
7a976304
VZ
415 else if( m_frameToolBar->HasFlag(wxTB_RIGHT) )
416 {
417 yy += 2;
418 ww = m_toolBarDetached ? wxPLACE_HOLDER
419 : m_frameToolBar->m_width;
420 xx = GetClientSize().x - 1;
421 hh = m_height - 2*m_miniEdge;
422 if( hh < 0 )
423 hh = 0;
424
425 }
5b2acc3a
RR
426 else if( m_frameToolBar->GetWindowStyle() & wxTB_BOTTOM )
427 {
428 xx = m_miniEdge;
429 yy = GetClientSize().y;
430#if wxUSE_MENUS_NATIVE
431 yy += m_menuBarHeight;
432#endif // wxUSE_MENU_NATIVE
433 m_frameToolBar->m_x = xx;
434 m_frameToolBar->m_y = yy;
435 ww = m_width - 2*m_miniEdge;
436 hh = m_toolBarDetached ? wxPLACE_HOLDER
437 : m_frameToolBar->m_height;
438 }
93fa69f8
VZ
439 else
440 {
441 ww = m_width - 2*m_miniEdge;
442 hh = m_toolBarDetached ? wxPLACE_HOLDER
443 : m_frameToolBar->m_height;
7b4c2a06 444
93fa69f8
VZ
445 client_area_y_offset += hh;
446 }
447
6ba2e194
PC
448 if (ww < 0)
449 ww = 0;
450 if (hh < 0)
451 hh = 0;
da048e3d 452 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
88ac883a 453 m_frameToolBar->m_widget,
f03fc89f 454 xx, yy, ww, hh );
ab2b3dd4 455 }
93fa69f8 456#endif // wxUSE_TOOLBAR
88ac883a 457
93fa69f8 458 int client_x = client_area_x_offset + m_miniEdge;
f03fc89f 459 int client_y = client_area_y_offset + m_miniEdge + m_miniTitle;
93fa69f8 460 int client_w = m_width - client_area_x_offset - 2*m_miniEdge;
f03fc89f 461 int client_h = m_height - client_area_y_offset- 2*m_miniEdge - m_miniTitle;
9cf7a6c0
PC
462 if (client_w < 0)
463 client_w = 0;
464 if (client_h < 0)
465 client_h = 0;
da048e3d 466 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
88ac883a 467 m_wxwindow,
f03fc89f 468 client_x, client_y, client_w, client_h );
32a95f9f
RR
469 }
470 else
471 {
047ac72b
RR
472 // If there is no m_mainWidget between m_widget and m_wxwindow there
473 // is no need to set the size or position of m_wxwindow.
f5368809 474 }
88ac883a 475
dcf924a3 476#if wxUSE_STATUSBAR
0fb2e879 477 if (m_frameStatusBar && m_frameStatusBar->IsShown() &&
02112408 478 !(m_fsIsShowing && (m_fsSaveFlag & wxFULLSCREEN_NOSTATUSBAR) != 0))
f5368809 479 {
0fb2e879
RR
480 if (!GTK_WIDGET_VISIBLE(m_frameStatusBar->m_widget))
481 gtk_widget_show( m_frameStatusBar->m_widget );
f4322df6 482
b2b3ccc5 483 int xx = 0 + m_miniEdge;
f362b96d 484 int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge - client_area_y_offset;
ac57418f 485 int ww = m_width - 2*m_miniEdge;
9cf7a6c0
PC
486 if (ww < 0)
487 ww = 0;
ac57418f 488 int hh = wxSTATUS_HEIGHT;
121a3581
RR
489 m_frameStatusBar->m_x = xx;
490 m_frameStatusBar->m_y = yy;
491 m_frameStatusBar->m_width = ww;
492 m_frameStatusBar->m_height = hh;
da048e3d 493 gtk_pizza_set_size( GTK_PIZZA(m_wxwindow),
7c0ea335
VZ
494 m_frameStatusBar->m_widget,
495 xx, yy, ww, hh );
f5368809 496 }
0fb2e879
RR
497 else
498 {
499 if (m_frameStatusBar)
500 {
501 if (GTK_WIDGET_VISIBLE(m_frameStatusBar->m_widget))
502 gtk_widget_hide( m_frameStatusBar->m_widget );
503 }
504 }
1e6feb95 505#endif // wxUSE_STATUSBAR
8bbe427f 506
91af0895 507 m_sizeSet = true;
7beba2fc 508
54517652 509 // send size event to frame
43a18898
RR
510 wxSizeEvent event( wxSize(m_width,m_height), GetId() );
511 event.SetEventObject( this );
e52f60e6 512 GetEventHandler()->ProcessEvent( event );
8bbe427f 513
1e6feb95 514#if wxUSE_STATUSBAR
54517652 515 // send size event to status bar
5aa5e35a
RR
516 if (m_frameStatusBar)
517 {
a2053b27 518 wxSizeEvent event2( wxSize(m_frameStatusBar->m_width,m_frameStatusBar->m_height), m_frameStatusBar->GetId() );
5aa5e35a
RR
519 event2.SetEventObject( m_frameStatusBar );
520 m_frameStatusBar->GetEventHandler()->ProcessEvent( event2 );
521 }
1e6feb95 522#endif // wxUSE_STATUSBAR
884470b1 523
91af0895 524 m_resizing = false;
e52f60e6
RR
525}
526
0d53fc34 527void wxFrame::OnInternalIdle()
e52f60e6 528{
e39af974 529 wxFrameBase::OnInternalIdle();
88ac883a 530
75c9da25 531#if wxUSE_MENUS_NATIVE
082b2798 532 if (m_frameMenuBar) m_frameMenuBar->OnInternalIdle();
75c9da25 533#endif // wxUSE_MENUS_NATIVE
dcf924a3 534#if wxUSE_TOOLBAR
082b2798 535 if (m_frameToolBar) m_frameToolBar->OnInternalIdle();
dcf924a3
RR
536#endif
537#if wxUSE_STATUSBAR
e4edaf5c
JS
538 if (m_frameStatusBar)
539 {
540 m_frameStatusBar->OnInternalIdle();
541
542 // There may be controls in the status bar that
543 // need to be updated
544 for ( wxWindowList::compatibility_iterator node = m_frameStatusBar->GetChildren().GetFirst();
545 node;
546 node = node->GetNext() )
547 {
548 wxWindow *child = node->GetData();
549 child->OnInternalIdle();
550 }
551 }
dcf924a3 552#endif
362c6693 553}
c801d85f 554
7c0ea335
VZ
555// ----------------------------------------------------------------------------
556// menu/tool/status bar stuff
557// ----------------------------------------------------------------------------
c801d85f 558
6522713c 559#if wxUSE_MENUS_NATIVE
1e6feb95 560
0d53fc34 561void wxFrame::DetachMenuBar()
c801d85f 562{
223d09f6
KB
563 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
564 wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") );
8bbe427f 565
6522713c 566 if ( m_frameMenuBar )
186baeb2
RR
567 {
568 m_frameMenuBar->UnsetInvokingWindow( this );
569
570 if (m_frameMenuBar->GetWindowStyle() & wxMB_DOCKABLE)
571 {
9fa72bd2
MR
572 g_signal_handlers_disconnect_by_func (m_frameMenuBar->m_widget,
573 (gpointer) gtk_menu_attached_callback,
574 this);
186baeb2 575
9fa72bd2
MR
576 g_signal_handlers_disconnect_by_func (m_frameMenuBar->m_widget,
577 (gpointer) gtk_menu_detached_callback,
578 this);
186baeb2 579 }
f6bcfd97 580
186baeb2 581 gtk_widget_ref( m_frameMenuBar->m_widget );
f283a575
RR
582
583 gtk_container_remove( GTK_CONTAINER(m_mainWidget), m_frameMenuBar->m_widget );
186baeb2
RR
584 }
585
6522713c
VZ
586 wxFrameBase::DetachMenuBar();
587}
588
0d53fc34 589void wxFrame::AttachMenuBar( wxMenuBar *menuBar )
6522713c
VZ
590{
591 wxFrameBase::AttachMenuBar(menuBar);
8bbe427f 592
f5368809 593 if (m_frameMenuBar)
30dea054 594 {
5bd9e519 595 m_frameMenuBar->SetInvokingWindow( this );
8bbe427f 596
186baeb2
RR
597 m_frameMenuBar->SetParent(this);
598 gtk_pizza_put( GTK_PIZZA(m_mainWidget),
88ac883a
VZ
599 m_frameMenuBar->m_widget,
600 m_frameMenuBar->m_x,
a2053b27
RR
601 m_frameMenuBar->m_y,
602 m_frameMenuBar->m_width,
603 m_frameMenuBar->m_height );
88ac883a 604
186baeb2
RR
605 if (menuBar->GetWindowStyle() & wxMB_DOCKABLE)
606 {
9fa72bd2
MR
607 g_signal_connect (menuBar->m_widget, "child_attached",
608 G_CALLBACK (gtk_menu_attached_callback),
609 this);
610 g_signal_connect (menuBar->m_widget, "child_detached",
611 G_CALLBACK (gtk_menu_detached_callback),
612 this);
f5368809 613 }
91af0895 614
02a8e64c 615 gtk_widget_show( m_frameMenuBar->m_widget );
2b5f62a0
VZ
616
617 UpdateMenuBarSize();
716b7364 618 }
2b5f62a0
VZ
619 else
620 {
621 m_menuBarHeight = 2;
622 GtkUpdateSize(); // resize window in OnInternalIdle
623 }
624}
625
626void wxFrame::UpdateMenuBarSize()
627{
8c70a789 628 m_menuBarHeight = 2;
91af0895 629
e5894d19
CE
630 // this is called after Remove with a NULL m_frameMenuBar
631 if ( m_frameMenuBar )
8c70a789
PC
632 {
633 GtkRequisition req;
634 gtk_widget_ensure_style(m_frameMenuBar->m_widget);
635 // have to call class method directly because
636 // "size_request" signal is overridden by wx
637 GTK_WIDGET_GET_CLASS(m_frameMenuBar->m_widget)->size_request(
638 m_frameMenuBar->m_widget, &req);
639
640 m_menuBarHeight = req.height;
641 }
2b5f62a0 642
0a164d4c 643 // resize window in OnInternalIdle
b8b7f03c 644 GtkUpdateSize();
362c6693 645}
c801d85f 646
6522713c 647#endif // wxUSE_MENUS_NATIVE
1e6feb95 648
88ac883a 649#if wxUSE_TOOLBAR
1e6feb95 650
0d53fc34 651wxToolBar* wxFrame::CreateToolBar( long style, wxWindowID id, const wxString& name )
46dc76ba 652{
223d09f6 653 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 654
91af0895 655 m_insertInClientArea = false;
88ac883a 656
7c0ea335 657 m_frameToolBar = wxFrameBase::CreateToolBar( style, id, name );
8bbe427f 658
91af0895 659 m_insertInClientArea = true;
8bbe427f 660
b8b7f03c 661 GtkUpdateSize();
8bbe427f 662
f5368809 663 return m_frameToolBar;
362c6693 664}
46dc76ba 665
0d53fc34 666void wxFrame::SetToolBar(wxToolBar *toolbar)
7beba2fc 667{
94f14509
VZ
668 bool hadTbar = m_frameToolBar != NULL;
669
7c0ea335
VZ
670 wxFrameBase::SetToolBar(toolbar);
671
94f14509 672 if ( m_frameToolBar )
307f16e8 673 {
f283a575 674 // insert into toolbar area if not already there
3017f78d
RR
675 if ((m_frameToolBar->m_widget->parent) &&
676 (m_frameToolBar->m_widget->parent != m_mainWidget))
307f16e8 677 {
3017f78d 678 GetChildren().DeleteObject( m_frameToolBar );
7beba2fc
VZ
679
680 gtk_widget_reparent( m_frameToolBar->m_widget, m_mainWidget );
5b8a521e 681 GtkUpdateSize();
7beba2fc 682 }
307f16e8 683 }
94f14509
VZ
684 else // toolbar unset
685 {
686 // still need to update size if it had been there before
687 if ( hadTbar )
688 {
689 GtkUpdateSize();
690 }
691 }
307f16e8
RR
692}
693
88ac883a 694#endif // wxUSE_TOOLBAR
46dc76ba 695
88ac883a 696#if wxUSE_STATUSBAR
8bbe427f 697
0d53fc34 698wxStatusBar* wxFrame::CreateStatusBar(int number,
7c0ea335
VZ
699 long style,
700 wxWindowID id,
701 const wxString& name)
c801d85f 702{
223d09f6 703 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 704
7c0ea335 705 // because it will change when toolbar is added
b8b7f03c 706 GtkUpdateSize();
c801d85f 707
7c0ea335 708 return wxFrameBase::CreateStatusBar( number, style, id, name );
362c6693
RR
709}
710
3851e479
RR
711void wxFrame::SetStatusBar(wxStatusBar *statbar)
712{
713 bool hadStatBar = m_frameStatusBar != NULL;
91af0895 714
3851e479 715 wxFrameBase::SetStatusBar(statbar);
91af0895
WS
716
717 if (hadStatBar && !m_frameStatusBar)
3851e479
RR
718 GtkUpdateSize();
719}
720
0d53fc34 721void wxFrame::PositionStatusBar()
8febdd39
RR
722{
723 if ( !m_frameStatusBar )
724 return;
725
b8b7f03c 726 GtkUpdateSize();
8febdd39 727}
88ac883a 728#endif // wxUSE_STATUSBAR