home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / pascal / PASLIBR.ZIP / CH6_1.DOC < prev    next >
Encoding:
Text File  |  1991-03-15  |  15.9 KB  |  650 lines

  1. ..pgno01
  2. ..foot60A6-##
  3. ..head02L──────────────────────────────────────────────────────────────────────
  4. ..head04L──────────────────────────────────────────────────────────────────────
  5. ..head03LGlobal Variables
  6. Var
  7.    NEvents : Word        contains the number of events waiting in the
  8.                          mouse event handler queue.
  9. ..page
  10. ..head03AMButtonPress
  11. ■ Description
  12.  
  13.   Returns the current button status information.
  14.  
  15.  
  16. ■ Summary
  17.  
  18.   Function MButtonPress(    Button         : Integer;
  19.                         Var ButPress, x, y : Integer ) : Integer;
  20.  
  21.   Button      specifies the button to check.
  22.                  0 - left button
  23.                  1 - right button
  24.                  2 - middle button
  25.  
  26.   ButPress    number of button presses since the last call to
  27.               MButtonPress.
  28.  
  29.   x           column the mouse cursor was in the last time the button
  30.               was pressed.
  31.  
  32.   y           row the mouse cursor was in the last time the button was
  33.               pressed.
  34.  
  35.  
  36. ■ Remarks
  37.  
  38.   MButtonPress will return an integer indicating the current state of
  39.   the mouse button requested.
  40.  
  41.      0 - Button is released
  42.      1 - Button is pressed
  43. ..page
  44. ■ Example
  45.  
  46.   Program Example;
  47.   Uses FPMouse;
  48.   Var
  49.      NBut,ButPresses,x,y : Integer;
  50.   Begin
  51.      If ( MResetMouse( NBut ) ) Then Begin
  52.  
  53.         MInitEventHandler( 14 );
  54.         While ( NEvents < 10 ) Do
  55.         ;
  56.  
  57.         Writeln( 'left button status is ==> ' );
  58.  
  59.         Case ( MButtonPress( 0, ButPresses, x, y ) ) Of
  60.            0 : Writeln( 'UP' );
  61.            1 : Writeln( 'DOWN' );
  62.         End;
  63.  
  64.         Writeln( 'Total Button presses = ', ButPresses:1 );
  65.      End;
  66.   End.
  67.  
  68.   This example will report the number of times the left button was
  69.   pressed and also the current state of the left button.
  70. ..page
  71. ..head03AMButtonRel
  72. ■ Description
  73.  
  74.   Returns the current button status information.
  75.  
  76.  
  77. ■ Summary
  78.  
  79.   Function MButtonRel(    Button         : Integer;
  80.                       Var ButPress, x, y : Integer ) : Integer;
  81.  
  82.   Button      specifies the button to check.
  83.                  0 - left button
  84.                  1 - right button
  85.                  2 - middle button
  86.  
  87.   ButPress    number of button releases since the last call to
  88.               MButtonRel.
  89.  
  90.   x           column the mouse cursor was in the last time the button
  91.               was released.
  92.  
  93.   y           row the mouse cursor was in the last time the button was
  94.               released.
  95.  
  96.  
  97. ■ Remarks
  98.  
  99.   MButtonReleased will return an integer indicating the current state
  100.   of the mouse button requested.
  101.      0 - Button is released
  102.      1 - Button is pressed
  103. ..page
  104. ■ Example
  105.  
  106.   Program Example;
  107.   Uses FPMouse;
  108.   Var
  109.      NBut,ButPresses,x,y : Integer;
  110.   Begin
  111.      If ( MResetMouse( NBut ) <> 0 ) Then Begin
  112.         MInitEventHandler( 14 );
  113.         While ( NEvents < 10 )
  114.         ;
  115.  
  116.         Writeln( 'left button status is ==> ' );
  117.  
  118.         Case ( MButtonRel( 0, ButPresses, x, y ) ) Of
  119.            0 : Writeln( 'UP' );
  120.            1 : Writeln( 'DOWN' );
  121.         }
  122.  
  123.         Writeln( 'Total Button releases = ', ButPresses:1 );
  124.      End;
  125.   End.
  126.  
  127.   This example will report the number of times the left button was
  128.   released and also the current state of the left button.
  129. ..page
  130. ..head03AMGetPos
  131. ■ Description
  132.  
  133.   Returns the current button status and the location of the mouse
  134.   cursor.
  135.  
  136.  
  137. ■ Summary
  138.  
  139.   Procedure MGetPos( Var ButStat, x, y : Integer );
  140.  
  141.   Button      returns the status of each button by its corresponding
  142.               bit value. If a bit is 0 then that button is up.  If a
  143.               bit is 1 then that button is pressed.
  144.  
  145.               Bit  Value  Button
  146.               ───  ───── ─────────────
  147.               0     1    left button
  148.               1     2    right button
  149.               2     4    middle button
  150.  
  151.   x           column the mouse cursor is in.
  152.  
  153.   y           row the mouse cursor is in.
  154.  
  155.  
  156. ■ Remarks
  157.  
  158.   In 80 column text mode the upper left corner of the screen is 1,1
  159.   and the lower right corner is 80,25.
  160.  
  161.  
  162. ■ Example
  163.  
  164.   MGetPos( ButStat, x, y );
  165.  
  166.   If ( ButStat And 1 ) <> 0 Then
  167.      Writeln( 'button is pressed' );
  168.  
  169.   If ( ButStat And 2 ) <> 0 Then
  170.      Writeln( 'button is pressed' );
  171.  
  172.   If ( ButStat And 4 ) <> 0 Then
  173.      Writeln( 'button is pressed' );
  174.  
  175.   Writeln( 'The cursor is located at ', x:1, ',' y:1 );
  176. ..page
  177. ..head03AMGetSpeed
  178. ■ Description
  179.  
  180.   Returns the distance the mouse has moved since the last call to this
  181.   routine.
  182.  
  183.  
  184. ■ Summary
  185.  
  186.   Procedure MGetSpeed( Var HorCnt, VerCnt : Integer );
  187.  
  188.   HorCnt      returns horizontal step count since last call.
  189.  
  190.   VerCnt      returns vertical step count since last call.
  191.  
  192.  
  193. ■ Remarks
  194.  
  195.   The step count is always in the range -32768 to 32767. A positive
  196.   value specifies movements to the right and down while negative
  197.   values specify movements to the left and up.  After the call is
  198.   completed the step counts are reset to zero.
  199.  
  200. ■ Example
  201.  
  202.   MGetSpeed( &HorCnt, &VerCnt );
  203.  
  204.   If ( HorCnt > 0 ) Then
  205.      Writeln( ' Mouse moved to the right ' )
  206.   Else If ( HorCnt < 0 ) Then
  207.      Writeln( ' Mouse moved to the left ' )
  208.   Else
  209.      Writeln( ' Mouse did not move horizontally' );
  210.  
  211.   This example will report the horizontal direction the mouse has
  212.   moved since the last call to this routine.
  213. ..page
  214. ..head03AMGraphCursor
  215. ■ Description
  216.  
  217.   Defines the shape and color of the mouse cursor when in graphics
  218.   mode.
  219.  
  220. ■ Summary
  221.  
  222.   Procedure MGraphCursor( XHotSpot, YHotSpot : Integer;
  223.                           CMaskSeg, CMaskOfs : Word   );
  224.  
  225.   XHotSpot    a value in the range -16 to 16 used to define the X
  226.               pixel within or outside the cursor block
  227.  
  228.   YHotSpot    a value in the range -16 to 16 used to define the Y
  229.               pixel within or outside the cursor block.
  230.  
  231.   CMaskSeg    the segment of the cursor mask description variable.
  232.  
  233.   CMaskOfs    the offset of the cursor mask description variable.
  234.  
  235.  
  236. ■ Remarks
  237.  
  238.   The cursor mask variable is two arrays of 16 words each.  The first
  239.   16 words define the screen mask and the second 16 words define the
  240.   cursor mask.  Each array of 16 words defines the set of pixels that
  241.   are 16x16.
  242.  
  243.   The screen mask is used to determine which pixels become part of the
  244.   cursor shape while the cursor mask is used to determine the
  245.   color/shape of the cursor.
  246.  
  247. ■ Example
  248.  
  249.   Const
  250.      CMask : Array[1..32] Of Word = (
  251.      0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
  252.      0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
  253.  
  254.      0xffff, 0xffff, 0xf00f, 0xf00f, 0xf00f, 0xf00f, 0xf00f, 0xf00f,
  255.      0xf00f, 0xf00f, 0xf00f, 0xf00f, 0xf00f, 0xf00f, 0xffff, 0xffff
  256.      );
  257.  
  258.   MGraphCursor( -5, 5, Seg( CMask ), Ofs( CMask ) );
  259.  
  260.   The cursor defined by CMask will be a solid block with a smaller
  261.   block inside being a different color.
  262. ..page
  263. ..head03AMHideCursor
  264. ■ Description
  265.  
  266.   Removes the mouse cursor from the screen.
  267.  
  268.  
  269. ■ Summary
  270.  
  271.   Procedure MHideCursor;
  272.  
  273.  
  274. ■ Remarks
  275.  
  276.   Although the mouse cursor is hidden from view its motion is still
  277.   tracked.
  278.  
  279.  
  280. ■ Example
  281.  
  282.   MHideCursor();
  283. ..page
  284. ..head03AMInitEventHandler
  285. ■ Description
  286.  
  287.   Initializes the mouse interrupt event handler.
  288.  
  289.  
  290. ■ Summary
  291.  
  292.   Procedure MInitEventHandler( EventMask : Integer );
  293.  
  294.   EventMask   defines the event types the mouse event handler will
  295.               place in its queue.
  296.  
  297.  
  298. ■ Remarks
  299.  
  300.   Each bit in the event mask corresponds to a specific event:
  301.  
  302.   Bit     Value   Event
  303.   ───     ─────   ────────────────────────────────────────
  304.    0         1    cursor position moved
  305.    1         2    left button pressed
  306.    2         4    left button released
  307.    3         8    right button pressed
  308.    4        16    right button released
  309.    5        32    middle button pressed
  310.    6        64    middle button released
  311.    7-15           not used
  312.  
  313.  
  314. ■ Example
  315.  
  316.   MInitEventHandler( 4 );
  317.  
  318.   In this example the only time an event is recorded in the event
  319.   handler queue is when the left button of the mouse is released.
  320.   When this happens the global variable NEvents will be incremented.
  321.   The maximum number of events that is kept in the event queue at one
  322.   time is 20. MRetQue must be used to empty the queue. DO NOT change
  323.   the value of NEvents as this may cause severe problems.
  324.  
  325.   When you have finished using the event handler you must uninstall
  326.   the event handler with:
  327.  
  328.   MInitEventHandler( 0 );
  329. ..page
  330. ..head03AMPollQue
  331. ■ Description
  332.  
  333.   Returns a copy of the oldest event in the mouse event queue.  The
  334.   event queue is left unchanged.
  335.  
  336.  
  337. ■ Summary
  338.  
  339.   Procedure MPollQue( Var Event, ButStat, x, y : Integer );
  340.  
  341.   Event       an integer describing the event that occurred (See
  342.               MInitEventHandler).
  343.  
  344.   ButStat     button status at time of event.
  345.  
  346.   x           column mouse cursor was located in at the time of event.
  347.  
  348.   y           row mouse cursor was located in at the time of event.
  349.  
  350.  
  351. ■ Remarks
  352.  
  353.   If the number of events in the queue is zero when this procedure is
  354.   called the values in the return variables will be -1.  Use the
  355.   global variable NEvents to determine if an event is in the queue.
  356.  
  357. ■ Example
  358.  
  359.   MPollQue( Event, ButStat, x, y );
  360.  
  361.   In this example MPollQue is called to get the oldest event
  362.   information without removing the event from the queue.
  363. ..page
  364. ..head03AMResetMouse
  365. ■ Description
  366.  
  367.   Determines if the mouse hardware and software are installed.
  368.  
  369.  
  370. ■ Summary
  371.  
  372.   Function MResetMouse( NBut : Integer ) : Integer;
  373.  
  374.   Button      returns the number of buttons on the mouse.
  375.  
  376.  
  377. ■ Remarks
  378.  
  379.   MResetMouse will return:
  380.       0 - Mouse hardware and software are not installed.
  381.      -1 - Mouse hardware and software are installed.
  382.  
  383.   Every call to MResetMouse will also reset the position of the mouse
  384.   cursor to the middle of the video dispaly.
  385.  
  386.  
  387. ■ Example
  388.  
  389.   Program Example;
  390.   Uses FPMouse;
  391.   Var
  392.      NBut : Integer;
  393.   Begin
  394.      If ( MResetMouse( NBut ) <> 0 ) Then
  395.         Writeln( 'Mouse NOT installed on your computer' );
  396.      Else Begin
  397.         Writeln( 'You have a mouse in your computer' );
  398.         Writeln( 'Squeak Squeak Squeak...' );
  399.      }
  400.   End.
  401. ..page
  402. ..head03AMRetQue
  403. ■ Description
  404.  
  405.   Returns the oldest event in the mouse event queue and removes the
  406.   event from the queue.
  407.  
  408.  
  409. ■ Summary
  410.  
  411.   Procedure MRetQue( Var Event, ButStat, x, y : Integer );
  412.  
  413.   Event       returns the event that occurred (see MInitEventHandler).
  414.  
  415.   ButStat     button status at the time of this event.
  416.  
  417.   x           column mouse cursor was located in at time of event.
  418.  
  419.   y           row mouse cursor was located in at time of event.
  420.  
  421.  
  422. ■ Remarks
  423.  
  424.   If the number of events in the queue is zero when this procedure is
  425.   called the values in the return variables will be -1.  Use the
  426.   global variable NEvents to determine if an event is in the queue.
  427.  
  428.  
  429. ■ Example
  430.  
  431.   Program Example;
  432.   Uses FPMouse;
  433.   Var
  434.      NBut : Integer;
  435.   Begin
  436.      If ( MResetMouse( NBut ) <> 0 ) Then Begin
  437.         MInitEventHandler( 2 );
  438.  
  439.         While ( NEvents > 0 ) Do
  440.            MRetQue( Event, ButStat, x, y );
  441.      End;
  442.   End.
  443.  
  444.   In this example MRetQue is called until the mouse event queue is
  445.   empty.
  446. ..page
  447. ..head03AMSetEvent
  448. ■ Description
  449.  
  450.   Simulates a mouse event.
  451.  
  452.  
  453. ■ Summary
  454.  
  455.  
  456.   void MRetQue( Var Event, ButStat, x, y : Integer );
  457.  
  458.   Event       event that should occur (see MInitEventHandler).
  459.  
  460.   ButStat     button status for this event.
  461.  
  462.   x           column of the mouse cursor for this event.
  463.  
  464.   y           row of the mouse cursor for this event.
  465.  
  466.  
  467. ■ Remarks
  468.  
  469.   If the number of events in the queue is less than the maximum number
  470.   of events allowed in the queue then the event will be placed as the
  471.   newest or last mouse event to occur.  All global and local variables
  472.   used for this procedure will be updated exactly the same as if an
  473.   actual mouse event had occurred.
  474.  
  475. ■ Example
  476.  
  477.   MSetEvent( 1, 0, 80, 25 );
  478.  
  479.   In this example MSetEvent will place in the mouse event queue an
  480.   event that says the left button was pressed with the position of the
  481.   mouse cursor being at column 80 row 25.
  482. ..page
  483. ..head03AMSetPos
  484. ■ Description
  485.  
  486.   Set the position of the mouse cursor.
  487.  
  488.  
  489. ■ Summary
  490.  
  491.   Procedure MSetPos( x, y : Integer )
  492.  
  493.   x           column to put mouse cursor in
  494.  
  495.   y           row to put mouse cursor in
  496.  
  497.  
  498. ■ Remarks
  499.  
  500.   Checks for valid X and Y values are NOT performed.  In 80 column
  501.   text mode the upper left corner of the screen is 1,1 and the lower
  502.   right corner is 80,25.
  503.  
  504. ■ Example
  505.  
  506.   MSetPos( 1, 1 );
  507.  
  508.   Assuming text mode this example will place the mouse cursor in row
  509.   one column one of the display screen.
  510. ..page
  511. ..head03AMSetSpeed
  512. ■ Description
  513.  
  514.   Sets mouse motion to screen pixel ratio.
  515.  
  516.  
  517. ■ Summary
  518.  
  519.   Procedure MSetSpeed( HorCnt, VerCnt : Integer );
  520.  
  521.   HorCnt      the horizontal step ratio.  The value is in the range of
  522.               1 to 32767 where the ratio will be HorCnt steps to 8
  523.               pixels horizontally.
  524.  
  525.   VerCnt      the vertical step ratio.  The value is in the range of 1
  526.               to 32767 where the ratio will be VerCnt steps to 8
  527.               pixels vertically.
  528.  
  529.  
  530. ■ Remarks
  531.  
  532.   The step values refer to the amount of mouse movement.
  533.  
  534. ■ Example
  535.  
  536.   MSetSpeed( 16, 8 );
  537.  
  538.   This example sets the ratios as follows:
  539.      Horizontal - 16 steps to 8 pixels
  540.      Vertical   - 8 steps to 8 pixels
  541. ..page
  542. ..head03AMSetXRange
  543. ■ Description
  544.  
  545.   Sets the column boundaries the mouse cursor will be allowed to move
  546.   within.
  547.  
  548.  
  549. ■ Summary
  550.  
  551.   Procedure MSetXRange( Min, Max : Integer );
  552.  
  553.   Min         left column boundary for the mouse cursor.
  554.  
  555.   Max         right column boundary for the mosue cursor.
  556.  
  557.  
  558. ■ Remarks
  559.  
  560.   Range checks are not performed on the parameters.
  561.  
  562.  
  563. ■ Example
  564.  
  565.   MSetXRange( 10, 20 );
  566.  
  567.   In this example the mouse cursor will not be allowed to move to the
  568.   left of column 10 and to the right of column 20.
  569. ..page
  570. ..head03AMSetYRange
  571. ■ Description
  572.  
  573.   Sets the row boundaries the mouse cursor will be allowed to move
  574.   within.
  575.  
  576.  
  577. ■ Summary
  578.  
  579.   Procedure MSetYRange( Min, Max : Integer );
  580.  
  581.   Min         top row boundary of mouse cursor.
  582.  
  583.   Max         bottom row boundary of mouse cursor.
  584.  
  585.  
  586. ■ Remarks
  587.  
  588.   Range checks are not performed on the parameters.
  589.  
  590.  
  591. ■ Example
  592.  
  593.   MSetYRange( 3, 20 );
  594.  
  595.   In this example the mouse cursor will not be allowed to move above
  596.   row 3 and below row 20.
  597. ..page
  598. ..head03AMShowCursor
  599. ■ Description
  600.  
  601.   Display the mouse cursor on the screen
  602.  
  603.  
  604. ■ Summary
  605.  
  606.   Procedure MShowCursor;
  607.  
  608.  
  609. ■ Example
  610.  
  611.   MShowCursor()
  612. ..page
  613. ..head03AMTextCursor
  614. ■ Description
  615.  
  616.   Defines the mouse text cursor
  617.  
  618.  
  619. ■ Summary
  620.  
  621.   Procedure MTextCursor( CType, SMask, CMask : Integer );
  622.  
  623.   CType       selects the type of mouse cursor to use.
  624.                  0 - software cursor
  625.                  1 - hardware cursor
  626.  
  627.   SMask       if the software cursor is selected the screen mask is
  628.               defined.  If the hardware cursor is selected the
  629.               starting scan line is defined.
  630.  
  631.   CMask       if the software cursor is selected the cursor mask is
  632.               defined.  If the hardware cursor is selected the ending
  633.               scan line is defined.
  634.  
  635. ■ Remarks
  636.  
  637.   The screen mask is an integer that defines which of the character
  638.   attributes are preserved.  The cursor mask is used to determine
  639.   which of the characteristics are changed by the cursor.
  640.  
  641.   See SetCursor Size in chapter two for a description of the starting
  642.   and ending scan lines.
  643.  
  644.  
  645. ■ Example
  646.  
  647.   MTextCursor( CType, SMask, CMask );
  648. ..page
  649. 
  650.