NOTE:
This project is no longer being maintained: it was developed for my masters thesis, which was completed in early 1997. I still, however, welcome any questions or comments that people may have.

[Home] [ToC] [Up] [Prev] [Next]


iHTML Browser Services

Events

The browser's event services provide an abstract interface to user interface events that occur within the browser. This includes typical graphical user interface events such as keyboard and mouse movement, as well as higher-level browser events such as printing, changes in the view of a document, and selection of hyperlinks.

These services are typically implemented in two pieces, with the user interface events being implemented by the operating system glue and the document events a part of the browser glue.


Types

IHAttrType
Synopsis
The type of an attribute value.
Definition
typedef enum {
  ATTRTYPE_NONE_ID,               /* No attribute value returned */
  ATTRTYPE_INTEGER_ID,            /* Returned attribute is an integer */
  ATTRTYPE_STRING_ID,             /* Attribute points to 0-term string */
  _ATTRTYPE_NUM
} IHAttrType;
See Also
IHAttrVal

This enumeration is used to indicated the actual type of an attribute that is returned by the browser or being sent to it.

IHAttrVal
Synopsis
An abstract handle on an event attribute's value.
Definition
typedef void* IHAttrVal;  /* Type to use for attributes */
See Also
IHAttrType

This type is used to hold an arbitrary attribute value. When getting and setting attributes, it is used in conjunction with IHAttrType to manipulute attributes of arbitrary type.

IHEvent
Synopsis
A type representing a single user action that has occured in the system.
Definition
struct ih_event_rec {
  IHGlobalInfo* interface;   /* Interface event is for */
  IHLangEnv* langenv;        /* Language to send to / owns object */
  IHDocument document;       /* The document event is associated with */
  IHEventClass class;        /* Major event class */
  IHEventCode code;          /* Minor event type */
  void* object;              /* Object associated with event.  The type
                                this points to depends on the event class. */
  /* The browser may append private information after this structure */
};
See Also
IHGlobalInfo, IHLangEnv, IHDocument, IHEventClass, IHEventCode

This event type represents a single action that can occur in the iHTML system. This includes standard user interface events such as button and keyboard presses, as well as higher-level events such as a document being printed or a hyperlink being displayed.

Each event is associated with a particular document, which tells where in the browser component it is located, and a language environment that associates it with a particular scripting language running in that document. In addition, its major class identifier describes the high-level type of the event, with the minor code identifying the exact action that occured.

IHEventAttr
Synopsis
The attributes that can be associated with an event.
Definition
typedef enum {
  IEATTR_CUSTOM_ID = -1,          /* Attribute custom to program */

  IEATTR_VIEW_TOP_ID = 0,         /* Top pixel of container view */
  IEATTR_VIEW_BOTTOM_ID,          /* Bottom pixel of container view */
  IEATTR_VIEW_LEFT_ID,            /* Left pixel of container view */
  IEATTR_VIEW_RIGHT_ID,           /* Right pixel of container view */
  IEATTR_VIEW_WIDTH_ID,           /* Pixel width of container view */
  IEATTR_VIEW_HEIGHT_ID,          /* Pixel height of container view */
  IEATTR_VIEW_FULLWIDTH_ID,       /* Pixel width of container object */
  IEATTR_VIEW_FULLHEIGHT_ID,      /* Pixel height of container object */

  IEATTR_ANCHOR_NAME_ID,          /* The href of anchor that caused event */

  IEATTR_MOUSE_X_ID,              /* Current mouse x position */
  IEATTR_MOUSE_Y_ID,              /* Current mouse y position */
  IEATTR_MOUSE_BUTTON_ID,         /* Mouse button which was pressed/released */
  IEATTR_MOUSE_STATE_ID,          /* Current mouse button flags, see below */
  IEATTR_KEY_ASCII_ID,            /* ASCII value of keypress */
  IEATTR_KEY_STATE_ID,            /* Current key qualifier flags, see below */

  IEATTR_REDRAW_X_ID,             /* Region that needs to be redrawn */
  IEATTR_REDRAW_Y_ID,
  IEATTR_REDRAW_WIDTH_ID,
  IEATTR_REDRAW_HEIGHT_ID,

  _IEATTR_NUM
} IHEventAttr;
See Also
IHEvent

