| 1064 | } |
| 1065 | |
| 1066 | BOOL |
| 1067 | onListChar(HWND hWnd, HWND hwndList, WORD ch) |
| 1068 | { |
| 1069 | int i = 0; |
| 1070 | PNHMenuWindow data; |
| 1071 | int curIndex, topIndex, pageSize; |
| 1072 | boolean is_accelerator = FALSE; |
| 1073 | |
| 1074 | data = (PNHMenuWindow) GetWindowLong(hWnd, GWL_USERDATA); |
| 1075 | |
| 1076 | switch (ch) { |
| 1077 | case MENU_FIRST_PAGE: |
| 1078 | i = 0; |
| 1079 | ListView_SetItemState(hwndList, i, LVIS_FOCUSED, LVIS_FOCUSED); |
| 1080 | ListView_EnsureVisible(hwndList, i, FALSE); |
| 1081 | return -2; |
| 1082 | |
| 1083 | case MENU_LAST_PAGE: |
| 1084 | i = max(0, data->menu.size - 1); |
| 1085 | ListView_SetItemState(hwndList, i, LVIS_FOCUSED, LVIS_FOCUSED); |
| 1086 | ListView_EnsureVisible(hwndList, i, FALSE); |
| 1087 | return -2; |
| 1088 | |
| 1089 | case MENU_NEXT_PAGE: |
| 1090 | topIndex = ListView_GetTopIndex(hwndList); |
| 1091 | pageSize = ListView_GetCountPerPage(hwndList); |
| 1092 | curIndex = ListView_GetNextItem(hwndList, -1, LVNI_FOCUSED); |
| 1093 | /* Focus down one page */ |
| 1094 | i = min(curIndex + pageSize, data->menu.size - 1); |
| 1095 | ListView_SetItemState(hwndList, i, LVIS_FOCUSED, LVIS_FOCUSED); |
| 1096 | /* Scrollpos down one page */ |
| 1097 | i = min(topIndex + (2 * pageSize - 1), data->menu.size - 1); |
| 1098 | ListView_EnsureVisible(hwndList, i, FALSE); |
| 1099 | return -2; |
| 1100 | |
| 1101 | case MENU_PREVIOUS_PAGE: |
| 1102 | topIndex = ListView_GetTopIndex(hwndList); |
| 1103 | pageSize = ListView_GetCountPerPage(hwndList); |
| 1104 | curIndex = ListView_GetNextItem(hwndList, -1, LVNI_FOCUSED); |
| 1105 | /* Focus up one page */ |
| 1106 | i = max(curIndex - pageSize, 0); |
| 1107 | ListView_SetItemState(hwndList, i, LVIS_FOCUSED, LVIS_FOCUSED); |
| 1108 | /* Scrollpos up one page */ |
| 1109 | i = max(topIndex - pageSize, 0); |
| 1110 | ListView_EnsureVisible(hwndList, i, FALSE); |
| 1111 | break; |
| 1112 | |
| 1113 | case MENU_SELECT_ALL: |
| 1114 | if (data->how == PICK_ANY) { |
| 1115 | reset_menu_count(hwndList, data); |
| 1116 | for (i = 0; i < data->menu.size; i++) { |
| 1117 | SelectMenuItem(hwndList, data, i, -1); |
| 1118 | } |
| 1119 | return -2; |
| 1120 | } |
| 1121 | break; |
| 1122 | |
| 1123 | case MENU_UNSELECT_ALL: |
no test coverage detected