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