2.1.5 canvas<%>

► |  | GUI: Racket Graphics Toolkit

1 | Overview
2 | Reference
3 | Configuration
4 | Dynamic Loading
| Bibliography
| Index

► | 2 | Reference

2.1 | Windowing Classes
2.2 | Windowing Functions
2.3 | Drawing Classes
2.4 | Drawing Functions
2.5 | Editor Classes
2.6 | Editor Functions
2.7 | WXME Decoding

▼ | 2.1 | Windowing Classes

2.1.1 | area<%>
2.1.2 | area-container<%>
2.1.3 | area-container-window<%>
2.1.4 | button%
2.1.5 | canvas<%>
2.1.6 | canvas%
2.1.7 | check-box%
2.1.8 | checkable-menu-item%
2.1.9 | choice%
2.1.10 | clipboard-client%
2.1.11 | clipboard<%>
2.1.12 | combo-field%
2.1.13 | control<%>
2.1.14 | control-event%
2.1.15 | cursor%
2.1.16 | dialog%
2.1.17 | event%
2.1.18 | frame%
2.1.19 | gauge%
2.1.20 | group-box-panel%
2.1.21 | grow-box-spacer-pane%
2.1.22 | horizontal-pane%
2.1.23 | horizontal-panel%
2.1.24 | key-event%
2.1.25 | labelled-menu-item<%>
2.1.26 | list-box%
2.1.27 | list-control<%>
2.1.28 | menu%
2.1.29 | menu-bar%
2.1.30 | menu-item<%>
2.1.31 | menu-item%
2.1.32 | menu-item-container<%>
2.1.33 | message%
2.1.34 | mouse-event%
2.1.35 | pane%
2.1.36 | panel%
2.1.37 | popup-menu%
2.1.38 | radio-box%
2.1.39 | selectable-menu-item<%>
2.1.40 | separator-menu-item%
2.1.41 | scroll-event%
2.1.42 | slider%
2.1.43 | subarea<%>
2.1.44 | subwindow<%>
2.1.45 | tab-panel%
2.1.46 | text-field%
2.1.47 | timer%
2.1.48 | top-level-window<%>
2.1.49 | vertical-pane%
2.1.50 | vertical-panel%
2.1.51 | window<%>

On this page:

accept-tab-focus
get-canvas-background
get-dc
min-client-height
min-client-width
on-char
on-event
on-paint
on-tab-in
set-canvas-background
set-resize-corner
warp-pointer

Inherited methods:
from window<%>
accept-drop-files
client->screen
enable
focus
get-client-size
get-cursor
get-handle
get-height
get-label
get-plain-label
get-size
get-width
get-x
get-y
has-focus?
is-enabled?
is-shown?
on-drop-file
on-focus
on-move
on-size
on-subwindow-char
on-subwindow-event
on-superwindow-enable
on-superwindow-show
popup-menu
refresh
screen->client
set-cursor
set-label
show
from area<%>
get-graphical-min-size
get-parent
get-top-level-window
min-height
min-width
stretchable-height
stretchable-width
from subarea<%>
horiz-margin
vert-margin

top← prev up next →

canvas<%> : interface?

implements: | subwindow<%>

A canvas is a subwindow onto which graphics and text can be drawn. Canvases also receive mouse and keyboard events.

To draw onto a canvas, get its device context (see get-dc).

The canvas<%> interface is implemented by two classes:

- canvas% – a canvas for arbitrary drawing and event handling

- editor-canvas% – a canvas for displaying editor<%> objects

( send a-canvas accept-tab-focus) → boolean?
( send a-canvas accept-tab-focus on?) → void?
on? : any/c

