X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/61f0bec0cd812de8ed7e50dff6a269043e49c7a2..bfab25d4c41327d6db170be1f832821f36cd425f:/src/gtk/window.cpp diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index ae474682b5..1d4834b108 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: gtk/window.cpp +// Name: src/gtk/window.cpp // Purpose: // Author: Robert Roebling // Id: $Id$ @@ -50,7 +50,6 @@ #include "wx/settings.h" #include "wx/log.h" #include "wx/fontutil.h" -#include "wx/stattext.h" #ifdef __WXDEBUG__ #include "wx/thread.h" @@ -282,13 +281,6 @@ gdk_window_warp_pointer (GdkWindow *window, } } -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - //----------------------------------------------------------------------------- // local code (see below) //----------------------------------------------------------------------------- @@ -659,11 +651,11 @@ static long wxTranslateKeySymToWXKey(KeySym keysym, bool isChar) break; case GDK_Prior: // == GDK_Page_Up - key_code = WXK_PRIOR; + key_code = WXK_PAGEUP; break; case GDK_Next: // == GDK_Page_Down - key_code = WXK_NEXT; + key_code = WXK_PAGEDOWN; break; case GDK_End: @@ -742,11 +734,11 @@ static long wxTranslateKeySymToWXKey(KeySym keysym, bool isChar) break; case GDK_KP_Prior: // == GDK_KP_Page_Up - key_code = isChar ? WXK_PRIOR : WXK_NUMPAD_PRIOR; + key_code = isChar ? WXK_PAGEUP : WXK_NUMPAD_PAGEUP; break; case GDK_KP_Next: // == GDK_KP_Page_Down - key_code = isChar ? WXK_NEXT : WXK_NUMPAD_NEXT; + key_code = isChar ? WXK_PAGEDOWN : WXK_NUMPAD_PAGEDOWN; break; case GDK_KP_End: @@ -1762,7 +1754,7 @@ gtk_window_motion_notify_callback( GtkWidget *widget, // Rewrite cursor handling here (away from idle). } } - + if (win->GetEventHandler()->ProcessEvent( event )) { g_signal_stop_emission_by_name (widget, "motion_notify_event"); @@ -2031,7 +2023,7 @@ gtk_window_enter_callback( GtkWidget *widget, // Rewrite cursor handling here (away from idle). } } - + if (win->GetEventHandler()->ProcessEvent( event )) { g_signal_stop_emission_by_name (widget, "enter_notify_event"); @@ -2950,7 +2942,7 @@ void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags if (GTK_WIDGET_VISIBLE (widget)) gtk_widget_queue_resize (widget); } - else + else #endif if (m_parent->m_wxwindow == NULL) // i.e. wxNotebook { @@ -3613,44 +3605,62 @@ void wxWindowGTK::DoMoveInTabOrder(wxWindow *win, MoveKind move) wxapp_install_idle_handler(); } +bool wxWindowGTK::GTKWidgetNeedsMnemonic() const +{ + // none needed by default + return false; +} + +void wxWindowGTK::GTKWidgetDoSetMnemonic(GtkWidget* WXUNUSED(w)) +{ + // nothing to do by default since none is needed +} + void wxWindowGTK::RealizeTabOrder() { if (m_wxwindow) { if ( !m_children.empty() ) { -#if wxUSE_STATTEXT // we don't only construct the correct focus chain but also use - // this opportunity to update the mnemonic widgets for all labels - // - // it would be nice to extract this code from here and put it in - // stattext.cpp to reduce dependencies but there is no really easy - // way to do it unfortunately - wxStaticText *lastLabel = NULL; -#endif // wxUSE_STATTEXT + // this opportunity to update the mnemonic widgets for the widgets + // that need them GList *chain = NULL; + wxWindowGTK* mnemonicWindow = NULL; for ( wxWindowList::const_iterator i = m_children.begin(); i != m_children.end(); ++i ) { wxWindowGTK *win = *i; -#if wxUSE_STATTEXT - if ( lastLabel ) + + if ( mnemonicWindow ) { if ( win->AcceptsFocusFromKeyboard() ) { - GtkLabel *l = GTK_LABEL(lastLabel->m_widget); - gtk_label_set_mnemonic_widget(l, win->m_widget); - lastLabel = NULL; + // wxComboBox et al. needs to focus on on a different + // widget than m_widget, so if the main widget isn't + // focusable try the connect widget + GtkWidget* w = win->m_widget; + if ( !GTK_WIDGET_CAN_FOCUS(w) ) + { + w = win->GetConnectWidget(); + if ( !GTK_WIDGET_CAN_FOCUS(w) ) + w = NULL; + } + + if ( w ) + { + mnemonicWindow->GTKWidgetDoSetMnemonic(w); + mnemonicWindow = NULL; + } } } - else // check if this one is a label + else if ( win->GTKWidgetNeedsMnemonic() ) { - lastLabel = wxDynamicCast(win, wxStaticText); + mnemonicWindow = win; } -#endif // wxUSE_STATTEXT chain = g_list_prepend(chain, win->m_widget); } @@ -4419,4 +4429,3 @@ void wxWinModule::OnExit() if (g_eraseGC) gdk_gc_unref( g_eraseGC ); } -