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