The MOUSE object

The t_mouse structure is used for getting information from mouse and set cursors, speed, range, etc... This object is placed in t_driver object together with t_keyboard. Whenever the OBJECT(driver)->translate_event... is called it also calls the translate_event function from t_mouse structures.


mouse_set_cursor_focus_id ()
     Description:
       Sets the cursor to one of the standard types.

     Syntax:
       void  mouse_set_cursor_focus_id ( l_int id )

     Parameters:
       id          The type of cursor to set.



     Returns:
       




Standard cursor types

     CUR_ARROW    - Standard arrow.
     CUR_MOVE     - Move cursor.
     CUR_GROW     - Grow cursor.
     CUR_TEXT     - Text cursor.
     CUR_CLOCK    - Clock.
     CUR_PENCIL
     CUR_TARGET
     CUR_TARGET2
     CUR_STOP
     CUR_ZOOM
     CUR_SCRUP
     CUR_SCRDN
     CUR_SCRLF
     CUR_SCRRG
     CUR_TEXT2
     CUR_DRAG     - Drag cursor (used for drag & drop).
     CUR_FINGER   - Finger cursor (used for html links).

     These values use also for the "t_view.cursor" variable.



Available states for the t_mouse structure

     MO_SF_MOUSEMOVE    - Mouse is moved.
     MO_SF_MOUSELDOWN   - Left button on mouse was pressed.
     MO_SF_MOUSELUP     - Left button on mouse was released.
     MO_SF_MOUSERDOWN
     MO_SF_MOUSERUP
     MO_SF_MOUSEMDOWN
     MO_SF_MOUSEMUP
     MO_SF_MOUSELAUTO   - Left button is still pushed.
     MO_SF_MOUSEMAUTO
     MO_SF_MOUSERAUTO
     MO_SF_MOUSELDOUBLE - Left button was double-clicked.
     MO_SF_MOUSERDOUBLE
     MO_SF_MOUSEMDOUBLE

     MO_SF_MOUSEDOUBLE  - One of buttons was double-clicked.
     MO_SF_MOUSEAUTO    - One of buttons is still pushing.
     MO_SF_MOUSEDOWN    - One of buttons was pressed.
     MO_SF_MOUSEUP      - One of buttons was released.
     MO_SF_MOUSEPRESS   - One of button is down.
     MO_SF_MOUSELPRESS  - Left button is down.
     MO_SF_MOUSEMPRESS	
     MO_SF_MOUSERPRESS





The t_mouse structure

Variables

     Name:         struct t_object  obclass;

     Description:  Inherit functions/variables from the t_object structure.



     Name:         struct t_point  speed;

     Description:  Speed of mouse, speed.x = 0 is maximal speed in x coord 
                   and speed.x = 10 is minimal speed. It's same in speed.y.



     Name:         struct t_point  where;

     Description:  Point of mouse, where cursor is placed in screen.



     Name:         l_char  buttons;

     Description:  Number of buttons for mouse.




Functions

get_cursor ()
     Description:
       Gets the BITMAP of the cursor.

     Syntax:
       BITMAP*  (*get_cursor)(p_mouse o);

     Parameters:
       o           Object to get cursor from.

     Returns:
       BITMAP containing the cursor.



get_focus ()
     Description:
       Gets the focus point of cursor. This is the delta point from the
       beginning of cursor's BITMAP, where the focus is placed.

     Syntax:
       t_point   (*get_focus)(p_mouse o);

     Parameters:
       o           The object to get focus point for.

     Returns:
       A t_point structure containing the focus.



get_range ()
     Description:
       Gets the bounds of the cursor on the screen.

     Syntax:
       t_rect  (*get_range)(p_mouse o);

     Parameters:
       o           The object to get the bounds for.

     Returns:
       The bounds in a t_rect structure.



is_visible ()
     Description:
       Determines wether the cursor is visible or not.

     Syntax:
       l_bool  (*is_visible)(p_mouse o);

     Parameters:
       o           The mouse object to check.

     Returns:
       True if visible. False otherwise.



set_dclick_diff ()
     Description:
       Set double-click time in miliseconds between the two clicks.

     Syntax:
       void  (*set_dclick_diff)(p_mouse o, l_int mili);

     Parameters:
       o           Mouse object to set.
       mili        The time in miliseconds.

     Returns:
       -



