Mouse-cursors

You should not use the Allegro functions/variables for mouse-manipulations directly. CGUI will do some changes for certain events, that will override such changes. Instead use the functions listed below. There are some pre- defined cursors "installed" that you can selecet among (CGUI uses them itself). You may also extend this list of installed cursors. In addition to this you may create overlayed cursors, i.e. make a new cursor from the currently selected and some other sprite.


int cgui_mouse_draw_in_interrupt;

A global variable that tells the mouse cursor to be drawn inside the interrupt. The default is not. The reason why the mouse is drawn "polled" (or rather via the event queue), is that the interrupt drawing will not draw well if you use canvases. This is a weakness in CGUI, that may be removed in later versions. The reason why uou want to let the cursor to be drawn in the interrupt is that it otherwise will "freeze" if the program is busy for a long time without returning the control to the event queue processor (this is quite rare in most programs, e.g. disk accesses for 1M will not be affect the mouse moving).


void InstallCursor(int cursor_no, BITMAP *sprite, int x, int y);

Installs a sprite to be a predefined cursor. This cursor may replace an existing cursor, as well as extend the list of available. x,y is the hotspot point relative to the upper left corner of the sprite. InstallCursor will make a copy of the bitmap, so you are still responsible for the memory after the call, and may feel free to destroy it.
If your cursor replaces an existing one, the latter will be destroyed.


void SelectCursor(int cursor_no);

Selects a predefined cursor using the specified index. Available cursor alternatives are: The mouse event processing will occasionally switch between the above indexes. E.g. moving over a draggable object will set CURS_DRAGGABLE. If you select another index this will inhibit this automatic cursor switching.
Selecting another cursor than above requires that the cursor have been installed first.
See also: InstallCursor.
void PointerLocation(int id, int *x, int *y);

Returns the mouse pointer locataion related to the specified object.
See also: OverlayPointer.
BITMAP *ObjectApearance(int id);

Returns a pointer to a bitmap showing the current view of the specified object. The bitmap belongs to you, i.e. it's your responsibility to destroy it when you don't need it any longer.
See also: OverlayPointer.
void OverlayPointer(BITMAP *sprite, int x, int y);

Creates an overlayed mouse pointer. This means that a new pointer will be created by merging the shapes of `sprite' and the current selected pointer.
The current selected pointer will appear on top of `sprite'.
Overlayed mouse pointer may be useful e.g. during dragging operations showing the dragged object as a cursor and letting the current selected cursor still be left on top to point out the "hot spot".
The current selected cursor can later be restored as a single pointer by `RemoveOverlayPointer'.
Subsequent calls to `OverlayPointer' let you overlay multiple cursors.
If `SelectCursor' is called while an overlayed pointer is in use the requested change will be reflected in the overlayed pointer.
Parameters:
See also: InstallCursor, RemoveOverlayPointer, PointerLocation, ObjectApearance.
void RemoveOverlayPointer(void);

UnInstalles a secondary cursor previously installed by OverlayPointer.
See also: OverlayPointer.
void MkTextPointer(FONT *f, char *text);

Creates an overlayed cursor using the specified text and font Restore a plain pointer by a call to `RemoveOverlayPointer'.


Back to contents