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