SP Mice implementation

Mice and SuperLib

 SuperLib contains a set of mouse and event functions.
 These functions are MOSTLY prefaced with 'RAT' for uniqueness.

 The basic functions are written in assembler (MASM
 5.10) and are in s_mouse.asm. These provide such things as
 testing for a mouse, turning the mouse cursor on, turning it off,
 positioning it.

 Also provided are two approaches to knowing where the
 mouse is and what it is doing. The first is a direct query of
 the mouse's status and position. This is basically, "where is the
 mouse right now, is the right button depressed right now, is the
 left button depressed right now". These are accomplished through
 service 3 of interrupt 33h.

 The second approach is to use service 5 of interrupt
 33h, which 'records' right and left mouse button depresses and
 where the mouse was when these occurred.

 These Clipper functions, contained in s_moose.prg,
 are included to provide a simple event manager to trap both keys
 and mouse events and store them for reference.

 The event manager RAT_EVENT() can be used in place of
 inkey(), and will detect a keypress, a mouse left button press,
 a mouse right button press, or a timeout. The 'event' returns a
 value similiar to inkey(), but adds values of 400 and 500 for
 mouse right and left presses. Functions are provided to find out
 the mouse row and column when the event occurred.

 Two additional functions RAT_READ() and RAT_MENU2()
 are provided which use the mouse and event functions to perform
 a read and a menu to emulation. These are also good examples for
 usage of the mouse and event functions.

 All SuperLib functions are mouse aware, as of version 3.5.

 

SP Mouse Functions

 RAT_ELBHD()    Determines if left mouse button is held down
 RAT_EQMCOL()   Returns mouse column at last press
 RAT_EQMROW()   Returns mouse row at last press
 RAT_ERBHD()    Determines if right mouse button is held down
 RAT_EVENT()    Event handler - inkey() with mouse awareness
 RAT_ISMOUSE()  Determines mouse usage by RAT_EVENT()
 RAT_LASTEV()   Returns the last event recorded by RAT_EVENT()
 RAT_MENU2()    Mouseable MENU TO emulation
 RAT_READ()     Mouseable read
 RAT_AREA()     Limits the mouse to a rectangular area of the screen
 RAT_COL()      Current mouse column
 RAT_COLL()     Returns mouse column at the last left button press
 RAT_COLR()     Returns mouse column at the last right button press
 RAT_EXIST()    Determines if a mouse is available
 RAT_FORCE()    This forces a mouse present status, regardless
 RAT_LBHD()     Determines if the mouse left button is currently depressed
 RAT_LEFTB()    Determines if the left mouse button has been pressed
 RAT_NOMOUSE()  This forces a no mouse status, regardless
 RAT_OFF()      Sets the mouse cursor off
 RAT_ON()       Sets the mouse cursor on
 RAT_POSIT()    Positions the mouse cursor at row,column
 RAT_RBHD()     Determines if the mouse right button is currently depressed
 RAT_RESET()    Resets the mouse to its default values
 RAT_RIGHTB()   Determines if the right mouse button has been pressed
 RAT_ROW()      Current mouse row
 RAT_ROWL()     Returns mouse row at the last left button press
 RAT_ROWR()     Returns mouse row at the last right button press

