{}
{UNIT GTMouse.pas ver 1.3, date 07-07-93}
{ (c) Copyright JINR, Dubna, 1992,1993 by I.Evsikov, S.Shmakov, P.Sychov }
{}

{$R-,L-,D-,S-,F-,V-,A+,O+,I+,B-,E-,N-,G-}

UNIT GTMouse;

interface

Type

 tDisplay     = (VGA,EGA,NogrMouse);
 imageArray = array[0..15] of byte;
 ImageNames = (
                         NormalArrow, DragArrow,
                         DragArrowL,  DragArrowR,
                         ClockArrow,  HandArrow,
                         Hand1Arrow,  Clock2Arrow,
                         Hand2Arrow,  BigArrow,
                         SU29Arrow,   Hand3Arrow,
                         PencilArrow, FootArrow,
                         PlusArrow,   Big2Arrow,
                         SightArrow,  UserArrow);

 dPoint=record
   X:WORD;
   Y:WORD;
 end;

const

{$IfNDef VER70}
 SEGB800        : word = $B800;   { For Protected mode compatible           }
 SEGA000        : word = $A000;
 SEG0040        : word = $0040;
{$EndIf}

 grMouse        : boolean = false;
 grShow         : boolean = false;      { True if arrow curros is visible    }
 _ScreenWidth   : integer = 80;         { Screen Width                       }
 _ScreenHeight  : integer = 25;         { Screen Height                      }
 _ButtonCount   : integer = 0;          { The number of Mouse Buttons        }

var

 crMouseStatus  : byte;
 ImageNoPressed : ImageNames;
 ImagePressed   : ImageNames;
 DisplayType    : tDisplay;
 _VideoSegment  : WORD;                 { Segment of Video Memory for init   }
 _MouseWhere    : dPoint;               { Current Mouse position             }
 _MouseWindow   : dPoint;               { Current Window mouse               }
 Sleepper       : boolean;
 grMouseWhere   : dPoint;

{                            MAIN PROCEDURES                                 }
{                            ---------------                                 }



Procedure InitGtMouse;

{     Reactivate GTMouse.                                                    }
{     Detect mouse driver, reinitiate Arrow Mouse, set Event  Handler,       }
{     initiate variables, select default Mouse Image etc.                    }
{     GTMouse initiates automatically, so this procedure is nessesary only   }
{     after deactivating of GTMouse by DoneMouse.                            }


Procedure DoneGtMouse;

{     Deactivate GTMouse CORRECTLY.                                          }
{     Use this procedure before exit to DOS or start child process           }
{     or before any screen mode changing                                     }



Procedure DrawArrow;

{     Redraw mouse cursor.                                                   }
{     GTMouse call this procedure at any timer tick (about 18 times per sec) }
{     To improve the smoothnes of cursor movement include this procedure     }
{     to any event wait cycle of your program                                }


Procedure ShowGtMouse;

{     Show mouse cursor                                                      }


Procedure HideGtMouse;

{     Hide mouse cursor                                                      }


{                           ADDITIONAL PROCEDURES                            }



Procedure SelectNotPressedImage( NameOfImage : ImageNames);

{     Select new notpressed mouse cursor image.                              }
{     For example:                                                           }
{             SelectNotPressedImage(FootArrow);                              }



Procedure SelectPressedImage( NameOfImage : ImageNames);

{     Select new pressed mouse cursor image.                                 }
{     For example:                                                           }
{                        ...                                                 }
{                        SelectPressedImage(ClockArrow);                     }



Procedure SetNewCharacters( var CharSet);

{     Set new Character Array for mouse cursor building.                     }
{     Parameter is 8-bytes array of chars.                                   }
{     This array is used to construct the grahics mouse cursor form          }
{     as superposition of four characters adjacent to mouse position         }
{     and mouse cursor image. Eight symbols are used because of VGA          }
{     peculiarities in text mode. Last four symbols must be in pseudo        }
{     graphics range ($c0..$df), first ones have not to be in this range.    }
{     You have to avoid usage of these symbols on your screen images.        }
{     Null symbol at any position means not to change this symbol.           }
{     Default array is (^A,^B,^C,^D,'','','','').                        }
{     For example:                                                           }
{         CONST newarray : Array[1..8] of Char =                             }
{                                   (^A,^B,^C,^T,'','','','');           }
{            ...                                                             }
{          (*Hide mouse cursor befor set new characters*)                    }
{            SetNewCharacters(newarray);                                     }



Procedure LinkUserImageWith(
               ArrowName                 : ImageNames;
               var UserImage             : ImageArray);

{     Define User Mouse Cursor Image with ArrowName from ImageNames.         }
{     Example:                                                               }
{     CONST MyArrow : ImageArray =                                           }
{       ($00,$00,$18,$18,$18,$18,$00,$C3,$00,$18,$18,$18,$18,$00,$00,$00);   }
{                        ...                                                 }
{       LinkUserImageWith(UserArrow,MyArrow);                                }
{       SelectNotPressedImage(UserArrow);                                    }

procedure InitSleepper( TimeDelay,
                        LeftUpX,  LeftUpY,
                        RightDnX, RightDnY : integer);
{    Init "Sleep" coordinates and time (sec) without event to sleep Screen   }
{    By Default:   InitSleeper(30,80,1,80,1);                                }
{     Example:                                                               }
{                        ...                                                 }
{        InitSleepper(10,1,25,80,25);                                           }
