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 // ----------------------------------------------------------------------------
55 // ----------------------------------------------------------------------------
57 extern wxList wxPendingDelete
;
59 // ----------------------------------------------------------------------------
61 // ----------------------------------------------------------------------------
65 extern void debug_focus_in( GtkWidget
* widget
, const wxChar
* name
, const wxChar
*window
);
69 // ============================================================================
71 // ============================================================================
73 // ----------------------------------------------------------------------------
75 // ----------------------------------------------------------------------------
77 //-----------------------------------------------------------------------------
78 // "focus" from m_window
79 //-----------------------------------------------------------------------------
81 static gint
gtk_frame_focus_callback( GtkWidget
*widget
, GtkDirectionType
WXUNUSED(d
), wxWindow
*WXUNUSED(win
) )
84 wxapp_install_idle_handler();
86 // This disables GTK's tab traversal
87 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "focus" );
91 //-----------------------------------------------------------------------------
93 //-----------------------------------------------------------------------------
95 static void gtk_frame_size_callback( GtkWidget
*WXUNUSED(widget
), GtkAllocation
* alloc
, wxTopLevelWindowGTK
*win
)
98 wxapp_install_idle_handler();
103 if ((win
->m_width
!= alloc
->width
) || (win
->m_height
!= alloc
->height
))
106 wxPrintf( "OnSize from " );
107 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
108 wxPrintf( win->GetClassInfo()->GetClassName() );
109 wxPrintf( " %d %d %d %d\n", (int)alloc->x,
112 (int)alloc->height );
115 win
->m_width
= alloc
->width
;
116 win
->m_height
= alloc
->height
;
117 win
->m_queuedFullRedraw
= TRUE
;
118 win
->GtkUpdateSize();
122 //-----------------------------------------------------------------------------
124 //-----------------------------------------------------------------------------
126 static gint
gtk_frame_delete_callback( GtkWidget
*WXUNUSED(widget
), GdkEvent
*WXUNUSED(event
), wxTopLevelWindowGTK
*win
)
129 wxapp_install_idle_handler();
131 if (win
->IsEnabled() &&
132 (g_openDialogs
== 0 || (win
->GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
)))
139 //-----------------------------------------------------------------------------
141 //-----------------------------------------------------------------------------
144 gtk_frame_configure_callback( GtkWidget
*WXUNUSED(widget
), GdkEventConfigure
*WXUNUSED(event
), wxTopLevelWindowGTK
*win
)
147 wxapp_install_idle_handler();
149 if (!win
->m_hasVMT
|| !win
->IsShown())
154 gdk_window_get_root_origin( win
->m_widget
->window
, &x
, &y
);
158 wxMoveEvent
mevent( wxPoint(win
->m_x
,win
->m_y
), win
->GetId() );
159 mevent
.SetEventObject( win
);
160 win
->GetEventHandler()->ProcessEvent( mevent
);
165 //-----------------------------------------------------------------------------
166 // "realize" from m_widget
167 //-----------------------------------------------------------------------------
169 // we cannot MWM hints and icons before the widget has been realized,
170 // so we do this directly after realization
173 gtk_frame_realized_callback( GtkWidget
* WXUNUSED(widget
), wxTopLevelWindowGTK
*win
)
176 wxapp_install_idle_handler();
178 // All this is for Motif Window Manager "hints" and is supposed to be
179 // recognized by other WM as well. Not tested.
180 gdk_window_set_decorations(win
->m_widget
->window
,
181 (GdkWMDecoration
)win
->m_gdkDecor
);
182 gdk_window_set_functions(win
->m_widget
->window
,
183 (GdkWMFunction
)win
->m_gdkFunc
);
185 // GTK's shrinking/growing policy
186 if ((win
->m_gdkFunc
& GDK_FUNC_RESIZE
) == 0)
187 gtk_window_set_policy(GTK_WINDOW(win
->m_widget
), 0, 0, 1);
189 gtk_window_set_policy(GTK_WINDOW(win
->m_widget
), 1, 1, 1);
192 wxIcon iconOld
= win
->GetIcon();
193 if ( iconOld
!= wxNullIcon
)
195 wxIcon
icon( iconOld
);
196 win
->SetIcon( wxNullIcon
);
197 win
->SetIcon( icon
);
200 // we set the focus to the child that accepts the focus. this
201 // doesn't really have to be done in "realize" but why not?
202 wxWindowList::Node
*node
= win
->GetChildren().GetFirst();
205 wxWindow
*child
= node
->GetData();
206 if (child
->AcceptsFocus())
212 node
= node
->GetNext();
216 //-----------------------------------------------------------------------------
217 // "map_event" from m_widget
218 //-----------------------------------------------------------------------------
221 gtk_frame_map_callback( GtkWidget
* WXUNUSED(widget
),
222 GdkEvent
* WXUNUSED(event
),
223 wxTopLevelWindow
*win
)
225 win
->SetIconizeState(FALSE
);
228 //-----------------------------------------------------------------------------
229 // "unmap_event" from m_widget
230 //-----------------------------------------------------------------------------
233 gtk_frame_unmap_callback( GtkWidget
* WXUNUSED(widget
),
234 GdkEvent
* WXUNUSED(event
),
235 wxTopLevelWindow
*win
)
237 win
->SetIconizeState(TRUE
);
240 //-----------------------------------------------------------------------------
241 // "expose_event" of m_client
242 //-----------------------------------------------------------------------------
244 static int gtk_window_expose_callback( GtkWidget
*widget
, GdkEventExpose
*gdk_event
, wxWindow
*win
)
246 GtkPizza
*pizza
= GTK_PIZZA(widget
);
248 gtk_paint_flat_box (win
->m_widget
->style
,
249 pizza
->bin_window
, GTK_STATE_NORMAL
,
259 //-----------------------------------------------------------------------------
260 // "draw" of m_client
261 //-----------------------------------------------------------------------------
264 static void gtk_window_draw_callback( GtkWidget
*widget
, GdkRectangle
*rect
, wxWindow
*win
)
266 GtkPizza
*pizza
= GTK_PIZZA(widget
);
268 gtk_paint_flat_box (win
->m_widget
->style
,
269 pizza
->bin_window
, GTK_STATE_NORMAL
,
277 // ----------------------------------------------------------------------------
278 // wxTopLevelWindowGTK itself
279 // ----------------------------------------------------------------------------
281 //-----------------------------------------------------------------------------
282 // InsertChild for wxTopLevelWindowGTK
283 //-----------------------------------------------------------------------------
285 /* Callback for wxTopLevelWindowGTK. This very strange beast has to be used because
286 * C++ has no virtual methods in a constructor. We have to emulate a
287 * virtual function here as wxWindows requires different ways to insert
288 * a child in container classes. */
290 static void wxInsertChildInTopLevelWindow( wxTopLevelWindowGTK
* parent
, wxWindow
* child
)
292 wxASSERT( GTK_IS_WIDGET(child
->m_widget
) );
294 if (!parent
->m_insertInClientArea
)
296 // these are outside the client area
297 wxTopLevelWindowGTK
* frame
= (wxTopLevelWindowGTK
*) parent
;
298 gtk_pizza_put( GTK_PIZZA(frame
->m_mainWidget
),
299 GTK_WIDGET(child
->m_widget
),
307 // these are inside the client area
308 gtk_pizza_put( GTK_PIZZA(parent
->m_wxwindow
),
309 GTK_WIDGET(child
->m_widget
),
316 // resize on OnInternalIdle
317 parent
->GtkUpdateSize();
320 // ----------------------------------------------------------------------------
321 // wxTopLevelWindowGTK creation
322 // ----------------------------------------------------------------------------
324 void wxTopLevelWindowGTK::Init()
329 m_mainWidget
= (GtkWidget
*) NULL
;
330 m_insertInClientArea
= TRUE
;
332 m_isIconized
= FALSE
;
333 m_fsIsShowing
= FALSE
;
334 m_themeEnabled
= TRUE
;
335 m_gdkDecor
= m_gdkFunc
= 0;
338 bool wxTopLevelWindowGTK::Create( wxWindow
*parent
,
340 const wxString
& title
,
342 const wxSize
& sizeOrig
,
344 const wxString
&name
)
346 // always create a frame of some reasonable, even if arbitrary, size (at
347 // least for MSW compatibility)
348 wxSize size
= sizeOrig
;
349 if ( size
.x
== -1 || size
.y
== -1 )
351 wxSize sizeDpy
= wxGetDisplaySize();
353 size
.x
= sizeDpy
.x
/ 3;
355 size
.y
= sizeDpy
.y
/ 5;
358 wxTopLevelWindows
.Append( this );
360 m_needParent
= FALSE
;
362 if (!PreCreation( parent
, pos
, size
) ||
363 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
365 wxFAIL_MSG( wxT("wxTopLevelWindowGTK creation failed") );
371 m_insertCallback
= (wxInsertChildFunction
) wxInsertChildInTopLevelWindow
;
373 GtkWindowType win_type
= GTK_WINDOW_TOPLEVEL
;
375 if (style
& wxFRAME_TOOL_WINDOW
)
376 win_type
= GTK_WINDOW_POPUP
;
378 if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
)
380 // there is no more GTK_WINDOW_DIALOG in 2.0
382 win_type
= GTK_WINDOW_TOPLEVEL
;
384 win_type
= GTK_WINDOW_DIALOG
;
388 m_widget
= gtk_window_new( win_type
);
390 if (m_parent
&& (GTK_IS_WINDOW(m_parent
->m_widget
)) &&
391 (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
))
393 gtk_window_set_transient_for( GTK_WINDOW(m_widget
), GTK_WINDOW(m_parent
->m_widget
) );
397 gtk_window_set_wmclass( GTK_WINDOW(m_widget
), name
.mb_str(), name
.mb_str() );
400 debug_focus_in( m_widget
, wxT("wxTopLevelWindowGTK::m_widget"), name
);
403 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
404 GTK_WIDGET_UNSET_FLAGS( m_widget
, GTK_CAN_FOCUS
);
406 gtk_signal_connect( GTK_OBJECT(m_widget
), "delete_event",
407 GTK_SIGNAL_FUNC(gtk_frame_delete_callback
), (gpointer
)this );
409 // m_mainWidget holds the toolbar, the menubar and the client area
410 m_mainWidget
= gtk_pizza_new();
411 gtk_widget_show( m_mainWidget
);
412 GTK_WIDGET_UNSET_FLAGS( m_mainWidget
, GTK_CAN_FOCUS
);
413 gtk_container_add( GTK_CONTAINER(m_widget
), m_mainWidget
);
415 // for m_mainWidget themes
416 gtk_signal_connect( GTK_OBJECT(m_mainWidget
), "expose_event",
417 GTK_SIGNAL_FUNC(gtk_window_expose_callback
), (gpointer
)this );
418 gtk_signal_connect( GTK_OBJECT(m_mainWidget
), "draw",
419 GTK_SIGNAL_FUNC(gtk_window_draw_callback
), (gpointer
)this );
422 debug_focus_in( m_mainWidget
, wxT("wxTopLevelWindowGTK::m_mainWidget"), name
);
425 // m_wxwindow only represents the client area without toolbar and menubar
426 m_wxwindow
= gtk_pizza_new();
427 gtk_widget_show( m_wxwindow
);
428 gtk_container_add( GTK_CONTAINER(m_mainWidget
), m_wxwindow
);
431 debug_focus_in( m_wxwindow
, wxT("wxTopLevelWindowGTK::m_wxwindow"), name
);
434 // we donm't allow the frame to get the focus as otherwise
435 // the frame will grab it at arbitrary focus changes
436 GTK_WIDGET_UNSET_FLAGS( m_wxwindow
, GTK_CAN_FOCUS
);
438 if (m_parent
) m_parent
->AddChild( this );
440 // the user resized the frame by dragging etc.
441 gtk_signal_connect( GTK_OBJECT(m_widget
), "size_allocate",
442 GTK_SIGNAL_FUNC(gtk_frame_size_callback
), (gpointer
)this );
446 if ((m_x
!= -1) || (m_y
!= -1))
447 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
449 gtk_window_set_default_size( GTK_WINDOW(m_widget
), m_width
, m_height
);
451 // we cannot set MWM hints and icons before the widget has
452 // been realized, so we do this directly after realization
453 gtk_signal_connect( GTK_OBJECT(m_widget
), "realize",
454 GTK_SIGNAL_FUNC(gtk_frame_realized_callback
), (gpointer
) this );
456 // the only way to get the window size is to connect to this event
457 gtk_signal_connect( GTK_OBJECT(m_widget
), "configure_event",
458 GTK_SIGNAL_FUNC(gtk_frame_configure_callback
), (gpointer
)this );
460 // map and unmap for iconized state
461 gtk_signal_connect( GTK_OBJECT(m_widget
), "map_event",
462 GTK_SIGNAL_FUNC(gtk_frame_map_callback
), (gpointer
)this );
463 gtk_signal_connect( GTK_OBJECT(m_widget
), "unmap_event",
464 GTK_SIGNAL_FUNC(gtk_frame_unmap_callback
), (gpointer
)this );
466 // the only way to get the window size is to connect to this event
467 gtk_signal_connect( GTK_OBJECT(m_widget
), "configure_event",
468 GTK_SIGNAL_FUNC(gtk_frame_configure_callback
), (gpointer
)this );
470 // disable native tab traversal
471 gtk_signal_connect( GTK_OBJECT(m_widget
), "focus",
472 GTK_SIGNAL_FUNC(gtk_frame_focus_callback
), (gpointer
)this );
475 if ((m_miniEdge
> 0) || (style
& wxSIMPLE_BORDER
) || (style
& wxNO_BORDER
))
482 m_gdkDecor
= (long) GDK_DECOR_BORDER
;
483 m_gdkFunc
= (long) GDK_FUNC_MOVE
;
485 // All this is for Motif Window Manager "hints" and is supposed to be
486 // recognized by other WMs as well.
487 if ((style
& wxCAPTION
) != 0)
488 m_gdkDecor
|= GDK_DECOR_TITLE
;
489 if ((style
& wxSYSTEM_MENU
) != 0)
491 m_gdkFunc
|= GDK_FUNC_CLOSE
;
492 m_gdkDecor
|= GDK_DECOR_MENU
;
494 if ((style
& wxMINIMIZE_BOX
) != 0)
496 m_gdkFunc
|= GDK_FUNC_MINIMIZE
;
497 m_gdkDecor
|= GDK_DECOR_MINIMIZE
;
499 if ((style
& wxMAXIMIZE_BOX
) != 0)
501 m_gdkFunc
|= GDK_FUNC_MAXIMIZE
;
502 m_gdkDecor
|= GDK_DECOR_MAXIMIZE
;
504 if ((style
& wxRESIZE_BORDER
) != 0)
506 m_gdkFunc
|= GDK_FUNC_RESIZE
;
507 m_gdkDecor
|= GDK_DECOR_RESIZEH
;
514 wxTopLevelWindowGTK::~wxTopLevelWindowGTK()
516 m_isBeingDeleted
= TRUE
;
518 gtk_window_set_focus( GTK_WINDOW(m_widget
), NULL
);
520 wxTopLevelWindows
.DeleteObject( this );
522 if (wxTheApp
->GetTopWindow() == this)
523 wxTheApp
->SetTopWindow( (wxWindow
*) NULL
);
525 if ((wxTopLevelWindows
.Number() == 0) &&
526 (wxTheApp
->GetExitOnFrameDelete()))
528 wxTheApp
->ExitMainLoop();
532 bool wxTopLevelWindowGTK::ShowFullScreen(bool show
, long style
)
534 if (show
== m_fsIsShowing
) return FALSE
; // return what?
536 m_fsIsShowing
= show
;
540 m_fsSaveGdkFunc
= m_gdkFunc
;
541 m_fsSaveGdkDecor
= m_gdkDecor
;
542 m_fsSaveFlag
= style
;
543 GetPosition( &m_fsSaveFrame
.x
, &m_fsSaveFrame
.y
);
544 GetSize( &m_fsSaveFrame
.width
, &m_fsSaveFrame
.height
);
546 gtk_widget_hide( m_widget
);
547 gtk_widget_unrealize( m_widget
);
549 m_gdkDecor
= (long) GDK_DECOR_BORDER
;
550 m_gdkFunc
= (long) GDK_FUNC_MOVE
;
554 wxDisplaySize( &x
, &y
);
555 SetSize( 0, 0, x
, y
);
557 gtk_widget_realize( m_widget
);
558 gtk_widget_show( m_widget
);
562 gtk_widget_hide( m_widget
);
563 gtk_widget_unrealize( m_widget
);
565 m_gdkFunc
= m_fsSaveGdkFunc
;
566 m_gdkDecor
= m_fsSaveGdkDecor
;
568 SetSize( m_fsSaveFrame
.x
, m_fsSaveFrame
.y
, m_fsSaveFrame
.width
, m_fsSaveFrame
.height
);
570 gtk_widget_realize( m_widget
);
571 gtk_widget_show( m_widget
);
577 // ----------------------------------------------------------------------------
578 // overridden wxWindow methods
579 // ----------------------------------------------------------------------------
581 bool wxTopLevelWindowGTK::Show( bool show
)
583 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
585 if (show
&& !m_sizeSet
)
587 /* by calling GtkOnSize here, we don't have to call
588 either after showing the frame, which would entail
589 much ugly flicker or from within the size_allocate
590 handler, because GTK 1.1.X forbids that. */
592 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
595 return wxWindow::Show( show
);
598 void wxTopLevelWindowGTK::DoMoveWindow(int WXUNUSED(x
), int WXUNUSED(y
), int WXUNUSED(width
), int WXUNUSED(height
) )
600 wxFAIL_MSG( wxT("DoMoveWindow called for wxTopLevelWindowGTK") );
603 void wxTopLevelWindowGTK::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
605 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
607 // this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow
608 wxASSERT_MSG( (m_wxwindow
!= NULL
), wxT("invalid frame") );
618 int old_width
= m_width
;
619 int old_height
= m_height
;
621 if ((sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) == 0)
623 if (x
!= -1) m_x
= x
;
624 if (y
!= -1) m_y
= y
;
625 if (width
!= -1) m_width
= width
;
626 if (height
!= -1) m_height
= height
;
637 if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
639 if (width == -1) m_width = 80;
642 if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
644 if (height == -1) m_height = 26;
648 int minWidth
= GetMinWidth(),
649 minHeight
= GetMinHeight(),
650 maxWidth
= GetMaxWidth(),
651 maxHeight
= GetMaxHeight();
653 if ((minWidth
!= -1) && (m_width
< minWidth
)) m_width
= minWidth
;
654 if ((minHeight
!= -1) && (m_height
< minHeight
)) m_height
= minHeight
;
655 if ((maxWidth
!= -1) && (m_width
> maxWidth
)) m_width
= maxWidth
;
656 if ((maxHeight
!= -1) && (m_height
> maxHeight
)) m_height
= maxHeight
;
658 if ((m_x
!= -1) || (m_y
!= -1))
660 if ((m_x
!= old_x
) || (m_y
!= old_y
))
662 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
666 if ((m_width
!= old_width
) || (m_height
!= old_height
))
668 if (m_widget
->window
)
669 gdk_window_resize( m_widget
->window
, m_width
, m_height
);
671 gtk_window_set_default_size( GTK_WINDOW(m_widget
), m_width
, m_height
);
673 /* we set the size in GtkOnSize, i.e. mostly the actual resizing is
674 done either directly before the frame is shown or in idle time
675 so that different calls to SetSize() don't lead to flicker. */
682 void wxTopLevelWindowGTK::DoGetClientSize( int *width
, int *height
) const
684 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
686 wxWindow::DoGetClientSize( width
, height
);
690 *height
-= m_miniEdge
*2 + m_miniTitle
;
694 *width
-= m_miniEdge
*2;
698 void wxTopLevelWindowGTK::DoSetClientSize( int width
, int height
)
700 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
703 width
+ m_miniEdge
*2, height
+ m_miniEdge
*2 + m_miniTitle
, 0);
706 void wxTopLevelWindowGTK::GtkOnSize( int WXUNUSED(x
), int WXUNUSED(y
),
707 int width
, int height
)
709 // due to a bug in gtk, x,y are always 0
714 if (m_resizing
) return;
717 if ( m_wxwindow
== NULL
) return;
722 /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses
723 wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
724 set in wxFrame::Create so it is used to check what kind of frame we
725 have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
726 skip the part which handles m_frameMenuBar, m_frameToolBar and (most
727 importantly) m_mainWidget */
729 int minWidth
= GetMinWidth(),
730 minHeight
= GetMinHeight(),
731 maxWidth
= GetMaxWidth(),
732 maxHeight
= GetMaxHeight();
734 if ((minWidth
!= -1) && (m_width
< minWidth
)) m_width
= minWidth
;
735 if ((minHeight
!= -1) && (m_height
< minHeight
)) m_height
= minHeight
;
736 if ((maxWidth
!= -1) && (m_width
> maxWidth
)) m_width
= maxWidth
;
737 if ((maxHeight
!= -1) && (m_height
> maxHeight
)) m_height
= maxHeight
;
742 gint flag
= 0; // GDK_HINT_POS;
743 if ((minWidth
!= -1) || (minHeight
!= -1)) flag
|= GDK_HINT_MIN_SIZE
;
744 if ((maxWidth
!= -1) || (maxHeight
!= -1)) flag
|= GDK_HINT_MAX_SIZE
;
746 geom
.min_width
= minWidth
;
747 geom
.min_height
= minHeight
;
748 geom
.max_width
= maxWidth
;
749 geom
.max_height
= maxHeight
;
750 gtk_window_set_geometry_hints( GTK_WINDOW(m_widget
),
753 (GdkWindowHints
) flag
);
755 /* I revert back to wxGTK's original behaviour. m_mainWidget holds the
756 * menubar, the toolbar and the client area, which is represented by
758 * this hurts in the eye, but I don't want to call SetSize()
759 * because I don't want to call any non-native functions here. */
761 int client_x
= m_miniEdge
;
762 int client_y
= m_miniEdge
+ m_miniTitle
;
763 int client_w
= m_width
- 2*m_miniEdge
;
764 int client_h
= m_height
- 2*m_miniEdge
- m_miniTitle
;
765 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget
),
767 client_x
, client_y
, client_w
, client_h
);
771 // If there is no m_mainWidget between m_widget and m_wxwindow there
772 // is no need to set the size or position of m_wxwindow.
777 // send size event to frame
778 wxSizeEvent
event( wxSize(m_width
,m_height
), GetId() );
779 event
.SetEventObject( this );
780 GetEventHandler()->ProcessEvent( event
);
785 void wxTopLevelWindowGTK::OnInternalIdle()
787 if (!m_sizeSet
&& GTK_WIDGET_REALIZED(m_wxwindow
))
789 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
791 // we'll come back later
793 wxapp_install_idle_handler();
797 wxWindow::OnInternalIdle();
801 // ----------------------------------------------------------------------------
803 // ----------------------------------------------------------------------------
805 void wxTopLevelWindowGTK::SetTitle( const wxString
&title
)
807 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
810 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
813 void wxTopLevelWindowGTK::SetIcon( const wxIcon
&icon
)
815 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
817 wxTopLevelWindowBase::SetIcon(icon
);
822 if (!m_widget
->window
)
825 wxMask
*mask
= icon
.GetMask();
826 GdkBitmap
*bm
= (GdkBitmap
*) NULL
;
827 if (mask
) bm
= mask
->GetBitmap();
829 gdk_window_set_icon( m_widget
->window
, (GdkWindow
*) NULL
, icon
.GetPixmap(), bm
);
832 // ----------------------------------------------------------------------------
833 // frame state: maximized/iconized/normal
834 // ----------------------------------------------------------------------------
836 void wxTopLevelWindowGTK::Maximize(bool WXUNUSED(maximize
))
838 wxFAIL_MSG( _T("not implemented") );
841 bool wxTopLevelWindowGTK::IsMaximized() const
843 // wxFAIL_MSG( _T("not implemented") );
845 // This is an approximation
849 void wxTopLevelWindowGTK::Restore()
851 wxFAIL_MSG( _T("not implemented") );
854 void wxTopLevelWindowGTK::Iconize( bool iconize
)
858 GdkWindow
*window
= m_widget
->window
;
860 // you should do it later, for example from OnCreate() handler
861 wxCHECK_RET( window
, _T("frame not created yet - can't iconize") );
863 XIconifyWindow( GDK_WINDOW_XDISPLAY( window
),
864 GDK_WINDOW_XWINDOW( window
),
865 DefaultScreen( GDK_DISPLAY() ) );
869 bool wxTopLevelWindowGTK::IsIconized() const
874 void wxTopLevelWindowGTK::SetIconizeState(bool iconize
)
876 if ( iconize
!= m_isIconized
)
878 m_isIconized
= iconize
;
879 (void)SendIconizeEvent(iconize
);