SP Get system Functions

 SMALLKCLR()    Clears GET-HOTKEY lookup combinations set up with SMALLKSET()
 POPUPKCLR()    Clears GET hotkey popups set up with POPUPKSET()
 PMREADER()     Creates specialized PLUS/MINUS get reader block
 SMALLKSET()    Sets up GET-HOTKEY lookup combinations using SMALLS()
 PICKREADER()   Creates specialized picklist reader block
 POPUPWHEN()    Allows use of a popup for a GET WHEN clause
 POPUPKSET()    Set a popup for hotkey access from a GET, with autoassignment
 POPUPVALID()   Allows use of a popup for a GET VALID clause
 CALENDVALID()  Uses GETDATE() popup calendar function as a GET VALID clause
 CALCKCLR()     Clears hot keys set by CALCKSET()
 CALCKSET()     Allows use of GETCALC() calculator in GETS
 SMALLWHEN()    Uses SMALLS() in a WHEN condition for a GET
 CALENDWHEN()   Uses GETDATE() function as a GET WHEN clause
 CALCWHEN()     Uses GETCALC() calculator function as a GET WHEN clause
 SMALLVALID()   Uses SMALLS() in a VALID condition for a GET
 CALCVALID()    Uses GETCALC() calculator function as a GET VALID clause
 RAT_READ()     Mouseable read
 GENVAL()       Generic VALID clause validation with message
 GENREADER()    Creates specialized user defined get reader block
 GETAKEY()      Gets intent of last keystroke
 SBREADER()     Creates specialized spacebar spinner get reader block
 ED_G_PIC()     Returns appropriate picture for getting a field
 CALENDKSET()   Allows use of GETDATE() calendar in GETS
 YNREADER()     Creates specialized Yes/No get reader block
 CALENDKCLR()   Clears hot keys set up by CALENDKSET()

 

SP Event Functions

 RAT_EVENT()    Event handler - inkey() with mouse awareness
 RAT_ERBHD()    Determines if right mouse button is held down
 RAT_ISMOUSE()  Determines mouse usage by RAT_EVENT()
 RAT_ELBHD()    Determines if left mouse button is held down
 RAT_EQMCOL()   Returns mouse column at last press
 RAT_EQMROW()   Returns mouse row at last press
 IFMOUSEHD()    Checks if mouse held down,evals codeblock while it is
 ISMOUSEAT()    Checks for mouse click within passed coordinates
 MBRZCLICK()    Checks for mouse click on current Tbrowse row/col
 MBRZMOVE()     Checks for mouse click at and moves to Tbrowse row/col
 MOUSEHOTAT()   Checks for mouse click from array of hot coordinates
 RAT_LASTEV()   Returns the last event recorded by RAT_EVENT()
 R_ISRATREAD()  Determines if RAT_READ() is current get system

 

SP_R_ISRATREAD

R_ISRATREAD()

  Short:
  ------
  R_ISRATREAD() Determines if RAT_READ() is current get system

  Returns:
  --------
  <lIsRatRead> => True if RAT_READ() is current get system

  Syntax:
  -------
  R_ISRATREAD()

  Description:
  ------------

  By calling R_ISRATREAD(), you can determine if the current
  read is a RAT_READ or not, and call the regular exported
  read/get functions, or call their equivalent RAT* functions
  as listed in RAT_READ().

  An exception is GETACTIVE(), which may be called while using
  either get system, as RAT_READ() calls GETACTIVE() to update
  the current get, and also saves and restores the active get
  in case there is a prior READ active.

  This R_ISRATREAD() function returns TRUE/FALSE for 'is the current
  read a RAT_READ or a READMODAL (normal) read'. Essentially it tells
  you which GetSystem you are in.

  Thus you can have both RAT_READ() mouse aware reads, and standard
  READMODAL() Clipper reads in the same system, and tell the
  difference between the two.

  Examples:
  ---------
  IF R_ISRATREAD()
     ...
  ENDIF

  Notes:
  -------

  Source:
  -------
  S_RREAD.PRG

See also : RAT_READ(), READMODAL()

 

 

SP_RRLASTKEY

