Next take at focus vs. keyboard input probs
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1503 
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
     delete wxTheApp;
     wxTheApp = (wxApp*) NULL;
 
     delete wxTheApp;
     wxTheApp = (wxApp*) NULL;
 
+    wxSystemSettings::Done();
+    
+    delete[] wxBuffer;
+
+    wxClassInfo::CleanUpClasses();
+    
     /* check for memory leaks */
 #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
     if (wxDebugContext::CountObjectsLeft() > 0)
     /* check for memory leaks */
 #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
     if (wxDebugContext::CountObjectsLeft() > 0)
     
     wxLog *oldLog = wxLog::SetActiveTarget( (wxLog*) NULL );
     if (oldLog) delete oldLog;
     
     wxLog *oldLog = wxLog::SetActiveTarget( (wxLog*) NULL );
     if (oldLog) delete oldLog;
-
-    wxSystemSettings::Done();
-    
-    wxClassInfo::CleanUpClasses();
-
-    delete[] wxBuffer;
 }
 
 wxLog *wxApp::CreateLogTarget()
 }
 
 wxLog *wxApp::CreateLogTarget()
 
 
 static char *GetResourcePath(char *buf, char *name, bool create)
 {
 
 static char *GetResourcePath(char *buf, char *name, bool create)
 {
-    if (create && FileExists(name)) {
+    if (create && FileExists(name)) 
+    {
         strcpy(buf, name);
         return buf; // Exists so ...
     }
     if (*name == '/')
         strcpy(buf, name);
         strcpy(buf, name);
         return buf; // Exists so ...
     }
     if (*name == '/')
         strcpy(buf, name);
         // Put in standard place for resource files if not absolute
         strcpy(buf, DEFAULT_XRESOURCE_DIR);
         strcat(buf, "/");
         strcat(buf, FileNameFromPath(name));
     }
         // Put in standard place for resource files if not absolute
         strcpy(buf, DEFAULT_XRESOURCE_DIR);
         strcat(buf, "/");
         strcat(buf, FileNameFromPath(name));
     }
         // Touch the file to create it
         FILE *fd = fopen(buf, "w");
         if (fd) fclose(fd);
         // Touch the file to create it
         FILE *fd = fopen(buf, "w");
         if (fd) fclose(fd);
     // window when the server initializes and loaded into the display
     // structure on XOpenDisplay;
     // if not defined, use .Xdefaults
     // window when the server initializes and loaded into the display
     // structure on XOpenDisplay;
     // if not defined, use .Xdefaults
-    if (XResourceManagerString(GDK_DISPLAY()) != NULL) {
+    if (XResourceManagerString(GDK_DISPLAY()) != NULL) 
+    {
         serverDB = XrmGetStringDatabase(XResourceManagerString(GDK_DISPLAY()));
         serverDB = XrmGetStringDatabase(XResourceManagerString(GDK_DISPLAY()));
         (void)GetIniFile(filename, (char *) NULL);
         serverDB = XrmGetFileDatabase(filename);
     }
         (void)GetIniFile(filename, (char *) NULL);
         serverDB = XrmGetFileDatabase(filename);
     }
     // Open XENVIRONMENT file, or if not defined, the .Xdefaults,
     // and merge into existing database
 
     // Open XENVIRONMENT file, or if not defined, the .Xdefaults,
     // and merge into existing database
 
