]> git.saurik.com Git - wxWidgets.git/commitdiff
Had to change the time point, when widgets are
authorRobert Roebling <robert@roebling.de>
Sat, 24 Apr 1999 21:57:18 +0000 (21:57 +0000)
committerRobert Roebling <robert@roebling.de>
Sat, 24 Apr 1999 21:57:18 +0000 (21:57 +0000)
  created (no longer forced). This seems to break
  wxNotebook...

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2276 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

19 files changed:
samples/controls/controls.cpp
src/gtk/checkbox.cpp
src/gtk/choice.cpp
src/gtk/combobox.cpp
src/gtk/dcclient.cpp
src/gtk/dialog.cpp
src/gtk/frame.cpp
src/gtk/listbox.cpp
src/gtk/notebook.cpp
src/gtk/window.cpp
src/gtk1/checkbox.cpp
src/gtk1/choice.cpp
src/gtk1/combobox.cpp
src/gtk1/dcclient.cpp
src/gtk1/dialog.cpp
src/gtk1/frame.cpp
src/gtk1/listbox.cpp
src/gtk1/notebook.cpp
src/gtk1/window.cpp

index 3f1df49a668d6eb25bc6933d4ce29300f9384916..5365385b03a545824f426951851da311460e4899 100644 (file)
@@ -474,6 +474,7 @@ m_text(NULL), m_notebook(NULL)
 
     panel = new wxPanel(m_notebook);
     m_choice = new wxChoice( panel, ID_CHOICE, wxPoint(10,10), wxSize(120,-1), 5, choices );