RRLASTKEY()

  Short:
  ------
  RRLASTKEY()  Retrieve the last key handled by ratapplykey()

  Returns:
  --------
  <nLastKey> => last key handled by ratapplykey()

  Syntax:
  -------
  RRLASTKEY()

  Description:
  ------------
  Returns the last key - including pseudo keys - handled by
  RatApplyKey().

  The [nRmKey]  and [aLmKeys] parameters of RAT_READ() allow
  emulation of keypresses. The [nRmKey] determines what key is
  emulated when the right mouse button is pressed. The [aLmKeys]
  array contains key emulations to be used for a set of screen
  hot areas for left mouse button clicks. In both cases, the
  ascii key code is passed to RatApplyKey() to handle. However,
  the keys ARE NOT STUFFED INTO THE KEYBOARD, and thus are not
  retrievable through LASTKEY(). The reason, by the way, that they
  are not stuffed into the keyboard, is that some keys cannot be
  stuffed with the KEYBOARD command  ( i.e. ALT-F10 or -39 )

  After a number of requests to be able to tell what key was
  pressed last when exiting a read, even when it is an interpreted
  key based on a mouse click, I've added this function. It will return
  the last key handled by RatApplyKey(), even if the key is based on
  a mouse click. If the last event is a mouse event that does not
  translate into a key value, it will return either K_MOUSELEFT for left
  mouse click, or K_MOUSERIGHT for right mouse click.

  Examples:
  ---------
  RAT_READ(getlist,...)
  if RRLASTKEY()==27
    * escape was pressed or mouse right button was pressed

  endif

  Notes:
  -------

  Source:
  -------
  S_RREAD.PRG

See also : RAT_READ()

 

SP_RRJUMP2

RRJUMP2()

  Short:
  ------
  RRJUMP2()  Jump to a new get in a RAT_READ()

  Returns:
  --------
  NIL

  Syntax:
  -------
  RRJUMP2(nNew)

  Description:
  ------------
  While in a RAT_READ(), causes the jump flag to be set to <nNew>, and
  and the current get's exitstate variable to be set to GE_ENTER. This
  causes an exit from the current get, and a jump to get <nNew>.

  Examples:
  ---------
   // in this example, pressing or clicking F3 causes a jump to
   // get # 1, while pressing or clicking F4 causes a jump to
   // get # 5.

   #include "inkey.ch"

   v1 := space(10)
   v2 := space(10)
   v3 := space(10)
   v4 := space(10)
   v5 := space(10)

   setkey(K_F4,{||rrjump2(5)} )
   setkey(K_F3,{||rrjump2(1)} )

   @24,0 say "[F3-Go to First Get]  [F4-Go to Last Get]"

   ahot := {{24,0,24,20,K_F3},{24,23,24,41,K_F4} }

   @10,10 get v1
   @11,10 get v2
   @12,10 get v3
   @13,10 get v4
   @14,10 get v5

   RAT_READ(getlist,1,.T.,27,nil,aHot)

  Notes:
  -------

  Source:
  -------
  S_RREAD.PRG

See also : RAT_READ()

SP_RAT_READ

