4.13.1 Context class

The Context class provides the interface to the tablet driver.

class Context( )
The class takes no parameters. All the context attributes will be initialized with the default values as provided by the driver.

Context attributes:

name
Context name.

options
Specifies options for the context and must be a combination of the following flags:

Option Description
CXO_SYSTEM The context is a system cursor context
CXO_PEN The context is a Pen Windows (and system cursor) context
CXO_MESSAGES The context sends WT_PACKET messages to its owner
CXO_MARGIN The input context will have a margin
CXO_MGNINSIDE The margin will be inside the specified context
CXO_CSRMESSAGES The context sends WT_CSRCHANGE messages to its owner

status
Specifies current status conditions for the context. The status value is a combination of the following bits:

Status bit Description
CXS_DISABLED The context has been disabled
CXS_OBSCURED The context is at least partially obscured by another context
CXS_ONTOP The context is the topmost context

locks
Specifies which attributes of the context the application wishes to be locked. The value can be a combination of the following bits:

Lock Description
CXL_INSIZE The input size cannot be changed
CXL_INASPECT The input aspect ration cannot be changed
CXL_MARGIN The margin options cannot be changed
CXL_SENSITIVITY The sensitivity settings for x, y and z cannot be changed
CXL_SYSOUT The system pointing control variables cannot be changed

msgbase
Base number for the message IDs.

device
Specifies the device whose input the context processes.

pktrate
Specifies the desired packet report rate in Hertz. Once the context is open, this field will contain the actual report rate.

pktdata
Specifies which optional data items will be in packets returned from the context.

pktmode
Specifies whether the packet data items will be returned in absolute or relative mode. If the item's bit is set in this field, the item will be returned in relative mode.

movemask
Specifies which packet data items can generate move events in the context.

btndnmask
Specifies the buttons for which button press events will be processed in the context.

btnupmask
Specifies the buttons for which button release events will be processed in the context.

inorgx
Specifies the origin of the context's input area in the tablet's native coordinates along the x axis.

inorgy
Specifies the origin of the context's input area in the tablet's native coordinates along the y axis.

inorgz
Specifies the origin of the context's input area in the tablet's native coordinates along the z axis.

inextx
Specifies the extent of the context's input area in the tablet's native coordinates along the x axis.

inexty
Specifies the extent of the context's input area in the tablet's native coordinates along the y axis.

inextz
Specifies the extent of the context's input area in the tablet's native coordinates along the z axis.

outorgx
Specifies the extent of the context's output area in context output coordinates along the x axis.

outorgy
Specifies the extent of the context's output area in context output coordinates along the y axis.

outorgz
Specifies the extent of the context's output area in context output coordinates along the z axis.

outextx
Specifies the extent of the context's output area in context output coordinates along the x axis.

outexty
Specifies the extent of the context's output area in context output coordinates along the y axis.

outextz
Specifies the extent of the context's output area in context output coordinates along the z axis.

sensx
Specifies the relative-mode sensitivity factor for the x axis.

sensy
Specifies the relative-mode sensitivity factor for the y axis.

sensz
Specifies the relative-mode sensitivity factor for the z axis.

sysmode
Specifies the system cursor tracking mode. True specifies absolute, False means relative.

sysorgx
Specifies the origin in screen coordinates of the screen mapping area for system cursor tracking.

sysorgy
Specifies the origin in screen coordinates of the screen mapping area for system cursor tracking.

sysextx
Specifies the extent in screen coordinates of the screen mapping area for system cursor tracking.

sysexty
Specifies the extent in screen coordinates of the screen mapping area for system cursor tracking.

syssensx
Specifies the system-cursor relative-mode sensitivity factor for the x axis.

syssensy
Specifies the system-cursor relative-mode sensitivity factor for the y axis.

Other attributes:

queuesize
The number of packets the context's queue can hole. Setting this attribute may result in an exception if the queue size could not be set. In such a case, you must try again with a smaller value.

id_packet
The final id of the WT_PACKET message.

id_csrchange
The final id of the WT_CSRCHANGE message.

id_ctxopen
The final id of the WT_CTXOPEN message.

id_ctxclose
The final id of the WT_CTXCLOSE message.

id_ctxupdate
The final id of the WT_CTXUPDATE message.

id_ctxoverlap
The final id of the WT_CTXOVERLAP message.

id_proximity
The final id of the WT_PROXIMITY message.

id_infochange
The final id of the WT_INFOCHANGE message.

Methods:

open( hwnd, enable)
Opens the context. hwnd is the window handle (as integer) of the window that owns the context and that receives messages from the context. enable is a boolean that specifies whether the context will immediately begin processing input data.

Set the context attributes to the desired values before calling this method. Modifying context attributes after the context was opened is possible with the set() method.

restore( hwnd, saveinfo, enable)
This method is equivalent to the open() method with the only difference that it takes the context attributes via the binary saveinfo string which was returned by the save() method in a previous session.

close( )
Closes the context if it was open (or do nothing if it was already closed or if it was not open at all).

save( )
Returns a binary saveinfo string containing the current context state. This string can be used as argument to the restore() method.

packet( serial)
Returns the packet with the specified serial number.

enable( flag)
If flag is True the context is enabled, otherwise it is disabled. Returns True if the operation was successful.

overlap( totop)
If totop is True the context will become the topmost context, otherwise it will be send to the bottom. Returns True if the operation was successful.

config( hwnd=0)
Prompts the user for changes to the context via a dialog box. hwnd is the window handle of the window that will be parent of the dialog. If it is 0, the context owning window will be used. The return value is True if the context was changed.

get( )
Update the local context attributes.

set( )
Update the tablet context with the settings stored in the local context attributes.

packetsGet( maxpkts)
Return the next maxpkts packets and remove them from the queue.

packetsPeek( maxpkts)
Return the next maxpkts packets without removing them from the queue.

dataGet( begin, end, maxpkts)
Return all packets with serial numbers between begin and end inclusive and remove them from the queue. However, no more than maxpkts packets are returned. The return value is a 2-tuple (numpackets, packet list) where numpackets is the total number of packets found in the queue between begin and end.

dataPeek( begin, end, maxpkts)
This is the same as dataGet() but it doesn't remove the packets from the queue.

queuePacketsEx( )
Returns the serial numbers of the oldest and newest packets currently in the queue.