+    m_choice->SetBackgroundColour( "red" );
     (void)new wxButton( panel, ID_CHOICE_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
     (void)new wxButton( panel, ID_CHOICE_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
     (void)new wxButton( panel, ID_CHOICE_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) );
index d4023c5a042a644fd5a283f69c3f6025988538dc..8cda3d112bfc782c4d11c1e6877ad997cbfdc480 100644 (file)
@@ -121,9 +121,6 @@ bool wxCheckBox::Create(wxWindow *parent,
 
     PostCreation();
 
-    gtk_widget_realize( m_widgetLabel );
-    gtk_widget_realize( m_widgetCheckbox );
-
     SetBackgroundColour( parent->GetBackgroundColour() );
     SetForegroundColour( parent->GetForegroundColour() );
     SetFont( parent->GetFont() );
index 2c1d4c702c8f5b5191480c11006882fe6ca6ee9b..ba049f6447090e75e04c9b5741e7b5a20b552e49 100644 (file)
@@ -85,9 +85,6 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
         GtkWidget *item = gtk_menu_item_new_with_label( choices[i].mbc_str() );
         gtk_menu_append( GTK_MENU(menu), item );
 
-        gtk_widget_realize( item );
-        gtk_widget_realize( GTK_BIN(item)->child );
-
         gtk_widget_show( item );
 
         gtk_signal_connect( GTK_OBJECT( item ), "activate",
@@ -124,10 +121,13 @@ void wxChoice::AppendCommon( const wxString &item )
 
     gtk_menu_append( GTK_MENU(menu), menu_item );
 
-    gtk_widget_realize( menu_item );
-    gtk_widget_realize( GTK_BIN(menu_item)->child );
+    if (GTK_WIDGET_REALIZED(m_widget))
+    {
+        gtk_widget_realize( menu_item );
+        gtk_widget_realize( GTK_BIN(menu_item)->child );
 
-    if (m_widgetStyle) ApplyWidgetStyle();
+        if (m_widgetStyle) ApplyWidgetStyle();
+    }
 
     gtk_signal_connect( GTK_OBJECT( menu_item ), "activate",
       GTK_SIGNAL_FUNC(gtk_choice_clicked_callback), (gpointer*)this );
index 54aea8e64706e4f79e59698d2fb271692fd75a58..c202ba56eb55a9106525d6f20c56e27fb4e59caf 100644 (file)
@@ -113,9 +113,6 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
 
         gtk_container_add( GTK_CONTAINER(list), list_item );
 
-        gtk_widget_realize( list_item );
-        gtk_widget_realize( GTK_BIN(list_item)->child );
-
         gtk_widget_show( list_item );
 
         gtk_signal_connect( GTK_OBJECT(list_item), "select",
@@ -132,10 +129,6 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
 
     if (!value.IsNull()) SetValue( value );
 
-    gtk_widget_realize( GTK_COMBO(m_widget)->list );
-    gtk_widget_realize( GTK_COMBO(m_widget)->entry );
-    gtk_widget_realize( GTK_COMBO(m_widget)->button );
-
     if (style & wxCB_READONLY)
         gtk_entry_set_editable( GTK_ENTRY( GTK_COMBO(m_widget)->entry ), FALSE );
 
@@ -176,7 +169,13 @@ void wxComboBox::AppendCommon( const wxString &item )
 
     gtk_container_add( GTK_CONTAINER(list), list_item );
 
-    if (m_widgetStyle) ApplyWidgetStyle();
+    if (GTK_WIDGET_REALIZED(m_widget))
+    {
+        gtk_widget_realize( list_item );
+        gtk_widget_realize( GTK_BIN(list_item)->child );
+
+        if (m_widgetStyle) ApplyWidgetStyle();
+    }
 
     gtk_widget_show( list_item );
 }
index 2cdeb7137aeb68cd15223716cc8038c1110b810f..ffd5d9ef1539db6c9fdea3e8fc24169ef185bd8f 100644 (file)
@@ -825,8 +825,6 @@ void wxWindowDC::GetTextExtent( const wxString &string, long *width, long *heigh
                      long *descent, long *externalLeading,
                      wxFont *theFont, bool WXUNUSED(use16) )
 {
-    wxCHECK_RET( Ok(), _T("invalid window dc") );
-  
     wxFont fontToUse = m_font;
     if (theFont) fontToUse = *theFont;
   
@@ -839,16 +837,12 @@ void wxWindowDC::GetTextExtent( const wxString &string, long *width, long *heigh
 
 long wxWindowDC::GetCharWidth()
 {
-    wxCHECK_MSG( Ok(), 0, _T("invalid window dc") );
-  
     GdkFont *font = m_font.GetInternalFont( m_scaleY );
     return long(gdk_string_width( font, "H" ) / m_scaleX);
 }
 
 long wxWindowDC::GetCharHeight()
 {
-    wxCHECK_MSG( Ok(), 0, _T("invalid window dc") );
-  
     GdkFont *font = m_font.GetInternalFont( m_scaleY );
     return long((font->ascent + font->descent) / m_scaleY);
 }
@@ -883,8 +877,6 @@ void wxWindowDC::Clear()
 
 void wxWindowDC::SetFont( const wxFont &font )
 {
-    wxCHECK_RET( Ok(), _T("invalid window dc") );
-  
     m_font = font;
 }
 
index 7edb2940c8712fd6b239715896d9ca75d1944ba4..427557a8c6d79e93e2d54e191134a6e4fcfc2cbb 100644 (file)
@@ -82,6 +82,48 @@ static gint gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEvent
     return FALSE;
 }
 
+//-----------------------------------------------------------------------------
+// "realize" from m_widget
+//-----------------------------------------------------------------------------
+
+/* we cannot MWM hints before the widget has been realized, 
+   so we do this directly after realization */
+
+static gint 
+gtk_dialog_realized_callback( GtkWidget *widget, wxWindow *win )
+{
+    /* all this is for Motif Window Manager "hints" and is supposed to be
+       recognized by other WM as well. not tested. */
+    long decor = (long) GDK_DECOR_ALL;
+    long func = (long) GDK_FUNC_ALL;
+    
+    if ((win->m_windowStyle & wxCAPTION) == 0)
+       decor |= GDK_DECOR_TITLE;
+/*  if ((win->m_windowStyle & wxMINIMIZE) == 0)
+       func |= GDK_FUNC_MINIMIZE;
+    if ((win->m_windowStyle & wxMAXIMIZE) == 0)
+       func |= GDK_FUNC_MAXIMIZE;            */
+    if ((win->m_windowStyle & wxSYSTEM_MENU) == 0)
+       decor |= GDK_DECOR_MENU;
+    if ((win->m_windowStyle & wxMINIMIZE_BOX) == 0)
+       decor |= GDK_DECOR_MINIMIZE;
+    if ((win->m_windowStyle & wxMAXIMIZE_BOX) == 0)
+       decor |= GDK_DECOR_MAXIMIZE;
+    if ((win->m_windowStyle & wxRESIZE_BORDER) == 0)
+       func |= GDK_FUNC_RESIZE;
+       
+    gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor);
+    gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func);
+      
+    /* GTK's shrinking/growing policy */
+    if ((win->m_windowStyle & wxRESIZE_BORDER) == 0)
+        gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1);
+    else
+        gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
+    
+    return FALSE;
+}
+    
 //-----------------------------------------------------------------------------
 // wxDialog
 //-----------------------------------------------------------------------------
@@ -143,37 +185,12 @@ bool wxDialog::Create( wxWindow *parent,
 
     PostCreation();
 
-    gtk_widget_realize( m_widget );
-
-    /* all this is for Motif Window Manager "hints" and is supposed to be
-       recognized by other WM as well. not tested. */
-    long decor = (long) GDK_DECOR_ALL;
-    long func = (long) GDK_FUNC_ALL;
+    /*  we cannot set MWM hints  before the widget has
+        been realized, so we do this directly after realization */
+    gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
+                       GTK_SIGNAL_FUNC(gtk_dialog_realized_callback), (gpointer) this );
     
-    if ((m_windowStyle & wxCAPTION) == 0)
-       decor |= GDK_DECOR_TITLE;
-/*  if ((m_windowStyle & wxMINIMIZE) == 0)
-       func |= GDK_FUNC_MINIMIZE;
-    if ((m_windowStyle & wxMAXIMIZE) == 0)
-       func |= GDK_FUNC_MAXIMIZE; */
-    if ((m_windowStyle & wxSYSTEM_MENU) == 0)
-       decor |= GDK_DECOR_MENU;
-    if ((m_windowStyle & wxMINIMIZE_BOX) == 0)
-       decor |= GDK_DECOR_MINIMIZE;
-    if ((m_windowStyle & wxMAXIMIZE_BOX) == 0)
-       decor |= GDK_DECOR_MAXIMIZE;
-    if ((m_windowStyle & wxRESIZE_BORDER) == 0)
-       func |= GDK_FUNC_RESIZE;
-       
-    gdk_window_set_decorations(m_widget->window, (GdkWMDecoration)decor);
-    gdk_window_set_functions(m_widget->window, (GdkWMFunction)func);
-    
-    /* GTK's shrinking/growing policy */
-    if ((m_windowStyle & wxRESIZE_BORDER) == 0)
-        gtk_window_set_policy(GTK_WINDOW(m_widget), 0, 0, 1);
-    else
-        gtk_window_set_policy(GTK_WINDOW(m_widget), 1, 1, 1);
-
+    /* the user resized the frame by dragging etc. */
     gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
         GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this );
 
index 288579b66122d3566f192a9262dafb9e9db33f5a..edef46b4ee8139a755a7ad4f056988dde6396350 100644 (file)
@@ -146,6 +146,48 @@ static gint gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventC
     return FALSE;
 }
 