RAT_READ()

  Short:
  ------
  RAT_READ() Mouseable read

  Returns:
  --------
  Nil

  Syntax:
  -------
  RAT_READ(aGetlist,[nStart],[lWrap],[nRmKey],[bLmouse],[aLmKeys])

  Description:
  ------------
  Set up your gets as normal, with @SAY...GET
  statements.

  The only limitation is that you cannot use a
  user-defined READER block, as RAT_READ() installs a
  user-defined reader block for each get.

  After setting up your @SAY...GET statements, instead
  of issuing a READ, issue a RAT_READ(getlist,...).

  [nStart] is an optional starting get number, which
  defaults to 1.

  [lWrap] determines if going past top or bottom get
  exits the read. Default is True. By sending false, going past top
  will put you at bottom, and going past bottom will put you at top,
  with only CTRL-W exiting the read.

  [nRmKey] is an inkey value that tells RAT_READ() how
  it should interpret a right mouse button click. Default is ESCAPE.

  [bLmouse] (new in 3.5) is a codeblock that is evaluated when there
  is a mouse click and it is not meaningful to RAT_READ().
  It is evaluated as :  eval(bLMouse,mouserow, mousecolumn)

  [aLmKeys] is an array of hot mouse coordinate sub-arrays and their
  key equivalents. For instance, if you have the following for hot
  keys: @24,0 say "[F10=save] [ESC=Cancel]", and you wanted these as
  hot mouse areas, the array would be:
        {   {24,0,24,9,K_F10},  {24,11,24,22,K_ESC}   }
  Clicking the mouse within 24,0,24,9 would be interpreted as pressing
  the F10 key.
  The structure of each sub-array is {nTop,nLeft,nBottom,nRight,nKeyValue}

  Examples:
  ---------
   v1 := space(10)
   v2 := space(10)
   v3 := space(10)
   @10,10 get v1
   @11,10 get v2
   @12,10 get v3

   RAT_READ(getlist,2,.T.,27)

   // read, starting at get # 2, wrapping, and interpreting the right
   // mouse button as chr(27) (escape).

  Notes:
  -------
  This does not replace GETSYS.PRG, but rather parallels it.

  The Clipper GET system, contained in GetSys.Prg and accessed via
  READ contains several exported functions which obtain /handle
  information about the current GET and the current READ.

  In order to implement mouse-aware reads, a modification of
  GetSys.Prg was needed. However....

  I didn't want SuperLib to replace the Clipper Get system
  willy-nilly, as that would presume that you always wanted
  to use _only_ the SuperLib version. So I had to rename all
  of the exported functions in the SuperLib mouseable get
  system. The names are as follows:

   Clipper Get System    SuperLib GetSystem
   ------------------    ------------------
   ReadModal()           Rat_Read()
   GetReader()           RatReader()
   GetApplyKey()         RatApplyKey()
   GetDoSetKey()         RatDoSetKey()
   GetPostValidate()     RatPostValidate()
   GetPreValidate()      RatPreValidate()
   GetActive()           RatActive() ---or--- GetActive()
   ReadKill()            RatKill()
   ReadUpdated()         RatSetUpdated()
   Updated()             RatUpdated()

  So you can call either READ or READMODAL() which accesses the
  Clipper Get System, or call RAT_READ(), which access the
  SuperLib mouseable get system, and they will not tromp on
  one another.

  There still remained one problem, however. Some of the SuperLib
  functions access the above named exported functions, such as
  GetActive(), and of course user-defined get readers need to
  access GetPostValidate(), GetPreValidate(), GetApplyKey() and
  GetDoSetKey(), and possibly others.

  By calling R_ISRATREAD(), you can determine if the current
  read is a RAT_READ or not, and call the regular exported
  read/get functions, or call their equivalent RAT* functions
  as listed above.

  An exception is GETACTIVE(), which may be called while using
  either get system, as RAT_READ() calls GETACTIVE() to update
  the current get, and also saves and restores the active get
  in case there is a prior READ active.

  This R_ISRATREAD() function returns TRUE/FALSE for 'is the current
  read a RAT_READ or a READMODAL (normal) read'. Essentially it tells
  you which GetSystem you are in.

  Thus you can have both RAT_READ() mouse aware reads, and standard
  READMODAL() Clipper reads in the same system, and tell the
  difference between the two.

  User defined readers attached to GETS passed to RAT_READ can
  return a numeric value indicating which get to jump to.

  Source:
  -------
  S_RREAD.PRG

See Also : RAT_ELBHD(), RAT_EQMCOL(), RAT_EQMROW(), RAT_ERBHD(), RAT_EVENT(), 
           RAT_ISMOUSE(), RAT_LASTEV(), RAT_MENU2(), RAT_READ()

SP_GETJUMP2

GETJUMP2()

  Short:
  ------
  GETJUMP2() Determines if mouse clicked on a get

  Returns:
  --------
  <nJumpTo> => Number of get that mouse clicked on

  Syntax:
  -------
  GETJUMP2(nMouseRow, nMousecol, [aGetList] )

  Description:
  ------------
  This function checks nMouseRow and nMouseCol against the getlist,
  either passed by you as [aGetList], or by accessing the most recent
  RAT_READ() get list, and determines if the user clicked on a
  get. How you then get to that get is up to you. RAT_READ and the
  specialized get readers in SuperLib make use of this function to
  jump to non-contiguous gets.

  Examples:
  ---------
  IF (nGet := GETJUMP2(nMouseR, nMouseC,getlist) ) > 0
     ....
  ENDIF

  Notes:
  -------

  Source:
  -------
  S_RREAD.PRG