Return home 

VWin Scrollbar Library

A collection of routines that implement scrollbars, scrolling windows, draggable windows, and buttons. 
Psion5 friendly  

VWin is a collection of routines for OPL programmers, which are designed to make the implementation of scrollbars and scrollable windows simple. In addition, there are routines to put draggable window titles, borders, and pressable buttons.
 
For examples of the scrollbars created by VWin, see either the Disassembler on this site, or Russ Spooner's HtmlEdit (in which half of this site was written).
For an example of the virtual window, and the buttons, see the Global Find application's main screen on this site.


General Calls
Scrollbar Calls
Virtual Window Calls
Button Calls

Download



The following calls are available:

General Calls

Defines the global variables need by the VWin system.
PROC VWinLink:(AppCont$)

Clears any active dragging operation
PROC VWinResetDrag:

Offers a pen event to the virtual window system
PROC VWinOffer%:(WinId&,EvType&,X&,Y&)

PROC WinBorder:(WinId%,Type%,Width%)
Sets the border type (see gXBORDER) and width in pixels of the border returned by WinGetBorder%:

PROC WinTitle:(WinId%,Title$)
Sets the title of the window and enables the window to be moved. Takes into account the border as set by WinBorder:

Scrollbar Calls

Creates a scrollbar and returns its handle. The ScrollBar appears on window WinId% at position px%,py% len% represents the height if the scrollbar is Vertical, or the width if the scrollbar is horizontal
PROC SbCreate&:(WinId%,Orient%,px%,py%,len%,CallBack$)

Whenever the scrollbar is moved, the procedure whose name is in CallBack$ will be called:
@(CallBack):(SbId&,OldTop&)
The global variables (described below) will be set to indicate the new position

Sets the full extent of the scrollbar, and the size of the current view. Eg, SbSetExtent:(Sb&,400,100) sets the size of the scrollbar to be 1/4 maximum
PROC SbSetExtent:(SbId&,Extent&,ViewSize&)

Sets the current view position of the scrollbar. The scrollbar will be redrawn in the new position. The allowed range for Top& is 0 <= Top& <= Extent&-ViewSize&
PROC SbSetView:(SbId&,Top&)

Destroys the scrollbar, blanks it from the display, and releases all resources associated with it
PROC SbDestroy:(SbId&)

Sets an application specific word associated with the ScrollBar
This word is passed back as SbAppWord&
PROC SbSetWord:(SbId&,Word&)

Get the global variables for the scrollbar
PROC SbGetVars:(SbId&)

The following variables are set by a call to SbGetVars: They will also be set before any callback procedure is called.

SbWinId% - The OPL window that contains the ScrollBar
SbOrient% - The orientation (eg: KSbVertical%)
SbExtent& - The full extent of the ScrollBar
SbViewSize& - How much of the extent is visible
SbTop& - The position of the top of the ScrollBar in the extent
SbPx% - The posn of the scrollbar in pixels
SbPy% - The posn of the scrollbar in pixels
SbLength% - The size of the ScrollBar in pixels (width or height)
SbCallBack$ - The name of the callback routine
SbAppWord& - An arbitrary word for application use

Virtual Window Calls

Creates a new virtual window and returns its handle. The VirtualWindow occupies the area given by (px%,py%) (width%,height%) on the OPL window WinId%
PROC VwCreate&:(WinId%,px%,py%,width%,height%,CallBack$)
Whenever the virtual window is scrolled, and an area of the screen needs to be re-drawn, the procedure whose name is in CallBack$ will be called with the position and size of the area to be redrawn, both in VwUnits and in pixels
@(CallBack$):(VwId&,WinId%,LX&,TY&,W&,H&,LX%,TY%,W%,H%)
The global variables (described below) will be set to indicate the new position

Sets Flags associated with a virtual window
PROC VwSetFlags:(VwId&,Clear%,Set%,Redraw%)
The flags are detailed in the constants below
CONST KVwFgForceHOn%=1 Always have H scrollbar
CONST KVwFgForceHOff%=2 Never have H scrollbar
CONST KVwFgForceVOn%=4 Always have V scrollbar
CONST KVwFgForceVOff%=8 Never have V scrollbar
CONST KVwFgNoClear%=16 Do not clear before calling the redraw callback

Sets an application specific word associated with the VirtualWindow
This word is passed back as VwAppWord&
PROC VwSetWord:(VwId&,Word&)

