]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/frame.cpp
added missing menu.cpp
[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
d02af7bb
JJ
22#ifdef __VMS
23#define XIconifyWindow XICONIFYWINDOW
24#endif
25
0c394212
VZ
26#include "wx/defs.h"
27
c801d85f
KB
28#include "wx/dialog.h"
29#include "wx/control.h"
30#include "wx/app.h"
cf4219e7 31#include "wx/menu.h"
dcf924a3 32#if wxUSE_TOOLBAR
7c0ea335 33 #include "wx/toolbar.h"
dcf924a3
RR
34#endif
35#if wxUSE_STATUSBAR
7c0ea335 36 #include "wx/statusbr.h"
dcf924a3 37#endif
362c6693 38#include "wx/dcclient.h"
83624f79 39
55703c91
RR
40#include <glib.h>
41#include <gdk/gdk.h>
42#include <gtk/gtk.h>
43#include <gdk/gdkkeysyms.h>
44#include <gdk/gdkx.h>
45
c801d85f
KB
46#include "wx/gtk/win_gtk.h"
47
7c0ea335 48// ----------------------------------------------------------------------------
2f2aa628 49// constants
7c0ea335 50// ----------------------------------------------------------------------------
2f2aa628 51
907789a0 52const int wxMENU_HEIGHT = 27;
c67daf87 53const int wxSTATUS_HEIGHT = 25;
41ca191f 54const int wxPLACE_HOLDER = 0;
c801d85f 55
7c0ea335 56// ----------------------------------------------------------------------------
acfd422a 57// idle system
7c0ea335 58// ----------------------------------------------------------------------------
acfd422a
RR
59
60extern void wxapp_install_idle_handler();
61extern bool g_isIdle;
2d68e1b4 62extern int g_openDialogs;
acfd422a 63
7c0ea335
VZ
64// ----------------------------------------------------------------------------
65// event tables
66// ----------------------------------------------------------------------------
67
af8964c4
VZ
68#ifndef __WXUNIVERSAL__
69 IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)
1e6feb95 70#endif
7c0ea335
VZ
71
72// ----------------------------------------------------------------------------
2f2aa628 73// data
7c0ea335 74// ----------------------------------------------------------------------------
2f2aa628 75
c801d85f
KB
76extern wxList wxPendingDelete;
77
7c0ea335 78// ----------------------------------------------------------------------------
2e563988 79// debug
7c0ea335 80// ----------------------------------------------------------------------------
2e563988
RR
81
82#ifdef __WXDEBUG__
83
84extern void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar *window );
85
86#endif
87
7c0ea335
VZ
88// ============================================================================
89// implementation
90// ============================================================================
91
92// ----------------------------------------------------------------------------
93// GTK callbacks
94// ----------------------------------------------------------------------------
95
69ffe1d2
RR
96//-----------------------------------------------------------------------------
97// "focus" from m_window
98//-----------------------------------------------------------------------------
99
100static gint gtk_frame_focus_callback( GtkWidget *widget, GtkDirectionType WXUNUSED(d), wxWindow *WXUNUSED(win) )
101{
102 if (g_isIdle)
103 wxapp_install_idle_handler();
104
105 // This disables GTK's tab traversal
106 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "focus" );
107 return TRUE;
108}
109
c801d85f 110//-----------------------------------------------------------------------------
2f2aa628 111// "size_allocate"
c801d85f 112//-----------------------------------------------------------------------------
c801d85f 113
1e6feb95 114static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxFrameGTK *win )
ed7a557b 115{
88ac883a 116 if (g_isIdle)
121a3581 117 wxapp_install_idle_handler();
acfd422a 118
54517652
RR
119 if (!win->m_hasVMT)
120 return;
8bbe427f 121
121a3581
RR
122 if ((win->m_width != alloc->width) || (win->m_height != alloc->height))
123 {
54517652
RR
124/*
125 wxPrintf( "OnSize from " );
126 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
127 wxPrintf( win->GetClassInfo()->GetClassName() );
128 wxPrintf( " %d %d %d %d\n", (int)alloc->x,
129 (int)alloc->y,
130 (int)alloc->width,
131 (int)alloc->height );
132*/
7beba2fc 133
121a3581
RR
134 win->m_width = alloc->width;
135 win->m_height = alloc->height;
8cb9f0d0 136 win->m_queuedFullRedraw = TRUE;
5b8a521e 137 win->GtkUpdateSize();
121a3581 138 }
362c6693 139}
c801d85f
KB
140
141//-----------------------------------------------------------------------------
2f2aa628
RR
142// "delete_event"
143//-----------------------------------------------------------------------------
c801d85f 144
1e6feb95 145static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxFrameGTK *win )
ed7a557b 146{
88ac883a 147 if (g_isIdle)
121a3581 148 wxapp_install_idle_handler();
ed7a557b 149
a56fcaaf 150 if ((g_openDialogs == 0) && (win->IsEnabled()))
2d68e1b4 151 win->Close();
c801d85f 152
fb1585ae 153 return TRUE;
362c6693 154}
c801d85f 155
1e6feb95 156#if wxUSE_MENUS
16bcc879
RR
157//-----------------------------------------------------------------------------
158// "child_attached" of menu bar
159//-----------------------------------------------------------------------------
160
1e6feb95 161static void gtk_menu_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrameGTK *win )
16bcc879 162{
a2053b27 163 if (!win->m_hasVMT) return;
88ac883a 164
16bcc879 165 win->m_menuBarDetached = FALSE;
5b8a521e 166 win->GtkUpdateSize();
16bcc879
RR
167}
168
169//-----------------------------------------------------------------------------
170// "child_detached" of menu bar
171//-----------------------------------------------------------------------------
172
1e6feb95 173static void gtk_menu_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrameGTK *win )
16bcc879 174{
a2053b27 175 if (!win->m_hasVMT) return;
88ac883a 176
16bcc879 177 win->m_menuBarDetached = TRUE;
5b8a521e 178 win->GtkUpdateSize();
16bcc879 179}
1e6feb95 180#endif // wxUSE_MENUS
16bcc879 181
88ac883a 182#if wxUSE_TOOLBAR
16bcc879
RR
183//-----------------------------------------------------------------------------
184// "child_attached" of tool bar
185//-----------------------------------------------------------------------------
186
1e6feb95 187static void gtk_toolbar_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrameGTK *win )
16bcc879 188{
a2053b27 189 if (!win->m_hasVMT) return;
88ac883a 190
16bcc879 191 win->m_toolBarDetached = FALSE;
88ac883a 192
5b8a521e 193 win->GtkUpdateSize();
16bcc879
RR
194}
195
196//-----------------------------------------------------------------------------
197// "child_detached" of tool bar
198//-----------------------------------------------------------------------------
199
1e6feb95 200static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrameGTK *win )
16bcc879 201{
88ac883a 202 if (g_isIdle)
801aa178 203 wxapp_install_idle_handler();
acfd422a 204
a2053b27 205 if (!win->m_hasVMT) return;
88ac883a 206
16bcc879 207 win->m_toolBarDetached = TRUE;
5b8a521e 208 win->GtkUpdateSize();
16bcc879 209}
88ac883a 210#endif // wxUSE_TOOLBAR
16bcc879 211
47908e25 212//-----------------------------------------------------------------------------
2f2aa628
RR
213// "configure_event"
214//-----------------------------------------------------------------------------
47908e25 215
7beba2fc 216static gint
2d68e1b4 217#if (GTK_MINOR_VERSION > 0)
1e6feb95 218gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxFrameGTK *win )
c693edf3 219#else
1e6feb95 220gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxFrameGTK *win )
c693edf3 221#endif
47908e25 222{
7beba2fc 223 if (g_isIdle)
121a3581 224 wxapp_install_idle_handler();
acfd422a 225
7c0ea335 226 if (!win->m_hasVMT)
2d68e1b4 227 return FALSE;
f6bcfd97 228
2d68e1b4 229#if (GTK_MINOR_VERSION > 0)
dfc3d7e0
RR
230 int x = 0;
231 int y = 0;
232 gdk_window_get_root_origin( win->m_widget->window, &x, &y );
dfc3d7e0
RR
233 win->m_x = x;
234 win->m_y = y;
c693edf3
RR
235#else
236 win->m_x = event->x;
237 win->m_y = event->y;
238#endif
8bbe427f 239
a2053b27 240 wxMoveEvent mevent( wxPoint(win->m_x,win->m_y), win->GetId() );
36b3b54a
RR
241 mevent.SetEventObject( win );
242 win->GetEventHandler()->ProcessEvent( mevent );
243
fb1585ae 244 return FALSE;
362c6693 245}
47908e25 246
2b07d713
RR
247//-----------------------------------------------------------------------------
248// "realize" from m_widget
249//-----------------------------------------------------------------------------
250
88ac883a 251/* we cannot MWM hints and icons before the widget has been realized,
2b07d713
RR
252 so we do this directly after realization */
253
43f5c493 254static void
1e6feb95 255gtk_frame_realized_callback( GtkWidget * WXUNUSED(widget), wxFrameGTK *win )
2b07d713 256{
88ac883a 257 if (g_isIdle)
121a3581 258 wxapp_install_idle_handler();
acfd422a 259
84eacd30 260 if ((win->m_miniEdge > 0) || (win->HasFlag(wxSIMPLE_BORDER)) || (win->HasFlag(wxNO_BORDER)))
15b24b14 261 {
80629c8b 262 /* This is a mini-frame or a borderless frame. */
81855216
RR
263 gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)0 );
264 gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)0 );
15b24b14 265 }
81855216 266 else
aa64626e 267 {
81855216
RR
268 /* All this is for Motif Window Manager "hints" and is supposed to be
269 recognized by other WM as well. Not tested. */
270 long decor = (long) GDK_DECOR_BORDER;
271 long func = (long) GDK_FUNC_MOVE;
272
273 if ((win->GetWindowStyle() & wxCAPTION) != 0)
274 decor |= GDK_DECOR_TITLE;
275 if ((win->GetWindowStyle() & wxSYSTEM_MENU) != 0)
276 {
277 decor |= GDK_DECOR_MENU;
278 func |= GDK_FUNC_CLOSE;
279 }
280 if ((win->GetWindowStyle() & wxMINIMIZE_BOX) != 0)
281 {
282 func |= GDK_FUNC_MINIMIZE;
283 decor |= GDK_DECOR_MINIMIZE;
284 }
285 if ((win->GetWindowStyle() & wxMAXIMIZE_BOX) != 0)
286 {
287 func |= GDK_FUNC_MAXIMIZE;
288 decor |= GDK_DECOR_MAXIMIZE;
289 }
290 if ((win->GetWindowStyle() & wxRESIZE_BORDER) != 0)
291 {
292 func |= GDK_FUNC_RESIZE;
293 decor |= GDK_DECOR_RESIZEH;
294 }
f6bcfd97 295
81855216
RR
296 gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor);
297 gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func);
aa64626e
KB
298 }
299
2b07d713 300 /* GTK's shrinking/growing policy */
f03fc89f 301 if ((win->GetWindowStyle() & wxRESIZE_BORDER) == 0)
a2053b27 302 gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1);
2b07d713 303 else
a2053b27 304 gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
88ac883a 305
58dea4b0 306 /* reset the icon */
7c0ea335
VZ
307 wxIcon iconOld = win->GetIcon();
308 if ( iconOld != wxNullIcon )
58dea4b0 309 {
7c0ea335
VZ
310 wxIcon icon( iconOld );
311 win->SetIcon( wxNullIcon );
f03fc89f 312 win->SetIcon( icon );
58dea4b0 313 }
88ac883a 314
2e563988
RR
315 /* we set the focus to the child that accepts the focus. this
316 doesn't really have to be done in "realize" but why not? */
f03fc89f 317 wxWindowList::Node *node = win->GetChildren().GetFirst();
2e563988
RR
318 while (node)
319 {
f03fc89f
VZ
320 wxWindow *child = node->GetData();
321 if (child->AcceptsFocus())
322 {
323 child->SetFocus();
324 break;
325 }
88ac883a 326
f03fc89f 327 node = node->GetNext();
2e563988 328 }
43f5c493 329}
88ac883a 330
43f5c493
RR
331//-----------------------------------------------------------------------------
332// "map_event" from m_widget
333//-----------------------------------------------------------------------------
334
335static void
c0f09a2e
VZ
336gtk_frame_map_callback( GtkWidget * WXUNUSED(widget),
337 GdkEvent * WXUNUSED(event),
338 wxFrame *win )
43f5c493 339{
3dd9b88a 340 win->SetIconizeState(FALSE);
43f5c493
RR
341}
342
343//-----------------------------------------------------------------------------
344// "unmap_event" from m_widget
345//-----------------------------------------------------------------------------
346
347static void
c0f09a2e
VZ
348gtk_frame_unmap_callback( GtkWidget * WXUNUSED(widget),
349 GdkEvent * WXUNUSED(event),
350 wxFrame *win )
43f5c493 351{
3dd9b88a 352 win->SetIconizeState(TRUE);
227e5e99 353}
88ac883a 354
117247fd
RR
355//-----------------------------------------------------------------------------
356// "expose_event" of m_client
357//-----------------------------------------------------------------------------
358
359static int gtk_window_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_event, wxWindow *win )
360{
361 GtkPizza *pizza = GTK_PIZZA(widget);
362
363 gtk_paint_flat_box (win->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL,
3dd9b88a
VZ
364 GTK_SHADOW_NONE, &gdk_event->area, win->m_widget, "base", 0, 0, -1, -1);
365
117247fd
RR
366 return TRUE;
367}
368
369//-----------------------------------------------------------------------------
370// "draw" of m_client
371//-----------------------------------------------------------------------------
372
373
374static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle *rect, wxWindow *win )
375{
376 GtkPizza *pizza = GTK_PIZZA(widget);
377
3dd9b88a
VZ
378 gtk_paint_flat_box (win->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL,
379 GTK_SHADOW_NONE, rect, win->m_widget, "base", 0, 0, -1, -1);
117247fd
RR
380}
381
7c0ea335 382// ----------------------------------------------------------------------------
1e6feb95 383// wxFrameGTK itself
7c0ea335
VZ
384// ----------------------------------------------------------------------------
385
f362b96d 386//-----------------------------------------------------------------------------
1e6feb95 387// InsertChild for wxFrameGTK
f362b96d
RR
388//-----------------------------------------------------------------------------
389
1e6feb95 390/* Callback for wxFrameGTK. This very strange beast has to be used because
f362b96d
RR
391 * C++ has no virtual methods in a constructor. We have to emulate a
392 * virtual function here as wxWindows requires different ways to insert
393 * a child in container classes. */
394
1e6feb95 395static void wxInsertChildInFrame( wxFrameGTK* parent, wxWindow* child )
f362b96d 396{
5fd11f09 397 wxASSERT( GTK_IS_WIDGET(child->m_widget) );
7beba2fc 398
6bc8a1c8 399 if (!parent->m_insertInClientArea)
f362b96d
RR
400 {
401 /* these are outside the client area */
1e6feb95 402 wxFrameGTK* frame = (wxFrameGTK*) parent;
da048e3d 403 gtk_pizza_put( GTK_PIZZA(frame->m_mainWidget),
a2053b27
RR
404 GTK_WIDGET(child->m_widget),
405 child->m_x,
406 child->m_y,
407 child->m_width,
408 child->m_height );
88ac883a 409
caf51f95 410#if wxUSE_TOOLBAR_NATIVE
f03fc89f
VZ
411 /* we connect to these events for recalculating the client area
412 space when the toolbar is floating */
413 if (wxIS_KIND_OF(child,wxToolBar))
414 {
415 wxToolBar *toolBar = (wxToolBar*) child;
416 if (toolBar->GetWindowStyle() & wxTB_DOCKABLE)
417 {
a2053b27 418 gtk_signal_connect( GTK_OBJECT(toolBar->m_widget), "child_attached",
41ca191f 419 GTK_SIGNAL_FUNC(gtk_toolbar_attached_callback), (gpointer)parent );
88ac883a 420
a2053b27 421 gtk_signal_connect( GTK_OBJECT(toolBar->m_widget), "child_detached",
41ca191f 422 GTK_SIGNAL_FUNC(gtk_toolbar_detached_callback), (gpointer)parent );
f03fc89f
VZ
423 }
424 }
88ac883a 425#endif // wxUSE_TOOLBAR
f362b96d
RR
426 }
427 else
428 {
429 /* these are inside the client area */
da048e3d 430 gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow),
a2053b27
RR
431 GTK_WIDGET(child->m_widget),
432 child->m_x,
433 child->m_y,
434 child->m_width,
435 child->m_height );
f362b96d
RR
436 }
437
f362b96d 438 /* resize on OnInternalIdle */
5b8a521e 439 parent->GtkUpdateSize();
f362b96d
RR
440}
441
7c0ea335 442// ----------------------------------------------------------------------------
1e6feb95 443// wxFrameGTK creation
7c0ea335 444// ----------------------------------------------------------------------------
c801d85f 445
1e6feb95 446void wxFrameGTK::Init()
c801d85f 447{
fb1585ae 448 m_sizeSet = FALSE;
b2b3ccc5
RR
449 m_miniEdge = 0;
450 m_miniTitle = 0;
ab2b3dd4 451 m_mainWidget = (GtkWidget*) NULL;
16bcc879
RR
452 m_menuBarDetached = FALSE;
453 m_toolBarDetached = FALSE;
6bc8a1c8 454 m_insertInClientArea = TRUE;
d786bf87 455 m_isFrame = TRUE;
f94fca1b 456 m_isIconized = FALSE;
43f5c493 457 m_fsIsShowing = FALSE;
a2d93e73 458 m_themeEnabled = TRUE;
362c6693 459}
c801d85f 460
1e6feb95 461bool wxFrameGTK::Create( wxWindow *parent,
7c0ea335 462 wxWindowID id,
ca8bf976
VZ
463 const wxString& title,
464 const wxPoint& pos,
465 const wxSize& sizeOrig,
7c0ea335
VZ
466 long style,
467 const wxString &name )
c801d85f 468{
ca8bf976
VZ
469 // always create a frame of some reasonable, even if arbitrary, size (at
470 // least for MSW compatibility)
471 wxSize size = sizeOrig;
472 if ( size.x == -1 || size.y == -1 )
473 {
474 wxSize sizeDpy = wxGetDisplaySize();
475 if ( size.x == -1 )
476 size.x = sizeDpy.x / 3;
477 if ( size.y == -1 )
478 size.y = sizeDpy.y / 5;
479 }
480
a802c3a1 481 wxTopLevelWindows.Append( this );
8bbe427f 482
fb1585ae 483 m_needParent = FALSE;
ed7a557b 484
4dcaf11a
RR
485 if (!PreCreation( parent, pos, size ) ||
486 !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
487 {
1e6feb95 488 wxFAIL_MSG( wxT("wxFrameGTK creation failed") );
7beba2fc 489 return FALSE;
4dcaf11a 490 }
c801d85f 491
fb1585ae 492 m_title = title;
88ac883a 493
6bc8a1c8 494 m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame;
ed7a557b 495
faecf4cb 496 GtkWindowType win_type = GTK_WINDOW_TOPLEVEL;
3dd9b88a 497
343e14b3
RR
498 if (style & wxFRAME_TOOL_WINDOW)
499 win_type = GTK_WINDOW_POPUP;
8bbe427f 500
fb1585ae 501 m_widget = gtk_window_new( win_type );
88ac883a 502
80629c8b
RR
503 if ((m_parent) && (HasFlag(wxFRAME_FLOAT_ON_PARENT)) && (GTK_IS_WINDOW(m_parent->m_widget)))
504 gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(m_parent->m_widget) );
505
de1c750f
RR
506 if (!name.IsEmpty())
507 gtk_window_set_wmclass( GTK_WINDOW(m_widget), name.mb_str(), name.mb_str() );
8bbe427f 508
2e563988 509#ifdef __WXDEBUG__
1e6feb95 510 debug_focus_in( m_widget, wxT("wxFrameGTK::m_widget"), name );
2e563988
RR
511#endif
512
ed9b9841 513 gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() );
fb1585ae 514 GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
ed7a557b 515
fb1585ae
RR
516 gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
517 GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this );
ed7a557b 518
f362b96d 519 /* m_mainWidget holds the toolbar, the menubar and the client area */
da048e3d 520 m_mainWidget = gtk_pizza_new();
f362b96d
RR
521 gtk_widget_show( m_mainWidget );
522 GTK_WIDGET_UNSET_FLAGS( m_mainWidget, GTK_CAN_FOCUS );
523 gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget );
88ac883a 524
117247fd
RR
525 /* for m_mainWidget themes */
526 gtk_signal_connect( GTK_OBJECT(m_mainWidget), "expose_event",
527 GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this );
528 gtk_signal_connect( GTK_OBJECT(m_mainWidget), "draw",
529 GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this );
530
2e563988 531#ifdef __WXDEBUG__
1e6feb95 532 debug_focus_in( m_mainWidget, wxT("wxFrameGTK::m_mainWidget"), name );
2e563988
RR
533#endif
534
f362b96d 535 /* m_wxwindow only represents the client area without toolbar and menubar */
da048e3d 536 m_wxwindow = gtk_pizza_new();
fb1585ae 537 gtk_widget_show( m_wxwindow );
f362b96d 538 gtk_container_add( GTK_CONTAINER(m_mainWidget), m_wxwindow );
88ac883a 539
2e563988 540#ifdef __WXDEBUG__
1e6feb95 541 debug_focus_in( m_wxwindow, wxT("wxFrameGTK::m_wxwindow"), name );
2e563988
RR
542#endif
543
544 /* we donm't allow the frame to get the focus as otherwise
3dd9b88a 545 the frame will grab it at arbitrary focus changes. */
2e563988 546 GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
ed7a557b 547
de8113d9
RR
548 if (m_parent) m_parent->AddChild( this );
549
54517652
RR
550 /* the user resized the frame by dragging etc. */
551 gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
552 GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this );
553
de8113d9
RR
554 PostCreation();
555
15909a16
RR
556 if ((m_x != -1) || (m_y != -1))
557 gtk_widget_set_uposition( m_widget, m_x, m_y );
558 gtk_widget_set_usize( m_widget, m_width, m_height );
f6bcfd97 559
58dea4b0 560 /* we cannot set MWM hints and icons before the widget has
2b07d713
RR
561 been realized, so we do this directly after realization */
562 gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
f03fc89f 563 GTK_SIGNAL_FUNC(gtk_frame_realized_callback), (gpointer) this );
88ac883a 564
ab2b3dd4 565 /* the only way to get the window size is to connect to this event */
fb1585ae
RR
566 gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event",
567 GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this );
8bbe427f 568
43f5c493
RR
569 /* map and unmap for iconized state */
570 gtk_signal_connect( GTK_OBJECT(m_widget), "map_event",
571 GTK_SIGNAL_FUNC(gtk_frame_map_callback), (gpointer)this );
572 gtk_signal_connect( GTK_OBJECT(m_widget), "unmap_event",
573 GTK_SIGNAL_FUNC(gtk_frame_unmap_callback), (gpointer)this );
574
575 /* the only way to get the window size is to connect to this event */
576 gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event",
577 GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this );
578
69ffe1d2
RR
579 /* disable native tab traversal */
580 gtk_signal_connect( GTK_OBJECT(m_widget), "focus",
581 GTK_SIGNAL_FUNC(gtk_frame_focus_callback), (gpointer)this );
582
fb1585ae 583 return TRUE;
362c6693 584}
c801d85f 585
1e6feb95 586wxFrameGTK::~wxFrameGTK()
c801d85f 587{
31c6b4fc 588 m_isBeingDeleted = TRUE;
88ac883a 589
7c0ea335 590 DeleteAllBars();
ed7a557b 591
fb1585ae 592 wxTopLevelWindows.DeleteObject( this );
2b854a32 593
0d2a2b60 594 if (wxTheApp->GetTopWindow() == this)
0d2a2b60 595 wxTheApp->SetTopWindow( (wxWindow*) NULL );
2b854a32 596
f59d80ca
RR
597 if ((wxTopLevelWindows.Number() == 0) &&
598 (wxTheApp->GetExitOnFrameDelete()))
599 {
0d2a2b60 600 wxTheApp->ExitMainLoop();
f59d80ca 601 }
362c6693 602}
ed7a557b 603
2a365b7d 604bool wxFrameGTK::ShowFullScreen(bool show, long style )
3d0c4d2e
RR
605{
606 if (show == m_fsIsShowing) return FALSE; // return what?
607
608 m_fsIsShowing = show;
3dd9b88a 609
3d0c4d2e
RR
610 if (show)
611 {
612 m_fsSaveStyle = m_windowStyle;
613 m_fsSaveFlag = style;
614 GetPosition( &m_fsSaveFrame.x, &m_fsSaveFrame.y );
615 GetSize( &m_fsSaveFrame.width, &m_fsSaveFrame.height );
3dd9b88a 616
3d0c4d2e
RR
617 gtk_widget_hide( m_widget );
618 gtk_widget_unrealize( m_widget );
3dd9b88a 619
3d0c4d2e 620 m_windowStyle = wxSIMPLE_BORDER;
3dd9b88a 621
3d0c4d2e
RR
622 int x;
623 int y;
624 wxDisplaySize( &x, &y );
625 SetSize( 0, 0, x, y );
3dd9b88a 626
3d0c4d2e
RR
627 gtk_widget_realize( m_widget );
628 gtk_widget_show( m_widget );
629 }
630 else
631 {
632 gtk_widget_hide( m_widget );
633 gtk_widget_unrealize( m_widget );
3dd9b88a 634
3d0c4d2e 635 m_windowStyle = m_fsSaveStyle;
3dd9b88a 636
3d0c4d2e 637 SetSize( m_fsSaveFrame.x, m_fsSaveFrame.y, m_fsSaveFrame.width, m_fsSaveFrame.height );
3dd9b88a 638
3d0c4d2e
RR
639 gtk_widget_realize( m_widget );
640 gtk_widget_show( m_widget );
641 }
3dd9b88a 642
3d0c4d2e
RR
643 return TRUE;
644}
645
7c0ea335
VZ
646// ----------------------------------------------------------------------------
647// overridden wxWindow methods
648// ----------------------------------------------------------------------------
649
1e6feb95 650bool wxFrameGTK::Show( bool show )
c801d85f 651{
223d09f6 652 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 653
35178437 654 if (show && !m_sizeSet)
fb1585ae 655 {
e27ce4e9
RR
656 /* by calling GtkOnSize here, we don't have to call
657 either after showing the frame, which would entail
f362b96d 658 much ugly flicker or from within the size_allocate
e27ce4e9 659 handler, because GTK 1.1.X forbids that. */
8bbe427f 660
35178437 661 GtkOnSize( m_x, m_y, m_width, m_height );
fb1585ae 662 }
8bbe427f 663
fb1585ae 664 return wxWindow::Show( show );
362c6693 665}
c801d85f 666
1e6feb95 667void wxFrameGTK::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) )
23efdd02 668{
1e6feb95 669 wxFAIL_MSG( wxT("DoMoveWindow called for wxFrameGTK") );
23efdd02 670}
f6bcfd97 671
1e6feb95 672void wxFrameGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags )
903f689b 673{
223d09f6 674 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 675
1e6feb95 676 /* this shouldn't happen: wxFrameGTK, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
223d09f6 677 wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") );
88ac883a 678
ab2b3dd4 679 /* avoid recursions */
7c0ea335
VZ
680 if (m_resizing)
681 return;
fb1585ae
RR
682 m_resizing = TRUE;
683
684 int old_x = m_x;
685 int old_y = m_y;
7beba2fc 686
fb1585ae
RR
687 int old_width = m_width;
688 int old_height = m_height;
8bbe427f 689
85ad5eb5 690 if ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0)
fb1585ae
RR
691 {
692 if (x != -1) m_x = x;
693 if (y != -1) m_y = y;
694 if (width != -1) m_width = width;
695 if (height != -1) m_height = height;
696 }
697 else
698 {
699 m_x = x;
700 m_y = y;
701 m_width = width;
702 m_height = height;
703 }
704
11e1c70d 705/*
fb1585ae
RR
706 if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
707 {
708 if (width == -1) m_width = 80;
709 }
710
711 if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
712 {
713 if (height == -1) m_height = 26;
714 }
11e1c70d 715*/
8bbe427f 716
fb1585ae
RR
717 if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
718 if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
0c77152e
RR
719 if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
720 if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
fb1585ae
RR
721
722 if ((m_x != -1) || (m_y != -1))
723 {
8bbe427f 724 if ((m_x != old_x) || (m_y != old_y))
0138c2de 725 {
8487f887 726 gtk_widget_set_uposition( m_widget, m_x, m_y );
0138c2de 727 }
fb1585ae 728 }
8bbe427f 729
fb1585ae
RR
730 if ((m_width != old_width) || (m_height != old_height))
731 {
15909a16
RR
732 gtk_widget_set_usize( m_widget, m_width, m_height );
733
ab2b3dd4 734 /* we set the size in GtkOnSize, i.e. mostly the actual resizing is
f03fc89f
VZ
735 done either directly before the frame is shown or in idle time
736 so that different calls to SetSize() don't lead to flicker. */
de8113d9 737 m_sizeSet = FALSE;
fb1585ae 738 }
8bbe427f 739
fb1585ae 740 m_resizing = FALSE;
903f689b
RR
741}
742
1e6feb95 743void wxFrameGTK::DoGetClientSize( int *width, int *height ) const
c801d85f 744{
223d09f6 745 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 746
f9241296 747 wxWindow::DoGetClientSize( width, height );
fb1585ae 748 if (height)
46dc76ba 749 {
1e6feb95 750#if wxUSE_MENUS
41ca191f
RR
751 /* menu bar */
752 if (m_frameMenuBar)
f03fc89f 753 {
88ac883a 754 if (!m_menuBarDetached)
f03fc89f
VZ
755 (*height) -= wxMENU_HEIGHT;
756 else
757 (*height) -= wxPLACE_HOLDER;
758 }
1e6feb95 759#endif // wxUSE_MENUS
88ac883a 760
dcf924a3 761#if wxUSE_STATUSBAR
f03fc89f 762 /* status bar */
fa755cf1 763 if (m_frameStatusBar && m_frameStatusBar->IsShown()) (*height) -= wxSTATUS_HEIGHT;
93fa69f8 764#endif // wxUSE_STATUSBAR
88ac883a 765
dcf924a3 766#if wxUSE_TOOLBAR
f03fc89f 767 /* tool bar */
fa755cf1 768 if (m_frameToolBar && m_frameToolBar->IsShown())
fb1585ae 769 {
93fa69f8 770 if (m_toolBarDetached)
f03fc89f 771 {
93fa69f8 772 *height -= wxPLACE_HOLDER;
f03fc89f
VZ
773 }
774 else
93fa69f8
VZ
775 {
776 int x, y;
777 m_frameToolBar->GetSize( &x, &y );
778 if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL )
779 {
780 *width -= x;
781 }
782 else
783 {
784 *height -= y;
785 }
786 }
fb1585ae 787 }
93fa69f8 788#endif // wxUSE_TOOLBAR
88ac883a 789
f03fc89f 790 /* mini edge */
93fa69f8 791 *height -= m_miniEdge*2 + m_miniTitle;
b2b3ccc5
RR
792 }
793 if (width)
794 {
93fa69f8 795 *width -= m_miniEdge*2;
46dc76ba 796 }
362c6693 797}
c801d85f 798
1e6feb95 799void wxFrameGTK::DoSetClientSize( int width, int height )
b593568e 800{
223d09f6 801 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 802
1e6feb95 803#if wxUSE_MENUS
41ca191f
RR
804 /* menu bar */
805 if (m_frameMenuBar)
f03fc89f 806 {
88ac883a 807 if (!m_menuBarDetached)
f03fc89f
VZ
808 height += wxMENU_HEIGHT;
809 else
810 height += wxPLACE_HOLDER;
811 }
1e6feb95 812#endif // wxUSE_MENUS
88ac883a 813
dcf924a3 814#if wxUSE_STATUSBAR
f03fc89f 815 /* status bar */
fa755cf1 816 if (m_frameStatusBar && m_frameStatusBar->IsShown()) height += wxSTATUS_HEIGHT;
dcf924a3 817#endif
88ac883a 818
dcf924a3 819#if wxUSE_TOOLBAR
f03fc89f 820 /* tool bar */
fa755cf1 821 if (m_frameToolBar && m_frameToolBar->IsShown())
41ca191f 822 {
93fa69f8 823 if (m_toolBarDetached)
f03fc89f 824 {
93fa69f8 825 height += wxPLACE_HOLDER;
f03fc89f
VZ
826 }
827 else
93fa69f8
VZ
828 {
829 int x, y;
830 m_frameToolBar->GetSize( &x, &y );
831 if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL )
832 {
833 width += x;
834 }
835 else
836 {
837 height += y;
838 }
839 }
41ca191f 840 }
dcf924a3 841#endif
88ac883a 842
3017f78d 843 DoSetSize( -1, -1, width + m_miniEdge*2, height + m_miniEdge*2 + m_miniTitle, 0 );
362c6693 844}
b593568e 845
1e6feb95 846void wxFrameGTK::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
7c0ea335 847 int width, int height )
c801d85f 848{
f5368809
RR
849 // due to a bug in gtk, x,y are always 0
850 // m_x = x;
851 // m_y = y;
852
ab2b3dd4 853 /* avoid recursions */
e52f60e6
RR
854 if (m_resizing) return;
855 m_resizing = TRUE;
8bbe427f 856
1e6feb95 857 /* this shouldn't happen: wxFrameGTK, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
223d09f6 858 wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") );
88ac883a 859
f5368809
RR
860 m_width = width;
861 m_height = height;
7beba2fc 862
ab2b3dd4 863 /* space occupied by m_frameToolBar and m_frameMenuBar */
93fa69f8
VZ
864 int client_area_x_offset = 0,
865 client_area_y_offset = 0;
8bbe427f 866
1e6feb95 867 /* wxMDIChildFrame derives from wxFrameGTK but it _is_ a wxWindow as it uses
ab2b3dd4 868 wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
1e6feb95 869 set in wxFrameGTK::Create so it is used to check what kind of frame we
ab2b3dd4
RR
870 have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
871 skip the part which handles m_frameMenuBar, m_frameToolBar and (most
872 importantly) m_mainWidget */
88ac883a 873
1f3c610d
RR
874 if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
875 if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
876 if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
877 if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
1f3c610d 878
ab2b3dd4 879 if (m_mainWidget)
f5368809 880 {
f6bcfd97
BP
881 /* set size hints */
882 gint flag = 0; // GDK_HINT_POS;
883 if ((m_minWidth != -1) || (m_minHeight != -1)) flag |= GDK_HINT_MIN_SIZE;
884 if ((m_maxWidth != -1) || (m_maxHeight != -1)) flag |= GDK_HINT_MAX_SIZE;
885 GdkGeometry geom;
886 geom.min_width = m_minWidth;
887 geom.min_height = m_minHeight;
888 geom.max_width = m_maxWidth;
889 geom.max_height = m_maxHeight;
890 gtk_window_set_geometry_hints( GTK_WINDOW(m_widget),
891 (GtkWidget*) NULL,
892 &geom,
893 (GdkWindowHints) flag );
ab2b3dd4
RR
894
895 /* I revert back to wxGTK's original behaviour. m_mainWidget holds the
896 * menubar, the toolbar and the client area, which is represented by
897 * m_wxwindow.
898 * this hurts in the eye, but I don't want to call SetSize()
899 * because I don't want to call any non-native functions here. */
88ac883a 900
1e6feb95 901#if wxUSE_MENUS
ab2b3dd4
RR
902 if (m_frameMenuBar)
903 {
904 int xx = m_miniEdge;
905 int yy = m_miniEdge + m_miniTitle;
906 int ww = m_width - 2*m_miniEdge;
41ca191f 907 int hh = wxMENU_HEIGHT;
f03fc89f 908 if (m_menuBarDetached) hh = wxPLACE_HOLDER;
121a3581
RR
909 m_frameMenuBar->m_x = xx;
910 m_frameMenuBar->m_y = yy;
911 m_frameMenuBar->m_width = ww;
912 m_frameMenuBar->m_height = hh;
da048e3d 913 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
88ac883a 914 m_frameMenuBar->m_widget,
f03fc89f
VZ
915 xx, yy, ww, hh );
916 client_area_y_offset += hh;
ab2b3dd4 917 }
1e6feb95 918#endif // wxUSE_MENUS
88ac883a 919
dcf924a3 920#if wxUSE_TOOLBAR
fa755cf1 921 if ((m_frameToolBar) && m_frameToolBar->IsShown() &&
7beba2fc 922 (m_frameToolBar->m_widget->parent == m_mainWidget))
ab2b3dd4
RR
923 {
924 int xx = m_miniEdge;
925 int yy = m_miniEdge + m_miniTitle;
1e6feb95 926#if wxUSE_MENUS
41ca191f 927 if (m_frameMenuBar)
f03fc89f 928 {
88ac883a
VZ
929 if (!m_menuBarDetached)
930 yy += wxMENU_HEIGHT;
931 else
f03fc89f
VZ
932 yy += wxPLACE_HOLDER;
933 }
1e6feb95 934#endif // wxUSE_MENUS
93fa69f8 935
121a3581
RR
936 m_frameToolBar->m_x = xx;
937 m_frameToolBar->m_y = yy;
93fa69f8
VZ
938
939 /* don't change the toolbar's reported height/width */
940 int ww, hh;
941 if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL )
942 {
943 ww = m_toolBarDetached ? wxPLACE_HOLDER
944 : m_frameToolBar->m_width;
945 hh = m_height - 2*m_miniEdge;
946
947 client_area_x_offset += ww;
948 }
949 else
950 {
951 ww = m_width - 2*m_miniEdge;
952 hh = m_toolBarDetached ? wxPLACE_HOLDER
953 : m_frameToolBar->m_height;
954
955 client_area_y_offset += hh;
956 }
957
da048e3d 958 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
88ac883a 959 m_frameToolBar->m_widget,
f03fc89f 960 xx, yy, ww, hh );
ab2b3dd4 961 }
93fa69f8 962#endif // wxUSE_TOOLBAR
88ac883a 963
93fa69f8 964 int client_x = client_area_x_offset + m_miniEdge;
f03fc89f 965 int client_y = client_area_y_offset + m_miniEdge + m_miniTitle;
93fa69f8 966 int client_w = m_width - client_area_x_offset - 2*m_miniEdge;
f03fc89f 967 int client_h = m_height - client_area_y_offset- 2*m_miniEdge - m_miniTitle;
da048e3d 968 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
88ac883a 969 m_wxwindow,
f03fc89f 970 client_x, client_y, client_w, client_h );
32a95f9f
RR
971 }
972 else
973 {
974 /* if there is no m_mainWidget between m_widget and m_wxwindow there
f03fc89f 975 is no need to set the size or position of m_wxwindow. */
f5368809 976 }
88ac883a 977
dcf924a3 978#if wxUSE_STATUSBAR
fa755cf1 979 if (m_frameStatusBar && m_frameStatusBar->IsShown())
f5368809 980 {
b2b3ccc5 981 int xx = 0 + m_miniEdge;
f362b96d 982 int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge - client_area_y_offset;
ac57418f
RR
983 int ww = m_width - 2*m_miniEdge;
984 int hh = wxSTATUS_HEIGHT;
121a3581
RR
985 m_frameStatusBar->m_x = xx;
986 m_frameStatusBar->m_y = yy;
987 m_frameStatusBar->m_width = ww;
988 m_frameStatusBar->m_height = hh;
da048e3d 989 gtk_pizza_set_size( GTK_PIZZA(m_wxwindow),
7c0ea335
VZ
990 m_frameStatusBar->m_widget,
991 xx, yy, ww, hh );
b6fa52db 992 gtk_widget_draw( m_frameStatusBar->m_widget, (GdkRectangle*) NULL );
f5368809 993 }
1e6feb95 994#endif // wxUSE_STATUSBAR
8bbe427f 995
54517652 996 m_sizeSet = TRUE;
7beba2fc 997
54517652 998 // send size event to frame
43a18898
RR
999 wxSizeEvent event( wxSize(m_width,m_height), GetId() );
1000 event.SetEventObject( this );
e52f60e6 1001 GetEventHandler()->ProcessEvent( event );
8bbe427f 1002
1e6feb95 1003#if wxUSE_STATUSBAR
54517652 1004 // send size event to status bar
5aa5e35a
RR
1005 if (m_frameStatusBar)
1006 {
a2053b27 1007 wxSizeEvent event2( wxSize(m_frameStatusBar->m_width,m_frameStatusBar->m_height), m_frameStatusBar->GetId() );
5aa5e35a
RR
1008 event2.SetEventObject( m_frameStatusBar );
1009 m_frameStatusBar->GetEventHandler()->ProcessEvent( event2 );
1010 }
1e6feb95 1011#endif // wxUSE_STATUSBAR
884470b1 1012
e52f60e6
RR
1013 m_resizing = FALSE;
1014}
1015
1e6feb95 1016void wxFrameGTK::MakeModal( bool modal )
ca26177c
RR
1017{
1018 if (modal)
ca26177c 1019 gtk_grab_add( m_widget );
ca26177c 1020 else
c25ccf85 1021 gtk_grab_remove( m_widget );
ca26177c
RR
1022}
1023
1e6feb95 1024void wxFrameGTK::OnInternalIdle()
e52f60e6 1025{
1b3667ab 1026 if (!m_sizeSet && GTK_WIDGET_REALIZED(m_wxwindow))
54517652 1027 {
e52f60e6 1028 GtkOnSize( m_x, m_y, m_width, m_height );
7beba2fc
VZ
1029
1030 // we'll come back later
54517652
RR
1031 if (g_isIdle)
1032 wxapp_install_idle_handler();
7beba2fc 1033 return;
54517652 1034 }
88ac883a 1035
1e6feb95 1036#if wxUSE_MENUS
082b2798 1037 if (m_frameMenuBar) m_frameMenuBar->OnInternalIdle();
1e6feb95 1038#endif // wxUSE_MENUS
dcf924a3 1039#if wxUSE_TOOLBAR
082b2798 1040 if (m_frameToolBar) m_frameToolBar->OnInternalIdle();
dcf924a3
RR
1041#endif
1042#if wxUSE_STATUSBAR
082b2798 1043 if (m_frameStatusBar) m_frameStatusBar->OnInternalIdle();
dcf924a3 1044#endif
5e014a0c
RR
1045
1046 wxWindow::OnInternalIdle();
362c6693 1047}
c801d85f 1048
7c0ea335
VZ
1049// ----------------------------------------------------------------------------
1050// menu/tool/status bar stuff
1051// ----------------------------------------------------------------------------
c801d85f 1052
1e6feb95
VZ
1053#if wxUSE_MENUS
1054
1055void wxFrameGTK::SetMenuBar( wxMenuBar *menuBar )
c801d85f 1056{
223d09f6
KB
1057 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
1058 wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") );
8bbe427f 1059
186baeb2
RR
1060 if (menuBar == m_frameMenuBar)
1061 return;
1062
1063 if (m_frameMenuBar)
1064 {
1065 m_frameMenuBar->UnsetInvokingWindow( this );
1066
1067 if (m_frameMenuBar->GetWindowStyle() & wxMB_DOCKABLE)
1068 {
1069 gtk_signal_disconnect_by_func( GTK_OBJECT(m_frameMenuBar->m_widget),
1070 GTK_SIGNAL_FUNC(gtk_menu_attached_callback), (gpointer)this );
1071
1072 gtk_signal_disconnect_by_func( GTK_OBJECT(m_frameMenuBar->m_widget),
1073 GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this );
1074 }
f6bcfd97 1075
186baeb2
RR
1076 gtk_container_remove( GTK_CONTAINER(m_mainWidget), m_frameMenuBar->m_widget );
1077 gtk_widget_ref( m_frameMenuBar->m_widget );
1078 gtk_widget_unparent( m_frameMenuBar->m_widget );
1079 }
1080
f5368809 1081 m_frameMenuBar = menuBar;
8bbe427f 1082
f5368809 1083 if (m_frameMenuBar)
30dea054 1084 {
5bd9e519 1085 m_frameMenuBar->SetInvokingWindow( this );
8bbe427f 1086
186baeb2
RR
1087 m_frameMenuBar->SetParent(this);
1088 gtk_pizza_put( GTK_PIZZA(m_mainWidget),
88ac883a
VZ
1089 m_frameMenuBar->m_widget,
1090 m_frameMenuBar->m_x,
a2053b27
RR
1091 m_frameMenuBar->m_y,
1092 m_frameMenuBar->m_width,
1093 m_frameMenuBar->m_height );
88ac883a 1094
186baeb2
RR
1095 if (menuBar->GetWindowStyle() & wxMB_DOCKABLE)
1096 {
1097 gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_attached",
1098 GTK_SIGNAL_FUNC(gtk_menu_attached_callback), (gpointer)this );
7beba2fc 1099
186baeb2
RR
1100 gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_detached",
1101 GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this );
f5368809 1102 }
186baeb2
RR
1103
1104 m_frameMenuBar->Show( TRUE );
716b7364 1105 }
8bbe427f 1106
1e133b7d 1107 /* resize window in OnInternalIdle */
5b077d48 1108 m_sizeSet = FALSE;
362c6693 1109}
c801d85f 1110
1e6feb95
VZ
1111#endif // wxUSE_MENUS
1112
88ac883a 1113#if wxUSE_TOOLBAR
1e6feb95
VZ
1114
1115wxToolBar* wxFrameGTK::CreateToolBar( long style, wxWindowID id, const wxString& name )
46dc76ba 1116{
223d09f6 1117 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 1118
6bc8a1c8 1119 m_insertInClientArea = FALSE;
88ac883a 1120
7c0ea335 1121 m_frameToolBar = wxFrameBase::CreateToolBar( style, id, name );
8bbe427f 1122
6bc8a1c8 1123 m_insertInClientArea = TRUE;
8bbe427f 1124
5b077d48 1125 m_sizeSet = FALSE;
8bbe427f 1126
f5368809 1127 return m_frameToolBar;
362c6693 1128}
46dc76ba 1129
1e6feb95 1130void wxFrameGTK::SetToolBar(wxToolBar *toolbar)
7beba2fc 1131{
7c0ea335
VZ
1132 wxFrameBase::SetToolBar(toolbar);
1133
307f16e8
RR
1134 if (m_frameToolBar)
1135 {
1136 /* insert into toolbar area if not already there */
3017f78d
RR
1137 if ((m_frameToolBar->m_widget->parent) &&
1138 (m_frameToolBar->m_widget->parent != m_mainWidget))
307f16e8 1139 {
3017f78d 1140 GetChildren().DeleteObject( m_frameToolBar );
7beba2fc
VZ
1141
1142 gtk_widget_reparent( m_frameToolBar->m_widget, m_mainWidget );
5b8a521e 1143 GtkUpdateSize();
7beba2fc 1144 }
307f16e8
RR
1145 }
1146}
1147
88ac883a 1148#endif // wxUSE_TOOLBAR
46dc76ba 1149
88ac883a 1150#if wxUSE_STATUSBAR
8bbe427f 1151
1e6feb95 1152wxStatusBar* wxFrameGTK::CreateStatusBar(int number,
7c0ea335
VZ
1153 long style,
1154 wxWindowID id,
1155 const wxString& name)
c801d85f 1156{
223d09f6 1157 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 1158
7c0ea335
VZ
1159 // because it will change when toolbar is added
1160 m_sizeSet = FALSE;
c801d85f 1161
7c0ea335 1162 return wxFrameBase::CreateStatusBar( number, style, id, name );
362c6693
RR
1163}
1164
1e6feb95 1165void wxFrameGTK::PositionStatusBar()
8febdd39
RR
1166{
1167 if ( !m_frameStatusBar )
1168 return;
1169
1170 m_sizeSet = FALSE;
1171}
88ac883a 1172#endif // wxUSE_STATUSBAR
c801d85f 1173
7c0ea335
VZ
1174// ----------------------------------------------------------------------------
1175// frame title/icon
1176// ----------------------------------------------------------------------------
c801d85f 1177
1e6feb95 1178void wxFrameGTK::SetTitle( const wxString &title )
c801d85f 1179{
223d09f6 1180 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 1181
f5368809 1182 m_title = title;
ed9b9841 1183 gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() );
362c6693 1184}
c801d85f 1185
1e6feb95 1186void wxFrameGTK::SetIcon( const wxIcon &icon )
d355d3fe 1187{
223d09f6 1188 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 1189
7c0ea335 1190 wxFrameBase::SetIcon(icon);
8bbe427f 1191
7c0ea335
VZ
1192 if ( !m_icon.Ok() )
1193 return;
1194
1195 if (!m_widget->window)
1196 return;
58dea4b0 1197
f5368809
RR
1198 wxMask *mask = icon.GetMask();
1199 GdkBitmap *bm = (GdkBitmap *) NULL;
1200 if (mask) bm = mask->GetBitmap();
8bbe427f 1201
f5368809 1202 gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm );
d355d3fe 1203}
b2b3ccc5 1204
7c0ea335 1205// ----------------------------------------------------------------------------
c0f09a2e 1206// frame state: maximized/iconized/normal
7c0ea335
VZ
1207// ----------------------------------------------------------------------------
1208
1e6feb95 1209void wxFrameGTK::Maximize(bool WXUNUSED(maximize))
cd25b18c 1210{
c0f09a2e 1211 wxFAIL_MSG( _T("not implemented") );
cd25b18c
RR
1212}
1213
1e6feb95 1214bool wxFrameGTK::IsMaximized() const
7c0ea335 1215{
a2d93e73 1216 // wxFAIL_MSG( _T("not implemented") );
c0f09a2e 1217
a2d93e73 1218 // This is an approximation
7c0ea335
VZ
1219 return FALSE;
1220}
1221
1e6feb95 1222void wxFrameGTK::Restore()
cd25b18c 1223{
c0f09a2e 1224 wxFAIL_MSG( _T("not implemented") );
cd25b18c
RR
1225}
1226
1e6feb95 1227void wxFrameGTK::Iconize( bool iconize )
7beba2fc 1228{
cd25b18c
RR
1229 if (iconize)
1230 {
48ff57ae
VZ
1231 GdkWindow *window = m_widget->window;
1232
1233 // you should do it later, for example from OnCreate() handler
1234 wxCHECK_RET( window, _T("frame not created yet - can't iconize") );
1235
1236 XIconifyWindow( GDK_WINDOW_XDISPLAY( window ),
1237 GDK_WINDOW_XWINDOW( window ),
1238 DefaultScreen( GDK_DISPLAY() ) );
cd25b18c
RR
1239 }
1240}
1241
1e6feb95 1242bool wxFrameGTK::IsIconized() const
7beba2fc 1243{
43f5c493 1244 return m_isIconized;
cd25b18c 1245}
3dd9b88a 1246
2a365b7d 1247void wxFrameGTK::SetIconizeState(bool iconize)
3dd9b88a
VZ
1248{
1249 if ( iconize != m_isIconized )
1250 {
1251 m_isIconized = iconize;
1252 (void)SendIconizeEvent(iconize);
1253 }
3dd9b88a
VZ
1254}
1255