#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"
// 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 )
switch ( g_sendActivateEvent )
{
case -1:
- // we've got focus from outside, synthtize wxActivateEvent
+ // we've got focus from outside, synthetize wxActivateEvent
g_sendActivateEvent = 1;
break;
g_focusWindowLast =
g_focusWindow = win;
-/*
- printf( "OnSetFocus from " );
+#if 0
+ wxPrintf( "OnSetFocus from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
- printf( win->GetClassInfo()->GetClassName() );
- printf( " " );
- printf( WXSTRINGCAST win->GetLabel() );
- printf( ".\n" );
-*/
+ wxPrintf( win->GetClassInfo()->GetClassName() );
+ wxPrintf( ".\n" );
+#endif
- 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)
// g_sendActivateEvent to -1
g_sendActivateEvent = 0;
- wxWindowGTK *winFocus = FindFocusedChild(win);
+ wxWindowGTK *winFocus = wxFindFocusedChild(win);
if ( winFocus )
win = winFocus;
g_focusWindow = (wxWindowGTK *)NULL;
-/*
- printf( "OnKillFocus from " );
+#if 0
+ wxPrintf( "OnKillFocus from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
- printf( win->GetClassInfo()->GetClassName() );
- printf( ".\n" );
-*/
+ wxPrintf( win->GetClassInfo()->GetClassName() );
+ wxPrintf( ".\n" );
+#endif
#ifdef HAVE_XIM
if (win->m_ic)
if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE;
wxMouseEvent event( wxEVT_ENTER_WINDOW );
-#if (GTK_MINOR_VERSION > 0)
event.SetTimestamp( gdk_event->time );
-#endif
event.SetEventObject( win );
int x = 0;
if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE;
wxMouseEvent event( wxEVT_LEAVE_WINDOW );
-#if (GTK_MINOR_VERSION > 0)
event.SetTimestamp( gdk_event->time );
-#endif
event.SetEventObject( win );
int x = 0;
// 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()
{
// GTK specific
m_widget = (GtkWidget *) NULL;
m_wxwindow = (GtkWidget *) NULL;
+ m_focusWidget = (GtkWidget *) NULL;
// position/size
m_x = 0;
m_noExpose = FALSE;
m_nativeSizeEvent = FALSE;
-
+
m_hasScrolling = FALSE;
m_isScrolling = FALSE;
if (m_parent)
m_parent->DoAddChild( this );
+
+ m_focusWidget = m_wxwindow;
PostCreation();
void wxWindowGTK::PostCreation()
{
wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") );
-
+
if (m_wxwindow)
{
if (!m_noExpose)
{
- /* these get reported to wxWindows -> wxPaintEvent */
+ // these get reported to wxWindows -> wxPaintEvent
gtk_pizza_set_external( GTK_PIZZA(m_wxwindow), TRUE );
}
}
-#if (GTK_MINOR_VERSION > 0)
- /* these are called when the "sunken" or "raised" borders are drawn */
+ // these are called when the "sunken" or "raised" borders are drawn */
gtk_signal_connect( GTK_OBJECT(m_widget), "expose_event",
GTK_SIGNAL_FUNC(gtk_window_own_expose_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(m_widget), "draw",
GTK_SIGNAL_FUNC(gtk_window_own_draw_callback), (gpointer)this );
-#endif
}
- if (m_wxwindow && m_needParent)
- {
- gtk_signal_connect( GTK_OBJECT(m_wxwindow), "focus_in_event",
- GTK_SIGNAL_FUNC(gtk_window_focus_in_callback), (gpointer)this );
+ // focus handling
- gtk_signal_connect( GTK_OBJECT(m_wxwindow), "focus_out_event",
- GTK_SIGNAL_FUNC(gtk_window_focus_out_callback), (gpointer)this );
- }
- else
- {
- // For dialogs and frames, we are interested mainly in
- // m_widget's focus.
+ if (m_focusWidget == NULL)
+ m_focusWidget = m_widget;
+
+#if 0
+ if (GetClassInfo() && GetClassInfo()->GetClassName())
+ wxPrintf( GetClassInfo()->GetClassName() );
+ wxPrintf( ".\n" );
+#endif
- gtk_signal_connect( GTK_OBJECT(m_widget), "focus_in_event",
- GTK_SIGNAL_FUNC(gtk_window_focus_in_callback), (gpointer)this );
+ gtk_signal_connect( GTK_OBJECT(m_focusWidget), "focus_in_event",
+ GTK_SIGNAL_FUNC(gtk_window_focus_in_callback), (gpointer)this );
- gtk_signal_connect( GTK_OBJECT(m_widget), "focus_out_event",
- GTK_SIGNAL_FUNC(gtk_window_focus_out_callback), (gpointer)this );
- }
+ gtk_signal_connect( GTK_OBJECT(m_focusWidget), "focus_out_event",
+ GTK_SIGNAL_FUNC(gtk_window_focus_out_callback), (gpointer)this );
+
+ // connect to the various key and mouse handlers
GtkWidget *connect_widget = GetConnectWidget();
return TRUE;
}
-static void wxWindowNotifyEnable(wxWindow* win, bool enable)
+static void wxWindowNotifyEnable(wxWindowGTK* win, bool enable)
{
win->OnParentEnable(enable);
}
}
-bool wxWindow::Enable( bool enable )
+bool wxWindowGTK::Enable( bool enable )
{
wxCHECK_MSG( (m_widget != NULL), FALSE, wxT("invalid window") );
wxWindowBase::DoSetToolTip(tip);
if (m_tooltip)
- m_tooltip->Apply( this );
+ m_tooltip->Apply( (wxWindow *)this );
}
void wxWindowGTK::ApplyToolTip( GtkTooltips *tips, const wxChar *tip )
// Pop-up menu stuff
//-----------------------------------------------------------------------------
-#if wxUSE_MENUS
+#if wxUSE_MENUS_NATIVE
static void gtk_pop_hide_callback( GtkWidget *WXUNUSED(widget), bool* is_waiting )
{
return TRUE;
}
-#endif // wxUSE_MENUS
+#endif // wxUSE_MENUS_NATIVE
#if wxUSE_DRAG_AND_DROP
{
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())
{
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)