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 //-----------------------------------------------------------------------------
252 // InsertChild for wxTopLevelWindowGTK
253 //-----------------------------------------------------------------------------
255 /* Callback for wxTopLevelWindowGTK. This very strange beast has to be used because
256 * C++ has no virtual methods in a constructor. We have to emulate a
257 * virtual function here as wxWindows requires different ways to insert
258 * a child in container classes. */
260 static void wxInsertChildInTopLevelWindow( wxTopLevelWindowGTK
* parent
, wxWindow
* child
)
262 wxASSERT( GTK_IS_WIDGET(child
->m_widget
) );
264 if (!parent
->m_insertInClientArea
)
266 // these are outside the client area
267 wxTopLevelWindowGTK
* frame
= (wxTopLevelWindowGTK
*) parent
;
268 gtk_pizza_put( GTK_PIZZA(frame
->m_mainWidget
),
269 GTK_WIDGET(child
->m_widget
),
277 // these are inside the client area
278 gtk_pizza_put( GTK_PIZZA(parent
->m_wxwindow
),
279 GTK_WIDGET(child
->m_widget
),
286 // resize on OnInternalIdle
287 parent
->GtkUpdateSize();
290 // ----------------------------------------------------------------------------
291 // wxTopLevelWindowGTK creation
292 // ----------------------------------------------------------------------------
294 void wxTopLevelWindowGTK::Init()
299 m_mainWidget
= (GtkWidget
*) NULL
;
300 m_insertInClientArea
= TRUE
;
302 m_isIconized
= FALSE
;
303 m_fsIsShowing
= FALSE
;
304 m_themeEnabled
= TRUE
;
305 m_gdkDecor
= m_gdkFunc
= 0;
308 bool wxTopLevelWindowGTK::Create( wxWindow
*parent
,
310 const wxString
& title
,
312 const wxSize
& sizeOrig
,
314 const wxString
&name
)
316 // always create a frame of some reasonable, even if arbitrary, size (at
317 // least for MSW compatibility)
318 wxSize size
= sizeOrig
;
319 if ( size
.x
== -1 || size
.y
== -1 )
321 wxSize sizeDpy
= wxGetDisplaySize();
323 size
.x
= sizeDpy
.x
/ 3;
325 size
.y
= sizeDpy
.y
/ 5;
328 wxTopLevelWindows
.Append( this );
330 m_needParent
= FALSE
;
332 if (!PreCreation( parent
, pos
, size
) ||
333 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
335 wxFAIL_MSG( wxT("wxTopLevelWindowGTK creation failed") );
341 m_insertCallback
= (wxInsertChildFunction
) wxInsertChildInTopLevelWindow
;
343 GtkWindowType win_type
= GTK_WINDOW_TOPLEVEL
;
345 if (style
& wxFRAME_TOOL_WINDOW
)
346 win_type
= GTK_WINDOW_POPUP
;
348 if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
)
350 // there is no more GTK_WINDOW_DIALOG in 2.0
352 win_type
= GTK_WINDOW_TOPLEVEL
;
354 win_type
= GTK_WINDOW_DIALOG
;
358 m_widget
= gtk_window_new( win_type
);
360 if (m_parent
&& (GTK_IS_WINDOW(m_parent
->m_widget
)) &&
361 (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
))
363 gtk_window_set_transient_for( GTK_WINDOW(m_widget
), GTK_WINDOW(m_parent
->m_widget
) );
367 gtk_window_set_wmclass( GTK_WINDOW(m_widget
), name
.mb_str(), name
.mb_str() );
369 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
370 GTK_WIDGET_UNSET_FLAGS( m_widget
, GTK_CAN_FOCUS
);
372 gtk_signal_connect( GTK_OBJECT(m_widget
), "delete_event",
373 GTK_SIGNAL_FUNC(gtk_frame_delete_callback
), (gpointer
)this );
375 // m_mainWidget holds the toolbar, the menubar and the client area
376 m_mainWidget
= gtk_pizza_new();
377 gtk_widget_show( m_mainWidget
);
378 GTK_WIDGET_UNSET_FLAGS( m_mainWidget
, GTK_CAN_FOCUS
);
379 gtk_container_add( GTK_CONTAINER(m_widget
), m_mainWidget
);
381 // for m_mainWidget themes
382 gtk_signal_connect( GTK_OBJECT(m_mainWidget
), "expose_event",
383 GTK_SIGNAL_FUNC(gtk_window_expose_callback
), (gpointer
)this );
385 gtk_signal_connect( GTK_OBJECT(m_mainWidget
), "draw",
386 GTK_SIGNAL_FUNC(gtk_window_draw_callback
), (gpointer
)this );
389 // m_wxwindow only represents the client area without toolbar and menubar
390 m_wxwindow
= gtk_pizza_new();
391 gtk_widget_show( m_wxwindow
);
392 gtk_container_add( GTK_CONTAINER(m_mainWidget
), m_wxwindow
);
394 // we donm't allow the frame to get the focus as otherwise
395 // the frame will grab it at arbitrary focus changes
396 GTK_WIDGET_UNSET_FLAGS( m_wxwindow
, GTK_CAN_FOCUS
);
398 if (m_parent
) m_parent
->AddChild( this );
400 // the user resized the frame by dragging etc.
401 gtk_signal_connect( GTK_OBJECT(m_widget
), "size_allocate",
402 GTK_SIGNAL_FUNC(gtk_frame_size_callback
), (gpointer
)this );
406 if ((m_x
!= -1) || (m_y
!= -1))
407 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
409 gtk_window_set_default_size( GTK_WINDOW(m_widget
), m_width
, m_height
);
411 // we cannot set MWM hints and icons before the widget has
412 // been realized, so we do this directly after realization
413 gtk_signal_connect( GTK_OBJECT(m_widget
), "realize",
414 GTK_SIGNAL_FUNC(gtk_frame_realized_callback
), (gpointer
) this );
416 // the only way to get the window size is to connect to this event
417 gtk_signal_connect( GTK_OBJECT(m_widget
), "configure_event",
418 GTK_SIGNAL_FUNC(gtk_frame_configure_callback
), (gpointer
)this );
420 // map and unmap for iconized state
421 gtk_signal_connect( GTK_OBJECT(m_widget
), "map_event",
422 GTK_SIGNAL_FUNC(gtk_frame_map_callback
), (gpointer
)this );
423 gtk_signal_connect( GTK_OBJECT(m_widget
), "unmap_event",
424 GTK_SIGNAL_FUNC(gtk_frame_unmap_callback
), (gpointer
)this );
426 // the only way to get the window size is to connect to this event
427 gtk_signal_connect( GTK_OBJECT(m_widget
), "configure_event",
428 GTK_SIGNAL_FUNC(gtk_frame_configure_callback
), (gpointer
)this );
430 // disable native tab traversal
431 gtk_signal_connect( GTK_OBJECT(m_widget
), "focus",
432 GTK_SIGNAL_FUNC(gtk_frame_focus_callback
), (gpointer
)this );
435 if ((m_miniEdge
> 0) || (style
& wxSIMPLE_BORDER
) || (style
& wxNO_BORDER
))
442 m_gdkDecor
= (long) GDK_DECOR_BORDER
;
443 m_gdkFunc
= (long) GDK_FUNC_MOVE
;
445 // All this is for Motif Window Manager "hints" and is supposed to be
446 // recognized by other WMs as well.
447 if ((style
& wxCAPTION
) != 0)
448 m_gdkDecor
|= GDK_DECOR_TITLE
;
449 if ((style
& wxSYSTEM_MENU
) != 0)
451 m_gdkFunc
|= GDK_FUNC_CLOSE
;
452 m_gdkDecor
|= GDK_DECOR_MENU
;
454 if ((style
& wxMINIMIZE_BOX
) != 0)
456 m_gdkFunc
|= GDK_FUNC_MINIMIZE
;
457 m_gdkDecor
|= GDK_DECOR_MINIMIZE
;
459 if ((style
& wxMAXIMIZE_BOX
) != 0)
461 m_gdkFunc
|= GDK_FUNC_MAXIMIZE
;
462 m_gdkDecor
|= GDK_DECOR_MAXIMIZE
;
464 if ((style
& wxRESIZE_BORDER
) != 0)
466 m_gdkFunc
|= GDK_FUNC_RESIZE
;
467 m_gdkDecor
|= GDK_DECOR_RESIZEH
;
474 wxTopLevelWindowGTK::~wxTopLevelWindowGTK()
476 m_isBeingDeleted
= TRUE
;
478 // it may also be GtkScrolledWindow in the case of an MDI child
479 if (GTK_IS_WINDOW(m_widget
))
481 gtk_window_set_focus( GTK_WINDOW(m_widget
), NULL
);
484 wxTopLevelWindows
.DeleteObject( this );
486 if (wxTheApp
->GetTopWindow() == this)
487 wxTheApp
->SetTopWindow( (wxWindow
*) NULL
);
489 if ((wxTopLevelWindows
.Number() == 0) &&
490 (wxTheApp
->GetExitOnFrameDelete()))
492 wxTheApp
->ExitMainLoop();
496 bool wxTopLevelWindowGTK::ShowFullScreen(bool show
, long style
)
498 if (show
== m_fsIsShowing
) return FALSE
; // return what?
500 m_fsIsShowing
= show
;
504 m_fsSaveGdkFunc
= m_gdkFunc
;
505 m_fsSaveGdkDecor
= m_gdkDecor
;
506 m_fsSaveFlag
= style
;
507 GetPosition( &m_fsSaveFrame
.x
, &m_fsSaveFrame
.y
);
508 GetSize( &m_fsSaveFrame
.width
, &m_fsSaveFrame
.height
);
510 gtk_widget_hide( m_widget
);
511 gtk_widget_unrealize( m_widget
);
513 m_gdkDecor
= (long) GDK_DECOR_BORDER
;
514 m_gdkFunc
= (long) GDK_FUNC_MOVE
;
518 wxDisplaySize( &x
, &y
);
519 SetSize( 0, 0, x
, y
);
521 gtk_widget_realize( m_widget
);
522 gtk_widget_show( m_widget
);
526 gtk_widget_hide( m_widget
);
527 gtk_widget_unrealize( m_widget
);
529 m_gdkFunc
= m_fsSaveGdkFunc
;
530 m_gdkDecor
= m_fsSaveGdkDecor
;
532 SetSize( m_fsSaveFrame
.x
, m_fsSaveFrame
.y
, m_fsSaveFrame
.width
, m_fsSaveFrame
.height
);
534 gtk_widget_realize( m_widget
);
535 gtk_widget_show( m_widget
);
541 // ----------------------------------------------------------------------------
542 // overridden wxWindow methods
543 // ----------------------------------------------------------------------------
545 bool wxTopLevelWindowGTK::Show( bool show
)
547 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
549 if (show
&& !m_sizeSet
)
551 /* by calling GtkOnSize here, we don't have to call
552 either after showing the frame, which would entail
553 much ugly flicker or from within the size_allocate
554 handler, because GTK 1.1.X forbids that. */
556 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
559 return wxWindow::Show( show
);
562 void wxTopLevelWindowGTK::DoMoveWindow(int WXUNUSED(x
), int WXUNUSED(y
), int WXUNUSED(width
), int WXUNUSED(height
) )
564 wxFAIL_MSG( wxT("DoMoveWindow called for wxTopLevelWindowGTK") );
567 void wxTopLevelWindowGTK::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
569 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
571 // this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow
572 wxASSERT_MSG( (m_wxwindow
!= NULL
), wxT("invalid frame") );
582 int old_width
= m_width
;
583 int old_height
= m_height
;
585 if ((sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) == 0)
587 if (x
!= -1) m_x
= x
;
588 if (y
!= -1) m_y
= y
;
589 if (width
!= -1) m_width
= width
;
590 if (height
!= -1) m_height
= height
;
601 if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
603 if (width == -1) m_width = 80;
606 if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
608 if (height == -1) m_height = 26;
612 int minWidth
= GetMinWidth(),
613 minHeight
= GetMinHeight(),
614 maxWidth
= GetMaxWidth(),
615 maxHeight
= GetMaxHeight();
617 if ((minWidth
!= -1) && (m_width
< minWidth
)) m_width
= minWidth
;
618 if ((minHeight
!= -1) && (m_height
< minHeight
)) m_height
= minHeight
;
619 if ((maxWidth
!= -1) && (m_width
> maxWidth
)) m_width
= maxWidth
;
620 if ((maxHeight
!= -1) && (m_height
> maxHeight
)) m_height
= maxHeight
;
622 if ((m_x
!= -1) || (m_y
!= -1))
624 if ((m_x
!= old_x
) || (m_y
!= old_y
))
626 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
630 if ((m_width
!= old_width
) || (m_height
!= old_height
))
632 if (m_widget
->window
)
633 gdk_window_resize( m_widget
->window
, m_width
, m_height
);
635 gtk_window_set_default_size( GTK_WINDOW(m_widget
), m_width
, m_height
);
637 /* we set the size in GtkOnSize, i.e. mostly the actual resizing is
638 done either directly before the frame is shown or in idle time
639 so that different calls to SetSize() don't lead to flicker. */
646 void wxTopLevelWindowGTK::DoGetClientSize( int *width
, int *height
) const
648 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
650 wxWindow::DoGetClientSize( width
, height
);
654 *height
-= m_miniEdge
*2 + m_miniTitle
;
658 *width
-= m_miniEdge
*2;
662 void wxTopLevelWindowGTK::DoSetClientSize( int width
, int height
)
664 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
667 width
+ m_miniEdge
*2, height
+ m_miniEdge
*2 + m_miniTitle
, 0);
670 void wxTopLevelWindowGTK::GtkOnSize( int WXUNUSED(x
), int WXUNUSED(y
),
671 int width
, int height
)
673 // due to a bug in gtk, x,y are always 0
678 if (m_resizing
) return;
681 if ( m_wxwindow
== NULL
) return;
686 /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses
687 wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
688 set in wxFrame::Create so it is used to check what kind of frame we
689 have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
690 skip the part which handles m_frameMenuBar, m_frameToolBar and (most
691 importantly) m_mainWidget */
693 int minWidth
= GetMinWidth(),
694 minHeight
= GetMinHeight(),
695 maxWidth
= GetMaxWidth(),
696 maxHeight
= GetMaxHeight();
698 if ((minWidth
!= -1) && (m_width
< minWidth
)) m_width
= minWidth
;
699 if ((minHeight
!= -1) && (m_height
< minHeight
)) m_height
= minHeight
;
700 if ((maxWidth
!= -1) && (m_width
> maxWidth
)) m_width
= maxWidth
;
701 if ((maxHeight
!= -1) && (m_height
> maxHeight
)) m_height
= maxHeight
;
706 gint flag
= 0; // GDK_HINT_POS;
707 if ((minWidth
!= -1) || (minHeight
!= -1)) flag
|= GDK_HINT_MIN_SIZE
;
708 if ((maxWidth
!= -1) || (maxHeight
!= -1)) flag
|= GDK_HINT_MAX_SIZE
;
710 geom
.min_width
= minWidth
;
711 geom
.min_height
= minHeight
;
712 geom
.max_width
= maxWidth
;
713 geom
.max_height
= maxHeight
;
714 gtk_window_set_geometry_hints( GTK_WINDOW(m_widget
),
717 (GdkWindowHints
) flag
);
719 /* I revert back to wxGTK's original behaviour. m_mainWidget holds the
720 * menubar, the toolbar and the client area, which is represented by
722 * this hurts in the eye, but I don't want to call SetSize()
723 * because I don't want to call any non-native functions here. */
725 int client_x
= m_miniEdge
;
726 int client_y
= m_miniEdge
+ m_miniTitle
;
727 int client_w
= m_width
- 2*m_miniEdge
;
728 int client_h
= m_height
- 2*m_miniEdge
- m_miniTitle
;
729 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget
),
731 client_x
, client_y
, client_w
, client_h
);
735 // If there is no m_mainWidget between m_widget and m_wxwindow there
736 // is no need to set the size or position of m_wxwindow.
741 // send size event to frame
742 wxSizeEvent
event( wxSize(m_width
,m_height
), GetId() );
743 event
.SetEventObject( this );
744 GetEventHandler()->ProcessEvent( event
);
749 void wxTopLevelWindowGTK::OnInternalIdle()
751 if (!m_sizeSet
&& GTK_WIDGET_REALIZED(m_wxwindow
))
753 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
755 // we'll come back later
757 wxapp_install_idle_handler();
761 // set the focus if not done yet and if we can already do it
762 if ( GTK_WIDGET_REALIZED(m_wxwindow
) )
764 if ( g_delayedFocus
&& wxGetTopLevelParent(g_delayedFocus
) == this )
766 g_delayedFocus
->SetFocus();
767 g_delayedFocus
= NULL
;
771 wxWindow::OnInternalIdle();
774 // ----------------------------------------------------------------------------
776 // ----------------------------------------------------------------------------
778 void wxTopLevelWindowGTK::SetTitle( const wxString
&title
)
780 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
783 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
786 void wxTopLevelWindowGTK::DoSetIcon( const wxIcon
&icon
)
791 if (!m_widget
->window
)
794 wxMask
*mask
= icon
.GetMask();
795 GdkBitmap
*bm
= (GdkBitmap
*) NULL
;
796 if (mask
) bm
= mask
->GetBitmap();
798 gdk_window_set_icon( m_widget
->window
, (GdkWindow
*) NULL
, icon
.GetPixmap(), bm
);
801 void wxTopLevelWindowGTK::SetIcon( const wxIcon
&icon
)
803 SetIcons( wxIconBundle( icon
) );
806 void wxTopLevelWindowGTK::SetIcons( const wxIconBundle
&icons
)
808 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
809 GdkWindow
* window
= m_widget
->window
;
811 wxTopLevelWindowBase::SetIcons( icons
);
813 DoSetIcon( icons
.GetIcon( -1 ) );
816 wxSetIconsX11( (WXDisplay
*)GDK_WINDOW_XDISPLAY( window
),
817 (WXWindow
)GDK_WINDOW_XWINDOW( window
), icons
);
821 // ----------------------------------------------------------------------------
822 // frame state: maximized/iconized/normal
823 // ----------------------------------------------------------------------------
825 void wxTopLevelWindowGTK::Maximize(bool WXUNUSED(maximize
))
827 wxFAIL_MSG( _T("not implemented") );
830 bool wxTopLevelWindowGTK::IsMaximized() const
832 // wxFAIL_MSG( _T("not implemented") );
834 // This is an approximation
838 void wxTopLevelWindowGTK::Restore()
840 wxFAIL_MSG( _T("not implemented") );
843 void wxTopLevelWindowGTK::Iconize( bool iconize
)
847 GdkWindow
*window
= m_widget
->window
;
849 // you should do it later, for example from OnCreate() handler
850 wxCHECK_RET( window
, _T("frame not created yet - can't iconize") );
852 XIconifyWindow( GDK_WINDOW_XDISPLAY( window
),
853 GDK_WINDOW_XWINDOW( window
),
854 DefaultScreen( GDK_DISPLAY() ) );
858 bool wxTopLevelWindowGTK::IsIconized() const
863 void wxTopLevelWindowGTK::SetIconizeState(bool iconize
)
865 if ( iconize
!= m_isIconized
)
867 m_isIconized
= iconize
;
868 (void)SendIconizeEvent(iconize
);