model_server/gra/src/graWindow.h.cxx
/*_______________________________________________________________________
!
! Member:	graWindow::dialog_scrollbars
!
! Arguments:	int
!
! Returns:	void
!
! Synopsis:	Sends information about the perspective to the dialog so it will
!		show up in any scrollbars or panners that may be attached.
!
!		class Perspective
!    		IntCoord x0, y0;		origin of the graphic
!    		int width, height;		total size of the graphic
!    		IntCoord curx, cury;		current view position
!    		int curwidth, curheight;	current view size
!    		int sx, sy, lx, ly;		small and large scrolling increments
!
!		Calculates the scroll_bars' size as the percentage of the
!		graphic shown in the view, roughly (max - min) * (view size / graphic size).
!		The scroll value can be any value between the control's
!		(min + control's size) and max.
!
! Warning:	This routine must measure the scroll bar's position
!		by it's right edge as opposed to the left, our error.
!	        There should be some rounding error induced in the
!		scroll -> view relation since we calculate the scroll
!		bar's position from the view if the thumb box is moved.
!
_______________________________________________________________________*/


int

void

Sends information about the perspective to the dialog so it will
show up in any scrollbars or panners that may be attached.

class Perspective
IntCoord x0, y0;                origin of the graphic
int width, height;              total size of the graphic
IntCoord curx, cury;            current view position
int curwidth, curheight;        current view size
int sx, sy, lx, ly;             small and large scrolling increments

Calculates the scroll_bars' size as the percentage of the
graphic shown in the view, roughly (max - min) * (view size / graphic size).
The scroll value can be any value between the control's
(min + control's size) and max.

This routine must measure the scroll bar's position
by it's right edge as opposed to the left, our error.
There should be some rounding error induced in the
scroll -> view relation since we calculate the scroll
bar's position from the view if the thumb box is moved.


int void Sends information about the perspective to the dialog so it will show up in any scrollbars or panners that may be attached . class Perspective IntCoord x0 y0 ; origin of the graphic int width height ; total size of the graphic IntCoord curx cury ; current view position int curwidth curheight ; current view size int sx sy lx ly ; small and large scrolling increments Calculates the scroll_bars ' size as the percentage of the graphic shown in the view roughly ( max - min ) * ( view size / graphic size ) . The scroll value can be any value between the control ' s ( min + control ' s size ) and max . This routine must measure the scroll bar ' s position by it ' s right edge as opposed to the left our error . There should be some rounding error induced in the scroll - > view relation since we calculate the scroll bar ' s position from the view if the thumb box is moved .
void graWindow::dialog_scrollbars()
{
    Initialize(graWindow::dialog_scrollbars);
    dialogPtr dlg = driver_instance->find_dialog_for_view(view_header);
    if(dlg == NULL)
	return;
    const int ticks = 100;
    const int view_num = dlg->get_view_num(view_header);
    dlg->set_vert_scrollbar_range(view_num, 0, ticks);
    iv3(Perspective)* ps = GetPerspective();
    int horiz_size = ticks;
    if((ps->width) && (ps->width - ps->curwidth > 0))
	horiz_size = round(double(ticks) * double(ps->curwidth)
			   / double(ps->width));
    if(horiz_size > ticks)
	horiz_size = ticks;
    int vert_size = ticks;
    if((ps->height) && (ps->height - ps->curheight > 0))
	vert_size = round(double(ticks) * double(ps->curheight)
			  / double(ps->height));
    if(vert_size > ticks)
	vert_size = ticks;
    int horiz_val = 0;
    if ((ps->width - ps->curwidth) > 0)
	horiz_val = round(double(horiz_size) + (double(ps->curx - ps->x0)
			   * double(ticks - horiz_size))
			  / double(ps->width - ps->curwidth));
    if(horiz_val > ticks)
	horiz_val = ticks;
    int vert_val = ticks;
    if (((ps->height - ps->curheight) > 0) && (ticks - vert_size != 0))
	vert_val = round(double(vert_size) + ((double(1) - double(ps->cury - ps->y0)
 			 / double(ps->height - ps->curheight)))
			 * double(ticks - vert_size));
    if(vert_val > ticks)
	vert_val = ticks;
    dlg->set_horiz_slider_size(view_num, horiz_size);
    dlg->set_vert_slider_size(view_num, vert_size);
    dlg->set_horiz_scrollbar_value(view_num, horiz_val);
    dlg->set_vert_scrollbar_value(view_num, vert_val);
}
void graWindow :: dialog_scrollbars ( ) { Initialize ( graWindow :: dialog_scrollbars ) ; dialogPtr dlg = driver_instance -> find_dialog_for_view ( view_header ) ; if ( dlg == NULL ) return ; const int ticks = 100 ; const int view_num = dlg -> get_view_num ( view_header ) ; dlg -> set_vert_scrollbar_range ( view_num , 0 , ticks ) ; iv3 ( Perspective ) * ps = GetPerspective ( ) ; int horiz_size = ticks ; if ( ( ps -> width ) && ( ps -> width - ps -> curwidth > 0 ) ) horiz_size = round ( double ( ticks ) * double ( ps -> curwidth ) / double ( ps -> width ) ) ; if ( horiz_size > ticks ) horiz_size = ticks ; int vert_size = ticks ; if ( ( ps -> height ) && ( ps -> height - ps -> curheight > 0 ) ) vert_size = round ( double ( ticks ) * double ( ps -> curheight ) / double ( ps -> height ) ) ; if ( vert_size > ticks ) vert_size = ticks ; int horiz_val = 0 ; if ( ( ps -> width - ps -> curwidth ) > 0 ) horiz_val = round ( double ( horiz_size ) + ( double ( ps -> curx - ps -> x0 ) * double ( ticks - horiz_size ) ) / double ( ps -> width - ps -> curwidth ) ) ; if ( horiz_val > ticks ) horiz_val = ticks ; int vert_val = ticks ; if ( ( ( ps -> height - ps -> curheight ) > 0 ) && ( ticks - vert_size != 0 ) ) vert_val = round ( double ( vert_size ) + ( ( double ( 1 ) - double ( ps -> cury - ps -> y0 ) / double ( ps -> height - ps -> curheight ) ) ) * double ( ticks - vert_size ) ) ; if ( vert_val > ticks ) vert_val = ticks ; dlg -> set_horiz_slider_size ( view_num , horiz_size ) ; dlg -> set_vert_slider_size ( view_num , vert_size ) ; dlg -> set_horiz_scrollbar_value ( view_num , horiz_val ) ; dlg -> set_vert_scrollbar_value ( view_num , vert_val ) ; }
_______________________________________________________________________
Member:        graWindow::dialog_scrollbars
_______________________________________________________________________ Member : graWindow :: dialog_scrollbars