changeset 1812:9bbe090d0250

Depending on the tab direction on Windows, the dual purpose notebook control needs to be handled in a different order when being input and box.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 09 Oct 2012 03:08:45 +0000
parents e7ed7bbea3a4
children 9cb8660c5fa3
files win/dw.c
diffstat 1 files changed, 29 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/win/dw.c	Mon Oct 08 23:51:45 2012 +0000
+++ b/win/dw.c	Tue Oct 09 03:08:45 2012 +0000
@@ -958,6 +958,8 @@
 #define _DW_DIRECTION_FORWARD -1
 #define _DW_DIRECTION_BACKWARD 1
 
+int _focus_check_box(Box *box, HWND handle, int start, int direction, HWND defaultitem);
+
 /* Internal comparision function */
 int _focus_comp(int direction, int z, int end)
 {
@@ -966,6 +968,26 @@
    return z < end;
 }
 
+int _focus_notebook(HWND hwnd, HWND handle, int start, int direction, HWND defaultitem)
+{
+   NotebookPage **array = (NotebookPage **)dw_window_get_data(hwnd, "_dw_array");
+   int pageid = TabCtrl_GetCurSel(hwnd);
+
+   if(pageid > -1 && array && array[pageid])
+   {
+      Box *notebox;
+
+      if(array[pageid]->hwnd)
+      {
+         notebox = (Box *)GetWindowLongPtr(array[pageid]->hwnd, GWLP_USERDATA);
+
+         if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0, direction, defaultitem))
+            return 1;
+      }
+   }
+   return 0;
+}
+
 /* Handle box focus traversal in either direction */
 int _focus_check_box(Box *box, HWND handle, int start, int direction, HWND defaultitem)
 {
@@ -1008,8 +1030,11 @@
       }
       else
       {
-         int type;
+         int type = _validate_focus(box->items[z].hwnd);
          
+         /* Special case notebook, can focus and contains items */
+         if(type == 2 && direction == _DW_DIRECTION_FORWARD && _focus_notebook(box->items[z].hwnd, handle, start, direction, defaultitem)) 
+            return 1;
          if(box->items[z].hwnd == handle)
          {
             if(lasthwnd == handle && firsthwnd)
@@ -1025,7 +1050,7 @@
             if(!finish_searching)
                return 1;
          }
-         if((type = _validate_focus(box->items[z].hwnd)) != 0)
+         if(type > 0)
          {
             /* Start is 3 when we are looking for the
              * first valid item in the layout.
@@ -1085,24 +1110,8 @@
             }
          }
          /* Special case notebook, can focus and contains items */
-         if(type == 2 && box->items[z].hwnd != handle) 
-         {
-            NotebookPage **array = (NotebookPage **)dw_window_get_data(box->items[z].hwnd, "_dw_array");
-            int pageid = TabCtrl_GetCurSel(box->items[z].hwnd);
-
-            if(pageid > -1 && array && array[pageid])
-            {
-               Box *notebox;
-
-               if(array[pageid]->hwnd)
-               {
-                  notebox = (Box *)GetWindowLongPtr(array[pageid]->hwnd, GWLP_USERDATA);
-
-                  if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0, direction, defaultitem))
-                     return 1;
-               }
-            }
-         }
+         if(type == 2 && direction == _DW_DIRECTION_BACKWARD && _focus_notebook(box->items[z].hwnd, handle, start, direction, defaultitem)) 
+            return 1;
       }
    }
    return 0;