{"size": 2937, "ext": "scrbl", "max_stars_repo_path": "gui-doc/scribblings/gui/snip-class-class.scrbl", "max_stars_repo_name": "jjsimpso/gui", "max_stars_repo_stars_event_min_datetime": "2015-03-17T22:11:52.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-12T15:09:34.000Z", "max_issues_repo_path": "gui-doc/scribblings/gui/snip-class-class.scrbl", "max_issues_repo_name": "jjsimpso/gui", "max_issues_repo_issues_event_min_datetime": "2015-01-09T15:53:25.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T16:21:29.000Z", "max_forks_repo_path": "gui-doc/scribblings/gui/snip-class-class.scrbl", "max_forks_repo_name": "jjsimpso/gui", "max_forks_repo_forks_event_min_datetime": "2015-01-08T13:03:07.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-26T21:49:09.000Z"}
{"max_stars_count": 65, "max_issues_count": 231, "max_forks_count": 89, "avg_line_length": 23.125984252, "max_line_length": 72, "alphanum_fraction": 0.7065032346}
#lang scribble/doc
@(require "common.rkt")

@defclass/title[snip-class% object% ()]{

Useful snip classes are defined by instantiating derived subclasses of
 @racket[snip-class%]. A class derived from @racket[snip-class%]
 serves as a kind of ``meta-class'' for snips; each snip is associated
 with an instance of @racket[snip-class%] as its snip class.
 See @secref["snip-example"] for more information about deriving a new
  snip class.


@defconstructor[()]{

Creates a (useless) snip class.

}

@defmethod[(get-classname)
           string?]{

Returns the class's name, a string uniquely designating this snip
 class. For example, the standard text snip classname is
 @racket["wxtext"]. Names beginning with @litchar{wx} are reserved.

A snip class name should usually have the form @racket["((lib ...)
(lib ...))"]  to enable on-demand loading of the class. See
@|snipclassdiscuss| for details.

}

@defmethod[(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.

}

@defmethod[(read [f (is-a?/c editor-stream-in%)])
           (or/c (is-a?/c snip%) #f)]{

@methspec{

Reads a snip from a given stream, returning a newly created snip as
 the result or @racket[#f] if there is an error.

}
@methimpl{

Returns @racket[#f].

}}

@defmethod[(read-header [f (is-a?/c editor-stream-in%)])
           boolean?]{

@methspec{

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 @racket[#f] if a read error occurs or anything else
 otherwise.

See also @method[snip-class% write-header].

}
@methimpl{

Returns @racket[#t].

}}


@defmethod[(reading-version [stream (is-a?/c editor-stream-in%)])
           exact-integer?]{

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

}


@defmethod[(set-classname [name string?])
           void?]{

Sets the class's name. See also @method[snip-class% get-classname].

}


@defmethod[(set-version [v exact-integer?])
           void?]{

Sets the version of this class. See @method[snip-class% get-version].

}

@defmethod[(write-header [stream (is-a?/c editor-stream-out%)])
           boolean?]{

@methspec{

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, @method[snip-class% read-header] will
 only be called if @method[snip-class% write-header] writes some data
 to the stream.

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

}
@methimpl{

Returns @racket[#t].

}}
}