+//-----------------------------------------------------------------------------
+// "realize" from m_widget
+//-----------------------------------------------------------------------------
+
+/* we cannot MWM hints before the widget has been realized, 
+   so we do this directly after realization */
+
+static gint 
+gtk_frame_realized_callback( GtkWidget *widget, wxWindow *win )
+{
+    /* all this is for Motif Window Manager "hints" and is supposed to be
+       recognized by other WM as well. not tested. */
+    long decor = (long) GDK_DECOR_ALL;
+    long func = (long) GDK_FUNC_ALL;
+    
+    if ((win->m_windowStyle & wxCAPTION) == 0)
+       decor |= GDK_DECOR_TITLE;
+/*  if ((win->m_windowStyle & wxMINIMIZE) == 0)
+       func |= GDK_FUNC_MINIMIZE;
+    if ((win->m_windowStyle & wxMAXIMIZE) == 0)
+       func |= GDK_FUNC_MAXIMIZE;            */
+    if ((win->m_windowStyle & wxSYSTEM_MENU) == 0)
+       decor |= GDK_DECOR_MENU;
+    if ((win->m_windowStyle & wxMINIMIZE_BOX) == 0)
+       decor |= GDK_DECOR_MINIMIZE;
+    if ((win->m_windowStyle & wxMAXIMIZE_BOX) == 0)
+       decor |= GDK_DECOR_MAXIMIZE;
+    if ((win->m_windowStyle & wxRESIZE_BORDER) == 0)
+       func |= GDK_FUNC_RESIZE;
+       
+    gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor);
+    gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func);
+      
+    /* GTK's shrinking/growing policy */
+    if ((win->m_windowStyle & wxRESIZE_BORDER) == 0)
+        gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1);
+    else
+        gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
+    
+    return FALSE;
+}
+    
 //-----------------------------------------------------------------------------
 // InsertChild for wxFrame
 //-----------------------------------------------------------------------------
@@ -281,7 +323,6 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
     gtk_widget_show( m_mainWidget );
     GTK_WIDGET_UNSET_FLAGS( m_mainWidget, GTK_CAN_FOCUS );
     gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget );
-    gtk_widget_realize( m_mainWidget );
     
     /* m_wxwindow only represents the client area without toolbar and menubar */
     m_wxwindow = gtk_myfixed_new();
@@ -293,37 +334,11 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
 
     PostCreation();
 
-    gtk_widget_realize( m_widget );
+    /*  we cannot set MWM hints  before the widget has
+        been realized, so we do this directly after realization */
+    gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
+                       GTK_SIGNAL_FUNC(gtk_frame_realized_callback), (gpointer) this );
     
-    /* all this is for Motif Window Manager "hints" and is supposed to be
-       recognized by other WM as well. not tested. */
-    long decor = (long) GDK_DECOR_ALL;
-    long func = (long) GDK_FUNC_ALL;
-    
-    if ((m_windowStyle & wxCAPTION) == 0)
-       decor |= GDK_DECOR_TITLE;
-/*  if ((m_windowStyle & wxMINIMIZE) == 0)
-       func |= GDK_FUNC_MINIMIZE;
-    if ((m_windowStyle & wxMAXIMIZE) == 0)
-       func |= GDK_FUNC_MAXIMIZE;            */
-    if ((m_windowStyle & wxSYSTEM_MENU) == 0)
-       decor |= GDK_DECOR_MENU;
-    if ((m_windowStyle & wxMINIMIZE_BOX) == 0)
-       decor |= GDK_DECOR_MINIMIZE;
-    if ((m_windowStyle & wxMAXIMIZE_BOX) == 0)
-       decor |= GDK_DECOR_MAXIMIZE;
-    if ((m_windowStyle & wxRESIZE_BORDER) == 0)
-       func |= GDK_FUNC_RESIZE;
-       
-    gdk_window_set_decorations(m_widget->window, (GdkWMDecoration)decor);
-    gdk_window_set_functions(m_widget->window, (GdkWMFunction)func);
-      
-    /* GTK's shrinking/growing policy */
-    if ((m_windowStyle & wxRESIZE_BORDER) == 0)
-        gtk_window_set_policy(GTK_WINDOW(m_widget), 0, 0, 1);
-    else
-        gtk_window_set_policy(GTK_WINDOW(m_widget), 1, 1, 1);
-       
     /* the user resized the frame by dragging etc. */
     gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
         GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this );
index e20908585c2d0eb6e17acda08293a000e122ba03..138fc38d96d1ed72ff6195f22c375807ebb055e9 100644 (file)
@@ -274,8 +274,6 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
 
     PostCreation();
 
-    gtk_widget_realize( GTK_WIDGET(m_list) );
-
     SetBackgroundColour( parent->GetBackgroundColour() );
     SetForegroundColour( parent->GetForegroundColour() );
     SetFont( parent->GetFont() );
@@ -411,8 +409,6 @@ void wxListBox::AppendCommon( const wxString &item )
         gtk_signal_connect( GTK_OBJECT(list_item), "deselect",
           GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
 
-    if (m_widgetStyle) ApplyWidgetStyle();
-
     gtk_signal_connect( GTK_OBJECT(list_item),
                         "button_press_event",
                         (GtkSignalFunc)gtk_listbox_button_press_callback,
@@ -430,15 +426,23 @@ void wxListBox::AppendCommon( const wxString &item )
 
     ConnectWidget( list_item );
 
+    if (GTK_WIDGET_REALIZED(m_widget))
+    {
+        gtk_widget_realize( list_item );
+        gtk_widget_realize( GTK_BIN(list_item)->child );
+       
+        if (m_widgetStyle) ApplyWidgetStyle();
+
 #if wxUSE_DRAG_AND_DROP
 #ifndef NEW_GTK_DND_CODE
-    if (m_dropTarget) m_dropTarget->RegisterWidget( list_item );
+        if (m_dropTarget) m_dropTarget->RegisterWidget( list_item );
 #endif
 #endif
 
 #if wxUSE_TOOLTIPS
-    if (m_toolTip) m_toolTip->Apply( this );
+        if (m_toolTip) m_toolTip->Apply( this );
 #endif
+    }
 }
 
 void wxListBox::Append( const wxString &item )
index 364487fafcfb13b9f606a6c4fb26eab3f29012c8..eb13d01f4646f2f0562ee20ba90dacd0bc683fe5 100644 (file)
@@ -109,9 +109,9 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation*
         (win->m_width == alloc->width) &&
         (win->m_height == alloc->height))
     {
-        return;
+//        return;
     }
