From a589495eeb083bee99e4c92f8ff4e12457ca82bb Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sat, 3 Jul 2004 11:16:03 +0000 Subject: [PATCH] implemented tab order in wxGTK2 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28151 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/window.h | 16 +++++++++++ include/wx/gtk1/window.h | 16 +++++++++++ src/gtk/window.cpp | 62 ++++++++++++++++++++++++++++++++++++++++ src/gtk1/window.cpp | 62 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 156 insertions(+) diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index 3d888c0b39..ebc2120620 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -105,6 +105,11 @@ public: #if wxUSE_DRAG_AND_DROP virtual void SetDropTarget( wxDropTarget *dropTarget ); #endif // wxUSE_DRAG_AND_DROP + +#ifdef __WXGTK20__ + virtual void AddChild( wxWindowBase *child ); + virtual void RemoveChild( wxWindowBase *child ); +#endif // implementation // -------------- @@ -229,6 +234,10 @@ public: bool m_hasFocus:1; // true if == FindFocus() bool m_isScrolling:1; // dragging scrollbar thumb? bool m_clipPaintRegion:1; // TRUE after ScrollWindow() +#ifdef __WXGTK20__ + bool m_dirtyTabOrder:1; // tab order changed, GTK focus + // chain needs update +#endif // C++ has no virtual methods in the constrcutor of any class but we need // different methods of inserting a child window into a wxFrame, @@ -258,6 +267,13 @@ protected: // common part of all ctors (not virtual because called from ctor) void Init(); +#ifdef __WXGTK20__ + virtual void DoMoveInTabOrder(wxWindow *win, MoveKind move); + + // Copies m_children tab order to GTK focus chain: + void RealizeTabOrder(); +#endif + // Called by ApplyWidgetStyle (which is called by SetFont() and // SetXXXColour etc to apply style changed to native widgets) to create // modified GTK style with non-standard attributes. If forceStyle=true, diff --git a/include/wx/gtk1/window.h b/include/wx/gtk1/window.h index 3d888c0b39..ebc2120620 100644 --- a/include/wx/gtk1/window.h +++ b/include/wx/gtk1/window.h @@ -105,6 +105,11 @@ public: #if wxUSE_DRAG_AND_DROP virtual void SetDropTarget( wxDropTarget *dropTarget ); #endif // wxUSE_DRAG_AND_DROP + +#ifdef __WXGTK20__ + virtual void AddChild( wxWindowBase *child ); + virtual void RemoveChild( wxWindowBase *child ); +#endif // implementation // -------------- @@ -229,6 +234,10 @@ public: bool m_hasFocus:1; // true if == FindFocus() bool m_isScrolling:1; // dragging scrollbar thumb? bool m_clipPaintRegion:1; // TRUE after ScrollWindow() +#ifdef __WXGTK20__ + bool m_dirtyTabOrder:1; // tab order changed, GTK focus + // chain needs update +#endif // C++ has no virtual methods in the constrcutor of any class but we need // different methods of inserting a child window into a wxFrame, @@ -258,6 +267,13 @@ protected: // common part of all ctors (not virtual because called from ctor) void Init(); +#ifdef __WXGTK20__ + virtual void DoMoveInTabOrder(wxWindow *win, MoveKind move); + + // Copies m_children tab order to GTK focus chain: + void RealizeTabOrder(); +#endif + // Called by ApplyWidgetStyle (which is called by SetFont() and // SetXXXColour etc to apply style changed to native widgets) to create // modified GTK style with non-standard attributes. If forceStyle=true, diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 2aa4d322f3..8e6e0f5a81 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -2655,6 +2655,7 @@ void wxWindowGTK::Init() #ifdef __WXGTK20__ m_imData = NULL; m_x11Context = NULL; + m_dirtyTabOrder = false; #else #ifdef HAVE_XIM m_ic = (GdkIC*) NULL; @@ -3116,6 +3117,11 @@ void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags void wxWindowGTK::OnInternalIdle() { +#ifdef __WXGTK20__ + if ( m_dirtyTabOrder ) + RealizeTabOrder(); +#endif + // Update invalidated regions. GtkUpdate(); @@ -3705,6 +3711,62 @@ void wxWindowGTK::DoAddChild(wxWindowGTK *child) (*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") ); diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 2aa4d322f3..8e6e0f5a81 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -2655,6 +2655,7 @@ void wxWindowGTK::Init() #ifdef __WXGTK20__ m_imData = NULL; m_x11Context = NULL; + m_dirtyTabOrder = false; #else #ifdef HAVE_XIM m_ic = (GdkIC*) NULL; @@ -3116,6 +3117,11 @@ void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags void wxWindowGTK::OnInternalIdle() { +#ifdef __WXGTK20__ + if ( m_dirtyTabOrder ) + RealizeTabOrder(); +#endif + // Update invalidated regions. GtkUpdate(); @@ -3705,6 +3711,62 @@ void wxWindowGTK::DoAddChild(wxWindowGTK *child) (*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") ); -- 2.45.2