contents up previous next

wxdataformat

a wxdataformat is an encapsulation of a platform-specific format handle which is used by the system for the clipboard and drag and drop operations. the applications are usually only interested in, for example, pasting data from the clipboard only if the data is in a format the program understands and a data format is something which uniquely identifies this format.

on the system level, a data format is usually just a number (clipformat under windows or atom under x11, for example) and the standard formats are, indeed, just numbers which can be implicitly converted to wxdataformat. the standard formats are:

wxdf_invalid an invalid format - used as default argument for functions taking a wxdataformat argument sometimes
wxdf_text text format (wxstring)
wxdf_bitmap a bitmap (wxbitmap)
wxdf_metafile a metafile (wxmetafile, windows only)
wxdf_filename a list of filenames
wxdf_html an html string. this is only valid when passed to wxsetclipboarddata when compiled with visual c++ in non-unicode mode

as mentioned above, these standard formats may be passed to any function taking wxdataformat argument because wxdataformat has an implicit conversion from them (or, to be precise from the type wxdataformat::nativeformat which is the type used by the underlying platform for data formats).

aside the standard formats, the application may also use custom formats which are identified by their names (strings) and not numeric identifiers. although internally custom format must be created (or registered) first, you shouldn't care about it because it is done automatically the first time the wxdataformat object corresponding to a given format name is created. the only implication of this is that you should avoid having global wxdataformat objects with non-default constructor because their constructors are executed before the program has time to perform all necessary initialisations and so an attempt to do clipboard format registration at this time will usually lead to a crash!

virtual functions to override

none

derived from

none

see also

clipboard and drag and drop overview, dnd sample, wxdataobject

include files

<wx/dataobj.h>

members

wxdataformat::wxdataformat
wxdataformat::wxdataformat
wxdataformat::operator ==
wxdataformat::operator !=
wxdataformat::getid
wxdataformat::gettype
wxdataformat::setid
wxdataformat::settype


wxdataformat::wxdataformat

wxdataformat(nativeformat format = wxdf_invalid)

constructs a data format object for one of the standard data formats or an empty data object (use settype or setid later in this case)

wxperl note: in wxperl this function is named newnative.


wxdataformat::wxdataformat

wxdataformat(const wxchar *format)

constructs a data format object for a custom format identified by its name format.

wxperl note: in wxperl this function is named newuser.


wxdataformat::operator ==

bool operator ==(const wxdataformat& format) const

returns true if the formats are equal.


wxdataformat::operator !=

bool operator !=(const wxdataformat& format) const

returns true if the formats are different.


wxdataformat::getid

wxstring getid() const

returns the name of a custom format (this function will fail for a standard format).


wxdataformat::gettype

nativeformat gettype() const

returns the platform-specific number identifying the format.


wxdataformat::setid

void setid(const wxchar *format)

sets the format to be the custom format identified by the given name.


wxdataformat::settype

void settype(nativeformat format)

sets the format to the given value, which should be one of wxdf_xxx constants.