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
;
301 m_isIconized
= FALSE
;
302 m_fsIsShowing
= FALSE
;
303 m_themeEnabled
= TRUE
;
304 m_gdkDecor
= m_gdkFunc
= 0;
307 bool wxTopLevelWindowGTK::Create( wxWindow
*parent
,
309 const wxString
& title
,
311 const wxSize
& sizeOrig
,
313 const wxString
&name
)
315 // always create a frame of some reasonable, even if arbitrary, size (at
316 // least for MSW compatibility)
317 wxSize size
= sizeOrig
;
318 if ( size
.x
== -1 || size
.y
== -1 )
320 wxSize sizeDpy
= wxGetDisplaySize();
322 size
.x
= sizeDpy
.x
/ 3;
324 size
.y
= sizeDpy
.y
/ 5;
327 wxTopLevelWindows
.Append( this );
329 m_needParent
= FALSE
;
331 if (!PreCreation( parent
, pos
, size
) ||
332 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
334 wxFAIL_MSG( wxT("wxTopLevelWindowGTK creation failed") );
340 m_insertCallback
= (wxInsertChildFunction
) wxInsertChildInTopLevelWindow
;
342 GtkWindowType win_type
= GTK_WINDOW_TOPLEVEL
;
344 if (style
& wxFRAME_TOOL_WINDOW
)
345 win_type
= GTK_WINDOW_POPUP
;
347 if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
)
349 // there is no more GTK_WINDOW_DIALOG in 2.0
351 win_type
= GTK_WINDOW_TOPLEVEL
;
353 win_type
= GTK_WINDOW_DIALOG
;
357 m_widget
= gtk_window_new( win_type
);
359 if (m_parent
&& (GTK_IS_WINDOW(m_parent
->m_widget
)) &&
360 (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
))
362 gtk_window_set_transient_for( GTK_WINDOW(m_widget
), GTK_WINDOW(m_parent
->m_widget
) );
366 gtk_window_set_wmclass( GTK_WINDOW(m_widget
), name
.mb_str(), name
.mb_str() );
368 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
369 GTK_WIDGET_UNSET_FLAGS( m_widget
, GTK_CAN_FOCUS
);
371 gtk_signal_connect( GTK_OBJECT(m_widget
), "delete_event",
372 GTK_SIGNAL_FUNC(gtk_frame_delete_callback
), (gpointer
)this );
374 // m_mainWidget holds the toolbar, the menubar and the client area
375 m_mainWidget
= gtk_pizza_new();
376 gtk_widget_show( m_mainWidget
);
377 GTK_WIDGET_UNSET_FLAGS( m_mainWidget
, GTK_CAN_FOCUS
);
378 gtk_container_add( GTK_CONTAINER(m_widget
), m_mainWidget
);
380 // for m_mainWidget themes
381 gtk_signal_connect( GTK_OBJECT(m_mainWidget
), "expose_event",
382 GTK_SIGNAL_FUNC(gtk_window_expose_callback
), (gpointer
)this );
384 gtk_signal_connect( GTK_OBJECT(m_mainWidget
), "draw",
385 GTK_SIGNAL_FUNC(gtk_window_draw_callback
), (gpointer
)this );
388 // m_wxwindow only represents the client area without toolbar and menubar
389 m_wxwindow
= gtk_pizza_new();
390 gtk_widget_show( m_wxwindow
);
391 gtk_container_add( GTK_CONTAINER(m_mainWidget
), m_wxwindow
);
393 // we donm't allow the frame to get the focus as otherwise
394 // the frame will grab it at arbitrary focus changes
395 GTK_WIDGET_UNSET_FLAGS( m_wxwindow
, GTK_CAN_FOCUS
);
397 if (m_parent
) m_parent
->AddChild( this );
399 // the user resized the frame by dragging etc.
400 gtk_signal_connect( GTK_OBJECT(m_widget
), "size_allocate",
401 GTK_SIGNAL_FUNC(gtk_frame_size_callback
), (gpointer
)this );
405 if ((m_x
!= -1) || (m_y
!= -1))
406 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
408 gtk_window_set_default_size( GTK_WINDOW(m_widget
), m_width
, m_height
);
410 // we cannot set MWM hints and icons before the widget has
411 // been realized, so we do this directly after realization
412 gtk_signal_connect( GTK_OBJECT(m_widget
), "realize",
413 GTK_SIGNAL_FUNC(gtk_frame_realized_callback
), (gpointer
) this );
415 // the only way to get the window size is to connect to this event
416 gtk_signal_connect( GTK_OBJECT(m_widget
), "configure_event",
417 GTK_SIGNAL_FUNC(gtk_frame_configure_callback
), (gpointer
)this );
419 // map and unmap for iconized state
420 gtk_signal_connect( GTK_OBJECT(m_widget
), "map_event",
421 GTK_SIGNAL_FUNC(gtk_frame_map_callback
), (gpointer
)this );
422 gtk_signal_connect( GTK_OBJECT(m_widget
), "unmap_event",
423 GTK_SIGNAL_FUNC(gtk_frame_unmap_callback
), (gpointer
)this );
425 // the only way to get the window size is to connect to this event
426 gtk_signal_connect( GTK_OBJECT(m_widget
), "configure_event",
427 GTK_SIGNAL_FUNC(gtk_frame_configure_callback
), (gpointer
)this );
429 // disable native tab traversal
430 gtk_signal_connect( GTK_OBJECT(m_widget
), "focus",
431 GTK_SIGNAL_FUNC(gtk_frame_focus_callback
), (gpointer
)this );
434 if ((m_miniEdge
> 0) || (style
& wxSIMPLE_BORDER
) || (style
& wxNO_BORDER
))
441 m_gdkDecor
= (long) GDK_DECOR_BORDER
;
442 m_gdkFunc
= (long) GDK_FUNC_MOVE
;
444 // All this is for Motif Window Manager "hints" and is supposed to be
445 // recognized by other WMs as well.
446 if ((style
& wxCAPTION
) != 0)
447 m_gdkDecor
|= GDK_DECOR_TITLE
;
448 if ((style
& wxSYSTEM_MENU
) != 0)
450 m_gdkFunc
|= GDK_FUNC_CLOSE
;
451 m_gdkDecor
|= GDK_DECOR_MENU
;
453 if ((style
& wxMINIMIZE_BOX
) != 0)
455 m_gdkFunc
|= GDK_FUNC_MINIMIZE
;
456 m_gdkDecor
|= GDK_DECOR_MINIMIZE
;
458 if ((style
& wxMAXIMIZE_BOX
) != 0)
460 m_gdkFunc
|= GDK_FUNC_MAXIMIZE
;
461 m_gdkDecor
|= GDK_DECOR_MAXIMIZE
;
463 if ((style
& wxRESIZE_BORDER
) != 0)
465 m_gdkFunc
|= GDK_FUNC_RESIZE
;
466 m_gdkDecor
|= GDK_DECOR_RESIZEH
;
473 wxTopLevelWindowGTK::~wxTopLevelWindowGTK()
475 m_isBeingDeleted
= TRUE
;
477 // it may also be GtkScrolledWindow in the case of an MDI child
478 if (GTK_IS_WINDOW(m_widget
))
480 gtk_window_set_focus( GTK_WINDOW(m_widget
), NULL
);
483 wxTopLevelWindows
.DeleteObject( this );
485 if (wxTheApp
->GetTopWindow() == this)
486 wxTheApp
->SetTopWindow( (wxWindow
*) NULL
);
488 if ((wxTopLevelWindows
.Number() == 0) &&
489 (wxTheApp
->GetExitOnFrameDelete()))
491 wxTheApp
->ExitMainLoop();
495 bool wxTopLevelWindowGTK::ShowFullScreen(bool show
, long style
)
497 if (show
== m_fsIsShowing
) return FALSE
; // return what?
499 m_fsIsShowing
= show
;
503 m_fsSaveGdkFunc
= m_gdkFunc
;
504 m_fsSaveGdkDecor
= m_gdkDecor
;
505 m_fsSaveFlag
= style
;
506 GetPosition( &m_fsSaveFrame
.x
, &m_fsSaveFrame
.y
);
507 GetSize( &m_fsSaveFrame
.width
, &m_fsSaveFrame
.height
);
509 gtk_widget_hide( m_widget
);
510 gtk_widget_unrealize( m_widget
);
512 m_gdkDecor
= (long) GDK_DECOR_BORDER
;
513 m_gdkFunc
= (long) GDK_FUNC_MOVE
;
517 wxDisplaySize( &x
, &y
);
518 SetSize( 0, 0, x
, y
);
520 gtk_widget_realize( m_widget
);
521 gtk_widget_show( m_widget
);
525 gtk_widget_hide( m_widget
);
526 gtk_widget_unrealize( m_widget
);
528 m_gdkFunc
= m_fsSaveGdkFunc
;
529 m_gdkDecor
= m_fsSaveGdkDecor
;
531 SetSize( m_fsSaveFrame
.x
, m_fsSaveFrame
.y
, m_fsSaveFrame
.width
, m_fsSaveFrame
.height
);
533 gtk_widget_realize( m_widget
);
534 gtk_widget_show( m_widget
);
540 // ----------------------------------------------------------------------------
541 // overridden wxWindow methods
542 // ----------------------------------------------------------------------------
544 bool wxTopLevelWindowGTK::Show( bool show
)
546 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
548 if (show
&& !m_sizeSet
)
550 /* by calling GtkOnSize here, we don't have to call
551 either after showing the frame, which would entail
552 much ugly flicker or from within the size_allocate
553 handler, because GTK 1.1.X forbids that. */
555 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
558 return wxWindow::Show( show
);
561 void wxTopLevelWindowGTK::DoMoveWindow(int WXUNUSED(x
), int WXUNUSED(y
), int WXUNUSED(width
), int WXUNUSED(height
) )
563 wxFAIL_MSG( wxT("DoMoveWindow called for wxTopLevelWindowGTK") );
566 void wxTopLevelWindowGTK::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
568 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
570 // this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow
571 wxASSERT_MSG( (m_wxwindow
!= NULL
), wxT("invalid frame") );
581 int old_width
= m_width
;
582 int old_height
= m_height
;
584 if ((sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) == 0)
586 if (x
!= -1) m_x
= x
;
587 if (y
!= -1) m_y
= y
;
588 if (width
!= -1) m_width
= width
;
589 if (height
!= -1) m_height
= height
;
600 if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
602 if (width == -1) m_width = 80;
605 if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
607 if (height == -1) m_height = 26;
611 int minWidth
= GetMinWidth(),
612 minHeight
= GetMinHeight(),
613 maxWidth
= GetMaxWidth(),
614 maxHeight
= GetMaxHeight();
616 if ((minWidth
!= -1) && (m_width
< minWidth
)) m_width
= minWidth
;
617 if ((minHeight
!= -1) && (m_height
< minHeight
)) m_height
= minHeight
;
618 if ((maxWidth
!= -1) && (m_width
> maxWidth
)) m_width
= maxWidth
;
619 if ((maxHeight
!= -1) && (m_height
> maxHeight
)) m_height
= maxHeight
;
621 if ((m_x
!= -1) || (m_y
!= -1))
623 if ((m_x
!= old_x
) || (m_y
!= old_y
))
625 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
629 if ((m_width
!= old_width
) || (m_height
!= old_height
))
631 if (m_widget
->window
)
632 gdk_window_resize( m_widget
->window
, m_width
, m_height
);
634 gtk_window_set_default_size( GTK_WINDOW(m_widget
), m_width
, m_height
);
636 /* we set the size in GtkOnSize, i.e. mostly the actual resizing is
637 done either directly before the frame is shown or in idle time
638 so that different calls to SetSize() don't lead to flicker. */
645 void wxTopLevelWindowGTK::DoGetClientSize( int *width
, int *height
) const
647 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
649 wxWindow::DoGetClientSize( width
, height
);
653 *height
-= m_miniEdge
*2 + m_miniTitle
;
657 *width
-= m_miniEdge
*2;
661 void wxTopLevelWindowGTK::DoSetClientSize( int width
, int height
)
663 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
666 width
+ m_miniEdge
*2, height
+ m_miniEdge
*2 + m_miniTitle
, 0);
669 void wxTopLevelWindowGTK::GtkOnSize( int WXUNUSED(x
), int WXUNUSED(y
),
670 int width
, int height
)
672 // due to a bug in gtk, x,y are always 0
677 if (m_resizing
) return;
680 if ( m_wxwindow
== NULL
) return;
685 /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses
686 wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
687 set in wxFrame::Create so it is used to check what kind of frame we
688 have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
689 skip the part which handles m_frameMenuBar, m_frameToolBar and (most
690 importantly) m_mainWidget */
692 int minWidth
= GetMinWidth(),
693 minHeight
= GetMinHeight(),
694 maxWidth
= GetMaxWidth(),
695 maxHeight
= GetMaxHeight();
697 if ((minWidth
!= -1) && (m_width
< minWidth
)) m_width
= minWidth
;
698 if ((minHeight
!= -1) && (m_height
< minHeight
)) m_height
= minHeight
;
699 if ((maxWidth
!= -1) && (m_width
> maxWidth
)) m_width
= maxWidth
;
700 if ((maxHeight
!= -1) && (m_height
> maxHeight
)) m_height
= maxHeight
;
705 gint flag
= 0; // GDK_HINT_POS;
706 if ((minWidth
!= -1) || (minHeight
!= -1)) flag
|= GDK_HINT_MIN_SIZE
;
707 if ((maxWidth
!= -1) || (maxHeight
!= -1)) flag
|= GDK_HINT_MAX_SIZE
;
709 geom
.min_width
= minWidth
;
710 geom
.min_height
= minHeight
;
711 geom
.max_width
= maxWidth
;
712 geom
.max_height
= maxHeight
;
713 gtk_window_set_geometry_hints( GTK_WINDOW(m_widget
),
716 (GdkWindowHints
) flag
);
718 /* I revert back to wxGTK's original behaviour. m_mainWidget holds the
719 * menubar, the toolbar and the client area, which is represented by
721 * this hurts in the eye, but I don't want to call SetSize()
722 * because I don't want to call any non-native functions here. */
724 int client_x
= m_miniEdge
;
725 int client_y
= m_miniEdge
+ m_miniTitle
;
726 int client_w
= m_width
- 2*m_miniEdge
;
727 int client_h
= m_height
- 2*m_miniEdge
- m_miniTitle
;
728 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget
),
730 client_x
, client_y
, client_w
, client_h
);
734 // If there is no m_mainWidget between m_widget and m_wxwindow there
735 // is no need to set the size or position of m_wxwindow.
740 // send size event to frame
741 wxSizeEvent
event( wxSize(m_width
,m_height
), GetId() );
742 event
.SetEventObject( this );
743 GetEventHandler()->ProcessEvent( event
);
748 void wxTopLevelWindowGTK::OnInternalIdle()
750 if (!m_sizeSet
&& GTK_WIDGET_REALIZED(m_wxwindow
))
752 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
754 // we'll come back later
756 wxapp_install_idle_handler();
760 // set the focus if not done yet and if we can already do it
761 if ( GTK_WIDGET_REALIZED(m_wxwindow
) )
763 if ( g_delayedFocus
&&
764 wxGetTopLevelParent((wxWindow
*)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
);