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