Windows and non-unicode builds
================ =====================================
-Aside the standard formats, the application may also use custom
+Besies 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
DocDeclStr(
void , SetId(const wxString& format),
"Sets the format to be the custom format identified by the given name.", "");
+
+ %property(Id, GetId, SetId, doc="See `GetId` and `SetId`");
+ %property(Type, GetType, SetType, doc="See `GetType` and `SetType`");
};
- // return all formats in the provided array (of size GetFormatCount())
- //virtual void GetAllFormats(wxDataFormat *formats,
- // Direction dir = Get) const;
- DocAStr(GetAllFormats,
- "GetAllFormats(self, int dir=Get) -> [formats]",
- "Returns a list of all the wx.DataFormats that this dataobject supports
-in the given direction.", "");
%extend {
+ DocAStr(GetAllFormats,
+ "GetAllFormats(self, int dir=Get) -> [formats]",
+ "Returns a list of all the wx.DataFormats that this dataobject supports
+in the given direction.", "");
PyObject* GetAllFormats(Direction dir = Get) {
size_t count = self->GetFormatCount(dir);
wxDataFormat* formats = new wxDataFormat[count];
self->GetAllFormats(formats, dir);
- bool blocked = wxPyBeginBlockThreads();
+ wxPyBlock_t blocked = wxPyBeginBlockThreads();
PyObject* list = PyList_New(count);
for (size_t i=0; i<count; i++) {
wxDataFormat* format = new wxDataFormat(formats[i]);
PyObject* obj = wxPyConstructObject((void*)format, wxT("wxDataFormat"), true);
- PyList_Append(list, obj);
- Py_DECREF(obj);
+ PyList_SET_ITEM(list, i, obj); // PyList_SET_ITEM steals a reference
}
wxPyEndBlockThreads(blocked);
delete [] formats;
// True if data copied successfully, False otherwise
// virtual bool GetDataHere(const wxDataFormat& format, void *buf) const;
- DocAStr(GetDataHere,
- "GetDataHere(self, DataFormat format) -> String",
- "Get the data bytes in the specified format, returns None on failure.
-", "
-:todo: This should use the python buffer interface isntead...");
%extend {
+ DocAStr(GetDataHere,
+ "GetDataHere(self, DataFormat format) -> String",
+ "Get the data bytes in the specified format, returns None on failure.", "
+:todo: This should use the python buffer interface isntead...");
PyObject* GetDataHere(const wxDataFormat& format) {
PyObject* rval = NULL;
size_t size = self->GetDataSize(format);
- bool blocked = wxPyBeginBlockThreads();
+ wxPyBlock_t blocked = wxPyBeginBlockThreads();
if (size) {
char* buf = new char[size];
if (self->GetDataHere(format, buf))
%extend {
bool SetData(const wxDataFormat& format, PyObject* data) {
bool rval;
- bool blocked = wxPyBeginBlockThreads();
+ wxPyBlock_t blocked = wxPyBeginBlockThreads();
if (PyString_Check(data)) {
rval = self->SetData(format, PyString_Size(data), PyString_AsString(data));
}
}
}
+ %property(AllFormats, GetAllFormats, doc="See `GetAllFormats`");
+ %property(DataHere, GetDataHere, doc="See `GetDataHere`");
+ %property(DataSize, GetDataSize, doc="See `GetDataSize`");
+ %property(FormatCount, GetFormatCount, doc="See `GetFormatCount`");
+ %property(PreferredFormat, GetPreferredFormat, doc="See `GetPreferredFormat`");
};
- DocAStr(GetDataHere,
- "GetDataHere(self) -> String",
- "Returns the data bytes from the data object as a string, returns None
+ %extend {
+ DocAStr(GetDataHere,
+ "GetDataHere(self) -> String",
+ "Returns the data bytes from the data object as a string, returns None
on failure. Must be implemented in the derived class if the object
supports rendering its data.", "");
- %extend {
PyObject* GetDataHere() {
PyObject* rval = NULL;
size_t size = self->GetDataSize();
- bool blocked = wxPyBeginBlockThreads();
+ wxPyBlock_t blocked = wxPyBeginBlockThreads();
if (size) {
char* buf = new char[size];
if (self->GetDataHere(buf))
}
- DocAStr(SetData,
- "SetData(self, String data) -> bool",
- "Copy the data value to the data object. Must be implemented in the
+ %extend {
+ DocAStr(SetData,
+ "SetData(self, String data) -> bool",
+ "Copy the data value to the data object. Must be implemented in the
derived class if the object supports setting its data.
", "");
- %extend {
bool SetData(PyObject* data) {
bool rval;
- bool blocked = wxPyBeginBlockThreads();
+ wxPyBlock_t blocked = wxPyBeginBlockThreads();
if (PyString_Check(data)) {
rval = self->SetData(PyString_Size(data), PyString_AsString(data));
}
}
}
+ %property(Format, GetFormat, SetFormat, doc="See `GetFormat` and `SetFormat`");
};
DEC_PYCALLBACK_SIZET__const(GetDataSize);
bool GetDataHere(void *buf) const;
- bool SetData(size_t len, const void *buf) const;
+ bool SetData(size_t len, const void *buf);
PYPRIVATE;
};
// C++ version.
bool rval = false;
- bool blocked = wxPyBeginBlockThreads();
+ wxPyBlock_t blocked = wxPyBeginBlockThreads();
if (wxPyCBH_findCallback(m_myInst, "GetDataHere")) {
PyObject* ro;
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
return rval;
}
-bool wxPyDataObjectSimple::SetData(size_t len, const void *buf) const{
+bool wxPyDataObjectSimple::SetData(size_t len, const void *buf) {
// For this one we simply need to make a string from buf and len
// and send it to the Python method.
bool rval = false;
- bool blocked = wxPyBeginBlockThreads();
+ wxPyBlock_t blocked = wxPyBeginBlockThreads();
if (wxPyCBH_findCallback(m_myInst, "SetData")) {
PyObject* data = PyString_FromStringAndSize((char*)buf, len);
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", data));
");
class wxPyDataObjectSimple : public wxDataObjectSimple {
public:
- %pythonAppend wxPyDataObjectSimple "self._setCallbackInfo(self, PyDataObjectSimple)"
+ %pythonAppend wxPyDataObjectSimple setCallbackInfo(PyDataObjectSimple)
wxPyDataObjectSimple(const wxDataFormat& format = wxFormatInvalid);
void _setCallbackInfo(PyObject* self, PyObject* _class);
public:
wxDataObjectComposite();
- %apply SWIGTYPE *DISOWN { wxDataObjectSimple *dataObject };
+ %disownarg( wxDataObjectSimple *dataObject );
DocDeclStr(
void , Add(wxDataObjectSimple *dataObject, bool preferred = false),
"Adds the dataObject to the list of supported objects and it becomes
the preferred object if preferred is True.", "");
- %clear wxDataObjectSimple *dataObject;
+ %cleardisown( wxDataObjectSimple *dataObject );
+
+ DocDeclStr(
+ wxDataFormat , GetReceivedFormat() const,
+ "Report the format passed to the `SetData` method. This should be the
+format of the data object within the composite that recieved data from
+the clipboard or the DnD operation. You can use this method to find
+out what kind of data object was recieved.", "");
+
+ %property(ReceivedFormat, GetReceivedFormat, doc="See `GetReceivedFormat`");
};
//---------------------------------------------------------------------------
fly you may wish to override this function (via
`wx.PyTextDataObject`.)", "");
+ %property(Text, GetText, SetText, doc="See `GetText` and `SetText`");
+ %property(TextLength, GetTextLength, doc="See `GetTextLength`");
};
class wxPyTextDataObject : public wxTextDataObject {
public:
- %pythonAppend wxPyTextDataObject "self._setCallbackInfo(self, PyTextDataObject)"
+ %pythonAppend wxPyTextDataObject setCallbackInfo(PyTextDataObject)
wxPyTextDataObject(const wxString& text = wxPyEmptyString);
void _setCallbackInfo(PyObject* self, PyObject* _class);
when the data object receives data. Usually there will be no reason to
override this function.", "");
+ %property(Bitmap, GetBitmap, SetBitmap, doc="See `GetBitmap` and `SetBitmap`");
};
wxBitmap wxPyBitmapDataObject::GetBitmap() const {
wxBitmap* rval = &wxNullBitmap;
- bool blocked = wxPyBeginBlockThreads();
+ wxPyBlock_t blocked = wxPyBeginBlockThreads();
if (wxPyCBH_findCallback(m_myInst, "GetBitmap")) {
PyObject* ro;
wxBitmap* ptr;
}
void wxPyBitmapDataObject::SetBitmap(const wxBitmap& bitmap) {
- bool blocked = wxPyBeginBlockThreads();
+ wxPyBlock_t blocked = wxPyBeginBlockThreads();
if (wxPyCBH_findCallback(m_myInst, "SetBitmap")) {
PyObject* bo = wxPyConstructObject((void*)&bitmap, wxT("wxBitmap"), false);
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", bo));
class wxPyBitmapDataObject : public wxBitmapDataObject {
public:
- %pythonAppend wxPyBitmapDataObject "self._setCallbackInfo(self, PyBitmapDataObject)"
+ %pythonAppend wxPyBitmapDataObject setCallbackInfo(PyBitmapDataObject)
wxPyBitmapDataObject(const wxBitmap& bitmap = wxNullBitmap);
void _setCallbackInfo(PyObject* self, PyObject* _class);
absolute file names, but internally it uses the same format as
Explorer and other compatible programs under Windows or GNOME/KDE
filemanager under Unix which makes it possible to receive files from
-them using this class.
-
-:Warning: Under all non-Windows platforms this class is currently
- \"input-only\", i.e. you can receive the files from another
- application, but copying (or dragging) file(s) from a wxWidgets
- application is not currently supported.
-", "");
+them using this class.", "");
class wxFileDataObject : public wxDataObjectSimple
{
void , AddFile(const wxString &filename),
"Adds a file to the list of files represented by this data object.", "");
+ %property(Filenames, GetFilenames, doc="See `GetFilenames`");
};
//---------------------------------------------------------------------------
class wxCustomDataObject : public wxDataObjectSimple {
public:
- wxCustomDataObject(const wxDataFormat& format = wxFormatInvalid);
-
+ %nokwargs wxCustomDataObject;
+ wxCustomDataObject(const wxDataFormat& format);
+ %extend {
+ wxCustomDataObject(const wxString& formatName) {
+ return new wxCustomDataObject(wxDataFormat(formatName));
+ }
+ }
+ wxCustomDataObject();
+
- DocAStr(SetData,
- "SetData(self, String data) -> bool",
- "Copy the data value to the data object.", "");
%extend {
+ DocAStr(SetData,
+ "SetData(self, String data) -> bool",
+ "Copy the data value to the data object.", "");
bool SetData(PyObject* data) {
bool rval;
- bool blocked = wxPyBeginBlockThreads();
+ wxPyBlock_t blocked = wxPyBeginBlockThreads();
if (PyString_Check(data)) {
rval = self->SetData(PyString_Size(data), PyString_AsString(data));
}
"Get the size of the data.", "");
- DocAStr(GetData,
- "GetData(self) -> String",
- "Returns the data bytes from the data object as a string.", "");
%extend {
+ DocAStr(GetData,
+ "GetData(self) -> String",
+ "Returns the data bytes from the data object as a string.", "");
PyObject* GetData() {
PyObject* obj;
- bool blocked = wxPyBeginBlockThreads();
+ wxPyBlock_t blocked = wxPyBeginBlockThreads();
obj = PyString_FromStringAndSize((char*)self->GetData(), self->GetSize());
wxPyEndBlockThreads(blocked);
return obj;
}
}
+
+ %property(Data, GetData, SetData, doc="See `GetData` and `SetData`");
+ %property(Size, GetSize, doc="See `GetSize`");
+
};
DocStr(wxURLDataObject,
"This data object holds a URL in a format that is compatible with some
browsers such that it is able to be dragged to or from them.", "");
-class wxURLDataObject : public wxDataObjectComposite {
+class wxURLDataObject : public wxDataObject/*Composite*/ {
public:
- wxURLDataObject();
+ wxURLDataObject(const wxString& url = wxPyEmptyString);
DocDeclStr(
wxString , GetURL(),
void , SetURL(const wxString& url),
"Set the URL.", "");
+ %property(URL, GetURL, SetURL, doc="See `GetURL` and `SetURL`");
};
//---------------------------------------------------------------------------