home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / flash-c1.zip / CH6_1.DOC < prev    next >
Text File  |  1990-02-11  |  16KB  |  654 lines

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