(new canvas% [parent parent] [ [style style] [paint-callback paint-callback] [label label] [gl-config gl-config] [enabled enabled] [vert-margin vert-margin] [horiz-margin horiz-margin] [min-width min-width] [min-height min-height] [stretchable-width stretchable-width] [stretchable-height stretchable-height]]) → (is-a?/c canvas%)
parent :
(or/c (is-a?/c frame%) (is-a?/c dialog%) (is-a?/c panel%) (is-a?/c pane%))
style :
(listof (one-of/c 'border 'control-border 'combo 'vscroll 'hscroll 'resize-corner 'gl 'no-autoclear 'transparent 'no-focus 'deleted)) = null
paint-callback : ((is-a?/c canvas%) (is-a?/c dc<%>) . -> . any) = void label : (or/c label-string? false/c) = #f gl-config : (or/c (is-a?/c gl-config%) false/c) = #f enabled : any/c = #t vert-margin : (integer-in 0 1000) = 0 horiz-margin : (integer-in 0 1000) = 0 min-width : (integer-in 0 10000) = graphical-minimum-width min-height : (integer-in 0 10000) = graphical-minimum-height stretchable-width : any/c = #t stretchable-height : any/c = #t
'border —
gives the canvas a thin border 'control-border —
gives the canvas a border that is like a text-field% control 'combo —
gives the canvas a combo button that is like a combo-field% control; this style is intended for use with 'control-border and not with 'hscroll or 'vscroll 'hscroll —
enables horizontal scrolling (initially visible but inactive) 'vscroll —
enables vertical scrolling (initially visible but inactive) 'resize-corner —
leaves room for a resize control at the canvas’s bottom right when only one scrollbar is visible 'gl —
creates a canvas for OpenGL drawing instead of normal dc<%> drawing; call the get-gl-context method on the result of get-dc; this style is usually combined with 'no-autoclear 'no-autoclear —
prevents automatic erasing of the canvas by the windowing system; see canvas<%> for information on canvas refresh 'transparent —
the canvas is “erased” by the windowing system by letting its parent show through; see canvas<%> for information on window refresh and on the interaction of 'transparent and offscreen buffering; the result is undefined if this flag is combined with 'no-autoclear 'no-focus —
prevents the canvas from accepting the keyboard focus when the canvas is clicked or when the focus method is called 'deleted —
creates the canvas as initially hidden and without affecting parent’s geometry; the canvas can be made active later by calling parent’s add-child method
The 'hscroll and 'vscroll styles create a canvas with an initially inactive scrollbar. The scrollbars are activated with either init-manual-scrollbars or init-auto-scrollbars, and they can be hidden and re-shown with show-scrollbars.
The paint-callback argument is called by the default on-paint method, using the canvas and the DC returned by get-dc as the argument.
The label argument names the canvas for get-label, but it is not displayed with the canvas.
The gl-config argument determines properties of an OpenGL context for this canvas, as obtained through the canvas’s drawing context. See also get-dc and get-gl-context in dc<%>.
For information about the enabled argument, see window<%>. For information about the horiz-margin and vert-margin arguments, see subarea<%>. For information about the min-width, min-height, stretchable-width, and stretchable-height arguments, see area<%>.
(send a-canvas get-scroll-page which) → (integer-in 1 1000000) which : (one-of/c 'horizontal 'vertical)
The which argument is either 'horizontal or 'vertical, indicating whether to get the page step size of the horizontal or vertical scrollbar, respectively.
See also init-manual-scrollbars.
(send a-canvas get-scroll-pos which) → (integer-in 0 1000000) which : (one-of/c 'horizontal 'vertical)
The which argument is either 'horizontal or 'vertical, indicating that the value of the horizontal or vertical scrollbar should be returned, respectively.
See also init-manual-scrollbars.
(send a-canvas get-scroll-range which) → (integer-in 0 1000000) which : (one-of/c 'horizontal 'vertical)
The which argument is either 'horizontal or 'vertical, indicating whether to get the maximum value of the horizontal or vertical scrollbar, respectively.
See also init-manual-scrollbars.
(send a-canvas get-view-start)
→
(integer-in 0 10000) (integer-in 0 10000)
If the scrollbars are disabled or initialized as manual (see init-manual-scrollbars), the result is (values 0 0).
(send a-canvas get-virtual-size) → (value (integer-in 0 10000) (integer-in 0 10000))
(send a-canvas init-auto-scrollbars horiz-pixels vert-pixels h-value v-value) → void? horiz-pixels : (or/c (integer-in 1 1000000) false/c) vert-pixels : (or/c (integer-in 1 1000000) false/c) h-value : (real-in 0.0 1.0) v-value : (real-in 0.0 1.0)
With automatic scrollbars, the programmer specifies the desired virtual size of the canvas, and the scrollbars are automatically handled to allow the user to scroll around the virtual area. The scrollbars are not automatically hidden if they are unneeded; see show-scrollbars.
See also init-manual-scrollbars for information about manual scrollbars. The horizontal and vertical scrollbars are always either both manual or both automatic, but they are independently enabled. Automatic scrollbars can be re-initialized as manual, and vice versa.
If either horiz-pixels or vert-pixels is #f, the scrollbar is not enabled in the corresponding direction, and the canvas’s virtual size in that direction is the same as its client size.
The h-value and v-value arguments specify the initial values of the scrollbars as a fraction of the scrollbar’s range. A 0.0 value initializes the scrollbar to its left/top, while a 1.0 value initializes the scrollbar to its right/bottom.
See also on-scroll and get-virtual-size.
(send a-canvas init-manual-scrollbars h-length v-length h-page v-page h-value v-value) → void? h-length : (or/c (integer-in 0 1000000) false/c) v-length : (or/c (integer-in 0 1000000) false/c) h-page : (integer-in 1 1000000) v-page : (integer-in 1 1000000) h-value : (integer-in 0 1000000) v-value : (integer-in 0 1000000)
With manual scrollbars, the programmer is responsible for managing all details of the scrollbars, and the scrollbar state has no effect on the canvas’s virtual size. Instead, the canvas’s virtual size is the same as its client size.
See also init-auto-scrollbars for information about automatic scrollbars. The horizontal and vertical scrollbars are always either both manual or both automatic, but they are independently enabled. Automatic scrollbars can be re-initialized as manual, and vice versa.
The h-length and v-length arguments specify the length of each scrollbar in scroll steps (i.e., the maximum value of each scrollbar). If either is #f, the scrollbar is disabled in the corresponding direction.
The h-page and v-page arguments set the number of scrollbar steps in a page, i.e., the amount moved when pressing above or below the value indicator in the scrollbar control.
The h-value and v-value arguments specify the initial values of the scrollbars.
If h-value is greater than h-length or v-value is greater than v-length, an exn:fail:contract exception is raised. (The page step may be larger than the total size of a scrollbar.)
See also on-scroll and get-virtual-size.
(send a-canvas make-bitmap width height) → (is-a/c? bitmap%) width : exact-positive-integer? height : exact-positive-integer?
(send a-canvas on-scroll event) → void? event : (is-a?/c scroll-event%)
This method is called only when manual scrollbars are changed, not automatic scrollbars; for automatic scrollbars, the on-paint method is called, instead.
(send a-canvas refresh-now [ paint-proc #:flush? flush?]) → void?
paint-proc : ((is-a?/c dc<%>) . -> . any) = (lambda (dc) (send a-canvas on-paint)) flush? : any/c = #t
Before paint-proc is called, flushing is disabled for the canvas. Also, the canvas is erased, unless the canvas has the 'no-autoclear style. After paint-proc returns, flushing is enabled, and if flush? is true, then flush is called immediately.
(send a-canvas scroll h-value v-value) → void? h-value : (or/c (real-in 0.0 1.0) false/c) v-value : (or/c (real-in 0.0 1.0) false/c)
If either argument is #f, the scrollbar value is not changed in the corresponding direction.
The h-value and v-value arguments each specify a fraction of the scrollbar’s movement. A 0.0 value sets the scrollbar to its left/top, while a 1.0 value sets the scrollbar to its right/bottom. A 0.5 value sets the scrollbar to its middle. In general, if the canvas’s virtual size is v, its client size is c, and (> v c), then scrolling to p sets the view start to (floor (* p (- v c))).
See also init-auto-scrollbars and get-view-start.
(send a-canvas set-scroll-page which value) → void? which : (one-of/c 'horizontal 'vertical) value : (integer-in 1 1000000)
The which argument is either 'horizontal or 'vertical, indicating whether to set the page step size of the horizontal or vertical scrollbar, respectively.
See also init-manual-scrollbars.
(send a-canvas set-scroll-pos which value) → void? which : (one-of/c 'horizontal 'vertical) value : (integer-in 0 1000000)
The which argument is either 'horizontal or 'vertical, indicating whether to set the value of the horizontal or vertical scrollbar set, respectively.
The value of the canvas’s scrollbar can be changed by the user scrolling, and such changes do not go through this method; use on-scroll to monitor scrollbar value changes.
See also init-manual-scrollbars and scroll.
(send a-canvas set-scroll-range which value) → void? which : (one-of/c 'horizontal 'vertical) value : (integer-in 0 1000000)
The which argument is either 'horizontal or 'vertical, indicating whether to set the maximum value of the horizontal or vertical scrollbar, respectively.
See also init-manual-scrollbars.
(send a-canvas show-scrollbars show-horiz? show-vert?) → void? show-horiz? : any/c show-vert? : any/c
The horizontal scrollbar can be shown only if the canvas was created with the 'hscroll style, and the vertical scrollbar can be shown only if the canvas was created with the 'vscroll style. See also init-auto-scrollbars and init-manual-scrollbars.
(send a-canvas swap-gl-buffers) → void?
The swap-buffers method acquires a re-entrant lock, so nested calls to with-gl-context on different threads or OpenGL contexts can block or deadlock.
(send a-canvas with-gl-context thunk) → any thunk : (-> any)
The call-as-current method acquires a re-entrant lock, so nested calls to with-gl-context on different threads or OpenGL contexts can block or deadlock.