This type identifies the basic attributes that can be assigned and retrieved from an event. Their availability and interpretation depends on the event class and code, as follows:

IECLASS_DOCUMENT_ID
The IEATTR_VIEW_* events indicate the current position and size of the browser's view on the document when the event occurred. Writing to them changes this view, either scrolling the document or possible resizing the document's window.
IECLASS_WIDGET_ID
The IEATTR_MOUSE_*, IEATTR_KEY_*, and IEATTR_REDRAW_*, contain information about the event that occurred. Exactly which ones are defined depends on what is relevant for the event code.

The following bits are defined for the IEATTR_MOUSE_STATE_ID and IEATTR_BUTTON_ID attributes:

#define IEMOUSE_SELECT_ID (1<<0)  /* Select button */
#define IEMOUSE_POPUP_ID  (1<<1)  /* Popup menu button */
#define IEMOUSE_OPTION_ID (1<<2)  /* Optional action (ie, draw w/background) */

The following bits are defined for the IEATTR_KEY_STATE_ID attribute:

#define IEKEY_SHIFT_ID   (1<<0)  /* Shift key is down */
#define IEKEY_CONTROL_ID (1<<1)  /* Control key is down */
#define IEKEY_CAPS_ID    (1<<2)  /* Caps-lock key is down */
#define IEKEY_ALT_ID     (1<<3)  /* Alt inducer key is down */
IHEventClass
Synopsis
The major class identifier of an event.
Definition
typedef enum {
  IECLASS_CUSTOM_ID = -1,  /* A event class custom to program */
  IECLASS_NULL_ID = 0,     /* A nothing event */

  IECLASS_DOCUMENT_ID,     /* An event for the entire document */
  IECLASS_WIDGET_ID,       /* A widget-specific event */

  _IECLASS_NUM             /* Number of possible events classes */
} IHEventClass;
See Also
IHEvent

This type enumerates the possible classes of events, which determine the general structure and attributes of the event. It also determines that type the IHEvent's object field is, as follows:

IECLASS_DOCUMENT_ID
(no object)
IECLASS_WIDGET_ID
IHWidgetObj

IHEventCode
Synopsis
The minor code identifier of an event.
Definition
typedef enum {
  IECODE_CUSTOM_ID = -1,     /* A event code custom to program */
  IECODE_ANY_ID = 0,         /* Any event type */

  IECODE_DISPLAYED_ID,       /* A view has been displayed. */
  IECODE_LOADED_ID,          /* A data requested has finished loading. */
  IECODE_SCROLL_ID,          /* Scroll within container */
  IECODE_ONANCHOR_ID,        /* Mouse pointer has moved on hypertext link. */
  IECODE_OFFANCHOR_ID,       /* Mouse pointer has moved off hypertext link. */
  IECODE_HITANCHOR_ID,       /* User has selected a hypertext link. */
  IECODE_PRINT_ID,           /* Being printed.  Not implemented for widgets. */
  IECODE_RESIZE_ID,          /* Resize object */
  IECODE_REDRAW_ID,          /* Object needs to redraw itself */
  IECODE_MOUSEMOVE_ID,       /* Mouse has moved */
  IECODE_MOUSEPRESS_ID,      /* Mouse button pressed */
  IECODE_MOUSERELEASE_ID,    /* Mouse button released */
  IECODE_KEYPRESS_ID,        /* Keyboard button pressed */
  IECODE_KEYRELEASE_ID,      /* Keyboard button released */
  IECODE_ENTER_ID,           /* Mouse entered object */
  IECODE_LEAVE_ID,           /* Mouse left object */

  _IECODE_NUM                /* Number of possible events types */
} IHEventCode;
See Also
IHEvent

