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