};
+DocStr(wxDataFormat,
+"A wx.DataFormat 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. A data format is is used to uniquely
+identify this format.",
+"
+On the system level, a data format is usually just a number, (which
+may be the CLIPFORMAT under Windows or Atom under X11, for example.)
+
+The standard format IDs are:
+
+ ================ =====================================
+ wx.DF_INVALID An invalid format
+ wx.DF_TEXT Text format
+ wx.DF_BITMAP A bitmap (wx.Bitmap)
+ wx.DF_METAFILE A metafile (wx.Metafile, Windows only)
+ wx.DF_FILENAME A list of filenames
+ wx.DF_HTML An HTML string. This is only valid on
+ Windows and non-unicode builds
+ ================ =====================================
+
+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.
+
+");
+
class wxDataFormat {
public:
- wxDataFormat( wxDataFormatId type );
- %name(CustomDataFormat) wxDataFormat(const wxString& format);
+ DocCtorStr(
+ wxDataFormat( wxDataFormatId type ),
+ "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)", "");
+
+ DocCtorStrName(
+ wxDataFormat(const wxString& format),
+ "Constructs a data format object for a custom format identified by its
+name.", "",
+ CustomDataFormat);
~wxDataFormat();
+
%nokwargs operator==;
%nokwargs operator!=;
bool operator==(wxDataFormatId format) const;
bool operator==(const wxDataFormat& format) const;
bool operator!=(const wxDataFormat& format) const;
- void SetType(wxDataFormatId format);
- wxDataFormatId GetType() const;
+
+ DocDeclStr(
+ void , SetType(wxDataFormatId format),
+ "Sets the format to the given value, which should be one of wx.DF_XXX
+constants.", "");
+
+ DocDeclStr(
+ wxDataFormatId , GetType() const,
+ "Returns the platform-specific number identifying the format.", "");
+
- wxString GetId() const;
- void SetId(const wxString& format);
+ DocDeclStr(
+ wxString , GetId() const,
+ "Returns the name of a custom format (this function will fail for a
+standard format).", "");
+
+ DocDeclStr(
+ void , SetId(const wxString& format),
+ "Sets the format to be the custom format identified by the given name.", "");
};
// get the number of formats we support
virtual size_t GetFormatCount(Direction dir = Get) const;
- // returns TRUE if this format is supported
+ // returns True if this format is supported
bool IsSupported(const wxDataFormat& format, Direction dir = Get) const;
// get the (total) size of data for the given format
Direction dir = Get) const;
// copy raw data (in the specified format) to the provided buffer, return
- // TRUE if data copied successfully, FALSE otherwise
+ // True if data copied successfully, False otherwise
virtual bool GetDataHere(const wxDataFormat& format, void *buf) const;
// get data from the buffer of specified length (in the given format),
- // return TRUE if the data was read successfully, FALSE otherwise
+ // return True if the data was read successfully, False otherwise
virtual bool SetData(const wxDataFormat& format,
size_t len, const void * buf);
};
// wxDataObjectSimple is a wxDataObject which only supports one format (in
-// both Get and Set directions, but you may return FALSE from GetDataHere() or
+// both Get and Set directions, but you may return False from GetDataHere() or
// SetData() if one of them is not supported). This is the simplest possible
// wxDataObject implementation.
//
// return either a string or None and then act appropriately with the
// C++ version.
- bool rval = FALSE;
- wxPyBeginBlockThreads();
+ bool rval = False;
+ bool blocked = wxPyBeginBlockThreads();
if (wxPyCBH_findCallback(m_myInst, "GetDataHere")) {
PyObject* ro;
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
Py_DECREF(ro);
}
}
- wxPyEndBlockThreads();
+ wxPyEndBlockThreads(blocked);
return rval;
}
bool wxPyDataObjectSimple::SetData(size_t len, const void *buf) const{
// For this one we simply need to make a string from buf and len
// and send it to the Python method.
- bool rval = FALSE;
- wxPyBeginBlockThreads();
+ bool rval = False;
+ bool blocked = wxPyBeginBlockThreads();
if (wxPyCBH_findCallback(m_myInst, "SetData")) {
PyObject* data = PyString_FromStringAndSize((char*)buf, len);
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", data));
Py_DECREF(data);
}
- wxPyEndBlockThreads();
+ wxPyEndBlockThreads(blocked);
return rval;
}
%}
// Now define it for SWIG
class wxPyDataObjectSimple : public wxDataObjectSimple {
public:
- %addtofunc wxPyDataObjectSimple "self._setCallbackInfo(self, PyDataObjectSimple)"
+ %pythonAppend wxPyDataObjectSimple "self._setCallbackInfo(self, PyDataObjectSimple)"
wxPyDataObjectSimple(const wxDataFormat& format = wxFormatInvalid);
void _setCallbackInfo(PyObject* self, PyObject* _class);
public:
wxDataObjectComposite();
- %addtofunc Add "args[1].thisown = 0"
- void Add(wxDataObjectSimple *dataObject, int preferred = FALSE);
+ %apply SWIGTYPE *DISOWN { wxDataObjectSimple *dataObject };
+ void Add(wxDataObjectSimple *dataObject, int preferred = False);
+ %clear wxDataObjectSimple *dataObject;
};
//---------------------------------------------------------------------------
// Now define it for SWIG
class wxPyTextDataObject : public wxTextDataObject {
public:
- %addtofunc wxPyTextDataObject "self._setCallbackInfo(self, PyTextDataObject)"
+ %pythonAppend wxPyTextDataObject "self._setCallbackInfo(self, PyTextDataObject)"
wxPyTextDataObject(const wxString& text = wxPyEmptyString);
void _setCallbackInfo(PyObject* self, PyObject* _class);
wxBitmap wxPyBitmapDataObject::GetBitmap() const {
wxBitmap* rval = &wxNullBitmap;
- wxPyBeginBlockThreads();
+ bool blocked = wxPyBeginBlockThreads();
if (wxPyCBH_findCallback(m_myInst, "GetBitmap")) {
PyObject* ro;
wxBitmap* ptr;
Py_DECREF(ro);
}
}
- wxPyEndBlockThreads();
+ wxPyEndBlockThreads(blocked);
return *rval;
}
void wxPyBitmapDataObject::SetBitmap(const wxBitmap& bitmap) {
- wxPyBeginBlockThreads();
+ bool blocked = wxPyBeginBlockThreads();
if (wxPyCBH_findCallback(m_myInst, "SetBitmap")) {
- PyObject* bo = wxPyConstructObject((void*)&bitmap, wxT("wxBitmap"), false);
+ PyObject* bo = wxPyConstructObject((void*)&bitmap, wxT("wxBitmap"), False);
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", bo));
Py_DECREF(bo);
}
- wxPyEndBlockThreads();
+ wxPyEndBlockThreads(blocked);
}
%}
// Now define it for SWIG
class wxPyBitmapDataObject : public wxBitmapDataObject {
public:
- %addtofunc wxPyBitmapDataObject "self._setCallbackInfo(self, PyBitmapDataObject)"
+ %pythonAppend wxPyBitmapDataObject "self._setCallbackInfo(self, PyBitmapDataObject)"
wxPyBitmapDataObject(const wxBitmap& bitmap = wxNullBitmap);
void _setCallbackInfo(PyObject* self, PyObject* _class);
wxFileDataObject();
const wxArrayString& GetFilenames();
-#ifdef __WXMSW__
void AddFile(const wxString &filename);
-#endif
};
else {
// raise a TypeError if not a string
PyErr_SetString(PyExc_TypeError, "String expected.");
- return FALSE;
+ return False;
}
}
}
//---------------------------------------------------------------------------
-#ifndef __WXGTK__
+#if defined(__WXMSW__) || defined(__WXMAC__)
%{
#include <wx/metafile.h>
class wxMetafileDataObject : public wxDataObjectSimple
{
public:
- wxMetafileDataObject() { PyErr_SetNone(PyExc_NotImplementedError); }
+ wxMetafileDataObject() { wxPyRaiseNotImplemented(); }
};
%}