MCPcopy Create free account
hub / github.com/NetHack/NetHack / MoveScrollBar

Function MoveScrollBar

outdated/sys/mac/macwin.c:1517–1587  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1515}
1516
1517static pascal void
1518MoveScrollBar(ControlHandle theBar, short part)
1519{
1520#if 1 //!TARGET_API_MAC_CARBON
1521 EventRecord fake;
1522#endif
1523 Rect r;
1524 RgnHandle rgn;
1525 int now, amtToScroll;
1526 WindowPtr theWin;
1527 NhWindow *winToScroll;
1528
1529 if (!part)
1530 return;
1531
1532 theWin = GetControlOwner(theBar);
1533 GetWindowBounds(theWin, kWindowContentRgn, &r);
1534 OffsetRect(&r, -r.left, -r.top);
1535 winToScroll = (NhWindow *) (GetWRefCon(theWin));
1536 now = GetControlValue(theBar);
1537
1538 if (part == kControlPageUpPart || part == kControlPageDownPart)
1539 amtToScroll = (r.bottom - r.top) / winToScroll->row_height;
1540 else
1541 amtToScroll = 1;
1542
1543 if (part == kControlPageUpPart || part == kControlUpButtonPart) {
1544 int bound = GetControlMinimum(theBar);
1545 if (now - bound < amtToScroll)
1546 amtToScroll = now - bound;
1547 amtToScroll = -amtToScroll;
1548 } else {
1549 int bound = GetControlMaximum(theBar);
1550 if (bound - now < amtToScroll)
1551 amtToScroll = bound - now;
1552 }
1553
1554 if (!amtToScroll)
1555 return;
1556
1557 SetControlValue(theBar, now + amtToScroll);
1558 winToScroll->scrollPos = now + amtToScroll;
1559 r.right -= SBARWIDTH;
1560 if (winToScroll == theWindows + WIN_MESSAGE)
1561 r.bottom -= SBARHEIGHT;
1562 rgn = NewRgn();
1563 ScrollRect(&r, 0, -amtToScroll * winToScroll->row_height, rgn);
1564 if (rgn) {
1565 InvalWindowRgn(theWin, rgn);
1566 BeginUpdate(theWin);
1567 }
1568#if 0 // TARGET_API_MAC_CARBON
1569 switch (GetWindowKind(theWin) - WIN_BASE_KIND) {
1570 case NHW_MESSAGE:
1571 MsgUpdate(GetNhWin(theWin));
1572 break;
1573 case NHW_MENU:
1574 MenwUpdate(GetNhWin(theWin));

Callers 2

filter_scroll_keyFunction · 0.85
mac_doprev_messageFunction · 0.85

Calls 4

MsgUpdateFunction · 0.85
GetNhWinFunction · 0.85
MenwUpdateFunction · 0.85
TextUpdateFunction · 0.85

Tested by

no test coverage detected