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 #if (GTK_MINOR_VERSION > 0)
145 gtk_frame_configure_callback( GtkWidget
*WXUNUSED(widget
), GdkEventConfigure
*WXUNUSED(event
), wxTopLevelWindowGTK
*win
)
147 gtk_frame_configure_callback( GtkWidget
*WXUNUSED(widget
), GdkEventConfigure
*event
, wxTopLevelWindowGTK
*win
)
151 wxapp_install_idle_handler();
156 #if (GTK_MINOR_VERSION > 0)
159 gdk_window_get_root_origin( win
->m_widget
->window
, &x
, &y
);
167 wxMoveEvent
mevent( wxPoint(win
->m_x
,win
->m_y
), win
->GetId() );
168 mevent
.SetEventObject( win
);
169 win
->GetEventHandler()->ProcessEvent( mevent
);
174 //-----------------------------------------------------------------------------
175 // "realize" from m_widget
176 //-----------------------------------------------------------------------------
178 /* we cannot MWM hints and icons before the widget has been realized,
179 so we do this directly after realization */
182 gtk_frame_realized_callback( GtkWidget
* WXUNUSED(widget
), wxTopLevelWindowGTK
*win
)
185 wxapp_install_idle_handler();
187 /* All this is for Motif Window Manager "hints" and is supposed to be
188 recognized by other WM as well. Not tested. */
189 gdk_window_set_decorations(win
->m_widget
->window
,
190 (GdkWMDecoration
)win
->m_gdkDecor
);
191 gdk_window_set_functions(win
->m_widget
->window
,
192 (GdkWMFunction
)win
->m_gdkFunc
);
194 /* GTK's shrinking/growing policy */
195 if ((win
->m_gdkFunc
& GDK_FUNC_RESIZE
) == 0)
196 gtk_window_set_policy(GTK_WINDOW(win
->m_widget
), 0, 0, 1);
198 gtk_window_set_policy(GTK_WINDOW(win
->m_widget
), 1, 1, 1);
201 wxIcon iconOld
= win
->GetIcon();
202 if ( iconOld
!= wxNullIcon
)
204 wxIcon
icon( iconOld
);
205 win
->SetIcon( wxNullIcon
);
206 win
->SetIcon( icon
);
209 /* we set the focus to the child that accepts the focus. this
210 doesn't really have to be done in "realize" but why not? */
211 wxWindowList::Node
*node
= win
->GetChildren().GetFirst();
214 wxWindow
*child
= node
->GetData();
215 if (child
->AcceptsFocus())
221 node
= node
->GetNext();
225 //-----------------------------------------------------------------------------
226 // "map_event" from m_widget
227 //-----------------------------------------------------------------------------
230 gtk_frame_map_callback( GtkWidget
* WXUNUSED(widget
),
231 GdkEvent
* WXUNUSED(event
),
232 wxTopLevelWindow
*win
)
234 win
->SetIconizeState(FALSE
);
237 //-----------------------------------------------------------------------------
238 // "unmap_event" from m_widget
239 //-----------------------------------------------------------------------------
242 gtk_frame_unmap_callback( GtkWidget
* WXUNUSED(widget
),
243 GdkEvent
* WXUNUSED(event
),
244 wxTopLevelWindow
*win
)
246 win
->SetIconizeState(TRUE
);
249 //-----------------------------------------------------------------------------
250 // "expose_event" of m_client
251 //-----------------------------------------------------------------------------
253 static int gtk_window_expose_callback( GtkWidget
*widget
, GdkEventExpose
*gdk_event
, wxWindow
*win
)
255 GtkPizza
*pizza
= GTK_PIZZA(widget
);
257 gtk_paint_flat_box (win
->m_widget
->style
, pizza
->bin_window
, GTK_STATE_NORMAL
,
258 GTK_SHADOW_NONE
, &gdk_event
->area
, win
->m_widget
, "base", 0, 0, -1, -1);
263 //-----------------------------------------------------------------------------
264 // "draw" of m_client
265 //-----------------------------------------------------------------------------
268 static void gtk_window_draw_callback( GtkWidget
*widget
, GdkRectangle
*rect
, wxWindow
*win
)
270 GtkPizza
*pizza
= GTK_PIZZA(widget
);
272 gtk_paint_flat_box (win
->m_widget
->style
, pizza
->bin_window
, GTK_STATE_NORMAL
,
273 GTK_SHADOW_NONE
, rect
, win
->m_widget
, "base", 0, 0, -1, -1);
276 // ----------------------------------------------------------------------------
277 // wxTopLevelWindowGTK itself
278 // ----------------------------------------------------------------------------
280 //-----------------------------------------------------------------------------
281 // InsertChild for wxTopLevelWindowGTK
282 //-----------------------------------------------------------------------------
284 /* Callback for wxTopLevelWindowGTK. This very strange beast has to be used because
285 * C++ has no virtual methods in a constructor. We have to emulate a
286 * virtual function here as wxWindows requires different ways to insert
287 * a child in container classes. */
289 static void wxInsertChildInTopLevelWindow( wxTopLevelWindowGTK
* parent
, wxWindow
* child
)
291 wxASSERT( GTK_IS_WIDGET(child
->m_widget
) );
293 if (!parent
->m_insertInClientArea
)
295 /* these are outside the client area */
296 wxTopLevelWindowGTK
* frame
= (wxTopLevelWindowGTK
*) parent
;
297 gtk_pizza_put( GTK_PIZZA(frame
->m_mainWidget
),
298 GTK_WIDGET(child
->m_widget
),
306 /* these are inside the client area */
307 gtk_pizza_put( GTK_PIZZA(parent
->m_wxwindow
),
308 GTK_WIDGET(child
->m_widget
),
315 /* resize on OnInternalIdle */
316 parent
->GtkUpdateSize();
319 // ----------------------------------------------------------------------------
320 // wxTopLevelWindowGTK creation
321 // ----------------------------------------------------------------------------
323 void wxTopLevelWindowGTK::Init()
328 m_mainWidget
= (GtkWidget
*) NULL
;
329 m_insertInClientArea
= TRUE
;
331 m_isIconized
= FALSE
;
332 m_fsIsShowing
= FALSE
;
333 m_themeEnabled
= TRUE
;
334 m_gdkDecor
= m_gdkFunc
= 0;
337 bool wxTopLevelWindowGTK::Create( wxWindow
*parent
,
339 const wxString
& title
,
341 const wxSize
& sizeOrig
,
343 const wxString
&name
)
345 // always create a frame of some reasonable, even if arbitrary, size (at
346 // least for MSW compatibility)
347 wxSize size
= sizeOrig
;
348 if ( size
.x
== -1 || size
.y
== -1 )
350 wxSize sizeDpy
= wxGetDisplaySize();
352 size
.x
= sizeDpy
.x
/ 3;
354 size
.y
= sizeDpy
.y
/ 5;
357 wxTopLevelWindows
.Append( this );
359 m_needParent
= FALSE
;
361 if (!PreCreation( parent
, pos
, size
) ||
362 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
364 wxFAIL_MSG( wxT("wxTopLevelWindowGTK creation failed") );
370 m_insertCallback
= (wxInsertChildFunction
) wxInsertChildInTopLevelWindow
;
372 GtkWindowType win_type
= GTK_WINDOW_TOPLEVEL
;
374 if (style
& wxFRAME_TOOL_WINDOW
)
375 win_type
= GTK_WINDOW_POPUP
;
377 if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
)
378 win_type
= GTK_WINDOW_DIALOG
;
380 m_widget
= gtk_window_new( win_type
);
382 if ((m_parent
) && (HasFlag(wxFRAME_FLOAT_ON_PARENT
)) && (GTK_IS_WINDOW(m_parent
->m_widget
)))
383 gtk_window_set_transient_for( GTK_WINDOW(m_widget
), GTK_WINDOW(m_parent
->m_widget
) );
386 gtk_window_set_wmclass( GTK_WINDOW(m_widget
), name
.mb_str(), name
.mb_str() );
389 debug_focus_in( m_widget
, wxT("wxTopLevelWindowGTK::m_widget"), name
);
392 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
393 GTK_WIDGET_UNSET_FLAGS( m_widget
, GTK_CAN_FOCUS
);
395 gtk_signal_connect( GTK_OBJECT(m_widget
), "delete_event",
396 GTK_SIGNAL_FUNC(gtk_frame_delete_callback
), (gpointer
)this );
398 /* m_mainWidget holds the toolbar, the menubar and the client area */
399 m_mainWidget
= gtk_pizza_new();
400 gtk_widget_show( m_mainWidget
);
401 GTK_WIDGET_UNSET_FLAGS( m_mainWidget
, GTK_CAN_FOCUS
);
402 gtk_container_add( GTK_CONTAINER(m_widget
), m_mainWidget
);
404 /* for m_mainWidget themes */
405 gtk_signal_connect( GTK_OBJECT(m_mainWidget
), "expose_event",
406 GTK_SIGNAL_FUNC(gtk_window_expose_callback
), (gpointer
)this );
407 gtk_signal_connect( GTK_OBJECT(m_mainWidget
), "draw",
408 GTK_SIGNAL_FUNC(gtk_window_draw_callback
), (gpointer
)this );
411 debug_focus_in( m_mainWidget
, wxT("wxTopLevelWindowGTK::m_mainWidget"), name
);
414 /* m_wxwindow only represents the client area without toolbar and menubar */
415 m_wxwindow
= gtk_pizza_new();
416 gtk_widget_show( m_wxwindow
);
417 gtk_container_add( GTK_CONTAINER(m_mainWidget
), m_wxwindow
);
420 debug_focus_in( m_wxwindow
, wxT("wxTopLevelWindowGTK::m_wxwindow"), name
);
423 /* we donm't allow the frame to get the focus as otherwise
424 the frame will grab it at arbitrary focus changes. */
425 GTK_WIDGET_UNSET_FLAGS( m_wxwindow
, GTK_CAN_FOCUS
);
427 if (m_parent
) m_parent
->AddChild( this );
429 /* the user resized the frame by dragging etc. */
430 gtk_signal_connect( GTK_OBJECT(m_widget
), "size_allocate",
431 GTK_SIGNAL_FUNC(gtk_frame_size_callback
), (gpointer
)this );
435 if ((m_x
!= -1) || (m_y
!= -1))
436 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
437 gtk_widget_set_usize( m_widget
, m_width
, m_height
);
439 /* we cannot set MWM hints and icons before the widget has
440 been realized, so we do this directly after realization */
441 gtk_signal_connect( GTK_OBJECT(m_widget
), "realize",
442 GTK_SIGNAL_FUNC(gtk_frame_realized_callback
), (gpointer
) this );
444 /* the only way to get the window size is to connect to this event */
445 gtk_signal_connect( GTK_OBJECT(m_widget
), "configure_event",
446 GTK_SIGNAL_FUNC(gtk_frame_configure_callback
), (gpointer
)this );
448 /* map and unmap for iconized state */
449 gtk_signal_connect( GTK_OBJECT(m_widget
), "map_event",
450 GTK_SIGNAL_FUNC(gtk_frame_map_callback
), (gpointer
)this );
451 gtk_signal_connect( GTK_OBJECT(m_widget
), "unmap_event",
452 GTK_SIGNAL_FUNC(gtk_frame_unmap_callback
), (gpointer
)this );
454 /* the only way to get the window size is to connect to this event */
455 gtk_signal_connect( GTK_OBJECT(m_widget
), "configure_event",
456 GTK_SIGNAL_FUNC(gtk_frame_configure_callback
), (gpointer
)this );
458 /* disable native tab traversal */
459 gtk_signal_connect( GTK_OBJECT(m_widget
), "focus",
460 GTK_SIGNAL_FUNC(gtk_frame_focus_callback
), (gpointer
)this );
464 if ((m_miniEdge
> 0) || (style
& wxSIMPLE_BORDER
) || (style
& wxNO_BORDER
))
471 m_gdkDecor
= (long) GDK_DECOR_BORDER
;
472 m_gdkFunc
= (long) GDK_FUNC_MOVE
;
474 // All this is for Motif Window Manager "hints" and is supposed to be
475 // recognized by other WM as well. Not tested.
476 if ((style
& wxCAPTION
) != 0)
477 m_gdkDecor
|= GDK_DECOR_TITLE
;
478 if ((style
& wxSYSTEM_MENU
) != 0)
480 m_gdkFunc
|= GDK_FUNC_CLOSE
;
481 m_gdkDecor
|= GDK_DECOR_MENU
;
483 if ((style
& wxMINIMIZE_BOX
) != 0)
485 m_gdkFunc
|= GDK_FUNC_MINIMIZE
;
486 m_gdkDecor
|= GDK_DECOR_MINIMIZE
;
488 if ((style
& wxMAXIMIZE_BOX
) != 0)
490 m_gdkFunc
|= GDK_FUNC_MAXIMIZE
;
491 m_gdkDecor
|= GDK_DECOR_MAXIMIZE
;
493 if ((style
& wxRESIZE_BORDER
) != 0)
495 m_gdkFunc
|= GDK_FUNC_RESIZE
;
496 m_gdkDecor
|= GDK_DECOR_RESIZEH
;
503 wxTopLevelWindowGTK::~wxTopLevelWindowGTK()
505 m_isBeingDeleted
= TRUE
;
507 wxTopLevelWindows
.DeleteObject( this );
509 if (wxTheApp
->GetTopWindow() == this)
510 wxTheApp
->SetTopWindow( (wxWindow
*) NULL
);
512 if ((wxTopLevelWindows
.Number() == 0) &&
513 (wxTheApp
->GetExitOnFrameDelete()))
515 wxTheApp
->ExitMainLoop();
519 bool wxTopLevelWindowGTK::ShowFullScreen(bool show
, long style
)
521 if (show
== m_fsIsShowing
) return FALSE
; // return what?
523 m_fsIsShowing
= show
;
527 m_fsSaveGdkFunc
= m_gdkFunc
;
528 m_fsSaveGdkDecor
= m_gdkDecor
;
529 m_fsSaveFlag
= style
;
530 GetPosition( &m_fsSaveFrame
.x
, &m_fsSaveFrame
.y
);
531 GetSize( &m_fsSaveFrame
.width
, &m_fsSaveFrame
.height
);
533 gtk_widget_hide( m_widget
);
534 gtk_widget_unrealize( m_widget
);
536 m_gdkDecor
= (long) GDK_DECOR_BORDER
;
537 m_gdkFunc
= (long) GDK_FUNC_MOVE
;
541 wxDisplaySize( &x
, &y
);
542 SetSize( 0, 0, x
, y
);
544 gtk_widget_realize( m_widget
);
545 gtk_widget_show( m_widget
);
549 gtk_widget_hide( m_widget
);
550 gtk_widget_unrealize( m_widget
);
552 m_gdkFunc
= m_fsSaveGdkFunc
;
553 m_gdkDecor
= m_fsSaveGdkDecor
;
555 SetSize( m_fsSaveFrame
.x
, m_fsSaveFrame
.y
, m_fsSaveFrame
.width
, m_fsSaveFrame
.height
);
557 gtk_widget_realize( m_widget
);
558 gtk_widget_show( m_widget
);
564 // ----------------------------------------------------------------------------
565 // overridden wxWindow methods
566 // ----------------------------------------------------------------------------
568 bool wxTopLevelWindowGTK::Show( bool show
)
570 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
572 if (show
&& !m_sizeSet
)
574 /* by calling GtkOnSize here, we don't have to call
575 either after showing the frame, which would entail
576 much ugly flicker or from within the size_allocate
577 handler, because GTK 1.1.X forbids that. */
579 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
582 return wxWindow::Show( show
);
585 void wxTopLevelWindowGTK::DoMoveWindow(int WXUNUSED(x
), int WXUNUSED(y
), int WXUNUSED(width
), int WXUNUSED(height
) )
587 wxFAIL_MSG( wxT("DoMoveWindow called for wxTopLevelWindowGTK") );
590 void wxTopLevelWindowGTK::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
592 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
594 /* this shouldn't happen: wxFrameGTK, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
595 wxASSERT_MSG( (m_wxwindow
!= NULL
), wxT("invalid frame") );
597 /* avoid recursions */
605 int old_width
= m_width
;
606 int old_height
= m_height
;
608 if ((sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) == 0)
610 if (x
!= -1) m_x
= x
;
611 if (y
!= -1) m_y
= y
;
612 if (width
!= -1) m_width
= width
;
613 if (height
!= -1) m_height
= height
;
624 if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
626 if (width == -1) m_width = 80;
629 if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
631 if (height == -1) m_height = 26;
635 if ((m_minWidth
!= -1) && (m_width
< m_minWidth
)) m_width
= m_minWidth
;
636 if ((m_minHeight
!= -1) && (m_height
< m_minHeight
)) m_height
= m_minHeight
;
637 if ((m_maxWidth
!= -1) && (m_width
> m_maxWidth
)) m_width
= m_maxWidth
;
638 if ((m_maxHeight
!= -1) && (m_height
> m_maxHeight
)) m_height
= m_maxHeight
;
640 if ((m_x
!= -1) || (m_y
!= -1))
642 if ((m_x
!= old_x
) || (m_y
!= old_y
))
644 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
648 if ((m_width
!= old_width
) || (m_height
!= old_height
))
650 gtk_widget_set_usize( m_widget
, m_width
, m_height
);
652 /* we set the size in GtkOnSize, i.e. mostly the actual resizing is
653 done either directly before the frame is shown or in idle time
654 so that different calls to SetSize() don't lead to flicker. */
661 void wxTopLevelWindowGTK::DoGetClientSize( int *width
, int *height
) const
663 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
665 wxWindow::DoGetClientSize( width
, height
);
669 *height
-= m_miniEdge
*2 + m_miniTitle
;
673 *width
-= m_miniEdge
*2;
677 void wxTopLevelWindowGTK::DoSetClientSize( int width
, int height
)
679 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
682 width
+ m_miniEdge
*2, height
+ m_miniEdge
*2 + m_miniTitle
, 0);
685 void wxTopLevelWindowGTK::GtkOnSize( int WXUNUSED(x
), int WXUNUSED(y
),
686 int width
, int height
)
688 // due to a bug in gtk, x,y are always 0
692 /* avoid recursions */
693 if (m_resizing
) return;
696 if ( m_wxwindow
== NULL
) return;
701 /* wxMDIChildFrame derives from wxFrameGTK but it _is_ a wxWindow as it uses
702 wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
703 set in wxFrameGTK::Create so it is used to check what kind of frame we
704 have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
705 skip the part which handles m_frameMenuBar, m_frameToolBar and (most
706 importantly) m_mainWidget */
708 if ((m_minWidth
!= -1) && (m_width
< m_minWidth
)) m_width
= m_minWidth
;
709 if ((m_minHeight
!= -1) && (m_height
< m_minHeight
)) m_height
= m_minHeight
;
710 if ((m_maxWidth
!= -1) && (m_width
> m_maxWidth
)) m_width
= m_maxWidth
;
711 if ((m_maxHeight
!= -1) && (m_height
> m_maxHeight
)) m_height
= m_maxHeight
;
716 gint flag
= 0; // GDK_HINT_POS;
717 if ((m_minWidth
!= -1) || (m_minHeight
!= -1)) flag
|= GDK_HINT_MIN_SIZE
;
718 if ((m_maxWidth
!= -1) || (m_maxHeight
!= -1)) flag
|= GDK_HINT_MAX_SIZE
;
720 geom
.min_width
= m_minWidth
;
721 geom
.min_height
= m_minHeight
;
722 geom
.max_width
= m_maxWidth
;
723 geom
.max_height
= m_maxHeight
;
724 gtk_window_set_geometry_hints( GTK_WINDOW(m_widget
),
727 (GdkWindowHints
) flag
);
729 /* I revert back to wxGTK's original behaviour. m_mainWidget holds the
730 * menubar, the toolbar and the client area, which is represented by
732 * this hurts in the eye, but I don't want to call SetSize()
733 * because I don't want to call any non-native functions here. */
735 int client_x
= m_miniEdge
;
736 int client_y
= m_miniEdge
+ m_miniTitle
;
737 int client_w
= m_width
- 2*m_miniEdge
;
738 int client_h
= m_height
- 2*m_miniEdge
- m_miniTitle
;
739 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget
),
741 client_x
, client_y
, client_w
, client_h
);
745 /* if there is no m_mainWidget between m_widget and m_wxwindow there
746 is no need to set the size or position of m_wxwindow. */
751 // send size event to frame
752 wxSizeEvent
event( wxSize(m_width
,m_height
), GetId() );
753 event
.SetEventObject( this );
754 GetEventHandler()->ProcessEvent( event
);
759 void wxTopLevelWindowGTK::OnInternalIdle()
761 if (!m_sizeSet
&& GTK_WIDGET_REALIZED(m_wxwindow
))
763 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
765 // we'll come back later
767 wxapp_install_idle_handler();
771 wxWindow::OnInternalIdle();
775 // ----------------------------------------------------------------------------
777 // ----------------------------------------------------------------------------
779 void wxTopLevelWindowGTK::SetTitle( const wxString
&title
)
781 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
784 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
787 void wxTopLevelWindowGTK::SetIcon( const wxIcon
&icon
)
789 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
791 wxTopLevelWindowBase::SetIcon(icon
);
796 if (!m_widget
->window
)
799 wxMask
*mask
= icon
.GetMask();
800 GdkBitmap
*bm
= (GdkBitmap
*) NULL
;
801 if (mask
) bm
= mask
->GetBitmap();
803 gdk_window_set_icon( m_widget
->window
, (GdkWindow
*) NULL
, icon
.GetPixmap(), bm
);
806 // ----------------------------------------------------------------------------
807 // frame state: maximized/iconized/normal
808 // ----------------------------------------------------------------------------
810 void wxTopLevelWindowGTK::Maximize(bool WXUNUSED(maximize
))
812 wxFAIL_MSG( _T("not implemented") );
815 bool wxTopLevelWindowGTK::IsMaximized() const
817 // wxFAIL_MSG( _T("not implemented") );
819 // This is an approximation
823 void wxTopLevelWindowGTK::Restore()
825 wxFAIL_MSG( _T("not implemented") );
828 void wxTopLevelWindowGTK::Iconize( bool iconize
)
832 GdkWindow
*window
= m_widget
->window
;
834 // you should do it later, for example from OnCreate() handler
835 wxCHECK_RET( window
, _T("frame not created yet - can't iconize") );
837 XIconifyWindow( GDK_WINDOW_XDISPLAY( window
),
838 GDK_WINDOW_XWINDOW( window
),
839 DefaultScreen( GDK_DISPLAY() ) );
843 bool wxTopLevelWindowGTK::IsIconized() const
848 void wxTopLevelWindowGTK::SetIconizeState(bool iconize
)
850 if ( iconize
!= m_isIconized
)
852 m_isIconized
= iconize
;
853 (void)SendIconizeEvent(iconize
);