Mercurial > dwindows
comparison win/dw.c @ 1811:e7ed7bbea3a4
Rewrite of the focus shifting code on Windows, eliminate duplicated code.
Added support for tabbing to the notebook control, there seems to be a bug
in the order when tabbing forward but not back.... when I solve this bug
I'll proceed to port the same changes to the OS/2 code base.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 08 Oct 2012 23:51:45 +0000 |
parents | c110191e3775 |
children | 9bbe090d0250 |
comparison
equal
deleted
inserted
replaced
1810:c110191e3775 | 1811:e7ed7bbea3a4 |
---|---|
925 _tcsnicmp(tmpbuf, UPDOWN_CLASS, _tcslen(UPDOWN_CLASS)+1)==0 || /* Spinbutton */ | 925 _tcsnicmp(tmpbuf, UPDOWN_CLASS, _tcslen(UPDOWN_CLASS)+1)==0 || /* Spinbutton */ |
926 _tcsnicmp(tmpbuf, TRACKBAR_CLASS, _tcslen(TRACKBAR_CLASS)+1)==0 || /* Slider */ | 926 _tcsnicmp(tmpbuf, TRACKBAR_CLASS, _tcslen(TRACKBAR_CLASS)+1)==0 || /* Slider */ |
927 _tcsnicmp(tmpbuf, WC_LISTVIEW, _tcslen(WC_LISTVIEW)+1)== 0 || /* Container */ | 927 _tcsnicmp(tmpbuf, WC_LISTVIEW, _tcslen(WC_LISTVIEW)+1)== 0 || /* Container */ |
928 _tcsnicmp(tmpbuf, WC_TREEVIEW, _tcslen(WC_TREEVIEW)+1)== 0) /* Tree */ | 928 _tcsnicmp(tmpbuf, WC_TREEVIEW, _tcslen(WC_TREEVIEW)+1)== 0) /* Tree */ |
929 return 1; | 929 return 1; |
930 /* Special case for the notebook, can get focus and contains other items */ | |
931 if(_tcsnicmp(tmpbuf, WC_TABCONTROL, _tcslen(WC_TABCONTROL))==0) /* Notebook */ | |
932 return 2; | |
930 return 0; | 933 return 0; |
931 } | 934 } |
932 | 935 |
933 HWND _normalize_handle(HWND handle) | 936 HWND _normalize_handle(HWND handle) |
934 { | 937 { |
950 return cinfo->buddy; | 953 return cinfo->buddy; |
951 } | 954 } |
952 return handle; | 955 return handle; |
953 } | 956 } |
954 | 957 |
955 int _focus_check_box(Box *box, HWND handle, int start, HWND defaultitem) | 958 #define _DW_DIRECTION_FORWARD -1 |
959 #define _DW_DIRECTION_BACKWARD 1 | |
960 | |
961 /* Internal comparision function */ | |
962 int _focus_comp(int direction, int z, int end) | |
963 { | |
964 if(direction == _DW_DIRECTION_FORWARD) | |
965 return z > -1; | |
966 return z < end; | |
967 } | |
968 | |
969 /* Handle box focus traversal in either direction */ | |
970 int _focus_check_box(Box *box, HWND handle, int start, int direction, HWND defaultitem) | |
956 { | 971 { |
957 int z; | 972 int z; |
958 static HWND lasthwnd, firsthwnd; | 973 static HWND lasthwnd, firsthwnd; |
959 static int finish_searching; | 974 static int finish_searching; |
975 int beg = (direction == _DW_DIRECTION_FORWARD) ? box->count-1 : 0; | |
976 int end = (direction == _DW_DIRECTION_FORWARD) ? -1 : box->count; | |
960 | 977 |
961 /* Start is 2 when we have cycled completely and | 978 /* Start is 2 when we have cycled completely and |
962 * need to set the focus to the last widget we found | 979 * need to set the focus to the last widget we found |
963 * that was valid. | 980 * that was valid. |
964 */ | 981 */ |
978 lasthwnd = handle; | 995 lasthwnd = handle; |
979 finish_searching = 0; | 996 finish_searching = 0; |
980 firsthwnd = 0; | 997 firsthwnd = 0; |
981 } | 998 } |
982 | 999 |
983 for(z=box->count-1;z>-1;z--) | 1000 for(z=beg;_focus_comp(direction, z, end);z+=direction) |
984 { | 1001 { |
985 if(box->items[z].type == TYPEBOX) | 1002 if(box->items[z].type == TYPEBOX) |
986 { | 1003 { |
987 Box *thisbox = (Box *)GetWindowLongPtr(box->items[z].hwnd, GWLP_USERDATA); | 1004 Box *thisbox = (Box *)GetWindowLongPtr(box->items[z].hwnd, GWLP_USERDATA); |
988 | 1005 |
989 if(thisbox && _focus_check_box(thisbox, handle, start == 3 ? 3 : 0, defaultitem)) | 1006 if(thisbox && _focus_check_box(thisbox, handle, start == 3 ? 3 : 0, direction, defaultitem)) |
990 return 1; | 1007 return 1; |
991 } | 1008 } |
992 else | 1009 else |
993 { | 1010 { |
1011 int type; | |
1012 | |
994 if(box->items[z].hwnd == handle) | 1013 if(box->items[z].hwnd == handle) |
995 { | 1014 { |
996 if(lasthwnd == handle && firsthwnd) | 1015 if(lasthwnd == handle && firsthwnd) |
997 SetFocus(firsthwnd); | 1016 SetFocus(firsthwnd); |
998 else if(lasthwnd == handle && !firsthwnd) | 1017 else if(lasthwnd == handle && !firsthwnd) |
1004 * return immediately. | 1023 * return immediately. |
1005 */ | 1024 */ |
1006 if(!finish_searching) | 1025 if(!finish_searching) |
1007 return 1; | 1026 return 1; |
1008 } | 1027 } |
1009 if(_validate_focus(box->items[z].hwnd)) | 1028 if((type = _validate_focus(box->items[z].hwnd)) != 0) |
1010 { | 1029 { |
1011 /* Start is 3 when we are looking for the | 1030 /* Start is 3 when we are looking for the |
1012 * first valid item in the layout. | 1031 * first valid item in the layout. |
1013 */ | 1032 */ |
1014 if(start == 3) | 1033 if(start == 3) |
1018 SetFocus(_normalize_handle(box->items[z].hwnd)); | 1037 SetFocus(_normalize_handle(box->items[z].hwnd)); |
1019 return 1; | 1038 return 1; |
1020 } | 1039 } |
1021 } | 1040 } |
1022 | 1041 |
1042 lasthwnd = _normalize_handle(box->items[z].hwnd); | |
1043 | |
1023 if(!firsthwnd) | 1044 if(!firsthwnd) |
1024 firsthwnd = _normalize_handle(box->items[z].hwnd); | 1045 firsthwnd = lasthwnd; |
1025 | |
1026 lasthwnd = _normalize_handle(box->items[z].hwnd); | |
1027 } | 1046 } |
1028 else | 1047 else |
1029 { | 1048 { |
1049 /* Handle controls that contain other items */ | |
1030 TCHAR tmpbuf[100] = {0}; | 1050 TCHAR tmpbuf[100] = {0}; |
1031 | 1051 |
1032 GetClassName(box->items[z].hwnd, tmpbuf, 99); | 1052 GetClassName(box->items[z].hwnd, tmpbuf, 99); |
1033 | 1053 |
1034 if(_tcsncmp(tmpbuf, SplitbarClassName, _tcslen(SplitbarClassName)+1)==0) | 1054 if(_tcsncmp(tmpbuf, SplitbarClassName, _tcslen(SplitbarClassName)+1)==0) |
1035 { | 1055 { |
1036 /* Then try the bottom or right box */ | 1056 /* Then try the bottom or right box */ |
1037 HWND mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_bottomright"); | 1057 HWND mybox = (HWND)dw_window_get_data(box->items[z].hwnd, (direction == _DW_DIRECTION_FORWARD) ? "_dw_bottomright" : "_dw_topleft"); |
1038 | 1058 |
1039 if(mybox) | 1059 if(mybox) |
1040 { | 1060 { |
1041 Box *splitbox = (Box *)GetWindowLongPtr(mybox, GWLP_USERDATA); | 1061 Box *splitbox = (Box *)GetWindowLongPtr(mybox, GWLP_USERDATA); |
1042 | 1062 |
1043 if(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, defaultitem)) | 1063 if(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, direction, defaultitem)) |
1044 return 1; | 1064 return 1; |
1045 } | 1065 } |
1046 | 1066 |
1047 /* Try the top or left box */ | 1067 /* Try the top or left box */ |
1048 mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_topleft"); | 1068 mybox = (HWND)dw_window_get_data(box->items[z].hwnd, (direction == _DW_DIRECTION_FORWARD) ? "_dw_topleft" : "_dw_bottomright"); |
1049 | 1069 |
1050 if(mybox) | 1070 if(mybox) |
1051 { | 1071 { |
1052 Box *splitbox = (Box *)GetWindowLongPtr(mybox, GWLP_USERDATA); | 1072 Box *splitbox = (Box *)GetWindowLongPtr(mybox, GWLP_USERDATA); |
1053 | 1073 |
1054 if(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, defaultitem)) | 1074 if(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, direction, defaultitem)) |
1055 return 1; | 1075 return 1; |
1056 } | |
1057 } | |
1058 else if(_tcsnicmp(tmpbuf, WC_TABCONTROL, _tcslen(WC_TABCONTROL))==0) /* Notebook */ | |
1059 { | |
1060 NotebookPage **array = (NotebookPage **)dw_window_get_data(box->items[z].hwnd, "_dw_array"); | |
1061 int pageid = TabCtrl_GetCurSel(box->items[z].hwnd); | |
1062 | |
1063 if(pageid > -1 && array && array[pageid]) | |
1064 { | |
1065 Box *notebox; | |
1066 | |
1067 if(array[pageid]->hwnd) | |
1068 { | |
1069 notebox = (Box *)GetWindowLongPtr(array[pageid]->hwnd, GWLP_USERDATA); | |
1070 | |
1071 if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0, defaultitem)) | |
1072 return 1; | |
1073 } | |
1074 } | 1076 } |
1075 } | 1077 } |
1076 else if(_tcsnicmp(tmpbuf, ScrollClassName, _tcslen(ScrollClassName))==0) /* Scroll Box */ | 1078 else if(_tcsnicmp(tmpbuf, ScrollClassName, _tcslen(ScrollClassName))==0) /* Scroll Box */ |
1077 { | 1079 { |
1078 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(box->items[z].hwnd, GWLP_USERDATA); | 1080 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(box->items[z].hwnd, GWLP_USERDATA); |
1079 Box *scrollbox = (Box *)GetWindowLongPtr(cinfo->combo, GWLP_USERDATA); | 1081 Box *scrollbox = (Box *)GetWindowLongPtr(cinfo->combo, GWLP_USERDATA); |
1080 | 1082 |
1081 if(scrollbox && _focus_check_box(scrollbox, handle, start == 3 ? 3 : 0, defaultitem)) | 1083 if(scrollbox && _focus_check_box(scrollbox, handle, start == 3 ? 3 : 0, direction, defaultitem)) |
1082 return 1; | 1084 return 1; |
1083 } | 1085 } |
1084 } | 1086 } |
1085 } | 1087 /* Special case notebook, can focus and contains items */ |
1086 } | 1088 if(type == 2 && box->items[z].hwnd != handle) |
1087 return 0; | |
1088 } | |
1089 | |
1090 int _focus_check_box_back(Box *box, HWND handle, int start, HWND defaultitem) | |
1091 { | |
1092 int z; | |
1093 static HWND lasthwnd, firsthwnd; | |
1094 static int finish_searching; | |
1095 | |
1096 /* Start is 2 when we have cycled completely and | |
1097 * need to set the focus to the last widget we found | |
1098 * that was valid. | |
1099 */ | |
1100 if(start == 2) | |
1101 { | |
1102 if(lasthwnd) | |
1103 SetFocus(lasthwnd); | |
1104 return 0; | |
1105 } | |
1106 | |
1107 /* Start is 1 when we are entering the function | |
1108 * for the first time, it is zero when entering | |
1109 * the function recursively. | |
1110 */ | |
1111 if(start == 1) | |
1112 { | |
1113 lasthwnd = handle; | |
1114 finish_searching = 0; | |
1115 firsthwnd = 0; | |
1116 } | |
1117 | |
1118 for(z=0;z<box->count;z++) | |
1119 { | |
1120 if(box->items[z].type == TYPEBOX) | |
1121 { | |
1122 Box *thisbox = (Box *)GetWindowLongPtr(box->items[z].hwnd, GWLP_USERDATA); | |
1123 | |
1124 if(thisbox && _focus_check_box_back(thisbox, handle, start == 3 ? 3 : 0, defaultitem)) | |
1125 return 1; | |
1126 } | |
1127 else | |
1128 { | |
1129 if(box->items[z].hwnd == handle) | |
1130 { | 1089 { |
1131 if(lasthwnd == handle && firsthwnd) | 1090 NotebookPage **array = (NotebookPage **)dw_window_get_data(box->items[z].hwnd, "_dw_array"); |
1132 SetFocus(firsthwnd); | 1091 int pageid = TabCtrl_GetCurSel(box->items[z].hwnd); |
1133 else if(lasthwnd == handle && !firsthwnd) | 1092 |
1134 finish_searching = 1; | 1093 if(pageid > -1 && array && array[pageid]) |
1135 else | |
1136 SetFocus(lasthwnd); | |
1137 | |
1138 /* If we aren't looking for the last handle, | |
1139 * return immediately. | |
1140 */ | |
1141 if(!finish_searching) | |
1142 return 1; | |
1143 } | |
1144 if(_validate_focus(box->items[z].hwnd)) | |
1145 { | |
1146 /* Start is 3 when we are looking for the | |
1147 * first valid item in the layout. | |
1148 */ | |
1149 if(start == 3) | |
1150 { | 1094 { |
1151 if(!defaultitem || (defaultitem && box->items[z].hwnd == defaultitem)) | 1095 Box *notebox; |
1096 | |
1097 if(array[pageid]->hwnd) | |
1152 { | 1098 { |
1153 SetFocus(_normalize_handle(box->items[z].hwnd)); | 1099 notebox = (Box *)GetWindowLongPtr(array[pageid]->hwnd, GWLP_USERDATA); |
1154 return 1; | 1100 |
1155 } | 1101 if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0, direction, defaultitem)) |
1156 } | |
1157 | |
1158 if(!firsthwnd) | |
1159 firsthwnd = _normalize_handle(box->items[z].hwnd); | |
1160 | |
1161 lasthwnd = _normalize_handle(box->items[z].hwnd); | |
1162 } | |
1163 else | |
1164 { | |
1165 TCHAR tmpbuf[100] = {0}; | |
1166 | |
1167 GetClassName(box->items[z].hwnd, tmpbuf, 99); | |
1168 | |
1169 if(_tcsncmp(tmpbuf, SplitbarClassName, _tcslen(SplitbarClassName)+1)==0) | |
1170 { | |
1171 /* Try the top or left box */ | |
1172 HWND mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_topleft"); | |
1173 | |
1174 if(mybox) | |
1175 { | |
1176 Box *splitbox = (Box *)GetWindowLongPtr(mybox, GWLP_USERDATA); | |
1177 | |
1178 if(splitbox && _focus_check_box_back(splitbox, handle, start == 3 ? 3 : 0, defaultitem)) | |
1179 return 1; | |
1180 } | |
1181 | |
1182 /* Then try the bottom or right box */ | |
1183 mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_bottomright"); | |
1184 | |
1185 if(mybox) | |
1186 { | |
1187 Box *splitbox = (Box *)GetWindowLongPtr(mybox, GWLP_USERDATA); | |
1188 | |
1189 if(splitbox && _focus_check_box_back(splitbox, handle, start == 3 ? 3 : 0, defaultitem)) | |
1190 return 1; | 1102 return 1; |
1191 } | 1103 } |
1192 } | 1104 } |
1193 else if(_tcsnicmp(tmpbuf, WC_TABCONTROL, _tcslen(WC_TABCONTROL))==0) /* Notebook */ | |
1194 { | |
1195 NotebookPage **array = (NotebookPage **)dw_window_get_data(box->items[z].hwnd, "_dw_array"); | |
1196 int pageid = TabCtrl_GetCurSel(box->items[z].hwnd); | |
1197 | |
1198 if(pageid > -1 && array && array[pageid]) | |
1199 { | |
1200 Box *notebox; | |
1201 | |
1202 if(array[pageid]->hwnd) | |
1203 { | |
1204 notebox = (Box *)GetWindowLongPtr(array[pageid]->hwnd, GWLP_USERDATA); | |
1205 | |
1206 if(notebox && _focus_check_box_back(notebox, handle, start == 3 ? 3 : 0, defaultitem)) | |
1207 return 1; | |
1208 } | |
1209 } | |
1210 } | |
1211 else if(_tcsnicmp(tmpbuf, ScrollClassName, _tcslen(ScrollClassName))==0) /* Scroll Box */ | |
1212 { | |
1213 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(box->items[z].hwnd, GWLP_USERDATA); | |
1214 Box *scrollbox = (Box *)GetWindowLongPtr(cinfo->combo, GWLP_USERDATA); | |
1215 | |
1216 if(scrollbox && _focus_check_box_back(scrollbox, handle, start == 3 ? 3 : 0, defaultitem)) | |
1217 return 1; | |
1218 } | |
1219 } | 1105 } |
1220 } | 1106 } |
1221 } | 1107 } |
1222 return 0; | 1108 return 0; |
1223 } | 1109 } |
1242 if(handle) | 1128 if(handle) |
1243 thisbox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA); | 1129 thisbox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA); |
1244 | 1130 |
1245 if(thisbox) | 1131 if(thisbox) |
1246 { | 1132 { |
1247 _focus_check_box(thisbox, handle, 3, thisbox->defaultitem); | 1133 _focus_check_box(thisbox, handle, 3, _DW_DIRECTION_FORWARD, thisbox->defaultitem); |
1248 } | 1134 } |
1249 } | 1135 } |
1250 | 1136 |
1251 HWND _toplevel_window(HWND handle) | 1137 HWND _toplevel_window(HWND handle) |
1252 { | 1138 { |
1276 } | 1162 } |
1277 | 1163 |
1278 /* This function finds the current widget in the | 1164 /* This function finds the current widget in the |
1279 * layout and moves the current focus to the next item. | 1165 * layout and moves the current focus to the next item. |
1280 */ | 1166 */ |
1281 void _shift_focus(HWND handle) | 1167 void _shift_focus(HWND handle, int direction) |
1282 { | 1168 { |
1283 Box *thisbox; | 1169 Box *thisbox; |
1284 | 1170 |
1285 HWND box, lastbox = GetParent(handle); | 1171 HWND box, lastbox = GetParent(handle); |
1286 | 1172 |
1291 } | 1177 } |
1292 | 1178 |
1293 thisbox = (Box *)GetWindowLongPtr(lastbox, GWLP_USERDATA); | 1179 thisbox = (Box *)GetWindowLongPtr(lastbox, GWLP_USERDATA); |
1294 if(thisbox) | 1180 if(thisbox) |
1295 { | 1181 { |
1296 if(_focus_check_box(thisbox, handle, 1, 0) == 0) | 1182 if(_focus_check_box(thisbox, handle, 1, direction, 0) == 0) |
1297 _focus_check_box(thisbox, handle, 2, 0); | 1183 _focus_check_box(thisbox, handle, 2, direction, 0); |
1298 } | 1184 } |
1299 } | 1185 } |
1300 | 1186 |
1301 /* This function finds the current widget in the | |
1302 * layout and moves the current focus to the next item. | |
1303 */ | |
1304 void _shift_focus_back(HWND handle) | |
1305 { | |
1306 Box *thisbox; | |
1307 | |
1308 HWND box, lastbox = GetParent(handle); | |
1309 | |
1310 /* Find the toplevel window */ | |
1311 while((box = GetParent(lastbox))) | |
1312 { | |
1313 lastbox = box; | |
1314 } | |
1315 | |
1316 thisbox = (Box *)GetWindowLongPtr(lastbox, GWLP_USERDATA); | |
1317 if(thisbox) | |
1318 { | |
1319 if(_focus_check_box_back(thisbox, handle, 1, 0) == 0) | |
1320 _focus_check_box_back(thisbox, handle, 2, 0); | |
1321 } | |
1322 } | |
1323 /* This function calculates how much space the widgets and boxes require | 1187 /* This function calculates how much space the widgets and boxes require |
1324 * and does expansion as necessary. | 1188 * and does expansion as necessary. |
1325 */ | 1189 */ |
1326 static void _resize_box(Box *thisbox, int *depth, int x, int y, int pass) | 1190 static void _resize_box(Box *thisbox, int *depth, int x, int y, int pass) |
1327 { | 1191 { |
2843 if (ret != TRUE && LOWORD(mp1) == '\t') | 2707 if (ret != TRUE && LOWORD(mp1) == '\t') |
2844 { | 2708 { |
2845 if (GetAsyncKeyState(VK_SHIFT) & 0x8000) | 2709 if (GetAsyncKeyState(VK_SHIFT) & 0x8000) |
2846 { | 2710 { |
2847 if (cinfo->combo) | 2711 if (cinfo->combo) |
2848 _shift_focus_back(cinfo->combo); | 2712 _shift_focus(cinfo->combo, _DW_DIRECTION_BACKWARD); |
2849 else if(cinfo->buddy) | 2713 else if(cinfo->buddy) |
2850 _shift_focus_back(cinfo->buddy); | 2714 _shift_focus(cinfo->buddy, _DW_DIRECTION_BACKWARD); |
2851 else | 2715 else |
2852 _shift_focus_back(hWnd); | 2716 _shift_focus(hWnd, _DW_DIRECTION_BACKWARD); |
2853 } | 2717 } |
2854 else | 2718 else |
2855 { | 2719 { |
2856 if (cinfo->combo) | 2720 if (cinfo->combo) |
2857 _shift_focus(cinfo->combo); | 2721 _shift_focus(cinfo->combo, _DW_DIRECTION_FORWARD); |
2858 else if(cinfo->buddy) | 2722 else if(cinfo->buddy) |
2859 _shift_focus(cinfo->buddy); | 2723 _shift_focus(cinfo->buddy, _DW_DIRECTION_FORWARD); |
2860 else | 2724 else |
2861 _shift_focus(hWnd); | 2725 _shift_focus(hWnd, _DW_DIRECTION_FORWARD); |
2862 } | 2726 } |
2863 return FALSE; | 2727 return FALSE; |
2864 } | 2728 } |
2865 else if(LOWORD(mp1) == '\r') | 2729 else if(LOWORD(mp1) == '\r') |
2866 { | 2730 { |
3055 int iItem; | 2919 int iItem; |
3056 | 2920 |
3057 if(LOWORD(mp1) == '\t') | 2921 if(LOWORD(mp1) == '\t') |
3058 { | 2922 { |
3059 if(GetAsyncKeyState(VK_SHIFT) & 0x8000) | 2923 if(GetAsyncKeyState(VK_SHIFT) & 0x8000) |
3060 _shift_focus_back(hWnd); | 2924 _shift_focus(hWnd, _DW_DIRECTION_BACKWARD); |
3061 else | 2925 else |
3062 _shift_focus(hWnd); | 2926 _shift_focus(hWnd, _DW_DIRECTION_FORWARD); |
3063 return FALSE; | 2927 return FALSE; |
3064 } | 2928 } |
3065 | 2929 |
3066 if(msg == WM_CHAR && (char)mp1 != '\r') | 2930 if(msg == WM_CHAR && (char)mp1 != '\r') |
3067 break; | 2931 break; |
3168 case WM_CHAR: | 3032 case WM_CHAR: |
3169 ret = _wndproc(hWnd, msg, mp1, mp2); | 3033 ret = _wndproc(hWnd, msg, mp1, mp2); |
3170 if(ret != TRUE && LOWORD(mp1) == '\t') | 3034 if(ret != TRUE && LOWORD(mp1) == '\t') |
3171 { | 3035 { |
3172 if(GetAsyncKeyState(VK_SHIFT) & 0x8000) | 3036 if(GetAsyncKeyState(VK_SHIFT) & 0x8000) |
3173 _shift_focus_back(hWnd); | 3037 _shift_focus(hWnd, _DW_DIRECTION_BACKWARD); |
3174 else | 3038 else |
3175 _shift_focus(hWnd); | 3039 _shift_focus(hWnd, _DW_DIRECTION_FORWARD); |
3176 return FALSE; | 3040 return FALSE; |
3177 } | 3041 } |
3178 break; | 3042 break; |
3179 } | 3043 } |
3180 | 3044 |
3716 } | 3580 } |
3717 } | 3581 } |
3718 if(LOWORD(mp1) == '\t') | 3582 if(LOWORD(mp1) == '\t') |
3719 { | 3583 { |
3720 if(GetAsyncKeyState(VK_SHIFT) & 0x8000) | 3584 if(GetAsyncKeyState(VK_SHIFT) & 0x8000) |
3721 _shift_focus_back(hwnd); | 3585 _shift_focus(hwnd, _DW_DIRECTION_BACKWARD); |
3722 else | 3586 else |
3723 _shift_focus(hwnd); | 3587 _shift_focus(hwnd, _DW_DIRECTION_FORWARD); |
3724 return FALSE; | 3588 return FALSE; |
3725 } | 3589 } |
3726 } | 3590 } |
3727 break; | 3591 break; |
3728 case WM_KEYDOWN: | 3592 case WM_KEYDOWN: |
3729 if(mp1 == VK_LEFT || mp1 == VK_UP) | 3593 if(mp1 == VK_LEFT || mp1 == VK_UP) |
3730 _shift_focus_back(hwnd); | 3594 _shift_focus(hwnd, _DW_DIRECTION_BACKWARD); |
3731 if(mp1 == VK_RIGHT || mp1 == VK_DOWN) | 3595 if(mp1 == VK_RIGHT || mp1 == VK_DOWN) |
3732 _shift_focus(hwnd); | 3596 _shift_focus(hwnd, _DW_DIRECTION_FORWARD); |
3733 break; | 3597 break; |
3734 } | 3598 } |
3735 | 3599 |
3736 /* Make sure windows are up-to-date */ | 3600 /* Make sure windows are up-to-date */ |
3737 if(retval != -1) | 3601 if(retval != -1) |
5480 HWND API dw_notebook_new(ULONG id, int top) | 5344 HWND API dw_notebook_new(ULONG id, int top) |
5481 { | 5345 { |
5482 ULONG flags = 0; | 5346 ULONG flags = 0; |
5483 HWND tmp; | 5347 HWND tmp; |
5484 NotebookPage **array = calloc(256, sizeof(NotebookPage *)); | 5348 NotebookPage **array = calloc(256, sizeof(NotebookPage *)); |
5349 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); | |
5485 | 5350 |
5486 if(!top) | 5351 if(!top) |
5487 flags = TCS_BOTTOM; | 5352 flags = TCS_BOTTOM; |
5488 | 5353 |
5489 tmp = CreateWindow(WC_TABCONTROL, | 5354 tmp = CreateWindow(WC_TABCONTROL, |
5492 0,0,0,0, | 5357 0,0,0,0, |
5493 DW_HWND_OBJECT, | 5358 DW_HWND_OBJECT, |
5494 (HMENU)id, | 5359 (HMENU)id, |
5495 DWInstance, | 5360 DWInstance, |
5496 NULL); | 5361 NULL); |
5362 cinfo->fore = cinfo->back = -1; | |
5363 cinfo->pOldProc = SubclassWindow(tmp, _simplewndproc); | |
5364 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo); | |
5497 dw_window_set_data(tmp, "_dw_array", (void *)array); | 5365 dw_window_set_data(tmp, "_dw_array", (void *)array); |
5498 dw_window_set_font(tmp, DefaultFont); | 5366 dw_window_set_font(tmp, DefaultFont); |
5499 return tmp; | 5367 return tmp; |
5500 } | 5368 } |
5501 | 5369 |