[comp.windows.open-look] Scrolling bug & manual speak

blanchar@prlhp1.prl.philips.co.uk (blanchar) (03/23/91)

I've been writing code for a scrolling canvas to display a sound
waveform. I'm handling the scrolling myself so that I don't have 
to create a canvas that is millions of pixels long-which is procbably
impossible anyway.

Symptom:
	You grab the elevator and move it somewhere. This bit works fine,
	the correct parameters get passed to the scrolling func. But if you
	then do a page forward or backward the elevator shoots to the end.

Cause:
	I think the bug occurs in the function
	scrollbar_offset_to_client_units. This is called from
	scrollbar_default_compute_scroll_proc. The bit of code from XView
	is shown below.

	/*******/

      case SCROLLBAR_PAGE_FORWARD:
      case SCROLLBAR_PAGE_BACKWARD:
	if (sb->page_length != SCROLLBAR_DEFAULT_LENGTH && sb->page_length != 0) {
	    normalized_offset =
		(offset / (sb->pixels_per_unit * sb->page_length)) * sb->page_length;
	    /* should always divide equally -- won't when last page */
	    /* isn't a full page -- in this case jump to the end */
	    if ((normalized_offset * sb->pixels_per_unit) != offset) {
		normalized_offset = Max_offset(sb);
	    }
	} else {
	    normalized_offset = offset / sb->pixels_per_unit;
	}
	break;

	/******/


For example say:
	SCROLLBAR_PIXELS_PER_UNIT=10
	SCROLLBAR_PAGE_LENGTH=100

	the user picks up the elevator and moves it so that
	SCROLLBAR_VIEW_START=125, then there's a page forward so
	SCROLLBAR_VIEW_START=225,in client unit(=2250 absolutely).

	Now look at what normalised_offset is

	normalized_offset =
	(offset / (sb->pixels_per_unit * sb->page_length)) * sb->page_length;
	normalised_offset=(2250/(10*100))*100=200;
	
	and the check

	if ((normalized_offset * sb->pixels_per_unit) != offset) {
	if(200*10!=2250)
		normalized_offset = Max_offset(sb);

	Obviously it jumps to the end!

Cure:
	Write your own scrollbar_default_compute_scroll_proc.

Has anyone else spotted this behaviour?

Now for a classic bit of manual speak....
In the XView prog. man. page 161 it says...
"Message items, like buttons, are selectable and can have notify
procedures."

Two lines later it says....
"Since message items cannot be selected....."

Which is correct? I suspect the first. Anyone know for sure?

TTFN

Simon Blanchard