wxWidgets: wxDataFormat Class Reference

| Version: 3.1.5

Loading...
Searching...
No Matches
Public Member Functions | List of all members
wxDataFormat Class Reference
Class List by Category » Clipboard and Drag & Drop

`#include </cygdrive/c/Users/Hamis/Cygwin-packaging/wxWidgets3.1/wxWidgets3.1-3.1.5-3.x86_64/src/wxWidgets-3.1.5/interface/wx/dataobj.h>`

## Detailed Description

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 currently only valid on Mac and MSW.
wxDF_PNG | A PNG file. This is valid only on MSW. This constant is available since wxWidgets 3.1.5.

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!

##

Library: wxCore

<>< =''>:</>&;&;< =''>\ </></>

See also
  Drag and Drop Overview, page_samples_dnd, wxDataObject

## Public Member Functions
| wxDataFormat (wxDataFormatId 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).
| wxDataFormat (const wxString &format)
| Constructs a data format object for a custom format identified by its name format.
wxString | GetId () const
| Returns the name of a custom format (this function will fail for a standard format).
wxDataFormatId | GetType () const
| Returns the platform-specific number identifying the format.
void | SetId (const wxString &format)
| Sets the format to be the custom format identified by the given name.
void | SetType (wxDataFormatId type)
| Sets the format to the given value, which should be one of wxDF_XXX constants.
bool | operator!= (const wxDataFormat &format) const
| Returns true if the formats are different.
bool | operator!= (wxDataFormatId format) const
| Returns true if the formats are different.
bool | operator== (const wxDataFormat &format) const
| Returns true if the formats are equal.
bool | operator== (wxDataFormatId format) const
| Returns true if the formats are equal.

## Constructor & Destructor Documentation

## ◆ wxDataFormat() [1/2]

wxDataFormat::wxDataFormat | ( | wxDataFormatId | 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 use Wx::Bitmap->newNative(format).

## ◆ wxDataFormat() [2/2]

wxDataFormat::wxDataFormat | ( | const wxString & | format | ) |

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

wxPerl Note: In wxPerl use Wx::Bitmap->newUser(format).

## Member Function Documentation

## ◆ GetId()

wxString wxDataFormat::GetId | ( |  | ) | const

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

## ◆ GetType()

wxDataFormatId wxDataFormat::GetType | ( |  | ) | const

Returns the platform-specific number identifying the format.

## ◆ operator!=() [1/2]

bool wxDataFormat::operator!= | ( | const wxDataFormat & | format | ) | const

Returns true if the formats are different.

## ◆ operator!=() [2/2]

bool wxDataFormat::operator!= | ( | wxDataFormatId | format | ) | const

Returns true if the formats are different.

## ◆ operator==() [1/2]

bool wxDataFormat::operator== | ( | const wxDataFormat & | format | ) | const

Returns true if the formats are equal.

## ◆ operator==() [2/2]

bool wxDataFormat::operator== | ( | wxDataFormatId | format | ) | const

Returns true if the formats are equal.

## ◆ SetId()

void wxDataFormat::SetId | ( | const wxString & | format | ) |

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

## ◆ SetType()

void wxDataFormat::SetType | ( | wxDataFormatId | type | ) |

Sets the format to the given value, which should be one of wxDF_XXX constants.