-    if ((environment = getenv("XENVIRONMENT")) == NULL) {
+    if ((environment = getenv("XENVIRONMENT")) == NULL) 
+    {
         size_t len;
         environment = GetIniFile(filename, (const char *) NULL);
         len = strlen(environment);
         size_t len;
         environment = GetIniFile(filename, (const char *) NULL);
         len = strlen(environment);
         wxXMergeDatabases();
 
     XrmDatabase database;
         wxXMergeDatabases();
 
     XrmDatabase database;
-    if ( !file.IsEmpty() ) {
+    if (!file.IsEmpty()) 
+    {
         char buffer[500];
         // Is this right? Trying to get it to look in the user's
         // home directory instead of current directory -- JACS
         char buffer[500];
         // Is this right? Trying to get it to look in the user's
         // home directory instead of current directory -- JACS
 
     bool success = XrmGetResource(database, buf, "*", str_type, &xvalue);
     // Try different combinations of upper/lower case, just in case...
 
     bool success = XrmGetResource(database, buf, "*", str_type, &xvalue);
     // Try different combinations of upper/lower case, just in case...
         buf[0] = (isupper(buf[0]) ? tolower(buf[0]) : toupper(buf[0]));
         success = XrmGetResource(database, buf, "*", str_type,        &xvalue);
     }
         buf[0] = (isupper(buf[0]) ? tolower(buf[0]) : toupper(buf[0]));
         success = XrmGetResource(database, buf, "*", str_type,        &xvalue);
     }
         if (*value)
             delete[] *value;
         *value = new char[xvalue.size + 1];
         if (*value)
             delete[] *value;
         *value = new char[xvalue.size + 1];
 {
     char *s = (char *) NULL;
     bool succ = wxGetResource(section, entry, &s, file);
 {
     char *s = (char *) NULL;
     bool succ = wxGetResource(section, entry, &s, file);
         *value = (float)strtod(s, (char **) NULL);
         delete[]s;
         return TRUE;
         *value = (float)strtod(s, (char **) NULL);
         delete[]s;
         return TRUE;
 {
     char *s = (char *) NULL;
     bool succ = wxGetResource(section, entry, &s, file);
 {
     char *s = (char *) NULL;
     bool succ = wxGetResource(section, entry, &s, file);
         *value = strtol(s, (char **) NULL, 10);
         delete[]s;
         return TRUE;
         *value = strtol(s, (char **) NULL, 10);
         delete[]s;
         return TRUE;
 {
     char *s = (char *) NULL;
     bool succ = wxGetResource(section, entry, &s, file);
 {
     char *s = (char *) NULL;
     bool succ = wxGetResource(section, entry, &s, file);
         // Handle True, False here
         // True, Yes, Enables, Set or  Activated
         if (*s == 'T' || *s == 'Y' || *s == 'E' || *s == 'S' || *s == 'A')
         // Handle True, False here
         // True, Yes, Enables, Set or  Activated
         if (*s == 'T' || *s == 'Y' || *s == 'E' || *s == 'S' || *s == 'A')
 
     {
         parent->m_sizeSet = FALSE;
     }
     {
         parent->m_sizeSet = FALSE;
     }
+    
+    if (parent->m_windowStyle & wxTAB_TRAVERSAL)
+    {
+        /* we now allow a window to get the focus as long as it
+          doesn't have any children. */
+        GTK_WIDGET_UNSET_FLAGS( parent->m_wxwindow, GTK_CAN_FOCUS );  
+    }
 }
 
 //-----------------------------------------------------------------------------
 }
 
 //-----------------------------------------------------------------------------
         gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_NONE );
     }
 
         gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_NONE );
     }
 
-    if ((m_windowStyle & wxTAB_TRAVERSAL) != 0)
+    if (m_windowStyle & wxTAB_TRAVERSAL)
-        GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );  /* changed from UNSET */
+        /* we now allow a window to get the focus as long as it
+          doesn't have any children. */
+        GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );  
         m_acceptsFocus = FALSE;
     }
     else
         m_acceptsFocus = FALSE;
     }
     else
 
     delete wxTheApp;
     wxTheApp = (wxApp*) NULL;
 
     delete wxTheApp;
     wxTheApp = (wxApp*) NULL;
 
+    wxSystemSettings::Done();
+    
+    delete[] wxBuffer;
+
+    wxClassInfo::CleanUpClasses();
+    
     /* check for memory leaks */
 #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
     if (wxDebugContext::CountObjectsLeft() > 0)
     /* check for memory leaks */
 #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
     if (wxDebugContext::CountObjectsLeft() > 0)
     
     wxLog *oldLog = wxLog::SetActiveTarget( (wxLog*) NULL );
     if (oldLog) delete oldLog;
     
     wxLog *oldLog = wxLog::SetActiveTarget( (wxLog*) NULL );
     if (oldLog) delete oldLog;
-
-    wxSystemSettings::Done();
-    
-    wxClassInfo::CleanUpClasses();
-
-    delete[] wxBuffer;
 }
 
 wxLog *wxApp::CreateLogTarget()
 }
 
 wxLog *wxApp::CreateLogTarget()
 
 
 static char *GetResourcePath(char *buf, char *name, bool create)
 {
 
 static char *GetResourcePath(char *buf, char *name, bool create)
 {
-    if (create && FileExists(name)) {
+    if (create && FileExists(name)) 
+    {
         strcpy(buf, name);
         return buf; // Exists so ...
     }
     if (*name == '/')
         strcpy(buf, name);
         strcpy(buf, name);
         return buf; // Exists so ...
     }
     if (*name == '/')
         strcpy(buf, name);
         // Put in standard place for resource files if not absolute
         strcpy(buf, DEFAULT_XRESOURCE_DIR);
         strcat(buf, "/");
         strcat(buf, FileNameFromPath(name));
     }
         // Put in standard place for resource files if not absolute
         strcpy(buf, DEFAULT_XRESOURCE_DIR);
         strcat(buf, "/");
         strcat(buf, FileNameFromPath(name));
     }
         // Touch the file to create it
         FILE *fd = fopen(buf, "w");
         if (fd) fclose(fd);
         // Touch the file to create it
         FILE *fd = fopen(buf, "w");
         if (fd) fclose(fd);
     // window when the server initializes and loaded into the display
     // structure on XOpenDisplay;
     // if not defined, use .Xdefaults
     // window when the server initializes and loaded into the display
     // structure on XOpenDisplay;
     // if not defined, use .Xdefaults
