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 // ----------------------------------------------------------------------------
43 // ----------------------------------------------------------------------------
45 extern void wxapp_install_idle_handler();
47 extern int g_openDialogs
;
49 // ----------------------------------------------------------------------------
51 // ----------------------------------------------------------------------------
53 #ifndef __WXUNIVERSAL__
54 IMPLEMENT_DYNAMIC_CLASS(wxTopLevelWindow
, wxWindow
)
57 // ----------------------------------------------------------------------------
59 // ----------------------------------------------------------------------------
61 extern wxList wxPendingDelete
;
63 // ----------------------------------------------------------------------------
65 // ----------------------------------------------------------------------------
69 extern void debug_focus_in( GtkWidget
* widget
, const wxChar
* name
, const wxChar
*window
);
73 // ============================================================================
75 // ============================================================================
77 // ----------------------------------------------------------------------------
79 // ----------------------------------------------------------------------------
81 //-----------------------------------------------------------------------------
82 // "focus" from m_window
83 //-----------------------------------------------------------------------------
85 static gint
gtk_frame_focus_callback( GtkWidget
*widget
, GtkDirectionType
WXUNUSED(d
), wxWindow
*WXUNUSED(win
) )
88 wxapp_install_idle_handler();
90 // This disables GTK's tab traversal
91 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "focus" );
95 //-----------------------------------------------------------------------------
97 //-----------------------------------------------------------------------------
99 static void gtk_frame_size_callback( GtkWidget
*WXUNUSED(widget
), GtkAllocation
* alloc
, wxTopLevelWindowGTK
*win
)
102 wxapp_install_idle_handler();
107 if ((win
->m_width
!= alloc
->width
) || (win
->m_height
!= alloc
->height
))
110 wxPrintf( "OnSize from " );
111 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
112 wxPrintf( win->GetClassInfo()->GetClassName() );
113 wxPrintf( " %d %d %d %d\n", (int)alloc->x,
116 (int)alloc->height );
119 win
->m_width
= alloc
->width
;
120 win
->m_height
= alloc
->height
;
121 win
->m_queuedFullRedraw
= TRUE
;
122 win
->GtkUpdateSize();
126 //-----------------------------------------------------------------------------
128 //-----------------------------------------------------------------------------
130 static gint
gtk_frame_delete_callback( GtkWidget
*WXUNUSED(widget
), GdkEvent
*WXUNUSED(event
), wxTopLevelWindowGTK
*win
)
133 wxapp_install_idle_handler();
135 if (win
->IsEnabled() &&
136 (g_openDialogs
== 0 || (win
->GetExtraStyle() & wxTLW_EX_DIALOG
)))
143 //-----------------------------------------------------------------------------
145 //-----------------------------------------------------------------------------
148 #if (GTK_MINOR_VERSION > 0)
149 gtk_frame_configure_callback( GtkWidget
*WXUNUSED(widget
), GdkEventConfigure
*WXUNUSED(event
), wxTopLevelWindowGTK
*win
)
151 gtk_frame_configure_callback( GtkWidget
*WXUNUSED(widget
), GdkEventConfigure
*event
, wxTopLevelWindowGTK
*win
)
155 wxapp_install_idle_handler();
160 #if (GTK_MINOR_VERSION > 0)
163 gdk_window_get_root_origin( win
->m_widget
->window
, &x
, &y
);
171 wxMoveEvent
mevent( wxPoint(win
->m_x
,win
->m_y
), win
->GetId() );
172 mevent
.SetEventObject( win
);
173 win
->GetEventHandler()->ProcessEvent( mevent
);
178 //-----------------------------------------------------------------------------
179 // "realize" from m_widget
180 //-----------------------------------------------------------------------------
182 /* we cannot MWM hints and icons before the widget has been realized,
183 so we do this directly after realization */
186 gtk_frame_realized_callback( GtkWidget
* WXUNUSED(widget
), wxTopLevelWindowGTK
*win
)
189 wxapp_install_idle_handler();
191 if ((win
->m_miniEdge
> 0) || (win
->HasFlag(wxSIMPLE_BORDER
)) || (win
->HasFlag(wxNO_BORDER
)))
193 /* This is a mini-frame or a borderless frame. */
194 gdk_window_set_decorations( win
->m_widget
->window
, (GdkWMDecoration
)0 );
195 gdk_window_set_functions( win
->m_widget
->window
, (GdkWMFunction
)0 );
199 /* All this is for Motif Window Manager "hints" and is supposed to be
200 recognized by other WM as well. Not tested. */
201 long decor
= (long) GDK_DECOR_BORDER
;
202 long func
= (long) GDK_FUNC_MOVE
;
204 if ((win
->GetWindowStyle() & wxCAPTION
) != 0)
205 decor
|= GDK_DECOR_TITLE
;
206 if ((win
->GetWindowStyle() & wxSYSTEM_MENU
) != 0)
208 decor
|= GDK_DECOR_MENU
;
209 func
|= GDK_FUNC_CLOSE
;
211 if ((win
->GetWindowStyle() & wxMINIMIZE_BOX
) != 0)
213 func
|= GDK_FUNC_MINIMIZE
;
214 decor
|= GDK_DECOR_MINIMIZE
;
216 if ((win
->GetWindowStyle() & wxMAXIMIZE_BOX
) != 0)
218 func
|= GDK_FUNC_MAXIMIZE
;
219 decor
|= GDK_DECOR_MAXIMIZE
;
221 if ((win
->GetWindowStyle() & wxRESIZE_BORDER
) != 0)
223 func
|= GDK_FUNC_RESIZE
;
224 decor
|= GDK_DECOR_RESIZEH
;
227 gdk_window_set_decorations( win
->m_widget
->window
, (GdkWMDecoration
)decor
);
228 gdk_window_set_functions( win
->m_widget
->window
, (GdkWMFunction
)func
);
231 /* GTK's shrinking/growing policy */
232 if ((win
->GetWindowStyle() & wxRESIZE_BORDER
) == 0)
233 gtk_window_set_policy(GTK_WINDOW(win
->m_widget
), 0, 0, 1);
235 gtk_window_set_policy(GTK_WINDOW(win
->m_widget
), 1, 1, 1);
238 wxIcon iconOld
= win
->GetIcon();
239 if ( iconOld
!= wxNullIcon
)
241 wxIcon
icon( iconOld
);
242 win
->SetIcon( wxNullIcon
);
243 win
->SetIcon( icon
);
246 /* we set the focus to the child that accepts the focus. this
247 doesn't really have to be done in "realize" but why not? */
248 wxWindowList::Node
*node
= win
->GetChildren().GetFirst();
251 wxWindow
*child
= node
->GetData();
252 if (child
->AcceptsFocus())
258 node
= node
->GetNext();
262 //-----------------------------------------------------------------------------
263 // "map_event" from m_widget
264 //-----------------------------------------------------------------------------
267 gtk_frame_map_callback( GtkWidget
* WXUNUSED(widget
),
268 GdkEvent
* WXUNUSED(event
),
269 wxTopLevelWindow
*win
)
271 win
->SetIconizeState(FALSE
);
274 //-----------------------------------------------------------------------------
275 // "unmap_event" from m_widget
276 //-----------------------------------------------------------------------------
279 gtk_frame_unmap_callback( GtkWidget
* WXUNUSED(widget
),
280 GdkEvent
* WXUNUSED(event
),
281 wxTopLevelWindow
*win
)
283 win
->SetIconizeState(TRUE
);
286 //-----------------------------------------------------------------------------
287 // "expose_event" of m_client
288 //-----------------------------------------------------------------------------
290 static int gtk_window_expose_callback( GtkWidget
*widget
, GdkEventExpose
*gdk_event
, wxWindow
*win
)
292 GtkPizza
*pizza
= GTK_PIZZA(widget
);
294 gtk_paint_flat_box (win
->m_widget
->style
, pizza
->bin_window
, GTK_STATE_NORMAL
,
295 GTK_SHADOW_NONE
, &gdk_event
->area
, win
->m_widget
, "base", 0, 0, -1, -1);
300 //-----------------------------------------------------------------------------
301 // "draw" of m_client
302 //-----------------------------------------------------------------------------
305 static void gtk_window_draw_callback( GtkWidget
*widget
, GdkRectangle
*rect
, wxWindow
*win
)
307 GtkPizza
*pizza
= GTK_PIZZA(widget
);
309 gtk_paint_flat_box (win
->m_widget
->style
, pizza
->bin_window
, GTK_STATE_NORMAL
,
310 GTK_SHADOW_NONE
, rect
, win
->m_widget
, "base", 0, 0, -1, -1);
313 // ----------------------------------------------------------------------------
314 // wxTopLevelWindowGTK itself
315 // ----------------------------------------------------------------------------
317 //-----------------------------------------------------------------------------
318 // InsertChild for wxTopLevelWindowGTK
319 //-----------------------------------------------------------------------------
321 /* Callback for wxTopLevelWindowGTK. This very strange beast has to be used because
322 * C++ has no virtual methods in a constructor. We have to emulate a
323 * virtual function here as wxWindows requires different ways to insert
324 * a child in container classes. */
326 static void wxInsertChildInTopLevelWindow( wxTopLevelWindowGTK
* parent
, wxWindow
* child
)
328 wxASSERT( GTK_IS_WIDGET(child
->m_widget
) );
330 if (!parent
->m_insertInClientArea
)
332 /* these are outside the client area */
333 wxTopLevelWindowGTK
* frame
= (wxTopLevelWindowGTK
*) parent
;
334 gtk_pizza_put( GTK_PIZZA(frame
->m_mainWidget
),
335 GTK_WIDGET(child
->m_widget
),
343 /* these are inside the client area */
344 gtk_pizza_put( GTK_PIZZA(parent
->m_wxwindow
),
345 GTK_WIDGET(child
->m_widget
),
352 /* resize on OnInternalIdle */
353 parent
->GtkUpdateSize();
356 // ----------------------------------------------------------------------------
357 // wxTopLevelWindowGTK creation
358 // ----------------------------------------------------------------------------
360 void wxTopLevelWindowGTK::Init()
365 m_mainWidget
= (GtkWidget
*) NULL
;
366 m_insertInClientArea
= TRUE
;
368 m_isIconized
= FALSE
;
369 m_fsIsShowing
= FALSE
;
370 m_themeEnabled
= TRUE
;
373 bool wxTopLevelWindowGTK::Create( wxWindow
*parent
,
375 const wxString
& title
,
377 const wxSize
& sizeOrig
,
379 const wxString
&name
)
381 // always create a frame of some reasonable, even if arbitrary, size (at
382 // least for MSW compatibility)
383 wxSize size
= sizeOrig
;
384 if ( size
.x
== -1 || size
.y
== -1 )
386 wxSize sizeDpy
= wxGetDisplaySize();
388 size
.x
= sizeDpy
.x
/ 3;
390 size
.y
= sizeDpy
.y
/ 5;
393 wxTopLevelWindows
.Append( this );
395 m_needParent
= FALSE
;
397 if (!PreCreation( parent
, pos
, size
) ||
398 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
400 wxFAIL_MSG( wxT("wxTopLevelWindowGTK creation failed") );
406 m_insertCallback
= (wxInsertChildFunction
) wxInsertChildInTopLevelWindow
;
408 GtkWindowType win_type
= GTK_WINDOW_TOPLEVEL
;
410 if (style
& wxFRAME_TOOL_WINDOW
)
411 win_type
= GTK_WINDOW_POPUP
;
413 if (GetExtraStyle() & wxTLW_EX_DIALOG
)
414 win_type
= GTK_WINDOW_DIALOG
;
416 m_widget
= gtk_window_new( win_type
);
418 if ((m_parent
) && (HasFlag(wxFRAME_FLOAT_ON_PARENT
)) && (GTK_IS_WINDOW(m_parent
->m_widget
)))
419 gtk_window_set_transient_for( GTK_WINDOW(m_widget
), GTK_WINDOW(m_parent
->m_widget
) );
422 gtk_window_set_wmclass( GTK_WINDOW(m_widget
), name
.mb_str(), name
.mb_str() );
425 debug_focus_in( m_widget
, wxT("wxTopLevelWindowGTK::m_widget"), name
);
428 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
429 GTK_WIDGET_UNSET_FLAGS( m_widget
, GTK_CAN_FOCUS
);
431 gtk_signal_connect( GTK_OBJECT(m_widget
), "delete_event",
432 GTK_SIGNAL_FUNC(gtk_frame_delete_callback
), (gpointer
)this );
434 /* m_mainWidget holds the toolbar, the menubar and the client area */
435 m_mainWidget
= gtk_pizza_new();
436 gtk_widget_show( m_mainWidget
);
437 GTK_WIDGET_UNSET_FLAGS( m_mainWidget
, GTK_CAN_FOCUS
);
438 gtk_container_add( GTK_CONTAINER(m_widget
), m_mainWidget
);
440 /* for m_mainWidget themes */
441 gtk_signal_connect( GTK_OBJECT(m_mainWidget
), "expose_event",
442 GTK_SIGNAL_FUNC(gtk_window_expose_callback
), (gpointer
)this );
443 gtk_signal_connect( GTK_OBJECT(m_mainWidget
), "draw",
444 GTK_SIGNAL_FUNC(gtk_window_draw_callback
), (gpointer
)this );
447 debug_focus_in( m_mainWidget
, wxT("wxTopLevelWindowGTK::m_mainWidget"), name
);
450 /* m_wxwindow only represents the client area without toolbar and menubar */
451 m_wxwindow
= gtk_pizza_new();
452 gtk_widget_show( m_wxwindow
);
453 gtk_container_add( GTK_CONTAINER(m_mainWidget
), m_wxwindow
);
456 debug_focus_in( m_wxwindow
, wxT("wxTopLevelWindowGTK::m_wxwindow"), name
);
459 /* we donm't allow the frame to get the focus as otherwise
460 the frame will grab it at arbitrary focus changes. */
461 GTK_WIDGET_UNSET_FLAGS( m_wxwindow
, GTK_CAN_FOCUS
);
463 if (m_parent
) m_parent
->AddChild( this );
465 /* the user resized the frame by dragging etc. */
466 gtk_signal_connect( GTK_OBJECT(m_widget
), "size_allocate",
467 GTK_SIGNAL_FUNC(gtk_frame_size_callback
), (gpointer
)this );
471 if ((m_x
!= -1) || (m_y
!= -1))
472 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
473 gtk_widget_set_usize( m_widget
, m_width
, m_height
);
475 /* we cannot set MWM hints and icons before the widget has
476 been realized, so we do this directly after realization */
477 gtk_signal_connect( GTK_OBJECT(m_widget
), "realize",
478 GTK_SIGNAL_FUNC(gtk_frame_realized_callback
), (gpointer
) this );
480 /* the only way to get the window size is to connect to this event */
481 gtk_signal_connect( GTK_OBJECT(m_widget
), "configure_event",
482 GTK_SIGNAL_FUNC(gtk_frame_configure_callback
), (gpointer
)this );
484 /* map and unmap for iconized state */
485 gtk_signal_connect( GTK_OBJECT(m_widget
), "map_event",
486 GTK_SIGNAL_FUNC(gtk_frame_map_callback
), (gpointer
)this );
487 gtk_signal_connect( GTK_OBJECT(m_widget
), "unmap_event",
488 GTK_SIGNAL_FUNC(gtk_frame_unmap_callback
), (gpointer
)this );
490 /* the only way to get the window size is to connect to this event */
491 gtk_signal_connect( GTK_OBJECT(m_widget
), "configure_event",
492 GTK_SIGNAL_FUNC(gtk_frame_configure_callback
), (gpointer
)this );
494 /* disable native tab traversal */
495 gtk_signal_connect( GTK_OBJECT(m_widget
), "focus",
496 GTK_SIGNAL_FUNC(gtk_frame_focus_callback
), (gpointer
)this );
501 wxTopLevelWindowGTK::~wxTopLevelWindowGTK()
503 m_isBeingDeleted
= TRUE
;
505 wxTopLevelWindows
.DeleteObject( this );
507 if (wxTheApp
->GetTopWindow() == this)
508 wxTheApp
->SetTopWindow( (wxWindow
*) NULL
);
510 if ((wxTopLevelWindows
.Number() == 0) &&
511 (wxTheApp
->GetExitOnFrameDelete()))
513 wxTheApp
->ExitMainLoop();
517 bool wxTopLevelWindowGTK::ShowFullScreen(bool show
, long style
)
519 if (show
== m_fsIsShowing
) return FALSE
; // return what?
521 m_fsIsShowing
= show
;
525 m_fsSaveStyle
= m_windowStyle
;
526 m_fsSaveFlag
= style
;
527 GetPosition( &m_fsSaveFrame
.x
, &m_fsSaveFrame
.y
);
528 GetSize( &m_fsSaveFrame
.width
, &m_fsSaveFrame
.height
);
530 gtk_widget_hide( m_widget
);
531 gtk_widget_unrealize( m_widget
);
533 m_windowStyle
= wxSIMPLE_BORDER
;
537 wxDisplaySize( &x
, &y
);
538 SetSize( 0, 0, x
, y
);
540 gtk_widget_realize( m_widget
);
541 gtk_widget_show( m_widget
);
545 gtk_widget_hide( m_widget
);
546 gtk_widget_unrealize( m_widget
);
548 m_windowStyle
= m_fsSaveStyle
;
550 SetSize( m_fsSaveFrame
.x
, m_fsSaveFrame
.y
, m_fsSaveFrame
.width
, m_fsSaveFrame
.height
);
552 gtk_widget_realize( m_widget
);
553 gtk_widget_show( m_widget
);
559 // ----------------------------------------------------------------------------
560 // overridden wxWindow methods
561 // ----------------------------------------------------------------------------
563 bool wxTopLevelWindowGTK::Show( bool show
)
565 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
567 if (show
&& !m_sizeSet
)
569 /* by calling GtkOnSize here, we don't have to call
570 either after showing the frame, which would entail
571 much ugly flicker or from within the size_allocate
572 handler, because GTK 1.1.X forbids that. */
574 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
577 return wxWindow::Show( show
);
580 void wxTopLevelWindowGTK::DoMoveWindow(int WXUNUSED(x
), int WXUNUSED(y
), int WXUNUSED(width
), int WXUNUSED(height
) )
582 wxFAIL_MSG( wxT("DoMoveWindow called for wxTopLevelWindowGTK") );
585 void wxTopLevelWindowGTK::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
587 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
589 /* this shouldn't happen: wxFrameGTK, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
590 wxASSERT_MSG( (m_wxwindow
!= NULL
), wxT("invalid frame") );
592 /* avoid recursions */
600 int old_width
= m_width
;
601 int old_height
= m_height
;
603 if ((sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) == 0)
605 if (x
!= -1) m_x
= x
;
606 if (y
!= -1) m_y
= y
;
607 if (width
!= -1) m_width
= width
;
608 if (height
!= -1) m_height
= height
;
619 if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
621 if (width == -1) m_width = 80;
624 if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
626 if (height == -1) m_height = 26;
630 if ((m_minWidth
!= -1) && (m_width
< m_minWidth
)) m_width
= m_minWidth
;
631 if ((m_minHeight
!= -1) && (m_height
< m_minHeight
)) m_height
= m_minHeight
;
632 if ((m_maxWidth
!= -1) && (m_width
> m_maxWidth
)) m_width
= m_maxWidth
;
633 if ((m_maxHeight
!= -1) && (m_height
> m_maxHeight
)) m_height
= m_maxHeight
;
635 if ((m_x
!= -1) || (m_y
!= -1))
637 if ((m_x
!= old_x
) || (m_y
!= old_y
))
639 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
643 if ((m_width
!= old_width
) || (m_height
!= old_height
))
645 gtk_widget_set_usize( m_widget
, m_width
, m_height
);
647 /* we set the size in GtkOnSize, i.e. mostly the actual resizing is
648 done either directly before the frame is shown or in idle time
649 so that different calls to SetSize() don't lead to flicker. */
656 void wxTopLevelWindowGTK::DoGetClientSize( int *width
, int *height
) const
658 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
660 wxWindow::DoGetClientSize( width
, height
);
664 *height
-= m_miniEdge
*2 + m_miniTitle
;
668 *width
-= m_miniEdge
*2;
672 void wxTopLevelWindowGTK::DoSetClientSize( int width
, int height
)
674 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
677 width
+ m_miniEdge
*2, height
+ m_miniEdge
*2 + m_miniTitle
, 0);
680 void wxTopLevelWindowGTK::GtkOnSize( int WXUNUSED(x
), int WXUNUSED(y
),
681 int width
, int height
)
683 // due to a bug in gtk, x,y are always 0
687 /* avoid recursions */
688 if (m_resizing
) return;
691 if ( m_wxwindow
== NULL
) return;
696 /* wxMDIChildFrame derives from wxFrameGTK but it _is_ a wxWindow as it uses
697 wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
698 set in wxFrameGTK::Create so it is used to check what kind of frame we
699 have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
700 skip the part which handles m_frameMenuBar, m_frameToolBar and (most
701 importantly) m_mainWidget */
703 if ((m_minWidth
!= -1) && (m_width
< m_minWidth
)) m_width
= m_minWidth
;
704 if ((m_minHeight
!= -1) && (m_height
< m_minHeight
)) m_height
= m_minHeight
;
705 if ((m_maxWidth
!= -1) && (m_width
> m_maxWidth
)) m_width
= m_maxWidth
;
706 if ((m_maxHeight
!= -1) && (m_height
> m_maxHeight
)) m_height
= m_maxHeight
;
711 gint flag
= 0; // GDK_HINT_POS;
712 if ((m_minWidth
!= -1) || (m_minHeight
!= -1)) flag
|= GDK_HINT_MIN_SIZE
;
713 if ((m_maxWidth
!= -1) || (m_maxHeight
!= -1)) flag
|= GDK_HINT_MAX_SIZE
;
715 geom
.min_width
= m_minWidth
;
716 geom
.min_height
= m_minHeight
;
717 geom
.max_width
= m_maxWidth
;
718 geom
.max_height
= m_maxHeight
;
719 gtk_window_set_geometry_hints( GTK_WINDOW(m_widget
),
722 (GdkWindowHints
) flag
);
724 /* I revert back to wxGTK's original behaviour. m_mainWidget holds the
725 * menubar, the toolbar and the client area, which is represented by
727 * this hurts in the eye, but I don't want to call SetSize()
728 * because I don't want to call any non-native functions here. */
730 int client_x
= m_miniEdge
;
731 int client_y
= m_miniEdge
+ m_miniTitle
;
732 int client_w
= m_width
- 2*m_miniEdge
;
733 int client_h
= m_height
- 2*m_miniEdge
- m_miniTitle
;
734 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget
),
736 client_x
, client_y
, client_w
, client_h
);
740 /* if there is no m_mainWidget between m_widget and m_wxwindow there
741 is no need to set the size or position of m_wxwindow. */
746 // send size event to frame
747 wxSizeEvent
event( wxSize(m_width
,m_height
), GetId() );
748 event
.SetEventObject( this );
749 GetEventHandler()->ProcessEvent( event
);
754 void wxTopLevelWindowGTK::OnInternalIdle()
756 if (!m_sizeSet
&& GTK_WIDGET_REALIZED(m_wxwindow
))
758 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
760 // we'll come back later
762 wxapp_install_idle_handler();
766 wxWindow::OnInternalIdle();
770 // ----------------------------------------------------------------------------
772 // ----------------------------------------------------------------------------
774 void wxTopLevelWindowGTK::SetTitle( const wxString
&title
)
776 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
779 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
782 void wxTopLevelWindowGTK::SetIcon( const wxIcon
&icon
)
784 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
786 wxTopLevelWindowBase::SetIcon(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 // ----------------------------------------------------------------------------
802 // frame state: maximized/iconized/normal
803 // ----------------------------------------------------------------------------
805 void wxTopLevelWindowGTK::Maximize(bool WXUNUSED(maximize
))
807 wxFAIL_MSG( _T("not implemented") );
810 bool wxTopLevelWindowGTK::IsMaximized() const
812 // wxFAIL_MSG( _T("not implemented") );
814 // This is an approximation
818 void wxTopLevelWindowGTK::Restore()
820 wxFAIL_MSG( _T("not implemented") );
823 void wxTopLevelWindowGTK::Iconize( bool iconize
)
827 GdkWindow
*window
= m_widget
->window
;
829 // you should do it later, for example from OnCreate() handler
830 wxCHECK_RET( window
, _T("frame not created yet - can't iconize") );
832 XIconifyWindow( GDK_WINDOW_XDISPLAY( window
),
833 GDK_WINDOW_XWINDOW( window
),
834 DefaultScreen( GDK_DISPLAY() ) );
838 bool wxTopLevelWindowGTK::IsIconized() const
843 void wxTopLevelWindowGTK::SetIconizeState(bool iconize
)
845 if ( iconize
!= m_isIconized
)
847 m_isIconized
= iconize
;
848 (void)SendIconizeEvent(iconize
);