home *** CD-ROM | disk | FTP | other *** search
- * ' PROCLIB
- * '
- * ' Procedures for handling scrolling and clicking
- * '
-
- procedure scroll
- * '
- * ' Manages the actions associated with a scroll event
- * '
- * '
- * ' The following variables must be declared in the calling proc:
- * '
- * ' mthumb - the current thumbwheel position
- * ' mscreensz - the window size
- * ' mdisplines - the window size minus 1
- * ' mtoprec - the recno() of the 1st record in window
- * ' mplace - the current place in the window
- * ' mredraw - whether to redraw the window or not
- * '
- * '
- * ' Assumptions:
- * '
- * ' the scrolled window is window 1
- * ' msfactor is calculated by the calling procedure
- * ' as follows:
- * '
- * ' msfactor = 1000 / (reccount() - mdisplines)
- * '
- * '
- scrollbar = hmenu()
- action = vmenu()
- modif = mrow()
- do scroll_win with scrollbar, action, modif
- return
-
-
- procedure scroll_win
- parameters hm, vm, mr
- *
- * the following do..while clears the event.
- * this was screwing up mrow() and dragging the mthumbwheel.
- *
- if .not. os() $ 'MSDOS'
- do while .t.
- if chkevent() = -1
- exit
- endif
- enddo
- endif
- * if hm = 0
- * return
- * endif
- select window 1
- do case
- case vm = 1 && Up Arrow
- if mplace > 1
- dec mplace
- else
- if reccount() <= mdisplines
- select window 0
- return
- endif
- mplace = 1
- mthumb = mthumb - msfactor
- if mthumb < 1
- mthumb = 1
- endif
- * setscroll(hm,round(mthumb,0))
- skip -1
- dec mtoprec
- if bof()
- go top
- mtoprec = 1
- endif
- mredraw = .t.
- * Do MySetScroll
- endif
- case vm = 2 && down Arrow
- if mplace >= reccount()
- select window 0
- return
- endif
- if mplace < mscreensz
- inc mplace
- else
- mplace = mscreensz
- mthumb = mthumb + msfactor
- if mthumb > 1000
- mthumb = 1000
- endif
- * setscroll(hm,round(mthumb,0))
- skip 1
- inc mtoprec
- if mtoprec + mscreensz > reccount() + 1
- skip -1
- dec mtoprec
- endif
- * Do MySetScroll
- mredraw = .t.
- endif
- case vm = 3 && Page Up
- if reccount() <= mdisplines
- select window 0
- return
- endif
- mthumb = mthumb - (msfactor * mdisplines)
- if mthumb < 1
- mthumb = 1
- endif
- setscroll(hm,round(mthumb,0))
- if recno() - mdisplines < 1
- go top
- else
- skip -mdisplines
- endif
- if bof()
- go top
- endif
- mtoprec = recno()
- mplace = 1
- mredraw = .t.
- case vm = 4 && Page down
- if reccount() <= mdisplines
- select window 0
- return
- endif
- mthumb = mthumb + (msfactor * mdisplines)
- if mthumb > 1000
- mthumb = 1000
- endif
- setscroll(hm,round(mthumb,0))
- skip mdisplines
- if recno() + mdisplines >= reccount()
- go bottom
- skip -mdisplines
- endif
- mtoprec = recno()
- mplace = 1
- mredraw = .t.
- case vm = 5 && Drag mthumb
- if reccount() <= mdisplines
- select window 0
- return
- endif
- mthumb = mr
- setscroll(hm,mr)
- y = mr / 1000
- mcount = round(reccount() * y)
- store iifn(mcount < 1,1,mcount) to mcount
- store iifn(mcount > reccount() - mdisplines,;
- reccount() - mdisplines,mcount) to mcount
- go mcount
- mtoprec = recno()
- mplace = 1
- mredraw = .t.
- endcase
- select window 0
-
- return
-
-
- procedure click
-
- msaveplace = mplace
- if mrow() > 0
- mplace = mrow()
- if mtoprec + (mplace - 1) > reccount()
- ?? chr(7)
- mplace = msaveplace
- endif
- go mtoprec + (mplace - 1)
- endif
-
- return
-
- ****************************
- procedure MySetScroll
- ****************************
- if reccount() <= mscreensz .or. mtoprec = 1
- moffset = 1
- else
- diviz = 1000.000 / (reccount() - mscreensz)
- moffset = (mtoprec - 1) * diviz
- endif
- setscroll(1,round(moffset,0))
- return