1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // ============================================================================
12 // ============================================================================
14 // ----------------------------------------------------------------------------
16 // ----------------------------------------------------------------------------
19 #pragma implementation "toplevel.h"
23 #define XIconifyWindow XICONIFYWINDOW
28 #include "wx/dialog.h"
29 #include "wx/control.h"
31 #include "wx/dcclient.h"
36 #include <gdk/gdkkeysyms.h>
39 #include "wx/gtk/win_gtk.h"
41 #include "wx/unix/utilsx11.h"
43 // ----------------------------------------------------------------------------
45 // ----------------------------------------------------------------------------
47 extern void wxapp_install_idle_handler();
50 // ----------------------------------------------------------------------------
52 // ----------------------------------------------------------------------------
54 extern wxList wxPendingDelete
;
56 extern int g_openDialogs
;
57 extern wxWindowGTK
*g_delayedFocus
;
59 //-----------------------------------------------------------------------------
60 // "focus" from m_window
61 //-----------------------------------------------------------------------------
63 static gint
gtk_frame_focus_callback( GtkWidget
*widget
, GtkDirectionType
WXUNUSED(d
), wxWindow
*WXUNUSED(win
) )
66 wxapp_install_idle_handler();
68 // This disables GTK's tab traversal
69 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "focus" );
73 //-----------------------------------------------------------------------------
75 //-----------------------------------------------------------------------------
77 static void gtk_frame_size_callback( GtkWidget
*WXUNUSED(widget
), GtkAllocation
* alloc
, wxTopLevelWindowGTK
*win
)
80 wxapp_install_idle_handler();
85 if ((win
->m_width
!= alloc
->width
) || (win
->m_height
!= alloc
->height
))
88 wxPrintf( "OnSize from " );
89 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
90 wxPrintf( win->GetClassInfo()->GetClassName() );
91 wxPrintf( " %d %d %d %d\n", (int)alloc->x,
97 win
->m_width
= alloc
->width
;
98 win
->m_height
= alloc
->height
;
99 win
->m_queuedFullRedraw
= TRUE
;
100 win
->GtkUpdateSize();
104 //-----------------------------------------------------------------------------
106 //-----------------------------------------------------------------------------
108 static gint
gtk_frame_delete_callback( GtkWidget
*WXUNUSED(widget
), GdkEvent
*WXUNUSED(event
), wxTopLevelWindowGTK
*win
)
111 wxapp_install_idle_handler();
113 if (win
->IsEnabled() &&
114 (g_openDialogs
== 0 || (win
->GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
) ||
122 //-----------------------------------------------------------------------------
124 //-----------------------------------------------------------------------------
127 gtk_frame_configure_callback( GtkWidget
*WXUNUSED(widget
), GdkEventConfigure
*WXUNUSED(event
), wxTopLevelWindowGTK
*win
)
130 wxapp_install_idle_handler();
132 if (!win
->m_hasVMT
|| !win
->IsShown())
137 gdk_window_get_root_origin( win
->m_widget
->window
, &x
, &y
);
141 wxMoveEvent
mevent( wxPoint(win
->m_x
,win
->m_y
), win
->GetId() );
142 mevent
.SetEventObject( win
);
143 win
->GetEventHandler()->ProcessEvent( mevent
);
148 //-----------------------------------------------------------------------------
149 // "realize" from m_widget
150 //-----------------------------------------------------------------------------
152 // we cannot MWM hints and icons before the widget has been realized,
153 // so we do this directly after realization
156 gtk_frame_realized_callback( GtkWidget
* WXUNUSED(widget
),
157 wxTopLevelWindowGTK
*win
)
160 wxapp_install_idle_handler();
162 // All this is for Motif Window Manager "hints" and is supposed to be
163 // recognized by other WM as well. Not tested.
164 gdk_window_set_decorations(win
->m_widget
->window
,
165 (GdkWMDecoration
)win
->m_gdkDecor
);
166 gdk_window_set_functions(win
->m_widget
->window
,
167 (GdkWMFunction
)win
->m_gdkFunc
);
169 // GTK's shrinking/growing policy
170 if ((win
->m_gdkFunc
& GDK_FUNC_RESIZE
) == 0)
171 gtk_window_set_policy(GTK_WINDOW(win
->m_widget
), 0, 0, 1);
173 gtk_window_set_policy(GTK_WINDOW(win
->m_widget
), 1, 1, 1);
176 wxIconBundle iconsOld
= win
->GetIcons();
177 if ( iconsOld
.GetIcon(-1).Ok() )
179 win
->SetIcon( wxNullIcon
);
180 win
->SetIcons( iconsOld
);
184 //-----------------------------------------------------------------------------
185 // "map_event" from m_widget
186 //-----------------------------------------------------------------------------
189 gtk_frame_map_callback( GtkWidget
* WXUNUSED(widget
),
190 GdkEvent
* WXUNUSED(event
),
191 wxTopLevelWindow
*win
)
193 win
->SetIconizeState(FALSE
);
196 //-----------------------------------------------------------------------------
197 // "unmap_event" from m_widget
198 //-----------------------------------------------------------------------------
201 gtk_frame_unmap_callback( GtkWidget
* WXUNUSED(widget
),
202 GdkEvent
* WXUNUSED(event
),
203 wxTopLevelWindow
*win
)
205 win
->SetIconizeState(TRUE
);
208 //-----------------------------------------------------------------------------
209 // "expose_event" of m_client
210 //-----------------------------------------------------------------------------
212 static int gtk_window_expose_callback( GtkWidget
*widget
, GdkEventExpose
*gdk_event
, wxWindow
*win
)
214 GtkPizza
*pizza
= GTK_PIZZA(widget
);
216 gtk_paint_flat_box (win
->m_widget
->style
,
217 pizza
->bin_window
, GTK_STATE_NORMAL
,
227 //-----------------------------------------------------------------------------
228 // "draw" of m_client
229 //-----------------------------------------------------------------------------
233 static void gtk_window_draw_callback( GtkWidget
*widget
, GdkRectangle
*rect
, wxWindow
*win
)
235 GtkPizza
*pizza
= GTK_PIZZA(widget
);
237 gtk_paint_flat_box (win
->m_widget
->style
,
238 pizza
->bin_window
, GTK_STATE_NORMAL
,
248 // ----------------------------------------------------------------------------
249 // wxTopLevelWindowGTK itself
250 // ----------------------------------------------------------------------------
252 //-----------------------------------------------------------------------------
253 // InsertChild for wxTopLevelWindowGTK
254 //-----------------------------------------------------------------------------
256 /* Callback for wxTopLevelWindowGTK. This very strange beast has to be used because
257 * C++ has no virtual methods in a constructor. We have to emulate a
258 * virtual function here as wxWindows requires different ways to insert
259 * a child in container classes. */
261 static void wxInsertChildInTopLevelWindow( wxTopLevelWindowGTK
* parent
, wxWindow
* child
)
263 wxASSERT( GTK_IS_WIDGET(child
->m_widget
) );
265 if (!parent
->m_insertInClientArea
)
267 // these are outside the client area
268 wxTopLevelWindowGTK
* frame
= (wxTopLevelWindowGTK
*) parent
;
269 gtk_pizza_put( GTK_PIZZA(frame
->m_mainWidget
),
270 GTK_WIDGET(child
->m_widget
),
278 // these are inside the client area
279 gtk_pizza_put( GTK_PIZZA(parent
->m_wxwindow
),
280 GTK_WIDGET(child
->m_widget
),
287 // resize on OnInternalIdle
288 parent
->GtkUpdateSize();
291 // ----------------------------------------------------------------------------
292 // wxTopLevelWindowGTK creation
293 // ----------------------------------------------------------------------------
295 void wxTopLevelWindowGTK::Init()
300 m_mainWidget
= (GtkWidget
*) NULL
;
301 m_insertInClientArea
= TRUE
;
302 m_isIconized
= FALSE
;
303 m_fsIsShowing
= FALSE
;
304 m_themeEnabled
= TRUE
;
305 m_gdkDecor
= m_gdkFunc
= 0;
309 bool wxTopLevelWindowGTK::Create( wxWindow
*parent
,
311 const wxString
& title
,
313 const wxSize
& sizeOrig
,
315 const wxString
&name
)
317 // always create a frame of some reasonable, even if arbitrary, size (at
318 // least for MSW compatibility)
319 wxSize size
= sizeOrig
;
320 if ( size
.x
== -1 || size
.y
== -1 )
322 wxSize sizeDpy
= wxGetDisplaySize();
324 size
.x
= sizeDpy
.x
/ 3;
326 size
.y
= sizeDpy
.y
/ 5;
329 wxTopLevelWindows
.Append( this );
331 m_needParent
= FALSE
;
333 if (!PreCreation( parent
, pos
, size
) ||
334 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
336 wxFAIL_MSG( wxT("wxTopLevelWindowGTK creation failed") );
342 m_insertCallback
= (wxInsertChildFunction
) wxInsertChildInTopLevelWindow
;
344 GtkWindowType win_type
= GTK_WINDOW_TOPLEVEL
;
346 if (style
& wxFRAME_TOOL_WINDOW
)
347 win_type
= GTK_WINDOW_POPUP
;
349 if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
)
351 // there is no more GTK_WINDOW_DIALOG in 2.0
353 win_type
= GTK_WINDOW_TOPLEVEL
;
355 win_type
= GTK_WINDOW_DIALOG
;
359 m_widget
= gtk_window_new( win_type
);
361 if (m_parent
&& (GTK_IS_WINDOW(m_parent
->m_widget
)) &&
362 (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
))
364 gtk_window_set_transient_for( GTK_WINDOW(m_widget
), GTK_WINDOW(m_parent
->m_widget
) );
368 gtk_window_set_wmclass( GTK_WINDOW(m_widget
), name
.mb_str(), name
.mb_str() );
370 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
371 GTK_WIDGET_UNSET_FLAGS( m_widget
, GTK_CAN_FOCUS
);
373 gtk_signal_connect( GTK_OBJECT(m_widget
), "delete_event",
374 GTK_SIGNAL_FUNC(gtk_frame_delete_callback
), (gpointer
)this );
376 // m_mainWidget holds the toolbar, the menubar and the client area
377 m_mainWidget
= gtk_pizza_new();
378 gtk_widget_show( m_mainWidget
);
379 GTK_WIDGET_UNSET_FLAGS( m_mainWidget
, GTK_CAN_FOCUS
);
380 gtk_container_add( GTK_CONTAINER(m_widget
), m_mainWidget
);
382 // for m_mainWidget themes
383 gtk_signal_connect( GTK_OBJECT(m_mainWidget
), "expose_event",
384 GTK_SIGNAL_FUNC(gtk_window_expose_callback
), (gpointer
)this );
386 gtk_signal_connect( GTK_OBJECT(m_mainWidget
), "draw",
387 GTK_SIGNAL_FUNC(gtk_window_draw_callback
), (gpointer
)this );
390 // m_wxwindow only represents the client area without toolbar and menubar
391 m_wxwindow
= gtk_pizza_new();
392 gtk_widget_show( m_wxwindow
);
393 gtk_container_add( GTK_CONTAINER(m_mainWidget
), m_wxwindow
);
395 // we donm't allow the frame to get the focus as otherwise
396 // the frame will grab it at arbitrary focus changes
397 GTK_WIDGET_UNSET_FLAGS( m_wxwindow
, GTK_CAN_FOCUS
);
399 if (m_parent
) m_parent
->AddChild( this );
401 // the user resized the frame by dragging etc.
402 gtk_signal_connect( GTK_OBJECT(m_widget
), "size_allocate",
403 GTK_SIGNAL_FUNC(gtk_frame_size_callback
), (gpointer
)this );
407 if ((m_x
!= -1) || (m_y
!= -1))
408 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
410 gtk_window_set_default_size( GTK_WINDOW(m_widget
), m_width
, m_height
);
412 // we cannot set MWM hints and icons before the widget has
413 // been realized, so we do this directly after realization
414 gtk_signal_connect( GTK_OBJECT(m_widget
), "realize",
415 GTK_SIGNAL_FUNC(gtk_frame_realized_callback
), (gpointer
) this );
417 // the only way to get the window size is to connect to this event
418 gtk_signal_connect( GTK_OBJECT(m_widget
), "configure_event",
419 GTK_SIGNAL_FUNC(gtk_frame_configure_callback
), (gpointer
)this );
421 // map and unmap for iconized state
422 gtk_signal_connect( GTK_OBJECT(m_widget
), "map_event",
423 GTK_SIGNAL_FUNC(gtk_frame_map_callback
), (gpointer
)this );
424 gtk_signal_connect( GTK_OBJECT(m_widget
), "unmap_event",
425 GTK_SIGNAL_FUNC(gtk_frame_unmap_callback
), (gpointer
)this );
427 // the only way to get the window size is to connect to this event
428 gtk_signal_connect( GTK_OBJECT(m_widget
), "configure_event",
429 GTK_SIGNAL_FUNC(gtk_frame_configure_callback
), (gpointer
)this );
431 // disable native tab traversal
432 gtk_signal_connect( GTK_OBJECT(m_widget
), "focus",
433 GTK_SIGNAL_FUNC(gtk_frame_focus_callback
), (gpointer
)this );
436 if ((m_miniEdge
> 0) || (style
& wxSIMPLE_BORDER
) || (style
& wxNO_BORDER
))
443 m_gdkDecor
= (long) GDK_DECOR_BORDER
;
444 m_gdkFunc
= (long) GDK_FUNC_MOVE
;
446 // All this is for Motif Window Manager "hints" and is supposed to be
447 // recognized by other WMs as well.
448 if ((style
& wxCAPTION
) != 0)
449 m_gdkDecor
|= GDK_DECOR_TITLE
;
450 if ((style
& wxSYSTEM_MENU
) != 0)
452 m_gdkFunc
|= GDK_FUNC_CLOSE
;
453 m_gdkDecor
|= GDK_DECOR_MENU
;
455 if ((style
& wxMINIMIZE_BOX
) != 0)
457 m_gdkFunc
|= GDK_FUNC_MINIMIZE
;
458 m_gdkDecor
|= GDK_DECOR_MINIMIZE
;
460 if ((style
& wxMAXIMIZE_BOX
) != 0)
462 m_gdkFunc
|= GDK_FUNC_MAXIMIZE
;
463 m_gdkDecor
|= GDK_DECOR_MAXIMIZE
;
465 if ((style
& wxRESIZE_BORDER
) != 0)
467 m_gdkFunc
|= GDK_FUNC_RESIZE
;
468 m_gdkDecor
|= GDK_DECOR_RESIZEH
;
475 wxTopLevelWindowGTK::~wxTopLevelWindowGTK()
479 wxASSERT_MSG( FALSE
, "Window still grabbed");
483 m_isBeingDeleted
= TRUE
;
485 // it may also be GtkScrolledWindow in the case of an MDI child
486 if (GTK_IS_WINDOW(m_widget
))
488 gtk_window_set_focus( GTK_WINDOW(m_widget
), NULL
);
491 wxTopLevelWindows
.DeleteObject( this );
493 if (wxTheApp
->GetTopWindow() == this)
494 wxTheApp
->SetTopWindow( (wxWindow
*) NULL
);
496 if ((wxTopLevelWindows
.Number() == 0) &&
497 (wxTheApp
->GetExitOnFrameDelete()))
499 wxTheApp
->ExitMainLoop();
503 bool wxTopLevelWindowGTK::ShowFullScreen(bool show
, long style
)
505 if (show
== m_fsIsShowing
) return FALSE
; // return what?
507 m_fsIsShowing
= show
;
511 m_fsSaveGdkFunc
= m_gdkFunc
;
512 m_fsSaveGdkDecor
= m_gdkDecor
;
513 m_fsSaveFlag
= style
;
514 GetPosition( &m_fsSaveFrame
.x
, &m_fsSaveFrame
.y
);
515 GetSize( &m_fsSaveFrame
.width
, &m_fsSaveFrame
.height
);
517 gtk_widget_hide( m_widget
);
518 gtk_widget_unrealize( m_widget
);
520 m_gdkDecor
= (long) GDK_DECOR_BORDER
;
521 m_gdkFunc
= (long) GDK_FUNC_MOVE
;
525 wxDisplaySize( &x
, &y
);
526 SetSize( 0, 0, x
, y
);
528 gtk_widget_realize( m_widget
);
529 gtk_widget_show( m_widget
);
533 gtk_widget_hide( m_widget
);
534 gtk_widget_unrealize( m_widget
);
536 m_gdkFunc
= m_fsSaveGdkFunc
;
537 m_gdkDecor
= m_fsSaveGdkDecor
;
539 SetSize( m_fsSaveFrame
.x
, m_fsSaveFrame
.y
, m_fsSaveFrame
.width
, m_fsSaveFrame
.height
);
541 gtk_widget_realize( m_widget
);
542 gtk_widget_show( m_widget
);
548 // ----------------------------------------------------------------------------
549 // overridden wxWindow methods
550 // ----------------------------------------------------------------------------
552 bool wxTopLevelWindowGTK::Show( bool show
)
554 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
556 if (show
&& !m_sizeSet
)
558 /* by calling GtkOnSize here, we don't have to call
559 either after showing the frame, which would entail
560 much ugly flicker or from within the size_allocate
561 handler, because GTK 1.1.X forbids that. */
563 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
566 return wxWindow::Show( show
);
569 void wxTopLevelWindowGTK::DoMoveWindow(int WXUNUSED(x
), int WXUNUSED(y
), int WXUNUSED(width
), int WXUNUSED(height
) )
571 wxFAIL_MSG( wxT("DoMoveWindow called for wxTopLevelWindowGTK") );
574 void wxTopLevelWindowGTK::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
576 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
578 // this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow
579 wxASSERT_MSG( (m_wxwindow
!= NULL
), wxT("invalid frame") );
589 int old_width
= m_width
;
590 int old_height
= m_height
;
592 if ((sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) == 0)
594 if (x
!= -1) m_x
= x
;
595 if (y
!= -1) m_y
= y
;
602 if (width
!= -1) m_width
= width
;
603 if (height
!= -1) m_height
= height
;
606 if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
608 if (width == -1) m_width = 80;
611 if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
613 if (height == -1) m_height = 26;
617 int minWidth
= GetMinWidth(),
618 minHeight
= GetMinHeight(),
619 maxWidth
= GetMaxWidth(),
620 maxHeight
= GetMaxHeight();
622 if ((minWidth
!= -1) && (m_width
< minWidth
)) m_width
= minWidth
;
623 if ((minHeight
!= -1) && (m_height
< minHeight
)) m_height
= minHeight
;
624 if ((maxWidth
!= -1) && (m_width
> maxWidth
)) m_width
= maxWidth
;
625 if ((maxHeight
!= -1) && (m_height
> maxHeight
)) m_height
= maxHeight
;
627 if ((m_x
!= -1) || (m_y
!= -1))
629 if ((m_x
!= old_x
) || (m_y
!= old_y
))
631 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
635 if ((m_width
!= old_width
) || (m_height
!= old_height
))
637 if (m_widget
->window
)
638 gdk_window_resize( m_widget
->window
, m_width
, m_height
);
640 gtk_window_set_default_size( GTK_WINDOW(m_widget
), m_width
, m_height
);
642 /* we set the size in GtkOnSize, i.e. mostly the actual resizing is
643 done either directly before the frame is shown or in idle time
644 so that different calls to SetSize() don't lead to flicker. */
651 void wxTopLevelWindowGTK::DoGetClientSize( int *width
, int *height
) const
653 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
655 wxWindow::DoGetClientSize( width
, height
);
659 *height
-= m_miniEdge
*2 + m_miniTitle
;
663 *width
-= m_miniEdge
*2;
667 void wxTopLevelWindowGTK::DoSetClientSize( int width
, int height
)
669 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
672 width
+ m_miniEdge
*2, height
+ m_miniEdge
*2 + m_miniTitle
, 0);
675 void wxTopLevelWindowGTK::GtkOnSize( int WXUNUSED(x
), int WXUNUSED(y
),
676 int width
, int height
)
678 // due to a bug in gtk, x,y are always 0
683 if (m_resizing
) return;
686 if ( m_wxwindow
== NULL
) return;
691 /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses
692 wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
693 set in wxFrame::Create so it is used to check what kind of frame we
694 have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
695 skip the part which handles m_frameMenuBar, m_frameToolBar and (most
696 importantly) m_mainWidget */
698 int minWidth
= GetMinWidth(),
699 minHeight
= GetMinHeight(),
700 maxWidth
= GetMaxWidth(),
701 maxHeight
= GetMaxHeight();
703 if ((minWidth
!= -1) && (m_width
< minWidth
)) m_width
= minWidth
;
704 if ((minHeight
!= -1) && (m_height
< minHeight
)) m_height
= minHeight
;
705 if ((maxWidth
!= -1) && (m_width
> maxWidth
)) m_width
= maxWidth
;
706 if ((maxHeight
!= -1) && (m_height
> maxHeight
)) m_height
= maxHeight
;
711 gint flag
= 0; // GDK_HINT_POS;
714 if ((minWidth
!= -1) || (minHeight
!= -1)) flag
|= GDK_HINT_MIN_SIZE
;
715 if ((maxWidth
!= -1) || (maxHeight
!= -1)) flag
|= GDK_HINT_MAX_SIZE
;
717 geom
.min_width
= minWidth
;
718 geom
.min_height
= minHeight
;
720 // Because of the way we set GDK_HINT_MAX_SIZE above, if either of
721 // maxHeight or maxWidth is set, we must set them both, else the
722 // remaining -1 will be taken literally.
724 // I'm certain this also happens elsewhere, and is the probable
725 // cause of other such things as:
726 // Gtk-WARNING **: gtk_widget_size_allocate():
727 // attempt to allocate widget with width 65535 and height 600
728 // but I don't have time to track them all now..
730 // Really we need to encapulate all this height/width business and
731 // stop any old method from ripping at the members directly and
732 // scattering -1's without regard for who might resolve them later.
734 geom
.max_width
= ( maxHeight
== -1 ) ? maxWidth
735 : ( maxWidth
== -1 ) ? wxGetDisplaySize().GetWidth()
738 geom
.max_height
= ( maxWidth
== -1 ) ? maxHeight
// ( == -1 here )
739 : ( maxHeight
== -1 ) ? wxGetDisplaySize().GetHeight()
742 gtk_window_set_geometry_hints( GTK_WINDOW(m_widget
),
745 (GdkWindowHints
) flag
);
747 /* I revert back to wxGTK's original behaviour. m_mainWidget holds the
748 * menubar, the toolbar and the client area, which is represented by
750 * this hurts in the eye, but I don't want to call SetSize()
751 * because I don't want to call any non-native functions here. */
753 int client_x
= m_miniEdge
;
754 int client_y
= m_miniEdge
+ m_miniTitle
;
755 int client_w
= m_width
- 2*m_miniEdge
;
756 int client_h
= m_height
- 2*m_miniEdge
- m_miniTitle
;
758 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget
),
760 client_x
, client_y
, client_w
, client_h
);
764 // If there is no m_mainWidget between m_widget and m_wxwindow there
765 // is no need to set the size or position of m_wxwindow.
770 // send size event to frame
771 wxSizeEvent
event( wxSize(m_width
,m_height
), GetId() );
772 event
.SetEventObject( this );
773 GetEventHandler()->ProcessEvent( event
);
778 void wxTopLevelWindowGTK::OnInternalIdle()
780 if (!m_sizeSet
&& GTK_WIDGET_REALIZED(m_wxwindow
))
782 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
784 // we'll come back later
786 wxapp_install_idle_handler();
790 // set the focus if not done yet and if we can already do it
791 if ( GTK_WIDGET_REALIZED(m_wxwindow
) )
793 if ( g_delayedFocus
&&
794 wxGetTopLevelParent((wxWindow
*)g_delayedFocus
) == this )
796 g_delayedFocus
->SetFocus();
797 g_delayedFocus
= NULL
;
801 wxWindow::OnInternalIdle();
804 // ----------------------------------------------------------------------------
806 // ----------------------------------------------------------------------------
808 void wxTopLevelWindowGTK::SetTitle( const wxString
&title
)
810 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
813 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
816 void wxTopLevelWindowGTK::DoSetIcon( const wxIcon
&icon
)
821 if (!m_widget
->window
)
824 wxMask
*mask
= icon
.GetMask();
825 GdkBitmap
*bm
= (GdkBitmap
*) NULL
;
826 if (mask
) bm
= mask
->GetBitmap();
828 gdk_window_set_icon( m_widget
->window
, (GdkWindow
*) NULL
, icon
.GetPixmap(), bm
);
831 void wxTopLevelWindowGTK::SetIcon( const wxIcon
&icon
)
833 SetIcons( wxIconBundle( icon
) );
836 void wxTopLevelWindowGTK::SetIcons( const wxIconBundle
&icons
)
838 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
839 GdkWindow
* window
= m_widget
->window
;
841 wxTopLevelWindowBase::SetIcons( icons
);
843 DoSetIcon( icons
.GetIcon( -1 ) );
846 wxSetIconsX11( (WXDisplay
*)GDK_WINDOW_XDISPLAY( window
),
847 (WXWindow
)GDK_WINDOW_XWINDOW( window
), icons
);
851 // ----------------------------------------------------------------------------
852 // frame state: maximized/iconized/normal
853 // ----------------------------------------------------------------------------
855 void wxTopLevelWindowGTK::Maximize(bool WXUNUSED(maximize
))
857 wxFAIL_MSG( _T("not implemented") );
860 bool wxTopLevelWindowGTK::IsMaximized() const
862 // wxFAIL_MSG( _T("not implemented") );
864 // This is an approximation
868 void wxTopLevelWindowGTK::Restore()
870 wxFAIL_MSG( _T("not implemented") );
873 void wxTopLevelWindowGTK::Iconize( bool iconize
)
877 GdkWindow
*window
= m_widget
->window
;
879 // you should do it later, for example from OnCreate() handler
880 wxCHECK_RET( window
, _T("frame not created yet - can't iconize") );
882 XIconifyWindow( GDK_WINDOW_XDISPLAY( window
),
883 GDK_WINDOW_XWINDOW( window
),
884 DefaultScreen( GDK_DISPLAY() ) );
888 bool wxTopLevelWindowGTK::IsIconized() const
893 void wxTopLevelWindowGTK::SetIconizeState(bool iconize
)
895 if ( iconize
!= m_isIconized
)
897 m_isIconized
= iconize
;
898 (void)SendIconizeEvent(iconize
);
902 void wxTopLevelWindowGTK::AddGrab()
907 gtk_grab_add( m_widget
);
909 gtk_grab_remove( m_widget
);
913 void wxTopLevelWindowGTK::RemoveGrab()