================= Item_ListBox_ThumbPosition ================= */
| 8910 | ================= |
| 8911 | */ |
| 8912 | int Item_ListBox_ThumbPosition(itemDef_t *item) |
| 8913 | { |
| 8914 | float max, pos, size; |
| 8915 | listBoxDef_t *listPtr = (listBoxDef_t*)item->typeData; |
| 8916 | |
| 8917 | max = Item_ListBox_MaxScroll(item); |
| 8918 | if (item->window.flags & WINDOW_HORIZONTAL) { |
| 8919 | |
| 8920 | size = item->window.rect.w - (SCROLLBAR_SIZE * 2) - 2; |
| 8921 | if (max > 0) |
| 8922 | { |
| 8923 | pos = (size-SCROLLBAR_SIZE) / (float) max; |
| 8924 | } |
| 8925 | else |
| 8926 | { |
| 8927 | pos = 0; |
| 8928 | } |
| 8929 | pos *= listPtr->startPos; |
| 8930 | return item->window.rect.x + 1 + SCROLLBAR_SIZE + pos; |
| 8931 | } |
| 8932 | else |
| 8933 | { |
| 8934 | size = item->window.rect.h - (SCROLLBAR_SIZE * 2) - 2; |
| 8935 | if (max > 0) |
| 8936 | { |
| 8937 | pos = (size-SCROLLBAR_SIZE) / (float) max; |
| 8938 | } |
| 8939 | else |
| 8940 | { |
| 8941 | pos = 0; |
| 8942 | } |
| 8943 | pos *= listPtr->startPos; |
| 8944 | return item->window.rect.y + 1 + SCROLLBAR_SIZE + pos; |
| 8945 | } |
| 8946 | } |
| 8947 | |
| 8948 | /* |
| 8949 | ================= |
no test coverage detected