Gets or sets whether tab-focus is enabled for the canvas (assuming that the canvas is not created with the 'no-focus style for canvas%). When tab-focus is enabled, the canvas can receive the keyboard focus when the user navigates among a frame or dialog’s controls with the Tab and arrow keys. By default, tab-focus is disabled.

When tab-focus is enabled for a canvas% object, Tab, arrow, Enter, and Escape keyboard events are consumed by a frame’s default on-traverse-char method. (In addition, a dialog’s default method consumes Escape key events.) Otherwise, on-traverse-char allows the keyboard events to be propagated to the canvas.

For an editor-canvas% object, handling of Tab, arrow, Enter, and Escape keyboard events is determined by the allow-tab-exit method.

( send a-canvas get-canvas-background)
→ ( or/c ( is-a?/c color%) false/c)

Returns the color currently used to “erase” the canvas content before on-paint is called. See also set-canvas-background.

The result is #f if the canvas was created with the 'transparent style, otherwise it is always a color% object.

( send a-canvas get-dc) → ( is-a?/c dc<%>)

Gets the canvas’s device context. See dc<%> for more information about drawing.

( send a-canvas min-client-height) → ( integer-in 0 10000)
( send a-canvas min-client-height h) → void?
h : ( integer-in 0 10000)

Gets or sets the canvas’s minimum height for geometry management, based on the client size rather than the full size. The client height is obtained or changed via min-height in area<%>, adding or subtracting border and scrollbar sizes as appropriate.

The minimum height is ignored when it is smaller than the canvas’s graphical minimum height. See Geometry Management for more information.

( send a-canvas min-client-width) → ( integer-in 0 10000)
( send a-canvas min-client-width w) → void?
w : ( integer-in 0 10000)

Gets or sets the canvas’s minimum width for geometry management, based on the canvas’s client size rather than its full size. The client width is obtained or changed via min-width in area<%>, adding or subtracting border and scrollbar sizes as appropriate.

The minimum width is ignored when it is smaller than the canvas’s graphical minimum width. See Geometry Management for more information.

( send a-canvas on-char ch) → void?
ch : ( is-a?/c key-event%)

Specification: Called when the canvas receives a keyboard event. See also Mouse and Keyboard Events.

Default implementation: Does nothing.

( send a-canvas on-event event) → void?
event : ( is-a?/c mouse-event%)

Specification: Called when the canvas receives a mouse event. See also Mouse and Keyboard Events, noting in particular that certain mouse events can get dropped.

Default implementation: Does nothing.

( send a-canvas on-paint) → void?

Specification: Called when the canvas is exposed or resized so that the image in the canvas can be repainted.

When on-paint is called in response to a system expose event and only a portion of the canvas is newly exposed, any drawing operations performed by on-paint are clipped to the newly-exposed region; however, the clipping region as reported by get-clipping-region does not change.

Default implementation: Does nothing.

( send a-canvas on-tab-in) → void?

Specification: Called when the keyboard focus enters the canvas via keyboard navigation events. The on-focus method is also called, as usual for a focus change. When the keyboard focus leaves a canvas due to a navigation event, only on-focus is called.

See also accept-tab-focus and on-traverse-char in top-level-window<%> .

Default implementation: Does nothing.

( send a-canvas set-canvas-background color) → void?
color : ( is-a?/c color%)

Sets the color used to “erase” the canvas content before on-paint is called. (This color is typically associated with the canvas at a low level, so that it is used even when a complete refresh of the canvas is delayed by other activity.)

If the canvas was created with the 'transparent style, an exn:fail:contract exception is raised.

( send a-canvas set-resize-corner on?) → void?
on? : any/c

Under Mac OS X, enables or disables space for a resize tab at the canvas’s lower-right corner when only one scrollbar is visible. This method has no effect under Windows or X, and it has no effect when both or no scrollbars are visible. The resize corner is disabled by default, but it can be enabled when a canvas is created with the 'resize-corner style.

( send a-canvas warp-pointer x y) → void?
x : ( integer-in 0 10000)
y : ( integer-in 0 10000)

Moves the cursor to the given location on the canvas.
top← prev up next →