| 15274 | |
| 15275 | |
| 15276 | ResultType GuiControlType::LV_GetNextOrCount(ResultToken &aResultToken, int aID, int aFlags, ExprTokenType *aParam[], int aParamCount) |
| 15277 | // LV.GetNext: |
| 15278 | // Returns: The index of the found item, or 0 on failure. |
| 15279 | // Parameters: |
| 15280 | // 1: Starting index (one-based when it comes in). If absent, search starts at the top. |
| 15281 | // 2: Options string. |
| 15282 | // 3: (FUTURE): Possible for use with LV.FindItem (though I think it can only search item text, not subitem text). |
| 15283 | { |
| 15284 | HWND control_hwnd = hwnd; |
| 15285 | |
| 15286 | LPTSTR options; |
| 15287 | if (aID == FID_LV_GetCount) |
| 15288 | { |
| 15289 | options = (aParamCount > 0) ? omit_leading_whitespace(ParamIndexToString(0, _f_number_buf)) : _T(""); |
| 15290 | if (*options) |
| 15291 | { |
| 15292 | if (ctoupper(*options) == 'S') |
| 15293 | _o_return(SendMessage(control_hwnd, LVM_GETSELECTEDCOUNT, 0, 0)); |
| 15294 | else if (!_tcsnicmp(options, _T("Col"), 3)) // "Col" or "Column". Don't allow "C" by itself, so that "Checked" can be added in the future. |
| 15295 | _o_return(union_lv_attrib->col_count); |
| 15296 | else |
| 15297 | _o_throw_param(0); |
| 15298 | } |
| 15299 | _o_return(SendMessage(control_hwnd, LVM_GETITEMCOUNT, 0, 0)); |
| 15300 | } |
| 15301 | // Since above didn't return, this is GetNext() mode. |
| 15302 | |
| 15303 | int index = -1; |
| 15304 | if (!ParamIndexIsOmitted(0)) |
| 15305 | { |
| 15306 | if (!ParamIndexIsNumeric(0)) |
| 15307 | _o_throw_param(0, _T("Number")); |
| 15308 | index = ParamIndexToInt(0) - 1; // -1 to convert to zero-based. |
| 15309 | // For flexibility, allow index to be less than -1 to avoid first-iteration complications in script loops |
| 15310 | // (such as when deleting rows, which shifts the row index upward, require the search to resume at |
| 15311 | // the previously found index rather than the row after it). However, reset it to -1 to ensure |
| 15312 | // proper return values from the API in the "find checked item" mode used below. |
| 15313 | if (index < -1) |
| 15314 | index = -1; // Signal it to start at the top. |
| 15315 | } |
| 15316 | |
| 15317 | // For performance, decided to always find next selected item when the "C" option hasn't been specified, |
| 15318 | // even when the checkboxes style is in effect. Otherwise, would have to fetch and check checkbox style |
| 15319 | // bit for each call, which would slow down this heavily-called function. |
| 15320 | |
| 15321 | options = ParamIndexToOptionalString(1, _f_number_buf); |
| 15322 | TCHAR first_char = ctoupper(*omit_leading_whitespace(options)); |
| 15323 | // To retain compatibility in the future, also allow "Check(ed)" and "Focus(ed)" since any word that |
| 15324 | // starts with C or F is already supported. |
| 15325 | |
| 15326 | switch(first_char) |
| 15327 | { |
| 15328 | case '\0': // Listed first for performance. |
| 15329 | case 'F': |
| 15330 | _o_return(ListView_GetNextItem(control_hwnd, index |
| 15331 | , first_char ? LVNI_FOCUSED : LVNI_SELECTED) + 1); // +1 to convert to 1-based. |
| 15332 | case 'C': // Checkbox: Find checked items. For performance assume that the control really has checkboxes. |
| 15333 | { |
nothing calls this directly
no test coverage detected