]> git.saurik.com Git - wxWidgets.git/commitdiff
implemented tab order in wxGTK2
authorVáclav Slavík <vslavik@fastmail.fm>
Sat, 3 Jul 2004 11:16:03 +0000 (11:16 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Sat, 3 Jul 2004 11:16:03 +0000 (11:16 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28151 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/gtk/window.h
include/wx/gtk1/window.h
src/gtk/window.cpp
src/gtk1/window.cpp

index 3d888c0b396b2f1e3ace0277cdddb6e043856093..ebc2120620db4ac6ba395d4764c97108e5ce94c3 100644 (file)
@@ -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,
index 3d888c0b396b2f1e3ace0277cdddb6e043856093..ebc2120620db4ac6ba395d4764c97108e5ce94c3 100644 (file)
@@ -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,
index 2aa4d322f3a45413dce65daf7f6f69acb916be40..8e6e0f5a81628427ef793148df463cdd8793ea41 100644 (file)
@@ -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") );
index 2aa4d322f3a45413dce65daf7f6f69acb916be40..8e6e0f5a81628427ef793148df463cdd8793ea41 100644 (file)
@@ -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") );