-
+    
     win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height );
 
     if (win->GetAutoLayout()) win->Layout();
index a84758ad857499ef211c6ea32599f99e7638b7a5..2c6b88d560f54793866b99880f0d73fe5cd147ce 100644 (file)
@@ -1294,6 +1294,40 @@ static gint gtk_scrollbar_button_release_callback( GtkRange *widget,
     return FALSE;
 }
 
+//-----------------------------------------------------------------------------
+// "realize" from m_widget
+//-----------------------------------------------------------------------------
+
+/* we cannot set colours, fonts and cursors before the widget has
+   been realized, so we do this directly after realization */
+
+static gint 
+gtk_window_realized_callback( GtkWidget *widget, wxWindow *win )
+{
+    if (win->m_font != *wxSWISS_FONT)
+    {
+        wxFont font( win->m_font );
+        win->m_font = wxNullFont;
+       win->SetFont( font );
+    }
+    
+    if (win->m_backgroundColour != wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ))
+    {
+        wxColour bg( win->m_backgroundColour );
+       win->m_backgroundColour = wxNullColour;
+       win->SetBackgroundColour( bg );
+    }
+    
+    if (win->m_foregroundColour != *wxBLACK)
+    {
+        wxColour fg( win->m_foregroundColour );
+       win->m_foregroundColour = wxNullColour;
+       win->SetForegroundColour( fg );
+    }
+    
+    return FALSE;
+}
+    
 //-----------------------------------------------------------------------------
 // InsertChild for wxWindow.
 //-----------------------------------------------------------------------------
@@ -1750,13 +1784,12 @@ void wxWindow::PostCreation()
 
     ConnectWidget( GetConnectWidget() );
 
-    /* we force the creation of wxFrame and wxDialog in the respective code */
-    if (m_parent) gtk_widget_realize( m_widget );
-
-    if (m_wxwindow) gtk_widget_realize( m_wxwindow );
-
-    SetCursor( *wxSTANDARD_CURSOR );
-
+/*  we cannot set colours, fonts and cursors before the widget has
+    been realized, so we do this directly after realization */
+   
+    gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
+                           GTK_SIGNAL_FUNC(gtk_window_realized_callback), (gpointer) this );
+                           
     m_hasVMT = TRUE;
 }
 