This type enumerates all of the possible action codes that an event can be. The exact interpretation and validity of these codes depends on the class of the event they are used in.


Functions

BR_AllocEvent
Synopsis
IHEvent* BR_AllocEvent(IHGlobalInfo* gi, IHDocument doc, IHLangEnv* langenv, IHEventClass class, IHEventCode code, void* object)
Arguments
(IHGlobalInfo*) gi
iHTML library interface context.
(IHDocument) doc
Document event is associated with.
(IHLangEnv*) langenv
Language environment that will handle event.
(IHEventClass) class
Major class ID of event.
(IHEventCode) code
Minor code ID of event.
(void*) object
An object associated with the event, e.g. a language-side widget object. The actual type depends on the event class.
Return
(IHEvent*) A newly created event.
See Also
IHGlobalInfo, IHLangEnv, IHDocument, IHEvent, IHEventClass, IHEventCode

Creates a new event with the given attributes. The program may then perform set/get operations on any appropriate attributes. Not that all of these arguments are constants for an event, and should not be changed after the event is created.

BR_DupEvent
Synopsis
IHEvent* BR_DupEvent(IHEvent* orig)
Arguments
(IHEvent*) orig
The original event to copy.
Return
(IHEvent*) A newly created event, that is identical to orig
See Also
BR_AllocEvent()

Creates a new event that is a duplicate of the given existing event.

BR_FreeEvent
Synopsis
void BR_FreeEvent(IHEvent* event)
Arguments
(IHEvent*) event
A previously allocated event.
Return
nothing.
See Also
BR_AllocEvent() BR_DupEvent()

Frees an event previously allocated with BR_AllocEvent() or BR_DupEvent().

BR_FreeEventAttr
Synopsis
void BR_FreeEventAttr(IHEvent* event, IHEventAttr attr, IHAttrType type, IHAttrVal value)
Arguments
(IHEvent*) event
A previously allocated event.
(IHEventAttr) attr
The attribute being deallocated
(IHAttrType) type
The type that value is.
(IHAttrVal) value
The attribute value that was previously returned by BR_GetEventAttr().
Return
nothing.
See Also
IHEventAttr, IHAttrVal, IHAttrType BR_GetEventAttr

Deallocates any memory associated with the given attribute, which had previously been obtained with BR_GetEventAttr().

BR_GetEventAttr
Synopsis
IHAttrType BR_GetEventAttr(IHEvent* event, IHEventAttr attr, IHAttrVal* value)
Arguments
(IHEvent*) event
A previously allocated event.
(IHEventAttr) attr
The attribute value to retrieve
(IHAttrVal*) value
Where to place the attribute's current value.
Return
(IHAttrType) The type of the returned attribute value, or ATTRTYPE_NONE for failure.
See Also
IHEventAttr, IHAttrVal, IHAttrType, BR_FreeEventAttr

Returns the value of an attribute associated with the given browser event. The type of the attribute is the return code; a type of ATTRTYPE_NONE indicates that the attribute doesn't exist.

A program must call BR_FreeEventAttr() on all attributes it retrieves, when it is done with them.

BR_SetEventAttr
Synopsis
void BR_SetEventAttr(IHEvent* event, IHEventAttr attr, IHAttrType type, IHAttrVal value)
Arguments
(IHEvent*) event
A previously allocated event.
(IHEventAttr) attr
The attribute to set.
(IHAttrType) type
The type that value is.
(IHAttrVal) value
The new value to set the attribute to.
Return
nothing.
See Also
IHEventAttr, IHAttrVal, IHAttrType

Sets an event's attribute to the given value.


[Home] [ToC] [Up] [Prev] [Next]

_________.oo_Q_Q_oo.____________________________________________
Dianne Kyra Hackborn <hackbod@angryredplanet.com>
Last modified: Tue Oct 8 04:00:43 PDT 1996

This web page and all material contained herein is Copyright (c) 1997 Dianne Hackborn, unless otherwise noted. All rights reserved.