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