NotificationMon.ƒ/Source/ScrollBar.c

#include "ScrollBar.h"
 
void CalcScrollBounds(WindowPtr wp, Rect *cBounds)
{
    *cBounds = wp->portRect;
    cBounds->top -= 1;
    cBounds->right += 1;
    cBounds->left = cBounds->right - 16;
    cBounds->bottom -= 14;
}
 
ControlHandle NewVScrollBar(WindowPtr wp)
{
    GrafPtr         savePort;
    ControlHandle   cHandle;
    Rect            cBounds;
    
    GetPort(&savePort);
    SetPort(wp);
    
    CalcScrollBounds(wp, &cBounds);
    
    cHandle = NewControl( wp, &cBounds, "\pVGrooviScroller", 
                            true, 1, 1, 1,
                         scrollBarProc, (long)wp);
        
    
    SetPort(savePort);
    
    return cHandle;
}
 
void SizeVScrollBar(ControlHandle scroll, WindowPtr wp)
{
    GrafPtr         savePort;
    ControlHandle   cHandle;
    Rect            cBounds;
    
    GetPort(&savePort);
    SetPort(wp);
    
    CalcScrollBounds(wp, &cBounds);
    
    HideControl(scroll);
    (**scroll).contrlRect = cBounds;
    ShowControl(scroll);
    
    SetPort(savePort);
}