2.5.24 snip-class%

► |  | 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.5 | Editor Classes

2.5.1 | add-color<%>
2.5.2 | editor<%>
2.5.3 | editor-admin%
2.5.4 | editor-canvas%
2.5.5 | editor-data%
2.5.6 | editor-data-class%
2.5.7 | editor-data-class-list<%>
2.5.8 | editor-snip-editor-admin<%>
2.5.9 | editor-snip%
2.5.10 | editor-stream-in%
2.5.11 | editor-stream-in-base%
2.5.12 | editor-stream-in-bytes-base%
2.5.13 | editor-stream-out%
2.5.14 | editor-stream-out-base%
2.5.15 | editor-stream-out-bytes-base%
2.5.16 | editor-wordbreak-map%
2.5.17 | image-snip%
2.5.18 | keymap%
2.5.19 | mult-color<%>
2.5.20 | pasteboard%
2.5.21 | readable-snip<%>
2.5.22 | snip%
2.5.23 | snip-admin%
2.5.24 | snip-class%
2.5.25 | snip-class-list<%>
2.5.26 | string-snip%
2.5.27 | style<%>
2.5.28 | style-delta%
2.5.29 | style-list%
2.5.30 | tab-snip%
2.5.31 | text%

On this page:

get-classname
get-version
read
read-header
reading-version
set-classname
set-version
write-header

top← prev up next →

snip-class% : class?
superclass: object%

Useful snip classes are defined by instantiating derived subclasses of snip-class%. A class derived from snip-class% serves as a kind of “meta-class” for snips; each snip is associated with an instance of snip-class% as its snip class.

In deriving a new snip-class% class, override the read method. Then, for each instance of the derived class (where each instance corresponds to a single snip class):

- Set the classname using set-classname.

- Set the version using set-version.

- Install the class into the list returned by get-the-snip-class-list using the add method. Note that if the same name is inserted into the same class list multiple times, all but the first insertion is ignored.

See also Snip Classes.

( new snip-class%) → ( is-a?/c snip-class%)

Creates a (useless) snip class.

( send a-snip-class get-classname) → string?

Returns the class’s name, a string uniquely designating this snip class. For example, the standard text snip classname is "wxtext". Names beginning with wx are reserved.

A snip class name should usually have the form "((lib ...)\n(lib ...))" to enable on-demand loading of the class. See Snip Classes for details.

( send a-snip-class get-version) → exact-integer?

Returns the version of this snip class. When attempting to load a file containing a snip with the same class name but a different version, the user is warned.

( send a-snip-class read f) → ( or/c ( is-a?/c snip%) false/c)
f : ( is-a?/c editor-stream-in%)

Specification: Reads a snip from a given stream, returning a newly created snip as the result or #f if there is an error.

Default implementation: Returns #f.

( send a-snip-class read-header f) → boolean?
f : ( is-a?/c editor-stream-in%)

Specification: Called to read header information that may be useful for every snip read in this class. This method is only called once per editor read session, and only if the stream contains header information for this class.

The return value is #f if a read error occurs or anything else otherwise.

See also write-header.

Default implementation: Returns #t.

( send a-snip-class reading-version stream) → exact-integer?
stream : ( is-a?/c editor-stream-in%)

Returns the version number specified for this snip class for snips currently being read from the given stream.

( send a-snip-class set-classname name) → void?
name : string?

Sets the class’s name. See also get-classname.

( send a-snip-class set-version v) → void?
v : exact-integer?

Sets the version of this class. See get-version.

( send a-snip-class write-header stream) → boolean?
stream : ( is-a?/c editor-stream-out%)

Specification: Called to write header information that may be useful for every snip written for this class. This method is only called once per editor write session, and only if the editor contains snips in this class.

When reading the snips back in, read-header will only be called if write-header writes some data to the stream.

The return value is #f if a write error occurs or anything else otherwise.

Default implementation: Returns #t.
top← prev up next →