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();
49 extern int g_openDialogs
;
51 // ----------------------------------------------------------------------------
53 // ----------------------------------------------------------------------------
55 // ----------------------------------------------------------------------------
57 // ----------------------------------------------------------------------------
59 extern wxList wxPendingDelete
;
61 // ----------------------------------------------------------------------------
63 // ----------------------------------------------------------------------------
67 extern void debug_focus_in( GtkWidget
* widget
, const wxChar
* name
, const wxChar
*window
);
71 // ============================================================================
73 // ============================================================================
75 // ----------------------------------------------------------------------------
77 // ----------------------------------------------------------------------------
79 //-----------------------------------------------------------------------------
80 // "focus" from m_window
81 //-----------------------------------------------------------------------------
83 static gint
gtk_frame_focus_callback( GtkWidget
*widget
, GtkDirectionType
WXUNUSED(d
), wxWindow
*WXUNUSED(win
) )
86 wxapp_install_idle_handler();
88 // This disables GTK's tab traversal
89 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "focus" );
93 //-----------------------------------------------------------------------------
95 //-----------------------------------------------------------------------------
97 static void gtk_frame_size_callback( GtkWidget
*WXUNUSED(widget
), GtkAllocation
* alloc
, wxTopLevelWindowGTK
*win
)
100 wxapp_install_idle_handler();
105 if ((win
->m_width
!= alloc
->width
) || (win
->m_height
!= alloc
->height
))
108 wxPrintf( "OnSize from " );
109 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
110 wxPrintf( win->GetClassInfo()->GetClassName() );
111 wxPrintf( " %d %d %d %d\n", (int)alloc->x,
114 (int)alloc->height );
117 win
->m_width
= alloc
->width
;
118 win
->m_height
= alloc
->height
;
119 win
->m_queuedFullRedraw
= TRUE
;
120 win
->GtkUpdateSize();
124 //-----------------------------------------------------------------------------
126 //-----------------------------------------------------------------------------
128 static gint
gtk_frame_delete_callback( GtkWidget
*WXUNUSED(widget
), GdkEvent
*WXUNUSED(event
), wxTopLevelWindowGTK
*win
)
131 wxapp_install_idle_handler();
133 if (win
->IsEnabled() &&
134 (g_openDialogs
== 0 || (win
->GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
)))
141 //-----------------------------------------------------------------------------
143 //-----------------------------------------------------------------------------
146 gtk_frame_configure_callback( GtkWidget
*WXUNUSED(widget
), GdkEventConfigure
*WXUNUSED(event
), wxTopLevelWindowGTK
*win
)
149 wxapp_install_idle_handler();
151 if (!win
->m_hasVMT
|| !win
->IsShown())
156 gdk_window_get_root_origin( win
->m_widget
->window
, &x
, &y
);
160 wxMoveEvent
mevent( wxPoint(win
->m_x
,win
->m_y
), win
->GetId() );
161 mevent
.SetEventObject( win
);
162 win
->GetEventHandler()->ProcessEvent( mevent
);
167 //-----------------------------------------------------------------------------
168 // "realize" from m_widget
169 //-----------------------------------------------------------------------------
171 // we cannot MWM hints and icons before the widget has been realized,
172 // so we do this directly after realization
175 gtk_frame_realized_callback( GtkWidget
* WXUNUSED(widget
), wxTopLevelWindowGTK
*win
)
178 wxapp_install_idle_handler();
180 // All this is for Motif Window Manager "hints" and is supposed to be
181 // recognized by other WM as well. Not tested.
182 gdk_window_set_decorations(win
->m_widget
->window
,
183 (GdkWMDecoration
)win
->m_gdkDecor
);
184 gdk_window_set_functions(win
->m_widget
->window
,
185 (GdkWMFunction
)win
->m_gdkFunc
);
187 // GTK's shrinking/growing policy
188 if ((win
->m_gdkFunc
& GDK_FUNC_RESIZE
) == 0)
189 gtk_window_set_policy(GTK_WINDOW(win
->m_widget
), 0, 0, 1);
191 gtk_window_set_policy(GTK_WINDOW(win
->m_widget
), 1, 1, 1);
194 wxIcon iconOld
= win
->GetIcon();
195 if ( iconOld
!= wxNullIcon
)
197 wxIcon
icon( iconOld
);
198 win
->SetIcon( wxNullIcon
);
199 win
->SetIcon( icon
);
202 // we set the focus to the child that accepts the focus. this
203 // doesn't really have to be done in "realize" but why not?
204 wxWindowList::Node
*node
= win
->GetChildren().GetFirst();
207 wxWindow
*child
= node
->GetData();
208 if (child
->AcceptsFocus())
214 node
= node
->GetNext();
218 //-----------------------------------------------------------------------------
219 // "map_event" from m_widget
220 //-----------------------------------------------------------------------------
223 gtk_frame_map_callback( GtkWidget
* WXUNUSED(widget
),
224 GdkEvent
* WXUNUSED(event
),
225 wxTopLevelWindow
*win
)
227 win
->SetIconizeState(FALSE
);
230 //-----------------------------------------------------------------------------
231 // "unmap_event" from m_widget
232 //-----------------------------------------------------------------------------
235 gtk_frame_unmap_callback( GtkWidget
* WXUNUSED(widget
),
236 GdkEvent
* WXUNUSED(event
),
237 wxTopLevelWindow
*win
)
239 win
->SetIconizeState(TRUE
);
242 //-----------------------------------------------------------------------------
243 // "expose_event" of m_client
244 //-----------------------------------------------------------------------------
246 static int gtk_window_expose_callback( GtkWidget
*widget
, GdkEventExpose
*gdk_event
, wxWindow
*win
)
248 GtkPizza
*pizza
= GTK_PIZZA(widget
);
250 gtk_paint_flat_box (win
->m_widget
->style
,
251 pizza
->bin_window
, GTK_STATE_NORMAL
,
261 //-----------------------------------------------------------------------------
262 // "draw" of m_client
263 //-----------------------------------------------------------------------------
266 static void gtk_window_draw_callback( GtkWidget
*widget
, GdkRectangle
*rect
, wxWindow
*win
)
268 GtkPizza
*pizza
= GTK_PIZZA(widget
);
270 gtk_paint_flat_box (win
->m_widget
->style
,
271 pizza
->bin_window
, GTK_STATE_NORMAL
,
279 // ----------------------------------------------------------------------------
280 // wxTopLevelWindowGTK itself
281 // ----------------------------------------------------------------------------
283 //-----------------------------------------------------------------------------
284 // InsertChild for wxTopLevelWindowGTK
285 //-----------------------------------------------------------------------------
287 /* Callback for wxTopLevelWindowGTK. This very strange beast has to be used because
288 * C++ has no virtual methods in a constructor. We have to emulate a
289 * virtual function here as wxWindows requires different ways to insert
290 * a child in container classes. */
292 static void wxInsertChildInTopLevelWindow( wxTopLevelWindowGTK
* parent
, wxWindow
* child
)
294 wxASSERT( GTK_IS_WIDGET(child
->m_widget
) );
296 if (!parent
->m_insertInClientArea
)
298 // these are outside the client area
299 wxTopLevelWindowGTK
* frame
= (wxTopLevelWindowGTK
*) parent
;
300 gtk_pizza_put( GTK_PIZZA(frame
->m_mainWidget
),
301 GTK_WIDGET(child
->m_widget
),
309 // these are inside the client area
310 gtk_pizza_put( GTK_PIZZA(parent
->m_wxwindow
),
311 GTK_WIDGET(child
->m_widget
),
318 // resize on OnInternalIdle
319 parent
->GtkUpdateSize();
322 // ----------------------------------------------------------------------------
323 // wxTopLevelWindowGTK creation
324 // ----------------------------------------------------------------------------
326 void wxTopLevelWindowGTK::Init()
331 m_mainWidget
= (GtkWidget
*) NULL
;
332 m_insertInClientArea
= TRUE
;
334 m_isIconized
= FALSE
;
335 m_fsIsShowing
= FALSE
;
336 m_themeEnabled
= TRUE
;
337 m_gdkDecor
= m_gdkFunc
= 0;
340 bool wxTopLevelWindowGTK::Create( wxWindow
*parent
,
342 const wxString
& title
,
344 const wxSize
& sizeOrig
,
346 const wxString
&name
)
348 // always create a frame of some reasonable, even if arbitrary, size (at
349 // least for MSW compatibility)
350 wxSize size
= sizeOrig
;
351 if ( size
.x
== -1 || size
.y
== -1 )
353 wxSize sizeDpy
= wxGetDisplaySize();
355 size
.x
= sizeDpy
.x
/ 3;
357 size
.y
= sizeDpy
.y
/ 5;
360 wxTopLevelWindows
.Append( this );
362 m_needParent
= FALSE
;
364 if (!PreCreation( parent
, pos
, size
) ||
365 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
367 wxFAIL_MSG( wxT("wxTopLevelWindowGTK creation failed") );
373 m_insertCallback
= (wxInsertChildFunction
) wxInsertChildInTopLevelWindow
;
375 GtkWindowType win_type
= GTK_WINDOW_TOPLEVEL
;
377 if (style
& wxFRAME_TOOL_WINDOW
)
378 win_type
= GTK_WINDOW_POPUP
;
380 if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
)
382 // there is no more GTK_WINDOW_DIALOG in 2.0
384 win_type
= GTK_WINDOW_TOPLEVEL
;
386 win_type
= GTK_WINDOW_DIALOG
;
390 m_widget
= gtk_window_new( win_type
);
392 if (m_parent
&& (GTK_IS_WINDOW(m_parent
->m_widget
)) &&
393 (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG
))
395 gtk_window_set_transient_for( GTK_WINDOW(m_widget
), GTK_WINDOW(m_parent
->m_widget
) );
399 gtk_window_set_wmclass( GTK_WINDOW(m_widget
), name
.mb_str(), name
.mb_str() );
402 debug_focus_in( m_widget
, wxT("wxTopLevelWindowGTK::m_widget"), name
);
405 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
406 GTK_WIDGET_UNSET_FLAGS( m_widget
, GTK_CAN_FOCUS
);
408 gtk_signal_connect( GTK_OBJECT(m_widget
), "delete_event",
409 GTK_SIGNAL_FUNC(gtk_frame_delete_callback
), (gpointer
)this );
411 // m_mainWidget holds the toolbar, the menubar and the client area
412 m_mainWidget
= gtk_pizza_new();
413 gtk_widget_show( m_mainWidget
);
414 GTK_WIDGET_UNSET_FLAGS( m_mainWidget
, GTK_CAN_FOCUS
);
415 gtk_container_add( GTK_CONTAINER(m_widget
), m_mainWidget
);
417 // for m_mainWidget themes
418 gtk_signal_connect( GTK_OBJECT(m_mainWidget
), "expose_event",
419 GTK_SIGNAL_FUNC(gtk_window_expose_callback
), (gpointer
)this );
420 gtk_signal_connect( GTK_OBJECT(m_mainWidget
), "draw",
421 GTK_SIGNAL_FUNC(gtk_window_draw_callback
), (gpointer
)this );
424 debug_focus_in( m_mainWidget
, wxT("wxTopLevelWindowGTK::m_mainWidget"), name
);
427 // m_wxwindow only represents the client area without toolbar and menubar
428 m_wxwindow
= gtk_pizza_new();
429 gtk_widget_show( m_wxwindow
);
430 gtk_container_add( GTK_CONTAINER(m_mainWidget
), m_wxwindow
);
433 debug_focus_in( m_wxwindow
, wxT("wxTopLevelWindowGTK::m_wxwindow"), name
);
436 // we donm't allow the frame to get the focus as otherwise
437 // the frame will grab it at arbitrary focus changes
438 GTK_WIDGET_UNSET_FLAGS( m_wxwindow
, GTK_CAN_FOCUS
);
440 if (m_parent
) m_parent
->AddChild( this );
442 // the user resized the frame by dragging etc.
443 gtk_signal_connect( GTK_OBJECT(m_widget
), "size_allocate",
444 GTK_SIGNAL_FUNC(gtk_frame_size_callback
), (gpointer
)this );
448 if ((m_x
!= -1) || (m_y
!= -1))
449 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
451 gtk_window_set_default_size( GTK_WINDOW(m_widget
), m_width
, m_height
);
453 // we cannot set MWM hints and icons before the widget has
454 // been realized, so we do this directly after realization
455 gtk_signal_connect( GTK_OBJECT(m_widget
), "realize",
456 GTK_SIGNAL_FUNC(gtk_frame_realized_callback
), (gpointer
) this );
458 // the only way to get the window size is to connect to this event
459 gtk_signal_connect( GTK_OBJECT(m_widget
), "configure_event",
460 GTK_SIGNAL_FUNC(gtk_frame_configure_callback
), (gpointer
)this );
462 // map and unmap for iconized state
463 gtk_signal_connect( GTK_OBJECT(m_widget
), "map_event",
464 GTK_SIGNAL_FUNC(gtk_frame_map_callback
), (gpointer
)this );
465 gtk_signal_connect( GTK_OBJECT(m_widget
), "unmap_event",
466 GTK_SIGNAL_FUNC(gtk_frame_unmap_callback
), (gpointer
)this );
468 // the only way to get the window size is to connect to this event
469 gtk_signal_connect( GTK_OBJECT(m_widget
), "configure_event",
470 GTK_SIGNAL_FUNC(gtk_frame_configure_callback
), (gpointer
)this );
472 // disable native tab traversal
473 gtk_signal_connect( GTK_OBJECT(m_widget
), "focus",
474 GTK_SIGNAL_FUNC(gtk_frame_focus_callback
), (gpointer
)this );
477 if ((m_miniEdge
> 0) || (style
& wxSIMPLE_BORDER
) || (style
& wxNO_BORDER
))
484 m_gdkDecor
= (long) GDK_DECOR_BORDER
;
485 m_gdkFunc
= (long) GDK_FUNC_MOVE
;
487 // All this is for Motif Window Manager "hints" and is supposed to be
488 // recognized by other WMs as well.
489 if ((style
& wxCAPTION
) != 0)
490 m_gdkDecor
|= GDK_DECOR_TITLE
;
491 if ((style
& wxSYSTEM_MENU
) != 0)
493 m_gdkFunc
|= GDK_FUNC_CLOSE
;
494 m_gdkDecor
|= GDK_DECOR_MENU
;
496 if ((style
& wxMINIMIZE_BOX
) != 0)
498 m_gdkFunc
|= GDK_FUNC_MINIMIZE
;
499 m_gdkDecor
|= GDK_DECOR_MINIMIZE
;
501 if ((style
& wxMAXIMIZE_BOX
) != 0)
503 m_gdkFunc
|= GDK_FUNC_MAXIMIZE
;
504 m_gdkDecor
|= GDK_DECOR_MAXIMIZE
;
506 if ((style
& wxRESIZE_BORDER
) != 0)
508 m_gdkFunc
|= GDK_FUNC_RESIZE
;
509 m_gdkDecor
|= GDK_DECOR_RESIZEH
;
516 wxTopLevelWindowGTK::~wxTopLevelWindowGTK()
518 m_isBeingDeleted
= TRUE
;
520 // it may also be GtkScrolledWindow in the case of an MDI child
521 if (GTK_IS_WINDOW(m_widget
))
523 gtk_window_set_focus( GTK_WINDOW(m_widget
), NULL
);
526 wxTopLevelWindows
.DeleteObject( this );
528 if (wxTheApp
->GetTopWindow() == this)
529 wxTheApp
->SetTopWindow( (wxWindow
*) NULL
);
531 if ((wxTopLevelWindows
.Number() == 0) &&
532 (wxTheApp
->GetExitOnFrameDelete()))
534 wxTheApp
->ExitMainLoop();
538 bool wxTopLevelWindowGTK::ShowFullScreen(bool show
, long style
)
540 if (show
== m_fsIsShowing
) return FALSE
; // return what?
542 m_fsIsShowing
= show
;
546 m_fsSaveGdkFunc
= m_gdkFunc
;
547 m_fsSaveGdkDecor
= m_gdkDecor
;
548 m_fsSaveFlag
= style
;
549 GetPosition( &m_fsSaveFrame
.x
, &m_fsSaveFrame
.y
);
550 GetSize( &m_fsSaveFrame
.width
, &m_fsSaveFrame
.height
);
552 gtk_widget_hide( m_widget
);
553 gtk_widget_unrealize( m_widget
);
555 m_gdkDecor
= (long) GDK_DECOR_BORDER
;
556 m_gdkFunc
= (long) GDK_FUNC_MOVE
;
560 wxDisplaySize( &x
, &y
);
561 SetSize( 0, 0, x
, y
);
563 gtk_widget_realize( m_widget
);
564 gtk_widget_show( m_widget
);
568 gtk_widget_hide( m_widget
);
569 gtk_widget_unrealize( m_widget
);
571 m_gdkFunc
= m_fsSaveGdkFunc
;
572 m_gdkDecor
= m_fsSaveGdkDecor
;
574 SetSize( m_fsSaveFrame
.x
, m_fsSaveFrame
.y
, m_fsSaveFrame
.width
, m_fsSaveFrame
.height
);
576 gtk_widget_realize( m_widget
);
577 gtk_widget_show( m_widget
);
583 // ----------------------------------------------------------------------------
584 // overridden wxWindow methods
585 // ----------------------------------------------------------------------------
587 bool wxTopLevelWindowGTK::Show( bool show
)
589 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
591 if (show
&& !m_sizeSet
)
593 /* by calling GtkOnSize here, we don't have to call
594 either after showing the frame, which would entail
595 much ugly flicker or from within the size_allocate
596 handler, because GTK 1.1.X forbids that. */
598 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
601 return wxWindow::Show( show
);
604 void wxTopLevelWindowGTK::DoMoveWindow(int WXUNUSED(x
), int WXUNUSED(y
), int WXUNUSED(width
), int WXUNUSED(height
) )
606 wxFAIL_MSG( wxT("DoMoveWindow called for wxTopLevelWindowGTK") );
609 void wxTopLevelWindowGTK::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
611 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
613 // this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow
614 wxASSERT_MSG( (m_wxwindow
!= NULL
), wxT("invalid frame") );
624 int old_width
= m_width
;
625 int old_height
= m_height
;
627 if ((sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) == 0)
629 if (x
!= -1) m_x
= x
;
630 if (y
!= -1) m_y
= y
;
631 if (width
!= -1) m_width
= width
;
632 if (height
!= -1) m_height
= height
;
643 if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
645 if (width == -1) m_width = 80;
648 if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
650 if (height == -1) m_height = 26;
654 int minWidth
= GetMinWidth(),
655 minHeight
= GetMinHeight(),
656 maxWidth
= GetMaxWidth(),
657 maxHeight
= GetMaxHeight();
659 if ((minWidth
!= -1) && (m_width
< minWidth
)) m_width
= minWidth
;
660 if ((minHeight
!= -1) && (m_height
< minHeight
)) m_height
= minHeight
;
661 if ((maxWidth
!= -1) && (m_width
> maxWidth
)) m_width
= maxWidth
;
662 if ((maxHeight
!= -1) && (m_height
> maxHeight
)) m_height
= maxHeight
;
664 if ((m_x
!= -1) || (m_y
!= -1))
666 if ((m_x
!= old_x
) || (m_y
!= old_y
))
668 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
672 if ((m_width
!= old_width
) || (m_height
!= old_height
))
674 if (m_widget
->window
)
675 gdk_window_resize( m_widget
->window
, m_width
, m_height
);
677 gtk_window_set_default_size( GTK_WINDOW(m_widget
), m_width
, m_height
);
679 /* we set the size in GtkOnSize, i.e. mostly the actual resizing is
680 done either directly before the frame is shown or in idle time
681 so that different calls to SetSize() don't lead to flicker. */
688 void wxTopLevelWindowGTK::DoGetClientSize( int *width
, int *height
) const
690 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
692 wxWindow::DoGetClientSize( width
, height
);
696 *height
-= m_miniEdge
*2 + m_miniTitle
;
700 *width
-= m_miniEdge
*2;
704 void wxTopLevelWindowGTK::DoSetClientSize( int width
, int height
)
706 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
709 width
+ m_miniEdge
*2, height
+ m_miniEdge
*2 + m_miniTitle
, 0);
712 void wxTopLevelWindowGTK::GtkOnSize( int WXUNUSED(x
), int WXUNUSED(y
),
713 int width
, int height
)
715 // due to a bug in gtk, x,y are always 0
720 if (m_resizing
) return;
723 if ( m_wxwindow
== NULL
) return;
728 /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses
729 wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
730 set in wxFrame::Create so it is used to check what kind of frame we
731 have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
732 skip the part which handles m_frameMenuBar, m_frameToolBar and (most
733 importantly) m_mainWidget */
735 int minWidth
= GetMinWidth(),
736 minHeight
= GetMinHeight(),
737 maxWidth
= GetMaxWidth(),
738 maxHeight
= GetMaxHeight();
740 if ((minWidth
!= -1) && (m_width
< minWidth
)) m_width
= minWidth
;
741 if ((minHeight
!= -1) && (m_height
< minHeight
)) m_height
= minHeight
;
742 if ((maxWidth
!= -1) && (m_width
> maxWidth
)) m_width
= maxWidth
;
743 if ((maxHeight
!= -1) && (m_height
> maxHeight
)) m_height
= maxHeight
;
748 gint flag
= 0; // GDK_HINT_POS;
749 if ((minWidth
!= -1) || (minHeight
!= -1)) flag
|= GDK_HINT_MIN_SIZE
;
750 if ((maxWidth
!= -1) || (maxHeight
!= -1)) flag
|= GDK_HINT_MAX_SIZE
;
752 geom
.min_width
= minWidth
;
753 geom
.min_height
= minHeight
;
754 geom
.max_width
= maxWidth
;
755 geom
.max_height
= maxHeight
;
756 gtk_window_set_geometry_hints( GTK_WINDOW(m_widget
),
759 (GdkWindowHints
) flag
);
761 /* I revert back to wxGTK's original behaviour. m_mainWidget holds the
762 * menubar, the toolbar and the client area, which is represented by
764 * this hurts in the eye, but I don't want to call SetSize()
765 * because I don't want to call any non-native functions here. */
767 int client_x
= m_miniEdge
;
768 int client_y
= m_miniEdge
+ m_miniTitle
;
769 int client_w
= m_width
- 2*m_miniEdge
;
770 int client_h
= m_height
- 2*m_miniEdge
- m_miniTitle
;
771 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget
),
773 client_x
, client_y
, client_w
, client_h
);
777 // If there is no m_mainWidget between m_widget and m_wxwindow there
778 // is no need to set the size or position of m_wxwindow.
783 // send size event to frame
784 wxSizeEvent
event( wxSize(m_width
,m_height
), GetId() );
785 event
.SetEventObject( this );
786 GetEventHandler()->ProcessEvent( event
);
791 void wxTopLevelWindowGTK::OnInternalIdle()
793 if (!m_sizeSet
&& GTK_WIDGET_REALIZED(m_wxwindow
))
795 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
797 // we'll come back later
799 wxapp_install_idle_handler();
803 wxWindow::OnInternalIdle();
807 // ----------------------------------------------------------------------------
809 // ----------------------------------------------------------------------------
811 void wxTopLevelWindowGTK::SetTitle( const wxString
&title
)
813 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
816 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
819 void wxTopLevelWindowGTK::DoSetIcon( const wxIcon
&icon
)
824 if (!m_widget
->window
)
827 wxMask
*mask
= icon
.GetMask();
828 GdkBitmap
*bm
= (GdkBitmap
*) NULL
;
829 if (mask
) bm
= mask
->GetBitmap();
831 gdk_window_set_icon( m_widget
->window
, (GdkWindow
*) NULL
, icon
.GetPixmap(), bm
);
834 void wxTopLevelWindowGTK::SetIcon( const wxIcon
&icon
)
836 SetIcons( wxIconBundle( icon
) );
839 void wxTopLevelWindowGTK::SetIcons( const wxIconBundle
&icons
)
841 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
842 GdkWindow
* window
= m_widget
->window
;
843 wxCHECK_RET( window
, _T("window not created yet - can't set icon") );
845 wxTopLevelWindowBase::SetIcons( icons
);
847 DoSetIcon( icons
.GetIcon( -1 ) );
848 wxSetIconsX11( (WXDisplay
*)GDK_WINDOW_XDISPLAY( window
),
849 (WXWindow
)GDK_WINDOW_XWINDOW( window
), icons
);
852 // ----------------------------------------------------------------------------
853 // frame state: maximized/iconized/normal
854 // ----------------------------------------------------------------------------
856 void wxTopLevelWindowGTK::Maximize(bool WXUNUSED(maximize
))
858 wxFAIL_MSG( _T("not implemented") );
861 bool wxTopLevelWindowGTK::IsMaximized() const
863 // wxFAIL_MSG( _T("not implemented") );
865 // This is an approximation
869 void wxTopLevelWindowGTK::Restore()
871 wxFAIL_MSG( _T("not implemented") );
874 void wxTopLevelWindowGTK::Iconize( bool iconize
)
878 GdkWindow
*window
= m_widget
->window
;
880 // you should do it later, for example from OnCreate() handler
881 wxCHECK_RET( window
, _T("frame not created yet - can't iconize") );
883 XIconifyWindow( GDK_WINDOW_XDISPLAY( window
),
884 GDK_WINDOW_XWINDOW( window
),
885 DefaultScreen( GDK_DISPLAY() ) );
889 bool wxTopLevelWindowGTK::IsIconized() const
894 void wxTopLevelWindowGTK::SetIconizeState(bool iconize
)
896 if ( iconize
!= m_isIconized
)
898 m_isIconized
= iconize
;
899 (void)SendIconizeEvent(iconize
);