| 499 | } |
| 500 | |
| 501 | static void |
| 502 | DrawScrollbar(NhWindow *aWin) |
| 503 | { |
| 504 | WindowPtr theWindow = aWin->its_window; |
| 505 | Rect crect, wrect; |
| 506 | Boolean vis; |
| 507 | short val, lin, win_height; |
| 508 | |
| 509 | if (!aWin->scrollBar) |
| 510 | return; |
| 511 | GetControlBounds(aWin->scrollBar, &crect); |
| 512 | GetWindowBounds(aWin->its_window, kWindowContentRgn, &wrect); |
| 513 | OffsetRect(&wrect, -wrect.left, -wrect.top); |
| 514 | win_height = wrect.bottom - wrect.top; |
| 515 | |
| 516 | if (crect.top != wrect.top - 1 || crect.left != wrect.right - SBARWIDTH) { |
| 517 | MoveControl(aWin->scrollBar, wrect.right - SBARWIDTH, wrect.top - 1); |
| 518 | } |
| 519 | if (crect.bottom != wrect.bottom - SBARHEIGHT |
| 520 | || crect.right != wrect.right + 1) { |
| 521 | SizeControl(aWin->scrollBar, SBARWIDTH + 1, |
| 522 | win_height - SBARHEIGHT + 2); |
| 523 | } |
| 524 | vis = (win_height > (50 + SBARHEIGHT)); |
| 525 | if (vis != IsControlVisible(aWin->scrollBar)) { |
| 526 | /* current status != control */ |
| 527 | if (vis) /* if visible, show */ |
| 528 | ShowControl(aWin->scrollBar); |
| 529 | else /* else hide */ |
| 530 | HideControl(aWin->scrollBar); |
| 531 | } |
| 532 | lin = aWin->y_size; |
| 533 | if (aWin == theWindows + WIN_MESSAGE) { |
| 534 | /* calculate how big scroll bar is for message window */ |
| 535 | lin -= (win_height - SBARHEIGHT) / aWin->row_height; |
| 536 | if (lin < 0) |
| 537 | lin = 0; |
| 538 | val = 0; /* always have message scrollbar active */ |
| 539 | } else { |
| 540 | /* calculate how big scroll bar is for other windows */ |
| 541 | lin -= win_height / aWin->row_height; |
| 542 | if (lin < 0) |
| 543 | lin = 0; |
| 544 | if (lin) |
| 545 | val = 0; /* if there are 1+ screen lines, activate scrollbar */ |
| 546 | else |
| 547 | val = 255; /* else grey it out */ |
| 548 | } |
| 549 | SetControlMaximum(aWin->scrollBar, lin); |
| 550 | HiliteControl(aWin->scrollBar, val); |
| 551 | val = GetControlValue(aWin->scrollBar); |
| 552 | if (val != aWin->scrollPos) { |
| 553 | InvalWindowRect(theWindow, &wrect); |
| 554 | aWin->scrollPos = val; |
| 555 | } |
| 556 | } |
| 557 | |
| 558 | #define MAX_HEIGHT 100 |
no outgoing calls
no test coverage detected