Contents Up Previous Next

Canvas

A subwindow used for drawing arbitrary graphics. It must be the child of a frame.

The following callbacks are valid for the canvas class.

OnChar
The function is called with the canvas identifier, key code, and key event identifier. If the event is an ASCII keypress, the code will correspond to the ASCII code; otherwise, the programmer must refer to the constants defined in common.h, in the wxWindows library. See also Key event.
OnEvent
Called with a canvas identifier and a mouse event identifier.
OnScroll
Called with a canvas identifier and a command event identifier.
OnPaint
Called with a canvas identifier when the canvas receives a repaint event from the window manager.
OnSize
The function is called with the window identifier, width and height.

See also window-add-callback.

canvas-create
canvas-get-dc
canvas-get-scroll-page-x
canvas-get-scroll-page-y
canvas-get-scroll-pos-x
canvas-get-scroll-pos-y
canvas-get-scroll-range-x
canvas-get-scroll-range-y
canvas-get-scroll-pixels-per-unit-x
canvas-get-scroll-pixels-per-unit-x
canvas-on-char
canvas-on-scroll
canvas-set-scrollbars
canvas-set-scroll-page-x
canvas-set-scroll-page-y
canvas-set-scroll-pos-x
canvas-set-scroll-pos-y
canvas-set-scroll-range-x
canvas-set-scroll-range-y
canvas-scroll
canvas-view-start-x
canvas-view-start-y


canvas-create

long ( canvas-create long parent-id optional long x optional long y
optional long width optional long height optional string style="wxRETAINED'' optional string name)

Creates a canvas for drawing graphics on. parent-id must be a valid frame ID.

The value of style can be a bit list of the following values:

wxBORDER Gives the canvas a thin border (Windows 3 and Motif only).
wxRETAINED Gives the canvas a wxWindows-implemented backing store, making repainting much faster but at a potentially costly memory premium (XView and Motif only).
wxBACKINGSTORE Gives the canvas an X-implemented backing store (XView and Motif only). The X server may choose to ignore this request, whereas wxRETAINED is always implemented under X.

name gives the canvas a name that can be retrieved with window-get-name.


canvas-get-dc

long ( canvas-get-dc long canvas-id)

Return the device context handle belonging to the canvas. The device context must be retrieved before anything can be drawn on the canvas. If your drawing function is parameterized by a device context, you will be able to pass other types of device context to your drawing routine, such as PostScript and Windows metafile device contexts.


canvas-get-scroll-page-x

long ( canvas-get-scroll-page-x long canvas-id)

Gets the number of lines per horizontal scroll page.


canvas-get-scroll-page-y

long ( canvas-get-scroll-page-y long canvas-id)

Gets the number of lines per vertical scroll page.


canvas-get-scroll-pos-x

long ( canvas-get-scroll-pos-x long canvas-id)

Gets the horizontal scroll position in scroll units.


canvas-get-scroll-pos-y

long ( canvas-get-scroll-pos-y long canvas-id)

Gets the vertical scroll position in scroll units.


canvas-get-scroll-range-x

long ( canvas-get-scroll-range-x long canvas-id)

Gets the number of horizontal scroll positions.


canvas-get-scroll-range-y

long ( canvas-get-scroll-range-y long canvas-id)

Gets the number of vertical scroll positions.


canvas-get-scroll-pixels-per-unit-x

long ( canvas-get-scroll-pixels-per-unit-x long canvas-id)

Gets the number of pixels per horizontal scroll unit, as set in canvas-set-scrollbars.


canvas-get-scroll-pixels-per-unit-x

long ( canvas-get-scroll-pixels-per-unit-y long canvas-id)

Gets the number of pixels per vertical scroll unit, as set in canvas-set-scrollbars.


canvas-on-char

long ( canvas-on-char long panel-id long event-id)

The default implementation of the OnChar callback. Call this to pass intercepted characters through to the canvas.


canvas-on-scroll

long ( canvas-on-scroll long panel-id long event-id)

The default implementation of the OnScroll callback.


canvas-set-scrollbars

long ( canvas-set-scrollbars long canvas-id long x-unit-size long y-unit-size
long x-length long y-length long x-page-length long y-page-length)

Set the scrollbars for the given canvas. The first argument pair specifies the number of pixels per logical scroll unit, that is, the number of pixels to scroll when a scroll arrow is clicked. If either is zero or less, that scrollbar will not appear. The second pair specifies the size of the virtual canvas in logical scroll units. The third pair of arguments specify the number of scroll units per page, that is, the amount to scroll by when the scrollbar is page-scrolled (usually by clicking either side of the scrollbar handle).


canvas-set-scroll-page-x

void ( canvas-set-scroll-page-x long canvas-id long value)

Sets the number of lines per horizontal scroll page.


canvas-set-scroll-page-y

void ( canvas-set-scroll-page-y long canvas-id long value)

Sets the number of lines per vertical scroll page.


canvas-set-scroll-pos-x

void ( canvas-set-scroll-pos-x long canvas-id long value)

Sets the horizontal scroll position.


canvas-set-scroll-pos-y

void ( canvas-set-scroll-pos-y long canvas-id long value)

Sets the vertical scroll position.


canvas-set-scroll-range-x

void ( canvas-set-scroll-range-x long canvas-id long value)

Sets the number of positions on the horizontal scrollbar.


canvas-set-scroll-range-y

void ( canvas-set-scroll-range-y long canvas-id long value)

Sets the number of positions on the vertical scrollbar.


canvas-scroll

long ( canvas-scroll long canvas-id long x-position long y-position)

Scroll the canvas programmatically to the given scroll position. To convert from pixel position to scroll position, divide the pixel position by the scroll unit size you passed to canvas-set-scrollbars.


canvas-view-start-x

long ( canvas-view-start-x long canvas-id)

Returns the first visible horizontal scroll position. Note this is in scroll units, not pixel, so to convert to pixel position you need to multiply this value by the result of canvas-get-scroll-pixels-per-unit-x.


canvas-view-start-y

long ( canvas-view-start-y long canvas-id)

Returns the first visible vertical scroll position. Note this is in scroll units, not pixel, so to convert to pixel position you need to multiply this value by the result of canvas-get-scroll-pixels-per-unit-y.