================= Scroll_ListBox_ThumbFunc ================= */
| 10510 | ================= |
| 10511 | */ |
| 10512 | static void Scroll_ListBox_ThumbFunc(void *p) |
| 10513 | { |
| 10514 | scrollInfo_t *si = (scrollInfo_t*)p; |
| 10515 | rectDef_t r; |
| 10516 | int pos, max; |
| 10517 | |
| 10518 | listBoxDef_t *listPtr = (listBoxDef_t*)si->item->typeData; |
| 10519 | if (si->item->window.flags & WINDOW_HORIZONTAL) |
| 10520 | { |
| 10521 | if (DC->cursorx == si->xStart) |
| 10522 | { |
| 10523 | return; |
| 10524 | } |
| 10525 | r.x = si->item->window.rect.x + SCROLLBAR_SIZE + 1; |
| 10526 | r.y = si->item->window.rect.y + si->item->window.rect.h - SCROLLBAR_SIZE - 1; |
| 10527 | r.h = SCROLLBAR_SIZE; |
| 10528 | r.w = si->item->window.rect.w - (SCROLLBAR_SIZE*2) - 2; |
| 10529 | max = Item_ListBox_MaxScroll(si->item); |
| 10530 | // |
| 10531 | pos = (DC->cursorx - r.x - SCROLLBAR_SIZE/2) * max / (r.w - SCROLLBAR_SIZE); |
| 10532 | if (pos < 0) |
| 10533 | { |
| 10534 | pos = 0; |
| 10535 | } |
| 10536 | else if (pos > max) |
| 10537 | { |
| 10538 | pos = max; |
| 10539 | } |
| 10540 | listPtr->startPos = pos; |
| 10541 | si->xStart = DC->cursorx; |
| 10542 | } |
| 10543 | else if (DC->cursory != si->yStart) |
| 10544 | { |
| 10545 | |
| 10546 | r.x = si->item->window.rect.x + si->item->window.rect.w - SCROLLBAR_SIZE - 1; |
| 10547 | r.y = si->item->window.rect.y + SCROLLBAR_SIZE + 1; |
| 10548 | r.h = si->item->window.rect.h - (SCROLLBAR_SIZE*2) - 2; |
| 10549 | r.w = SCROLLBAR_SIZE; |
| 10550 | max = Item_ListBox_MaxScroll(si->item); |
| 10551 | // |
| 10552 | pos = (DC->cursory - r.y - SCROLLBAR_SIZE/2) * max / (r.h - SCROLLBAR_SIZE); |
| 10553 | if (pos < 0) |
| 10554 | { |
| 10555 | pos = 0; |
| 10556 | } |
| 10557 | else if (pos > max) |
| 10558 | { |
| 10559 | pos = max; |
| 10560 | } |
| 10561 | listPtr->startPos = pos; |
| 10562 | si->yStart = DC->cursory; |
| 10563 | } |
| 10564 | |
| 10565 | if (DC->realTime > si->nextScrollTime) |
| 10566 | { |
| 10567 | // need to scroll which is done by simulating a click to the item |
| 10568 | // this is done a bit sideways as the autoscroll "knows" that the item is a listbox |
| 10569 | // so it calls it directly |
nothing calls this directly
no test coverage detected