@@ -2071,6 +2104,8 @@ void wxWindow::ClientToScreen( int *x, int *y )
 {
     wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
 
+    if (!m_widget->window) return;
+
     GdkWindow *source = (GdkWindow *) NULL;
     if (m_wxwindow)
         source = m_wxwindow->window;
@@ -2098,6 +2133,8 @@ void wxWindow::ScreenToClient( int *x, int *y )
 {
     wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
 
+    if (!m_widget->window) return;
+
     GdkWindow *source = (GdkWindow *) NULL;
     if (m_wxwindow)
         source = m_wxwindow->window;
@@ -2351,6 +2388,8 @@ void wxWindow::Raise()
 {
     wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
 
+    if (!m_widget->window) return;
+
     if (m_widget) gdk_window_raise( m_widget->window );
 }
 
@@ -2358,6 +2397,8 @@ void wxWindow::Lower()
 {
     wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
 
+    if (!m_widget->window) return;
+
     if (m_widget) gdk_window_lower( m_widget->window );
 }
 
@@ -2459,8 +2500,9 @@ void wxWindow::SetCursor( const wxCursor &cursor )
         *m_cursor = *wxSTANDARD_CURSOR;
     }
 
-    if ((m_widget) && (m_widget->window))
-         gdk_window_set_cursor( m_widget->window, m_cursor->GetCursor() );
+    if (!m_widget->window) return;
+
+    gdk_window_set_cursor( m_widget->window, m_cursor->GetCursor() );
 
     if ((m_wxwindow) && (m_wxwindow->window))
          gdk_window_set_cursor( m_wxwindow->window, m_cursor->GetCursor() );
@@ -2475,6 +2517,8 @@ void wxWindow::Refresh( bool eraseBackground, const wxRect *rect )
 {
     wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
 
+    if (!m_widget->window) return;
+
     if (eraseBackground && m_wxwindow && m_wxwindow->window)
     {
         if (rect)
@@ -2540,6 +2584,8 @@ void wxWindow::Clear()
 {
     wxCHECK_RET( m_widget != NULL, _T("invalid window") );
 
+    if (!m_widget->window) return;
+
     if (m_wxwindow && m_wxwindow->window)
     {
         gdk_window_clear( m_wxwindow->window );
@@ -2596,6 +2642,8 @@ void wxWindow::SetBackgroundColour( const wxColour &colour )
     m_backgroundColour = colour;
     if (!m_backgroundColour.Ok()) return;
 
+    if (!m_widget->window) return;
+
     if (m_wxwindow && m_wxwindow->window)
     {
        /* wxMSW doesn't clear the window here. I don't do that
@@ -2636,6 +2684,8 @@ void wxWindow::SetForegroundColour( const wxColour &colour )
     m_foregroundColour = colour;
     if (!m_foregroundColour.Ok()) return;
 
+    if (!m_widget->window) return;
+
     wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
     if (sysbg.Red() == colour.Red() &&
         sysbg.Green() == colour.Green() &&
@@ -2896,6 +2946,8 @@ void wxWindow::CaptureMouse()
 
     wxCHECK_RET( g_capturing == FALSE, _T("CaptureMouse called twice") );
 
+    if (!m_widget->window) return;
+
     GtkWidget *connect_widget = GetConnectWidget();
     gtk_grab_add( connect_widget );
     gdk_pointer_grab( connect_widget->window, FALSE,
@@ -2915,6 +2967,8 @@ void wxWindow::ReleaseMouse()
 
     wxCHECK_RET( g_capturing == TRUE, _T("ReleaseMouse called twice") );
 
+    if (!m_widget->window) return;
+
     GtkWidget *connect_widget = GetConnectWidget();
     gtk_grab_remove( connect_widget );
     gdk_pointer_ungrab ( GDK_CURRENT_TIME );
index d4023c5a042a644fd5a283f69c3f6025988538dc..8cda3d112bfc782c4d11c1e6877ad997cbfdc480 100644 (file)
@@ -121,9 +121,6 @@ bool wxCheckBox::Create(wxWindow *parent,
 
     PostCreation();
 
-    gtk_widget_realize( m_widgetLabel );
-    gtk_widget_realize( m_widgetCheckbox );
-
     SetBackgroundColour( parent->GetBackgroundColour() );
     SetForegroundColour( parent->GetForegroundColour() );
     SetFont( parent->GetFont() );
index 2c1d4c702c8f5b5191480c11006882fe6ca6ee9b..ba049f6447090e75e04c9b5741e7b5a20b552e49 100644 (file)
@@ -85,9 +85,6 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
         GtkWidget *item = gtk_menu_item_new_with_label( choices[i].mbc_str() );
         gtk_menu_append( GTK_MENU(menu), item );
 
-        gtk_widget_realize( item );
-        gtk_widget_realize( GTK_BIN(item)->child );
-
         gtk_widget_show( item );
 
         gtk_signal_connect( GTK_OBJECT( item ), "activate",
@@ -124,10 +121,13 @@ void wxChoice::AppendCommon( const wxString &item )
 
     gtk_menu_append( GTK_MENU(menu), menu_item );
 
-    gtk_widget_realize( menu_item );
-    gtk_widget_realize( GTK_BIN(menu_item)->child );
+    if (GTK_WIDGET_REALIZED(m_widget))
+    {
+        gtk_widget_realize( menu_item );
+        gtk_widget_realize( GTK_BIN(menu_item)->child );
 
-    if (m_widgetStyle) ApplyWidgetStyle();
+        if (m_widgetStyle) ApplyWidgetStyle();
+    }
 
     gtk_signal_connect( GTK_OBJECT( menu_item ), "activate",
       GTK_SIGNAL_FUNC(gtk_choice_clicked_callback), (gpointer*)this );
index 54aea8e64706e4f79e59698d2fb271692fd75a58..c202ba56eb55a9106525d6f20c56e27fb4e59caf 100644 (file)
@@ -113,9 +113,6 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
 
         gtk_container_add( GTK_CONTAINER(list), list_item );
 
-        gtk_widget_realize( list_item );
-        gtk_widget_realize( GTK_BIN(list_item)->child );
-
         gtk_widget_show( list_item );
 
         gtk_signal_connect( GTK_OBJECT(list_item), "select",
@@ -132,10 +129,6 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
 
     if (!value.IsNull()) SetValue( value );
 
-    gtk_widget_realize( GTK_COMBO(m_widget)->list );
-    gtk_widget_realize( GTK_COMBO(m_widget)->entry );
-    gtk_widget_realize( GTK_COMBO(m_widget)->button );
-
     if (style & wxCB_READONLY)
         gtk_entry_set_editable( GTK_ENTRY( GTK_COMBO(m_widget)->entry ), FALSE );
 
@@ -176,7 +169,13 @@ void wxComboBox::AppendCommon( const wxString &item )
 
     gtk_container_add( GTK_CONTAINER(list), list_item );
 
-    if (m_widgetStyle) ApplyWidgetStyle();
+    if (GTK_WIDGET_REALIZED(m_widget))
+    {
+        gtk_widget_realize( list_item );
+        gtk_widget_realize( GTK_BIN(list_item)->child );
+
+        if (m_widgetStyle) ApplyWidgetStyle();
+    }
 
     gtk_widget_show( list_item );
 }
index 2cdeb7137aeb68cd15223716cc8038c1110b810f..ffd5d9ef1539db6c9fdea3e8fc24169ef185bd8f 100644 (file)
@@ -825,8 +825,6 @@ void wxWindowDC::GetTextExtent( const wxString &string, long *width, long *heigh
                      long *descent, long *externalLeading,
                      wxFont *theFont, bool WXUNUSED(use16) )
 {
-    wxCHECK_RET( Ok(), _T("invalid window dc") );
-  
     wxFont fontToUse = m_font;
     if (theFont) fontToUse = *theFont;
   
@@ -839,16 +837,12 @@ void wxWindowDC::GetTextExtent( const wxString &string, long *width, long *heigh
 
 long wxWindowDC::GetCharWidth()
 {
-    wxCHECK_MSG( Ok(), 0, _T("invalid window dc") );
-  
     GdkFont *font = m_font.GetInternalFont( m_scaleY );
     return long(gdk_string_width( font, "H" ) / m_scaleX);
 }
 
 long wxWindowDC::GetCharHeight()
 {
-    wxCHECK_MSG( Ok(), 0, _T("invalid window dc") );
-  
     GdkFont *font = m_font.GetInternalFont( m_scaleY );
     return long((font->ascent + font->descent) / m_scaleY);
 }
@@ -883,8 +877,6 @@ void wxWindowDC::Clear()
 
 void wxWindowDC::SetFont( const wxFont &font )
 {
-    wxCHECK_RET( Ok(), _T("invalid window dc") );
-  
     m_font = font;
 }
 
index 7edb2940c8712fd6b239715896d9ca75d1944ba4..427557a8c6d79e93e2d54e191134a6e4fcfc2cbb 100644 (file)
@@ -82,6 +82,48 @@ static gint gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEvent
     return FALSE;
 }
 
+//-----------------------------------------------------------------------------
+// "realize" from m_widget
+//-----------------------------------------------------------------------------
+
+/* we cannot MWM hints before the widget has been realized, 
+   so we do this directly after realization */
+
+static gint 
+gtk_dialog_realized_callback( GtkWidget *widget, wxWindow *win )
+{
+    /* all this is for Motif Window Manager "hints" and is supposed to be
+       recognized by other WM as well. not tested. */
+    long decor = (long) GDK_DECOR_ALL;
+    long func = (long) GDK_FUNC_ALL;
+    
+    if ((win->m_windowStyle & wxCAPTION) == 0)
+       decor |= GDK_DECOR_TITLE;
+/*  if ((win->m_windowStyle & wxMINIMIZE) == 0)
+       func |= GDK_FUNC_MINIMIZE;
+    if ((win->m_windowStyle & wxMAXIMIZE) == 0)
+       func |= GDK_FUNC_MAXIMIZE;            */
+    if ((win->m_windowStyle & wxSYSTEM_MENU) == 0)
+       decor |= GDK_DECOR_MENU;
+    if ((win->m_windowStyle & wxMINIMIZE_BOX) == 0)
+       decor |= GDK_DECOR_MINIMIZE;
+    if ((win->m_windowStyle & wxMAXIMIZE_BOX) == 0)
+       decor |= GDK_DECOR_MAXIMIZE;
+    if ((win->m_windowStyle & wxRESIZE_BORDER) == 0)
+       func |= GDK_FUNC_RESIZE;
+       
+    gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor);
+    gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func);
+      
+    /* GTK's shrinking/growing policy */
+    if ((win->m_windowStyle & wxRESIZE_BORDER) == 0)
+        gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1);
+    else
+        gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
+    
+    return FALSE;
+}
+    
 //-----------------------------------------------------------------------------
 // wxDialog
 //-----------------------------------------------------------------------------
@@ -143,37 +185,12 @@ bool wxDialog::Create( wxWindow *parent,
 
     PostCreation();
 
-    gtk_widget_realize( m_widget );
-
-    /* all this is for Motif Window Manager "hints" and is supposed to be
-       recognized by other WM as well. not tested. */
-    long decor = (long) GDK_DECOR_ALL;
-    long func = (long) GDK_FUNC_ALL;
+    /*  we cannot set MWM hints  before the widget has
+        been realized, so we do this directly after realization */
+    gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
+                       GTK_SIGNAL_FUNC(gtk_dialog_realized_callback), (gpointer) this );
     
-    if ((m_windowStyle & wxCAPTION) == 0)
-       decor |= GDK_DECOR_TITLE;
-/*  if ((m_windowStyle & wxMINIMIZE) == 0)
-       func |= GDK_FUNC_MINIMIZE;
-    if ((m_windowStyle & wxMAXIMIZE) == 0)
-       func |= GDK_FUNC_MAXIMIZE; */
-    if ((m_windowStyle & wxSYSTEM_MENU) == 0)
-       decor |= GDK_DECOR_MENU;
-    if ((m_windowStyle & wxMINIMIZE_BOX) == 0)
-       decor |= GDK_DECOR_MINIMIZE;
-    if ((m_windowStyle & wxMAXIMIZE_BOX) == 0)
-       decor |= GDK_DECOR_MAXIMIZE;
-    if ((m_windowStyle & wxRESIZE_BORDER) == 0)
-       func |= GDK_FUNC_RESIZE;
-       
-    gdk_window_set_decorations(m_widget->window, (GdkWMDecoration)decor);
-    gdk_window_set_functions(m_widget->window, (GdkWMFunction)func);
-    
-    /* GTK's shrinking/growing policy */
-    if ((m_windowStyle & wxRESIZE_BORDER) == 0)
-        gtk_window_set_policy(GTK_WINDOW(m_widget), 0, 0, 1);
-    else
-        gtk_window_set_policy(GTK_WINDOW(m_widget), 1, 1, 1);
-
+    /* the user resized the frame by dragging etc. */
     gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
         GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this );
 
index 288579b66122d3566f192a9262dafb9e9db33f5a..edef46b4ee8139a755a7ad4f056988dde6396350 100644 (file)
@@ -146,6 +146,48 @@ static gint gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventC
     return FALSE;
 }
 
+//-----------------------------------------------------------------------------
+// "realize" from m_widget
+//-----------------------------------------------------------------------------
+
+/* we cannot MWM hints before the widget has been realized, 
+   so we do this directly after realization */
+
+static gint 
+gtk_frame_realized_callback( GtkWidget *widget, wxWindow *win )
+{
+    /* all this is for Motif Window Manager "hints" and is supposed to be
+       recognized by other WM as well. not tested. */
+    long decor = (long) GDK_DECOR_ALL;
+    long func = (long) GDK_FUNC_ALL;
+    
+    if ((win->m_windowStyle & wxCAPTION) == 0)
+       decor |= GDK_DECOR_TITLE;
+/*  if ((win->m_windowStyle & wxMINIMIZE) == 0)
+       func |= GDK_FUNC_MINIMIZE;
+    if ((win->m_windowStyle & wxMAXIMIZE) == 0)
+       func |= GDK_FUNC_MAXIMIZE;            */
+    if ((win->m_windowStyle & wxSYSTEM_MENU) == 0)
+       decor |= GDK_DECOR_MENU;
+    if ((win->m_windowStyle & wxMINIMIZE_BOX) == 0)
+       decor |= GDK_DECOR_MINIMIZE;
+    if ((win->m_windowStyle & wxMAXIMIZE_BOX) == 0)
+       decor |= GDK_DECOR_MAXIMIZE;
+    if ((win->m_windowStyle & wxRESIZE_BORDER) == 0)
+       func |= GDK_FUNC_RESIZE;
+       
+    gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor);
+    gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func);
+      
+    /* GTK's shrinking/growing policy */
+    if ((win->m_windowStyle & wxRESIZE_BORDER) == 0)
+        gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1);
+    else
+        gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
+    
+    return FALSE;
+}
+    
 //-----------------------------------------------------------------------------
 // InsertChild for wxFrame
 //-----------------------------------------------------------------------------