-    if (XResourceManagerString(GDK_DISPLAY()) != NULL) {
+    if (XResourceManagerString(GDK_DISPLAY()) != NULL) 
+    {
         serverDB = XrmGetStringDatabase(XResourceManagerString(GDK_DISPLAY()));
         serverDB = XrmGetStringDatabase(XResourceManagerString(GDK_DISPLAY()));
         (void)GetIniFile(filename, (char *) NULL);
         serverDB = XrmGetFileDatabase(filename);
     }
         (void)GetIniFile(filename, (char *) NULL);
         serverDB = XrmGetFileDatabase(filename);
     }
     // Open XENVIRONMENT file, or if not defined, the .Xdefaults,
     // and merge into existing database
 
     // Open XENVIRONMENT file, or if not defined, the .Xdefaults,
     // and merge into existing database
 
-    if ((environment = getenv("XENVIRONMENT")) == NULL) {
+    if ((environment = getenv("XENVIRONMENT")) == NULL) 
+    {
         size_t len;
         environment = GetIniFile(filename, (const char *) NULL);
         len = strlen(environment);
         size_t len;
         environment = GetIniFile(filename, (const char *) NULL);
         len = strlen(environment);
         wxXMergeDatabases();
 
     XrmDatabase database;
         wxXMergeDatabases();
 
     XrmDatabase database;
-    if ( !file.IsEmpty() ) {
+    if (!file.IsEmpty()) 
+    {
         char buffer[500];
         // Is this right? Trying to get it to look in the user's
         // home directory instead of current directory -- JACS
         char buffer[500];
         // Is this right? Trying to get it to look in the user's
         // home directory instead of current directory -- JACS
 
     bool success = XrmGetResource(database, buf, "*", str_type, &xvalue);
     // Try different combinations of upper/lower case, just in case...
 
     bool success = XrmGetResource(database, buf, "*", str_type, &xvalue);
     // Try different combinations of upper/lower case, just in case...
         buf[0] = (isupper(buf[0]) ? tolower(buf[0]) : toupper(buf[0]));
         success = XrmGetResource(database, buf, "*", str_type,        &xvalue);
     }
         buf[0] = (isupper(buf[0]) ? tolower(buf[0]) : toupper(buf[0]));
         success = XrmGetResource(database, buf, "*", str_type,        &xvalue);
     }
         if (*value)
             delete[] *value;
         *value = new char[xvalue.size + 1];
         if (*value)
             delete[] *value;
         *value = new char[xvalue.size + 1];
 {
     char *s = (char *) NULL;
     bool succ = wxGetResource(section, entry, &s, file);
 {
     char *s = (char *) NULL;
     bool succ = wxGetResource(section, entry, &s, file);
         *value = (float)strtod(s, (char **) NULL);
         delete[]s;
         return TRUE;
         *value = (float)strtod(s, (char **) NULL);
         delete[]s;
         return TRUE;
 {
     char *s = (char *) NULL;
     bool succ = wxGetResource(section, entry, &s, file);
 {
     char *s = (char *) NULL;
     bool succ = wxGetResource(section, entry, &s, file);
         *value = strtol(s, (char **) NULL, 10);
         delete[]s;
         return TRUE;
         *value = strtol(s, (char **) NULL, 10);
         delete[]s;
         return TRUE;
 {
     char *s = (char *) NULL;
     bool succ = wxGetResource(section, entry, &s, file);
 {
     char *s = (char *) NULL;
     bool succ = wxGetResource(section, entry, &s, file);
         // Handle True, False here
         // True, Yes, Enables, Set or  Activated
         if (*s == 'T' || *s == 'Y' || *s == 'E' || *s == 'S' || *s == 'A')
         // Handle True, False here
         // True, Yes, Enables, Set or  Activated
         if (*s == 'T' || *s == 'Y' || *s == 'E' || *s == 'S' || *s == 'A')
 
     {
         parent->m_sizeSet = FALSE;
     }
     {
         parent->m_sizeSet = FALSE;
     }
+    
+    if (parent->m_windowStyle & wxTAB_TRAVERSAL)
+    {
+        /* we now allow a window to get the focus as long as it
+          doesn't have any children. */
+        GTK_WIDGET_UNSET_FLAGS( parent->m_wxwindow, GTK_CAN_FOCUS );  
+    }
 }
 
 //-----------------------------------------------------------------------------
 }
 
 //-----------------------------------------------------------------------------
         gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_NONE );
     }
 
         gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_NONE );
     }
 
-    if ((m_windowStyle & wxTAB_TRAVERSAL) != 0)
+    if (m_windowStyle & wxTAB_TRAVERSAL)
-        GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );  /* changed from UNSET */
+        /* we now allow a window to get the focus as long as it
+          doesn't have any children. */
+        GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );  
         m_acceptsFocus = FALSE;
     }
     else
         m_acceptsFocus = FALSE;
     }
     else