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
)))
121 //-----------------------------------------------------------------------------
123 //-----------------------------------------------------------------------------
126 gtk_frame_configure_callback( GtkWidget
*WXUNUSED(widget
), GdkEventConfigure
*WXUNUSED(event
), wxTopLevelWindowGTK
*win
)
129 wxapp_install_idle_handler();
131 if (!win
->m_hasVMT
|| !win
->IsShown())
136 gdk_window_get_root_origin( win
->m_widget
->window
, &x
, &y
);
140 wxMoveEvent
mevent( wxPoint(win
->m_x
,win
->m_y
), win
->GetId() );
141 mevent
.SetEventObject( win
);
142 win
->GetEventHandler()->ProcessEvent( mevent
);
147 //-----------------------------------------------------------------------------
148 // "realize" from m_widget
149 //-----------------------------------------------------------------------------
151 // we cannot MWM hints and icons before the widget has been realized,
152 // so we do this directly after realization
155 gtk_frame_realized_callback( GtkWidget
* WXUNUSED(widget
),
156 wxTopLevelWindowGTK
*win
)
159 wxapp_install_idle_handler();
161 // All this is for Motif Window Manager "hints" and is supposed to be
162 // recognized by other WM as well. Not tested.
163 gdk_window_set_decorations(win
->m_widget
->window
,
164 (GdkWMDecoration
)win
->m_gdkDecor
);
165 gdk_window_set_functions(win
->m_widget
->window
,
166 (GdkWMFunction
)win
->m_gdkFunc
);
168 // GTK's shrinking/growing policy
169 if ((win
->m_gdkFunc
& GDK_FUNC_RESIZE
) == 0)
170 gtk_window_set_policy(GTK_WINDOW(win
->m_widget
), 0, 0, 1);
172 gtk_window_set_policy(GTK_WINDOW(win
->m_widget
), 1, 1, 1);
175 wxIconBundle iconsOld
= win
->GetIcons();
176 if ( iconsOld
.GetIcon(-1).Ok() )
178 win
->SetIcon( wxNullIcon
);
179 win
->SetIcons( iconsOld
);
183 //-----------------------------------------------------------------------------
184 // "map_event" from m_widget
185 //-----------------------------------------------------------------------------
188 gtk_frame_map_callback( GtkWidget
* WXUNUSED(widget
),
189 GdkEvent
* WXUNUSED(event
),
190 wxTopLevelWindow
*win
)
192 win
->SetIconizeState(FALSE
);
195 //-----------------------------------------------------------------------------
196 // "unmap_event" from m_widget
197 //-----------------------------------------------------------------------------
200 gtk_frame_unmap_callback( GtkWidget
* WXUNUSED(widget
),
201 GdkEvent
* WXUNUSED(event
),
202 wxTopLevelWindow
*win
)
204 win
->SetIconizeState(TRUE
);
207 //-----------------------------------------------------------------------------
208 // "expose_event" of m_client
209 //-----------------------------------------------------------------------------
211 static int gtk_window_expose_callback( GtkWidget
*widget
, GdkEventExpose
*gdk_event
, wxWindow
*win
)
213 GtkPizza
*pizza
= GTK_PIZZA(widget
);
215 gtk_paint_flat_box (win
->m_widget
->style
,
216 pizza
->bin_window
, GTK_STATE_NORMAL
,
226 //-----------------------------------------------------------------------------
227 // "draw" of m_client
228 //-----------------------------------------------------------------------------
232 static void gtk_window_draw_callback( GtkWidget
*widget
, GdkRectangle
*rect
, wxWindow
*win
)
234 GtkPizza
*pizza
= GTK_PIZZA(widget
);
236 gtk_paint_flat_box (win
->m_widget
->style
,
237 pizza
->bin_window
, GTK_STATE_NORMAL
,
247 // ----------------------------------------------------------------------------
248 // wxTopLevelWindowGTK itself
249 // ----------------------------------------------------------------------------
251 BEGIN_EVENT_TABLE(wxTopLevelWindowGTK
, wxTopLevelWindowBase
)
252 EVT_SET_FOCUS(wxTopLevelWindowGTK::OnSetFocus
)
255 //-----------------------------------------------------------------------------
256 // InsertChild for wxTopLevelWindowGTK
257 //-----------------------------------------------------------------------------
259 /* Callback for wxTopLevelWindowGTK. This very strange beast has to be used because
260 * C++ has no virtual methods in a constructor. We have to emulate a
261 * virtual function here as wxWindows requires different ways to insert
262 * a child in container classes. */
264 static void wxInsertChildInTopLevelWindow( wxTopLevelWindowGTK
* parent
, wxWindow
* child
)
266 wxASSERT( GTK_IS_WIDGET(child
->m_widget
) );
268 if (!parent
->m_insertInClientArea
)
270 // these are outside the client area
271 wxTopLevelWindowGTK
* frame
= (wxTopLevelWindowGTK
*) parent
;
272 gtk_pizza_put( GTK_PIZZA(frame
->m_mainWidget
),
273 GTK_WIDGET(child
->m_widget
),
281 // these are inside the client area
282 gtk_pizza_put( GTK_PIZZA(parent
->m_wxwindow
),
283 GTK_WIDGET(child
->m_widget
),
290 // resize on OnInternalIdle
291 parent
->GtkUpdateSize();
294 // ----------------------------------------------------------------------------
295 // wxTopLevelWindowGTK creation
296 // ----------------------------------------------------------------------------
298 void wxTopLevelWindowGTK::Init()
303 m_mainWidget
= (GtkWidget
*) NULL
;
304 m_insertInClientArea
= TRUE
;
306 m_isIconized
= FALSE
;
307 m_fsIsShowing
= FALSE
;
308 m_themeEnabled
= TRUE
;
309 m_gdkDecor
= m_gdkFunc
= 0;
312 bool wxTopLevelWindowGTK::Create( wxWindow
*parent
,
314 const wxString
& title
,
316 const wxSize
& sizeOrig
,
318 const wxString
&name
)
320 // always create a frame of some reasonable, even if arbitrary, size (at
321 // least for MSW compatibility)
322 wxSize size
= sizeOrig
;
323 if ( size
.x
== -1 || size
.y
== -1 )
325 wxSize sizeDpy
= wxGetDisplaySize();
327 size
.x
= sizeDpy
.x
/ 3;
329 size
.y
= sizeDpy
.y
/ 5;
332 wxTopLevelWindows
.Append( this );
334 m_needParent
= FALSE
;
336 if (!PreCreation( parent
, pos
, size
) ||
337 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
339 wxFAIL_MSG( wxT("wxTopLevelWindowGTK creation failed") );
345 m_insertCallback
= (wxInsertChildFunction
) wxInsertChildInTopLevelWindow
;
347 GtkWindowType win_type
= GTK_WINDOW_TOPLEVEL
;
349 if (style
& wxFRAME_TOOL_WINDOW
)
350 win_type
= GTK_WINDOW_POPUP
;
352 if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
)
354 // there is no more GTK_WINDOW_DIALOG in 2.0
356 win_type
= GTK_WINDOW_TOPLEVEL
;
358 win_type
= GTK_WINDOW_DIALOG
;
362 m_widget
= gtk_window_new( win_type
);
364 if (m_parent
&& (GTK_IS_WINDOW(m_parent
->m_widget
)) &&
365 (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
))
367 gtk_window_set_transient_for( GTK_WINDOW(m_widget
), GTK_WINDOW(m_parent
->m_widget
) );
371 gtk_window_set_wmclass( GTK_WINDOW(m_widget
), name
.mb_str(), name
.mb_str() );
373 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
374 GTK_WIDGET_UNSET_FLAGS( m_widget
, GTK_CAN_FOCUS
);
376 gtk_signal_connect( GTK_OBJECT(m_widget
), "delete_event",
377 GTK_SIGNAL_FUNC(gtk_frame_delete_callback
), (gpointer
)this );
379 // m_mainWidget holds the toolbar, the menubar and the client area
380 m_mainWidget
= gtk_pizza_new();
381 gtk_widget_show( m_mainWidget
);
382 GTK_WIDGET_UNSET_FLAGS( m_mainWidget
, GTK_CAN_FOCUS
);
383 gtk_container_add( GTK_CONTAINER(m_widget
), m_mainWidget
);
385 // for m_mainWidget themes
386 gtk_signal_connect( GTK_OBJECT(m_mainWidget
), "expose_event",
387 GTK_SIGNAL_FUNC(gtk_window_expose_callback
), (gpointer
)this );
389 gtk_signal_connect( GTK_OBJECT(m_mainWidget
), "draw",
390 GTK_SIGNAL_FUNC(gtk_window_draw_callback
), (gpointer
)this );
393 // m_wxwindow only represents the client area without toolbar and menubar
394 m_wxwindow
= gtk_pizza_new();
395 gtk_widget_show( m_wxwindow
);
396 gtk_container_add( GTK_CONTAINER(m_mainWidget
), m_wxwindow
);
398 // we donm't allow the frame to get the focus as otherwise
399 // the frame will grab it at arbitrary focus changes
400 GTK_WIDGET_UNSET_FLAGS( m_wxwindow
, GTK_CAN_FOCUS
);
402 if (m_parent
) m_parent
->AddChild( this );
404 // the user resized the frame by dragging etc.
405 gtk_signal_connect( GTK_OBJECT(m_widget
), "size_allocate",
406 GTK_SIGNAL_FUNC(gtk_frame_size_callback
), (gpointer
)this );
410 if ((m_x
!= -1) || (m_y
!= -1))
411 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
413 gtk_window_set_default_size( GTK_WINDOW(m_widget
), m_width
, m_height
);
415 // we cannot set MWM hints and icons before the widget has
416 // been realized, so we do this directly after realization
417 gtk_signal_connect( GTK_OBJECT(m_widget
), "realize",
418 GTK_SIGNAL_FUNC(gtk_frame_realized_callback
), (gpointer
) this );
420 // the only way to get the window size is to connect to this event
421 gtk_signal_connect( GTK_OBJECT(m_widget
), "configure_event",
422 GTK_SIGNAL_FUNC(gtk_frame_configure_callback
), (gpointer
)this );
424 // map and unmap for iconized state
425 gtk_signal_connect( GTK_OBJECT(m_widget
), "map_event",
426 GTK_SIGNAL_FUNC(gtk_frame_map_callback
), (gpointer
)this );
427 gtk_signal_connect( GTK_OBJECT(m_widget
), "unmap_event",
428 GTK_SIGNAL_FUNC(gtk_frame_unmap_callback
), (gpointer
)this );
430 // the only way to get the window size is to connect to this event
431 gtk_signal_connect( GTK_OBJECT(m_widget
), "configure_event",
432 GTK_SIGNAL_FUNC(gtk_frame_configure_callback
), (gpointer
)this );
434 // disable native tab traversal
435 gtk_signal_connect( GTK_OBJECT(m_widget
), "focus",
436 GTK_SIGNAL_FUNC(gtk_frame_focus_callback
), (gpointer
)this );
439 if ((m_miniEdge
> 0) || (style
& wxSIMPLE_BORDER
) || (style
& wxNO_BORDER
))
446 m_gdkDecor
= (long) GDK_DECOR_BORDER
;
447 m_gdkFunc
= (long) GDK_FUNC_MOVE
;
449 // All this is for Motif Window Manager "hints" and is supposed to be
450 // recognized by other WMs as well.
451 if ((style
& wxCAPTION
) != 0)
452 m_gdkDecor
|= GDK_DECOR_TITLE
;
453 if ((style
& wxSYSTEM_MENU
) != 0)
455 m_gdkFunc
|= GDK_FUNC_CLOSE
;
456 m_gdkDecor
|= GDK_DECOR_MENU
;
458 if ((style
& wxMINIMIZE_BOX
) != 0)
460 m_gdkFunc
|= GDK_FUNC_MINIMIZE
;
461 m_gdkDecor
|= GDK_DECOR_MINIMIZE
;
463 if ((style
& wxMAXIMIZE_BOX
) != 0)
465 m_gdkFunc
|= GDK_FUNC_MAXIMIZE
;
466 m_gdkDecor
|= GDK_DECOR_MAXIMIZE
;
468 if ((style
& wxRESIZE_BORDER
) != 0)
470 m_gdkFunc
|= GDK_FUNC_RESIZE
;
471 m_gdkDecor
|= GDK_DECOR_RESIZEH
;
478 wxTopLevelWindowGTK::~wxTopLevelWindowGTK()
480 m_isBeingDeleted
= TRUE
;
482 // it may also be GtkScrolledWindow in the case of an MDI child
483 if (GTK_IS_WINDOW(m_widget
))
485 gtk_window_set_focus( GTK_WINDOW(m_widget
), NULL
);
488 wxTopLevelWindows
.DeleteObject( this );
490 if (wxTheApp
->GetTopWindow() == this)
491 wxTheApp
->SetTopWindow( (wxWindow
*) NULL
);
493 if ((wxTopLevelWindows
.Number() == 0) &&
494 (wxTheApp
->GetExitOnFrameDelete()))
496 wxTheApp
->ExitMainLoop();
500 bool wxTopLevelWindowGTK::ShowFullScreen(bool show
, long style
)
502 if (show
== m_fsIsShowing
) return FALSE
; // return what?
504 m_fsIsShowing
= show
;
508 m_fsSaveGdkFunc
= m_gdkFunc
;
509 m_fsSaveGdkDecor
= m_gdkDecor
;
510 m_fsSaveFlag
= style
;
511 GetPosition( &m_fsSaveFrame
.x
, &m_fsSaveFrame
.y
);
512 GetSize( &m_fsSaveFrame
.width
, &m_fsSaveFrame
.height
);
514 gtk_widget_hide( m_widget
);
515 gtk_widget_unrealize( m_widget
);
517 m_gdkDecor
= (long) GDK_DECOR_BORDER
;
518 m_gdkFunc
= (long) GDK_FUNC_MOVE
;
522 wxDisplaySize( &x
, &y
);
523 SetSize( 0, 0, x
, y
);
525 gtk_widget_realize( m_widget
);
526 gtk_widget_show( m_widget
);
530 gtk_widget_hide( m_widget
);
531 gtk_widget_unrealize( m_widget
);
533 m_gdkFunc
= m_fsSaveGdkFunc
;
534 m_gdkDecor
= m_fsSaveGdkDecor
;
536 SetSize( m_fsSaveFrame
.x
, m_fsSaveFrame
.y
, m_fsSaveFrame
.width
, m_fsSaveFrame
.height
);
538 gtk_widget_realize( m_widget
);
539 gtk_widget_show( m_widget
);
545 // ----------------------------------------------------------------------------
546 // overridden wxWindow methods
547 // ----------------------------------------------------------------------------
549 bool wxTopLevelWindowGTK::Show( bool show
)
551 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
553 if (show
&& !m_sizeSet
)
555 /* by calling GtkOnSize here, we don't have to call
556 either after showing the frame, which would entail
557 much ugly flicker or from within the size_allocate
558 handler, because GTK 1.1.X forbids that. */
560 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
563 return wxWindow::Show( show
);
566 void wxTopLevelWindowGTK::DoMoveWindow(int WXUNUSED(x
), int WXUNUSED(y
), int WXUNUSED(width
), int WXUNUSED(height
) )
568 wxFAIL_MSG( wxT("DoMoveWindow called for wxTopLevelWindowGTK") );
571 void wxTopLevelWindowGTK::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
573 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
575 // this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow
576 wxASSERT_MSG( (m_wxwindow
!= NULL
), wxT("invalid frame") );
586 int old_width
= m_width
;
587 int old_height
= m_height
;
589 if ((sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) == 0)
591 if (x
!= -1) m_x
= x
;
592 if (y
!= -1) m_y
= y
;
593 if (width
!= -1) m_width
= width
;
594 if (height
!= -1) m_height
= height
;
605 if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
607 if (width == -1) m_width = 80;
610 if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
612 if (height == -1) m_height = 26;
616 int minWidth
= GetMinWidth(),
617 minHeight
= GetMinHeight(),
618 maxWidth
= GetMaxWidth(),
619 maxHeight
= GetMaxHeight();
621 if ((minWidth
!= -1) && (m_width
< minWidth
)) m_width
= minWidth
;
622 if ((minHeight
!= -1) && (m_height
< minHeight
)) m_height
= minHeight
;
623 if ((maxWidth
!= -1) && (m_width
> maxWidth
)) m_width
= maxWidth
;
624 if ((maxHeight
!= -1) && (m_height
> maxHeight
)) m_height
= maxHeight
;
626 if ((m_x
!= -1) || (m_y
!= -1))
628 if ((m_x
!= old_x
) || (m_y
!= old_y
))
630 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
634 if ((m_width
!= old_width
) || (m_height
!= old_height
))
636 if (m_widget
->window
)
637 gdk_window_resize( m_widget
->window
, m_width
, m_height
);
639 gtk_window_set_default_size( GTK_WINDOW(m_widget
), m_width
, m_height
);
641 /* we set the size in GtkOnSize, i.e. mostly the actual resizing is
642 done either directly before the frame is shown or in idle time
643 so that different calls to SetSize() don't lead to flicker. */
650 void wxTopLevelWindowGTK::DoGetClientSize( int *width
, int *height
) const
652 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
654 wxWindow::DoGetClientSize( width
, height
);
658 *height
-= m_miniEdge
*2 + m_miniTitle
;
662 *width
-= m_miniEdge
*2;
666 void wxTopLevelWindowGTK::DoSetClientSize( int width
, int height
)
668 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
671 width
+ m_miniEdge
*2, height
+ m_miniEdge
*2 + m_miniTitle
, 0);
674 void wxTopLevelWindowGTK::GtkOnSize( int WXUNUSED(x
), int WXUNUSED(y
),
675 int width
, int height
)
677 // due to a bug in gtk, x,y are always 0
682 if (m_resizing
) return;
685 if ( m_wxwindow
== NULL
) return;
690 /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses
691 wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
692 set in wxFrame::Create so it is used to check what kind of frame we
693 have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
694 skip the part which handles m_frameMenuBar, m_frameToolBar and (most
695 importantly) m_mainWidget */
697 int minWidth
= GetMinWidth(),
698 minHeight
= GetMinHeight(),
699 maxWidth
= GetMaxWidth(),
700 maxHeight
= GetMaxHeight();
702 if ((minWidth
!= -1) && (m_width
< minWidth
)) m_width
= minWidth
;
703 if ((minHeight
!= -1) && (m_height
< minHeight
)) m_height
= minHeight
;
704 if ((maxWidth
!= -1) && (m_width
> maxWidth
)) m_width
= maxWidth
;
705 if ((maxHeight
!= -1) && (m_height
> maxHeight
)) m_height
= maxHeight
;
710 gint flag
= 0; // GDK_HINT_POS;
711 if ((minWidth
!= -1) || (minHeight
!= -1)) flag
|= GDK_HINT_MIN_SIZE
;
712 if ((maxWidth
!= -1) || (maxHeight
!= -1)) flag
|= GDK_HINT_MAX_SIZE
;
714 geom
.min_width
= minWidth
;
715 geom
.min_height
= minHeight
;
716 geom
.max_width
= maxWidth
;
717 geom
.max_height
= maxHeight
;
718 gtk_window_set_geometry_hints( GTK_WINDOW(m_widget
),
721 (GdkWindowHints
) flag
);
723 /* I revert back to wxGTK's original behaviour. m_mainWidget holds the
724 * menubar, the toolbar and the client area, which is represented by
726 * this hurts in the eye, but I don't want to call SetSize()
727 * because I don't want to call any non-native functions here. */
729 int client_x
= m_miniEdge
;
730 int client_y
= m_miniEdge
+ m_miniTitle
;
731 int client_w
= m_width
- 2*m_miniEdge
;
732 int client_h
= m_height
- 2*m_miniEdge
- m_miniTitle
;
733 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget
),
735 client_x
, client_y
, client_w
, client_h
);
739 // If there is no m_mainWidget between m_widget and m_wxwindow there
740 // is no need to set the size or position of m_wxwindow.
745 // send size event to frame
746 wxSizeEvent
event( wxSize(m_width
,m_height
), GetId() );
747 event
.SetEventObject( this );
748 GetEventHandler()->ProcessEvent( event
);
753 void wxTopLevelWindowGTK::OnInternalIdle()
755 if (!m_sizeSet
&& GTK_WIDGET_REALIZED(m_wxwindow
))
757 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
759 // we'll come back later
761 wxapp_install_idle_handler();
765 // set the focus if not done yet and if we can already do it
766 if ( GTK_WIDGET_REALIZED(m_wxwindow
) )
768 if ( g_delayedFocus
&& wxGetTopLevelParent(g_delayedFocus
) == this )
770 g_delayedFocus
->SetFocus();
771 g_delayedFocus
= NULL
;
775 wxWindow::OnInternalIdle();
778 void wxTopLevelWindowGTK::OnSetFocus(wxFocusEvent
& event
)
781 if ( !g_delayedFocus
|| wxGetTopLevelParent(g_delayedFocus
) != this )
783 // let the base class version set the focus to the first child which
787 //else: the focus will be really set from OnInternalIdle() later
791 // ----------------------------------------------------------------------------
793 // ----------------------------------------------------------------------------
795 void wxTopLevelWindowGTK::SetTitle( const wxString
&title
)
797 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
800 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
803 void wxTopLevelWindowGTK::DoSetIcon( const wxIcon
&icon
)
808 if (!m_widget
->window
)
811 wxMask
*mask
= icon
.GetMask();
812 GdkBitmap
*bm
= (GdkBitmap
*) NULL
;
813 if (mask
) bm
= mask
->GetBitmap();
815 gdk_window_set_icon( m_widget
->window
, (GdkWindow
*) NULL
, icon
.GetPixmap(), bm
);
818 void wxTopLevelWindowGTK::SetIcon( const wxIcon
&icon
)
820 SetIcons( wxIconBundle( icon
) );
823 void wxTopLevelWindowGTK::SetIcons( const wxIconBundle
&icons
)
825 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
826 GdkWindow
* window
= m_widget
->window
;
828 wxTopLevelWindowBase::SetIcons( icons
);
830 DoSetIcon( icons
.GetIcon( -1 ) );
833 wxSetIconsX11( (WXDisplay
*)GDK_WINDOW_XDISPLAY( window
),
834 (WXWindow
)GDK_WINDOW_XWINDOW( window
), icons
);
838 // ----------------------------------------------------------------------------
839 // frame state: maximized/iconized/normal
840 // ----------------------------------------------------------------------------
842 void wxTopLevelWindowGTK::Maximize(bool WXUNUSED(maximize
))
844 wxFAIL_MSG( _T("not implemented") );
847 bool wxTopLevelWindowGTK::IsMaximized() const
849 // wxFAIL_MSG( _T("not implemented") );
851 // This is an approximation
855 void wxTopLevelWindowGTK::Restore()
857 wxFAIL_MSG( _T("not implemented") );
860 void wxTopLevelWindowGTK::Iconize( bool iconize
)
864 GdkWindow
*window
= m_widget
->window
;
866 // you should do it later, for example from OnCreate() handler
867 wxCHECK_RET( window
, _T("frame not created yet - can't iconize") );
869 XIconifyWindow( GDK_WINDOW_XDISPLAY( window
),
870 GDK_WINDOW_XWINDOW( window
),
871 DefaultScreen( GDK_DISPLAY() ) );
875 bool wxTopLevelWindowGTK::IsIconized() const
880 void wxTopLevelWindowGTK::SetIconizeState(bool iconize
)
882 if ( iconize
!= m_isIconized
)
884 m_isIconized
= iconize
;
885 (void)SendIconizeEvent(iconize
);