@@ -281,7 +323,6 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
     gtk_widget_show( m_mainWidget );
     GTK_WIDGET_UNSET_FLAGS( m_mainWidget, GTK_CAN_FOCUS );
     gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget );
-    gtk_widget_realize( m_mainWidget );
     
     /* m_wxwindow only represents the client area without toolbar and menubar */
     m_wxwindow = gtk_myfixed_new();
@@ -293,37 +334,11 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
 
     PostCreation();
 
-    gtk_widget_realize( m_widget );
+    /*  we cannot set MWM hints  before the widget has
+        been realized, so we do this directly after realization */
+    gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
+                       GTK_SIGNAL_FUNC(gtk_frame_realized_callback), (gpointer) this );
     
-    /* all this is for Motif Window Manager "hints" and is supposed to be
-       recognized by other WM as well. not tested. */
-    long decor = (long) GDK_DECOR_ALL;
-    long func = (long) GDK_FUNC_ALL;
-    
-    if ((m_windowStyle & wxCAPTION) == 0)
-       decor |= GDK_DECOR_TITLE;
-/*  if ((m_windowStyle & wxMINIMIZE) == 0)
-       func |= GDK_FUNC_MINIMIZE;
-    if ((m_windowStyle & wxMAXIMIZE) == 0)
-       func |= GDK_FUNC_MAXIMIZE;            */
-    if ((m_windowStyle & wxSYSTEM_MENU) == 0)
-       decor |= GDK_DECOR_MENU;
-    if ((m_windowStyle & wxMINIMIZE_BOX) == 0)
-       decor |= GDK_DECOR_MINIMIZE;
-    if ((m_windowStyle & wxMAXIMIZE_BOX) == 0)
-       decor |= GDK_DECOR_MAXIMIZE;
-    if ((m_windowStyle & wxRESIZE_BORDER) == 0)
-       func |= GDK_FUNC_RESIZE;
-       
-    gdk_window_set_decorations(m_widget->window, (GdkWMDecoration)decor);
-    gdk_window_set_functions(m_widget->window, (GdkWMFunction)func);
-      
-    /* GTK's shrinking/growing policy */
-    if ((m_windowStyle & wxRESIZE_BORDER) == 0)
-        gtk_window_set_policy(GTK_WINDOW(m_widget), 0, 0, 1);
-    else
-        gtk_window_set_policy(GTK_WINDOW(m_widget), 1, 1, 1);
-       
     /* the user resized the frame by dragging etc. */
     gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
         GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this );
