18.3 Clipboard Data Formats
As discussed in the introduction, the clipboard can contain data in arbitrary formats. While the most commonly used
format is text, other formats include integers, pixmaps, and arbitrary data structures. Since all applications on the
desktop have access to the clipboard, any of them may register a new format and place items of that type on the
clipboard.
When registering a new format, you must also register a corresponding format name and the format length in bits (8,
16, and 32). Determining the type of data on the clipboard is much easier when there is a descriptive name associated
with it. The length allows applications to send and receive data without suffering from byte−swapping problems due
to differing computer architectures.
To register a new format, use XmClipboardRegisterFormat(), which takes the following form:
int
XmClipboardRegisterFormat(display, format_name, format_length)
Display *display;
char *format_name;
unsigned long format_length;
The function may return ClipboardBadFormat if the format name is NULL or the format length is other than 8,
16, or 32. The format length may be specified as 0, in which case Motif will attempt to look up the default length for
the given name. shows the format lengths for some predefined format names.
tab(@), linesize(2); l | l lfCW | nfCW . Format Name@Format Length
_
"TARGETS"@32 "MULTIPLE"@32 "TIMESTAMP"@32 "STRING"@8 "LIST_LENGTH"@32 "PIXMAP"@32
"DRAWABLE"@32 "BITMAP"@32 "FOREGROUND"@32 "BACKGROUND"@32 "COLORMAP"@32 ...