canvas.eh
Screen on which you can do arbitrary drawing. More...
Constants
Types
Functions
Description
This header provides a
Screen
called "canvas". Canvas provides facilities
of low-level drawing on the display and allows to read key presses and touch events.
Canvas is double-buffered, all drawings are performed on off-screen buffer that is
obtained with
Canvas.graphics. After drawing is finished,
Canvas.refresh
should be called to present changes on the display.
Key events
If you press the key while the active screen is canvas, the
UIEvent will be
generated. Its
kind
field will be
EV_KEY and its
value
field
will contain the code of the pressed key. Since returned type of the
UIEvent.value
is not known at the time of compilation, you have to cast it manually
Similarly, when key is released,
EV_KEY_RELEASE event is generated. Also, if key is
held down, device may generate
EV_KEY_HOLD event repeatedly. The last event type is
optional, to test if device supports hold events, use
Canvas.has_hold_event.
This header defines key codes for standard phone keypad (keys 0..9, * and #). If the phone
has other alphanumeric keys, the code (most probably) will be the corresponding Unicode
character code. If phone has non-alphanumeric keys (for example, joystick), those keys
will (most probably) return negative key codes. However, actual key codes may be different
on distinct hardware. If you want your application to be portable, you should use only
the standard key codes provided by this header. Or use the action codes.
Action codes
Since keypads differ from device to device, platform provides the following
portable
action codes:
UP,
DOWN,
LEFT,
RIGHT,
FIRE,
ACT_A,
ACT_B,
ACT_C
and
ACT_D. Each key code is mapped to at most one action code.
However, multiple keys may be mapped to the same action code. For example,
if the phone has joystick, both moving the joystick up and pressing '2' key
will generate
UP action. To get action code for the pressed key use
Canvas.action_code(key).
Pointer events
If device has touch screen, the canvas may generate pointer events. To test
whether the device supports touch events, use
Canvas.has_ptr_events
and
Canvas.has_ptrdrag_event. For pointer events
value
field
of the event will be of type
Point. Since compiler cannot predict type
of the value, you have to cast it to the needed type manually to extract values
x and
y.
Constant details
Key code for key 0.
Key code for key 1.
Key code for key 2.
Key code for key 3.
Key code for key 4.
Key code for key 5.
Key code for key 6.
Key code for key 7.
Key code for key 8.
Key code for key 9.
Key code for key *.
Key code for key #.
Constant for the UP action.
Constant for the DOWN action.
Constant for the LEFT action.
Constant for the RIGHT action.
Constant for the FIRE action.
Constant for the general purpose "A" action.
Constant for the general purpose "B" action.
Constant for the general purpose "C" action.
Constant for the general purpose "D" action.
Type details
Screen for low-level drawing.
Function details
Creates new canvas screen.
If
fullscreen is
true
then created canvas is in fullscreen mode.
Returns the graphical buffer for this canvas on which you can draw.
def Canvas.read_key(): Int;
|
Returns key code of the last pressed key.
If no key was pressed, returns
0
. This is convenient function, if you
want to receive only key presses from canvas. If you want to receive other
kinds of events, use event framework.
Refreshes displayed content of the canvas.
def Canvas.action_code(key: Int): Int;
|
Returns the action code for the specified key code.
If given key has no associated action, then
0
is returned.
def Canvas.has_ptr_events(): Bool;
|
Checks if the platform supports pointer press and release events.
If returns
true
, the canvas will generate
EV_PTR_PRESS and
EV_PTR_RELEASE events.
def Canvas.has_ptrdrag_event(): Bool;
|
Checks if the platform supports pointer dragging events.
If returns
true
, the canvas will generate
EV_PTR_DRAG event.
def Canvas.has_hold_event(): Bool;
|
Checks if the platform supports key hold event.
If returns
true
, the canvas will generate
EV_KEY_HOLD event.