]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/frame.cpp
don't use deprecated wxMenuItem methods
[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
28fcfbfe
VZ
122#if wxUSE_TOOLBAR
123
0d53fc34 124/* Callback for wxFrame. This very strange beast has to be used because
f362b96d 125 * C++ has no virtual methods in a constructor. We have to emulate a
77ffb593 126 * virtual function here as wxWidgets requires different ways to insert
f362b96d
RR
127 * a child in container classes. */
128
c821db16 129static void wxInsertChildInFrame(wxWindow* parent, wxWindow* child)
f362b96d 130{
5fd11f09 131 wxASSERT( GTK_IS_WIDGET(child->m_widget) );
7beba2fc 132
c821db16
PC
133 // These are outside the client area
134 wxFrame* frame = wx_static_cast(wxFrame*, parent);
135 gtk_pizza_put( GTK_PIZZA(frame->m_mainWidget),
136 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
c821db16
PC
143 // We connect to these events for recalculating the client area
144 // space when the toolbar is floating
145 if (wxIS_KIND_OF(child,wxToolBar))
146 {
147 if (child->HasFlag(wxTB_DOCKABLE))
f03fc89f 148 {
c821db16
PC
149 g_signal_connect (child->m_widget, "child_attached",
150 G_CALLBACK (gtk_toolbar_attached_callback),
151 parent);
152 g_signal_connect (child->m_widget, "child_detached",
153 G_CALLBACK (gtk_toolbar_detached_callback),
154 parent);
f03fc89f 155 }
f362b96d 156 }
28fcfbfe 157#endif // wxUSE_TOOLBAR_NATIVE
f362b96d
RR
158}
159
28fcfbfe
VZ
160#endif // wxUSE_TOOLBAR
161
7c0ea335 162// ----------------------------------------------------------------------------
0d53fc34 163// wxFrame creation
7c0ea335 164// ----------------------------------------------------------------------------
c801d85f 165
0d53fc34 166void wxFrame::Init()
c801d85f 167{
91af0895
WS
168 m_menuBarDetached = false;
169 m_toolBarDetached = false;
2b5f62a0 170 m_menuBarHeight = 2;
1529bc41 171 m_fsSaveFlag = 0;
362c6693 172}
c801d85f 173
0d53fc34 174bool wxFrame::Create( wxWindow *parent,
7c0ea335 175 wxWindowID id,
ca8bf976
VZ
176 const wxString& title,
177 const wxPoint& pos,
178 const wxSize& sizeOrig,
7c0ea335
VZ
179 long style,
180 const wxString &name )
c801d85f 181{
c821db16 182 return wxFrameBase::Create(parent, id, title, pos, sizeOrig, style, name);
362c6693 183}
c801d85f 184
0d53fc34 185wxFrame::~wxFrame()
c801d85f 186{
91af0895 187 m_isBeingDeleted = true;
7c0ea335 188 DeleteAllBars();
3d0c4d2e
RR
189}
190
7c0ea335
VZ
191// ----------------------------------------------------------------------------
192// overridden wxWindow methods
193// ----------------------------------------------------------------------------
194
0d53fc34 195void wxFrame::DoGetClientSize( int *width, int *height ) const
c801d85f 196{
223d09f6 197 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
7b4c2a06 198
e36a8aff 199 wxFrameBase::DoGetClientSize(width, height);
8bbe427f 200
fb1585ae 201 if (height)
46dc76ba 202 {
75c9da25 203#if wxUSE_MENUS_NATIVE
047ac72b 204 // menu bar
1d66b099 205 if (HasVisibleMenubar() && !m_menuBarDetached)
f03fc89f 206 {
e36a8aff 207 *height -= m_menuBarHeight;
f03fc89f 208 }
75c9da25 209#endif // wxUSE_MENUS_NATIVE
88ac883a 210
dcf924a3 211#if wxUSE_STATUSBAR
047ac72b 212 // status bar
e36a8aff
PC
213 if (m_frameStatusBar && GTK_WIDGET_VISIBLE(m_frameStatusBar->m_widget))
214 *height -= wxSTATUS_HEIGHT;
93fa69f8 215#endif // wxUSE_STATUSBAR
c1fa6f52 216 }
88ac883a 217
dcf924a3 218#if wxUSE_TOOLBAR
c1fa6f52 219 // tool bar
e36a8aff
PC
220 if (m_frameToolBar &&
221 GTK_WIDGET_VISIBLE(m_frameToolBar->m_widget) && !m_toolBarDetached)
c1fa6f52 222 {
e36a8aff 223 if (m_frameToolBar->IsVertical())
fb1585ae 224 {
e36a8aff
PC
225 if (width)
226 *width -= m_frameToolBar->GetSize().x;
c1fa6f52
PC
227 }
228 else
229 {
e36a8aff
PC
230 if (height)
231 *height -= m_frameToolBar->GetSize().y;
fb1585ae 232 }
46dc76ba 233 }
c1fa6f52
PC
234#endif // wxUSE_TOOLBAR
235
236 if (width != NULL && *width < 0)
237 *width = 0;
238 if (height != NULL && *height < 0)
239 *height = 0;
362c6693 240}
c801d85f 241
1529bc41
PC
242bool wxFrame::ShowFullScreen(bool show, long style)
243{
244 if (!wxFrameBase::ShowFullScreen(show, style))
245 return false;
246
247 wxWindow* const bar[] = {
28fcfbfe
VZ
248#if wxUSE_MENUS
249 m_frameMenuBar,
250#else
251 NULL,
252#endif
253#if wxUSE_TOOLBAR
254 m_frameToolBar,
255#else
256 NULL,
257#endif
258#if wxUSE_STATUSBAR
259 m_frameStatusBar,
260#else
261 NULL,
262#endif
1529bc41
PC
263 };
264 const long fsNoBar[] = {
265 wxFULLSCREEN_NOMENUBAR, wxFULLSCREEN_NOTOOLBAR, wxFULLSCREEN_NOSTATUSBAR
266 };
267 for (int i = 0; i < 3; i++)
268 {
269 if (show)
270 {
271 if (bar[i] && (style & fsNoBar[i]))
272 {
273 if (bar[i]->IsShown())
274 bar[i]->Show(false);
275 else
276 style &= ~fsNoBar[i];
277 }
278 }
279 else
280 {
281 if (bar[i] && (m_fsSaveFlag & fsNoBar[i]))
282 bar[i]->Show(true);
283 }
284 }
285 if (show)
286 m_fsSaveFlag = style;
287
288 return true;
289}
290
b5e31cc8 291void wxFrame::GtkOnSize()
c801d85f 292{
047ac72b 293 // avoid recursions
e52f60e6 294 if (m_resizing) return;
91af0895 295 m_resizing = true;
8bbe427f 296
047ac72b 297 // this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow
223d09f6 298 wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") );
88ac883a 299
047ac72b 300 // space occupied by m_frameToolBar and m_frameMenuBar
93fa69f8
VZ
301 int client_area_x_offset = 0,
302 client_area_y_offset = 0;
8bbe427f 303
0d53fc34 304 /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses
ab2b3dd4 305 wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
0d53fc34 306 set in wxFrame::Create so it is used to check what kind of frame we
ab2b3dd4
RR
307 have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
308 skip the part which handles m_frameMenuBar, m_frameToolBar and (most
309 importantly) m_mainWidget */
88ac883a 310
82008f15 311 ConstrainSize();
1f3c610d 312
ab2b3dd4 313 if (m_mainWidget)
f5368809 314 {
3a8b3bd1
RR
315 // TODO
316 // Rewrite this terrible code to using GtkVBox
ab2b3dd4 317
3a8b3bd1
RR
318 // m_mainWidget holds the menubar, the toolbar and the client
319 // area, which is represented by m_wxwindow.
88ac883a 320
ba51e75b 321#if wxUSE_MENUS_NATIVE
1d66b099 322 int menubarHeight = 0;
ba51e75b
VZ
323#endif
324
75c9da25 325#if wxUSE_MENUS_NATIVE
1d66b099 326 if (HasVisibleMenubar())
ab2b3dd4
RR
327 {
328 int xx = m_miniEdge;
329 int yy = m_miniEdge + m_miniTitle;
330 int ww = m_width - 2*m_miniEdge;
9cf7a6c0
PC
331 if (ww < 0)
332 ww = 0;
1d66b099
PC
333 menubarHeight = m_menuBarHeight;
334 if (m_menuBarDetached) menubarHeight = wxPLACE_HOLDER;
121a3581
RR
335 m_frameMenuBar->m_x = xx;
336 m_frameMenuBar->m_y = yy;
337 m_frameMenuBar->m_width = ww;
1d66b099 338 m_frameMenuBar->m_height = menubarHeight;
da048e3d 339 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
88ac883a 340 m_frameMenuBar->m_widget,
1d66b099
PC
341 xx, yy, ww, menubarHeight);
342 client_area_y_offset += menubarHeight;
ab2b3dd4 343 }
75c9da25 344#endif // wxUSE_MENUS_NATIVE
88ac883a 345
dcf924a3 346#if wxUSE_TOOLBAR
fa755cf1 347 if ((m_frameToolBar) && m_frameToolBar->IsShown() &&
7beba2fc 348 (m_frameToolBar->m_widget->parent == m_mainWidget))
ab2b3dd4
RR
349 {
350 int xx = m_miniEdge;
ba51e75b
VZ
351 int yy = m_miniEdge + m_miniTitle
352#if wxUSE_MENUS_NATIVE
353 + menubarHeight
354#endif
355 ;
93fa69f8 356
121a3581
RR
357 m_frameToolBar->m_x = xx;
358 m_frameToolBar->m_y = yy;
93fa69f8 359
047ac72b 360 // don't change the toolbar's reported height/width
93fa69f8
VZ
361 int ww, hh;
362 if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL )
363 {
364 ww = m_toolBarDetached ? wxPLACE_HOLDER
365 : m_frameToolBar->m_width;
366 hh = m_height - 2*m_miniEdge;
367
368 client_area_x_offset += ww;
369 }
7a976304
VZ
370 else if( m_frameToolBar->HasFlag(wxTB_RIGHT) )
371 {
372 yy += 2;
373 ww = m_toolBarDetached ? wxPLACE_HOLDER
374 : m_frameToolBar->m_width;
375 xx = GetClientSize().x - 1;
376 hh = m_height - 2*m_miniEdge;
377 if( hh < 0 )
378 hh = 0;
379
380 }
5b2acc3a
RR
381 else if( m_frameToolBar->GetWindowStyle() & wxTB_BOTTOM )
382 {
383 xx = m_miniEdge;
384 yy = GetClientSize().y;
385#if wxUSE_MENUS_NATIVE
386 yy += m_menuBarHeight;
b0f76951 387#endif // wxUSE_MENUS_NATIVE
5b2acc3a
RR
388 m_frameToolBar->m_x = xx;
389 m_frameToolBar->m_y = yy;
390 ww = m_width - 2*m_miniEdge;
391 hh = m_toolBarDetached ? wxPLACE_HOLDER
392 : m_frameToolBar->m_height;
393 }
93fa69f8
VZ
394 else
395 {
396 ww = m_width - 2*m_miniEdge;
397 hh = m_toolBarDetached ? wxPLACE_HOLDER
398 : m_frameToolBar->m_height;
7b4c2a06 399
93fa69f8
VZ
400 client_area_y_offset += hh;
401 }
402
6ba2e194
PC
403 if (ww < 0)
404 ww = 0;
405 if (hh < 0)
406 hh = 0;
da048e3d 407 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
88ac883a 408 m_frameToolBar->m_widget,
f03fc89f 409 xx, yy, ww, hh );
ab2b3dd4 410 }
93fa69f8 411#endif // wxUSE_TOOLBAR
88ac883a 412
93fa69f8 413 int client_x = client_area_x_offset + m_miniEdge;
f03fc89f 414 int client_y = client_area_y_offset + m_miniEdge + m_miniTitle;
93fa69f8 415 int client_w = m_width - client_area_x_offset - 2*m_miniEdge;
f03fc89f 416 int client_h = m_height - client_area_y_offset- 2*m_miniEdge - m_miniTitle;
9cf7a6c0
PC
417 if (client_w < 0)
418 client_w = 0;
419 if (client_h < 0)
420 client_h = 0;
da048e3d 421 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
88ac883a 422 m_wxwindow,
f03fc89f 423 client_x, client_y, client_w, client_h );
32a95f9f
RR
424 }
425 else
426 {
047ac72b
RR
427 // If there is no m_mainWidget between m_widget and m_wxwindow there
428 // is no need to set the size or position of m_wxwindow.
f5368809 429 }
88ac883a 430
dcf924a3 431#if wxUSE_STATUSBAR
1529bc41 432 if (m_frameStatusBar && m_frameStatusBar->IsShown())
f5368809 433 {
b2b3ccc5 434 int xx = 0 + m_miniEdge;
f362b96d 435 int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge - client_area_y_offset;
ac57418f 436 int ww = m_width - 2*m_miniEdge;
9cf7a6c0
PC
437 if (ww < 0)
438 ww = 0;
ac57418f 439 int hh = wxSTATUS_HEIGHT;
121a3581
RR
440 m_frameStatusBar->m_x = xx;
441 m_frameStatusBar->m_y = yy;
442 m_frameStatusBar->m_width = ww;
443 m_frameStatusBar->m_height = hh;
da048e3d 444 gtk_pizza_set_size( GTK_PIZZA(m_wxwindow),
7c0ea335
VZ
445 m_frameStatusBar->m_widget,
446 xx, yy, ww, hh );
f5368809 447 }
1e6feb95 448#endif // wxUSE_STATUSBAR
8bbe427f 449
91af0895 450 m_sizeSet = true;
7beba2fc 451
54517652 452 // send size event to frame
43a18898
RR
453 wxSizeEvent event( wxSize(m_width,m_height), GetId() );
454 event.SetEventObject( this );
e52f60e6 455 GetEventHandler()->ProcessEvent( event );
8bbe427f 456
1e6feb95 457#if wxUSE_STATUSBAR
54517652 458 // send size event to status bar
5aa5e35a
RR
459 if (m_frameStatusBar)
460 {
a2053b27 461 wxSizeEvent event2( wxSize(m_frameStatusBar->m_width,m_frameStatusBar->m_height), m_frameStatusBar->GetId() );
5aa5e35a
RR
462 event2.SetEventObject( m_frameStatusBar );
463 m_frameStatusBar->GetEventHandler()->ProcessEvent( event2 );
464 }
1e6feb95 465#endif // wxUSE_STATUSBAR
884470b1 466
91af0895 467 m_resizing = false;
e52f60e6
RR
468}
469
0d53fc34 470void wxFrame::OnInternalIdle()
e52f60e6 471{
e39af974 472 wxFrameBase::OnInternalIdle();
88ac883a 473
75c9da25 474#if wxUSE_MENUS_NATIVE
082b2798 475 if (m_frameMenuBar) m_frameMenuBar->OnInternalIdle();
75c9da25 476#endif // wxUSE_MENUS_NATIVE
dcf924a3 477#if wxUSE_TOOLBAR
082b2798 478 if (m_frameToolBar) m_frameToolBar->OnInternalIdle();
dcf924a3
RR
479#endif
480#if wxUSE_STATUSBAR
e4edaf5c
JS
481 if (m_frameStatusBar)
482 {
483 m_frameStatusBar->OnInternalIdle();
484
485 // There may be controls in the status bar that
486 // need to be updated
487 for ( wxWindowList::compatibility_iterator node = m_frameStatusBar->GetChildren().GetFirst();
488 node;
489 node = node->GetNext() )
490 {
491 wxWindow *child = node->GetData();
492 child->OnInternalIdle();
493 }
494 }
dcf924a3 495#endif
362c6693 496}
c801d85f 497
7c0ea335
VZ
498// ----------------------------------------------------------------------------
499// menu/tool/status bar stuff
500// ----------------------------------------------------------------------------
c801d85f 501
6522713c 502#if wxUSE_MENUS_NATIVE
1e6feb95 503
0d53fc34 504void wxFrame::DetachMenuBar()
c801d85f 505{
223d09f6
KB
506 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
507 wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") );
8bbe427f 508
6522713c 509 if ( m_frameMenuBar )
186baeb2
RR
510 {
511 m_frameMenuBar->UnsetInvokingWindow( this );
512
513 if (m_frameMenuBar->GetWindowStyle() & wxMB_DOCKABLE)
514 {
9fa72bd2
MR
515 g_signal_handlers_disconnect_by_func (m_frameMenuBar->m_widget,
516 (gpointer) gtk_menu_attached_callback,
517 this);
186baeb2 518
9fa72bd2
MR
519 g_signal_handlers_disconnect_by_func (m_frameMenuBar->m_widget,
520 (gpointer) gtk_menu_detached_callback,
521 this);
186baeb2 522 }
f6bcfd97 523
186baeb2 524 gtk_widget_ref( m_frameMenuBar->m_widget );
f283a575
RR
525
526 gtk_container_remove( GTK_CONTAINER(m_mainWidget), m_frameMenuBar->m_widget );
186baeb2
RR
527 }
528
6522713c
VZ
529 wxFrameBase::DetachMenuBar();
530}
531
0d53fc34 532void wxFrame::AttachMenuBar( wxMenuBar *menuBar )
6522713c
VZ
533{
534 wxFrameBase::AttachMenuBar(menuBar);
8bbe427f 535
f5368809 536 if (m_frameMenuBar)
30dea054 537 {
5bd9e519 538 m_frameMenuBar->SetInvokingWindow( this );
8bbe427f 539
186baeb2
RR
540 m_frameMenuBar->SetParent(this);
541 gtk_pizza_put( GTK_PIZZA(m_mainWidget),
88ac883a
VZ
542 m_frameMenuBar->m_widget,
543 m_frameMenuBar->m_x,
a2053b27
RR
544 m_frameMenuBar->m_y,
545 m_frameMenuBar->m_width,
546 m_frameMenuBar->m_height );
88ac883a 547
186baeb2
RR
548 if (menuBar->GetWindowStyle() & wxMB_DOCKABLE)
549 {
9fa72bd2
MR
550 g_signal_connect (menuBar->m_widget, "child_attached",
551 G_CALLBACK (gtk_menu_attached_callback),
552 this);
553 g_signal_connect (menuBar->m_widget, "child_detached",
554 G_CALLBACK (gtk_menu_detached_callback),
555 this);
f5368809 556 }
91af0895 557
02a8e64c 558 gtk_widget_show( m_frameMenuBar->m_widget );
2b5f62a0
VZ
559
560 UpdateMenuBarSize();
716b7364 561 }
2b5f62a0
VZ
562 else
563 {
564 m_menuBarHeight = 2;
565 GtkUpdateSize(); // resize window in OnInternalIdle
566 }
567}
568
569void wxFrame::UpdateMenuBarSize()
570{
8c70a789 571 m_menuBarHeight = 2;
91af0895 572
e5894d19
CE
573 // this is called after Remove with a NULL m_frameMenuBar
574 if ( m_frameMenuBar )
8c70a789
PC
575 {
576 GtkRequisition req;
577 gtk_widget_ensure_style(m_frameMenuBar->m_widget);
578 // have to call class method directly because
579 // "size_request" signal is overridden by wx
580 GTK_WIDGET_GET_CLASS(m_frameMenuBar->m_widget)->size_request(
581 m_frameMenuBar->m_widget, &req);
582
583 m_menuBarHeight = req.height;
584 }
2b5f62a0 585
0a164d4c 586 // resize window in OnInternalIdle
b8b7f03c 587 GtkUpdateSize();
362c6693 588}
c801d85f 589
1d66b099
PC
590bool wxFrame::HasVisibleMenubar() const
591{
592 return m_frameMenuBar && m_frameMenuBar->IsShown();
593}
6522713c 594#endif // wxUSE_MENUS_NATIVE
1e6feb95 595
88ac883a 596#if wxUSE_TOOLBAR
1e6feb95 597
0d53fc34 598wxToolBar* wxFrame::CreateToolBar( long style, wxWindowID id, const wxString& name )
46dc76ba 599{
223d09f6 600 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 601
c821db16
PC
602 InsertChildFunction save = m_insertCallback;
603 m_insertCallback = wxInsertChildInFrame;
7c0ea335 604 m_frameToolBar = wxFrameBase::CreateToolBar( style, id, name );
c821db16 605 m_insertCallback = save;
8bbe427f 606
b8b7f03c 607 GtkUpdateSize();
8bbe427f 608
f5368809 609 return m_frameToolBar;
362c6693 610}
46dc76ba 611
0d53fc34 612void wxFrame::SetToolBar(wxToolBar *toolbar)
7beba2fc 613{
94f14509
VZ
614 bool hadTbar = m_frameToolBar != NULL;
615
7c0ea335
VZ
616 wxFrameBase::SetToolBar(toolbar);
617
94f14509 618 if ( m_frameToolBar )
307f16e8 619 {
f283a575 620 // insert into toolbar area if not already there
3017f78d
RR
621 if ((m_frameToolBar->m_widget->parent) &&
622 (m_frameToolBar->m_widget->parent != m_mainWidget))
307f16e8 623 {
3017f78d 624 GetChildren().DeleteObject( m_frameToolBar );
7beba2fc
VZ
625
626 gtk_widget_reparent( m_frameToolBar->m_widget, m_mainWidget );
5b8a521e 627 GtkUpdateSize();
7beba2fc 628 }
307f16e8 629 }
94f14509
VZ
630 else // toolbar unset
631 {
632 // still need to update size if it had been there before
633 if ( hadTbar )
634 {
635 GtkUpdateSize();
636 }
637 }
307f16e8
RR
638}
639
88ac883a 640#endif // wxUSE_TOOLBAR
46dc76ba 641
88ac883a 642#if wxUSE_STATUSBAR
8bbe427f 643
0d53fc34 644wxStatusBar* wxFrame::CreateStatusBar(int number,
7c0ea335
VZ
645 long style,
646 wxWindowID id,
647 const wxString& name)
c801d85f 648{
223d09f6 649 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 650
7c0ea335 651 // because it will change when toolbar is added
b8b7f03c 652 GtkUpdateSize();
c801d85f 653
7c0ea335 654 return wxFrameBase::CreateStatusBar( number, style, id, name );
362c6693
RR
655}
656
3851e479
RR
657void wxFrame::SetStatusBar(wxStatusBar *statbar)
658{
659 bool hadStatBar = m_frameStatusBar != NULL;
91af0895 660
3851e479 661 wxFrameBase::SetStatusBar(statbar);
91af0895
WS
662
663 if (hadStatBar && !m_frameStatusBar)
3851e479
RR
664 GtkUpdateSize();
665}
666
0d53fc34 667void wxFrame::PositionStatusBar()
8febdd39
RR
668{
669 if ( !m_frameStatusBar )
670 return;
671
b8b7f03c 672 GtkUpdateSize();
8febdd39 673}
88ac883a 674#endif // wxUSE_STATUSBAR