home *** CD-ROM | disk | FTP | other *** search
-
- The HASWIN window library.
- ===========================
- Copyright H.A. Shaw 1990.
- ===========================
-
- Mouse Pointers under the HASWIN system.
- ----------------------------------------
-
- HASWIN provides a more complex pointer system than that provided
- by the WIMP. Since there is a single pointer available at any time HASWIN
- considers the pointer to be a non-shared resource available to the user
- program (in the same way the caret is a non-shared resource). Each HASWIN
- window can have its own pointer that is automatically selected when the
- mouse is positioned over the window. In addition to this new pointers may
- be selected at any time. A first-in-first-out pointer stack is provided to
- simplify programming. If a section of code wishes to display a pointer it
- pushes its pointer onto the stack at the begining, and pulls its pointer
- off at the end of the code. If no action is taken the existing pointer is
- not changed. Pointers are made up of sprites that may be in any of the
- sprite areas except the system area. This is how pointers are selected on
- entering and leaving windows. Programs must be careful to pair pushes and
- pulls of the pointer stack.
-
-
- The HASWIN pointer is a data structure created and maintained by
- the HASWIN routines. A pointer has the following user selected features.
-
- 1) a named sprite that defines the pointer shape.
- 2) an active position that defines where the WIMP considers the
- pointer to actually be. (This is usually somewhere in the
- sprite shape, but does not have to be.)
- 3) A palette for the sprite, if it does not already have one.
- 4) X and Y coordinates.
- 5) The state of the buttons, and some control keys.
- 6) The window and icon the pointer is over.
-
- Since all of the fields of a pointer structure are user fields they
- will all be described.
-
- short mx;
- - The X coordinate of the mouse position. This may be read after
- a call to "haswin_getpointerinfo()" to get the current mouse X
- position. To move the pointer use "haswin_(push/set)pointer()"
- with this field set to the required value, or use
- "haswin_placepointer()".
-
- short my;
- - The Y coordinate of the mouse position. This may be read after
- a call to "haswin_getpointerinfo()" to get the current mouse Y
- position. To move the pointer use "haswin_(push/set)pointer()"
- with this field set to the required value, or use
- "haswin_placepointer()".
-
- int ihandle;
- - The handle of the icon the mouse it on top of. This may be
- read after a call to "haswin_getpointerinfo()" and may be set
- before a call to "haswin_(push/set)pointer()". If "whandle" is
- greater than 0 then "ihandle" can take various negative values
- as follows...
- -1 work area
- -2 back icon
- -3 close icon
- -4 title bar
- -5 toggle size icon
- -6 scroll up arrow
- -7 vertical scroll bar
- -8 scroll down arrow
- -9 adjust size icon
- -10 scroll left arrow
- -11 horizontal scroll bar
- -12 scroll right arrow
- -13 outer window frame
-
- int whandle;
- - The handle of the window the mouse it on top of. This may be
- read after a call to "haswin_getpointerinfo()" and may be set
- before a call to "haswin_(push/set)pointer()".
-
- struct window *win;
- - If "whandle" is a HASWIN window belonging to this program then
- "win" points to its window structure, or 0 otherwise.
-
- struct icon *ic;
- - If "ihandle" is a HASWIN icon belonging to this program then
- "ic" points to its window structure, or 0 otherwise.
-
- char name[POINTER_MAXDATA];
- - This contains the first POINTER_MAXDATA characters of the name
- of the sprite that defines the shape of the pointer. In this
- version POINTER_MAXDATA has the value 16.
-
- signed char activex;
- - This is the X coordinate of the active point of the pointer.
-
- signed char activey;
- - This is the Y coordinate of the active point of the pointer.
-
- unsigned char number;
- - This is the pointer number, from 1-4, but is unused.
-
- unsigned char buttons;
- - This is the state of the buttons and SHIFT, CONTROL and ALT keys.
- It may be read after a call to "haswin_getpointerinfo()". The
- bits of this coorespond to the three mouse buttons and the SHIFT,
- CONTROL and ALT keys.
- POINTER_MOUSE_R right mouse button
- POINTER_MOUSE_M middle mouse button
- POINTER_MOUSE_L left mouse button
- POINTER_MOUSE_S Shift pressed down
- POINTER_MOUSE_C Control pressed down
- POINTER_MOUSE_A Alt pressed down
- POINTER_MOUSEBUTTONS mask of just the mouse buttons
-
- palette *palette;
- - This points to a palette structure. If "palette" is non-zero and
- the sprite "name" does not have a palette of its own then alter
- the WIMP palette to this palette when the pointer is changed to
- this pointer.
-
-
- The routines that deal with pointers within the HASWIN system are
- described below.
-
- pointer *haswin_getpointerinfo(pointer *mouse);
- - fill in the current mouse coordinates, button state, state of
- the SHIFT, CONTROL and ALT keys and the window and icon the
- pointer is over in the pointer "mouse" with the current state as
- obtained from the WIMP. If "mouse" is 0 then a new pointer
- structure is created and all its fields are filled in from the
- current state.
- - Returns the pointer "mouse", the newly created pointer structure,
- or HASWIN_FALSE on any error.
-
- pointer *haswin_makepointer(char *name, int x, int y);
- - Create a new pointer structure with the sprite "name" and active
- point "x", "y". The position and button/key state is not filled
- into the new structure.
- - Returns the new pointer, or HASWIN_FALSE on any error.
-
- int haswin_poppointer(int move);
- - Pull a pointer from the pointer stack. if "move" is HASWIN_TRUE
- then move the pointer to the coordinates stored in the stacked
- pointer. If the stacked pointer is 0 then turn the pointer off.
- If "move" is HASWIN_FALSE then just change the pointer shape to
- the stacked shape. If the pointer structure has a palette then
- use WIMP_SetPalette to change the WIMP palette.
- - Return HASWIN_TRUE if successful, or HASWIN_FALSE on any error.
-
- int haswin_pushpointer(pointer *mouse, int move);
- - Push the current pointer onto the pointer stack and then change
- the current pointer to "mouse". If "mouse" is 0 turn the pointer
- off. If "move" is HASWIN_TRUE then move the current pointer to
- the coordinates stored in "mouse". If "move" is HASWIN_FALSE
- then just change the pointer shape to "mouse". If "mouse" has a
- palette then use WIMP_SetPalette to change the WIMP palette.
- - Return HASWIN_TRUE if successful, or HASWIN_FALSE on any error.
-
- int haswin_setpointer(pointer *mouse, int move);
- - Change the current pointer to "mouse". If "mouse" is 0 turn the
- pointer off. If "move" is HASWIN_TRUE then move the current
- pointer to the coordinates stored in "mouse". If "move" is
- HASWIN_FALSE then just change the pointer shape to "mouse". If
- "mouse" has a palette then use WIMP_SetPalette to change the WIMP
- palette.
- - Return HASWIN_TRUE if successful, or HASWIN_FALSE on any error.
-
- int haswin_placepointer(window *win, int x, int y);
- - Reposition the current pointer at "x","y" in the window "win".
- - Returns HASWIN_TRUE if successful or HASWIN_FALSE on any error, or
- if "x" or "y" were outside the window area. If the window is not
- being displayed the pointer is moved to where it would have been
- if the window was being displayed and no error is returned.
-
-
- The WIMP returns details of mouse button states in a rather
- inconvienent form for many purposes in that the button state code the WIMP
- uses for a particular button state depends upon the button type of the
- object the mouse in on at the time the button state changed. It would be
- much more convienent to the user program if the code representating a
- particular button state was independent of the button type of the objects
- on the screen. HASWIN therefore has a number of routines for converting
- between the object button type dependent button state codes that the WIMP
- uses and the independent codes that a user program can find more easy to
- use internally. The 7 types of single button operation are represented
- by the following constant values
-
- HASWIN_MOUSE_R - right or ADJUST button pressed
- HASWIN_MOUSE_M - middle or MENU button pressed
- HASWIN_MOUSE_L - left or SELECT button pressed
- HASWIN_MOUSE_RDRAG - right or ADJUST button dragged
- HASWIN_MOUSE_LDRAG - left or SELECT button dragged
- HASWIN_MOUSE_RDOUB - right or ADJUST button double clicked
- HASWIN_MOUSE_LDOUB - left or SELECT button double clicked
-
- int haswin_buttonHASWINtoWIMP(window *win, icon *ic, int button);
- - convert the button state "button" from one of the HASWIN internal
- codes into a WIMP button state with reference to the window "win"
- and the icon "ic". Either "win" or "ic" may be 0.
- - Returns the WIMP button code.
-
- int haswin_buttonWIMPtoHASWIN(window *win, icon *ic, int button);
- - convert the button state "button" from the codes the WIMP uses
- into codes for HASWIN with reference to the window "win" and the
- icon "ic". Either "win" or "ic" may be 0. It is garenteed that
- for a particular mouse button state (such as SELECT pressed) the
- returned code will be unique to that state and is independent of
- the button type of the object under the mouse pointer.
- - Returns the HASWIN button code.
-
- int haswin_canbuttondouble(int type);
- - Returns HASWIN_TRUE if the WIMP button type "type" responds to
- double clicks and HASWIN_FALSE if it does not. If the button
- type is not known it returns HASWIN_UNKNOWN.
-
- int haswin_canbuttondrag(int type);
- - Returns HASWIN_TRUE if the WIMP button type "type" responds to
- drags and HASWIN_FALSE if it does not. If the button type is
- not known it returns HASWIN_UNKNOWN.
-
- int haswin_canbuttonselect(int type);
- - Returns HASWIN_TRUE if the WIMP button type "type" responds to
- select and HASWIN_FALSE if it does not. If the button type is
- not known it returns HASWIN_UNKNOWN.
-
- int haswin_canbuttonwrite(int type);
- - Returns HASWIN_TRUE if the WIMP button type "type" is a writable
- type and HASWIN_FALSE if it does not. If the button type is not
- known it returns HASWIN_UNKNOWN.
-
- int haswin_canbuttontwice(int type);
- - Returns HASWIN_TRUE if the WIMP button type "type" responds to
- drags or double clicks, ie. any mouse operation that results in
- more than one event returned by SWI WIMP_Poll. The routine
- returns HASWIN_FALSE if it does not respond. If the button type
- is not known it returns HASWIN_UNKNOWN.
-
-