home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / OOPMOU_B.ZIP / MOUSEUNI.INC < prev    next >
Encoding:
Text File  |  1989-11-26  |  7.5 KB  |  138 lines

  1. unit MouseUnit;
  2.  
  3. { This unit defines an object type mouse_object that provides mouse     }
  4. { support for Turbo Pascal 5.5 programs.  The routines have been tested }
  5. { with a MicroSoft serial mouse.  I created this as an educational      }
  6. { experience for myself in object oriented programming.  If you have    }
  7. { suggestions or enhancements feel free to contact me.                  }
  8. {                                                                       }
  9. {       Benjamin R Peart                                                }
  10. {       735 N 400 E #29                                                 }
  11. {       Provo, UT  84606                                                }
  12. {       CIS 76645,1041.                                                 }
  13. {                                                                       }
  14. { If there is any interest in a joystick object and a keyboard object   }
  15. { that would provide routines similar to those available in the mouse   }
  16. { object let me know.                                                   }
  17.  
  18. interface
  19.  
  20. uses Dos;
  21.  
  22. type mouse_object = object
  23.         function  Exists : boolean;
  24.         { check if a mouse driver is currently loaded           }
  25.  
  26.         function  NumberOfButtons : integer;
  27.         { returns the number of available buttons on the mouse  }
  28.  
  29.         procedure Reset;
  30.         { reset the mouse driver to its defaults                }
  31.  
  32.         procedure Show;
  33.         { Makes the mouse cursor visible.                       }
  34.  
  35.         procedure Hide;
  36.         { Makes mouse cursor invisible. Movement and button activity are        }
  37.         { still tracked.                                                        }
  38.  
  39.         procedure GetStatus(var status, row, column : integer);
  40.         { Get mouse position and status.  Gives button status and       }
  41.         { current position.  status:    1 = left button pressed,        }
  42.         {                               2 = right,                      }
  43.         {                               3 = both.                       }
  44.  
  45.         procedure MoveTo(new_row, new_column : integer);
  46.         { Position the mouse on the screen.  It wants the pixel         }
  47.         { coordinates, not just character positions.                    }
  48.  
  49.         procedure Pressed(button : integer; var result : boolean; var count, row, column : integer);
  50.         { Gets pressed info about named button: current status          }
  51.         { (up/down), times pressed since last call, position at most    }
  52.         { recent press.  Resets count and position info. Button 0 is    }
  53.         { left, 1 is right on Microsoft mouse.                          }
  54.  
  55.         procedure Released(button : integer; var result : boolean; var count, row, column : integer);
  56.         { Gets released info about named button: current status         }
  57.         { (up/down), times released since last call, position at most   }
  58.         { recent press.  Resets count and position info. Button 0 is    }
  59.         { left, 1 is right on Microsoft mouse.                          }
  60.  
  61.         procedure ColRange(horizontal_min, horizontal_max : integer);
  62.         { Sets min and max horizontal range for mouse cursor. Moves     }
  63.         { cursor inside range if outside when called. Swaps values if   }
  64.         { min and max are reversed.                                     }
  65.  
  66.         procedure RowRange(vertical_min, vertical_max : integer);
  67.         { Sets min and max vertical range for mouse cursor. Moves       }
  68.         { cursor inside range if outside when called. Swaps values if   }
  69.         { min and max are reversed.                                     }
  70.  
  71.         procedure GraphCursor(hHot, vHot : integer; mask_segment, mask_offset : word);
  72.         { Sets the graphics cursor's hot spot and mask which defines    }
  73.         { what the graphics cursor will look like.  The cursor hot spot }
  74.         { must be within the range -16 to +16 pixels relative to the    }
  75.         { cursor.  The mask values could be something like:             }
  76.         { xmask : array[1..33] :=                                       }
  77.         {       $07e0, $0000, $0180, $700e, $0000, $1c38, $c003, $0660, }
  78.         {       $f00f, $03c0, $c003, $0660, $0000, $1c38, $0180, $700e, }
  79.         {       $07e0, $0000, $ffff, $0000, $ffff, $0000, $ffff, $0000, }
  80.         {       $ffff, $0000, $ffff, $0000, $ffff, $0000, $ffff, $0000  }
  81.         { defines a graphics cursor like an x.  See the reference       }
  82.         { earlier in this file for the table of the mask values effects }
  83.         { on the screen.                                                }
  84.  
  85.         procedure TextCursor(cursor_type : integer; arg1, arg2 : word);
  86.         { Sets text cursor type, where 0 = software and 1 = hardware)   }
  87.         { For software cursor, arg1 and arg2 are the screen and cursor  }
  88.         { masks.  For hardware cursor, arg1 and arg2 specify scan line  }
  89.         { start/stop i.e. cursor shape.                                 }
  90.  
  91.         procedure Motion(var horizontal_count, vertical_count : integer);
  92.         { Reports net motion of cursor since last call to this function.}
  93.         { Returns the motion in "mickeys", always within the range of   }
  94.         { -32768 to +32767.                                             }
  95.  
  96.         procedure InstallTask(mask, task_segment, task_offset : word);
  97.         { This function sets a subroutine to be conditionally called by }
  98.         { the mouse software.  The condition of execution is defined by }
  99.         { the mask.                                                     }
  100.         {       Bit 0          cursor position changes                  }
  101.         {           1          left button pressed                      }
  102.         {           2          left button released                     }
  103.         {           3          right button pressed                     }
  104.         {           4          right button released                    }
  105.         {           5-15       unused                                   }
  106.         { To disable an interrupt for a specified condition, call       }
  107.         { function again with the corresponding bit set to zero.        }
  108.         { Calling mouse function Reset also resets everything.  The     }
  109.         { subroutine to be called must be a far procedure, must save    }
  110.         { any modified registers, and must not do any dos or bios calls.}
  111.  
  112.         procedure LightPenOn;
  113.         { Turns on light pen emulation. This is the default condition.  }
  114.  
  115.         procedure LightPenOff;
  116.         { Turns off light pen emulation.                                }
  117.  
  118.         procedure Ratio(horizontal, vertical : integer);
  119.         { Sets the mickey / pixel ratio vertically and horizontally.    }
  120.         { Default values are horizontal 8 mickeys to 8 pixels,          }
  121.         { vertically 16 to 8.                                           }
  122.  
  123.         procedure ConditionOff(x1, y1, x2, y2 : integer);
  124.         { This function is similar to hide_cursor(), but only turns off }
  125.         { the cursor if it is in the area defined when this function is }
  126.         { called.  If this function hides the cursor, Show must be      }
  127.         { called later on to show the cursor again.                     }
  128.  
  129.         procedure SetThreshold(x : integer);
  130.         { This function sets how fast the mouse must move before its    }
  131.         { relative cursor movements on the screen are doubled.  Default }
  132.         { value is 64 mickeys per second.                               }
  133.  
  134. end;
  135.  
  136. implementation
  137.  
  138.