Sets the extent of the VirtualWindow (in Vw units), and the scale.
Eg, a MBM viewer would set the extent to the size of the bitmap, and the scale to 1:
    a text viewer would set the extent to the number of lines/columns, and the scales to the font size in pixels
PROC VwSetExtent:(VwId&,ExtentX&,ExtentY&,ScaleX%,ScaleY%)

Sets the current view position in the virtual window
This call may scroll the window, redraw the scrollbars, and call the Redraw callback to display any 'blank' area of the window.
PROC VwSetView:(VwId&,Left&,Top&)

As above, but forces the entire VirtualWindow to be re-drawn. Use this call to draw the screen after the current contents have become invalid (eg, new file loaded)
PROC VwSetViewRedrawAll:(VwId&,Left&,Top&)

Force an area of the virtual window to be redrawn. If a part of this area is currently visible, the the Redraw Callback will be called to redraw the visible portion
PROC VwRedraw:(VwId&,LX&,TY&,W&,H&)

Redraw the entire VirtualWindow
PROC VwRedrawAll:(VwId&)

Destroys the VirtualWindow, blanks it from the display, and releases all resources associated with it
PROC VwDestroy:(VwId&)

Ensure that the specified point is currently visible. Make it so, by scrolling and redrawing as neccessary.
PROC VwMoveTo:(VwId&,X&,Y&)

In a MoveTo operation, set the jump amount (initially 1 VwUnit) for when the view is scrolled
PROC VwSetJump:(Vw&,XJump&,YJump&)

Adjust the extent of the VirtualWindow by inserting or deleting a strip from anywhere in the extent -
similar to ADJUSTALLOC(). The redraw callback is called as appropriate.
PROC VwAdjustHExtent:(VW&,VX&,W&)
PROC VwAdjustVExtent:(VW&,VY&,H&)

Copy an area of the virtual window to another place in the same window. The redraw callback
will be called for parts newly exposed.
PROC VwCopyArea:(VW&,LX&,TY&,W&,H&,PX&,PY&)

Sets a 'pen callback' on the virtual window.
PROC VwPenCallBack:(VwId&,PenCallback$)
Whenever a pen event occurs in a virtual window, the routine whose name is in PenCallback$ will be called with the position of the pen event in both Vw Units and pixels:
@(PenCallBack$):(VwId&,WinId%,EvType&,VX&,VY&,px%,py%)
The Global variables described below are available in the callback routine

Get the global VirtualWindow variables
PROC VwGetVars:(VwId&)
The following variables are set by a call to VwGetVars: They will also be set before any callback procedure is called

VwWinId% - The OPL window that contains the VirtualWindow
VwPx%,VwPy% - The position of the VirtualWindow in the window (pixels)
VwWidth% - The size of the VirtualWindow in pixels, including scrollbars
VwHeight%
VwDrawWidth% - The size of the VirtualWindow in pixels, EXCLUDING scrollbars
VwDrawHeight%
VwVSbId& - The handles of the scrollbars used by the VirtualWindow.
VwHSbId& - 0 indicates no scrollbar
VwFlags% - Currently unused
VwExtentX& - The size of the VirtualWindow in VW Units
VwExtentY&
VwLeft& - The position in Vw Units of the top and left
VwTop& - of the portion 'in view'
VwViewExtentX&- The size of the view onto the VirtualWindow in Vw units
VwViewExtentY&
VwScaleX% - The scales of the VirtualWindow. 1 VwUnit = VwScale% pixels
VwScaleY%
VwCallBack$ - The name of the RedrawCallback procedure
VwPenCallBack$- The name of the pen callback procedure
VwAppWord& - An arbitrary word set by the application using VwSetWord:

Button Calls

Creates a Button (see OPL reference for gBUTTON) on window WinId% at position lx%,ty%, size w% by h%, with bitmap BmpId& and mask MskId&.
PROC BtnCreate&:(WinId%,lx%,ty%,text$,w%,h%,BmpId&,MskId&,Layout%,CallBack$)
When the button is pressed, released, or dragged, the procedure whose name is in Callback$ is called:
@(Callback$):(BtnId&,EvType&)

Deletes the button and clears the button from the screen
PROC BtnDestroy:(BtnId&)


Download

Download VWin version 0.4 (ZIP file)

Contains the OPO module, an OPH file for inclusion in programs, full documentation, and a couple of simple examples. 


Disclaimer

All software on this site is supplied 'as-is' with no warranty, implied or otherwise.
Whilst I make every attempt to make the software as free from bugs as possible, this is not guaranteed, and I will not be liable for any loss or damage directly or indirectly incurred through the use of this software.