Merged modifications from the 2.6 branch
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36607 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -91,6 +91,7 @@
|
||||
%rename(SIZE_AUTO) wxSIZE_AUTO;
|
||||
%rename(SIZE_USE_EXISTING) wxSIZE_USE_EXISTING;
|
||||
%rename(SIZE_ALLOW_MINUS_ONE) wxSIZE_ALLOW_MINUS_ONE;
|
||||
%rename(SIZE_FORCE) wxSIZE_FORCE;
|
||||
%rename(PORTRAIT) wxPORTRAIT;
|
||||
%rename(LANDSCAPE) wxLANDSCAPE;
|
||||
%rename(PRINT_QUALITY_HIGH) wxPRINT_QUALITY_HIGH;
|
||||
@@ -99,6 +100,7 @@
|
||||
%rename(PRINT_QUALITY_DRAFT) wxPRINT_QUALITY_DRAFT;
|
||||
%rename(ID_ANY) wxID_ANY;
|
||||
%rename(ID_SEPARATOR) wxID_SEPARATOR;
|
||||
%rename(ID_NONE) wxID_NONE;
|
||||
%rename(ID_LOWEST) wxID_LOWEST;
|
||||
%rename(ID_OPEN) wxID_OPEN;
|
||||
%rename(ID_CLOSE) wxID_CLOSE;
|
||||
@@ -476,8 +478,12 @@
|
||||
%rename(MOD_NONE) wxMOD_NONE;
|
||||
%rename(MOD_ALT) wxMOD_ALT;
|
||||
%rename(MOD_CONTROL) wxMOD_CONTROL;
|
||||
%rename(MOD_ALTGR) wxMOD_ALTGR;
|
||||
%rename(MOD_SHIFT) wxMOD_SHIFT;
|
||||
%rename(MOD_META) wxMOD_META;
|
||||
%rename(MOD_WIN) wxMOD_WIN;
|
||||
%rename(MOD_CMD) wxMOD_CMD;
|
||||
%rename(MOD_ALL) wxMOD_ALL;
|
||||
%rename(UPDATE_UI_NONE) wxUPDATE_UI_NONE;
|
||||
%rename(UPDATE_UI_RECURSE) wxUPDATE_UI_RECURSE;
|
||||
%rename(UPDATE_UI_FROMIDLE) wxUPDATE_UI_FROMIDLE;
|
||||
@@ -554,6 +560,7 @@
|
||||
%rename(IMAGE_ALPHA_THRESHOLD) wxIMAGE_ALPHA_THRESHOLD;
|
||||
%rename(IMAGE_ALPHA_OPAQUE) wxIMAGE_ALPHA_OPAQUE;
|
||||
%rename(ImageHandler) wxImageHandler;
|
||||
%rename(PyImageHandler) wxPyImageHandler;
|
||||
%rename(ImageHistogram) wxImageHistogram;
|
||||
%rename(Image_RGBValue) wxImage_RGBValue;
|
||||
%rename(Image_HSVValue) wxImage_HSVValue;
|
||||
|
@@ -283,10 +283,13 @@ the ``type`` parameter.", "");
|
||||
|
||||
#ifdef __WXMSW__
|
||||
bool CopyFromCursor(const wxCursor& cursor);
|
||||
|
||||
// WXWIN_COMPATIBILITY_2_4
|
||||
#if 0
|
||||
int GetQuality();
|
||||
void SetQuality(int q);
|
||||
%pythoncode { GetQuality = wx._deprecated(GetQuality) }
|
||||
%pythoncode { SetQuality = wx._deprecated(SetQuality) }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@@ -73,6 +73,15 @@ public:
|
||||
List choices=EmptyList, long style=0, Validator validator=DefaultValidator,
|
||||
String name=ChoiceNameStr) -> bool",
|
||||
"Actually create the GUI Choice control for 2-phase creation", "");
|
||||
|
||||
DocDeclStr(
|
||||
int , GetCurrentSelection() const,
|
||||
"Unlike `GetSelection` which only returns the accepted selection value,
|
||||
i.e. the selection in the control once the user closes the dropdown
|
||||
list, this function returns the current selection. That is, while the
|
||||
dropdown list is shown, it returns the currently selected item in
|
||||
it. When it is not shown, its result is the same as for the other
|
||||
function.", "");
|
||||
|
||||
|
||||
static wxVisualAttributes
|
||||
|
@@ -142,7 +142,8 @@ normal clipboard, if primary is True.", "");
|
||||
self._instance = None
|
||||
def _checkInstance(self):
|
||||
if self._instance is None:
|
||||
self._instance = self._initfunc(*self._args, **self._kwargs)
|
||||
if wx.GetApp():
|
||||
self._instance = self._initfunc(*self._args, **self._kwargs)
|
||||
def __getattr__(self, name):
|
||||
self._checkInstance()
|
||||
return getattr(self._instance, name)
|
||||
|
@@ -166,6 +166,15 @@ the combobox text field.", "",
|
||||
GetMark);
|
||||
#endif
|
||||
|
||||
DocDeclStr(
|
||||
int , GetCurrentSelection() const,
|
||||
"Unlike `GetSelection` which only returns the accepted selection value,
|
||||
i.e. the selection in the control once the user closes the dropdown
|
||||
list, this function returns the current selection. That is, while the
|
||||
dropdown list is shown, it returns the currently selected item in
|
||||
it. When it is not shown, its result is the same as for the other
|
||||
function.", "");
|
||||
|
||||
DocDeclStr(
|
||||
bool , SetStringSelection(const wxString& string),
|
||||
"Select the item with the specifed string", "");
|
||||
|
@@ -122,6 +122,33 @@ PyObject* wxPyMakeSwigPtr(void* ptr, const wxChar* className) {
|
||||
}
|
||||
|
||||
|
||||
// Python's PyInstance_Check does not return True for instances of new-style
|
||||
// classes. This should get close enough for both new and old classes but I
|
||||
// should re-evaluate the need for doing instance checks...
|
||||
bool wxPyInstance_Check(PyObject* obj) {
|
||||
return PyObject_HasAttrString(obj, "__class__") != 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// This one checks if the object is an instance of a SWIG proxy class (it has
|
||||
// a .this attribute, and the .this attribute is a PySwigObject.)
|
||||
bool wxPySwigInstance_Check(PyObject* obj) {
|
||||
static PyObject* this_str = NULL;
|
||||
if (this_str == NULL)
|
||||
this_str = PyString_FromString("this");
|
||||
|
||||
PyObject* this_attr = PyObject_GetAttr(obj, this_str);
|
||||
if (this_attr) {
|
||||
bool retval = (PySwigObject_Check(this_attr) != 0);
|
||||
Py_DECREF(this_attr);
|
||||
return retval;
|
||||
}
|
||||
|
||||
PyErr_Clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Export a C API in a struct. Other modules will be able to load this from
|
||||
|
@@ -248,8 +248,7 @@ in the given direction.", "");
|
||||
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;
|
||||
|
@@ -586,10 +586,22 @@ public:
|
||||
wxDateTime ToTimezone(const wxDateTime::TimeZone& tz, bool noDST = false);
|
||||
wxDateTime& MakeTimezone(const wxDateTime::TimeZone& tz, bool noDST = false);
|
||||
|
||||
// transform to GMT/UTC
|
||||
wxDateTime ToGMT(bool noDST = false);
|
||||
// interpret current value as being in another timezone and transform
|
||||
// it to local one
|
||||
wxDateTime FromTimezone(const wxDateTime::TimeZone& tz, bool noDST = false) const;
|
||||
wxDateTime& MakeFromTimezone(const wxDateTime::TimeZone& tz, bool noDST = false);
|
||||
|
||||
// transform to/from GMT/UTC
|
||||
wxDateTime ToUTC(bool noDST = false) const;
|
||||
wxDateTime& MakeUTC(bool noDST = false);
|
||||
|
||||
wxDateTime ToGMT(bool noDST = false) const;
|
||||
wxDateTime& MakeGMT(bool noDST = false);
|
||||
|
||||
wxDateTime FromUTC(bool noDST = false) const;
|
||||
wxDateTime& MakeFromUTC(bool noDST = false);
|
||||
|
||||
|
||||
// is daylight savings time in effect at this moment according to the
|
||||
// rules of the specified country?
|
||||
//
|
||||
|
@@ -497,6 +497,7 @@ enum {
|
||||
wxSIZE_AUTO,
|
||||
wxSIZE_USE_EXISTING,
|
||||
wxSIZE_ALLOW_MINUS_ONE,
|
||||
wxSIZE_FORCE,
|
||||
wxPORTRAIT,
|
||||
wxLANDSCAPE,
|
||||
wxPRINT_QUALITY_HIGH,
|
||||
@@ -506,6 +507,7 @@ enum {
|
||||
|
||||
wxID_ANY,
|
||||
wxID_SEPARATOR,
|
||||
wxID_NONE,
|
||||
|
||||
wxID_LOWEST,
|
||||
wxID_OPEN,
|
||||
|
@@ -99,8 +99,16 @@ wxEventType wxNewEventType();
|
||||
%constant wxEventType wxEVT_NAVIGATION_KEY;
|
||||
%constant wxEventType wxEVT_KEY_DOWN;
|
||||
%constant wxEventType wxEVT_KEY_UP;
|
||||
|
||||
%{
|
||||
#if ! wxUSE_HOTKEY
|
||||
#define wxEVT_HOTKEY -9999
|
||||
#endif
|
||||
%}
|
||||
|
||||
%constant wxEventType wxEVT_HOTKEY;
|
||||
|
||||
|
||||
|
||||
// Set cursor event
|
||||
%constant wxEventType wxEVT_SET_CURSOR;
|
||||
|
||||
@@ -2234,8 +2242,15 @@ public:
|
||||
|
||||
|
||||
DocStr(wxWindowDestroyEvent,
|
||||
"The EVT_WINDOW_DESTROY event is sent right before the window is
|
||||
destroyed.", "");
|
||||
"The EVT_WINDOW_DESTROY event is sent from the `wx.Window` destructor
|
||||
when the GUI window is destroyed.
|
||||
|
||||
When a class derived from `wx.Window` is destroyed its destructor will
|
||||
have already run by the time this event is sent. Therefore this event
|
||||
will not usually be received at all by the window itself. Since it is
|
||||
received after the destructor has run, an object should not try to
|
||||
handle its own wx.WindowDestroyEvent, but it can be used to get
|
||||
notification of the destruction of another window.", "");
|
||||
class wxWindowDestroyEvent : public wxCommandEvent
|
||||
{
|
||||
public:
|
||||
|
@@ -345,7 +345,7 @@ public:
|
||||
|
||||
// return instance of the wxFontMapper singleton
|
||||
static wxFontMapper *Get();
|
||||
// set the sigleton to 'mapper' instance and return previous one
|
||||
// set the singleton to 'mapper' instance and return previous one
|
||||
static wxFontMapper *Set(wxFontMapper *mapper);
|
||||
|
||||
|
||||
@@ -364,10 +364,13 @@ public:
|
||||
// get the n-th supported encoding
|
||||
static wxFontEncoding GetEncoding(size_t n);
|
||||
|
||||
// return internal string identifier for the encoding (see also
|
||||
// GetEncodingDescription())
|
||||
// return canonical name of this encoding (this is a short string,
|
||||
// GetEncodingDescription() returns a longer one)
|
||||
static wxString GetEncodingName(wxFontEncoding encoding);
|
||||
|
||||
// // return a list of all names of this encoding (see GetEncodingName)
|
||||
// static const wxChar** GetAllEncodingNames(wxFontEncoding encoding);
|
||||
|
||||
// return user-readable string describing the given encoding
|
||||
//
|
||||
// NB: hard-coded now, but might change later (read it from config?)
|
||||
@@ -380,9 +383,6 @@ public:
|
||||
static wxFontEncoding GetEncodingFromName(const wxString& name);
|
||||
|
||||
|
||||
// set the config object to use (may be NULL to use default)
|
||||
void SetConfig(wxConfigBase *config);
|
||||
|
||||
// set the root config path to use (should be an absolute path)
|
||||
void SetConfigPath(const wxString& prefix);
|
||||
|
||||
|
@@ -214,7 +214,9 @@ long wxGetNumberFromUser(const wxString& message,
|
||||
long min = 0, long max = 100,
|
||||
wxWindow *parent = NULL,
|
||||
const wxPoint& pos = wxDefaultPosition);
|
||||
%pythoncode { GetNumberFromUser = wx._deprecated(GetNumberFromUser) }
|
||||
#endif
|
||||
|
||||
// GDI Functions
|
||||
|
||||
MustHaveApp(wxColourDisplay);
|
||||
|
@@ -59,6 +59,43 @@ public:
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
DocStr(wxPyImageHandler,
|
||||
"This is the base class for implementing image file loading/saving, and
|
||||
image creation from data, all written in Python. To create a custom
|
||||
image handler derive a new class from wx.PyImageHandler and provide
|
||||
the following methods::
|
||||
|
||||
def DoCanRead(self, stream) --> bool
|
||||
'''Check if this handler can read the image on the stream'''
|
||||
|
||||
def LoadFile(self, image, stream, verbose, index) --> bool
|
||||
'''Load image data from the stream and load it into image.'''
|
||||
|
||||
def SaveFile(self, image, stream, verbose) --> bool
|
||||
'''Save the iamge data in image to the stream using
|
||||
this handler's image file format.'''
|
||||
|
||||
def GetImageCount(self, stream) --> int
|
||||
'''If this image format can hold more than one image,
|
||||
how many does the image on the stream have?'''
|
||||
|
||||
To activate your handler create an instance of it and pass it to
|
||||
`wx.Image_AddHandler`. Be sure to call `SetName`, `SetType`, and
|
||||
`SetExtension` from your constructor.
|
||||
", "");
|
||||
|
||||
class wxPyImageHandler: public wxImageHandler {
|
||||
public:
|
||||
%pythonAppend wxPyImageHandler() "self._SetSelf(self)"
|
||||
wxPyImageHandler();
|
||||
void _SetSelf(PyObject *self);
|
||||
};
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class wxImageHistogram /* : public wxImageHistogramBase */
|
||||
{
|
||||
public:
|
||||
@@ -155,25 +192,41 @@ Unlike RGB data, not all images have an alpha channel and before using
|
||||
with `HasAlpha`. Note that currently only images loaded from PNG files
|
||||
with transparency information will have an alpha channel.", "");
|
||||
|
||||
|
||||
%{
|
||||
// Pull the nested class out to the top level for SWIG's sake
|
||||
#define wxImage_RGBValue wxImage::RGBValue
|
||||
#define wxImage_HSVValue wxImage::HSVValue
|
||||
%}
|
||||
|
||||
|
||||
DocStr(wxImage_RGBValue,
|
||||
"An object that contains values for red, green and blue which represent
|
||||
the value of a color. It is used by `wx.Image.HSVtoRGB` and
|
||||
`wx.Image.RGBtoHSV`, which converts between HSV color space and RGB
|
||||
color space.", "");
|
||||
class wxImage_RGBValue
|
||||
{
|
||||
public:
|
||||
wxImage_RGBValue(byte r=0, byte g=0, byte b=0);
|
||||
DocCtorStr(
|
||||
wxImage_RGBValue(byte r=0, byte g=0, byte b=0),
|
||||
"Constructor.", "");
|
||||
byte red;
|
||||
byte green;
|
||||
byte blue;
|
||||
};
|
||||
|
||||
|
||||
|
||||
DocStr(wxImage_HSVValue,
|
||||
"An object that contains values for hue, saturation and value which
|
||||
represent the value of a color. It is used by `wx.Image.HSVtoRGB` and
|
||||
`wx.Image.RGBtoHSV`, which +converts between HSV color space and RGB
|
||||
color space.", "");
|
||||
class wxImage_HSVValue
|
||||
{
|
||||
public:
|
||||
wxImage_HSVValue(double h=0.0, double s=0.0, double v=0.0);
|
||||
DocCtorStr(
|
||||
wxImage_HSVValue(double h=0.0, double s=0.0, double v=0.0),
|
||||
"Constructor.", "");
|
||||
double hue;
|
||||
double saturation;
|
||||
double value;
|
||||
@@ -919,8 +972,14 @@ MustHaveApp(ConvertToMonoBitmap);
|
||||
"Rotates the hue of each pixel of the image. Hue is a double in the
|
||||
range -1.0..1.0 where -1.0 is -360 degrees and 1.0 is 360 degrees", "");
|
||||
|
||||
static wxImage_HSVValue RGBtoHSV(wxImage_RGBValue rgb);
|
||||
static wxImage_RGBValue HSVtoRGB(wxImage_HSVValue hsv);
|
||||
DocDeclStr(
|
||||
static wxImage_HSVValue , RGBtoHSV(wxImage_RGBValue rgb),
|
||||
"Converts a color in RGB color space to HSV color space.", "");
|
||||
|
||||
DocDeclStr(
|
||||
static wxImage_RGBValue , HSVtoRGB(wxImage_HSVValue hsv),
|
||||
"Converts a color in HSV color space to RGB color space.", "");
|
||||
|
||||
|
||||
%pythoncode { def __nonzero__(self): return self.Ok() }
|
||||
};
|
||||
|
@@ -693,6 +693,9 @@ details in the second return value (see wx.LIST_HITTEST flags.)", "");
|
||||
void SetItemBackgroundColour( long item, const wxColour &col);
|
||||
wxColour GetItemBackgroundColour( long item ) const;
|
||||
|
||||
// Font of an item.
|
||||
void SetItemFont( long item, const wxFont &f);
|
||||
wxFont GetItemFont( long item ) const;
|
||||
|
||||
%pythoncode {
|
||||
%#
|
||||
|
@@ -318,14 +318,14 @@ static wxPySizerItemInfo wxPySizerItemTypeHelper(PyObject* item, bool checkSize,
|
||||
if ( !(info.window || info.sizer || (checkSize && info.gotSize) || (checkIdx && info.gotPos)) ) {
|
||||
// no expected type, figure out what kind of error message to generate
|
||||
if ( !checkSize && !checkIdx )
|
||||
PyErr_SetString(PyExc_TypeError, "wxWindow or wxSizer expected for item");
|
||||
PyErr_SetString(PyExc_TypeError, "wx.Window or wx.Sizer expected for item");
|
||||
else if ( checkSize && !checkIdx )
|
||||
PyErr_SetString(PyExc_TypeError, "wxWindow, wxSizer, wxSize, or (w,h) expected for item");
|
||||
PyErr_SetString(PyExc_TypeError, "wx.Window, wx.Sizer, wx.Size, or (w,h) expected for item");
|
||||
else if ( !checkSize && checkIdx)
|
||||
PyErr_SetString(PyExc_TypeError, "wxWindow, wxSizer or int (position) expected for item");
|
||||
PyErr_SetString(PyExc_TypeError, "wx.Window, wx.Sizer or int (position) expected for item");
|
||||
else
|
||||
// can this one happen?
|
||||
PyErr_SetString(PyExc_TypeError, "wxWindow, wxSizer, wxSize, or (w,h) or int (position) expected for item");
|
||||
PyErr_SetString(PyExc_TypeError, "wx.Window, wx.Sizer, wx.Size, or (w,h) or int (position) expected for item");
|
||||
}
|
||||
|
||||
return info;
|
||||
|
@@ -114,6 +114,14 @@ public:
|
||||
long style = 0,
|
||||
const wxString& name = wxPyStaticTextNameStr);
|
||||
|
||||
DocDeclStr(
|
||||
void , Wrap(int width),
|
||||
"This functions wraps the control's label so that each of its lines
|
||||
becomes at most ``width`` pixels wide if possible (the lines are
|
||||
broken at words boundaries so it might not be the case if words are
|
||||
too long). If ``width`` is negative, no wrapping is done.", "");
|
||||
|
||||
|
||||
static wxVisualAttributes
|
||||
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
|
||||
};
|
||||
|
@@ -436,13 +436,13 @@ window's *best size* values. Also set's the minsize for use with sizers.", "");
|
||||
|
||||
DocDeclStr(
|
||||
virtual void , Raise(),
|
||||
"Raises the window to the top of the window hierarchy if it is a
|
||||
managed window (dialog or frame).", "");
|
||||
"Raises the window to the top of the window hierarchy. In current
|
||||
version of wxWidgets this works both for manage and child windows.", "");
|
||||
|
||||
DocDeclStr(
|
||||
virtual void , Lower(),
|
||||
"Lowers the window to the bottom of the window hierarchy if it is a
|
||||
managed window (dialog or frame).", "");
|
||||
"Lowers the window to the bottom of the window hierarchy. In current
|
||||
version of wxWidgets this works both for manage and child windows.", "");
|
||||
|
||||
|
||||
|
||||
@@ -2060,7 +2060,8 @@ wxWindow* wxFindWindowByLabel( const wxString& label,
|
||||
WXHWND hWnd = (WXHWND)_hWnd;
|
||||
long id = wxGetWindowId(hWnd);
|
||||
wxWindow* win = new wxWindow;
|
||||
parent->AddChild(win);
|
||||
if (parent)
|
||||
parent->AddChild(win);
|
||||
win->SetEventHandler(win);
|
||||
win->SetHWND(hWnd);
|
||||
win->SetId(id);
|
||||
|
@@ -91,6 +91,9 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// Unload resource from the given XML file (wildcards not allowed)
|
||||
bool Unload(const wxString& filename);
|
||||
|
||||
// Initialize handlers for all supported controls/windows.
|
||||
void InitAllHandlers();
|
||||
|
||||
|
@@ -701,21 +701,6 @@ PyObject* __wxPySetDictionary(PyObject* /* self */, PyObject* args)
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// Python's PyInstance_Check does not return True for instances of new-style
|
||||
// classes. This should get close enough for both new and old classes but I
|
||||
// should re-evaluate the need for doing instance checks...
|
||||
bool wxPyInstance_Check(PyObject* obj) {
|
||||
return PyObject_HasAttrString(obj, "__class__") != 0;
|
||||
}
|
||||
|
||||
|
||||
// This one checks if the object is an instance of a SWIG proxy class (it has
|
||||
// a .this attribute)
|
||||
bool wxPySwigInstance_Check(PyObject* obj) {
|
||||
return PyObject_HasAttrString(obj, "this") != 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -2725,6 +2710,145 @@ PyObject* wxArrayInt2PyList_helper(const wxArrayInt& arr) {
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// wxPyImageHandler methods
|
||||
//
|
||||
// TODO: Switch these to use wxPython's standard macros and helper classes
|
||||
// for calling callbacks.
|
||||
|
||||
PyObject* wxPyImageHandler::m_DoCanRead_Name = NULL;
|
||||
PyObject* wxPyImageHandler::m_GetImageCount_Name = NULL;
|
||||
PyObject* wxPyImageHandler::m_LoadFile_Name = NULL;
|
||||
PyObject* wxPyImageHandler::m_SaveFile_Name = NULL;
|
||||
|
||||
PyObject* wxPyImageHandler::py_InputStream(wxInputStream* stream) {
|
||||
return wxPyConstructObject(new wxPyInputStream(stream),
|
||||
wxT("wxPyInputStream"), 0);
|
||||
}
|
||||
|
||||
PyObject* wxPyImageHandler::py_Image(wxImage* image) {
|
||||
return wxPyConstructObject(image, wxT("wxImage"), 0);
|
||||
}
|
||||
|
||||
PyObject* wxPyImageHandler::py_OutputStream(wxOutputStream* stream) {
|
||||
return wxPyConstructObject(stream, wxT("wxOutputStream"), 0);
|
||||
}
|
||||
|
||||
wxPyImageHandler::wxPyImageHandler():
|
||||
m_self(NULL)
|
||||
{
|
||||
if (!m_DoCanRead_Name) {
|
||||
m_DoCanRead_Name = PyString_FromString("DoCanRead");
|
||||
m_GetImageCount_Name = PyString_FromString("GetImageCount");
|
||||
m_LoadFile_Name = PyString_FromString("LoadFile");
|
||||
m_SaveFile_Name = PyString_FromString("SaveFile");
|
||||
}
|
||||
}
|
||||
|
||||
wxPyImageHandler::~wxPyImageHandler() {
|
||||
if (m_self) {
|
||||
Py_DECREF(m_self);
|
||||
m_self = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void wxPyImageHandler::_SetSelf(PyObject *self) {
|
||||
// should check here for isinstance(PyImageHandler) ??
|
||||
m_self = self;
|
||||
Py_INCREF(m_self);
|
||||
}
|
||||
|
||||
bool wxPyImageHandler::DoCanRead(wxInputStream& stream) {
|
||||
// check if our object has this method
|
||||
wxPyBlock_t blocked = wxPyBeginBlockThreads();
|
||||
if (!m_self || !PyObject_HasAttr(m_self, m_DoCanRead_Name)) {
|
||||
wxPyEndBlockThreads(blocked);
|
||||
return false;
|
||||
}
|
||||
|
||||
PyObject* res = PyObject_CallMethodObjArgs(m_self, m_DoCanRead_Name,
|
||||
py_InputStream(&stream), NULL);
|
||||
bool retval = false;
|
||||
if (res) {
|
||||
retval = PyInt_AsLong(res);
|
||||
Py_DECREF(res);
|
||||
PyErr_Clear();
|
||||
}
|
||||
else
|
||||
PyErr_Print();
|
||||
wxPyEndBlockThreads(blocked);
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool wxPyImageHandler::LoadFile( wxImage* image, wxInputStream& stream,
|
||||
bool verbose, int index ) {
|
||||
// check if our object has this method
|
||||
wxPyBlock_t blocked = wxPyBeginBlockThreads();
|
||||
if (!m_self || !PyObject_HasAttr(m_self, m_LoadFile_Name)) {
|
||||
wxPyEndBlockThreads(blocked);
|
||||
return false;
|
||||
}
|
||||
PyObject* res = PyObject_CallMethodObjArgs(m_self, m_LoadFile_Name,
|
||||
py_Image(image),
|
||||
py_InputStream(&stream),
|
||||
PyInt_FromLong(verbose),
|
||||
PyInt_FromLong(index),
|
||||
NULL);
|
||||
bool retval = false;
|
||||
if (res) {
|
||||
retval = PyInt_AsLong(res);
|
||||
Py_DECREF(res);
|
||||
PyErr_Clear();
|
||||
} else
|
||||
PyErr_Print();
|
||||
wxPyEndBlockThreads(blocked);
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool wxPyImageHandler::SaveFile( wxImage* image, wxOutputStream& stream,
|
||||
bool verbose ) {
|
||||
wxPyBlock_t blocked = wxPyBeginBlockThreads();
|
||||
if (!m_self || !PyObject_HasAttr(m_self, m_SaveFile_Name)) {
|
||||
wxPyEndBlockThreads(blocked);
|
||||
return false;
|
||||
}
|
||||
PyObject* res = PyObject_CallMethodObjArgs(m_self, m_SaveFile_Name,
|
||||
py_Image(image),
|
||||
py_OutputStream(&stream),
|
||||
PyInt_FromLong(verbose),
|
||||
NULL);
|
||||
bool retval = false;
|
||||
if(res) {
|
||||
retval=PyInt_AsLong(res);
|
||||
Py_DECREF(res);
|
||||
PyErr_Clear();
|
||||
} else
|
||||
PyErr_Print();
|
||||
wxPyEndBlockThreads(blocked);
|
||||
return retval;
|
||||
}
|
||||
|
||||
int wxPyImageHandler::GetImageCount( wxInputStream& stream ) {
|
||||
wxPyBlock_t blocked = wxPyBeginBlockThreads();
|
||||
if (!m_self || !PyObject_HasAttr(m_self, m_GetImageCount_Name)) {
|
||||
wxPyEndBlockThreads(blocked);
|
||||
return 1;
|
||||
}
|
||||
PyObject *res=PyObject_CallMethodObjArgs(m_self, m_GetImageCount_Name,
|
||||
py_InputStream(&stream),
|
||||
NULL);
|
||||
int retval = 1;
|
||||
if(res) {
|
||||
retval=PyInt_AsLong(res);
|
||||
Py_DECREF(res);
|
||||
PyErr_Clear();
|
||||
} else
|
||||
PyErr_Print();
|
||||
wxPyEndBlockThreads(blocked);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
@@ -55,7 +55,15 @@ enum wxMediaState
|
||||
wxMEDIASTATE_PLAYING=0
|
||||
};
|
||||
|
||||
enum wxMediaCtrlPlayerControls
|
||||
{
|
||||
wxMEDIACTRLPLAYERCONTROLS_NONE,
|
||||
wxMEDIACTRLPLAYERCONTROLS_STEP,
|
||||
wxMEDIACTRLPLAYERCONTROLS_VOLUME,
|
||||
wxMEDIACTRLPLAYERCONTROLS_DEFAULT
|
||||
};
|
||||
|
||||
|
||||
class wxMediaEvent : public wxNotifyEvent
|
||||
{
|
||||
public:
|
||||
@@ -89,9 +97,6 @@ public:
|
||||
bool Pause() { return false; }
|
||||
bool Stop() { return false; }
|
||||
|
||||
bool Load(const wxString& fileName) { return false; }
|
||||
bool Load(const wxURI& location) { return false; }
|
||||
|
||||
wxMediaState GetState() { return wxMEDIASTATE_STOPPED; }
|
||||
|
||||
double GetPlaybackRate() { return 0.0; }
|
||||
@@ -105,6 +110,14 @@ public:
|
||||
|
||||
double GetVolume() { return 0.0; }
|
||||
bool SetVolume(double dVolume) { return false; }
|
||||
|
||||
bool ShowPlayerControls(
|
||||
wxMediaCtrlPlayerControls flags = wxMEDIACTRLPLAYERCONTROLS_DEFAULT)
|
||||
{ return false; }
|
||||
|
||||
bool Load(const wxString& fileName) { return false; }
|
||||
bool LoadURI(const wxString& fileName) { return false; }
|
||||
bool LoadURIWithProxy(const wxString& fileName, const wxString& proxy) { return false; }
|
||||
};
|
||||
|
||||
const wxEventType wxEVT_MEDIA_FINISHED = 0;
|
||||
@@ -180,16 +193,6 @@ public:
|
||||
bool Pause();
|
||||
bool Stop();
|
||||
|
||||
double GetVolume(); //DirectShow only
|
||||
bool SetVolume(double dVolume); //DirectShow only
|
||||
|
||||
bool Load(const wxString& fileName);
|
||||
%extend {
|
||||
bool LoadFromURI(const wxString& location) {
|
||||
return self->Load(wxURI(location));
|
||||
}
|
||||
}
|
||||
|
||||
wxMediaState GetState();
|
||||
|
||||
double GetPlaybackRate();
|
||||
@@ -198,6 +201,17 @@ public:
|
||||
wxFileOffset Seek(wxFileOffset where, wxSeekMode mode = wxFromStart);
|
||||
wxFileOffset Tell();
|
||||
wxFileOffset Length();
|
||||
|
||||
double GetVolume();
|
||||
bool SetVolume(double dVolume);
|
||||
|
||||
bool ShowPlayerControls(
|
||||
wxMediaCtrlPlayerControls flags = wxMEDIACTRLPLAYERCONTROLS_DEFAULT);
|
||||
|
||||
bool Load(const wxString& fileName);
|
||||
bool LoadURI(const wxString& fileName);
|
||||
bool LoadURIWithProxy(const wxString& fileName, const wxString& proxy);
|
||||
%pythoncode { LoadFromURI = LoadURI }
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user