comparison win/dw.c @ 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 ece7befa9f3d
comparison
equal deleted inserted replaced
1811:e7ed7bbea3a4 1812:9bbe090d0250
956 } 956 }
957 957
958 #define _DW_DIRECTION_FORWARD -1 958 #define _DW_DIRECTION_FORWARD -1
959 #define _DW_DIRECTION_BACKWARD 1 959 #define _DW_DIRECTION_BACKWARD 1
960 960
961 int _focus_check_box(Box *box, HWND handle, int start, int direction, HWND defaultitem);
962
961 /* Internal comparision function */ 963 /* Internal comparision function */
962 int _focus_comp(int direction, int z, int end) 964 int _focus_comp(int direction, int z, int end)
963 { 965 {
964 if(direction == _DW_DIRECTION_FORWARD) 966 if(direction == _DW_DIRECTION_FORWARD)
965 return z > -1; 967 return z > -1;
966 return z < end; 968 return z < end;
969 }
970
971 int _focus_notebook(HWND hwnd, HWND handle, int start, int direction, HWND defaultitem)
972 {
973 NotebookPage **array = (NotebookPage **)dw_window_get_data(hwnd, "_dw_array");
974 int pageid = TabCtrl_GetCurSel(hwnd);
975
976 if(pageid > -1 && array && array[pageid])
977 {
978 Box *notebox;
979
980 if(array[pageid]->hwnd)
981 {
982 notebox = (Box *)GetWindowLongPtr(array[pageid]->hwnd, GWLP_USERDATA);
983
984 if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0, direction, defaultitem))
985 return 1;
986 }
987 }
988 return 0;
967 } 989 }
968 990
969 /* Handle box focus traversal in either direction */ 991 /* Handle box focus traversal in either direction */
970 int _focus_check_box(Box *box, HWND handle, int start, int direction, HWND defaultitem) 992 int _focus_check_box(Box *box, HWND handle, int start, int direction, HWND defaultitem)
971 { 993 {
1006 if(thisbox && _focus_check_box(thisbox, handle, start == 3 ? 3 : 0, direction, defaultitem)) 1028 if(thisbox && _focus_check_box(thisbox, handle, start == 3 ? 3 : 0, direction, defaultitem))
1007 return 1; 1029 return 1;
1008 } 1030 }
1009 else 1031 else
1010 { 1032 {
1011 int type; 1033 int type = _validate_focus(box->items[z].hwnd);
1012 1034
1035 /* Special case notebook, can focus and contains items */
1036 if(type == 2 && direction == _DW_DIRECTION_FORWARD && _focus_notebook(box->items[z].hwnd, handle, start, direction, defaultitem))
1037 return 1;
1013 if(box->items[z].hwnd == handle) 1038 if(box->items[z].hwnd == handle)
1014 { 1039 {
1015 if(lasthwnd == handle && firsthwnd) 1040 if(lasthwnd == handle && firsthwnd)
1016 SetFocus(firsthwnd); 1041 SetFocus(firsthwnd);
1017 else if(lasthwnd == handle && !firsthwnd) 1042 else if(lasthwnd == handle && !firsthwnd)
1023 * return immediately. 1048 * return immediately.
1024 */ 1049 */
1025 if(!finish_searching) 1050 if(!finish_searching)
1026 return 1; 1051 return 1;
1027 } 1052 }
1028 if((type = _validate_focus(box->items[z].hwnd)) != 0) 1053 if(type > 0)
1029 { 1054 {
1030 /* Start is 3 when we are looking for the 1055 /* Start is 3 when we are looking for the
1031 * first valid item in the layout. 1056 * first valid item in the layout.
1032 */ 1057 */
1033 if(start == 3) 1058 if(start == 3)
1083 if(scrollbox && _focus_check_box(scrollbox, handle, start == 3 ? 3 : 0, direction, defaultitem)) 1108 if(scrollbox && _focus_check_box(scrollbox, handle, start == 3 ? 3 : 0, direction, defaultitem))
1084 return 1; 1109 return 1;
1085 } 1110 }
1086 } 1111 }
1087 /* Special case notebook, can focus and contains items */ 1112 /* Special case notebook, can focus and contains items */
1088 if(type == 2 && box->items[z].hwnd != handle) 1113 if(type == 2 && direction == _DW_DIRECTION_BACKWARD && _focus_notebook(box->items[z].hwnd, handle, start, direction, defaultitem))
1089 { 1114 return 1;
1090 NotebookPage **array = (NotebookPage **)dw_window_get_data(box->items[z].hwnd, "_dw_array");
1091 int pageid = TabCtrl_GetCurSel(box->items[z].hwnd);
1092
1093 if(pageid > -1 && array && array[pageid])
1094 {
1095 Box *notebox;
1096
1097 if(array[pageid]->hwnd)
1098 {
1099 notebox = (Box *)GetWindowLongPtr(array[pageid]->hwnd, GWLP_USERDATA);
1100
1101 if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0, direction, defaultitem))
1102 return 1;
1103 }
1104 }
1105 }
1106 } 1115 }
1107 } 1116 }
1108 return 0; 1117 return 0;
1109 } 1118 }
1110 1119