It looks like you are reinventing the wheel but you will find much of what
you want in Jonathan Hudson's code (C68) for CView. This is still to be
found (tho' I haven't checked) on Dilwyn's web site. His handling of
scrollable/pannable screens provided the basis for MView.
Christopher Cave
This is something I ought to document at some point, as it is not the
easiest of subjects if you have never used it before. This explanation is
for use with BASIC or compiled BASIC.
I always use Easyptr 4 for this - earlier Easyptrs should work too (unless
you want to use GD2).
This is done by using the MAWBAR (and MAWBARR if you want to use the arrows,
but MAWBAR is easier).
1. set up a suitable window, allowing 8 pixels across the width of a
vertical scroll bar, and 5 pixels deep for the horizontal pan bars. The
window does NOT expand to take these bars, they are drawn INSIDE the window.
So if you want a window to display, say, 480x200 pixels it has to actually
be 488 wide inside the window border and 485 deep.
2. Set up the pan and scroll bars with a MAWBAR command:
MAWBAR
#channel,app_window_number,wide%,high%,x_start%,y_start%,x_grid%,y_grid%
wide% = number of vertical columns (can be bigger than screen)
high% = number of horizonatl rows (also can be bigger than screen)
x_start%, y_start% = coordinates of top left corner of the part shown
x_grid%,y_grid% = grid width and height. Could be 1 if graphics, or text
might be 6x10 for example
3. To remove the bar later (not explained in manual) use MWINDOW
#channel,app_window_num:MAWBAR #ch,0,0:mdraw
#channel,app_window_num,0,0:MDRAW #channel
4. Reading the bars is not as easy and needs a working example. Basically,
you use the value returned by MCALL to check if the action done by the user
was on a loose item (negative values), an application window (1 to 256), or
a special item number (>65536). Break down the value of MCALL with MAWNUM
and take appropriate SELectactions depending on the values.
MAWNUM with 4 parameters will break down the composite return value of
MCALL, which is operation code in bits 0-3 and the pixel position
information in bits 4 to 15.
action = MCALL(#channel)
winum = action : REMark temporary value
mpnum = MAWNUM(#channel,winum,x_st%,y_st%)
this returns mpnum as the action number (see easyptr manual) and winum is
the window number of the window hit. Then x_st% is the pixel position of the
hit onthe bar and y_st% is the length of the bar.
action = MCALL(#channel)
1900 SELect ON action
1910 =-1,-2........ : REMark loose items
1920 =1 TO 256 : REMark application windows
1970 =REMAINDER : REMark check for pan/scroll bars
1980 winum = num : x_st% = 0 : y_st% = 0
1990 mpnum = MAWNUM(#0,winum,x_st%,y_st%) : REMark opcode etc
2000 IF winum = 1 THEN
2010 REMark app window 1
2020 IF mpnum = 0 AND x_st% = 0 AND y_st% = 0 THEN
2030 REMark something in app win 1 itself hit
2040 ELSE
2050 REMark one of the pan/scroll bars hit
2060 REMark x_st% = pixel position of hit on bar
2070 REMark y_st% = length of the bar
2080 REMark mpnum is the operation code 0 to 4 (unused ones are
split/join)
2090 REMark beware of special case of mpnum=0 & x_st%=0 & y_st%=0
above
2100 SELect ON mpnum
2110 =0,8 : REMark hit/do on scroll bar
2120 oy% = x_st%*ph%/y_st% : REMark SHOW must adjust oy% if
out of range
2130 =4,12 : REMark hit/do on pan bar
2140 ox% = x_st%*ph%/y_st% : REMark SHOW must adjust ox% if
out of range
2150 END SELect
2160 END IF
In this example, ox% and oy% are the co-ordinates of the position visible on
the screen of the virtual page. pw% and ph% are the page width and height of
the virtual page.
This is not the easiest of subjects, especially if you start using the
advanced options with the MCALLT extension.
Hope this helps get you started enough to explore the possibilities further.
--
Dilwyn Jones
_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm