/* Scrollable windows */ #include "vibrant.h" #include "common.h" #define X (5*stdLineHeight) Global(GrouP) InitLargeWindow(WindoW window) { GrouP OuterGroup,UserGroup; OuterGroup=HiddenGroup(window,-2,0,NULL); SetGroupSpacing(OuterGroup,stdCharWidth>>1,0); SetGroupMargins(OuterGroup,0,0); UserGroup=HiddenGroup(OuterGroup,0,100,NULL); SetGroupSpacing(UserGroup,0,0); SetGroupMargins(UserGroup,0,0); return UserGroup; } Local(void) BarProc(BaR bar, GraphiC graphic, Int2 new, Int2 old); Local(Int2) Mheight; #define ONE X /* (5*stdLineHeight) */ Global(void) ShowLargeWindow(GrouP UserGroup) { WindoW window; GrouP OuterGroup; BaR bar; RecT r,rb; Int2 height; window=ParentWindow(UserGroup); OuterGroup=Parent(UserGroup); GetPosition(OuterGroup,&r); height=r.bottom-r.top+X; Mheight=screenRect.bottom-screenRect.top; if (height>=Mheight) { bar=ScrollBar(OuterGroup,0,(Mheight-X)/stdLineHeight,BarProc); SetObjectExtra(bar,(VoidPtr)UserGroup,NULL); CorrectBarMax(bar,(height-Mheight+X)/ONE); CorrectBarPage(bar,5,5); CorrectBarValue(bar,0); RealizeWindow(window); GetPosition(window,&r); GetPosition(OuterGroup,&rb); r.top=screenRect.top+(X>>1); r.bottom=screenRect.bottom-(X>>1); SetPosition(window,&r); ObjectRect(window,&rb); GetPosition(bar,&r); r.top=0; r.bottom=rb.bottom-rb.top; r.right=rb.right-rb.left; r.left=r.right-vScrollBarWidth; SetPosition(bar,&r); } Show(window); } #if _WIN #pragma argsused #endif Local(void) BarProc(BaR bar, GraphiC graphic, Int2 new, Int2 old) { GrouP UserGroup; RecT r; Int2 off; UserGroup=(GrouP)GetObjectExtra(bar); off=(old-new)*ONE; GetPosition(UserGroup,&r); OffsetRect(&r,0,off); Hide(UserGroup); SetPosition(UserGroup,&r); Show(UserGroup); }