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
;
596 if (width
!= -1) m_width
= width
;
597 if (height
!= -1) m_height
= height
;
608 if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
610 if (width == -1) m_width = 80;
613 if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
615 if (height == -1) m_height = 26;
619 int minWidth
= GetMinWidth(),
620 minHeight
= GetMinHeight(),
621 maxWidth
= GetMaxWidth(),
622 maxHeight
= GetMaxHeight();
624 if ((minWidth
!= -1) && (m_width
< minWidth
)) m_width
= minWidth
;
625 if ((minHeight
!= -1) && (m_height
< minHeight
)) m_height
= minHeight
;
626 if ((maxWidth
!= -1) && (m_width
> maxWidth
)) m_width
= maxWidth
;
627 if ((maxHeight
!= -1) && (m_height
> maxHeight
)) m_height
= maxHeight
;
629 if ((m_x
!= -1) || (m_y
!= -1))
631 if ((m_x
!= old_x
) || (m_y
!= old_y
))
633 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
637 if ((m_width
!= old_width
) || (m_height
!= old_height
))
639 if (m_widget
->window
)
640 gdk_window_resize( m_widget
->window
, m_width
, m_height
);
642 gtk_window_set_default_size( GTK_WINDOW(m_widget
), m_width
, m_height
);
644 /* we set the size in GtkOnSize, i.e. mostly the actual resizing is
645 done either directly before the frame is shown or in idle time
646 so that different calls to SetSize() don't lead to flicker. */
653 void wxTopLevelWindowGTK::DoGetClientSize( int *width
, int *height
) const
655 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
657 wxWindow::DoGetClientSize( width
, height
);
661 *height
-= m_miniEdge
*2 + m_miniTitle
;
665 *width
-= m_miniEdge
*2;
669 void wxTopLevelWindowGTK::DoSetClientSize( int width
, int height
)
671 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
674 width
+ m_miniEdge
*2, height
+ m_miniEdge
*2 + m_miniTitle
, 0);
677 void wxTopLevelWindowGTK::GtkOnSize( int WXUNUSED(x
), int WXUNUSED(y
),
678 int width
, int height
)
680 // due to a bug in gtk, x,y are always 0
685 if (m_resizing
) return;
688 if ( m_wxwindow
== NULL
) return;
693 /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses
694 wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
695 set in wxFrame::Create so it is used to check what kind of frame we
696 have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
697 skip the part which handles m_frameMenuBar, m_frameToolBar and (most
698 importantly) m_mainWidget */
700 int minWidth
= GetMinWidth(),
701 minHeight
= GetMinHeight(),
702 maxWidth
= GetMaxWidth(),
703 maxHeight
= GetMaxHeight();
705 if ((minWidth
!= -1) && (m_width
< minWidth
)) m_width
= minWidth
;
706 if ((minHeight
!= -1) && (m_height
< minHeight
)) m_height
= minHeight
;
707 if ((maxWidth
!= -1) && (m_width
> maxWidth
)) m_width
= maxWidth
;
708 if ((maxHeight
!= -1) && (m_height
> maxHeight
)) m_height
= maxHeight
;
713 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
;
719 geom
.max_width
= maxWidth
;
720 geom
.max_height
= maxHeight
;
721 gtk_window_set_geometry_hints( GTK_WINDOW(m_widget
),
724 (GdkWindowHints
) flag
);
726 /* I revert back to wxGTK's original behaviour. m_mainWidget holds the
727 * menubar, the toolbar and the client area, which is represented by
729 * this hurts in the eye, but I don't want to call SetSize()
730 * because I don't want to call any non-native functions here. */
732 int client_x
= m_miniEdge
;
733 int client_y
= m_miniEdge
+ m_miniTitle
;
734 int client_w
= m_width
- 2*m_miniEdge
;
735 int client_h
= m_height
- 2*m_miniEdge
- m_miniTitle
;
736 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget
),
738 client_x
, client_y
, client_w
, client_h
);
742 // If there is no m_mainWidget between m_widget and m_wxwindow there
743 // is no need to set the size or position of m_wxwindow.
748 // send size event to frame
749 wxSizeEvent
event( wxSize(m_width
,m_height
), GetId() );
750 event
.SetEventObject( this );
751 GetEventHandler()->ProcessEvent( event
);
756 void wxTopLevelWindowGTK::OnInternalIdle()
758 if (!m_sizeSet
&& GTK_WIDGET_REALIZED(m_wxwindow
))
760 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
762 // we'll come back later
764 wxapp_install_idle_handler();
768 // set the focus if not done yet and if we can already do it
769 if ( GTK_WIDGET_REALIZED(m_wxwindow
) )
771 if ( g_delayedFocus
&&
772 wxGetTopLevelParent((wxWindow
*)g_delayedFocus
) == this )
774 g_delayedFocus
->SetFocus();
775 g_delayedFocus
= NULL
;
779 wxWindow::OnInternalIdle();
782 // ----------------------------------------------------------------------------
784 // ----------------------------------------------------------------------------
786 void wxTopLevelWindowGTK::SetTitle( const wxString
&title
)
788 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
791 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
794 void wxTopLevelWindowGTK::DoSetIcon( const wxIcon
&icon
)
799 if (!m_widget
->window
)
802 wxMask
*mask
= icon
.GetMask();
803 GdkBitmap
*bm
= (GdkBitmap
*) NULL
;
804 if (mask
) bm
= mask
->GetBitmap();
806 gdk_window_set_icon( m_widget
->window
, (GdkWindow
*) NULL
, icon
.GetPixmap(), bm
);
809 void wxTopLevelWindowGTK::SetIcon( const wxIcon
&icon
)
811 SetIcons( wxIconBundle( icon
) );
814 void wxTopLevelWindowGTK::SetIcons( const wxIconBundle
&icons
)
816 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
817 GdkWindow
* window
= m_widget
->window
;
819 wxTopLevelWindowBase::SetIcons( icons
);
821 DoSetIcon( icons
.GetIcon( -1 ) );
824 wxSetIconsX11( (WXDisplay
*)GDK_WINDOW_XDISPLAY( window
),
825 (WXWindow
)GDK_WINDOW_XWINDOW( window
), icons
);
829 // ----------------------------------------------------------------------------
830 // frame state: maximized/iconized/normal
831 // ----------------------------------------------------------------------------
833 void wxTopLevelWindowGTK::Maximize(bool WXUNUSED(maximize
))
835 wxFAIL_MSG( _T("not implemented") );
838 bool wxTopLevelWindowGTK::IsMaximized() const
840 // wxFAIL_MSG( _T("not implemented") );
842 // This is an approximation
846 void wxTopLevelWindowGTK::Restore()
848 wxFAIL_MSG( _T("not implemented") );
851 void wxTopLevelWindowGTK::Iconize( bool iconize
)
855 GdkWindow
*window
= m_widget
->window
;
857 // you should do it later, for example from OnCreate() handler
858 wxCHECK_RET( window
, _T("frame not created yet - can't iconize") );
860 XIconifyWindow( GDK_WINDOW_XDISPLAY( window
),
861 GDK_WINDOW_XWINDOW( window
),
862 DefaultScreen( GDK_DISPLAY() ) );
866 bool wxTopLevelWindowGTK::IsIconized() const
871 void wxTopLevelWindowGTK::SetIconizeState(bool iconize
)
873 if ( iconize
!= m_isIconized
)
875 m_isIconized
= iconize
;
876 (void)SendIconizeEvent(iconize
);
880 void wxTopLevelWindowGTK::AddGrab()
885 gtk_grab_add( m_widget
);
887 gtk_grab_remove( m_widget
);
891 void wxTopLevelWindowGTK::RemoveGrab()