GLG Toolkit, C# Class Library  Version 4.6
Listeners and Callbacks

Detailed Description

GlgControl provides callback methods that are invoked to handle various events in the control's drawing. The callbacks may be overridden by control's subclasses to implement custom event processing logic.

AddListener can also be used to add GLG listeners that will handle events as an alternative to subclassing.

Functions

virtual Object AddListener (GlgCallbackType listener_type, Object listener)
 Adds an event listener to the control. More...
 
virtual void HCallback (GlgObject viewport)
 H callback. More...
 
virtual void HierarchyCallback (GlgObject top_viewport, GlgHierarchyData hierarchy_info)
 Hierarchy callback. More...
 
virtual void InputCallback (GlgObject vp, GlgObject message_obj)
 Input callback. More...
 
virtual void ReadyCallback (GlgObject viewport)
 Ready callback. More...
 
virtual void SelectCallback (GlgObject vp, Object[] name_array, int button)
 Select callback. More...
 
virtual void Trace2Callback (GlgObject top_viewport, GlgTraceData trace_info)
 This method is invoked to handle any events in the control's drawing and may be overridden by control's subclasses to implement custom event handling logic. More...
 
virtual void TraceCallback (GlgObject top_viewport, GlgTraceData trace_info)
 Trace callback. More...
 
virtual void VCallback (GlgObject viewport)
 V callback. More...
 

Function Documentation

◆ AddListener()

virtual Object AddListener ( GlgCallbackType  listener_type,
Object  listener 
)
virtual

Adds an event listener to the control.

Only a single event listener for each listener type is enabled. Setting a new event listener overrides any previous settings. Hierarchy listener must be attached before loading the control's drawing.

By default, the control itself is used as a listener for all GLG events; adding a listener disables the corresponding event-handling callback of the control (for example, adding the INPUT_CB listener disables the control's InputCallback). Therefore, the application must use only one type of the event handling: either a control's callback or a listener.

The control's callback method is usually used for applications which subclass the control to provide different event-handling functionality for derived classes.

The control's C# events are handled independently and are not affected if a corresponding listener is added: both the listener and an event handler will be invoked.

Parameters
listener_typeThe type of listener to add. May be one of the following:
listener

The listener to be added. Must implement one of the following interfaces that match the listener_type parameter:

A null value may be used to remove a listener for the events specified by the listener_type parameter.

Returns
Previous listener of the specified type.

◆ HCallback()

virtual void HCallback ( GlgObject  viewport)
virtual

H callback.

This method is invoked after the control's drawing has been loaded, but before its object hierarchy has been setup.

The method can be used for setting initial parameters of the loaded drawing before its hierarchy has been setup.

Parameters
viewportThe top viewport object of the control's drawing.

Implements GlgHListener.

◆ HierarchyCallback()

virtual void HierarchyCallback ( GlgObject  top_viewport,
GlgHierarchyData  hierarchy_info 
)
virtual

Hierarchy callback.

is used to get access to the drawing to be displayed in the SubWindow and SubDrawing objects before the drawing is displayed.

This method is invoked when a SubWindow object in the control's drawing loads its template drawing, or when a SubDrawing loads its template. The method is invokes several times at different stages of the template setup and may used to configure the SubWindow and SubDrawing instances before they are displayed.

The method may be overridden by control's subclasses to implement custom instance setup logic.

A Hierarchy listener can be added using AddListener as an alternative to subclassing.

Parameters
top_viewportThe top-level viewport object.
hierarchy_infoGlgHierarchyData object containing information about the subdrawing that triggered the callback. See GlgHierarchyData for more information.

The method is invoked with the same parameters as the HierarchyCallback method of GlgHierarchyListener. See HierarchyCallback for more information.

Implements GlgHierarchyListener.

◆ InputCallback()

virtual void InputCallback ( GlgObject  vp,
GlgObject  message_obj 
)
virtual

Input callback.

This method is invoked to handle user interaction with input objects, as well as to perform object selection and action processing, and may be overridden by control's subclasses to implement custom interaction logic.

An Input listener can be added using AddListener as an alternative to subclassing.

Parameters
vpThe top-level viewport object.
message_objMessage object containing input event information.

The method is invoked with the same parameters as the InputCallback method of GlgInputListener. See InputCallback for more information.

Implements GlgInputListener.

◆ ReadyCallback()

virtual void ReadyCallback ( GlgObject  viewport)
virtual

Ready callback.

This method is invoked when the control has finished initializing, loading and displaying its drawing. This method may be overridden by control's subclasses to provide a custom control initialization logic.

The IsReady method can also be used to query the control's readiness.

Parameters
viewportThe top viewport object of the loaded drawing.

Implements GlgReadyListener.

◆ SelectCallback()

virtual void SelectCallback ( GlgObject  vp,
Object[]  name_array,
int  button 
)
virtual

Select callback.

This method provides a simplified name-based interface to handle object selection. It is invoked when objects are selected with the mouse and may be overridden by control's subclasses to implement custom selection logic.

A Select listener can be added using AddListener as an alternative to subclassing.

InputCallback provides an alternative callback that provides more elaborate selection information.

Parameters
vpThe top-level viewport object.
name_arrayA null-terminated list of names of all named objects selected with the mouse, or null if no objects were selected.
buttonThe mouse button that was pressed to select objects.

The method is invoked with the same parameters as the SelectCallback method of GlgSelectListener. See SelectCallback for more information.

Implements GlgSelectListener.

◆ Trace2Callback()

virtual void Trace2Callback ( GlgObject  top_viewport,
GlgTraceData  trace_info 
)
virtual

This method is invoked to handle any events in the control's drawing and may be overridden by control's subclasses to implement custom event handling logic.

The method is similar to the TraceCallback, but is invoked after the event has been processed.

A Trace2 listener can be added using AddListener as an alternative to subclassing.

Parameters
top_viewportThe top-level viewport object.
trace_infoA GlgTraceData object containing detailed event information. See GlgTraceData for more information.

The method is invoked with the same parameters as the TraceCallback method of GlgTraceListener. See TraceCallback for more information.

◆ TraceCallback()

virtual void TraceCallback ( GlgObject  top_viewport,
GlgTraceData  trace_info 
)
virtual

Trace callback.

This method is invoked to handle any events in the control's drawing and may be overridden by control's subclasses to implement custom event handling logic. The method is invoked before the event has been processed.

A Trace listener can be added using AddListener as an alternative to subclassing.

Parameters
top_viewportThe top-level viewport object.
trace_infoA GlgTraceData object containing detailed event information. See GlgTraceData for more information.

The method is invoked with the same parameters as the TraceCallback method of GlgTraceListener. See TraceCallback for more information.

Implements GlgTraceListener.

◆ VCallback()

virtual void VCallback ( GlgObject  viewport)
virtual

V callback.

This method is invoked after the object hierarchy of the control's drawing has been setup.

The method can be used for setting initial parameters of the loaded drawing after its hierarchy has been setup, but before the drawing is displayed.

Parameters
viewportThe top viewport object of the control's drawing.

Implements GlgVListener.