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