|
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 get-canvas-background) |
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.
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.
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.
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.
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.
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 in canvas% and on-traverse-char in top-level-window<%> .
Default implementation: Does nothing.
(send a-canvas set-canvas-background color) → void? |
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.