index e20908585c2d0eb6e17acda08293a000e122ba03..138fc38d96d1ed72ff6195f22c375807ebb055e9 100644 (file)
@@ -274,8 +274,6 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
 
     PostCreation();
 
-    gtk_widget_realize( GTK_WIDGET(m_list) );
-
     SetBackgroundColour( parent->GetBackgroundColour() );
     SetForegroundColour( parent->GetForegroundColour() );
     SetFont( parent->GetFont() );
@@ -411,8 +409,6 @@ void wxListBox::AppendCommon( const wxString &item )
         gtk_signal_connect( GTK_OBJECT(list_item), "deselect",
           GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
 
-    if (m_widgetStyle) ApplyWidgetStyle();
-
     gtk_signal_connect( GTK_OBJECT(list_item),
                         "button_press_event",
                         (GtkSignalFunc)gtk_listbox_button_press_callback,
@@ -430,15 +426,23 @@ void wxListBox::AppendCommon( const wxString &item )
 
     ConnectWidget( list_item );
 
+    if (GTK_WIDGET_REALIZED(m_widget))
+    {
+        gtk_widget_realize( list_item );
+        gtk_widget_realize( GTK_BIN(list_item)->child );
+       
+        if (m_widgetStyle) ApplyWidgetStyle();
+
 #if wxUSE_DRAG_AND_DROP
 #ifndef NEW_GTK_DND_CODE
-    if (m_dropTarget) m_dropTarget->RegisterWidget( list_item );
+        if (m_dropTarget) m_dropTarget->RegisterWidget( list_item );
 #endif
 #endif
 
 #if wxUSE_TOOLTIPS
-    if (m_toolTip) m_toolTip->Apply( this );
+        if (m_toolTip) m_toolTip->Apply( this );
 #endif
+    }
 }
 
 void wxListBox::Append( const wxString &item )
index 364487fafcfb13b9f606a6c4fb26eab3f29012c8..eb13d01f4646f2f0562ee20ba90dacd0bc683fe5 100644 (file)
@@ -109,9 +109,9 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation*
         (win->m_width == alloc->width) &&
         (win->m_height == alloc->height))
     {
-        return;
+//        return;
     }
-
+    
     win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height );
 
     if (win->GetAutoLayout()) win->Layout();
index a84758ad857499ef211c6ea32599f99e7638b7a5..2c6b88d560f54793866b99880f0d73fe5cd147ce 100644 (file)
@@ -1294,6 +1294,40 @@ static gint gtk_scrollbar_button_release_callback( GtkRange *widget,
     return FALSE;
 }
 
