]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/frame.cpp
various small cleanups
[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
290cd301
PC
313 int width, height;
314 GTKDoGetSize(&width, &height);
315
ab2b3dd4 316 if (m_mainWidget)
f5368809 317 {
3a8b3bd1
RR
318 // TODO
319 // Rewrite this terrible code to using GtkVBox
ab2b3dd4 320
3a8b3bd1
RR
321 // m_mainWidget holds the menubar, the toolbar and the client
322 // area, which is represented by m_wxwindow.
88ac883a 323
ba51e75b 324#if wxUSE_MENUS_NATIVE
1d66b099 325 int menubarHeight = 0;
ba51e75b
VZ
326#endif
327
75c9da25 328#if wxUSE_MENUS_NATIVE
1d66b099 329 if (HasVisibleMenubar())
ab2b3dd4
RR
330 {
331 int xx = m_miniEdge;
332 int yy = m_miniEdge + m_miniTitle;
290cd301 333 int ww = width - 2*m_miniEdge;
9cf7a6c0
PC
334 if (ww < 0)
335 ww = 0;
1d66b099
PC
336 menubarHeight = m_menuBarHeight;
337 if (m_menuBarDetached) menubarHeight = wxPLACE_HOLDER;
121a3581
RR
338 m_frameMenuBar->m_x = xx;
339 m_frameMenuBar->m_y = yy;
340 m_frameMenuBar->m_width = ww;
1d66b099 341 m_frameMenuBar->m_height = menubarHeight;
da048e3d 342 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
88ac883a 343 m_frameMenuBar->m_widget,
1d66b099
PC
344 xx, yy, ww, menubarHeight);
345 client_area_y_offset += menubarHeight;
ab2b3dd4 346 }
75c9da25 347#endif // wxUSE_MENUS_NATIVE
88ac883a 348
dcf924a3 349#if wxUSE_TOOLBAR
fa755cf1 350 if ((m_frameToolBar) && m_frameToolBar->IsShown() &&
7beba2fc 351 (m_frameToolBar->m_widget->parent == m_mainWidget))
ab2b3dd4
RR
352 {
353 int xx = m_miniEdge;
ba51e75b
VZ
354 int yy = m_miniEdge + m_miniTitle
355#if wxUSE_MENUS_NATIVE
356 + menubarHeight
357#endif
358 ;
93fa69f8 359
121a3581
RR
360 m_frameToolBar->m_x = xx;
361 m_frameToolBar->m_y = yy;
93fa69f8 362
047ac72b 363 // don't change the toolbar's reported height/width
93fa69f8
VZ
364 int ww, hh;
365 if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL )
366 {
367 ww = m_toolBarDetached ? wxPLACE_HOLDER
368 : m_frameToolBar->m_width;
290cd301 369 hh = height - 2*m_miniEdge;
93fa69f8
VZ
370
371 client_area_x_offset += ww;
372 }
7a976304
VZ
373 else if( m_frameToolBar->HasFlag(wxTB_RIGHT) )
374 {
375 yy += 2;
376 ww = m_toolBarDetached ? wxPLACE_HOLDER
377 : m_frameToolBar->m_width;
378 xx = GetClientSize().x - 1;
290cd301 379 hh = height - 2*m_miniEdge;
7a976304
VZ
380 if( hh < 0 )
381 hh = 0;
382
383 }
5b2acc3a
RR
384 else if( m_frameToolBar->GetWindowStyle() & wxTB_BOTTOM )
385 {
386 xx = m_miniEdge;
387 yy = GetClientSize().y;
388#if wxUSE_MENUS_NATIVE
389 yy += m_menuBarHeight;
b0f76951 390#endif // wxUSE_MENUS_NATIVE
5b2acc3a
RR
391 m_frameToolBar->m_x = xx;
392 m_frameToolBar->m_y = yy;
290cd301 393 ww = width - 2*m_miniEdge;
5b2acc3a
RR
394 hh = m_toolBarDetached ? wxPLACE_HOLDER
395 : m_frameToolBar->m_height;
396 }
93fa69f8
VZ
397 else
398 {
290cd301 399 ww = width - 2*m_miniEdge;
93fa69f8
VZ
400 hh = m_toolBarDetached ? wxPLACE_HOLDER
401 : m_frameToolBar->m_height;
7b4c2a06 402
93fa69f8
VZ
403 client_area_y_offset += hh;
404 }
405
6ba2e194
PC
406 if (ww < 0)
407 ww = 0;
408 if (hh < 0)
409 hh = 0;
da048e3d 410 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
88ac883a 411 m_frameToolBar->m_widget,
f03fc89f 412 xx, yy, ww, hh );
ab2b3dd4 413 }
93fa69f8 414#endif // wxUSE_TOOLBAR
88ac883a 415
93fa69f8 416 int client_x = client_area_x_offset + m_miniEdge;
f03fc89f 417 int client_y = client_area_y_offset + m_miniEdge + m_miniTitle;
290cd301
PC
418 int client_w = width - client_area_x_offset - 2*m_miniEdge;
419 int client_h = height - client_area_y_offset- 2*m_miniEdge - m_miniTitle;
9cf7a6c0
PC
420 if (client_w < 0)
421 client_w = 0;
422 if (client_h < 0)
423 client_h = 0;
da048e3d 424 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
88ac883a 425 m_wxwindow,
f03fc89f 426 client_x, client_y, client_w, client_h );
32a95f9f
RR
427 }
428 else
429 {
047ac72b
RR
430 // If there is no m_mainWidget between m_widget and m_wxwindow there
431 // is no need to set the size or position of m_wxwindow.
f5368809 432 }
88ac883a 433
dcf924a3 434#if wxUSE_STATUSBAR
1529bc41 435 if (m_frameStatusBar && m_frameStatusBar->IsShown())
f5368809 436 {
b2b3ccc5 437 int xx = 0 + m_miniEdge;
290cd301
PC
438 int yy = height - wxSTATUS_HEIGHT - m_miniEdge - client_area_y_offset;
439 int ww = width - 2*m_miniEdge;
9cf7a6c0
PC
440 if (ww < 0)
441 ww = 0;
ac57418f 442 int hh = wxSTATUS_HEIGHT;
121a3581
RR
443 m_frameStatusBar->m_x = xx;
444 m_frameStatusBar->m_y = yy;
445 m_frameStatusBar->m_width = ww;
446 m_frameStatusBar->m_height = hh;
da048e3d 447 gtk_pizza_set_size( GTK_PIZZA(m_wxwindow),
7c0ea335
VZ
448 m_frameStatusBar->m_widget,
449 xx, yy, ww, hh );
f5368809 450 }
1e6feb95 451#endif // wxUSE_STATUSBAR
8bbe427f 452
91af0895 453 m_sizeSet = true;
7beba2fc 454
54517652 455 // send size event to frame
43a18898
RR
456 wxSizeEvent event( wxSize(m_width,m_height), GetId() );
457 event.SetEventObject( this );
e52f60e6 458 GetEventHandler()->ProcessEvent( event );
8bbe427f 459
1e6feb95 460#if wxUSE_STATUSBAR
54517652 461 // send size event to status bar
5aa5e35a
RR
462 if (m_frameStatusBar)
463 {
a2053b27 464 wxSizeEvent event2( wxSize(m_frameStatusBar->m_width,m_frameStatusBar->m_height), m_frameStatusBar->GetId() );
5aa5e35a
RR
465 event2.SetEventObject( m_frameStatusBar );
466 m_frameStatusBar->GetEventHandler()->ProcessEvent( event2 );
467 }
1e6feb95 468#endif // wxUSE_STATUSBAR
884470b1 469
91af0895 470 m_resizing = false;
e52f60e6
RR
471}
472
0d53fc34 473void wxFrame::OnInternalIdle()
e52f60e6 474{
e39af974 475 wxFrameBase::OnInternalIdle();
88ac883a 476
75c9da25 477#if wxUSE_MENUS_NATIVE
082b2798 478 if (m_frameMenuBar) m_frameMenuBar->OnInternalIdle();
75c9da25 479#endif // wxUSE_MENUS_NATIVE
dcf924a3 480#if wxUSE_TOOLBAR
082b2798 481 if (m_frameToolBar) m_frameToolBar->OnInternalIdle();
dcf924a3
RR
482#endif
483#if wxUSE_STATUSBAR
e4edaf5c
JS
484 if (m_frameStatusBar)
485 {
486 m_frameStatusBar->OnInternalIdle();
487
488 // There may be controls in the status bar that
489 // need to be updated
490 for ( wxWindowList::compatibility_iterator node = m_frameStatusBar->GetChildren().GetFirst();
491 node;
492 node = node->GetNext() )
493 {
494 wxWindow *child = node->GetData();
495 child->OnInternalIdle();
496 }
497 }
dcf924a3 498#endif
362c6693 499}
c801d85f 500
7c0ea335
VZ
501// ----------------------------------------------------------------------------
502// menu/tool/status bar stuff
503// ----------------------------------------------------------------------------
c801d85f 504
6522713c 505#if wxUSE_MENUS_NATIVE
1e6feb95 506
0d53fc34 507void wxFrame::DetachMenuBar()
c801d85f 508{
223d09f6
KB
509 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
510 wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") );
8bbe427f 511
6522713c 512 if ( m_frameMenuBar )
186baeb2
RR
513 {
514 m_frameMenuBar->UnsetInvokingWindow( this );
515
516 if (m_frameMenuBar->GetWindowStyle() & wxMB_DOCKABLE)
517 {
9fa72bd2
MR
518 g_signal_handlers_disconnect_by_func (m_frameMenuBar->m_widget,
519 (gpointer) gtk_menu_attached_callback,
520 this);
186baeb2 521
9fa72bd2
MR
522 g_signal_handlers_disconnect_by_func (m_frameMenuBar->m_widget,
523 (gpointer) gtk_menu_detached_callback,
524 this);
186baeb2 525 }
f6bcfd97 526
186baeb2 527 gtk_widget_ref( m_frameMenuBar->m_widget );
f283a575
RR
528
529 gtk_container_remove( GTK_CONTAINER(m_mainWidget), m_frameMenuBar->m_widget );
186baeb2
RR
530 }
531
6522713c
VZ
532 wxFrameBase::DetachMenuBar();
533}
534
0d53fc34 535void wxFrame::AttachMenuBar( wxMenuBar *menuBar )
6522713c
VZ
536{
537 wxFrameBase::AttachMenuBar(menuBar);
8bbe427f 538
f5368809 539 if (m_frameMenuBar)
30dea054 540 {
5bd9e519 541 m_frameMenuBar->SetInvokingWindow( this );
8bbe427f 542
186baeb2
RR
543 m_frameMenuBar->SetParent(this);
544 gtk_pizza_put( GTK_PIZZA(m_mainWidget),
88ac883a
VZ
545 m_frameMenuBar->m_widget,
546 m_frameMenuBar->m_x,
a2053b27
RR
547 m_frameMenuBar->m_y,
548 m_frameMenuBar->m_width,
549 m_frameMenuBar->m_height );
88ac883a 550
186baeb2
RR
551 if (menuBar->GetWindowStyle() & wxMB_DOCKABLE)
552 {
9fa72bd2
MR
553 g_signal_connect (menuBar->m_widget, "child_attached",
554 G_CALLBACK (gtk_menu_attached_callback),
555 this);
556 g_signal_connect (menuBar->m_widget, "child_detached",
557 G_CALLBACK (gtk_menu_detached_callback),
558 this);
f5368809 559 }
91af0895 560
02a8e64c 561 gtk_widget_show( m_frameMenuBar->m_widget );
2b5f62a0
VZ
562
563 UpdateMenuBarSize();
716b7364 564 }
2b5f62a0
VZ
565 else
566 {
567 m_menuBarHeight = 2;
568 GtkUpdateSize(); // resize window in OnInternalIdle
569 }
570}
571
572void wxFrame::UpdateMenuBarSize()
573{
8c70a789 574 m_menuBarHeight = 2;
91af0895 575
e5894d19
CE
576 // this is called after Remove with a NULL m_frameMenuBar
577 if ( m_frameMenuBar )
8c70a789
PC
578 {
579 GtkRequisition req;
580 gtk_widget_ensure_style(m_frameMenuBar->m_widget);
581 // have to call class method directly because
582 // "size_request" signal is overridden by wx
583 GTK_WIDGET_GET_CLASS(m_frameMenuBar->m_widget)->size_request(
584 m_frameMenuBar->m_widget, &req);
585
586 m_menuBarHeight = req.height;
587 }
2b5f62a0 588
0a164d4c 589 // resize window in OnInternalIdle
b8b7f03c 590 GtkUpdateSize();
362c6693 591}
c801d85f 592
1d66b099
PC
593bool wxFrame::HasVisibleMenubar() const
594{
595 return m_frameMenuBar && m_frameMenuBar->IsShown();
596}
6522713c 597#endif // wxUSE_MENUS_NATIVE
1e6feb95 598
88ac883a 599#if wxUSE_TOOLBAR
1e6feb95 600
0d53fc34 601wxToolBar* wxFrame::CreateToolBar( long style, wxWindowID id, const wxString& name )
46dc76ba 602{
223d09f6 603 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 604
c821db16
PC
605 InsertChildFunction save = m_insertCallback;
606 m_insertCallback = wxInsertChildInFrame;
7c0ea335 607 m_frameToolBar = wxFrameBase::CreateToolBar( style, id, name );
c821db16 608 m_insertCallback = save;
8bbe427f 609
b8b7f03c 610 GtkUpdateSize();
8bbe427f 611
f5368809 612 return m_frameToolBar;
362c6693 613}
46dc76ba 614
0d53fc34 615void wxFrame::SetToolBar(wxToolBar *toolbar)
7beba2fc 616{
94f14509
VZ
617 bool hadTbar = m_frameToolBar != NULL;
618
7c0ea335
VZ
619 wxFrameBase::SetToolBar(toolbar);
620
94f14509 621 if ( m_frameToolBar )
307f16e8 622 {
f283a575 623 // insert into toolbar area if not already there
3017f78d
RR
624 if ((m_frameToolBar->m_widget->parent) &&
625 (m_frameToolBar->m_widget->parent != m_mainWidget))
307f16e8 626 {
3017f78d 627 GetChildren().DeleteObject( m_frameToolBar );
7beba2fc
VZ
628
629 gtk_widget_reparent( m_frameToolBar->m_widget, m_mainWidget );
5b8a521e 630 GtkUpdateSize();
7beba2fc 631 }
307f16e8 632 }
94f14509
VZ
633 else // toolbar unset
634 {
635 // still need to update size if it had been there before
636 if ( hadTbar )
637 {
638 GtkUpdateSize();
639 }
640 }
307f16e8
RR
641}
642
88ac883a 643#endif // wxUSE_TOOLBAR
46dc76ba 644
88ac883a 645#if wxUSE_STATUSBAR
8bbe427f 646
0d53fc34 647wxStatusBar* wxFrame::CreateStatusBar(int number,
7c0ea335
VZ
648 long style,
649 wxWindowID id,
650 const wxString& name)
c801d85f 651{
223d09f6 652 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 653
7c0ea335 654 // because it will change when toolbar is added
b8b7f03c 655 GtkUpdateSize();
c801d85f 656
7c0ea335 657 return wxFrameBase::CreateStatusBar( number, style, id, name );
362c6693
RR
658}
659
3851e479
RR
660void wxFrame::SetStatusBar(wxStatusBar *statbar)
661{
662 bool hadStatBar = m_frameStatusBar != NULL;
91af0895 663
3851e479 664 wxFrameBase::SetStatusBar(statbar);
91af0895
WS
665
666 if (hadStatBar && !m_frameStatusBar)
3851e479
RR
667 GtkUpdateSize();
668}
669
0d53fc34 670void wxFrame::PositionStatusBar()
8febdd39
RR
671{
672 if ( !m_frameStatusBar )
673 return;
674
b8b7f03c 675 GtkUpdateSize();
8febdd39 676}
88ac883a 677#endif // wxUSE_STATUSBAR