X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1e6feb95a79834836e88143b15d9f424ebe79621..625cb8c0b1ac12f26265cae2c69d7f510de0edb1:/src/gtk/window.cpp diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index ce6e688621..8a1f5c0cb9 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -38,6 +38,10 @@ #include "wx/caret.h" #endif // wxUSE_CARET +#if wxUSE_TEXTCTRL +#include "wx/textctrl.h" +#endif + #include "wx/menu.h" #include "wx/statusbr.h" #include "wx/intl.h" @@ -333,25 +337,25 @@ extern bool g_isIdle; // returns the child of win which currently has focus or NULL if not found // // Note: can't be static, needed by textctrl.cpp. -wxWindow *FindFocusedChild(wxWindowGTK *win) +wxWindow *wxFindFocusedChild(wxWindowGTK *win) { - wxWindowGTK *winFocus = wxWindowGTK::FindFocus(); + wxWindow *winFocus = wxWindowGTK::FindFocus(); if ( !winFocus ) - return (wxWindowGTK *)NULL; + return (wxWindow *)NULL; if ( winFocus == win ) - return win; + return (wxWindow *)win; for ( wxWindowList::Node *node = win->GetChildren().GetFirst(); node; node = node->GetNext() ) { - wxWindowGTK *child = FindFocusedChild(node->GetData()); + wxWindow *child = wxFindFocusedChild(node->GetData()); if ( child ) return child; } - return (wxWindowGTK *)NULL; + return (wxWindow *)NULL; } static void draw_frame( GtkWidget *widget, wxWindowGTK *win ) @@ -1688,11 +1692,10 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget, printf( ".\n" ); */ - wxPanel *panel = wxDynamicCast(win->GetParent(), wxPanel); - if (panel) - { - panel->SetLastFocus(win); - } + // notify the parent keeping track of focus for the kbd navigation + // purposes that we got it + wxChildFocusEvent eventFocus(win); + (void)win->GetEventHandler()->ProcessEvent(eventFocus); #ifdef HAVE_XIM if (win->m_ic) @@ -1708,6 +1711,16 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget, } #endif // wxUSE_CARET +#if wxUSE_TEXTCTRL + // If it's a wxTextCtrl don't send the event as it will be done + // after the control gets to process it. + wxTextCtrl *ctrl = wxDynamicCast(win, wxTextCtrl); + if ( ctrl ) + { + return FALSE; + } +#endif + if (win->IsTopLevel()) { wxActivateEvent event( wxEVT_ACTIVATE, TRUE, win->GetId() ); @@ -1749,7 +1762,7 @@ static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED // g_sendActivateEvent to -1 g_sendActivateEvent = 0; - wxWindowGTK *winFocus = FindFocusedChild(win); + wxWindowGTK *winFocus = wxFindFocusedChild(win); if ( winFocus ) win = winFocus; @@ -1776,6 +1789,16 @@ static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED } #endif // wxUSE_CARET +#if wxUSE_TEXTCTRL + // If it's a wxTextCtrl don't send the event as it will be done + // after the control gets to process it. + wxTextCtrl *ctrl = wxDynamicCast(win, wxTextCtrl); + if ( ctrl ) + { + return FALSE; + } +#endif + if (win->IsTopLevel()) { wxActivateEvent event( wxEVT_ACTIVATE, FALSE, win->GetId() ); @@ -2260,11 +2283,13 @@ wxWindow *wxGetActiveWindow() // wxWindowGTK //----------------------------------------------------------------------------- +// in wxUniv/MSW this class is abstract because it doesn't have DoPopupMenu() +// method #ifdef __WXUNIVERSAL__ - IMPLEMENT_DYNAMIC_CLASS(wxWindowGTK, wxWindowBase) -#else + IMPLEMENT_ABSTRACT_CLASS(wxWindowGTK, wxWindowBase) +#else // __WXGTK__ IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase) -#endif +#endif // __WXUNIVERSAL__/__WXGTK__ void wxWindowGTK::Init() { @@ -3067,7 +3092,7 @@ bool wxWindowGTK::Show( bool show ) return TRUE; } -static void wxWindowNotifyEnable(wxWindow* win, bool enable) +static void wxWindowNotifyEnable(wxWindowGTK* win, bool enable) { win->OnParentEnable(enable); @@ -3084,7 +3109,7 @@ static void wxWindowNotifyEnable(wxWindow* win, bool enable) } } -bool wxWindow::Enable( bool enable ) +bool wxWindowGTK::Enable( bool enable ) { wxCHECK_MSG( (m_widget != NULL), FALSE, wxT("invalid window") ); @@ -3394,7 +3419,7 @@ void wxWindowGTK::DoSetToolTip( wxToolTip *tip ) wxWindowBase::DoSetToolTip(tip); if (m_tooltip) - m_tooltip->Apply( this ); + m_tooltip->Apply( (wxWindow *)this ); } void wxWindowGTK::ApplyToolTip( GtkTooltips *tips, const wxChar *tip ) @@ -3605,7 +3630,7 @@ void wxWindowGTK::ApplyWidgetStyle() // Pop-up menu stuff //----------------------------------------------------------------------------- -#if wxUSE_MENUS +#if wxUSE_MENUS_NATIVE static void gtk_pop_hide_callback( GtkWidget *WXUNUSED(widget), bool* is_waiting ) { @@ -3677,7 +3702,7 @@ bool wxWindowGTK::DoPopupMenu( wxMenu *menu, int x, int y ) return TRUE; } -#endif // wxUSE_MENUS +#endif // wxUSE_MENUS_NATIVE #if wxUSE_DRAG_AND_DROP @@ -3741,15 +3766,13 @@ void wxWindowGTK::CaptureMouse() { wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); - wxCHECK_RET( g_captureWindow == NULL, wxT("CaptureMouse called twice") ); - GdkWindow *window = (GdkWindow*) NULL; if (m_wxwindow) window = GTK_PIZZA(m_wxwindow)->bin_window; else window = GetConnectWidget()->window; - if (!window) return; + wxCHECK_RET( window, _T("CaptureMouse() failed") ); wxCursor* cursor = & m_cursor; if (!cursor->Ok()) @@ -3772,7 +3795,7 @@ void wxWindowGTK::ReleaseMouse() { wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); - wxCHECK_RET( g_captureWindow, wxT("ReleaseMouse called twice") ); + wxCHECK_RET( g_captureWindow, wxT("can't release mouse - not captured") ); GdkWindow *window = (GdkWindow*) NULL; if (m_wxwindow)