+//-----------------------------------------------------------------------------
+// "realize" from m_widget
+//-----------------------------------------------------------------------------
+
+/* we cannot set colours, fonts and cursors before the widget has
+   been realized, so we do this directly after realization */
+
+static gint 
+gtk_window_realized_callback( GtkWidget *widget, wxWindow *win )
+{
+    if (win->m_font != *wxSWISS_FONT)
+    {
+        wxFont font( win->m_font );
+        win->m_font = wxNullFont;
+       win->SetFont( font );
+    }
+    
+    if (win->m_backgroundColour != wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ))
+    {
+        wxColour bg( win->m_backgroundColour );
+       win->m_backgroundColour = wxNullColour;
+       win->SetBackgroundColour( bg );
+    }
+    
+    if (win->m_foregroundColour != *wxBLACK)
+    {
+        wxColour fg( win->m_foregroundColour );
+       win->m_foregroundColour = wxNullColour;
+       win->SetForegroundColour( fg );
+    }
+    
+    return FALSE;
+}
+    
 //-----------------------------------------------------------------------------
 // InsertChild for wxWindow.
 //-----------------------------------------------------------------------------
@@ -1750,13 +1784,12 @@ void wxWindow::PostCreation()
 
     ConnectWidget( GetConnectWidget() );
 
-    /* we force the creation of wxFrame and wxDialog in the respective code */
-    if (m_parent) gtk_widget_realize( m_widget );
-
-    if (m_wxwindow) gtk_widget_realize( m_wxwindow );
-
-    SetCursor( *wxSTANDARD_CURSOR );
-
+/*  we cannot set colours, fonts and cursors before the widget has
+    been realized, so we do this directly after realization */
+   
+    gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
+                           GTK_SIGNAL_FUNC(gtk_window_realized_callback), (gpointer) this );
+                           
     m_hasVMT = TRUE;
 }
 
@@ -2071,6 +2104,8 @@ void wxWindow::ClientToScreen( int *x, int *y )
 {
     wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
 
+    if (!m_widget->window) return;
+
     GdkWindow *source = (GdkWindow *) NULL;
     if (m_wxwindow)
         source = m_wxwindow->window;
@@ -2098,6 +2133,8 @@ void wxWindow::ScreenToClient( int *x, int *y )
 {
     wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
 
+    if (!m_widget->window) return;
+
     GdkWindow *source = (GdkWindow *) NULL;
     if (m_wxwindow)
         source = m_wxwindow->window;
@@ -2351,6 +2388,8 @@ void wxWindow::Raise()
 {
     wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
 
+    if (!m_widget->window) return;
+
     if (m_widget) gdk_window_raise( m_widget->window );
 }
 
@@ -2358,6 +2397,8 @@ void wxWindow::Lower()
 {
     wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
 
+    if (!m_widget->window) return;
+
     if (m_widget) gdk_window_lower( m_widget->window );
 }
 
@@ -2459,8 +2500,9 @@ void wxWindow::SetCursor( const wxCursor &cursor )
         *m_cursor = *wxSTANDARD_CURSOR;
     }
 
-    if ((m_widget) && (m_widget->window))
-         gdk_window_set_cursor( m_widget->window, m_cursor->GetCursor() );
+    if (!m_widget->window) return;
+
+    gdk_window_set_cursor( m_widget->window, m_cursor->GetCursor() );
 
     if ((m_wxwindow) && (m_wxwindow->window))
          gdk_window_set_cursor( m_wxwindow->window, m_cursor->GetCursor() );
@@ -2475,6 +2517,8 @@ void wxWindow::Refresh( bool eraseBackground, const wxRect *rect )
 {
     wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
 
+    if (!m_widget->window) return;
+
     if (eraseBackground && m_wxwindow && m_wxwindow->window)
     {
         if (rect)
@@ -2540,6 +2584,8 @@ void wxWindow::Clear()
 {
     wxCHECK_RET( m_widget != NULL, _T("invalid window") );
 
+    if (!m_widget->window) return;
+
     if (m_wxwindow && m_wxwindow->window)
     {
         gdk_window_clear( m_wxwindow->window );
@@ -2596,6 +2642,8 @@ void wxWindow::SetBackgroundColour( const wxColour &colour )
     m_backgroundColour = colour;
     if (!m_backgroundColour.Ok()) return;
 
+    if (!m_widget->window) return;
+
     if (m_wxwindow && m_wxwindow->window)
     {
        /* wxMSW doesn't clear the window here. I don't do that
@@ -2636,6 +2684,8 @@ void wxWindow::SetForegroundColour( const wxColour &colour )
     m_foregroundColour = colour;
     if (!m_foregroundColour.Ok()) return;
 
+    if (!m_widget->window) return;
+
     wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
     if (sysbg.Red() == colour.Red() &&
         sysbg.Green() == colour.Green() &&
@@ -2896,6 +2946,8 @@ void wxWindow::CaptureMouse()
 
     wxCHECK_RET( g_capturing == FALSE, _T("CaptureMouse called twice") );
 
+    if (!m_widget->window) return;
+
     GtkWidget *connect_widget = GetConnectWidget();
     gtk_grab_add( connect_widget );
     gdk_pointer_grab( connect_widget->window, FALSE,
@@ -2915,6 +2967,8 @@ void wxWindow::ReleaseMouse()
 
     wxCHECK_RET( g_capturing == TRUE, _T("ReleaseMouse called twice") );
 
+    if (!m_widget->window) return;
+
     GtkWidget *connect_widget = GetConnectWidget();
     gtk_grab_remove( connect_widget );
     gdk_pointer_ungrab ( GDK_CURRENT_TIME );