+#endif
+}
+
+void wxWindowGTK::SetFocus()
+{
+ wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
+ if ( m_hasFocus )
+ {
+ // don't do anything if we already have focus
+ return;
+ }
+
+ if (m_wxwindow)
+ {
+ if (!GTK_WIDGET_HAS_FOCUS (m_wxwindow))
+ {
+ gtk_widget_grab_focus (m_wxwindow);
+ }
+ }
+ else if (m_widget)
+ {
+#ifdef __WXGTK20__
+ if (GTK_IS_CONTAINER(m_widget))
+ {
+ gtk_widget_child_focus( m_widget, GTK_DIR_TAB_FORWARD );
+ }
+ else
+#endif
+ if (GTK_WIDGET_CAN_FOCUS(m_widget) && !GTK_WIDGET_HAS_FOCUS (m_widget) )
+ {
+
+ if (!GTK_WIDGET_REALIZED(m_widget))
+ {
+ // we can't set the focus to the widget now so we remember that
+ // it should be focused and will do it later, during the idle
+ // time, as soon as we can
+ wxLogTrace(TRACE_FOCUS,
+ _T("Delaying setting focus to %s(%s)"),
+ GetClassInfo()->GetClassName(), GetLabel().c_str());
+
+ g_delayedFocus = this;
+ }
+ else
+ {
+ wxLogTrace(TRACE_FOCUS,
+ _T("Setting focus to %s(%s)"),
+ GetClassInfo()->GetClassName(), GetLabel().c_str());
+
+ gtk_widget_grab_focus (m_widget);
+ }
+ }
+ else
+#ifndef __WXGTK20__
+ if (GTK_IS_CONTAINER(m_widget))
+ {
+ gtk_container_focus( GTK_CONTAINER(m_widget), GTK_DIR_TAB_FORWARD );
+ }
+ else
+#endif
+ {
+ wxLogTrace(TRACE_FOCUS,
+ _T("Can't set focus to %s(%s)"),
+ GetClassInfo()->GetClassName(), GetLabel().c_str());
+ }
+ }
+}
+
+bool wxWindowGTK::AcceptsFocus() const
+{
+ return m_acceptsFocus && wxWindowBase::AcceptsFocus();
+}
+
+bool wxWindowGTK::Reparent( wxWindowBase *newParentBase )
+{
+ wxCHECK_MSG( (m_widget != NULL), FALSE, wxT("invalid window") );
+
+ wxWindowGTK *oldParent = m_parent,
+ *newParent = (wxWindowGTK *)newParentBase;
+
+ wxASSERT( GTK_IS_WIDGET(m_widget) );
+
+ if ( !wxWindowBase::Reparent(newParent) )
+ return FALSE;
+
+ wxASSERT( GTK_IS_WIDGET(m_widget) );
+
+ /* prevent GTK from deleting the widget arbitrarily */
+ gtk_widget_ref( m_widget );
+
+ if (oldParent)
+ {
+ gtk_container_remove( GTK_CONTAINER(m_widget->parent), m_widget );
+ }
+
+ wxASSERT( GTK_IS_WIDGET(m_widget) );
+
+ if (newParent)
+ {
+ /* insert GTK representation */
+ (*(newParent->m_insertCallback))(newParent, this);
+ }
+
+ /* reverse: prevent GTK from deleting the widget arbitrarily */
+ gtk_widget_unref( m_widget );
+
+ return TRUE;
+}
+
+void wxWindowGTK::DoAddChild(wxWindowGTK *child)
+{
+ wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") );
+
+ wxASSERT_MSG( (child != NULL), wxT("invalid child window") );
+
+ wxASSERT_MSG( (m_insertCallback != NULL), wxT("invalid child insertion function") );
+
+ /* add to list */
+ AddChild( child );
+
+ /* insert GTK representation */
+ (*m_insertCallback)(this, child);
+}
+
+#ifdef __WXGTK20__
+
+void wxWindowGTK::AddChild(wxWindowBase *child)
+{
+ wxWindowBase::AddChild(child);
+ m_dirtyTabOrder = true;
+ if (g_isIdle)
+ wxapp_install_idle_handler();
+}
+
+void wxWindowGTK::RemoveChild(wxWindowBase *child)
+{
+ wxWindowBase::RemoveChild(child);
+ m_dirtyTabOrder = true;
+ if (g_isIdle)
+ wxapp_install_idle_handler();
+}
+
+void wxWindowGTK::DoMoveInTabOrder(wxWindow *win, MoveKind move)
+{
+ wxWindowBase::DoMoveInTabOrder(win, move);
+ m_dirtyTabOrder = true;
+ if (g_isIdle)
+ wxapp_install_idle_handler();
+}
+
+void wxWindowGTK::RealizeTabOrder()
+{
+ if (m_wxwindow)
+ {
+ if (m_children.size() > 0)
+ {
+ GList *chain = NULL;
+
+ for (wxWindowList::const_iterator i = m_children.begin();
+ i != m_children.end(); ++i)
+ {
+ chain = g_list_prepend(chain, (*i)->m_widget);
+ }
+
+ chain = g_list_reverse(chain);
+
+ gtk_container_set_focus_chain(GTK_CONTAINER(m_wxwindow), chain);
+ g_list_free(chain);
+ }
+ else
+ {
+ gtk_container_unset_focus_chain(GTK_CONTAINER(m_wxwindow));
+ }
+ }
+
+ m_dirtyTabOrder = false;
+}
+
+#endif // __WXGTK20__
+
+void wxWindowGTK::Raise()
+{
+ wxCHECK_RET( (m_widget != NULL), wxT("invalid window") );
+
+ if (m_wxwindow && m_wxwindow->window)
+ {
+ gdk_window_raise( m_wxwindow->window );
+ }
+ else if (m_widget->window)
+ {
+ gdk_window_raise( m_widget->window );
+ }
+}
+
+void wxWindowGTK::Lower()
+{
+ wxCHECK_RET( (m_widget != NULL), wxT("invalid window") );
+
+ if (m_wxwindow && m_wxwindow->window)
+ {
+ gdk_window_lower( m_wxwindow->window );
+ }
+ else if (m_widget->window)
+ {
+ gdk_window_lower( m_widget->window );
+ }
+}
+
+bool wxWindowGTK::SetCursor( const wxCursor &cursor )
+{
+ wxCHECK_MSG( (m_widget != NULL), FALSE, wxT("invalid window") );
+
+ if (cursor == m_cursor)
+ return FALSE;
+
+ if (g_isIdle)
+ wxapp_install_idle_handler();
+
+ if (cursor == wxNullCursor)
+ return wxWindowBase::SetCursor( *wxSTANDARD_CURSOR );
+ else
+ return wxWindowBase::SetCursor( cursor );
+}
+
+void wxWindowGTK::WarpPointer( int x, int y )
+{
+ wxCHECK_RET( (m_widget != NULL), wxT("invalid window") );
+
+ // We provide this function ourselves as it is
+ // missing in GDK (top of this file).
+
+ GdkWindow *window = (GdkWindow*) NULL;
+ if (m_wxwindow)
+ window = GTK_PIZZA(m_wxwindow)->bin_window;
+ else
+ window = GetConnectWidget()->window;
+
+ if (window)
+ gdk_window_warp_pointer( window, x, y );