show ()
     Description:
       Shows the cursor on the screen.

     Syntax:
       l_bool  (*show)(p_mouse o);

     Parameters:
       o           The mouse object who's cursor to show.

     Returns:
       True if successful, otherwise False.



hide ()
     Description:
       Hides the cursor on the screen.

     Syntax:
       l_bool  (*hide)(p_mouse o);

     Parameters:
       o           The mouse object who's cursor to hide.

     Returns:
       True if successful, otherwise False.



block ()
     Description:
       Hides mouse cursor when it's inside certain bounds.

     Syntax:
       l_int  (*block)(p_mouse o, t_rect r );

     Parameters:
       o           The mouse object to block.
       r           Rectangle defining the bounds.

     Returns:
       When cursor is visible and is placed somewhere within these 
       bounds, it hides cursor and returns non-zero. Otherwise it returns
       zero and does not hide the cursor. This value is used later in the
       "MOUSE->unblock()" function, to show the cursor on screen again.



unblock ()
     Description:
       Unblocks the mouse previously blocked with the block() function.
       This functions are used as push/pop in assembler.

     Syntax:
       void  (*unblock)(p_mouse o, l_int i );

     Parameters:
       o           The mouse to unblock.
       i           Value returned from the block() function.

     Returns:
       -



is_block ()
     Description:
       Finds out if a mouse is blocked and therefore not visible.

     Syntax:
       l_bool  (*is_block)(p_mouse o );

     Parameters:
       o           The mouse to check.

     Returns:
       True if mouse is blocked. False otherwise.



set_pos ()
     Description:
       Sets the position of the cursor to a point on the screen.

     Syntax:
       void  (*set_pos)( p_mouse o, t_point where );

     Parameters:
       o           The mouse who's cursor to set.
       where       t_point structure with new position to set.

     Returns:
       -



set_cursor ()
     Description:
       Sets the cursor of the mouse to a BITMAP.

     Syntax:
       l_bool    (*set_cursor)(p_mouse o, BITMAP *cursor);

     Parameters:
       o           Mouse who's cursor to set.
       BITMAP      The bitmap to set the cursor to.

     Returns:
       True if successful, otherwise False.



set_cursor_focus ()
     Description:
       Sets the cursor of the mouse to a BITMAP and sets its
       the focus point.

     Syntax:
       l_bool  (*set_cursor_focus)(p_mouse o, BITMAP *cursor, t_point p );

     Parameters:
       o           Mouse who's cursor to set.
       BITMAP      The bitmap to set the cursor to.
       p           The new focus point.

     Returns:
       True if successful, otherwise False.



set_range ()
     Description:
       Sets bounds of the cursor.

     Syntax:
       void  (*set_range)(p_mouse o, t_rect r );

     Parameters:
       o           Mouse cursor to set.
       r           New bounds of cursor.

     Returns:
       -



set_speed ()
     Description:
       Sets speed of mouse cursor. Then it can be gotten from
       the "MOUSE->speed" variable.

     Syntax:
       void  (*set_speed)(p_mouse o, t_point speed );

     Parameters:
       o           The mouse to set speed for.
       speed       t_point structure where p.x is horisontal
                   speed and p.y is vertical speed.

     Returns:
       -



set_focus ()
     Description:
       Sets the focus point of the cursor.

     Syntax:
       void  (*set_focus)(p_mouse o, t_point focus );

     Parameters:
       o           The mouse to set.
       focus       The new focus point.

     Returns:
       -



set_mode
     Description:
       Sets mode, color and rectangle of the cursor.

     Syntax:
       l_bool  (*set_mode)(p_mouse o, l_int mode, l_color col, t_rect r );

     Parameters:
       o           The object to set.
       mode        The mode to set. Can be one of:

                      MO_MO_RECT - Effect like a drag-window frame.
                      MO_MO_GROW - Effect like a resize-window frame.

       r           The rectangle to set.

     Returns:
       True if successful, otherwise False.




Example:


    if ( event->type & EV_MOUSE ) {

       if ( OBJECT(mouse)->state & MO_SF_MOUSELDOWN ) {

           /* ...left button is pressed... */ 

       };

    };