494 |
494 |
495 if (y < 0) |
495 if (y < 0) |
496 return - 1; |
496 return - 1; |
497 |
497 |
498 item = y / 10; |
498 item = y / 10; |
499 if (item >= WP(w,dropdown_d).num_items || (HASBIT(WP(w,dropdown_d).disabled_state, item) && !HASBIT(WP(w,dropdown_d).hidden_state, item)) || WP(w,dropdown_d).items[item] == 0) |
499 if (item >= WP(w,dropdown_d).num_items || (HasBit(WP(w,dropdown_d).disabled_state, item) && !HasBit(WP(w,dropdown_d).hidden_state, item)) || WP(w,dropdown_d).items[item] == 0) |
500 return - 1; |
500 return - 1; |
501 |
501 |
502 /* Skip hidden items -- +1 for each hidden item before the clicked item. */ |
502 /* Skip hidden items -- +1 for each hidden item before the clicked item. */ |
503 for (counter = 0; item >= counter; ++counter) |
503 for (counter = 0; item >= counter; ++counter) |
504 if (HASBIT(WP(w,dropdown_d).hidden_state, counter)) item++; |
504 if (HasBit(WP(w,dropdown_d).hidden_state, counter)) item++; |
505 |
505 |
506 return item; |
506 return item; |
507 } |
507 } |
508 |
508 |
509 static void DropdownMenuWndProc(Window *w, WindowEvent *e) |
509 static void DropdownMenuWndProc(Window *w, WindowEvent *e) |
523 sel = WP(w,dropdown_d).selected_index; |
523 sel = WP(w,dropdown_d).selected_index; |
524 width = w->widget[0].right - 3; |
524 width = w->widget[0].right - 3; |
525 height = w->widget[0].bottom - 3; |
525 height = w->widget[0].bottom - 3; |
526 |
526 |
527 for (i = 0; WP(w,dropdown_d).items[i] != INVALID_STRING_ID; i++, sel--) { |
527 for (i = 0; WP(w,dropdown_d).items[i] != INVALID_STRING_ID; i++, sel--) { |
528 if (HASBIT(WP(w,dropdown_d).hidden_state, i)) continue; |
528 if (HasBit(WP(w,dropdown_d).hidden_state, i)) continue; |
529 |
529 |
530 if (y >= 0 && y <= height) { |
530 if (y >= 0 && y <= height) { |
531 if (WP(w,dropdown_d).items[i] != STR_NULL) { |
531 if (WP(w,dropdown_d).items[i] != STR_NULL) { |
532 if (sel == 0) GfxFillRect(x + 1, y, x + width, y + 9, 0); |
532 if (sel == 0) GfxFillRect(x + 1, y, x + width, y + 9, 0); |
533 DrawStringTruncated(x + 2, y, WP(w,dropdown_d).items[i], sel == 0 ? TC_WHITE : TC_BLACK, x + width); |
533 DrawStringTruncated(x + 2, y, WP(w,dropdown_d).items[i], sel == 0 ? TC_WHITE : TC_BLACK, x + width); |
534 |
534 |
535 if (HASBIT(WP(w,dropdown_d).disabled_state, i)) { |
535 if (HasBit(WP(w,dropdown_d).disabled_state, i)) { |
536 GfxFillRect(x, y, x + width, y + 9, |
536 GfxFillRect(x, y, x + width, y + 9, |
537 (1 << PALETTE_MODIFIER_GREYOUT) | _colour_gradient[_dropdown_menu_widgets[0].color][5] |
537 (1 << PALETTE_MODIFIER_GREYOUT) | _colour_gradient[_dropdown_menu_widgets[0].color][5] |
538 ); |
538 ); |
539 } |
539 } |
540 } else { |
540 } else { |
628 |
628 |
629 if (hidden_mask != 0) { |
629 if (hidden_mask != 0) { |
630 uint j; |
630 uint j; |
631 |
631 |
632 for (j = 0; strings[j] != INVALID_STRING_ID; j++) { |
632 for (j = 0; strings[j] != INVALID_STRING_ID; j++) { |
633 if (HASBIT(hidden_mask, j)) i--; |
633 if (HasBit(hidden_mask, j)) i--; |
634 } |
634 } |
635 } |
635 } |
636 |
636 |
637 /* The preferred position is just below the dropdown calling widget */ |
637 /* The preferred position is just below the dropdown calling widget */ |
638 top = w->top + wi->bottom + 2; |
638 top = w->top + wi->bottom + 2; |