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