[previous] [up] [next]     [contents] [index]
Next: Global Data: Headers and Up: Encoding Snips Previous: Snip Classes

Buffer Data

While a snip belongs to a buffer, the buffer may store extra information about a snip in some specialized way. When the snip is to be encoded, this extra information needs to be put into a buffer data object so that the extra information can be encoded as well. In an editor buffer, extra information can be associated with ranges of items, as well as snips.

Just as a snip must be associated with a snip class to be decoded (see Snip Classes), a buffer data object needs a buffer data class for decoding. Every buffer data class object should be added to the global buffer data class list, wx:the-buffer-data-class-list.

To store and load information about a snip or region in a buffer:

  1. derive new classes from wx:buffer-data% and wx:buffer-data-class%.
  2. derive a new class from the wx:media-edit% or wx:media-pasteboard% class, and override the get-snip-data and set-snip-data methods and/or the get-region-data and set-region-data methods.

When deriving the new wx:buffer-data-class% class, pick a new unique name to identify the encoded data. All names beginning with ``wx'' are reserved for internal use. By tagging extra data with a unique name, the normal buffer content can be safely decoded in a buffer that does not support the extra data.



PLT